author | Tom Goff <tgoff@tgoff.net> |
Fri, 13 Dec 2013 22:50:35 -0800 | |
changeset 10524 | 229978c0d228 |
parent 10440 | 1e48ff9185f1 |
child 10528 | c1e835b43726 |
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" |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
24 |
#include "ns3/inet6-socket-address.h" |
1317
82629189efff
Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents:
1308
diff
changeset
|
25 |
#include "ns3/ipv4-route.h" |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
26 |
#include "ns3/ipv6-route.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
|
27 |
#include "ns3/ipv4.h" |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
28 |
#include "ns3/ipv6.h" |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
29 |
#include "ns3/ipv4-header.h" |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
30 |
#include "ns3/ipv4-routing-protocol.h" |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
31 |
#include "ns3/ipv6-routing-protocol.h" |
3125
d2d8a36cfd23
s/ns3::Udp/ns3::UdpSocketFactory
Tom Henderson <tomh@tomh.org>
parents:
3124
diff
changeset
|
32 |
#include "ns3/udp-socket-factory.h" |
3117
c8160bbb2085
Add SocketDefaults to store socket option attributes
Tom Henderson <tomh@tomh.org>
parents:
3113
diff
changeset
|
33 |
#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
|
34 |
#include "ns3/ipv4-packet-info-tag.h" |
3130
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
35 |
#include "udp-socket-impl.h" |
741
38ebb2fb16f5
udp.h -> udp-l4-protocol.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
36 |
#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
|
37 |
#include "ipv4-end-point.h" |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
38 |
#include "ipv6-end-point.h" |
3718
f22f8ab3f6f5
fix build with gcc 4.3.0
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3588
diff
changeset
|
39 |
#include <limits> |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
40 |
|
3130
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
41 |
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
|
42 |
|
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
43 |
namespace ns3 { |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
44 |
|
10410
4d4eb8097fa3
doxygen] Suppress "warning: Member NS_OBJECT_ENSURE_REGISTERED is not documented"
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9894
diff
changeset
|
45 |
NS_OBJECT_ENSURE_REGISTERED (UdpSocketImpl) |
4d4eb8097fa3
doxygen] Suppress "warning: Member NS_OBJECT_ENSURE_REGISTERED is not documented"
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9894
diff
changeset
|
46 |
; |
7870
059b1b83e29b
Bug 962 - list of paths to reach objects contains bogus entries
Mitch Watrous <watrous@u.washington.edu>
parents:
7758
diff
changeset
|
47 |
|
10440
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10410
diff
changeset
|
48 |
// The correct maximum UDP message size is 65507, as determined by the following formula: |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10410
diff
changeset
|
49 |
// 0xffff - (sizeof(IP Header) + sizeof(UDP Header)) = 65535-(20+8) = 65507 |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10410
diff
changeset
|
50 |
// \todo MAX_IPV4_UDP_DATAGRAM_SIZE is correct only for IPv4 |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10410
diff
changeset
|
51 |
static const uint32_t MAX_IPV4_UDP_DATAGRAM_SIZE = 65507; //!< Maximum UDP datagram size |
3122
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
52 |
|
3127
f5971b43ee58
Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents:
3125
diff
changeset
|
53 |
// 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
|
54 |
TypeId |
3130
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
55 |
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
|
56 |
{ |
3130
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
57 |
static TypeId tid = TypeId ("ns3::UdpSocketImpl") |
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
58 |
.SetParent<UdpSocket> () |
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
59 |
.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
|
60 |
.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
|
61 |
MakeTraceSourceAccessor (&UdpSocketImpl::m_dropTrace)) |
3820 | 62 |
.AddAttribute ("IcmpCallback", "Callback invoked whenever an icmp error is received on this socket.", |
63 |
CallbackValue (), |
|
64 |
MakeCallbackAccessor (&UdpSocketImpl::m_icmpCallback), |
|
65 |
MakeCallbackChecker ()) |
|
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
66 |
.AddAttribute ("IcmpCallback6", "Callback invoked whenever an icmpv6 error is received on this socket.", |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
67 |
CallbackValue (), |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
68 |
MakeCallbackAccessor (&UdpSocketImpl::m_icmpCallback6), |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
69 |
MakeCallbackChecker ()) |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
70 |
; |
3105
682950a37ea6
Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents:
3104
diff
changeset
|
71 |
return tid; |
682950a37ea6
Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents:
3104
diff
changeset
|
72 |
} |
682950a37ea6
Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents:
3104
diff
changeset
|
73 |
|
3130
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
74 |
UdpSocketImpl::UdpSocketImpl () |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
75 |
: m_endPoint (0), |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
76 |
m_endPoint6 (0), |
2592
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2574
diff
changeset
|
77 |
m_node (0), |
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2574
diff
changeset
|
78 |
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
|
79 |
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
|
80 |
m_shutdownSend (false), |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
81 |
m_shutdownRecv (false), |
3104 | 82 |
m_connected (false), |
3123
fae57a467d54
undo SocketDefaults class; plumb in new UdpSocket option attributes
Tom Henderson <tomh@tomh.org>
parents:
3122
diff
changeset
|
83 |
m_rxAvailable (0) |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1270
diff
changeset
|
84 |
{ |
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
|
85 |
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
|
86 |
m_allowBroadcast = false; |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1270
diff
changeset
|
87 |
} |
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1270
diff
changeset
|
88 |
|
3130
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
89 |
UdpSocketImpl::~UdpSocketImpl () |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
90 |
{ |
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
|
91 |
NS_LOG_FUNCTION_NOARGS (); |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1270
diff
changeset
|
92 |
|
9870
6543f3876ff5
[Doxygen] use \todo
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9145
diff
changeset
|
93 |
/// \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
|
94 |
m_node = 0; |
7747
53a26ce38807
Bug 1377: various memory leaks
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7717
diff
changeset
|
95 |
/** |
53a26ce38807
Bug 1377: various memory leaks
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7717
diff
changeset
|
96 |
* Note: actually this function is called AFTER |
53a26ce38807
Bug 1377: various memory leaks
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7717
diff
changeset
|
97 |
* UdpSocketImpl::Destroy or UdpSocketImpl::Destroy6 |
53a26ce38807
Bug 1377: various memory leaks
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7717
diff
changeset
|
98 |
* so the code below is unnecessary in normal operations |
53a26ce38807
Bug 1377: various memory leaks
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7717
diff
changeset
|
99 |
*/ |
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
|
100 |
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
|
101 |
{ |
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
|
102 |
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
|
103 |
/** |
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
|
104 |
* 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
|
105 |
* 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
|
106 |
* 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
|
107 |
* a delete of the associated endPoint which triggers |
7600
57ba46094a0d
fix various doxygen errors
Vedran Miletić <rivanvx@gmail.com>
parents:
7386
diff
changeset
|
108 |
* in turn a call to the method UdpSocketImpl::Destroy below |
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
|
109 |
* 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
|
110 |
*/ |
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
|
111 |
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
|
112 |
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
|
113 |
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
|
114 |
} |
7747
53a26ce38807
Bug 1377: various memory leaks
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7717
diff
changeset
|
115 |
if (m_endPoint6 != 0) |
53a26ce38807
Bug 1377: various memory leaks
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7717
diff
changeset
|
116 |
{ |
53a26ce38807
Bug 1377: various memory leaks
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7717
diff
changeset
|
117 |
NS_ASSERT (m_udp != 0); |
53a26ce38807
Bug 1377: various memory leaks
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7717
diff
changeset
|
118 |
/** |
53a26ce38807
Bug 1377: various memory leaks
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7717
diff
changeset
|
119 |
* Note that this piece of code is a bit tricky: |
53a26ce38807
Bug 1377: various memory leaks
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7717
diff
changeset
|
120 |
* when DeAllocate is called, it will call into |
53a26ce38807
Bug 1377: various memory leaks
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7717
diff
changeset
|
121 |
* Ipv4EndPointDemux::Deallocate which triggers |
53a26ce38807
Bug 1377: various memory leaks
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7717
diff
changeset
|
122 |
* a delete of the associated endPoint which triggers |
53a26ce38807
Bug 1377: various memory leaks
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7717
diff
changeset
|
123 |
* in turn a call to the method UdpSocketImpl::Destroy below |
53a26ce38807
Bug 1377: various memory leaks
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7717
diff
changeset
|
124 |
* will will zero the m_endPoint field. |
53a26ce38807
Bug 1377: various memory leaks
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7717
diff
changeset
|
125 |
*/ |
53a26ce38807
Bug 1377: various memory leaks
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7717
diff
changeset
|
126 |
NS_ASSERT (m_endPoint6 != 0); |
53a26ce38807
Bug 1377: various memory leaks
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7717
diff
changeset
|
127 |
m_udp->DeAllocate (m_endPoint6); |
53a26ce38807
Bug 1377: various memory leaks
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7717
diff
changeset
|
128 |
NS_ASSERT (m_endPoint6 == 0); |
53a26ce38807
Bug 1377: various memory leaks
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7717
diff
changeset
|
129 |
} |
568
e1660959ecbb
use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
557
diff
changeset
|
130 |
m_udp = 0; |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
131 |
} |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
132 |
|
2592
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2574
diff
changeset
|
133 |
void |
3130
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
134 |
UdpSocketImpl::SetNode (Ptr<Node> node) |
2592
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2574
diff
changeset
|
135 |
{ |
3113
e6740c0582bf
tweak UdpSocket buffer limit behavior
Tom Henderson <tomh@tomh.org>
parents:
3107
diff
changeset
|
136 |
NS_LOG_FUNCTION_NOARGS (); |
2592
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2574
diff
changeset
|
137 |
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
|
138 |
|
2592
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2574
diff
changeset
|
139 |
} |
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2574
diff
changeset
|
140 |
void |
3130
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
141 |
UdpSocketImpl::SetUdp (Ptr<UdpL4Protocol> udp) |
2592
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2574
diff
changeset
|
142 |
{ |
3113
e6740c0582bf
tweak UdpSocket buffer limit behavior
Tom Henderson <tomh@tomh.org>
parents:
3107
diff
changeset
|
143 |
NS_LOG_FUNCTION_NOARGS (); |
2592
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2574
diff
changeset
|
144 |
m_udp = udp; |
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2574
diff
changeset
|
145 |
} |
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2574
diff
changeset
|
146 |
|
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2574
diff
changeset
|
147 |
|
1264
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
148 |
enum Socket::SocketErrno |
3130
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
149 |
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
|
150 |
{ |
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
|
151 |
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
|
152 |
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
|
153 |
} |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
154 |
|
6689
e2de571e920a
Implement Socket::GetSocketType
Josh Pelkey <jpelkey@gatech.edu>
parents:
6448
diff
changeset
|
155 |
enum Socket::SocketType |
e2de571e920a
Implement Socket::GetSocketType
Josh Pelkey <jpelkey@gatech.edu>
parents:
6448
diff
changeset
|
156 |
UdpSocketImpl::GetSocketType (void) const |
e2de571e920a
Implement Socket::GetSocketType
Josh Pelkey <jpelkey@gatech.edu>
parents:
6448
diff
changeset
|
157 |
{ |
6692
591fb1aa0ca4
Avoid enum name collision in socket
Josh Pelkey <jpelkey@gatech.edu>
parents:
6689
diff
changeset
|
158 |
return NS3_SOCK_DGRAM; |
6689
e2de571e920a
Implement Socket::GetSocketType
Josh Pelkey <jpelkey@gatech.edu>
parents:
6448
diff
changeset
|
159 |
} |
e2de571e920a
Implement Socket::GetSocketType
Josh Pelkey <jpelkey@gatech.edu>
parents:
6448
diff
changeset
|
160 |
|
728
95c426b1cb60
rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
646
diff
changeset
|
161 |
Ptr<Node> |
3130
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
162 |
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
|
163 |
{ |
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
|
164 |
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
|
165 |
return m_node; |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
166 |
} |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
167 |
|
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
168 |
void |
3130
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
169 |
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
|
170 |
{ |
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
|
171 |
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
|
172 |
m_endPoint = 0; |
7747
53a26ce38807
Bug 1377: various memory leaks
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7717
diff
changeset
|
173 |
} |
53a26ce38807
Bug 1377: various memory leaks
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7717
diff
changeset
|
174 |
|
53a26ce38807
Bug 1377: various memory leaks
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7717
diff
changeset
|
175 |
void |
53a26ce38807
Bug 1377: various memory leaks
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7717
diff
changeset
|
176 |
UdpSocketImpl::Destroy6 (void) |
53a26ce38807
Bug 1377: various memory leaks
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7717
diff
changeset
|
177 |
{ |
53a26ce38807
Bug 1377: various memory leaks
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7717
diff
changeset
|
178 |
NS_LOG_FUNCTION_NOARGS (); |
53a26ce38807
Bug 1377: various memory leaks
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7717
diff
changeset
|
179 |
m_endPoint6 = 0; |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
180 |
} |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1270
diff
changeset
|
181 |
|
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
182 |
int |
3130
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
183 |
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
|
184 |
{ |
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
|
185 |
NS_LOG_FUNCTION_NOARGS (); |
7747
53a26ce38807
Bug 1377: various memory leaks
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7717
diff
changeset
|
186 |
bool done = false; |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
187 |
if (m_endPoint != 0) |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
188 |
{ |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
189 |
m_endPoint->SetRxCallback (MakeCallback (&UdpSocketImpl::ForwardUp, Ptr<UdpSocketImpl> (this))); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
190 |
m_endPoint->SetIcmpCallback (MakeCallback (&UdpSocketImpl::ForwardIcmp, Ptr<UdpSocketImpl> (this))); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
191 |
m_endPoint->SetDestroyCallback (MakeCallback (&UdpSocketImpl::Destroy, Ptr<UdpSocketImpl> (this))); |
7747
53a26ce38807
Bug 1377: various memory leaks
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7717
diff
changeset
|
192 |
done = true; |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
193 |
} |
7747
53a26ce38807
Bug 1377: various memory leaks
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7717
diff
changeset
|
194 |
if (m_endPoint6 != 0) |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
195 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
196 |
m_endPoint6->SetRxCallback (MakeCallback (&UdpSocketImpl::ForwardUp6, Ptr<UdpSocketImpl> (this))); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
197 |
m_endPoint6->SetIcmpCallback (MakeCallback (&UdpSocketImpl::ForwardIcmp6, Ptr<UdpSocketImpl> (this))); |
7747
53a26ce38807
Bug 1377: various memory leaks
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7717
diff
changeset
|
198 |
m_endPoint6->SetDestroyCallback (MakeCallback (&UdpSocketImpl::Destroy6, Ptr<UdpSocketImpl> (this))); |
53a26ce38807
Bug 1377: various memory leaks
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7717
diff
changeset
|
199 |
done = true; |
53a26ce38807
Bug 1377: various memory leaks
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7717
diff
changeset
|
200 |
} |
53a26ce38807
Bug 1377: various memory leaks
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7717
diff
changeset
|
201 |
if (done) |
53a26ce38807
Bug 1377: various memory leaks
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7717
diff
changeset
|
202 |
{ |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
203 |
return 0; |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
204 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
205 |
return -1; |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
206 |
} |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
207 |
|
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
208 |
int |
3130
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
209 |
UdpSocketImpl::Bind (void) |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
210 |
{ |
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
|
211 |
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
|
212 |
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
|
213 |
return FinishBind (); |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
214 |
} |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1270
diff
changeset
|
215 |
|
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
216 |
int |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
217 |
UdpSocketImpl::Bind6 (void) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
218 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
219 |
NS_LOG_FUNCTION_NOARGS (); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
220 |
m_endPoint6 = m_udp->Allocate6 (); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
221 |
return FinishBind (); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
222 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
223 |
|
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
224 |
int |
3130
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
225 |
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
|
226 |
{ |
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
|
227 |
NS_LOG_FUNCTION (this << address); |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1270
diff
changeset
|
228 |
|
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
229 |
if (InetSocketAddress::IsMatchingType (address)) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
230 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
231 |
InetSocketAddress transport = InetSocketAddress::ConvertFrom (address); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
232 |
Ipv4Address ipv4 = transport.GetIpv4 (); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
233 |
uint16_t port = transport.GetPort (); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
234 |
if (ipv4 == Ipv4Address::GetAny () && port == 0) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
235 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
236 |
m_endPoint = m_udp->Allocate (); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
237 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
238 |
else if (ipv4 == Ipv4Address::GetAny () && port != 0) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
239 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
240 |
m_endPoint = m_udp->Allocate (port); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
241 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
242 |
else if (ipv4 != Ipv4Address::GetAny () && port == 0) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
243 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
244 |
m_endPoint = m_udp->Allocate (ipv4); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
245 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
246 |
else if (ipv4 != Ipv4Address::GetAny () && port != 0) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
247 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
248 |
m_endPoint = m_udp->Allocate (ipv4, port); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
249 |
} |
10524
229978c0d228
bug 1767: make UDP sockets return error when binding to address already in use
Tom Goff <tgoff@tgoff.net>
parents:
10440
diff
changeset
|
250 |
if (0 == m_endPoint) |
229978c0d228
bug 1767: make UDP sockets return error when binding to address already in use
Tom Goff <tgoff@tgoff.net>
parents:
10440
diff
changeset
|
251 |
{ |
229978c0d228
bug 1767: make UDP sockets return error when binding to address already in use
Tom Goff <tgoff@tgoff.net>
parents:
10440
diff
changeset
|
252 |
m_errno = port ? ERROR_ADDRINUSE : ERROR_ADDRNOTAVAIL; |
229978c0d228
bug 1767: make UDP sockets return error when binding to address already in use
Tom Goff <tgoff@tgoff.net>
parents:
10440
diff
changeset
|
253 |
return -1; |
229978c0d228
bug 1767: make UDP sockets return error when binding to address already in use
Tom Goff <tgoff@tgoff.net>
parents:
10440
diff
changeset
|
254 |
} |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
255 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
256 |
else if (Inet6SocketAddress::IsMatchingType (address)) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
257 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
258 |
Inet6SocketAddress transport = Inet6SocketAddress::ConvertFrom (address); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
259 |
Ipv6Address ipv6 = transport.GetIpv6 (); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
260 |
uint16_t port = transport.GetPort (); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
261 |
if (ipv6 == Ipv6Address::GetAny () && port == 0) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
262 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
263 |
m_endPoint6 = m_udp->Allocate6 (); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
264 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
265 |
else if (ipv6 == Ipv6Address::GetAny () && port != 0) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
266 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
267 |
m_endPoint6 = m_udp->Allocate6 (port); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
268 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
269 |
else if (ipv6 != Ipv6Address::GetAny () && port == 0) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
270 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
271 |
m_endPoint6 = m_udp->Allocate6 (ipv6); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
272 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
273 |
else if (ipv6 != Ipv6Address::GetAny () && port != 0) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
274 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
275 |
m_endPoint6 = m_udp->Allocate6 (ipv6, port); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
276 |
} |
10524
229978c0d228
bug 1767: make UDP sockets return error when binding to address already in use
Tom Goff <tgoff@tgoff.net>
parents:
10440
diff
changeset
|
277 |
if (0 == m_endPoint6) |
229978c0d228
bug 1767: make UDP sockets return error when binding to address already in use
Tom Goff <tgoff@tgoff.net>
parents:
10440
diff
changeset
|
278 |
{ |
229978c0d228
bug 1767: make UDP sockets return error when binding to address already in use
Tom Goff <tgoff@tgoff.net>
parents:
10440
diff
changeset
|
279 |
m_errno = port ? ERROR_ADDRINUSE : ERROR_ADDRNOTAVAIL; |
229978c0d228
bug 1767: make UDP sockets return error when binding to address already in use
Tom Goff <tgoff@tgoff.net>
parents:
10440
diff
changeset
|
280 |
return -1; |
229978c0d228
bug 1767: make UDP sockets return error when binding to address already in use
Tom Goff <tgoff@tgoff.net>
parents:
10440
diff
changeset
|
281 |
} |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
282 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
283 |
else |
1172
2e5b994330c7
add InetSocketAddress::IsMatchingType and use it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1171
diff
changeset
|
284 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1452
diff
changeset
|
285 |
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
|
286 |
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
|
287 |
return -1; |
1172
2e5b994330c7
add InetSocketAddress::IsMatchingType and use it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1171
diff
changeset
|
288 |
} |
1162
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
742
diff
changeset
|
289 |
|
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
290 |
return FinishBind (); |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
291 |
} |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
292 |
|
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
293 |
int |
3130
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
294 |
UdpSocketImpl::ShutdownSend (void) |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
295 |
{ |
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
|
296 |
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
|
297 |
m_shutdownSend = true; |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
298 |
return 0; |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
299 |
} |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1270
diff
changeset
|
300 |
|
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
301 |
int |
3130
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
302 |
UdpSocketImpl::ShutdownRecv (void) |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
303 |
{ |
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
|
304 |
NS_LOG_FUNCTION_NOARGS (); |
4491
893d48fcf7f3
bug 535: UDP/TCP ShutdownRecv incorrect
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4472
diff
changeset
|
305 |
m_shutdownRecv = true; |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
306 |
return 0; |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
307 |
} |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
308 |
|
1186
909e9eb2124e
rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1182
diff
changeset
|
309 |
int |
4697
6e048d6486d8
Implement UdpSocketImpl::Close ()
Tom Henderson <tomh@tomh.org>
parents:
4603
diff
changeset
|
310 |
UdpSocketImpl::Close (void) |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
311 |
{ |
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
|
312 |
NS_LOG_FUNCTION_NOARGS (); |
4697
6e048d6486d8
Implement UdpSocketImpl::Close ()
Tom Henderson <tomh@tomh.org>
parents:
4603
diff
changeset
|
313 |
if (m_shutdownRecv == true && m_shutdownSend == true) |
6e048d6486d8
Implement UdpSocketImpl::Close ()
Tom Henderson <tomh@tomh.org>
parents:
4603
diff
changeset
|
314 |
{ |
6e048d6486d8
Implement UdpSocketImpl::Close ()
Tom Henderson <tomh@tomh.org>
parents:
4603
diff
changeset
|
315 |
m_errno = Socket::ERROR_BADF; |
6e048d6486d8
Implement UdpSocketImpl::Close ()
Tom Henderson <tomh@tomh.org>
parents:
4603
diff
changeset
|
316 |
return -1; |
6e048d6486d8
Implement UdpSocketImpl::Close ()
Tom Henderson <tomh@tomh.org>
parents:
4603
diff
changeset
|
317 |
} |
6e048d6486d8
Implement UdpSocketImpl::Close ()
Tom Henderson <tomh@tomh.org>
parents:
4603
diff
changeset
|
318 |
m_shutdownRecv = true; |
6e048d6486d8
Implement UdpSocketImpl::Close ()
Tom Henderson <tomh@tomh.org>
parents:
4603
diff
changeset
|
319 |
m_shutdownSend = true; |
1186
909e9eb2124e
rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1182
diff
changeset
|
320 |
return 0; |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
321 |
} |
1264
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
322 |
|
1186
909e9eb2124e
rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1182
diff
changeset
|
323 |
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
|
324 |
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
|
325 |
{ |
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
|
326 |
NS_LOG_FUNCTION (this << address); |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
327 |
if (InetSocketAddress::IsMatchingType(address) == true) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
328 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
329 |
InetSocketAddress transport = InetSocketAddress::ConvertFrom (address); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
330 |
m_defaultAddress = Address(transport.GetIpv4 ()); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
331 |
m_defaultPort = transport.GetPort (); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
332 |
m_connected = true; |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
333 |
NotifyConnectionSucceeded (); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
334 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
335 |
else if (Inet6SocketAddress::IsMatchingType(address) == true) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
336 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
337 |
Inet6SocketAddress transport = Inet6SocketAddress::ConvertFrom (address); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
338 |
m_defaultAddress = Address(transport.GetIpv6 ()); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
339 |
m_defaultPort = transport.GetPort (); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
340 |
m_connected = true; |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
341 |
NotifyConnectionSucceeded (); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
342 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
343 |
else |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
344 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
345 |
return -1; |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
346 |
} |
1434
2b63aafb050b
set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents:
1429
diff
changeset
|
347 |
|
1186
909e9eb2124e
rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1182
diff
changeset
|
348 |
return 0; |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
349 |
} |
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
|
350 |
|
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
351 |
int |
3772
f0d8608ab155
Remove queue limit from listen
Craig Dowell <craigdo@ee.washington.edu>
parents:
3718
diff
changeset
|
352 |
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
|
353 |
{ |
08a0424399fb
bug 203: Listen must be implemented for Udp and Packet sockets.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3157
diff
changeset
|
354 |
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
|
355 |
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
|
356 |
} |
08a0424399fb
bug 203: Listen must be implemented for Udp and Packet sockets.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3157
diff
changeset
|
357 |
|
08a0424399fb
bug 203: Listen must be implemented for Udp and Packet sockets.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3157
diff
changeset
|
358 |
int |
3269
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3213
diff
changeset
|
359 |
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
|
360 |
{ |
3269
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3213
diff
changeset
|
361 |
NS_LOG_FUNCTION (this << p << flags); |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1270
diff
changeset
|
362 |
|
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
363 |
if (!m_connected) |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
364 |
{ |
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
|
365 |
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
|
366 |
return -1; |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
367 |
} |
9145
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
368 |
|
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
|
369 |
return DoSend (p); |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
370 |
} |
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
|
371 |
|
82629189efff
Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents:
1308
diff
changeset
|
372 |
int |
3130
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
373 |
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
|
374 |
{ |
3269
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3213
diff
changeset
|
375 |
NS_LOG_FUNCTION (this << p); |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
376 |
if ((m_endPoint == 0) && (InetSocketAddress::IsMatchingType(m_defaultAddress) == true)) |
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
|
377 |
{ |
82629189efff
Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents:
1308
diff
changeset
|
378 |
if (Bind () == -1) |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
379 |
{ |
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
|
380 |
NS_ASSERT (m_endPoint == 0); |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
381 |
return -1; |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
382 |
} |
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
|
383 |
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
|
384 |
} |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
385 |
else if ((m_endPoint6 == 0) && (Inet6SocketAddress::IsMatchingType(m_defaultAddress) == true)) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
386 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
387 |
if (Bind6 () == -1) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
388 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
389 |
NS_ASSERT (m_endPoint6 == 0); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
390 |
return -1; |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
391 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
392 |
NS_ASSERT (m_endPoint6 != 0); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
393 |
} |
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
|
394 |
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
|
395 |
{ |
82629189efff
Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents:
1308
diff
changeset
|
396 |
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
|
397 |
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
|
398 |
} |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
399 |
|
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
400 |
return DoSendTo (p, (const Address)m_defaultAddress); |
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
|
401 |
} |
82629189efff
Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents:
1308
diff
changeset
|
402 |
|
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
403 |
int |
3130
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
404 |
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
|
405 |
{ |
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
|
406 |
NS_LOG_FUNCTION (this << p << address); |
1449 | 407 |
|
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
|
408 |
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
|
409 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1452
diff
changeset
|
410 |
NS_LOG_LOGIC ("Not connected"); |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
411 |
if (InetSocketAddress::IsMatchingType(address) == true) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
412 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
413 |
InetSocketAddress transport = InetSocketAddress::ConvertFrom (address); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
414 |
Ipv4Address ipv4 = transport.GetIpv4 (); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
415 |
uint16_t port = transport.GetPort (); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
416 |
return DoSendTo (p, ipv4, port); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
417 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
418 |
else if (Inet6SocketAddress::IsMatchingType(address) == true) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
419 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
420 |
Inet6SocketAddress transport = Inet6SocketAddress::ConvertFrom (address); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
421 |
Ipv6Address ipv6 = transport.GetIpv6 (); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
422 |
uint16_t port = transport.GetPort (); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
423 |
return DoSendTo (p, ipv6, port); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
424 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
425 |
else |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
426 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
427 |
return -1; |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
428 |
} |
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
|
429 |
} |
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
|
430 |
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
|
431 |
{ |
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
|
432 |
// connected UDP socket must use default addresses |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1452
diff
changeset
|
433 |
NS_LOG_LOGIC ("Connected"); |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
434 |
if (Ipv4Address::IsMatchingType(m_defaultAddress)) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
435 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
436 |
return DoSendTo (p, Ipv4Address::ConvertFrom(m_defaultAddress), m_defaultPort); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
437 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
438 |
else if (Ipv6Address::IsMatchingType(m_defaultAddress)) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
439 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
440 |
return DoSendTo (p, Ipv6Address::ConvertFrom(m_defaultAddress), m_defaultPort); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
441 |
} |
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
|
442 |
} |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
443 |
m_errno = ERROR_AFNOSUPPORT; |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
444 |
return(-1); |
1162
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
742
diff
changeset
|
445 |
} |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1270
diff
changeset
|
446 |
|
1162
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
742
diff
changeset
|
447 |
int |
3130
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
448 |
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
|
449 |
{ |
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
|
450 |
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
|
451 |
if (m_boundnetdevice) |
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents:
5769
diff
changeset
|
452 |
{ |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7222
diff
changeset
|
453 |
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
|
454 |
} |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
455 |
if (m_endPoint == 0) |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
456 |
{ |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
457 |
if (Bind () == -1) |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
458 |
{ |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
459 |
NS_ASSERT (m_endPoint == 0); |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
460 |
return -1; |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
461 |
} |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
462 |
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
|
463 |
} |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
464 |
if (m_shutdownSend) |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
465 |
{ |
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
|
466 |
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
|
467 |
return -1; |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
468 |
} |
1452
973c456d3684
socket update broke multicast
Craig Dowell <craigdo@ee.washington.edu>
parents:
1450
diff
changeset
|
469 |
|
3122
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
470 |
if (p->GetSize () > GetTxAvailable () ) |
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
471 |
{ |
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
472 |
m_errno = ERROR_MSGSIZE; |
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
473 |
return -1; |
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
474 |
} |
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
475 |
|
9145
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
476 |
if (IsManualIpTos ()) |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
477 |
{ |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
478 |
SocketIpTosTag ipTosTag; |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
479 |
ipTosTag.SetTos (GetIpTos ()); |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
480 |
p->AddPacketTag (ipTosTag); |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
481 |
} |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
482 |
|
2257
71a58e70c671
QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2231
diff
changeset
|
483 |
Ptr<Ipv4> ipv4 = m_node->GetObject<Ipv4> (); |
1452
973c456d3684
socket update broke multicast
Craig Dowell <craigdo@ee.washington.edu>
parents:
1450
diff
changeset
|
484 |
|
3124
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
485 |
// Locally override the IP TTL for this socket |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
486 |
// 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
|
487 |
// 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
|
488 |
// 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
|
489 |
// 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
|
490 |
// 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
|
491 |
// 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
|
492 |
// 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
|
493 |
if (m_ipMulticastTtl != 0 && dest.IsMulticast ()) |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
494 |
{ |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
495 |
SocketIpTtlTag tag; |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
496 |
tag.SetTtl (m_ipMulticastTtl); |
4502 | 497 |
p->AddPacketTag (tag); |
3124
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
498 |
} |
9145
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
499 |
else if (IsManualIpTtl () && GetIpTtl () != 0 && !dest.IsMulticast () && !dest.IsBroadcast ()) |
3124
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
500 |
{ |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
501 |
SocketIpTtlTag tag; |
9145
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
502 |
tag.SetTtl (GetIpTtl ()); |
4502 | 503 |
p->AddPacketTag (tag); |
3124
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
504 |
} |
3820 | 505 |
{ |
506 |
SocketSetDontFragmentTag tag; |
|
4502 | 507 |
bool found = p->RemovePacketTag (tag); |
3820 | 508 |
if (!found) |
509 |
{ |
|
510 |
if (m_mtuDiscover) |
|
511 |
{ |
|
512 |
tag.Enable (); |
|
513 |
} |
|
514 |
else |
|
515 |
{ |
|
516 |
tag.Disable (); |
|
517 |
} |
|
4502 | 518 |
p->AddPacketTag (tag); |
3820 | 519 |
} |
520 |
} |
|
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
|
521 |
// |
3956
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3846
diff
changeset
|
522 |
// 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
|
523 |
// 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
|
524 |
// 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
|
525 |
// 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
|
526 |
// 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
|
527 |
// 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
|
528 |
// 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
|
529 |
// |
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
|
530 |
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
|
531 |
{ |
6439
958a299f1100
Enforce the AllowBroadcast socket option for UDP sockets
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6437
diff
changeset
|
532 |
if (!m_allowBroadcast) |
958a299f1100
Enforce the AllowBroadcast socket option for UDP sockets
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6437
diff
changeset
|
533 |
{ |
958a299f1100
Enforce the AllowBroadcast socket option for UDP sockets
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6437
diff
changeset
|
534 |
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
|
535 |
return -1; |
958a299f1100
Enforce the AllowBroadcast socket option for UDP sockets
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6437
diff
changeset
|
536 |
} |
2299
0b9193f38f18
Some more udp socket debug messages
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2257
diff
changeset
|
537 |
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
|
538 |
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
|
539 |
{ |
4375
db81fdcb06e7
Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
540 |
// Get the primary address |
db81fdcb06e7
Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
541 |
Ipv4InterfaceAddress iaddr = ipv4->GetAddress (i, 0); |
db81fdcb06e7
Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
542 |
Ipv4Address addri = iaddr.GetLocal (); |
5696
207f9059840d
send to limited broadcast fixed
Borovkova Elena <borovkovaes@iitp.ru>
parents:
5680
diff
changeset
|
543 |
if (addri == Ipv4Address ("127.0.0.1")) |
207f9059840d
send to limited broadcast fixed
Borovkova Elena <borovkovaes@iitp.ru>
parents:
5680
diff
changeset
|
544 |
continue; |
5856
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents:
5769
diff
changeset
|
545 |
// Check if interface-bound socket |
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents:
5769
diff
changeset
|
546 |
if (m_boundnetdevice) |
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents:
5769
diff
changeset
|
547 |
{ |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7222
diff
changeset
|
548 |
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
|
549 |
continue; |
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents:
5769
diff
changeset
|
550 |
} |
4375
db81fdcb06e7
Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
551 |
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
|
552 |
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
|
553 |
{ |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3846
diff
changeset
|
554 |
// 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
|
555 |
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
|
556 |
<< " (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
|
557 |
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
|
558 |
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
|
559 |
NotifyDataSent (p->GetSize ()); |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3846
diff
changeset
|
560 |
NotifySend (GetTxAvailable ()); |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3846
diff
changeset
|
561 |
} |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3846
diff
changeset
|
562 |
else |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3846
diff
changeset
|
563 |
{ |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3846
diff
changeset
|
564 |
// 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
|
565 |
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
|
566 |
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
|
567 |
<< " (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
|
568 |
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
|
569 |
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
|
570 |
NotifyDataSent (p->GetSize ()); |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3846
diff
changeset
|
571 |
NotifySend (GetTxAvailable ()); |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3846
diff
changeset
|
572 |
} |
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
|
573 |
} |
2299
0b9193f38f18
Some more udp socket debug messages
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2257
diff
changeset
|
574 |
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
|
575 |
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
|
576 |
} |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7222
diff
changeset
|
577 |
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
|
578 |
{ |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7222
diff
changeset
|
579 |
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
|
580 |
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
|
581 |
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
|
582 |
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
|
583 |
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
|
584 |
} |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
585 |
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
|
586 |
{ |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
587 |
Ipv4Header header; |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
588 |
header.SetDestination (dest); |
5680
25c3039f4144
problem with protocol number fixed
Borovkova Elena <borovkovaes@iitp.ru>
parents:
4697
diff
changeset
|
589 |
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
|
590 |
Socket::SocketErrno errno_; |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
591 |
Ptr<Ipv4Route> route; |
5856
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents:
5769
diff
changeset
|
592 |
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
|
593 |
// 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
|
594 |
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
|
595 |
if (route != 0) |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
596 |
{ |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
597 |
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
|
598 |
if (!m_allowBroadcast) |
958a299f1100
Enforce the AllowBroadcast socket option for UDP sockets
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6437
diff
changeset
|
599 |
{ |
958a299f1100
Enforce the AllowBroadcast socket option for UDP sockets
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6437
diff
changeset
|
600 |
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
|
601 |
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
|
602 |
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
|
603 |
{ |
958a299f1100
Enforce the AllowBroadcast socket option for UDP sockets
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6437
diff
changeset
|
604 |
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
|
605 |
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
|
606 |
{ |
958a299f1100
Enforce the AllowBroadcast socket option for UDP sockets
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6437
diff
changeset
|
607 |
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
|
608 |
return -1; |
958a299f1100
Enforce the AllowBroadcast socket option for UDP sockets
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6437
diff
changeset
|
609 |
} |
958a299f1100
Enforce the AllowBroadcast socket option for UDP sockets
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6437
diff
changeset
|
610 |
} |
958a299f1100
Enforce the AllowBroadcast socket option for UDP sockets
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6437
diff
changeset
|
611 |
} |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
612 |
|
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
613 |
header.SetSource (route->GetSource ()); |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
614 |
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
|
615 |
m_endPoint->GetLocalPort (), port, route); |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
616 |
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
|
617 |
return p->GetSize (); |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
618 |
} |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
619 |
else |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
620 |
{ |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
621 |
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
|
622 |
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
|
623 |
m_errno = errno_; |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
624 |
return -1; |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
625 |
} |
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
|
626 |
} |
82629189efff
Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents:
1308
diff
changeset
|
627 |
else |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
628 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1452
diff
changeset
|
629 |
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
|
630 |
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
|
631 |
return -1; |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
632 |
} |
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
|
633 |
|
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
634 |
return 0; |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
635 |
} |
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
|
636 |
|
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
637 |
int |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
638 |
UdpSocketImpl::DoSendTo (Ptr<Packet> p, Ipv6Address dest, uint16_t port) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
639 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
640 |
NS_LOG_FUNCTION (this << p << dest << port); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
641 |
|
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
642 |
if (dest.IsIpv4MappedAddress ()) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
643 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
644 |
return (DoSendTo(p, dest.GetIpv4MappedAddress (), port)); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
645 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
646 |
if (m_boundnetdevice) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
647 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
648 |
NS_LOG_LOGIC ("Bound interface number " << m_boundnetdevice->GetIfIndex ()); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
649 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
650 |
if (m_endPoint6 == 0) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
651 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
652 |
if (Bind6 () == -1) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
653 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
654 |
NS_ASSERT (m_endPoint6 == 0); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
655 |
return -1; |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
656 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
657 |
NS_ASSERT (m_endPoint6 != 0); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
658 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
659 |
if (m_shutdownSend) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
660 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
661 |
m_errno = ERROR_SHUTDOWN; |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
662 |
return -1; |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
663 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
664 |
|
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
665 |
if (p->GetSize () > GetTxAvailable () ) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
666 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
667 |
m_errno = ERROR_MSGSIZE; |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
668 |
return -1; |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
669 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
670 |
|
9145
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
671 |
if (IsManualIpv6Tclass ()) |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
672 |
{ |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
673 |
SocketIpv6TclassTag ipTclassTag; |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
674 |
ipTclassTag.SetTclass (GetIpv6Tclass ()); |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
675 |
p->AddPacketTag (ipTclassTag); |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
676 |
} |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
677 |
|
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
678 |
Ptr<Ipv6> ipv6 = m_node->GetObject<Ipv6> (); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
679 |
|
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
680 |
// Locally override the IP TTL for this socket |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
681 |
// We cannot directly modify the TTL at this stage, so we set a Packet tag |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
682 |
// The destination can be either multicast, unicast/anycast, or |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
683 |
// either all-hosts broadcast or limited (subnet-directed) broadcast. |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
684 |
// For the latter two broadcast types, the TTL will later be set to one |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
685 |
// irrespective of what is set in these socket options. So, this tagging |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
686 |
// may end up setting the TTL of a limited broadcast packet to be |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
687 |
// the same as a unicast, but it will be fixed further down the stack |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
688 |
if (m_ipMulticastTtl != 0 && dest.IsMulticast ()) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
689 |
{ |
9145
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
690 |
SocketIpv6HopLimitTag tag; |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
691 |
tag.SetHopLimit (m_ipMulticastTtl); |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
692 |
p->AddPacketTag (tag); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
693 |
} |
9145
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
694 |
else if (IsManualIpv6HopLimit () && GetIpv6HopLimit () != 0 && !dest.IsMulticast ()) |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
695 |
{ |
9145
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
696 |
SocketIpv6HopLimitTag tag; |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
697 |
tag.SetHopLimit (GetIpv6HopLimit ()); |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
698 |
p->AddPacketTag (tag); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
699 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
700 |
// There is no analgous to an IPv4 broadcast address in IPv6. |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
701 |
// Instead, we use a set of link-local, site-local, and global |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
702 |
// multicast addresses. The Ipv6 routing layers should all |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
703 |
// provide an interface-specific route to these addresses such |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
704 |
// that we can treat these multicast addresses as "not broadcast" |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
705 |
|
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
706 |
if (m_endPoint6->GetLocalAddress () != Ipv6Address::GetAny ()) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
707 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
708 |
m_udp->Send (p->Copy (), m_endPoint6->GetLocalAddress (), dest, |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
709 |
m_endPoint6->GetLocalPort (), port, 0); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
710 |
NotifyDataSent (p->GetSize ()); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
711 |
NotifySend (GetTxAvailable ()); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
712 |
return p->GetSize (); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
713 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
714 |
else if (ipv6->GetRoutingProtocol () != 0) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
715 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
716 |
Ipv6Header header; |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
717 |
header.SetDestinationAddress (dest); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
718 |
header.SetNextHeader (UdpL4Protocol::PROT_NUMBER); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
719 |
Socket::SocketErrno errno_; |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
720 |
Ptr<Ipv6Route> route; |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
721 |
Ptr<NetDevice> oif = m_boundnetdevice; //specify non-zero if bound to a specific device |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
722 |
// TBD-- we could cache the route and just check its validity |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
723 |
route = ipv6->GetRoutingProtocol ()->RouteOutput (p, header, oif, errno_); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
724 |
if (route != 0) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
725 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
726 |
NS_LOG_LOGIC ("Route exists"); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
727 |
header.SetSourceAddress (route->GetSource ()); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
728 |
m_udp->Send (p->Copy (), header.GetSourceAddress (), header.GetDestinationAddress (), |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
729 |
m_endPoint6->GetLocalPort (), port, route); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
730 |
NotifyDataSent (p->GetSize ()); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
731 |
return p->GetSize (); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
732 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
733 |
else |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
734 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
735 |
NS_LOG_LOGIC ("No route to destination"); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
736 |
NS_LOG_ERROR (errno_); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
737 |
m_errno = errno_; |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
738 |
return -1; |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
739 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
740 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
741 |
else |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
742 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
743 |
NS_LOG_ERROR ("ERROR_NOROUTETOHOST"); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
744 |
m_errno = ERROR_NOROUTETOHOST; |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
745 |
return -1; |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
746 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
747 |
|
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
748 |
return 0; |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
749 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
750 |
|
9894
ac4e52a91d5d
Doxygenate todo's
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9870
diff
changeset
|
751 |
|
10440
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10410
diff
changeset
|
752 |
// maximum message size for UDP broadcast is limited by MTU |
3122
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
753 |
// size of underlying link; we are not checking that now. |
10440
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10410
diff
changeset
|
754 |
// \todo Check MTU size of underlying link |
3105
682950a37ea6
Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents:
3104
diff
changeset
|
755 |
uint32_t |
3130
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
756 |
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
|
757 |
{ |
3113
e6740c0582bf
tweak UdpSocket buffer limit behavior
Tom Henderson <tomh@tomh.org>
parents:
3107
diff
changeset
|
758 |
NS_LOG_FUNCTION_NOARGS (); |
3122
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
759 |
// No finite send buffer is modelled, but we must respect |
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
760 |
// the maximum size of an IP datagram (65535 bytes - headers). |
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
761 |
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
|
762 |
} |
682950a37ea6
Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents:
3104
diff
changeset
|
763 |
|
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
764 |
int |
3269
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3213
diff
changeset
|
765 |
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
|
766 |
{ |
3269
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3213
diff
changeset
|
767 |
NS_LOG_FUNCTION (this << p << flags << address); |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
768 |
if (InetSocketAddress::IsMatchingType (address)) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
769 |
{ |
9145
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
770 |
if (IsManualIpTos ()) |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
771 |
{ |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
772 |
SocketIpTosTag ipTosTag; |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
773 |
ipTosTag.SetTos (GetIpTos ()); |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
774 |
p->AddPacketTag (ipTosTag); |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
775 |
} |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
776 |
|
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
777 |
InetSocketAddress transport = InetSocketAddress::ConvertFrom (address); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
778 |
Ipv4Address ipv4 = transport.GetIpv4 (); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
779 |
uint16_t port = transport.GetPort (); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
780 |
return DoSendTo (p, ipv4, port); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
781 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
782 |
else if (Inet6SocketAddress::IsMatchingType (address)) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
783 |
{ |
9145
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
784 |
if (IsManualIpv6Tclass ()) |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
785 |
{ |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
786 |
SocketIpv6TclassTag ipTclassTag; |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
787 |
ipTclassTag.SetTclass (GetIpv6Tclass ()); |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
788 |
p->AddPacketTag (ipTclassTag); |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
789 |
} |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
790 |
|
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
791 |
Inet6SocketAddress transport = Inet6SocketAddress::ConvertFrom (address); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
792 |
Ipv6Address ipv6 = transport.GetIpv6 (); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
793 |
uint16_t port = transport.GetPort (); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
794 |
return DoSendTo (p, ipv6, port); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
795 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
796 |
return -1; |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
797 |
} |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
798 |
|
3269
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3213
diff
changeset
|
799 |
uint32_t |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3213
diff
changeset
|
800 |
UdpSocketImpl::GetRxAvailable (void) const |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3213
diff
changeset
|
801 |
{ |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3213
diff
changeset
|
802 |
NS_LOG_FUNCTION_NOARGS (); |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3213
diff
changeset
|
803 |
// 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
|
804 |
// 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
|
805 |
return m_rxAvailable; |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3213
diff
changeset
|
806 |
} |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3213
diff
changeset
|
807 |
|
3098
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
808 |
Ptr<Packet> |
3130
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
809 |
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
|
810 |
{ |
3269
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3213
diff
changeset
|
811 |
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
|
812 |
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
|
813 |
{ |
3820 | 814 |
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
|
815 |
return 0; |
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
816 |
} |
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
817 |
Ptr<Packet> p = m_deliveryQueue.front (); |
3104 | 818 |
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
|
819 |
{ |
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
820 |
m_deliveryQueue.pop (); |
3104 | 821 |
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
|
822 |
} |
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
823 |
else |
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
824 |
{ |
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
825 |
p = 0; |
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
826 |
} |
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
827 |
return p; |
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
828 |
} |
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
829 |
|
3269
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3213
diff
changeset
|
830 |
Ptr<Packet> |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3213
diff
changeset
|
831 |
UdpSocketImpl::RecvFrom (uint32_t maxSize, uint32_t flags, |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
832 |
Address &fromAddress) |
3104 | 833 |
{ |
3269
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3213
diff
changeset
|
834 |
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
|
835 |
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
|
836 |
if (packet != 0) |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3213
diff
changeset
|
837 |
{ |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3213
diff
changeset
|
838 |
SocketAddressTag tag; |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3213
diff
changeset
|
839 |
bool found; |
4502 | 840 |
found = packet->PeekPacketTag (tag); |
3269
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3213
diff
changeset
|
841 |
NS_ASSERT (found); |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3213
diff
changeset
|
842 |
fromAddress = tag.GetAddress (); |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3213
diff
changeset
|
843 |
} |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3213
diff
changeset
|
844 |
return packet; |
3104 | 845 |
} |
846 |
||
3778
78c4c41557f3
Liu's GetSockName patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
3776
diff
changeset
|
847 |
int |
78c4c41557f3
Liu's GetSockName patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
3776
diff
changeset
|
848 |
UdpSocketImpl::GetSockName (Address &address) const |
78c4c41557f3
Liu's GetSockName patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
3776
diff
changeset
|
849 |
{ |
78c4c41557f3
Liu's GetSockName patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
3776
diff
changeset
|
850 |
NS_LOG_FUNCTION_NOARGS (); |
78c4c41557f3
Liu's GetSockName patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
3776
diff
changeset
|
851 |
if (m_endPoint != 0) |
78c4c41557f3
Liu's GetSockName patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
3776
diff
changeset
|
852 |
{ |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7222
diff
changeset
|
853 |
address = InetSocketAddress (m_endPoint->GetLocalAddress (), m_endPoint->GetLocalPort ()); |
3778
78c4c41557f3
Liu's GetSockName patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
3776
diff
changeset
|
854 |
} |
78c4c41557f3
Liu's GetSockName patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
3776
diff
changeset
|
855 |
else |
78c4c41557f3
Liu's GetSockName patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
3776
diff
changeset
|
856 |
{ |
6093
bf2ffaeca24f
[bug 810] Tcp GetSockName() for unconnected sockets
Bill Roome <wdr@bell-labs.com>
parents:
5971
diff
changeset
|
857 |
// 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
|
858 |
// 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
|
859 |
address = InetSocketAddress (Ipv4Address::GetZero (), 0); |
3778
78c4c41557f3
Liu's GetSockName patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
3776
diff
changeset
|
860 |
} |
78c4c41557f3
Liu's GetSockName patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
3776
diff
changeset
|
861 |
return 0; |
78c4c41557f3
Liu's GetSockName patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
3776
diff
changeset
|
862 |
} |
78c4c41557f3
Liu's GetSockName patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
3776
diff
changeset
|
863 |
|
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
864 |
int |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
865 |
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
|
866 |
{ |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
867 |
NS_LOG_FUNCTION (interface << groupAddress); |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
868 |
/* |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
869 |
1) sanity check interface |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
870 |
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
|
871 |
3) determine address family of groupAddress |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
872 |
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
|
873 |
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
|
874 |
*/ |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
875 |
return 0; |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
876 |
} |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
877 |
|
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
878 |
int |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
879 |
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
|
880 |
{ |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
881 |
NS_LOG_FUNCTION (interface << groupAddress); |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
882 |
/* |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
883 |
1) sanity check interface |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
884 |
2) determine address family of groupAddress |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
885 |
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
|
886 |
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
|
887 |
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
|
888 |
*/ |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
889 |
return 0; |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
890 |
} |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
891 |
|
5856
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents:
5769
diff
changeset
|
892 |
void |
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents:
5769
diff
changeset
|
893 |
UdpSocketImpl::BindToNetDevice (Ptr<NetDevice> netdevice) |
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents:
5769
diff
changeset
|
894 |
{ |
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents:
5769
diff
changeset
|
895 |
NS_LOG_FUNCTION (netdevice); |
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents:
5769
diff
changeset
|
896 |
Socket::BindToNetDevice (netdevice); // Includes sanity check |
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents:
5769
diff
changeset
|
897 |
if (m_endPoint == 0) |
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents:
5769
diff
changeset
|
898 |
{ |
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents:
5769
diff
changeset
|
899 |
if (Bind () == -1) |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
900 |
{ |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
901 |
NS_ASSERT (m_endPoint == 0); |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
902 |
return; |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
903 |
} |
5856
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents:
5769
diff
changeset
|
904 |
NS_ASSERT (m_endPoint != 0); |
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents:
5769
diff
changeset
|
905 |
} |
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents:
5769
diff
changeset
|
906 |
m_endPoint->BindToNetDevice (netdevice); |
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents:
5769
diff
changeset
|
907 |
return; |
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents:
5769
diff
changeset
|
908 |
} |
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents:
5769
diff
changeset
|
909 |
|
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
910 |
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
|
911 |
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
|
912 |
Ptr<Ipv4Interface> incomingInterface) |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
913 |
{ |
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
|
914 |
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
|
915 |
|
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
916 |
if (m_shutdownRecv) |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
917 |
{ |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
918 |
return; |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
919 |
} |
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
|
920 |
|
f380cf1aa4d8
Bug 671 add packet-info-tag.cc for IP_PKTINFO/IPV6_PKTINFO
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
6439
diff
changeset
|
921 |
// Should check via getsockopt ().. |
7758
c678188af993
Replace references to m_recvpktinfo with method call IsRecvPktInfo()
frederic.urbani@inria.fr
parents:
7747
diff
changeset
|
922 |
if (IsRecvPktInfo ()) |
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
|
923 |
{ |
f380cf1aa4d8
Bug 671 add packet-info-tag.cc for IP_PKTINFO/IPV6_PKTINFO
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
6439
diff
changeset
|
924 |
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
|
925 |
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
|
926 |
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
|
927 |
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
|
928 |
} |
f380cf1aa4d8
Bug 671 add packet-info-tag.cc for IP_PKTINFO/IPV6_PKTINFO
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
6439
diff
changeset
|
929 |
|
9145
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
930 |
//Check only version 4 options |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
931 |
if (IsIpRecvTos ()) |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
932 |
{ |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
933 |
SocketIpTosTag ipTosTag; |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
934 |
ipTosTag.SetTos (header.GetTos ()); |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
935 |
packet->AddPacketTag (ipTosTag); |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
936 |
} |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
937 |
|
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
938 |
if (IsIpRecvTtl ()) |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
939 |
{ |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
940 |
SocketIpTtlTag ipTtlTag; |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
941 |
ipTtlTag.SetTtl (header.GetTtl ()); |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
942 |
packet->AddPacketTag (ipTtlTag); |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
943 |
} |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
944 |
|
3123
fae57a467d54
undo SocketDefaults class; plumb in new UdpSocket option attributes
Tom Henderson <tomh@tomh.org>
parents:
3122
diff
changeset
|
945 |
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
|
946 |
{ |
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
|
947 |
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
|
948 |
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
|
949 |
tag.SetAddress (address); |
4502 | 950 |
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
|
951 |
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
|
952 |
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
|
953 |
NotifyDataRecv (); |
682950a37ea6
Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents:
3104
diff
changeset
|
954 |
} |
682950a37ea6
Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents:
3104
diff
changeset
|
955 |
else |
682950a37ea6
Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents:
3104
diff
changeset
|
956 |
{ |
682950a37ea6
Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents:
3104
diff
changeset
|
957 |
// 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
|
958 |
// 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
|
959 |
// 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
|
960 |
// |
682950a37ea6
Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents:
3104
diff
changeset
|
961 |
// 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
|
962 |
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
|
963 |
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
|
964 |
} |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
965 |
} |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
966 |
|
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
967 |
void |
9145
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
968 |
UdpSocketImpl::ForwardUp6 (Ptr<Packet> packet, Ipv6Header header, uint16_t port) |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
969 |
{ |
9145
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
970 |
NS_LOG_FUNCTION (this << packet << header.GetSourceAddress () << port); |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
971 |
|
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
972 |
if (m_shutdownRecv) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
973 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
974 |
return; |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
975 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
976 |
|
9145
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
977 |
|
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
978 |
//Check only version 6 options |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
979 |
if (IsIpv6RecvTclass ()) |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
980 |
{ |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
981 |
SocketIpv6TclassTag ipTclassTag; |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
982 |
ipTclassTag.SetTclass (header.GetTrafficClass ()); |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
983 |
packet->AddPacketTag (ipTclassTag); |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
984 |
} |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
985 |
|
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
986 |
if (IsIpv6RecvHopLimit ()) |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
987 |
{ |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
988 |
SocketIpv6HopLimitTag ipHopLimitTag; |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
989 |
ipHopLimitTag.SetHopLimit (header.GetHopLimit ()); |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
990 |
packet->AddPacketTag (ipHopLimitTag); |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
991 |
} |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
992 |
|
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
993 |
if ((m_rxAvailable + packet->GetSize ()) <= m_rcvBufSize) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
994 |
{ |
9145
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7870
diff
changeset
|
995 |
Address address = Inet6SocketAddress (header.GetSourceAddress (), port); |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
996 |
SocketAddressTag tag; |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
997 |
tag.SetAddress (address); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
998 |
packet->AddPacketTag (tag); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
999 |
m_deliveryQueue.push (packet); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
1000 |
m_rxAvailable += packet->GetSize (); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
1001 |
NotifyDataRecv (); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
1002 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
1003 |
else |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
1004 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
1005 |
// In general, this case should not occur unless the |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
1006 |
// receiving application reads data from this socket slowly |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
1007 |
// in comparison to the arrival rate |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
1008 |
// |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
1009 |
// drop and trace packet |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
1010 |
NS_LOG_WARN ("No receive buffer space available. Drop."); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
1011 |
m_dropTrace (packet); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
1012 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
1013 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
1014 |
|
3820 | 1015 |
void |
1016 |
UdpSocketImpl::ForwardIcmp (Ipv4Address icmpSource, uint8_t icmpTtl, |
|
1017 |
uint8_t icmpType, uint8_t icmpCode, |
|
1018 |
uint32_t icmpInfo) |
|
1019 |
{ |
|
1020 |
NS_LOG_FUNCTION (this << icmpSource << (uint32_t)icmpTtl << (uint32_t)icmpType << |
|
1021 |
(uint32_t)icmpCode << icmpInfo); |
|
1022 |
if (!m_icmpCallback.IsNull ()) |
|
1023 |
{ |
|
1024 |
m_icmpCallback (icmpSource, icmpTtl, icmpType, icmpCode, icmpInfo); |
|
1025 |
} |
|
1026 |
} |
|
1027 |
||
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
1028 |
void |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
1029 |
UdpSocketImpl::ForwardIcmp6 (Ipv6Address icmpSource, uint8_t icmpTtl, |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
1030 |
uint8_t icmpType, uint8_t icmpCode, |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
1031 |
uint32_t icmpInfo) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
1032 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
1033 |
NS_LOG_FUNCTION (this << icmpSource << (uint32_t)icmpTtl << (uint32_t)icmpType << |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
1034 |
(uint32_t)icmpCode << icmpInfo); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
1035 |
if (!m_icmpCallback6.IsNull ()) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
1036 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
1037 |
m_icmpCallback6 (icmpSource, icmpTtl, icmpType, icmpCode, icmpInfo); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
1038 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
1039 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7704
diff
changeset
|
1040 |
|
3127
f5971b43ee58
Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents:
3125
diff
changeset
|
1041 |
void |
3130
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
1042 |
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
|
1043 |
{ |
f5971b43ee58
Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents:
3125
diff
changeset
|
1044 |
m_rcvBufSize = size; |
f5971b43ee58
Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents:
3125
diff
changeset
|
1045 |
} |
f5971b43ee58
Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents:
3125
diff
changeset
|
1046 |
|
f5971b43ee58
Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents:
3125
diff
changeset
|
1047 |
uint32_t |
3130
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
1048 |
UdpSocketImpl::GetRcvBufSize (void) const |
3127
f5971b43ee58
Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents:
3125
diff
changeset
|
1049 |
{ |
f5971b43ee58
Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents:
3125
diff
changeset
|
1050 |
return m_rcvBufSize; |
f5971b43ee58
Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents:
3125
diff
changeset
|
1051 |
} |
f5971b43ee58
Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents:
3125
diff
changeset
|
1052 |
|
f5971b43ee58
Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents:
3125
diff
changeset
|
1053 |
void |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
1054 |
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
|
1055 |
{ |
f5971b43ee58
Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents:
3125
diff
changeset
|
1056 |
m_ipMulticastTtl = ipTtl; |
f5971b43ee58
Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents:
3125
diff
changeset
|
1057 |
} |
f5971b43ee58
Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents:
3125
diff
changeset
|
1058 |
|
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
1059 |
uint8_t |
3130
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
1060 |
UdpSocketImpl::GetIpMulticastTtl (void) const |
3127
f5971b43ee58
Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents:
3125
diff
changeset
|
1061 |
{ |
f5971b43ee58
Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents:
3125
diff
changeset
|
1062 |
return m_ipMulticastTtl; |
f5971b43ee58
Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents:
3125
diff
changeset
|
1063 |
} |
f5971b43ee58
Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents:
3125
diff
changeset
|
1064 |
|
3820 | 1065 |
void |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
1066 |
UdpSocketImpl::SetIpMulticastIf (int32_t ipIf) |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
1067 |
{ |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
1068 |
m_ipMulticastIf = ipIf; |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
1069 |
} |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
1070 |
|
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
1071 |
int32_t |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
1072 |
UdpSocketImpl::GetIpMulticastIf (void) const |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
1073 |
{ |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
1074 |
return m_ipMulticastIf; |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
1075 |
} |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
1076 |
|
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
1077 |
void |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
1078 |
UdpSocketImpl::SetIpMulticastLoop (bool loop) |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
1079 |
{ |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
1080 |
m_ipMulticastLoop = loop; |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
1081 |
} |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
1082 |
|
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
1083 |
bool |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
1084 |
UdpSocketImpl::GetIpMulticastLoop (void) const |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
1085 |
{ |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
1086 |
return m_ipMulticastLoop; |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
1087 |
} |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
1088 |
|
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
1089 |
void |
3820 | 1090 |
UdpSocketImpl::SetMtuDiscover (bool discover) |
1091 |
{ |
|
1092 |
m_mtuDiscover = discover; |
|
1093 |
} |
|
1094 |
bool |
|
1095 |
UdpSocketImpl::GetMtuDiscover (void) const |
|
1096 |
{ |
|
1097 |
return m_mtuDiscover; |
|
1098 |
} |
|
1099 |
||
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
|
1100 |
bool |
6437
c11291f51d57
Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6170
diff
changeset
|
1101 |
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
|
1102 |
{ |
6439
958a299f1100
Enforce the AllowBroadcast socket option for UDP sockets
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6437
diff
changeset
|
1103 |
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
|
1104 |
return true; |
6437
c11291f51d57
Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6170
diff
changeset
|
1105 |
} |
c11291f51d57
Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6170
diff
changeset
|
1106 |
|
c11291f51d57
Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6170
diff
changeset
|
1107 |
bool |
c11291f51d57
Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6170
diff
changeset
|
1108 |
UdpSocketImpl::GetAllowBroadcast () const |
c11291f51d57
Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6170
diff
changeset
|
1109 |
{ |
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
|
1110 |
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
|
1111 |
} |
c11291f51d57
Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6170
diff
changeset
|
1112 |
|
3820 | 1113 |
|
7386
2310ed220a61
standardize ns-3 namespace declaration format
Vedran Miletić <rivanvx@gmail.com>
parents:
7385
diff
changeset
|
1114 |
} // namespace ns3 |