author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Thu, 13 Mar 2008 12:56:49 -0700 | |
changeset 2602 | d9262bff6df2 |
parent 2600 | 6c389d0c717d |
child 2608 | 408589d1dfff |
permissions | -rw-r--r-- |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
1 |
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
2 |
/* |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
3 |
* Copyright (c) 2005 INRIA |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
4 |
* All rights reserved. |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
5 |
* |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
6 |
* This program is free software; you can redistribute it and/or modify |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
7 |
* it under the terms of the GNU General Public License version 2 as |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
8 |
* published by the Free Software Foundation; |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
9 |
* |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
10 |
* This program is distributed in the hope that it will be useful, |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
13 |
* GNU General Public License for more details. |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
14 |
* |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
16 |
* along with this program; if not, write to the Free Software |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
17 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
18 |
* |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
19 |
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
20 |
*/ |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
21 |
|
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
22 |
#include "ns3/log.h" |
286
57e6a2006962
convert use of <cassert> to "ns3/assert.h"
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
241
diff
changeset
|
23 |
#include "ns3/assert.h" |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
24 |
#include "ns3/packet.h" |
729
b5e744285e92
rename i-node to node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
728
diff
changeset
|
25 |
#include "ns3/node.h" |
345
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
295
diff
changeset
|
26 |
|
741
38ebb2fb16f5
udp.h -> udp-l4-protocol.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
738
diff
changeset
|
27 |
#include "udp-l4-protocol.h" |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
28 |
#include "udp-header.h" |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
29 |
#include "ipv4-end-point-demux.h" |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
30 |
#include "ipv4-end-point.h" |
733
fb1882e7d785
rename ipv4.h to ipv4-l3-protocol.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
732
diff
changeset
|
31 |
#include "ipv4-l3-protocol.h" |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
348
diff
changeset
|
32 |
#include "udp-socket.h" |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
33 |
|
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
34 |
NS_LOG_COMPONENT_DEFINE ("UdpL4Protocol"); |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1176
diff
changeset
|
35 |
|
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
36 |
namespace ns3 { |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
37 |
|
2501
3eaeac1dd5ed
add missing NS_OBJECT_ENSURE_REGISTERED calls.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2498
diff
changeset
|
38 |
NS_OBJECT_ENSURE_REGISTERED (UdpL4Protocol); |
3eaeac1dd5ed
add missing NS_OBJECT_ENSURE_REGISTERED calls.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2498
diff
changeset
|
39 |
|
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
40 |
/* see http://www.iana.org/assignments/protocol-numbers */ |
742
b73f8e30c75e
Udp -> UdpL4Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
741
diff
changeset
|
41 |
const uint8_t UdpL4Protocol::PROT_NUMBER = 17; |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
42 |
|
2498
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
43 |
TypeId |
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
44 |
UdpL4Protocol::GetTypeId (void) |
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
45 |
{ |
2602
d9262bff6df2
add back support for introspected doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2600
diff
changeset
|
46 |
static TypeId tid = TypeId ("ns3::UdpL4Protocol") |
2498
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
47 |
.SetParent<Ipv4L4Protocol> () |
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
48 |
.AddConstructor<UdpL4Protocol> () |
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
49 |
; |
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
50 |
return tid; |
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
51 |
} |
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
52 |
|
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
53 |
UdpL4Protocol::UdpL4Protocol () |
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
54 |
: m_endPoints (new Ipv4EndPointDemux ()) |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1176
diff
changeset
|
55 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
56 |
NS_LOG_FUNCTION; |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1176
diff
changeset
|
57 |
} |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
58 |
|
742
b73f8e30c75e
Udp -> UdpL4Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
741
diff
changeset
|
59 |
UdpL4Protocol::~UdpL4Protocol () |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1176
diff
changeset
|
60 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
61 |
NS_LOG_FUNCTION; |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1176
diff
changeset
|
62 |
} |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
63 |
|
2592
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
64 |
void |
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
65 |
UdpL4Protocol::SetNode (Ptr<Node> node) |
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
66 |
{ |
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
67 |
m_node = node; |
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
68 |
} |
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
69 |
|
2498
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
70 |
int |
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
71 |
UdpL4Protocol::GetProtocolNumber (void) const |
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
72 |
{ |
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
73 |
return PROT_NUMBER; |
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
74 |
} |
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
75 |
int |
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
76 |
UdpL4Protocol::GetVersion (void) const |
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
77 |
{ |
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
78 |
return 2; |
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
79 |
} |
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
80 |
|
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
81 |
|
496
894c8380d57b
use Dispose more extensively
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
495
diff
changeset
|
82 |
void |
742
b73f8e30c75e
Udp -> UdpL4Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
741
diff
changeset
|
83 |
UdpL4Protocol::DoDispose (void) |
496
894c8380d57b
use Dispose more extensively
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
495
diff
changeset
|
84 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
85 |
NS_LOG_FUNCTION; |
496
894c8380d57b
use Dispose more extensively
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
495
diff
changeset
|
86 |
if (m_endPoints != 0) |
894c8380d57b
use Dispose more extensively
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
495
diff
changeset
|
87 |
{ |
894c8380d57b
use Dispose more extensively
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
495
diff
changeset
|
88 |
delete m_endPoints; |
894c8380d57b
use Dispose more extensively
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
495
diff
changeset
|
89 |
m_endPoints = 0; |
894c8380d57b
use Dispose more extensively
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
495
diff
changeset
|
90 |
} |
557
927a5bb6432a
convert UdpSocket and Udp to Ptr<Node>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
524
diff
changeset
|
91 |
m_node = 0; |
513
b7c7ea629de9
make L3Demux an NsUnknown object.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
504
diff
changeset
|
92 |
Ipv4L4Protocol::DoDispose (); |
496
894c8380d57b
use Dispose more extensively
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
495
diff
changeset
|
93 |
} |
894c8380d57b
use Dispose more extensively
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
495
diff
changeset
|
94 |
|
568
e1660959ecbb
use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
567
diff
changeset
|
95 |
Ptr<Socket> |
742
b73f8e30c75e
Udp -> UdpL4Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
741
diff
changeset
|
96 |
UdpL4Protocol::CreateSocket (void) |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
348
diff
changeset
|
97 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
98 |
NS_LOG_FUNCTION; |
2592
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
99 |
Ptr<UdpSocket> socket = CreateObject<UdpSocket> (); |
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
100 |
socket->SetNode (m_node); |
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
101 |
socket->SetUdp (this); |
567
6fb98941c36f
remove leaks and rework the Ptr class to work with a new refcount mechanism
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
557
diff
changeset
|
102 |
return socket; |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
348
diff
changeset
|
103 |
} |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
348
diff
changeset
|
104 |
|
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
105 |
Ipv4EndPoint * |
742
b73f8e30c75e
Udp -> UdpL4Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
741
diff
changeset
|
106 |
UdpL4Protocol::Allocate (void) |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
107 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
108 |
NS_LOG_FUNCTION; |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
109 |
return m_endPoints->Allocate (); |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
110 |
} |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1176
diff
changeset
|
111 |
|
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
112 |
Ipv4EndPoint * |
2326
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2257
diff
changeset
|
113 |
UdpL4Protocol::Allocate (Ipv4Address address, Ipv4Address localInterface) |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
114 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
115 |
NS_LOG_FUNCTION; |
1828
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1524
diff
changeset
|
116 |
NS_LOG_PARAMS (this << address); |
2326
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2257
diff
changeset
|
117 |
return m_endPoints->Allocate (address, localInterface); |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
118 |
} |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1176
diff
changeset
|
119 |
|
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
120 |
Ipv4EndPoint * |
742
b73f8e30c75e
Udp -> UdpL4Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
741
diff
changeset
|
121 |
UdpL4Protocol::Allocate (uint16_t port) |
240
7da682f99bf9
add non-debugged udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
238
diff
changeset
|
122 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
123 |
NS_LOG_FUNCTION; |
1828
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1524
diff
changeset
|
124 |
NS_LOG_PARAMS (this << port); |
240
7da682f99bf9
add non-debugged udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
238
diff
changeset
|
125 |
return m_endPoints->Allocate (port); |
7da682f99bf9
add non-debugged udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
238
diff
changeset
|
126 |
} |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1176
diff
changeset
|
127 |
|
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
128 |
Ipv4EndPoint * |
2326
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2257
diff
changeset
|
129 |
UdpL4Protocol::Allocate (Ipv4Address address, uint16_t port, Ipv4Address localInterface) |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
130 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
131 |
NS_LOG_FUNCTION; |
1828
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1524
diff
changeset
|
132 |
NS_LOG_PARAMS (this << address << port); |
2326
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2257
diff
changeset
|
133 |
return m_endPoints->Allocate (address, port, localInterface); |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
134 |
} |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
135 |
Ipv4EndPoint * |
742
b73f8e30c75e
Udp -> UdpL4Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
741
diff
changeset
|
136 |
UdpL4Protocol::Allocate (Ipv4Address localAddress, uint16_t localPort, |
2326
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2257
diff
changeset
|
137 |
Ipv4Address peerAddress, uint16_t peerPort, |
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2257
diff
changeset
|
138 |
Ipv4Address localInterface) |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
139 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
140 |
NS_LOG_FUNCTION; |
1828
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1524
diff
changeset
|
141 |
NS_LOG_PARAMS (this << localAddress << localPort << peerAddress << peerPort); |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
142 |
return m_endPoints->Allocate (localAddress, localPort, |
2326
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2257
diff
changeset
|
143 |
peerAddress, peerPort, localInterface); |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
144 |
} |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
145 |
|
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
146 |
void |
742
b73f8e30c75e
Udp -> UdpL4Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
741
diff
changeset
|
147 |
UdpL4Protocol::DeAllocate (Ipv4EndPoint *endPoint) |
515
e907146a191e
fix valgrind warning: UdpSocket must manage carefully its Ipv4EndPoint to avoid double deleting it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
513
diff
changeset
|
148 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
149 |
NS_LOG_FUNCTION; |
1828
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1524
diff
changeset
|
150 |
NS_LOG_PARAMS (this << endPoint); |
515
e907146a191e
fix valgrind warning: UdpSocket must manage carefully its Ipv4EndPoint to avoid double deleting it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
513
diff
changeset
|
151 |
m_endPoints->DeAllocate (endPoint); |
e907146a191e
fix valgrind warning: UdpSocket must manage carefully its Ipv4EndPoint to avoid double deleting it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
513
diff
changeset
|
152 |
} |
e907146a191e
fix valgrind warning: UdpSocket must manage carefully its Ipv4EndPoint to avoid double deleting it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
513
diff
changeset
|
153 |
|
e907146a191e
fix valgrind warning: UdpSocket must manage carefully its Ipv4EndPoint to avoid double deleting it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
513
diff
changeset
|
154 |
void |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
155 |
UdpL4Protocol::Receive(Ptr<Packet> packet, |
1524
3ead2b66f2e4
Fix a regression in handling of broadcast packets and UDP sockets (closes bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1504
diff
changeset
|
156 |
Ipv4Address const &source, |
3ead2b66f2e4
Fix a regression in handling of broadcast packets and UDP sockets (closes bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1504
diff
changeset
|
157 |
Ipv4Address const &destination, |
3ead2b66f2e4
Fix a regression in handling of broadcast packets and UDP sockets (closes bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1504
diff
changeset
|
158 |
Ptr<Ipv4Interface> interface) |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
159 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
160 |
NS_LOG_FUNCTION; |
1870 | 161 |
NS_LOG_PARAMS (this << packet << source << destination); |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1176
diff
changeset
|
162 |
|
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
163 |
UdpHeader udpHeader; |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
164 |
packet->RemoveHeader (udpHeader); |
984
3202c053eacc
Allow UDP sockets to receive broadcast (bug #51)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
746
diff
changeset
|
165 |
Ipv4EndPointDemux::EndPoints endPoints = |
3202c053eacc
Allow UDP sockets to receive broadcast (bug #51)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
746
diff
changeset
|
166 |
m_endPoints->Lookup (destination, udpHeader.GetDestination (), |
1524
3ead2b66f2e4
Fix a regression in handling of broadcast packets and UDP sockets (closes bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1504
diff
changeset
|
167 |
source, udpHeader.GetSource (), interface); |
984
3202c053eacc
Allow UDP sockets to receive broadcast (bug #51)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
746
diff
changeset
|
168 |
for (Ipv4EndPointDemux::EndPointsI endPoint = endPoints.begin (); |
3202c053eacc
Allow UDP sockets to receive broadcast (bug #51)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
746
diff
changeset
|
169 |
endPoint != endPoints.end (); endPoint++) |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
170 |
{ |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
171 |
(*endPoint)->ForwardUp (packet->Copy (), source, udpHeader.GetSource ()); |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
172 |
} |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
173 |
} |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
174 |
|
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
175 |
void |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
176 |
UdpL4Protocol::Send (Ptr<Packet> packet, |
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
177 |
Ipv4Address saddr, Ipv4Address daddr, |
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
178 |
uint16_t sport, uint16_t dport) |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
179 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
180 |
NS_LOG_FUNCTION; |
1870 | 181 |
NS_LOG_PARAMS (this << packet << saddr << daddr << sport << dport); |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1176
diff
changeset
|
182 |
|
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
183 |
UdpHeader udpHeader; |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
184 |
udpHeader.SetDestination (dport); |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
185 |
udpHeader.SetSource (sport); |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
186 |
udpHeader.SetPayloadSize (packet->GetSize ()); |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
187 |
udpHeader.InitializeChecksum (saddr, |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
188 |
daddr, |
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
189 |
PROT_NUMBER); |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
190 |
|
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
191 |
packet->AddHeader (udpHeader); |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
192 |
|
2257
71a58e70c671
QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2231
diff
changeset
|
193 |
Ptr<Ipv4L3Protocol> ipv4 = m_node->GetObject<Ipv4L3Protocol> (); |
241
9004ab4cfe17
add Ipv4 and Udp node capabilities, rework Copy methods to include an extra Node * argument
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
240
diff
changeset
|
194 |
if (ipv4 != 0) |
240
7da682f99bf9
add non-debugged udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
238
diff
changeset
|
195 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
196 |
NS_LOG_LOGIC ("Sending to IP"); |
295
5fc7ae0d0300
remove UdpIpv4L4Protocol class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
286
diff
changeset
|
197 |
ipv4->Send (packet, saddr, daddr, PROT_NUMBER); |
240
7da682f99bf9
add non-debugged udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
238
diff
changeset
|
198 |
} |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
199 |
} |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
200 |
|
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
201 |
|
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
202 |
}; // namespace ns3 |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
203 |