author | Vedran Mileti? <rivanvx@gmail.com> |
Tue, 02 Aug 2011 17:43:32 -0400 | |
changeset 7386 | 2310ed220a61 |
parent 7385 | 10beb0e53130 |
child 7600 | 57ba46094a0d |
permissions | -rw-r--r-- |
7385
10beb0e53130
standardize emacs c++ mode comments
Vedran Mileti? <rivanvx@gmail.com>
parents:
7321
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
453
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 |
* |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
5 |
* 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
|
6 |
* 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
|
7 |
* 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
|
8 |
* |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
9 |
* 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
|
10 |
* 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
|
11 |
* 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
|
12 |
* 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
|
13 |
* |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
14 |
* 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
|
15 |
* 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
|
16 |
* 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
|
17 |
* |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
18 |
* 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
|
19 |
*/ |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1270
diff
changeset
|
20 |
|
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1452
diff
changeset
|
21 |
#include "ns3/log.h" |
729
b5e744285e92
rename i-node to node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
728
diff
changeset
|
22 |
#include "ns3/node.h" |
1171
335886fe4ddd
InetAddress -> InetSocketAddress
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1164
diff
changeset
|
23 |
#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
|
24 |
#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
|
25 |
#include "ns3/ipv4.h" |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
26 |
#include "ns3/ipv4-header.h" |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
27 |
#include "ns3/ipv4-routing-protocol.h" |
3125
d2d8a36cfd23
s/ns3::Udp/ns3::UdpSocketFactory
Tom Henderson <tomh@tomh.org>
parents:
3124
diff
changeset
|
28 |
#include "ns3/udp-socket-factory.h" |
3117
c8160bbb2085
Add SocketDefaults to store socket option attributes
Tom Henderson <tomh@tomh.org>
parents:
3113
diff
changeset
|
29 |
#include "ns3/trace-source-accessor.h" |
6442
f380cf1aa4d8
Bug 671 add packet-info-tag.cc for IP_PKTINFO/IPV6_PKTINFO
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
6439
diff
changeset
|
30 |
#include "ns3/ipv4-packet-info-tag.h" |
3130
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
31 |
#include "udp-socket-impl.h" |
741
38ebb2fb16f5
udp.h -> udp-l4-protocol.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
32 |
#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
|
33 |
#include "ipv4-end-point.h" |
3718
f22f8ab3f6f5
fix build with gcc 4.3.0
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3588
diff
changeset
|
34 |
#include <limits> |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
35 |
|
3130
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
36 |
NS_LOG_COMPONENT_DEFINE ("UdpSocketImpl"); |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
37 |
|
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
38 |
namespace ns3 { |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
39 |
|
3122
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
40 |
static const uint32_t MAX_IPV4_UDP_DATAGRAM_SIZE = 65507; |
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
41 |
|
3127
f5971b43ee58
Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents:
3125
diff
changeset
|
42 |
// Add attributes generic to all UdpSockets to base class UdpSocket |
3105
682950a37ea6
Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents:
3104
diff
changeset
|
43 |
TypeId |
3130
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
44 |
UdpSocketImpl::GetTypeId (void) |
3105
682950a37ea6
Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents:
3104
diff
changeset
|
45 |
{ |
3130
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
46 |
static TypeId tid = TypeId ("ns3::UdpSocketImpl") |
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
47 |
.SetParent<UdpSocket> () |
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
48 |
.AddConstructor<UdpSocketImpl> () |
3105
682950a37ea6
Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents:
3104
diff
changeset
|
49 |
.AddTraceSource ("Drop", "Drop UDP packet due to receive buffer overflow", |
3130
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
50 |
MakeTraceSourceAccessor (&UdpSocketImpl::m_dropTrace)) |
3820 | 51 |
.AddAttribute ("IcmpCallback", "Callback invoked whenever an icmp error is received on this socket.", |
52 |
CallbackValue (), |
|
53 |
MakeCallbackAccessor (&UdpSocketImpl::m_icmpCallback), |
|
54 |
MakeCallbackChecker ()) |
|
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
55 |
; |
3105
682950a37ea6
Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents:
3104
diff
changeset
|
56 |
return tid; |
682950a37ea6
Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents:
3104
diff
changeset
|
57 |
} |
682950a37ea6
Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents:
3104
diff
changeset
|
58 |
|
3130
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
59 |
UdpSocketImpl::UdpSocketImpl () |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
60 |
: m_endPoint (0), |
2592
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2574
diff
changeset
|
61 |
m_node (0), |
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2574
diff
changeset
|
62 |
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
|
63 |
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
|
64 |
m_shutdownSend (false), |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
65 |
m_shutdownRecv (false), |
3104 | 66 |
m_connected (false), |
3123
fae57a467d54
undo SocketDefaults class; plumb in new UdpSocket option attributes
Tom Henderson <tomh@tomh.org>
parents:
3122
diff
changeset
|
67 |
m_rxAvailable (0) |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1270
diff
changeset
|
68 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
69 |
NS_LOG_FUNCTION_NOARGS (); |
6439
958a299f1100
Enforce the AllowBroadcast socket option for UDP sockets
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6437
diff
changeset
|
70 |
m_allowBroadcast = false; |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1270
diff
changeset
|
71 |
} |
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1270
diff
changeset
|
72 |
|
3130
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
73 |
UdpSocketImpl::~UdpSocketImpl () |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
74 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
75 |
NS_LOG_FUNCTION_NOARGS (); |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1270
diff
changeset
|
76 |
|
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
77 |
// XXX todo: leave any multicast groups that have been joined |
557
927a5bb6432a
convert UdpSocket and Udp to Ptr<Node>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
524
diff
changeset
|
78 |
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
|
79 |
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
|
80 |
{ |
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
|
81 |
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
|
82 |
/** |
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
|
83 |
* 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
|
84 |
* 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
|
85 |
* 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
|
86 |
* 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
|
87 |
* 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
|
88 |
* 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
|
89 |
*/ |
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
|
90 |
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
|
91 |
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
|
92 |
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
|
93 |
} |
568
e1660959ecbb
use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
557
diff
changeset
|
94 |
m_udp = 0; |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
95 |
} |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
96 |
|
2592
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2574
diff
changeset
|
97 |
void |
3130
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
98 |
UdpSocketImpl::SetNode (Ptr<Node> node) |
2592
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2574
diff
changeset
|
99 |
{ |
3113
e6740c0582bf
tweak UdpSocket buffer limit behavior
Tom Henderson <tomh@tomh.org>
parents:
3107
diff
changeset
|
100 |
NS_LOG_FUNCTION_NOARGS (); |
2592
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2574
diff
changeset
|
101 |
m_node = node; |
3105
682950a37ea6
Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents:
3104
diff
changeset
|
102 |
|
2592
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2574
diff
changeset
|
103 |
} |
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2574
diff
changeset
|
104 |
void |
3130
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
105 |
UdpSocketImpl::SetUdp (Ptr<UdpL4Protocol> udp) |
2592
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2574
diff
changeset
|
106 |
{ |
3113
e6740c0582bf
tweak UdpSocket buffer limit behavior
Tom Henderson <tomh@tomh.org>
parents:
3107
diff
changeset
|
107 |
NS_LOG_FUNCTION_NOARGS (); |
2592
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2574
diff
changeset
|
108 |
m_udp = udp; |
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2574
diff
changeset
|
109 |
} |
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2574
diff
changeset
|
110 |
|
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2574
diff
changeset
|
111 |
|
1264
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
112 |
enum Socket::SocketErrno |
3130
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
113 |
UdpSocketImpl::GetErrno (void) const |
1264
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
114 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
115 |
NS_LOG_FUNCTION_NOARGS (); |
1264
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
116 |
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
|
117 |
} |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
118 |
|
6689
e2de571e920a
Implement Socket::GetSocketType
Josh Pelkey <jpelkey@gatech.edu>
parents:
6448
diff
changeset
|
119 |
enum Socket::SocketType |
e2de571e920a
Implement Socket::GetSocketType
Josh Pelkey <jpelkey@gatech.edu>
parents:
6448
diff
changeset
|
120 |
UdpSocketImpl::GetSocketType (void) const |
e2de571e920a
Implement Socket::GetSocketType
Josh Pelkey <jpelkey@gatech.edu>
parents:
6448
diff
changeset
|
121 |
{ |
6692
591fb1aa0ca4
Avoid enum name collision in socket
Josh Pelkey <jpelkey@gatech.edu>
parents:
6689
diff
changeset
|
122 |
return NS3_SOCK_DGRAM; |
6689
e2de571e920a
Implement Socket::GetSocketType
Josh Pelkey <jpelkey@gatech.edu>
parents:
6448
diff
changeset
|
123 |
} |
e2de571e920a
Implement Socket::GetSocketType
Josh Pelkey <jpelkey@gatech.edu>
parents:
6448
diff
changeset
|
124 |
|
728
95c426b1cb60
rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
646
diff
changeset
|
125 |
Ptr<Node> |
3130
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
126 |
UdpSocketImpl::GetNode (void) const |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
127 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
128 |
NS_LOG_FUNCTION_NOARGS (); |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
129 |
return m_node; |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
130 |
} |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
131 |
|
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
132 |
void |
3130
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
133 |
UdpSocketImpl::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
|
134 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
135 |
NS_LOG_FUNCTION_NOARGS (); |
557
927a5bb6432a
convert UdpSocket and Udp to Ptr<Node>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
524
diff
changeset
|
136 |
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
|
137 |
m_endPoint = 0; |
568
e1660959ecbb
use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
557
diff
changeset
|
138 |
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
|
139 |
} |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1270
diff
changeset
|
140 |
|
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
141 |
int |
3130
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
142 |
UdpSocketImpl::FinishBind (void) |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
143 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
144 |
NS_LOG_FUNCTION_NOARGS (); |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
145 |
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
|
146 |
{ |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
147 |
return -1; |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
148 |
} |
3157
de8e4b4c662f
Bug #154: Attach sockets to nodes. Patch by Rajib Bhattacharjea.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3145
diff
changeset
|
149 |
m_endPoint->SetRxCallback (MakeCallback (&UdpSocketImpl::ForwardUp, Ptr<UdpSocketImpl> (this))); |
3820 | 150 |
m_endPoint->SetIcmpCallback (MakeCallback (&UdpSocketImpl::ForwardIcmp, Ptr<UdpSocketImpl> (this))); |
3157
de8e4b4c662f
Bug #154: Attach sockets to nodes. Patch by Rajib Bhattacharjea.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3145
diff
changeset
|
151 |
m_endPoint->SetDestroyCallback (MakeCallback (&UdpSocketImpl::Destroy, Ptr<UdpSocketImpl> (this))); |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
152 |
return 0; |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
153 |
} |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
154 |
|
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
155 |
int |
3130
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
156 |
UdpSocketImpl::Bind (void) |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
157 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
158 |
NS_LOG_FUNCTION_NOARGS (); |
499
8a469663f7ea
implement properly the refcounting rules for the capability getters
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
496
diff
changeset
|
159 |
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
|
160 |
return FinishBind (); |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
161 |
} |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1270
diff
changeset
|
162 |
|
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
163 |
int |
3130
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
164 |
UdpSocketImpl::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
|
165 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
166 |
NS_LOG_FUNCTION (this << address); |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1270
diff
changeset
|
167 |
|
1172
2e5b994330c7
add InetSocketAddress::IsMatchingType and use it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1171
diff
changeset
|
168 |
if (!InetSocketAddress::IsMatchingType (address)) |
2e5b994330c7
add InetSocketAddress::IsMatchingType and use it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1171
diff
changeset
|
169 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1452
diff
changeset
|
170 |
NS_LOG_ERROR ("Not IsMatchingType"); |
3846
265004d6dc15
apply patch for bug 390 (SocketImpl::Bind returns something other than -1)
raj.b@gatech.edu
parents:
3820
diff
changeset
|
171 |
m_errno = ERROR_INVAL; |
265004d6dc15
apply patch for bug 390 (SocketImpl::Bind returns something other than -1)
raj.b@gatech.edu
parents:
3820
diff
changeset
|
172 |
return -1; |
1172
2e5b994330c7
add InetSocketAddress::IsMatchingType and use it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1171
diff
changeset
|
173 |
} |
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
|
174 |
InetSocketAddress transport = InetSocketAddress::ConvertFrom (address); |
1162
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
742
diff
changeset
|
175 |
Ipv4Address ipv4 = transport.GetIpv4 (); |
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
742
diff
changeset
|
176 |
uint16_t port = transport.GetPort (); |
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
742
diff
changeset
|
177 |
if (ipv4 == Ipv4Address::GetAny () && port == 0) |
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
742
diff
changeset
|
178 |
{ |
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
742
diff
changeset
|
179 |
m_endPoint = m_udp->Allocate (); |
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
742
diff
changeset
|
180 |
} |
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
742
diff
changeset
|
181 |
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
|
182 |
{ |
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
742
diff
changeset
|
183 |
m_endPoint = m_udp->Allocate (port); |
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
742
diff
changeset
|
184 |
} |
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
742
diff
changeset
|
185 |
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
|
186 |
{ |
2608
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2600
diff
changeset
|
187 |
m_endPoint = m_udp->Allocate (ipv4); |
1162
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
742
diff
changeset
|
188 |
} |
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
742
diff
changeset
|
189 |
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
|
190 |
{ |
2608
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2600
diff
changeset
|
191 |
m_endPoint = m_udp->Allocate (ipv4, port); |
1162
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
742
diff
changeset
|
192 |
} |
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
742
diff
changeset
|
193 |
|
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
194 |
return FinishBind (); |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
195 |
} |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
196 |
|
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
197 |
int |
3130
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
198 |
UdpSocketImpl::ShutdownSend (void) |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
199 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
200 |
NS_LOG_FUNCTION_NOARGS (); |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
201 |
m_shutdownSend = true; |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
202 |
return 0; |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
203 |
} |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1270
diff
changeset
|
204 |
|
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
205 |
int |
3130
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
206 |
UdpSocketImpl::ShutdownRecv (void) |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
207 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
208 |
NS_LOG_FUNCTION_NOARGS (); |
4491
893d48fcf7f3
bug 535: UDP/TCP ShutdownRecv incorrect
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4472
diff
changeset
|
209 |
m_shutdownRecv = true; |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
210 |
return 0; |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
211 |
} |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
212 |
|
1186
909e9eb2124e
rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1182
diff
changeset
|
213 |
int |
4697
6e048d6486d8
Implement UdpSocketImpl::Close ()
Tom Henderson <tomh@tomh.org>
parents:
4603
diff
changeset
|
214 |
UdpSocketImpl::Close (void) |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
215 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
216 |
NS_LOG_FUNCTION_NOARGS (); |
4697
6e048d6486d8
Implement UdpSocketImpl::Close ()
Tom Henderson <tomh@tomh.org>
parents:
4603
diff
changeset
|
217 |
if (m_shutdownRecv == true && m_shutdownSend == true) |
6e048d6486d8
Implement UdpSocketImpl::Close ()
Tom Henderson <tomh@tomh.org>
parents:
4603
diff
changeset
|
218 |
{ |
6e048d6486d8
Implement UdpSocketImpl::Close ()
Tom Henderson <tomh@tomh.org>
parents:
4603
diff
changeset
|
219 |
m_errno = Socket::ERROR_BADF; |
6e048d6486d8
Implement UdpSocketImpl::Close ()
Tom Henderson <tomh@tomh.org>
parents:
4603
diff
changeset
|
220 |
return -1; |
6e048d6486d8
Implement UdpSocketImpl::Close ()
Tom Henderson <tomh@tomh.org>
parents:
4603
diff
changeset
|
221 |
} |
6e048d6486d8
Implement UdpSocketImpl::Close ()
Tom Henderson <tomh@tomh.org>
parents:
4603
diff
changeset
|
222 |
m_shutdownRecv = true; |
6e048d6486d8
Implement UdpSocketImpl::Close ()
Tom Henderson <tomh@tomh.org>
parents:
4603
diff
changeset
|
223 |
m_shutdownSend = true; |
1186
909e9eb2124e
rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1182
diff
changeset
|
224 |
return 0; |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
225 |
} |
1264
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
226 |
|
1186
909e9eb2124e
rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1182
diff
changeset
|
227 |
int |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7222
diff
changeset
|
228 |
UdpSocketImpl::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
|
229 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
230 |
NS_LOG_FUNCTION (this << address); |
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
|
231 |
InetSocketAddress transport = InetSocketAddress::ConvertFrom (address); |
1162
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
742
diff
changeset
|
232 |
m_defaultAddress = transport.GetIpv4 (); |
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
742
diff
changeset
|
233 |
m_defaultPort = transport.GetPort (); |
7321
21678ba057ef
bug 1201 - connecting UDP sockets (reported by Steve Marotta)
Tom Henderson <tomh@tomh.org>
parents:
7256
diff
changeset
|
234 |
m_connected = true; |
1264
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
235 |
NotifyConnectionSucceeded (); |
1434
2b63aafb050b
set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents:
1429
diff
changeset
|
236 |
|
1186
909e9eb2124e
rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1182
diff
changeset
|
237 |
return 0; |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
238 |
} |
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
|
239 |
|
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
240 |
int |
3772
f0d8608ab155
Remove queue limit from listen
Craig Dowell <craigdo@ee.washington.edu>
parents:
3718
diff
changeset
|
241 |
UdpSocketImpl::Listen (void) |
3213
08a0424399fb
bug 203: Listen must be implemented for Udp and Packet sockets.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3157
diff
changeset
|
242 |
{ |
08a0424399fb
bug 203: Listen must be implemented for Udp and Packet sockets.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3157
diff
changeset
|
243 |
m_errno = Socket::ERROR_OPNOTSUPP; |
08a0424399fb
bug 203: Listen must be implemented for Udp and Packet sockets.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3157
diff
changeset
|
244 |
return -1; |
08a0424399fb
bug 203: Listen must be implemented for Udp and Packet sockets.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3157
diff
changeset
|
245 |
} |
08a0424399fb
bug 203: Listen must be implemented for Udp and Packet sockets.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3157
diff
changeset
|
246 |
|
08a0424399fb
bug 203: Listen must be implemented for Udp and Packet sockets.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3157
diff
changeset
|
247 |
int |
3269
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3213
diff
changeset
|
248 |
UdpSocketImpl::Send (Ptr<Packet> p, uint32_t flags) |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
249 |
{ |
3269
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3213
diff
changeset
|
250 |
NS_LOG_FUNCTION (this << p << flags); |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1270
diff
changeset
|
251 |
|
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
252 |
if (!m_connected) |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
253 |
{ |
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
|
254 |
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
|
255 |
return -1; |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
256 |
} |
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
|
257 |
return DoSend (p); |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
258 |
} |
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
|
259 |
|
82629189efff
Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents:
1308
diff
changeset
|
260 |
int |
3130
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
261 |
UdpSocketImpl::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
|
262 |
{ |
3269
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3213
diff
changeset
|
263 |
NS_LOG_FUNCTION (this << 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
|
264 |
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
|
265 |
{ |
82629189efff
Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents:
1308
diff
changeset
|
266 |
if (Bind () == -1) |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
267 |
{ |
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
|
268 |
NS_ASSERT (m_endPoint == 0); |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
269 |
return -1; |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
270 |
} |
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
|
271 |
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
|
272 |
} |
82629189efff
Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents:
1308
diff
changeset
|
273 |
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
|
274 |
{ |
82629189efff
Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents:
1308
diff
changeset
|
275 |
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
|
276 |
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
|
277 |
} |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
278 |
|
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
|
279 |
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
|
280 |
} |
82629189efff
Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents:
1308
diff
changeset
|
281 |
|
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
282 |
int |
3130
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
283 |
UdpSocketImpl::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
|
284 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
285 |
NS_LOG_FUNCTION (this << p << address); |
1449 | 286 |
|
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
|
287 |
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
|
288 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1452
diff
changeset
|
289 |
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
|
290 |
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
|
291 |
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
|
292 |
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
|
293 |
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
|
294 |
} |
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 |
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
|
296 |
{ |
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 |
// connected UDP socket must use default addresses |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1452
diff
changeset
|
298 |
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
|
299 |
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
|
300 |
} |
1162
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
742
diff
changeset
|
301 |
} |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1270
diff
changeset
|
302 |
|
1162
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
742
diff
changeset
|
303 |
int |
3130
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
304 |
UdpSocketImpl::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
|
305 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
306 |
NS_LOG_FUNCTION (this << p << dest << port); |
5856
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5769
diff
changeset
|
307 |
if (m_boundnetdevice) |
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5769
diff
changeset
|
308 |
{ |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7222
diff
changeset
|
309 |
NS_LOG_LOGIC ("Bound interface number " << m_boundnetdevice->GetIfIndex ()); |
5856
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5769
diff
changeset
|
310 |
} |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
311 |
if (m_endPoint == 0) |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
312 |
{ |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
313 |
if (Bind () == -1) |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
314 |
{ |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
315 |
NS_ASSERT (m_endPoint == 0); |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
316 |
return -1; |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
317 |
} |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
318 |
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
|
319 |
} |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
320 |
if (m_shutdownSend) |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
321 |
{ |
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
|
322 |
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
|
323 |
return -1; |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
324 |
} |
1452
973c456d3684
socket update broke multicast
Craig Dowell <craigdo@ee.washington.edu>
parents:
1450
diff
changeset
|
325 |
|
3122
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
326 |
if (p->GetSize () > GetTxAvailable () ) |
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
327 |
{ |
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
328 |
m_errno = ERROR_MSGSIZE; |
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
329 |
return -1; |
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
330 |
} |
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
331 |
|
2257
71a58e70c671
QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2231
diff
changeset
|
332 |
Ptr<Ipv4> ipv4 = m_node->GetObject<Ipv4> (); |
1452
973c456d3684
socket update broke multicast
Craig Dowell <craigdo@ee.washington.edu>
parents:
1450
diff
changeset
|
333 |
|
3124
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
334 |
// Locally override the IP TTL for this socket |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
335 |
// We cannot directly modify the TTL at this stage, so we set a Packet tag |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
336 |
// The destination can be either multicast, unicast/anycast, or |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
337 |
// either all-hosts broadcast or limited (subnet-directed) broadcast. |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
338 |
// For the latter two broadcast types, the TTL will later be set to one |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
339 |
// irrespective of what is set in these socket options. So, this tagging |
3124
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
340 |
// may end up setting the TTL of a limited broadcast packet to be |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
341 |
// the same as a unicast, but it will be fixed further down the stack |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
342 |
if (m_ipMulticastTtl != 0 && dest.IsMulticast ()) |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
343 |
{ |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
344 |
SocketIpTtlTag tag; |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
345 |
tag.SetTtl (m_ipMulticastTtl); |
4502 | 346 |
p->AddPacketTag (tag); |
3124
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
347 |
} |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
348 |
else if (m_ipTtl != 0 && !dest.IsMulticast () && !dest.IsBroadcast ()) |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
349 |
{ |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
350 |
SocketIpTtlTag tag; |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
351 |
tag.SetTtl (m_ipTtl); |
4502 | 352 |
p->AddPacketTag (tag); |
3124
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
353 |
} |
3820 | 354 |
{ |
355 |
SocketSetDontFragmentTag tag; |
|
4502 | 356 |
bool found = p->RemovePacketTag (tag); |
3820 | 357 |
if (!found) |
358 |
{ |
|
359 |
if (m_mtuDiscover) |
|
360 |
{ |
|
361 |
tag.Enable (); |
|
362 |
} |
|
363 |
else |
|
364 |
{ |
|
365 |
tag.Disable (); |
|
366 |
} |
|
4502 | 367 |
p->AddPacketTag (tag); |
3820 | 368 |
} |
369 |
} |
|
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
|
370 |
// |
3956
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3846
diff
changeset
|
371 |
// If dest is set to the limited broadcast address (all ones), |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3846
diff
changeset
|
372 |
// convert it to send a copy of the packet out of every |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3846
diff
changeset
|
373 |
// interface as a subnet-directed broadcast. |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3846
diff
changeset
|
374 |
// Exception: if the interface has a /32 address, there is no |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3846
diff
changeset
|
375 |
// valid subnet-directed broadcast, so send it as limited broadcast |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3846
diff
changeset
|
376 |
// Note also that some systems will only send limited broadcast packets |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3846
diff
changeset
|
377 |
// out of the "default" interface; here we send it out all interfaces |
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
|
378 |
// |
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
|
379 |
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
|
380 |
{ |
6439
958a299f1100
Enforce the AllowBroadcast socket option for UDP sockets
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6437
diff
changeset
|
381 |
if (!m_allowBroadcast) |
958a299f1100
Enforce the AllowBroadcast socket option for UDP sockets
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6437
diff
changeset
|
382 |
{ |
958a299f1100
Enforce the AllowBroadcast socket option for UDP sockets
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6437
diff
changeset
|
383 |
m_errno = ERROR_OPNOTSUPP; |
958a299f1100
Enforce the AllowBroadcast socket option for UDP sockets
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6437
diff
changeset
|
384 |
return -1; |
958a299f1100
Enforce the AllowBroadcast socket option for UDP sockets
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6437
diff
changeset
|
385 |
} |
2299
0b9193f38f18
Some more udp socket debug messages
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2257
diff
changeset
|
386 |
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
|
387 |
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
|
388 |
{ |
4375
db81fdcb06e7
Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
389 |
// Get the primary address |
db81fdcb06e7
Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
390 |
Ipv4InterfaceAddress iaddr = ipv4->GetAddress (i, 0); |
db81fdcb06e7
Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
391 |
Ipv4Address addri = iaddr.GetLocal (); |
5696
207f9059840d
send to limited broadcast fixed
Borovkova Elena <borovkovaes@iitp.ru>
parents:
5680
diff
changeset
|
392 |
if (addri == Ipv4Address ("127.0.0.1")) |
207f9059840d
send to limited broadcast fixed
Borovkova Elena <borovkovaes@iitp.ru>
parents:
5680
diff
changeset
|
393 |
continue; |
5856
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5769
diff
changeset
|
394 |
// Check if interface-bound socket |
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5769
diff
changeset
|
395 |
if (m_boundnetdevice) |
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5769
diff
changeset
|
396 |
{ |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7222
diff
changeset
|
397 |
if (ipv4->GetNetDevice (i) != m_boundnetdevice) |
5856
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5769
diff
changeset
|
398 |
continue; |
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5769
diff
changeset
|
399 |
} |
4375
db81fdcb06e7
Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
400 |
Ipv4Mask maski = iaddr.GetMask (); |
3956
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3846
diff
changeset
|
401 |
if (maski == Ipv4Mask::GetOnes ()) |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3846
diff
changeset
|
402 |
{ |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3846
diff
changeset
|
403 |
// if the network mask is 255.255.255.255, do not convert dest |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3846
diff
changeset
|
404 |
NS_LOG_LOGIC ("Sending one copy from " << addri << " to " << dest |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
405 |
<< " (mask is " << maski << ")"); |
3956
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3846
diff
changeset
|
406 |
m_udp->Send (p->Copy (), addri, dest, |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3846
diff
changeset
|
407 |
m_endPoint->GetLocalPort (), port); |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3846
diff
changeset
|
408 |
NotifyDataSent (p->GetSize ()); |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3846
diff
changeset
|
409 |
NotifySend (GetTxAvailable ()); |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3846
diff
changeset
|
410 |
} |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3846
diff
changeset
|
411 |
else |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3846
diff
changeset
|
412 |
{ |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3846
diff
changeset
|
413 |
// Convert to subnet-directed broadcast |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3846
diff
changeset
|
414 |
Ipv4Address bcast = addri.GetSubnetDirectedBroadcast (maski); |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3846
diff
changeset
|
415 |
NS_LOG_LOGIC ("Sending one copy from " << addri << " to " << bcast |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
416 |
<< " (mask is " << maski << ")"); |
3956
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3846
diff
changeset
|
417 |
m_udp->Send (p->Copy (), addri, bcast, |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3846
diff
changeset
|
418 |
m_endPoint->GetLocalPort (), port); |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3846
diff
changeset
|
419 |
NotifyDataSent (p->GetSize ()); |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3846
diff
changeset
|
420 |
NotifySend (GetTxAvailable ()); |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3846
diff
changeset
|
421 |
} |
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
|
422 |
} |
2299
0b9193f38f18
Some more udp socket debug messages
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2257
diff
changeset
|
423 |
NS_LOG_LOGIC ("Limited broadcast end."); |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7222
diff
changeset
|
424 |
return 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
|
425 |
} |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7222
diff
changeset
|
426 |
else if (m_endPoint->GetLocalAddress () != Ipv4Address::GetAny ()) |
5769
f6f3e7bae1a4
(bug 746) UDP source address is not set to bound address
Fabian Mauchle <fabian.mauchle@hsr.ch>
parents:
5707
diff
changeset
|
427 |
{ |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7222
diff
changeset
|
428 |
m_udp->Send (p->Copy (), m_endPoint->GetLocalAddress (), dest, |
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7222
diff
changeset
|
429 |
m_endPoint->GetLocalPort (), port, 0); |
6170
21c9ea05058b
bug 864: Invalid return value in UdpSocketImpl::Send and Ipv4RawSocketImpl::Send
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
6093
diff
changeset
|
430 |
NotifyDataSent (p->GetSize ()); |
21c9ea05058b
bug 864: Invalid return value in UdpSocketImpl::Send and Ipv4RawSocketImpl::Send
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
6093
diff
changeset
|
431 |
NotifySend (GetTxAvailable ()); |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7222
diff
changeset
|
432 |
return p->GetSize (); |
5769
f6f3e7bae1a4
(bug 746) UDP source address is not set to bound address
Fabian Mauchle <fabian.mauchle@hsr.ch>
parents:
5707
diff
changeset
|
433 |
} |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
434 |
else if (ipv4->GetRoutingProtocol () != 0) |
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
|
435 |
{ |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
436 |
Ipv4Header header; |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
437 |
header.SetDestination (dest); |
5680
25c3039f4144
problem with protocol number fixed
Borovkova Elena <borovkovaes@iitp.ru>
parents:
4697
diff
changeset
|
438 |
header.SetProtocol (UdpL4Protocol::PROT_NUMBER); |
4567
32ca321e4fe7
Bug 597: Ns-3 doesn't compile under MingWin
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents:
4505
diff
changeset
|
439 |
Socket::SocketErrno errno_; |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
440 |
Ptr<Ipv4Route> route; |
5856
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5769
diff
changeset
|
441 |
Ptr<NetDevice> oif = m_boundnetdevice; //specify non-zero if bound to a specific device |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
442 |
// TBD-- we could cache the route and just check its validity |
4603
67a0a49c1db4
bug 592: Ipv4RoutingProtocol::RouteOutput needs a packet pointer argument for reactive protocols
Josh Pelkey <joshpelkey@gmail.com>
parents:
4567
diff
changeset
|
443 |
route = ipv4->GetRoutingProtocol ()->RouteOutput (p, header, oif, errno_); |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
444 |
if (route != 0) |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
445 |
{ |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
446 |
NS_LOG_LOGIC ("Route exists"); |
6439
958a299f1100
Enforce the AllowBroadcast socket option for UDP sockets
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6437
diff
changeset
|
447 |
if (!m_allowBroadcast) |
958a299f1100
Enforce the AllowBroadcast socket option for UDP sockets
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6437
diff
changeset
|
448 |
{ |
958a299f1100
Enforce the AllowBroadcast socket option for UDP sockets
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6437
diff
changeset
|
449 |
uint32_t outputIfIndex = ipv4->GetInterfaceForDevice (route->GetOutputDevice ()); |
958a299f1100
Enforce the AllowBroadcast socket option for UDP sockets
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6437
diff
changeset
|
450 |
uint32_t ifNAddr = ipv4->GetNAddresses (outputIfIndex); |
958a299f1100
Enforce the AllowBroadcast socket option for UDP sockets
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6437
diff
changeset
|
451 |
for (uint32_t addrI = 0; addrI < ifNAddr; ++addrI) |
958a299f1100
Enforce the AllowBroadcast socket option for UDP sockets
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6437
diff
changeset
|
452 |
{ |
958a299f1100
Enforce the AllowBroadcast socket option for UDP sockets
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6437
diff
changeset
|
453 |
Ipv4InterfaceAddress ifAddr = ipv4->GetAddress (outputIfIndex, addrI); |
958a299f1100
Enforce the AllowBroadcast socket option for UDP sockets
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6437
diff
changeset
|
454 |
if (dest == ifAddr.GetBroadcast ()) |
958a299f1100
Enforce the AllowBroadcast socket option for UDP sockets
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6437
diff
changeset
|
455 |
{ |
958a299f1100
Enforce the AllowBroadcast socket option for UDP sockets
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6437
diff
changeset
|
456 |
m_errno = ERROR_OPNOTSUPP; |
958a299f1100
Enforce the AllowBroadcast socket option for UDP sockets
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6437
diff
changeset
|
457 |
return -1; |
958a299f1100
Enforce the AllowBroadcast socket option for UDP sockets
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6437
diff
changeset
|
458 |
} |
958a299f1100
Enforce the AllowBroadcast socket option for UDP sockets
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6437
diff
changeset
|
459 |
} |
958a299f1100
Enforce the AllowBroadcast socket option for UDP sockets
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6437
diff
changeset
|
460 |
} |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
461 |
|
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
462 |
header.SetSource (route->GetSource ()); |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
463 |
m_udp->Send (p->Copy (), header.GetSource (), header.GetDestination (), |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
464 |
m_endPoint->GetLocalPort (), port, route); |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
465 |
NotifyDataSent (p->GetSize ()); |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7222
diff
changeset
|
466 |
return p->GetSize (); |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
467 |
} |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
468 |
else |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
469 |
{ |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
470 |
NS_LOG_LOGIC ("No route to destination"); |
4567
32ca321e4fe7
Bug 597: Ns-3 doesn't compile under MingWin
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents:
4505
diff
changeset
|
471 |
NS_LOG_ERROR (errno_); |
32ca321e4fe7
Bug 597: Ns-3 doesn't compile under MingWin
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents:
4505
diff
changeset
|
472 |
m_errno = errno_; |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
473 |
return -1; |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
474 |
} |
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
|
475 |
} |
82629189efff
Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents:
1308
diff
changeset
|
476 |
else |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
477 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1452
diff
changeset
|
478 |
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
|
479 |
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
|
480 |
return -1; |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
481 |
} |
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
|
482 |
|
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
483 |
return 0; |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
484 |
} |
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
|
485 |
|
3122
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
486 |
// XXX maximum message size for UDP broadcast is limited by MTU |
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
487 |
// size of underlying link; we are not checking that now. |
3105
682950a37ea6
Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents:
3104
diff
changeset
|
488 |
uint32_t |
3130
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
489 |
UdpSocketImpl::GetTxAvailable (void) const |
3105
682950a37ea6
Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents:
3104
diff
changeset
|
490 |
{ |
3113
e6740c0582bf
tweak UdpSocket buffer limit behavior
Tom Henderson <tomh@tomh.org>
parents:
3107
diff
changeset
|
491 |
NS_LOG_FUNCTION_NOARGS (); |
3122
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
492 |
// No finite send buffer is modelled, but we must respect |
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
493 |
// the maximum size of an IP datagram (65535 bytes - headers). |
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
494 |
return MAX_IPV4_UDP_DATAGRAM_SIZE; |
3105
682950a37ea6
Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents:
3104
diff
changeset
|
495 |
} |
682950a37ea6
Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents:
3104
diff
changeset
|
496 |
|
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
497 |
int |
3269
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3213
diff
changeset
|
498 |
UdpSocketImpl::SendTo (Ptr<Packet> p, uint32_t flags, const Address &address) |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
499 |
{ |
3269
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3213
diff
changeset
|
500 |
NS_LOG_FUNCTION (this << p << flags << address); |
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
|
501 |
InetSocketAddress transport = InetSocketAddress::ConvertFrom (address); |
1162
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
742
diff
changeset
|
502 |
Ipv4Address ipv4 = transport.GetIpv4 (); |
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
742
diff
changeset
|
503 |
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
|
504 |
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
|
505 |
} |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
506 |
|
3269
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3213
diff
changeset
|
507 |
uint32_t |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3213
diff
changeset
|
508 |
UdpSocketImpl::GetRxAvailable (void) const |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3213
diff
changeset
|
509 |
{ |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3213
diff
changeset
|
510 |
NS_LOG_FUNCTION_NOARGS (); |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3213
diff
changeset
|
511 |
// We separately maintain this state to avoid walking the queue |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3213
diff
changeset
|
512 |
// every time this might be called |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3213
diff
changeset
|
513 |
return m_rxAvailable; |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3213
diff
changeset
|
514 |
} |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3213
diff
changeset
|
515 |
|
3098
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
516 |
Ptr<Packet> |
3130
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
517 |
UdpSocketImpl::Recv (uint32_t maxSize, uint32_t flags) |
3098
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
518 |
{ |
3269
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3213
diff
changeset
|
519 |
NS_LOG_FUNCTION (this << maxSize << flags); |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7222
diff
changeset
|
520 |
if (m_deliveryQueue.empty () ) |
3098
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
521 |
{ |
3820 | 522 |
m_errno = ERROR_AGAIN; |
3098
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
523 |
return 0; |
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
524 |
} |
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
525 |
Ptr<Packet> p = m_deliveryQueue.front (); |
3104 | 526 |
if (p->GetSize () <= maxSize) |
3098
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
527 |
{ |
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
528 |
m_deliveryQueue.pop (); |
3104 | 529 |
m_rxAvailable -= p->GetSize (); |
3098
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
530 |
} |
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
531 |
else |
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
532 |
{ |
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
533 |
p = 0; |
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
534 |
} |
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
535 |
return p; |
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
536 |
} |
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
537 |
|
3269
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3213
diff
changeset
|
538 |
Ptr<Packet> |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3213
diff
changeset
|
539 |
UdpSocketImpl::RecvFrom (uint32_t maxSize, uint32_t flags, |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
540 |
Address &fromAddress) |
3104 | 541 |
{ |
3269
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3213
diff
changeset
|
542 |
NS_LOG_FUNCTION (this << maxSize << flags); |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3213
diff
changeset
|
543 |
Ptr<Packet> packet = Recv (maxSize, flags); |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3213
diff
changeset
|
544 |
if (packet != 0) |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3213
diff
changeset
|
545 |
{ |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3213
diff
changeset
|
546 |
SocketAddressTag tag; |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3213
diff
changeset
|
547 |
bool found; |
4502 | 548 |
found = packet->PeekPacketTag (tag); |
3269
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3213
diff
changeset
|
549 |
NS_ASSERT (found); |
7222
bcee1d4b5bc3
Bug 1154 - part 3 'found' set but not used, g++ > 4.6.0
John Abraham<john.abraham@gatech.edu>
parents:
7176
diff
changeset
|
550 |
//cast found to void, to suppress 'found' set but not used,compiler warning |
bcee1d4b5bc3
Bug 1154 - part 3 'found' set but not used, g++ > 4.6.0
John Abraham<john.abraham@gatech.edu>
parents:
7176
diff
changeset
|
551 |
//in optimized builds |
bcee1d4b5bc3
Bug 1154 - part 3 'found' set but not used, g++ > 4.6.0
John Abraham<john.abraham@gatech.edu>
parents:
7176
diff
changeset
|
552 |
(void) found; |
3269
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3213
diff
changeset
|
553 |
fromAddress = tag.GetAddress (); |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3213
diff
changeset
|
554 |
} |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3213
diff
changeset
|
555 |
return packet; |
3104 | 556 |
} |
557 |
||
3778
78c4c41557f3
Liu's GetSockName patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
3776
diff
changeset
|
558 |
int |
78c4c41557f3
Liu's GetSockName patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
3776
diff
changeset
|
559 |
UdpSocketImpl::GetSockName (Address &address) const |
78c4c41557f3
Liu's GetSockName patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
3776
diff
changeset
|
560 |
{ |
78c4c41557f3
Liu's GetSockName patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
3776
diff
changeset
|
561 |
NS_LOG_FUNCTION_NOARGS (); |
78c4c41557f3
Liu's GetSockName patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
3776
diff
changeset
|
562 |
if (m_endPoint != 0) |
78c4c41557f3
Liu's GetSockName patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
3776
diff
changeset
|
563 |
{ |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7222
diff
changeset
|
564 |
address = InetSocketAddress (m_endPoint->GetLocalAddress (), m_endPoint->GetLocalPort ()); |
3778
78c4c41557f3
Liu's GetSockName patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
3776
diff
changeset
|
565 |
} |
78c4c41557f3
Liu's GetSockName patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
3776
diff
changeset
|
566 |
else |
78c4c41557f3
Liu's GetSockName patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
3776
diff
changeset
|
567 |
{ |
6093
bf2ffaeca24f
[bug 810] Tcp GetSockName() for unconnected sockets
Bill Roome <wdr@bell-labs.com>
parents:
5971
diff
changeset
|
568 |
// It is possible to call this method on a socket without a name |
bf2ffaeca24f
[bug 810] Tcp GetSockName() for unconnected sockets
Bill Roome <wdr@bell-labs.com>
parents:
5971
diff
changeset
|
569 |
// in which case, behavior is unspecified |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7222
diff
changeset
|
570 |
address = InetSocketAddress (Ipv4Address::GetZero (), 0); |
3778
78c4c41557f3
Liu's GetSockName patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
3776
diff
changeset
|
571 |
} |
78c4c41557f3
Liu's GetSockName patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
3776
diff
changeset
|
572 |
return 0; |
78c4c41557f3
Liu's GetSockName patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
3776
diff
changeset
|
573 |
} |
78c4c41557f3
Liu's GetSockName patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
3776
diff
changeset
|
574 |
|
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
575 |
int |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
576 |
UdpSocketImpl::MulticastJoinGroup (uint32_t interface, const Address &groupAddress) |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
577 |
{ |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
578 |
NS_LOG_FUNCTION (interface << groupAddress); |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
579 |
/* |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
580 |
1) sanity check interface |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
581 |
2) sanity check that it has not been called yet on this interface/group |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
582 |
3) determine address family of groupAddress |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
583 |
4) locally store a list of (interface, groupAddress) |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
584 |
5) call ipv4->MulticastJoinGroup () or Ipv6->MulticastJoinGroup () |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
585 |
*/ |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
586 |
return 0; |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
587 |
} |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
588 |
|
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
589 |
int |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
590 |
UdpSocketImpl::MulticastLeaveGroup (uint32_t interface, const Address &groupAddress) |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
591 |
{ |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
592 |
NS_LOG_FUNCTION (interface << groupAddress); |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
593 |
/* |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
594 |
1) sanity check interface |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
595 |
2) determine address family of groupAddress |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
596 |
3) delete from local list of (interface, groupAddress); raise a LOG_WARN |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
597 |
if not already present (but return 0) |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
598 |
5) call ipv4->MulticastLeaveGroup () or Ipv6->MulticastLeaveGroup () |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
599 |
*/ |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
600 |
return 0; |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
601 |
} |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
602 |
|
5856
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5769
diff
changeset
|
603 |
void |
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5769
diff
changeset
|
604 |
UdpSocketImpl::BindToNetDevice (Ptr<NetDevice> netdevice) |
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5769
diff
changeset
|
605 |
{ |
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5769
diff
changeset
|
606 |
NS_LOG_FUNCTION (netdevice); |
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5769
diff
changeset
|
607 |
Socket::BindToNetDevice (netdevice); // Includes sanity check |
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5769
diff
changeset
|
608 |
if (m_endPoint == 0) |
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5769
diff
changeset
|
609 |
{ |
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5769
diff
changeset
|
610 |
if (Bind () == -1) |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
611 |
{ |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
612 |
NS_ASSERT (m_endPoint == 0); |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
613 |
return; |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
614 |
} |
5856
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5769
diff
changeset
|
615 |
NS_ASSERT (m_endPoint != 0); |
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5769
diff
changeset
|
616 |
} |
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5769
diff
changeset
|
617 |
m_endPoint->BindToNetDevice (netdevice); |
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5769
diff
changeset
|
618 |
return; |
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5769
diff
changeset
|
619 |
} |
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5769
diff
changeset
|
620 |
|
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
621 |
void |
6442
f380cf1aa4d8
Bug 671 add packet-info-tag.cc for IP_PKTINFO/IPV6_PKTINFO
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
6439
diff
changeset
|
622 |
UdpSocketImpl::ForwardUp (Ptr<Packet> packet, Ipv4Header header, uint16_t port, |
f380cf1aa4d8
Bug 671 add packet-info-tag.cc for IP_PKTINFO/IPV6_PKTINFO
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
6439
diff
changeset
|
623 |
Ptr<Ipv4Interface> incomingInterface) |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
624 |
{ |
6442
f380cf1aa4d8
Bug 671 add packet-info-tag.cc for IP_PKTINFO/IPV6_PKTINFO
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
6439
diff
changeset
|
625 |
NS_LOG_FUNCTION (this << packet << header << port); |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1270
diff
changeset
|
626 |
|
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
627 |
if (m_shutdownRecv) |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
628 |
{ |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
629 |
return; |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
630 |
} |
6442
f380cf1aa4d8
Bug 671 add packet-info-tag.cc for IP_PKTINFO/IPV6_PKTINFO
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
6439
diff
changeset
|
631 |
|
f380cf1aa4d8
Bug 671 add packet-info-tag.cc for IP_PKTINFO/IPV6_PKTINFO
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
6439
diff
changeset
|
632 |
// Should check via getsockopt ().. |
f380cf1aa4d8
Bug 671 add packet-info-tag.cc for IP_PKTINFO/IPV6_PKTINFO
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
6439
diff
changeset
|
633 |
if (this->m_recvpktinfo) |
f380cf1aa4d8
Bug 671 add packet-info-tag.cc for IP_PKTINFO/IPV6_PKTINFO
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
6439
diff
changeset
|
634 |
{ |
f380cf1aa4d8
Bug 671 add packet-info-tag.cc for IP_PKTINFO/IPV6_PKTINFO
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
6439
diff
changeset
|
635 |
Ipv4PacketInfoTag tag; |
f380cf1aa4d8
Bug 671 add packet-info-tag.cc for IP_PKTINFO/IPV6_PKTINFO
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
6439
diff
changeset
|
636 |
packet->RemovePacketTag (tag); |
f380cf1aa4d8
Bug 671 add packet-info-tag.cc for IP_PKTINFO/IPV6_PKTINFO
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
6439
diff
changeset
|
637 |
tag.SetRecvIf (incomingInterface->GetDevice ()->GetIfIndex ()); |
f380cf1aa4d8
Bug 671 add packet-info-tag.cc for IP_PKTINFO/IPV6_PKTINFO
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
6439
diff
changeset
|
638 |
packet->AddPacketTag (tag); |
f380cf1aa4d8
Bug 671 add packet-info-tag.cc for IP_PKTINFO/IPV6_PKTINFO
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
6439
diff
changeset
|
639 |
} |
f380cf1aa4d8
Bug 671 add packet-info-tag.cc for IP_PKTINFO/IPV6_PKTINFO
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
6439
diff
changeset
|
640 |
|
3123
fae57a467d54
undo SocketDefaults class; plumb in new UdpSocket option attributes
Tom Henderson <tomh@tomh.org>
parents:
3122
diff
changeset
|
641 |
if ((m_rxAvailable + packet->GetSize ()) <= m_rcvBufSize) |
3105
682950a37ea6
Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents:
3104
diff
changeset
|
642 |
{ |
6442
f380cf1aa4d8
Bug 671 add packet-info-tag.cc for IP_PKTINFO/IPV6_PKTINFO
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
6439
diff
changeset
|
643 |
Address address = InetSocketAddress (header.GetSource (), port); |
3269
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3213
diff
changeset
|
644 |
SocketAddressTag tag; |
3105
682950a37ea6
Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents:
3104
diff
changeset
|
645 |
tag.SetAddress (address); |
4502 | 646 |
packet->AddPacketTag (tag); |
3105
682950a37ea6
Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents:
3104
diff
changeset
|
647 |
m_deliveryQueue.push (packet); |
682950a37ea6
Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents:
3104
diff
changeset
|
648 |
m_rxAvailable += packet->GetSize (); |
682950a37ea6
Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents:
3104
diff
changeset
|
649 |
NotifyDataRecv (); |
682950a37ea6
Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents:
3104
diff
changeset
|
650 |
} |
682950a37ea6
Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents:
3104
diff
changeset
|
651 |
else |
682950a37ea6
Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents:
3104
diff
changeset
|
652 |
{ |
682950a37ea6
Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents:
3104
diff
changeset
|
653 |
// In general, this case should not occur unless the |
682950a37ea6
Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents:
3104
diff
changeset
|
654 |
// receiving application reads data from this socket slowly |
682950a37ea6
Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents:
3104
diff
changeset
|
655 |
// in comparison to the arrival rate |
682950a37ea6
Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents:
3104
diff
changeset
|
656 |
// |
682950a37ea6
Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents:
3104
diff
changeset
|
657 |
// drop and trace packet |
682950a37ea6
Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents:
3104
diff
changeset
|
658 |
NS_LOG_WARN ("No receive buffer space available. Drop."); |
682950a37ea6
Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents:
3104
diff
changeset
|
659 |
m_dropTrace (packet); |
682950a37ea6
Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents:
3104
diff
changeset
|
660 |
} |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
661 |
} |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
662 |
|
3820 | 663 |
void |
664 |
UdpSocketImpl::ForwardIcmp (Ipv4Address icmpSource, uint8_t icmpTtl, |
|
665 |
uint8_t icmpType, uint8_t icmpCode, |
|
666 |
uint32_t icmpInfo) |
|
667 |
{ |
|
668 |
NS_LOG_FUNCTION (this << icmpSource << (uint32_t)icmpTtl << (uint32_t)icmpType << |
|
669 |
(uint32_t)icmpCode << icmpInfo); |
|
670 |
if (!m_icmpCallback.IsNull ()) |
|
671 |
{ |
|
672 |
m_icmpCallback (icmpSource, icmpTtl, icmpType, icmpCode, icmpInfo); |
|
673 |
} |
|
674 |
} |
|
675 |
||
3127
f5971b43ee58
Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents:
3125
diff
changeset
|
676 |
|
f5971b43ee58
Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents:
3125
diff
changeset
|
677 |
void |
3130
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
678 |
UdpSocketImpl::SetRcvBufSize (uint32_t size) |
3127
f5971b43ee58
Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents:
3125
diff
changeset
|
679 |
{ |
f5971b43ee58
Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents:
3125
diff
changeset
|
680 |
m_rcvBufSize = size; |
f5971b43ee58
Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents:
3125
diff
changeset
|
681 |
} |
f5971b43ee58
Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents:
3125
diff
changeset
|
682 |
|
f5971b43ee58
Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents:
3125
diff
changeset
|
683 |
uint32_t |
3130
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
684 |
UdpSocketImpl::GetRcvBufSize (void) const |
3127
f5971b43ee58
Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents:
3125
diff
changeset
|
685 |
{ |
f5971b43ee58
Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents:
3125
diff
changeset
|
686 |
return m_rcvBufSize; |
f5971b43ee58
Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents:
3125
diff
changeset
|
687 |
} |
f5971b43ee58
Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents:
3125
diff
changeset
|
688 |
|
f5971b43ee58
Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents:
3125
diff
changeset
|
689 |
void |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
690 |
UdpSocketImpl::SetIpTtl (uint8_t ipTtl) |
3127
f5971b43ee58
Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents:
3125
diff
changeset
|
691 |
{ |
f5971b43ee58
Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents:
3125
diff
changeset
|
692 |
m_ipTtl = ipTtl; |
f5971b43ee58
Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents:
3125
diff
changeset
|
693 |
} |
f5971b43ee58
Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents:
3125
diff
changeset
|
694 |
|
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
695 |
uint8_t |
3130
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
696 |
UdpSocketImpl::GetIpTtl (void) const |
3127
f5971b43ee58
Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents:
3125
diff
changeset
|
697 |
{ |
f5971b43ee58
Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents:
3125
diff
changeset
|
698 |
return m_ipTtl; |
f5971b43ee58
Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents:
3125
diff
changeset
|
699 |
} |
f5971b43ee58
Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents:
3125
diff
changeset
|
700 |
|
f5971b43ee58
Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents:
3125
diff
changeset
|
701 |
void |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
702 |
UdpSocketImpl::SetIpMulticastTtl (uint8_t ipTtl) |
3127
f5971b43ee58
Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents:
3125
diff
changeset
|
703 |
{ |
f5971b43ee58
Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents:
3125
diff
changeset
|
704 |
m_ipMulticastTtl = ipTtl; |
f5971b43ee58
Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents:
3125
diff
changeset
|
705 |
} |
f5971b43ee58
Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents:
3125
diff
changeset
|
706 |
|
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
707 |
uint8_t |
3130
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
708 |
UdpSocketImpl::GetIpMulticastTtl (void) const |
3127
f5971b43ee58
Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents:
3125
diff
changeset
|
709 |
{ |
f5971b43ee58
Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents:
3125
diff
changeset
|
710 |
return m_ipMulticastTtl; |
f5971b43ee58
Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents:
3125
diff
changeset
|
711 |
} |
f5971b43ee58
Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents:
3125
diff
changeset
|
712 |
|
3820 | 713 |
void |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
714 |
UdpSocketImpl::SetIpMulticastIf (int32_t ipIf) |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
715 |
{ |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
716 |
m_ipMulticastIf = ipIf; |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
717 |
} |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
718 |
|
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
719 |
int32_t |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
720 |
UdpSocketImpl::GetIpMulticastIf (void) const |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
721 |
{ |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
722 |
return m_ipMulticastIf; |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
723 |
} |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
724 |
|
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
725 |
void |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
726 |
UdpSocketImpl::SetIpMulticastLoop (bool loop) |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
727 |
{ |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
728 |
m_ipMulticastLoop = loop; |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
729 |
} |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
730 |
|
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
731 |
bool |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
732 |
UdpSocketImpl::GetIpMulticastLoop (void) const |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
733 |
{ |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
734 |
return m_ipMulticastLoop; |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
735 |
} |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
736 |
|
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
737 |
void |
3820 | 738 |
UdpSocketImpl::SetMtuDiscover (bool discover) |
739 |
{ |
|
740 |
m_mtuDiscover = discover; |
|
741 |
} |
|
742 |
bool |
|
743 |
UdpSocketImpl::GetMtuDiscover (void) const |
|
744 |
{ |
|
745 |
return m_mtuDiscover; |
|
746 |
} |
|
747 |
||
6448
184a509cc71d
Still Bug 943: fix UdpSocketImpl::GetAllowBroadcast, let Socket::SetAllowBroadcast return a bool indicating success/failure, instead of a fatal error.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6442
diff
changeset
|
748 |
bool |
6437
c11291f51d57
Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6170
diff
changeset
|
749 |
UdpSocketImpl::SetAllowBroadcast (bool allowBroadcast) |
c11291f51d57
Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6170
diff
changeset
|
750 |
{ |
6439
958a299f1100
Enforce the AllowBroadcast socket option for UDP sockets
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6437
diff
changeset
|
751 |
m_allowBroadcast = allowBroadcast; |
6448
184a509cc71d
Still Bug 943: fix UdpSocketImpl::GetAllowBroadcast, let Socket::SetAllowBroadcast return a bool indicating success/failure, instead of a fatal error.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6442
diff
changeset
|
752 |
return true; |
6437
c11291f51d57
Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6170
diff
changeset
|
753 |
} |
c11291f51d57
Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6170
diff
changeset
|
754 |
|
c11291f51d57
Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6170
diff
changeset
|
755 |
bool |
c11291f51d57
Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6170
diff
changeset
|
756 |
UdpSocketImpl::GetAllowBroadcast () const |
c11291f51d57
Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6170
diff
changeset
|
757 |
{ |
6448
184a509cc71d
Still Bug 943: fix UdpSocketImpl::GetAllowBroadcast, let Socket::SetAllowBroadcast return a bool indicating success/failure, instead of a fatal error.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6442
diff
changeset
|
758 |
return m_allowBroadcast; |
6437
c11291f51d57
Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6170
diff
changeset
|
759 |
} |
c11291f51d57
Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6170
diff
changeset
|
760 |
|
3820 | 761 |
|
7386
2310ed220a61
standardize ns-3 namespace declaration format
Vedran Mileti? <rivanvx@gmail.com>
parents:
7385
diff
changeset
|
762 |
} // namespace ns3 |