author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Mon, 01 Oct 2007 14:15:56 +0200 | |
changeset 1866 | e7dbcc4df546 |
parent 1524 | 3ead2b66f2e4 |
child 1870 | 67b3d2dea3d5 |
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 |
|
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
38 |
/* see http://www.iana.org/assignments/protocol-numbers */ |
742
b73f8e30c75e
Udp -> UdpL4Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
741
diff
changeset
|
39 |
const uint8_t UdpL4Protocol::PROT_NUMBER = 17; |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
40 |
|
742
b73f8e30c75e
Udp -> UdpL4Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
741
diff
changeset
|
41 |
UdpL4Protocol::UdpL4Protocol (Ptr<Node> node) |
295
5fc7ae0d0300
remove UdpIpv4L4Protocol class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
286
diff
changeset
|
42 |
: Ipv4L4Protocol (PROT_NUMBER, 2), |
5fc7ae0d0300
remove UdpIpv4L4Protocol class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
286
diff
changeset
|
43 |
m_node (node), |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
44 |
m_endPoints (new Ipv4EndPointDemux ()) |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1176
diff
changeset
|
45 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
46 |
NS_LOG_FUNCTION; |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1176
diff
changeset
|
47 |
} |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
48 |
|
742
b73f8e30c75e
Udp -> UdpL4Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
741
diff
changeset
|
49 |
UdpL4Protocol::~UdpL4Protocol () |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1176
diff
changeset
|
50 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
51 |
NS_LOG_FUNCTION; |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1176
diff
changeset
|
52 |
} |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
53 |
|
496
894c8380d57b
use Dispose more extensively
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
495
diff
changeset
|
54 |
void |
742
b73f8e30c75e
Udp -> UdpL4Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
741
diff
changeset
|
55 |
UdpL4Protocol::DoDispose (void) |
496
894c8380d57b
use Dispose more extensively
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
495
diff
changeset
|
56 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
57 |
NS_LOG_FUNCTION; |
496
894c8380d57b
use Dispose more extensively
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
495
diff
changeset
|
58 |
if (m_endPoints != 0) |
894c8380d57b
use Dispose more extensively
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
495
diff
changeset
|
59 |
{ |
894c8380d57b
use Dispose more extensively
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
495
diff
changeset
|
60 |
delete m_endPoints; |
894c8380d57b
use Dispose more extensively
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
495
diff
changeset
|
61 |
m_endPoints = 0; |
894c8380d57b
use Dispose more extensively
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
495
diff
changeset
|
62 |
} |
557
927a5bb6432a
convert UdpSocket and Udp to Ptr<Node>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
524
diff
changeset
|
63 |
m_node = 0; |
513
b7c7ea629de9
make L3Demux an NsUnknown object.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
504
diff
changeset
|
64 |
Ipv4L4Protocol::DoDispose (); |
496
894c8380d57b
use Dispose more extensively
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
495
diff
changeset
|
65 |
} |
894c8380d57b
use Dispose more extensively
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
495
diff
changeset
|
66 |
|
568
e1660959ecbb
use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
567
diff
changeset
|
67 |
Ptr<Socket> |
742
b73f8e30c75e
Udp -> UdpL4Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
741
diff
changeset
|
68 |
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
|
69 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
70 |
NS_LOG_FUNCTION; |
732
df256f32b6ae
rename MakeNewObject to Create
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
71 |
Ptr<Socket> socket = Create<UdpSocket> (m_node, 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
|
72 |
return socket; |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
348
diff
changeset
|
73 |
} |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
348
diff
changeset
|
74 |
|
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
75 |
Ipv4EndPoint * |
742
b73f8e30c75e
Udp -> UdpL4Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
741
diff
changeset
|
76 |
UdpL4Protocol::Allocate (void) |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
77 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
78 |
NS_LOG_FUNCTION; |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
79 |
return m_endPoints->Allocate (); |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
80 |
} |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1176
diff
changeset
|
81 |
|
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
82 |
Ipv4EndPoint * |
742
b73f8e30c75e
Udp -> UdpL4Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
741
diff
changeset
|
83 |
UdpL4Protocol::Allocate (Ipv4Address address) |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
84 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
85 |
NS_LOG_FUNCTION; |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
86 |
NS_LOG_PARAM ("(" << address << ")"); |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
87 |
return m_endPoints->Allocate (address); |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
88 |
} |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1176
diff
changeset
|
89 |
|
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
90 |
Ipv4EndPoint * |
742
b73f8e30c75e
Udp -> UdpL4Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
741
diff
changeset
|
91 |
UdpL4Protocol::Allocate (uint16_t port) |
240
7da682f99bf9
add non-debugged udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
238
diff
changeset
|
92 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
93 |
NS_LOG_FUNCTION; |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
94 |
NS_LOG_PARAM ("(" << port << ")"); |
240
7da682f99bf9
add non-debugged udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
238
diff
changeset
|
95 |
return m_endPoints->Allocate (port); |
7da682f99bf9
add non-debugged udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
238
diff
changeset
|
96 |
} |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1176
diff
changeset
|
97 |
|
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
98 |
Ipv4EndPoint * |
742
b73f8e30c75e
Udp -> UdpL4Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
741
diff
changeset
|
99 |
UdpL4Protocol::Allocate (Ipv4Address address, uint16_t port) |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
100 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
101 |
NS_LOG_FUNCTION; |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
102 |
NS_LOG_PARAM ("(" << address << ", " << port << ")"); |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
103 |
return m_endPoints->Allocate (address, port); |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
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 (Ipv4Address localAddress, uint16_t localPort, |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
107 |
Ipv4Address peerAddress, uint16_t peerPort) |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
108 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
109 |
NS_LOG_FUNCTION; |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
110 |
NS_LOG_PARAM ("(" << localAddress << ", " << localPort << ", " << |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
111 |
peerAddress << ", " << peerPort << ")"); |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
112 |
return m_endPoints->Allocate (localAddress, localPort, |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
113 |
peerAddress, peerPort); |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
114 |
} |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
115 |
|
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
116 |
void |
742
b73f8e30c75e
Udp -> UdpL4Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
741
diff
changeset
|
117 |
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
|
118 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
119 |
NS_LOG_FUNCTION; |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
120 |
NS_LOG_PARAM ("(" << 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
|
121 |
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
|
122 |
} |
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
|
123 |
|
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
|
124 |
void |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
125 |
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
|
126 |
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
|
127 |
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
|
128 |
Ptr<Ipv4Interface> interface) |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
129 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
130 |
NS_LOG_FUNCTION; |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
131 |
NS_LOG_PARAM ("(" << packet << ", " << source << ", " << destination << |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
132 |
")"); |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1176
diff
changeset
|
133 |
|
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
134 |
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
|
135 |
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
|
136 |
Ipv4EndPointDemux::EndPoints endPoints = |
3202c053eacc
Allow UDP sockets to receive broadcast (bug #51)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
746
diff
changeset
|
137 |
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
|
138 |
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
|
139 |
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
|
140 |
endPoint != endPoints.end (); endPoint++) |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
141 |
{ |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
142 |
(*endPoint)->ForwardUp (packet->Copy (), source, udpHeader.GetSource ()); |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
143 |
} |
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 |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
147 |
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
|
148 |
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
|
149 |
uint16_t sport, uint16_t dport) |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
150 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
151 |
NS_LOG_FUNCTION; |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
152 |
NS_LOG_PARAM ("(" << packet << ", " << saddr << ", " << daddr << ", " << |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
153 |
sport << ", " << dport << ")"); |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1176
diff
changeset
|
154 |
|
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
155 |
UdpHeader udpHeader; |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
156 |
udpHeader.SetDestination (dport); |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
157 |
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
|
158 |
udpHeader.SetPayloadSize (packet->GetSize ()); |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
159 |
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
|
160 |
daddr, |
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
161 |
PROT_NUMBER); |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
162 |
|
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
163 |
packet->AddHeader (udpHeader); |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
164 |
|
1176
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
984
diff
changeset
|
165 |
Ptr<Ipv4L3Protocol> ipv4 = m_node->QueryInterface<Ipv4L3Protocol> (Ipv4L3Protocol::iid); |
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
|
166 |
if (ipv4 != 0) |
240
7da682f99bf9
add non-debugged udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
238
diff
changeset
|
167 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
168 |
NS_LOG_LOGIC ("Sending to IP"); |
295
5fc7ae0d0300
remove UdpIpv4L4Protocol class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
286
diff
changeset
|
169 |
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
|
170 |
} |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
171 |
} |
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 |
}; // namespace ns3 |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
175 |