author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Thu, 13 Mar 2008 11:10:38 -0700 | |
changeset 2600 | 6c389d0c717d |
parent 2592 | 3ebf97150166 |
child 2608 | 408589d1dfff |
permissions | -rw-r--r-- |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
1 |
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
2 |
/* |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
3 |
* Copyright (c) 2007 INRIA |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
4 |
* All rights reserved. |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
5 |
* |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
6 |
* This program is free software; you can redistribute it and/or modify |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
7 |
* it under the terms of the GNU General Public License version 2 as |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
8 |
* published by the Free Software Foundation; |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
9 |
* |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
10 |
* This program is distributed in the hope that it will be useful, |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
13 |
* GNU General Public License for more details. |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
14 |
* |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
16 |
* along with this program; if not, write to the Free Software |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
17 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
18 |
* |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
19 |
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
20 |
*/ |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1270
diff
changeset
|
21 |
|
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1452
diff
changeset
|
22 |
#include "ns3/log.h" |
729
b5e744285e92
rename i-node to node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
728
diff
changeset
|
23 |
#include "ns3/node.h" |
1171
335886fe4ddd
InetAddress -> InetSocketAddress
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1164
diff
changeset
|
24 |
#include "ns3/inet-socket-address.h" |
1317
82629189efff
Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents:
1308
diff
changeset
|
25 |
#include "ns3/ipv4-route.h" |
82629189efff
Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents:
1308
diff
changeset
|
26 |
#include "ns3/ipv4.h" |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
27 |
#include "udp-socket.h" |
741
38ebb2fb16f5
udp.h -> udp-l4-protocol.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
28 |
#include "udp-l4-protocol.h" |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
29 |
#include "ipv4-end-point.h" |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
30 |
#include "ipv4-l4-demux.h" |
1434
2b63aafb050b
set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents:
1429
diff
changeset
|
31 |
#include "ns3/ipv4.h" |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
32 |
|
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1452
diff
changeset
|
33 |
NS_LOG_COMPONENT_DEFINE ("UdpSocket"); |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
34 |
|
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
35 |
namespace ns3 { |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
36 |
|
2592
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2574
diff
changeset
|
37 |
UdpSocket::UdpSocket () |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
38 |
: m_endPoint (0), |
2592
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2574
diff
changeset
|
39 |
m_node (0), |
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2574
diff
changeset
|
40 |
m_udp (0), |
646
f7475a7c5ae6
Rename the SocketErrno enumeration values, from ESOMETHING to ERROR_SOMETHING, to avoid conflict with errno #define's; fixes compilation in mingw32.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
607
diff
changeset
|
41 |
m_errno (ERROR_NOTERROR), |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
42 |
m_shutdownSend (false), |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
43 |
m_shutdownRecv (false), |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
44 |
m_connected (false) |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1270
diff
changeset
|
45 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1452
diff
changeset
|
46 |
NS_LOG_FUNCTION; |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1270
diff
changeset
|
47 |
} |
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1270
diff
changeset
|
48 |
|
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
49 |
UdpSocket::~UdpSocket () |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
50 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1452
diff
changeset
|
51 |
NS_LOG_FUNCTION; |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1270
diff
changeset
|
52 |
|
557
927a5bb6432a
convert UdpSocket and Udp to Ptr<Node>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
524
diff
changeset
|
53 |
m_node = 0; |
515
e907146a191e
fix valgrind warning: UdpSocket must manage carefully its Ipv4EndPoint to avoid double deleting it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
503
diff
changeset
|
54 |
if (m_endPoint != 0) |
e907146a191e
fix valgrind warning: UdpSocket must manage carefully its Ipv4EndPoint to avoid double deleting it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
503
diff
changeset
|
55 |
{ |
e907146a191e
fix valgrind warning: UdpSocket must manage carefully its Ipv4EndPoint to avoid double deleting it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
503
diff
changeset
|
56 |
NS_ASSERT (m_udp != 0); |
e907146a191e
fix valgrind warning: UdpSocket must manage carefully its Ipv4EndPoint to avoid double deleting it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
503
diff
changeset
|
57 |
/** |
e907146a191e
fix valgrind warning: UdpSocket must manage carefully its Ipv4EndPoint to avoid double deleting it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
503
diff
changeset
|
58 |
* Note that this piece of code is a bit tricky: |
e907146a191e
fix valgrind warning: UdpSocket must manage carefully its Ipv4EndPoint to avoid double deleting it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
503
diff
changeset
|
59 |
* when DeAllocate is called, it will call into |
e907146a191e
fix valgrind warning: UdpSocket must manage carefully its Ipv4EndPoint to avoid double deleting it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
503
diff
changeset
|
60 |
* Ipv4EndPointDemux::Deallocate which triggers |
e907146a191e
fix valgrind warning: UdpSocket must manage carefully its Ipv4EndPoint to avoid double deleting it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
503
diff
changeset
|
61 |
* a delete of the associated endPoint which triggers |
e907146a191e
fix valgrind warning: UdpSocket must manage carefully its Ipv4EndPoint to avoid double deleting it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
503
diff
changeset
|
62 |
* in turn a call to the method ::Destroy below |
e907146a191e
fix valgrind warning: UdpSocket must manage carefully its Ipv4EndPoint to avoid double deleting it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
503
diff
changeset
|
63 |
* will will zero the m_endPoint field. |
e907146a191e
fix valgrind warning: UdpSocket must manage carefully its Ipv4EndPoint to avoid double deleting it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
503
diff
changeset
|
64 |
*/ |
e907146a191e
fix valgrind warning: UdpSocket must manage carefully its Ipv4EndPoint to avoid double deleting it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
503
diff
changeset
|
65 |
NS_ASSERT (m_endPoint != 0); |
e907146a191e
fix valgrind warning: UdpSocket must manage carefully its Ipv4EndPoint to avoid double deleting it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
503
diff
changeset
|
66 |
m_udp->DeAllocate (m_endPoint); |
e907146a191e
fix valgrind warning: UdpSocket must manage carefully its Ipv4EndPoint to avoid double deleting it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
503
diff
changeset
|
67 |
NS_ASSERT (m_endPoint == 0); |
e907146a191e
fix valgrind warning: UdpSocket must manage carefully its Ipv4EndPoint to avoid double deleting it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
503
diff
changeset
|
68 |
} |
568
e1660959ecbb
use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
557
diff
changeset
|
69 |
m_udp = 0; |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
70 |
} |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
71 |
|
2592
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2574
diff
changeset
|
72 |
void |
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2574
diff
changeset
|
73 |
UdpSocket::SetNode (Ptr<Node> node) |
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2574
diff
changeset
|
74 |
{ |
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2574
diff
changeset
|
75 |
m_node = node; |
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2574
diff
changeset
|
76 |
} |
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2574
diff
changeset
|
77 |
void |
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2574
diff
changeset
|
78 |
UdpSocket::SetUdp (Ptr<UdpL4Protocol> udp) |
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2574
diff
changeset
|
79 |
{ |
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2574
diff
changeset
|
80 |
m_udp = udp; |
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2574
diff
changeset
|
81 |
} |
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2574
diff
changeset
|
82 |
|
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2574
diff
changeset
|
83 |
|
1264
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
84 |
enum Socket::SocketErrno |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
85 |
UdpSocket::GetErrno (void) const |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
86 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1452
diff
changeset
|
87 |
NS_LOG_FUNCTION; |
1264
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
88 |
return m_errno; |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
89 |
} |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
90 |
|
728
95c426b1cb60
rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
646
diff
changeset
|
91 |
Ptr<Node> |
95c426b1cb60
rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
646
diff
changeset
|
92 |
UdpSocket::GetNode (void) const |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
93 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1452
diff
changeset
|
94 |
NS_LOG_FUNCTION; |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
95 |
return m_node; |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
96 |
} |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
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 |
void |
496
894c8380d57b
use Dispose more extensively
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
495
diff
changeset
|
99 |
UdpSocket::Destroy (void) |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
100 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1452
diff
changeset
|
101 |
NS_LOG_FUNCTION; |
557
927a5bb6432a
convert UdpSocket and Udp to Ptr<Node>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
524
diff
changeset
|
102 |
m_node = 0; |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
103 |
m_endPoint = 0; |
568
e1660959ecbb
use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
557
diff
changeset
|
104 |
m_udp = 0; |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
105 |
} |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1270
diff
changeset
|
106 |
|
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
107 |
int |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
108 |
UdpSocket::FinishBind (void) |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
109 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1452
diff
changeset
|
110 |
NS_LOG_FUNCTION; |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
111 |
if (m_endPoint == 0) |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
112 |
{ |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
113 |
return -1; |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
114 |
} |
1182
2625b52217a7
I wonder what the point of that code was: why should you test for zero _after_ using the pointer ? It needs to be tested _before_.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1172
diff
changeset
|
115 |
m_endPoint->SetRxCallback (MakeCallback (&UdpSocket::ForwardUp, this)); |
2625b52217a7
I wonder what the point of that code was: why should you test for zero _after_ using the pointer ? It needs to be tested _before_.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1172
diff
changeset
|
116 |
m_endPoint->SetDestroyCallback (MakeCallback (&UdpSocket::Destroy, this)); |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
117 |
return 0; |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
118 |
} |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
119 |
|
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
120 |
int |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
121 |
UdpSocket::Bind (void) |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
122 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1452
diff
changeset
|
123 |
NS_LOG_FUNCTION; |
499
8a469663f7ea
implement properly the refcounting rules for the capability getters
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
496
diff
changeset
|
124 |
m_endPoint = m_udp->Allocate (); |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
125 |
return FinishBind (); |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
126 |
} |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1270
diff
changeset
|
127 |
|
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
128 |
int |
1162
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
742
diff
changeset
|
129 |
UdpSocket::Bind (const Address &address) |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
130 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1452
diff
changeset
|
131 |
NS_LOG_FUNCTION; |
1828
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1704
diff
changeset
|
132 |
NS_LOG_PARAMS (this << address); |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1270
diff
changeset
|
133 |
|
1172
2e5b994330c7
add InetSocketAddress::IsMatchingType and use it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1171
diff
changeset
|
134 |
if (!InetSocketAddress::IsMatchingType (address)) |
2e5b994330c7
add InetSocketAddress::IsMatchingType and use it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1171
diff
changeset
|
135 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1452
diff
changeset
|
136 |
NS_LOG_ERROR ("Not IsMatchingType"); |
1172
2e5b994330c7
add InetSocketAddress::IsMatchingType and use it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1171
diff
changeset
|
137 |
return ERROR_INVAL; |
2e5b994330c7
add InetSocketAddress::IsMatchingType and use it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1171
diff
changeset
|
138 |
} |
1207
a9f3610bbffa
remove implicit conversion from Address to Eui48Address, to Ipv4Address and to InetSocketAddress
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1204
diff
changeset
|
139 |
InetSocketAddress transport = InetSocketAddress::ConvertFrom (address); |
1162
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
742
diff
changeset
|
140 |
Ipv4Address ipv4 = transport.GetIpv4 (); |
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
742
diff
changeset
|
141 |
uint16_t port = transport.GetPort (); |
2326
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
142 |
|
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
143 |
Ipv4Address localInterface = Ipv4Address::GetAny (); |
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
144 |
if (ipv4 != Ipv4Address::GetAny ()) |
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
145 |
{ |
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
146 |
Ptr<Ipv4> ipv4_api = m_node->GetObject<Ipv4> (); |
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
147 |
// Assert that the given address matches an existing local interface |
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
148 |
NS_ASSERT (ipv4_api->FindInterfaceForAddr (ipv4) != 0); |
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
149 |
localInterface = ipv4; |
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
150 |
} |
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
151 |
|
1162
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
742
diff
changeset
|
152 |
if (ipv4 == Ipv4Address::GetAny () && port == 0) |
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
742
diff
changeset
|
153 |
{ |
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
742
diff
changeset
|
154 |
m_endPoint = m_udp->Allocate (); |
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
742
diff
changeset
|
155 |
} |
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
742
diff
changeset
|
156 |
else if (ipv4 == Ipv4Address::GetAny () && port != 0) |
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
742
diff
changeset
|
157 |
{ |
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
742
diff
changeset
|
158 |
m_endPoint = m_udp->Allocate (port); |
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
742
diff
changeset
|
159 |
} |
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
742
diff
changeset
|
160 |
else if (ipv4 != Ipv4Address::GetAny () && port == 0) |
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
742
diff
changeset
|
161 |
{ |
2326
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
162 |
m_endPoint = m_udp->Allocate (ipv4, localInterface); |
1162
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
742
diff
changeset
|
163 |
} |
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
742
diff
changeset
|
164 |
else if (ipv4 != Ipv4Address::GetAny () && port != 0) |
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
742
diff
changeset
|
165 |
{ |
2326
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
166 |
m_endPoint = m_udp->Allocate (ipv4, port, localInterface); |
1162
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
742
diff
changeset
|
167 |
} |
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
742
diff
changeset
|
168 |
|
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
169 |
return FinishBind (); |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
170 |
} |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
171 |
|
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
172 |
int |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
173 |
UdpSocket::ShutdownSend (void) |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
174 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1452
diff
changeset
|
175 |
NS_LOG_FUNCTION; |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
176 |
m_shutdownSend = true; |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
177 |
return 0; |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
178 |
} |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1270
diff
changeset
|
179 |
|
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
180 |
int |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
181 |
UdpSocket::ShutdownRecv (void) |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
182 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1452
diff
changeset
|
183 |
NS_LOG_FUNCTION; |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
184 |
m_shutdownRecv = false; |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
185 |
return 0; |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
186 |
} |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
187 |
|
1186
909e9eb2124e
rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1182
diff
changeset
|
188 |
int |
1264
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
189 |
UdpSocket::Close(void) |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
190 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1452
diff
changeset
|
191 |
NS_LOG_FUNCTION; |
1264
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
192 |
NotifyCloseCompleted (); |
1186
909e9eb2124e
rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1182
diff
changeset
|
193 |
return 0; |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
194 |
} |
1264
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
195 |
|
1186
909e9eb2124e
rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1182
diff
changeset
|
196 |
int |
1264
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
197 |
UdpSocket::Connect(const Address & address) |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
198 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1452
diff
changeset
|
199 |
NS_LOG_FUNCTION; |
1828
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1704
diff
changeset
|
200 |
NS_LOG_PARAMS (this << address); |
1317
82629189efff
Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents:
1308
diff
changeset
|
201 |
Ipv4Route routeToDest; |
1207
a9f3610bbffa
remove implicit conversion from Address to Eui48Address, to Ipv4Address and to InetSocketAddress
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1204
diff
changeset
|
202 |
InetSocketAddress transport = InetSocketAddress::ConvertFrom (address); |
1162
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
742
diff
changeset
|
203 |
m_defaultAddress = transport.GetIpv4 (); |
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
742
diff
changeset
|
204 |
m_defaultPort = transport.GetPort (); |
1264
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
205 |
NotifyConnectionSucceeded (); |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
206 |
m_connected = true; |
1434
2b63aafb050b
set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents:
1429
diff
changeset
|
207 |
|
1186
909e9eb2124e
rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1182
diff
changeset
|
208 |
return 0; |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
209 |
} |
1317
82629189efff
Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents:
1308
diff
changeset
|
210 |
|
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
211 |
int |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
212 |
UdpSocket::Send (Ptr<Packet> p) |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
213 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1452
diff
changeset
|
214 |
NS_LOG_FUNCTION; |
1870 | 215 |
NS_LOG_PARAMS (this << p); |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1270
diff
changeset
|
216 |
|
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
217 |
if (!m_connected) |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
218 |
{ |
646
f7475a7c5ae6
Rename the SocketErrno enumeration values, from ESOMETHING to ERROR_SOMETHING, to avoid conflict with errno #define's; fixes compilation in mingw32.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
607
diff
changeset
|
219 |
m_errno = ERROR_NOTCONN; |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
220 |
return -1; |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
221 |
} |
1317
82629189efff
Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents:
1308
diff
changeset
|
222 |
return DoSend (p); |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
223 |
} |
1317
82629189efff
Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents:
1308
diff
changeset
|
224 |
|
82629189efff
Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents:
1308
diff
changeset
|
225 |
int |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
226 |
UdpSocket::DoSend (Ptr<Packet> p) |
1317
82629189efff
Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents:
1308
diff
changeset
|
227 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1452
diff
changeset
|
228 |
NS_LOG_FUNCTION; |
1317
82629189efff
Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents:
1308
diff
changeset
|
229 |
if (m_endPoint == 0) |
82629189efff
Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents:
1308
diff
changeset
|
230 |
{ |
82629189efff
Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents:
1308
diff
changeset
|
231 |
if (Bind () == -1) |
82629189efff
Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents:
1308
diff
changeset
|
232 |
{ |
82629189efff
Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents:
1308
diff
changeset
|
233 |
NS_ASSERT (m_endPoint == 0); |
82629189efff
Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents:
1308
diff
changeset
|
234 |
return -1; |
82629189efff
Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents:
1308
diff
changeset
|
235 |
} |
82629189efff
Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents:
1308
diff
changeset
|
236 |
NS_ASSERT (m_endPoint != 0); |
82629189efff
Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents:
1308
diff
changeset
|
237 |
} |
82629189efff
Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents:
1308
diff
changeset
|
238 |
if (m_shutdownSend) |
82629189efff
Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents:
1308
diff
changeset
|
239 |
{ |
82629189efff
Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents:
1308
diff
changeset
|
240 |
m_errno = ERROR_SHUTDOWN; |
82629189efff
Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents:
1308
diff
changeset
|
241 |
return -1; |
82629189efff
Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents:
1308
diff
changeset
|
242 |
} |
1318
89b78e2d521e
Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents:
1317
diff
changeset
|
243 |
|
89b78e2d521e
Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents:
1317
diff
changeset
|
244 |
return DoSendTo (p, m_defaultAddress, m_defaultPort); |
1317
82629189efff
Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents:
1308
diff
changeset
|
245 |
} |
82629189efff
Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents:
1308
diff
changeset
|
246 |
|
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
247 |
int |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
248 |
UdpSocket::DoSendTo (Ptr<Packet> p, const Address &address) |
1162
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
742
diff
changeset
|
249 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1452
diff
changeset
|
250 |
NS_LOG_FUNCTION; |
1870 | 251 |
NS_LOG_PARAMS (this << p << address); |
1449 | 252 |
|
1318
89b78e2d521e
Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents:
1317
diff
changeset
|
253 |
if (!m_connected) |
89b78e2d521e
Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents:
1317
diff
changeset
|
254 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1452
diff
changeset
|
255 |
NS_LOG_LOGIC ("Not connected"); |
1318
89b78e2d521e
Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents:
1317
diff
changeset
|
256 |
InetSocketAddress transport = InetSocketAddress::ConvertFrom (address); |
89b78e2d521e
Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents:
1317
diff
changeset
|
257 |
Ipv4Address ipv4 = transport.GetIpv4 (); |
89b78e2d521e
Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents:
1317
diff
changeset
|
258 |
uint16_t port = transport.GetPort (); |
89b78e2d521e
Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents:
1317
diff
changeset
|
259 |
return DoSendTo (p, ipv4, port); |
89b78e2d521e
Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents:
1317
diff
changeset
|
260 |
} |
89b78e2d521e
Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents:
1317
diff
changeset
|
261 |
else |
89b78e2d521e
Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents:
1317
diff
changeset
|
262 |
{ |
89b78e2d521e
Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents:
1317
diff
changeset
|
263 |
// connected UDP socket must use default addresses |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1452
diff
changeset
|
264 |
NS_LOG_LOGIC ("Connected"); |
1318
89b78e2d521e
Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents:
1317
diff
changeset
|
265 |
return DoSendTo (p, m_defaultAddress, m_defaultPort); |
89b78e2d521e
Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents:
1317
diff
changeset
|
266 |
} |
1162
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
742
diff
changeset
|
267 |
} |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1270
diff
changeset
|
268 |
|
1162
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
742
diff
changeset
|
269 |
int |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
270 |
UdpSocket::DoSendTo (Ptr<Packet> p, Ipv4Address dest, uint16_t port) |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
271 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1452
diff
changeset
|
272 |
NS_LOG_FUNCTION; |
1870 | 273 |
NS_LOG_PARAMS (this << p << dest << port); |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1270
diff
changeset
|
274 |
|
1318
89b78e2d521e
Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents:
1317
diff
changeset
|
275 |
Ipv4Route routeToDest; |
1449 | 276 |
|
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
277 |
if (m_endPoint == 0) |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
278 |
{ |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
279 |
if (Bind () == -1) |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
280 |
{ |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
281 |
NS_ASSERT (m_endPoint == 0); |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
282 |
return -1; |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
283 |
} |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
284 |
NS_ASSERT (m_endPoint != 0); |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
285 |
} |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
286 |
if (m_shutdownSend) |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
287 |
{ |
646
f7475a7c5ae6
Rename the SocketErrno enumeration values, from ESOMETHING to ERROR_SOMETHING, to avoid conflict with errno #define's; fixes compilation in mingw32.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
607
diff
changeset
|
288 |
m_errno = ERROR_SHUTDOWN; |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
289 |
return -1; |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
290 |
} |
1452
973c456d3684
socket update broke multicast
Craig Dowell <craigdo@ee.washington.edu>
parents:
1450
diff
changeset
|
291 |
|
973c456d3684
socket update broke multicast
Craig Dowell <craigdo@ee.washington.edu>
parents:
1450
diff
changeset
|
292 |
uint32_t localIfIndex; |
2257
71a58e70c671
QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2231
diff
changeset
|
293 |
Ptr<Ipv4> ipv4 = m_node->GetObject<Ipv4> (); |
1452
973c456d3684
socket update broke multicast
Craig Dowell <craigdo@ee.washington.edu>
parents:
1450
diff
changeset
|
294 |
|
1318
89b78e2d521e
Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents:
1317
diff
changeset
|
295 |
// |
89b78e2d521e
Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents:
1317
diff
changeset
|
296 |
// If dest is sent to the limited broadcast address (all ones), |
89b78e2d521e
Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents:
1317
diff
changeset
|
297 |
// convert it to send a copy of the packet out of every interface |
89b78e2d521e
Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents:
1317
diff
changeset
|
298 |
// |
89b78e2d521e
Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents:
1317
diff
changeset
|
299 |
if (dest.IsBroadcast ()) |
89b78e2d521e
Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents:
1317
diff
changeset
|
300 |
{ |
2299
0b9193f38f18
Some more udp socket debug messages
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2257
diff
changeset
|
301 |
NS_LOG_LOGIC ("Limited broadcast start."); |
1318
89b78e2d521e
Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents:
1317
diff
changeset
|
302 |
for (uint32_t i = 0; i < ipv4->GetNInterfaces (); i++ ) |
89b78e2d521e
Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents:
1317
diff
changeset
|
303 |
{ |
89b78e2d521e
Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents:
1317
diff
changeset
|
304 |
Ipv4Address addri = ipv4->GetAddress (i); |
89b78e2d521e
Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents:
1317
diff
changeset
|
305 |
Ipv4Mask maski = ipv4->GetNetworkMask (i); |
2299
0b9193f38f18
Some more udp socket debug messages
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2257
diff
changeset
|
306 |
Ipv4Address bcast = addri.GetSubnetDirectedBroadcast (maski); |
2305
518187ed457c
Backed out changeset 055ff23aa034 (Tom does not like it turns out OLSR does not need it)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2300
diff
changeset
|
307 |
NS_LOG_LOGIC ("Sending one copy from " << addri << " to " << bcast |
2299
0b9193f38f18
Some more udp socket debug messages
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2257
diff
changeset
|
308 |
<< " (mask is " << maski << ")"); |
2305
518187ed457c
Backed out changeset 055ff23aa034 (Tom does not like it turns out OLSR does not need it)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2300
diff
changeset
|
309 |
m_udp->Send (p->Copy (), addri, bcast, |
1318
89b78e2d521e
Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents:
1317
diff
changeset
|
310 |
m_endPoint->GetLocalPort (), port); |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
311 |
NotifyDataSent (p->GetSize ()); |
1318
89b78e2d521e
Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents:
1317
diff
changeset
|
312 |
} |
2299
0b9193f38f18
Some more udp socket debug messages
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2257
diff
changeset
|
313 |
NS_LOG_LOGIC ("Limited broadcast end."); |
1318
89b78e2d521e
Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents:
1317
diff
changeset
|
314 |
} |
1452
973c456d3684
socket update broke multicast
Craig Dowell <craigdo@ee.washington.edu>
parents:
1450
diff
changeset
|
315 |
else if (ipv4->GetIfIndexForDestination(dest, localIfIndex)) |
1317
82629189efff
Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents:
1308
diff
changeset
|
316 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1452
diff
changeset
|
317 |
NS_LOG_LOGIC ("Route exists"); |
2305
518187ed457c
Backed out changeset 055ff23aa034 (Tom does not like it turns out OLSR does not need it)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2300
diff
changeset
|
318 |
m_udp->Send (p, ipv4->GetAddress (localIfIndex), dest, |
1162
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
742
diff
changeset
|
319 |
m_endPoint->GetLocalPort (), port); |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
320 |
NotifyDataSent (p->GetSize ()); |
1317
82629189efff
Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents:
1308
diff
changeset
|
321 |
return 0; |
82629189efff
Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents:
1308
diff
changeset
|
322 |
} |
82629189efff
Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents:
1308
diff
changeset
|
323 |
else |
82629189efff
Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents:
1308
diff
changeset
|
324 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1452
diff
changeset
|
325 |
NS_LOG_ERROR ("ERROR_NOROUTETOHOST"); |
1317
82629189efff
Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents:
1308
diff
changeset
|
326 |
m_errno = ERROR_NOROUTETOHOST; |
82629189efff
Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents:
1308
diff
changeset
|
327 |
return -1; |
82629189efff
Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents:
1308
diff
changeset
|
328 |
} |
1440
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
329 |
|
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
330 |
return 0; |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
331 |
} |
1317
82629189efff
Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents:
1308
diff
changeset
|
332 |
|
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
333 |
int |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
334 |
UdpSocket::SendTo(const Address &address, Ptr<Packet> p) |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
335 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1452
diff
changeset
|
336 |
NS_LOG_FUNCTION; |
1870 | 337 |
NS_LOG_PARAMS (this << address << p); |
1207
a9f3610bbffa
remove implicit conversion from Address to Eui48Address, to Ipv4Address and to InetSocketAddress
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1204
diff
changeset
|
338 |
InetSocketAddress transport = InetSocketAddress::ConvertFrom (address); |
1162
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
742
diff
changeset
|
339 |
Ipv4Address ipv4 = transport.GetIpv4 (); |
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
742
diff
changeset
|
340 |
uint16_t port = transport.GetPort (); |
1264
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
341 |
return DoSendTo (p, ipv4, port); |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
342 |
} |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
343 |
|
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
344 |
void |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
345 |
UdpSocket::ForwardUp (Ptr<Packet> packet, Ipv4Address ipv4, uint16_t port) |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
346 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1452
diff
changeset
|
347 |
NS_LOG_FUNCTION; |
1870 | 348 |
NS_LOG_PARAMS (this << packet << ipv4 << port); |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1270
diff
changeset
|
349 |
|
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
350 |
if (m_shutdownRecv) |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
351 |
{ |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
352 |
return; |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
353 |
} |
1162
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
742
diff
changeset
|
354 |
|
1204
d40723d53e3d
InetSocketAddress: replace explicit conversion to implicit conversion
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1172
diff
changeset
|
355 |
Address address = InetSocketAddress (ipv4, port); |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
356 |
NotifyDataReceived (packet, address); |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
357 |
} |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
358 |
|
1435
a70de165a25a
set source IP address in udp-socket packets
Craig Dowell <craigdo@ee.washington.edu>
parents:
1434
diff
changeset
|
359 |
} //namespace ns3 |
1519
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
360 |
|
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
361 |
|
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
362 |
#ifdef RUN_SELF_TESTS |
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
363 |
|
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
364 |
#include "ns3/test.h" |
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
365 |
#include "ns3/internet-node.h" |
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
366 |
#include "ns3/socket-factory.h" |
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
367 |
#include "ns3/udp.h" |
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
368 |
#include "ns3/simulator.h" |
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
369 |
#include "ns3/point-to-point-channel.h" |
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
370 |
#include "ns3/point-to-point-net-device.h" |
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
371 |
#include "ns3/drop-tail-queue.h" |
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
372 |
#include <string> |
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
373 |
|
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
374 |
namespace ns3 { |
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
375 |
|
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
376 |
class UdpSocketTest: public Test |
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
377 |
{ |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
378 |
Ptr<Packet> m_receivedPacket; |
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
379 |
Ptr<Packet> m_receivedPacket2; |
1519
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
380 |
|
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
381 |
public: |
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
382 |
virtual bool RunTests (void); |
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
383 |
UdpSocketTest (); |
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
384 |
|
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
385 |
void ReceivePacket (Ptr<Socket> socket, Ptr<Packet> packet, const Address &from); |
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
386 |
void ReceivePacket2 (Ptr<Socket> socket, Ptr<Packet> packet, const Address &from); |
1519
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
387 |
}; |
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
388 |
|
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
389 |
|
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
390 |
UdpSocketTest::UdpSocketTest () |
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
391 |
: Test ("UdpSocket") {} |
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
392 |
|
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
393 |
|
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
394 |
void UdpSocketTest::ReceivePacket (Ptr<Socket> socket, Ptr<Packet> packet, const Address &from) |
1519
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
395 |
{ |
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
396 |
m_receivedPacket = packet; |
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
397 |
} |
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
398 |
|
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
399 |
void UdpSocketTest::ReceivePacket2 (Ptr<Socket> socket, Ptr<Packet> packet, const Address &from) |
1519
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
400 |
{ |
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
401 |
m_receivedPacket2 = packet; |
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
402 |
} |
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
403 |
|
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
404 |
bool |
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
405 |
UdpSocketTest::RunTests (void) |
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
406 |
{ |
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
407 |
bool result = true; |
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
408 |
|
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
409 |
// Create topology |
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
410 |
|
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
411 |
// Receiver Node |
2230
9f13ac3291e0
add CreateObject<> to instanciate subclasses of the Object base class. Replaces Create<>.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1870
diff
changeset
|
412 |
Ptr<Node> rxNode = CreateObject<InternetNode> (); |
2326
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
413 |
Ptr<PointToPointNetDevice> rxDev1, rxDev2; |
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
414 |
{ // first interface |
2600
6c389d0c717d
add Application::SetNode and NetDevice::SetNode, use them from Node::AddApplication and Node::AddDevice. kill useless "Node" attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2592
diff
changeset
|
415 |
rxDev1 = CreateObject<PointToPointNetDevice> ("Address", Mac48Address::Allocate ()); |
2503 | 416 |
rxNode->AddDevice (rxDev1); |
2326
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
417 |
rxDev1->AddQueue(CreateObject<DropTailQueue> ()); |
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
418 |
Ptr<Ipv4> ipv4 = rxNode->GetObject<Ipv4> (); |
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
419 |
uint32_t netdev_idx = ipv4->AddInterface (rxDev1); |
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
420 |
ipv4->SetAddress (netdev_idx, Ipv4Address ("10.0.0.1")); |
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
421 |
ipv4->SetNetworkMask (netdev_idx, Ipv4Mask (0xffff0000U)); |
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
422 |
ipv4->SetUp (netdev_idx); |
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
423 |
} |
1519
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
424 |
|
2326
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
425 |
{ // second interface |
2600
6c389d0c717d
add Application::SetNode and NetDevice::SetNode, use them from Node::AddApplication and Node::AddDevice. kill useless "Node" attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2592
diff
changeset
|
426 |
rxDev2 = CreateObject<PointToPointNetDevice> ("Address", Mac48Address::Allocate ()); |
2503 | 427 |
rxNode->AddDevice (rxDev2); |
2326
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
428 |
rxDev2->AddQueue(CreateObject<DropTailQueue> ()); |
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
429 |
Ptr<Ipv4> ipv4 = rxNode->GetObject<Ipv4> (); |
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
430 |
uint32_t netdev_idx = ipv4->AddInterface (rxDev2); |
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
431 |
ipv4->SetAddress (netdev_idx, Ipv4Address ("10.0.1.1")); |
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
432 |
ipv4->SetNetworkMask (netdev_idx, Ipv4Mask (0xffff0000U)); |
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
433 |
ipv4->SetUp (netdev_idx); |
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
434 |
} |
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
435 |
|
1519
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
436 |
// Sender Node |
2230
9f13ac3291e0
add CreateObject<> to instanciate subclasses of the Object base class. Replaces Create<>.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1870
diff
changeset
|
437 |
Ptr<Node> txNode = CreateObject<InternetNode> (); |
2326
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
438 |
Ptr<PointToPointNetDevice> txDev; |
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
439 |
{ |
2600
6c389d0c717d
add Application::SetNode and NetDevice::SetNode, use them from Node::AddApplication and Node::AddDevice. kill useless "Node" attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2592
diff
changeset
|
440 |
txDev = CreateObject<PointToPointNetDevice> ("Address", Mac48Address::Allocate ()); |
2574
cc6ceef18cd3
ensure that device is reported in node.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
441 |
txNode->AddDevice (txDev); |
2326
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
442 |
txDev->AddQueue(CreateObject<DropTailQueue> ()); |
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
443 |
Ptr<Ipv4> ipv4 = txNode->GetObject<Ipv4> (); |
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
444 |
uint32_t netdev_idx = ipv4->AddInterface (txDev); |
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
445 |
ipv4->SetAddress (netdev_idx, Ipv4Address ("10.0.0.2")); |
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
446 |
ipv4->SetNetworkMask (netdev_idx, Ipv4Mask (0xffff0000U)); |
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
447 |
ipv4->SetUp (netdev_idx); |
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
448 |
} |
1519
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
449 |
|
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
450 |
// link the two nodes |
2230
9f13ac3291e0
add CreateObject<> to instanciate subclasses of the Object base class. Replaces Create<>.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1870
diff
changeset
|
451 |
Ptr<PointToPointChannel> channel = CreateObject<PointToPointChannel> (); |
2326
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
452 |
rxDev1->Attach (channel); |
1519
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
453 |
txDev->Attach (channel); |
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
454 |
|
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
455 |
|
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
456 |
// Create the UDP sockets |
2257
71a58e70c671
QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2231
diff
changeset
|
457 |
Ptr<SocketFactory> rxSocketFactory = rxNode->GetObject<Udp> (); |
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:
1520
diff
changeset
|
458 |
Ptr<Socket> rxSocket = rxSocketFactory->CreateSocket (); |
2326
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
459 |
NS_TEST_ASSERT_EQUAL (rxSocket->Bind (InetSocketAddress (Ipv4Address ("10.0.0.1"), 1234)), 0); |
1519
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
460 |
rxSocket->SetRecvCallback (MakeCallback (&UdpSocketTest::ReceivePacket, this)); |
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
461 |
|
2326
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
462 |
Ptr<Socket> rxSocket2 = rxSocketFactory->CreateSocket (); |
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
463 |
rxSocket2->SetRecvCallback (MakeCallback (&UdpSocketTest::ReceivePacket2, this)); |
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
464 |
NS_TEST_ASSERT_EQUAL (rxSocket2->Bind (InetSocketAddress (Ipv4Address ("10.0.1.1"), 1234)), 0); |
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
465 |
|
2257
71a58e70c671
QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2231
diff
changeset
|
466 |
Ptr<SocketFactory> txSocketFactory = txNode->GetObject<Udp> (); |
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:
1520
diff
changeset
|
467 |
Ptr<Socket> txSocket = txSocketFactory->CreateSocket (); |
1519
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
468 |
|
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
469 |
// ------ Now the tests ------------ |
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
470 |
|
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
471 |
// Unicast test |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
472 |
m_receivedPacket = Create<Packet> (); |
2326
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
473 |
m_receivedPacket2 = Create<Packet> (); |
1519
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
474 |
NS_TEST_ASSERT_EQUAL (txSocket->SendTo (InetSocketAddress (Ipv4Address("10.0.0.1"), 1234), |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
475 |
Create<Packet> (123)), 0); |
1519
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
476 |
Simulator::Run (); |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
477 |
NS_TEST_ASSERT_EQUAL (m_receivedPacket->GetSize (), 123); |
2326
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
478 |
NS_TEST_ASSERT_EQUAL (m_receivedPacket2->GetSize (), 0); // second interface should receive it |
1519
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
479 |
|
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
480 |
|
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
481 |
// Simple broadcast test |
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
482 |
|
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
483 |
m_receivedPacket = Create<Packet> (); |
2326
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
484 |
m_receivedPacket2 = Create<Packet> (); |
1519
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
485 |
NS_TEST_ASSERT_EQUAL (txSocket->SendTo (InetSocketAddress (Ipv4Address("255.255.255.255"), 1234), |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
486 |
Create<Packet> (123)), 0); |
1519
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
487 |
Simulator::Run (); |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
488 |
NS_TEST_ASSERT_EQUAL (m_receivedPacket->GetSize (), 123); |
2326
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
489 |
// second socket should not receive it (it is bound specifically to the second interface's address |
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
490 |
NS_TEST_ASSERT_EQUAL (m_receivedPacket2->GetSize (), 0); |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
491 |
|
1519
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
492 |
|
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
493 |
// Broadcast test with multiple receiving sockets |
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
494 |
|
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
495 |
// When receiving broadcast packets, all sockets sockets bound to |
2326
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
496 |
// the address/port should receive a copy of the same packet -- if |
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
497 |
// the socket address matches. |
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
498 |
rxSocket2->Dispose (); |
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2305
diff
changeset
|
499 |
rxSocket2 = rxSocketFactory->CreateSocket (); |
1520
47d4ee8f48b8
Fix a small error in the unit test added recently (though it doesn't change the result)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1519
diff
changeset
|
500 |
rxSocket2->SetRecvCallback (MakeCallback (&UdpSocketTest::ReceivePacket2, this)); |
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:
1520
diff
changeset
|
501 |
NS_TEST_ASSERT_EQUAL (rxSocket2->Bind (InetSocketAddress (Ipv4Address ("0.0.0.0"), 1234)), 0); |
1519
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
502 |
|
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
503 |
m_receivedPacket = Create<Packet> (); |
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
504 |
m_receivedPacket2 = Create<Packet> (); |
1519
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
505 |
NS_TEST_ASSERT_EQUAL (txSocket->SendTo (InetSocketAddress (Ipv4Address("255.255.255.255"), 1234), |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
506 |
Create<Packet> (123)), 0); |
1519
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
507 |
Simulator::Run (); |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
508 |
NS_TEST_ASSERT_EQUAL (m_receivedPacket->GetSize (), 123); |
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
509 |
NS_TEST_ASSERT_EQUAL (m_receivedPacket2->GetSize (), 123); |
1519
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
510 |
|
1704
41c3142f4293
add missing call to Simulator::Destroy to cleanup after test
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
511 |
Simulator::Destroy (); |
41c3142f4293
add missing call to Simulator::Destroy to cleanup after test
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
512 |
|
1519
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
513 |
return result; |
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
514 |
} |
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
515 |
|
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
516 |
|
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
517 |
static UdpSocketTest gUdpSocketTest; |
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
518 |
|
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
519 |
}; // namespace ns3 |
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
520 |
|
9b1cbc4c63f8
Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1511
diff
changeset
|
521 |
#endif /* RUN_SELF_TESTS */ |