author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Wed, 02 Jul 2008 03:16:36 -0700 | |
changeset 3365 | 6409d2460601 |
parent 3276 | 8869a79a391f |
child 3772 | f0d8608ab155 |
permissions | -rw-r--r-- |
1264
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
2 |
/* |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
3 |
* Copyright (c) 2006 Georgia Tech Research Corporation |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
4 |
* 2007 INRIA |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
5 |
* |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
6 |
* This program is free software; you can redistribute it and/or modify |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
7 |
* it under the terms of the GNU General Public License version 2 as |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
8 |
* published by the Free Software Foundation; |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
9 |
* |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
10 |
* This program is distributed in the hope that it will be useful, |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
13 |
* GNU General Public License for more details. |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
14 |
* |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
16 |
* along with this program; if not, write to the Free Software |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
17 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
18 |
* |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
19 |
* Authors: George F. Riley<riley@ece.gatech.edu> |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
20 |
* Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
21 |
*/ |
1499
93d51d757afa
working one way echo app
Craig Dowell <craigdo@ee.washington.edu>
parents:
1265
diff
changeset
|
22 |
|
1505 | 23 |
#include "ns3/log.h" |
1499
93d51d757afa
working one way echo app
Craig Dowell <craigdo@ee.washington.edu>
parents:
1265
diff
changeset
|
24 |
#include "ns3/packet.h" |
3116
c33b6d2775b7
Move API for socket factory to a Socket::CreateSocket () factory method
Tom Henderson <tomh@tomh.org>
parents:
3107
diff
changeset
|
25 |
#include "node.h" |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
26 |
#include "socket.h" |
3116
c33b6d2775b7
Move API for socket factory to a Socket::CreateSocket () factory method
Tom Henderson <tomh@tomh.org>
parents:
3107
diff
changeset
|
27 |
#include "socket-factory.h" |
3365
6409d2460601
bug 245: build failure with gcc 4.3.x
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3276
diff
changeset
|
28 |
#include <limits> |
1499
93d51d757afa
working one way echo app
Craig Dowell <craigdo@ee.washington.edu>
parents:
1265
diff
changeset
|
29 |
|
1505 | 30 |
NS_LOG_COMPONENT_DEFINE ("Socket"); |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
31 |
|
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
32 |
namespace ns3 { |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
33 |
|
3107 | 34 |
Socket::Socket (void) |
35 |
{ |
|
36 |
NS_LOG_FUNCTION_NOARGS (); |
|
37 |
} |
|
38 |
||
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
39 |
Socket::~Socket () |
1499
93d51d757afa
working one way echo app
Craig Dowell <craigdo@ee.washington.edu>
parents:
1265
diff
changeset
|
40 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2367
diff
changeset
|
41 |
NS_LOG_FUNCTION_NOARGS (); |
1499
93d51d757afa
working one way echo app
Craig Dowell <craigdo@ee.washington.edu>
parents:
1265
diff
changeset
|
42 |
} |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
43 |
|
3116
c33b6d2775b7
Move API for socket factory to a Socket::CreateSocket () factory method
Tom Henderson <tomh@tomh.org>
parents:
3107
diff
changeset
|
44 |
Ptr<Socket> |
c33b6d2775b7
Move API for socket factory to a Socket::CreateSocket () factory method
Tom Henderson <tomh@tomh.org>
parents:
3107
diff
changeset
|
45 |
Socket::CreateSocket (Ptr<Node> node, TypeId tid) |
c33b6d2775b7
Move API for socket factory to a Socket::CreateSocket () factory method
Tom Henderson <tomh@tomh.org>
parents:
3107
diff
changeset
|
46 |
{ |
c33b6d2775b7
Move API for socket factory to a Socket::CreateSocket () factory method
Tom Henderson <tomh@tomh.org>
parents:
3107
diff
changeset
|
47 |
Ptr<Socket> s; |
c33b6d2775b7
Move API for socket factory to a Socket::CreateSocket () factory method
Tom Henderson <tomh@tomh.org>
parents:
3107
diff
changeset
|
48 |
Ptr<SocketFactory> socketFactory = node->GetObject<SocketFactory> (tid); |
c33b6d2775b7
Move API for socket factory to a Socket::CreateSocket () factory method
Tom Henderson <tomh@tomh.org>
parents:
3107
diff
changeset
|
49 |
s = socketFactory->CreateSocket (); |
c33b6d2775b7
Move API for socket factory to a Socket::CreateSocket () factory method
Tom Henderson <tomh@tomh.org>
parents:
3107
diff
changeset
|
50 |
NS_ASSERT (s != 0); |
c33b6d2775b7
Move API for socket factory to a Socket::CreateSocket () factory method
Tom Henderson <tomh@tomh.org>
parents:
3107
diff
changeset
|
51 |
return s; |
c33b6d2775b7
Move API for socket factory to a Socket::CreateSocket () factory method
Tom Henderson <tomh@tomh.org>
parents:
3107
diff
changeset
|
52 |
} |
c33b6d2775b7
Move API for socket factory to a Socket::CreateSocket () factory method
Tom Henderson <tomh@tomh.org>
parents:
3107
diff
changeset
|
53 |
|
1264
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
54 |
void |
1499
93d51d757afa
working one way echo app
Craig Dowell <craigdo@ee.washington.edu>
parents:
1265
diff
changeset
|
55 |
Socket::SetConnectCallback ( |
93d51d757afa
working one way echo app
Craig Dowell <craigdo@ee.washington.edu>
parents:
1265
diff
changeset
|
56 |
Callback<void, Ptr<Socket> > connectionSucceeded, |
3276
8869a79a391f
Changes for bug 205, unlisted FIN bug
Craig Dowell <craigdo@ee.washington.edu>
parents:
3269
diff
changeset
|
57 |
Callback<void, Ptr<Socket> > connectionFailed) |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
58 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2367
diff
changeset
|
59 |
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
|
60 |
m_connectionSucceeded = connectionSucceeded; |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
61 |
m_connectionFailed = connectionFailed; |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
62 |
} |
1499
93d51d757afa
working one way echo app
Craig Dowell <craigdo@ee.washington.edu>
parents:
1265
diff
changeset
|
63 |
|
1264
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
64 |
void |
1499
93d51d757afa
working one way echo app
Craig Dowell <craigdo@ee.washington.edu>
parents:
1265
diff
changeset
|
65 |
Socket::SetAcceptCallback ( |
93d51d757afa
working one way echo app
Craig Dowell <craigdo@ee.washington.edu>
parents:
1265
diff
changeset
|
66 |
Callback<bool, Ptr<Socket>, const Address &> connectionRequest, |
3276
8869a79a391f
Changes for bug 205, unlisted FIN bug
Craig Dowell <craigdo@ee.washington.edu>
parents:
3269
diff
changeset
|
67 |
Callback<void, Ptr<Socket>, const Address&> newConnectionCreated) |
1264
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
68 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2367
diff
changeset
|
69 |
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
|
70 |
m_connectionRequest = connectionRequest; |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
71 |
m_newConnectionCreated = newConnectionCreated; |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
72 |
} |
1499
93d51d757afa
working one way echo app
Craig Dowell <craigdo@ee.washington.edu>
parents:
1265
diff
changeset
|
73 |
|
2999
0b10920623bf
bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents:
2983
diff
changeset
|
74 |
bool |
0b10920623bf
bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents:
2983
diff
changeset
|
75 |
Socket::SetDataSentCallback (Callback<void, Ptr<Socket>, uint32_t> dataSent) |
1264
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
76 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2367
diff
changeset
|
77 |
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
|
78 |
m_dataSent = dataSent; |
2999
0b10920623bf
bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents:
2983
diff
changeset
|
79 |
return true; |
0b10920623bf
bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents:
2983
diff
changeset
|
80 |
} |
0b10920623bf
bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents:
2983
diff
changeset
|
81 |
|
0b10920623bf
bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents:
2983
diff
changeset
|
82 |
void |
0b10920623bf
bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents:
2983
diff
changeset
|
83 |
Socket::SetSendCallback (Callback<void, Ptr<Socket>, uint32_t> sendCb) |
0b10920623bf
bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents:
2983
diff
changeset
|
84 |
{ |
0b10920623bf
bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents:
2983
diff
changeset
|
85 |
NS_LOG_FUNCTION_NOARGS (); |
0b10920623bf
bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents:
2983
diff
changeset
|
86 |
m_sendCb = sendCb; |
1264
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
87 |
} |
1499
93d51d757afa
working one way echo app
Craig Dowell <craigdo@ee.washington.edu>
parents:
1265
diff
changeset
|
88 |
|
1264
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
89 |
void |
3102 | 90 |
Socket::SetRecvCallback (Callback<void, Ptr<Socket> > receivedData) |
3097
1b1661bbfa33
Plumb in socket receive pull model, in parallel to existing Receive framework
Tom Henderson <tomh@tomh.org>
parents:
3000
diff
changeset
|
91 |
{ |
1b1661bbfa33
Plumb in socket receive pull model, in parallel to existing Receive framework
Tom Henderson <tomh@tomh.org>
parents:
3000
diff
changeset
|
92 |
NS_LOG_FUNCTION_NOARGS (); |
3102 | 93 |
m_receivedData = receivedData; |
3097
1b1661bbfa33
Plumb in socket receive pull model, in parallel to existing Receive framework
Tom Henderson <tomh@tomh.org>
parents:
3000
diff
changeset
|
94 |
} |
1b1661bbfa33
Plumb in socket receive pull model, in parallel to existing Receive framework
Tom Henderson <tomh@tomh.org>
parents:
3000
diff
changeset
|
95 |
|
3269
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
96 |
int |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
97 |
Socket::Send (Ptr<Packet> p) |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
98 |
{ |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
99 |
NS_LOG_FUNCTION_NOARGS (); |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
100 |
return Send (p, 0); |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
101 |
} |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
102 |
|
3000
bd2d3e32ef7b
A few minor cleanups to socket.h/cc
Tom Henderson <tomh@tomh.org>
parents:
2999
diff
changeset
|
103 |
|
3248 | 104 |
int Socket::Listen (uint32_t queueLimit) |
105 |
{ |
|
106 |
return 0; //XXX the base class version does nothing |
|
107 |
} |
|
108 |
||
3269
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
109 |
int |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
110 |
Socket::Send (const uint8_t* buf, uint32_t size, uint32_t flags) |
2186
69ad6ed6ccf4
Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
1866
diff
changeset
|
111 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2367
diff
changeset
|
112 |
NS_LOG_FUNCTION_NOARGS (); |
2186
69ad6ed6ccf4
Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
1866
diff
changeset
|
113 |
Ptr<Packet> p; |
69ad6ed6ccf4
Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
1866
diff
changeset
|
114 |
if (buf) |
69ad6ed6ccf4
Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
1866
diff
changeset
|
115 |
{ |
69ad6ed6ccf4
Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
1866
diff
changeset
|
116 |
p = Create<Packet> (buf, size); |
69ad6ed6ccf4
Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
1866
diff
changeset
|
117 |
} |
69ad6ed6ccf4
Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
1866
diff
changeset
|
118 |
else |
69ad6ed6ccf4
Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
1866
diff
changeset
|
119 |
{ |
69ad6ed6ccf4
Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
1866
diff
changeset
|
120 |
p = Create<Packet> (size); |
69ad6ed6ccf4
Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
1866
diff
changeset
|
121 |
} |
3269
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
122 |
return Send (p, flags); |
3103
91c6fce46125
overloaded Recv() method suggested by Gustavo
Tom Henderson <tomh@tomh.org>
parents:
3102
diff
changeset
|
123 |
} |
91c6fce46125
overloaded Recv() method suggested by Gustavo
Tom Henderson <tomh@tomh.org>
parents:
3102
diff
changeset
|
124 |
|
3142 | 125 |
int |
3269
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
126 |
Socket::SendTo (const uint8_t* buf, uint32_t size, uint32_t flags, |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
127 |
const Address &toAddress) |
2186
69ad6ed6ccf4
Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
1866
diff
changeset
|
128 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2367
diff
changeset
|
129 |
NS_LOG_FUNCTION_NOARGS (); |
2186
69ad6ed6ccf4
Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
1866
diff
changeset
|
130 |
Ptr<Packet> p; |
69ad6ed6ccf4
Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
1866
diff
changeset
|
131 |
if(buf) |
69ad6ed6ccf4
Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
1866
diff
changeset
|
132 |
{ |
69ad6ed6ccf4
Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
1866
diff
changeset
|
133 |
p = Create<Packet> (buf, size); |
69ad6ed6ccf4
Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
1866
diff
changeset
|
134 |
} |
69ad6ed6ccf4
Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
1866
diff
changeset
|
135 |
else |
69ad6ed6ccf4
Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
1866
diff
changeset
|
136 |
{ |
69ad6ed6ccf4
Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
1866
diff
changeset
|
137 |
p = Create<Packet> (size); |
69ad6ed6ccf4
Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
1866
diff
changeset
|
138 |
} |
3269
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
139 |
return SendTo (p, flags, toAddress); |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
140 |
} |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
141 |
|
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
142 |
Ptr<Packet> |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
143 |
Socket::Recv (void) |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
144 |
{ |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
145 |
NS_LOG_FUNCTION_NOARGS (); |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
146 |
return Recv (std::numeric_limits<uint32_t>::max(), 0); |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
147 |
} |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
148 |
|
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
149 |
int |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
150 |
Socket::Recv (uint8_t* buf, uint32_t size, uint32_t flags) |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
151 |
{ |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
152 |
NS_LOG_FUNCTION_NOARGS (); |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
153 |
Ptr<Packet> p = Recv (size, flags); // read up to "size" bytes |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
154 |
if (p == 0) |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
155 |
{ |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
156 |
return 0; |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
157 |
} |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
158 |
memcpy (buf, p->PeekData (), p->GetSize()); |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
159 |
return p->GetSize (); |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
160 |
} |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
161 |
|
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
162 |
Ptr<Packet> |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
163 |
Socket::RecvFrom (Address &fromAddress) |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
164 |
{ |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
165 |
NS_LOG_FUNCTION_NOARGS (); |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
166 |
return RecvFrom (std::numeric_limits<uint32_t>::max(), 0, fromAddress); |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
167 |
} |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
168 |
|
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
169 |
int |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
170 |
Socket::RecvFrom (uint8_t* buf, uint32_t size, uint32_t flags, |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
171 |
Address &fromAddress) |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
172 |
{ |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
173 |
NS_LOG_FUNCTION_NOARGS (); |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
174 |
Ptr<Packet> p = RecvFrom (size, flags, fromAddress); |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
175 |
if (p == 0) |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
176 |
{ |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
177 |
return 0; |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
178 |
} |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
179 |
memcpy (buf, p->PeekData (), p->GetSize()); |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
180 |
return p->GetSize (); |
2186
69ad6ed6ccf4
Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
1866
diff
changeset
|
181 |
} |
69ad6ed6ccf4
Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
1866
diff
changeset
|
182 |
|
1499
93d51d757afa
working one way echo app
Craig Dowell <craigdo@ee.washington.edu>
parents:
1265
diff
changeset
|
183 |
|
1264
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
184 |
void |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
185 |
Socket::NotifyConnectionSucceeded (void) |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
186 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2367
diff
changeset
|
187 |
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
|
188 |
if (!m_connectionSucceeded.IsNull ()) |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
189 |
{ |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
190 |
m_connectionSucceeded (this); |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
191 |
} |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
192 |
} |
1499
93d51d757afa
working one way echo app
Craig Dowell <craigdo@ee.washington.edu>
parents:
1265
diff
changeset
|
193 |
|
1264
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
194 |
void |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
195 |
Socket::NotifyConnectionFailed (void) |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
196 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2367
diff
changeset
|
197 |
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
|
198 |
if (!m_connectionFailed.IsNull ()) |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
199 |
{ |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
200 |
m_connectionFailed (this); |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
201 |
} |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
202 |
} |
1499
93d51d757afa
working one way echo app
Craig Dowell <craigdo@ee.washington.edu>
parents:
1265
diff
changeset
|
203 |
|
1264
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
204 |
bool |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
205 |
Socket::NotifyConnectionRequest (const Address &from) |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
206 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2367
diff
changeset
|
207 |
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
|
208 |
if (!m_connectionRequest.IsNull ()) |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
209 |
{ |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
210 |
return m_connectionRequest (this, from); |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
211 |
} |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
212 |
else |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
213 |
{ |
2367
904e5739f955
Undo changes to the packet sink to accept incoming connections; change the default behavior of the socket connection request notifier instead
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
2224
diff
changeset
|
214 |
// accept all incoming connections by default. |
904e5739f955
Undo changes to the packet sink to accept incoming connections; change the default behavior of the socket connection request notifier instead
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
2224
diff
changeset
|
215 |
// this way people writing code don't have to do anything |
904e5739f955
Undo changes to the packet sink to accept incoming connections; change the default behavior of the socket connection request notifier instead
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
2224
diff
changeset
|
216 |
// special like register a callback that returns true |
904e5739f955
Undo changes to the packet sink to accept incoming connections; change the default behavior of the socket connection request notifier instead
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
2224
diff
changeset
|
217 |
// just to get incoming connections |
904e5739f955
Undo changes to the packet sink to accept incoming connections; change the default behavior of the socket connection request notifier instead
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
2224
diff
changeset
|
218 |
return true; |
1264
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
219 |
} |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
220 |
} |
1499
93d51d757afa
working one way echo app
Craig Dowell <craigdo@ee.washington.edu>
parents:
1265
diff
changeset
|
221 |
|
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
222 |
void |
1264
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
223 |
Socket::NotifyNewConnectionCreated (Ptr<Socket> socket, const Address &from) |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
224 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2367
diff
changeset
|
225 |
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
|
226 |
if (!m_newConnectionCreated.IsNull ()) |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
227 |
{ |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
228 |
m_newConnectionCreated (socket, from); |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
229 |
} |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
230 |
} |
1499
93d51d757afa
working one way echo app
Craig Dowell <craigdo@ee.washington.edu>
parents:
1265
diff
changeset
|
231 |
|
1264
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
232 |
void |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
233 |
Socket::NotifyDataSent (uint32_t size) |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
234 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2367
diff
changeset
|
235 |
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
|
236 |
if (!m_dataSent.IsNull ()) |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
237 |
{ |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
238 |
m_dataSent (this, size); |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
239 |
} |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
240 |
} |
1499
93d51d757afa
working one way echo app
Craig Dowell <craigdo@ee.washington.edu>
parents:
1265
diff
changeset
|
241 |
|
1264
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
242 |
void |
2999
0b10920623bf
bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents:
2983
diff
changeset
|
243 |
Socket::NotifySend (uint32_t spaceAvailable) |
0b10920623bf
bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents:
2983
diff
changeset
|
244 |
{ |
0b10920623bf
bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents:
2983
diff
changeset
|
245 |
NS_LOG_FUNCTION_NOARGS (); |
0b10920623bf
bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents:
2983
diff
changeset
|
246 |
if (!m_sendCb.IsNull ()) |
0b10920623bf
bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents:
2983
diff
changeset
|
247 |
{ |
0b10920623bf
bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents:
2983
diff
changeset
|
248 |
m_sendCb (this, spaceAvailable); |
0b10920623bf
bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents:
2983
diff
changeset
|
249 |
} |
0b10920623bf
bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents:
2983
diff
changeset
|
250 |
} |
0b10920623bf
bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents:
2983
diff
changeset
|
251 |
|
0b10920623bf
bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents:
2983
diff
changeset
|
252 |
void |
3097
1b1661bbfa33
Plumb in socket receive pull model, in parallel to existing Receive framework
Tom Henderson <tomh@tomh.org>
parents:
3000
diff
changeset
|
253 |
Socket::NotifyDataRecv (void) |
1b1661bbfa33
Plumb in socket receive pull model, in parallel to existing Receive framework
Tom Henderson <tomh@tomh.org>
parents:
3000
diff
changeset
|
254 |
{ |
1b1661bbfa33
Plumb in socket receive pull model, in parallel to existing Receive framework
Tom Henderson <tomh@tomh.org>
parents:
3000
diff
changeset
|
255 |
NS_LOG_FUNCTION_NOARGS (); |
3102 | 256 |
if (!m_receivedData.IsNull ()) |
3097
1b1661bbfa33
Plumb in socket receive pull model, in parallel to existing Receive framework
Tom Henderson <tomh@tomh.org>
parents:
3000
diff
changeset
|
257 |
{ |
3102 | 258 |
m_receivedData (this); |
3097
1b1661bbfa33
Plumb in socket receive pull model, in parallel to existing Receive framework
Tom Henderson <tomh@tomh.org>
parents:
3000
diff
changeset
|
259 |
} |
1b1661bbfa33
Plumb in socket receive pull model, in parallel to existing Receive framework
Tom Henderson <tomh@tomh.org>
parents:
3000
diff
changeset
|
260 |
} |
3098
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
261 |
|
3138 | 262 |
/*************************************************************** |
263 |
* Socket Tags |
|
264 |
***************************************************************/ |
|
265 |
||
3269
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
266 |
SocketAddressTag::SocketAddressTag () |
3098
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
267 |
{ |
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
268 |
} |
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
269 |
|
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
270 |
void |
3269
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
271 |
SocketAddressTag::SetAddress (Address addr) |
3098
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
272 |
{ |
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
273 |
m_address = addr; |
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
274 |
} |
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
275 |
|
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
276 |
Address |
3269
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
277 |
SocketAddressTag::GetAddress (void) const |
3098
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
278 |
{ |
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
279 |
return m_address; |
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
280 |
} |
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
281 |
|
3138 | 282 |
|
283 |
TypeId |
|
3269
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
284 |
SocketAddressTag::GetTypeId (void) |
3124
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
285 |
{ |
3269
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
286 |
static TypeId tid = TypeId ("ns3::SocketAddressTag") |
3138 | 287 |
.SetParent<Tag> () |
3269
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
288 |
.AddConstructor<SocketAddressTag> () |
3138 | 289 |
; |
290 |
return tid; |
|
3124
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
291 |
} |
3138 | 292 |
TypeId |
3269
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
293 |
SocketAddressTag::GetInstanceTypeId (void) const |
3124
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
294 |
{ |
3138 | 295 |
return GetTypeId (); |
3124
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
296 |
} |
3139
37deb9deaf0e
Add tag serialize methods; add serialize routines to Address
Tom Henderson <tomh@tomh.org>
parents:
3138
diff
changeset
|
297 |
uint32_t |
3269
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
298 |
SocketAddressTag::GetSerializedSize (void) const |
3139
37deb9deaf0e
Add tag serialize methods; add serialize routines to Address
Tom Henderson <tomh@tomh.org>
parents:
3138
diff
changeset
|
299 |
{ |
37deb9deaf0e
Add tag serialize methods; add serialize routines to Address
Tom Henderson <tomh@tomh.org>
parents:
3138
diff
changeset
|
300 |
return m_address.GetSerializedSize (); |
3124
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
301 |
} |
3139
37deb9deaf0e
Add tag serialize methods; add serialize routines to Address
Tom Henderson <tomh@tomh.org>
parents:
3138
diff
changeset
|
302 |
void |
3269
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
303 |
SocketAddressTag::Serialize (TagBuffer i) const |
3139
37deb9deaf0e
Add tag serialize methods; add serialize routines to Address
Tom Henderson <tomh@tomh.org>
parents:
3138
diff
changeset
|
304 |
{ |
3167
644a220ad981
Fix off-by-2 errors
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3142
diff
changeset
|
305 |
m_address.Serialize (i); |
3138 | 306 |
} |
3139
37deb9deaf0e
Add tag serialize methods; add serialize routines to Address
Tom Henderson <tomh@tomh.org>
parents:
3138
diff
changeset
|
307 |
void |
3269
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
308 |
SocketAddressTag::Deserialize (TagBuffer i) |
3139
37deb9deaf0e
Add tag serialize methods; add serialize routines to Address
Tom Henderson <tomh@tomh.org>
parents:
3138
diff
changeset
|
309 |
{ |
3167
644a220ad981
Fix off-by-2 errors
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3142
diff
changeset
|
310 |
m_address.Deserialize (i); |
3124
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
311 |
} |
3208
1a754d09c4ba
bug 200: Packet::PrintTags is not implemented.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3167
diff
changeset
|
312 |
void |
3269
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
313 |
SocketAddressTag::Print (std::ostream &os) const |
3208
1a754d09c4ba
bug 200: Packet::PrintTags is not implemented.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3167
diff
changeset
|
314 |
{ |
1a754d09c4ba
bug 200: Packet::PrintTags is not implemented.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3167
diff
changeset
|
315 |
os << "address=" << m_address; |
1a754d09c4ba
bug 200: Packet::PrintTags is not implemented.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3167
diff
changeset
|
316 |
} |
3124
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
317 |
|
3138 | 318 |
SocketIpTtlTag::SocketIpTtlTag () |
3124
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
319 |
{ |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
320 |
} |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
321 |
|
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
322 |
void |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
323 |
SocketIpTtlTag::SetTtl (uint8_t ttl) |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
324 |
{ |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
325 |
m_ttl = ttl; |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
326 |
} |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
327 |
|
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
328 |
uint8_t |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
329 |
SocketIpTtlTag::GetTtl (void) const |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
330 |
{ |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
331 |
return m_ttl; |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
332 |
} |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
333 |
|
3138 | 334 |
|
335 |
TypeId |
|
336 |
SocketIpTtlTag::GetTypeId (void) |
|
337 |
{ |
|
338 |
static TypeId tid = TypeId ("ns3::SocketIpTtlTag") |
|
339 |
.SetParent<Tag> () |
|
340 |
.AddConstructor<SocketIpTtlTag> () |
|
341 |
; |
|
342 |
return tid; |
|
343 |
} |
|
344 |
TypeId |
|
345 |
SocketIpTtlTag::GetInstanceTypeId (void) const |
|
346 |
{ |
|
347 |
return GetTypeId (); |
|
348 |
} |
|
3139
37deb9deaf0e
Add tag serialize methods; add serialize routines to Address
Tom Henderson <tomh@tomh.org>
parents:
3138
diff
changeset
|
349 |
|
3138 | 350 |
uint32_t |
351 |
SocketIpTtlTag::GetSerializedSize (void) const |
|
352 |
{ |
|
3139
37deb9deaf0e
Add tag serialize methods; add serialize routines to Address
Tom Henderson <tomh@tomh.org>
parents:
3138
diff
changeset
|
353 |
return 1; |
3138 | 354 |
} |
355 |
void |
|
356 |
SocketIpTtlTag::Serialize (TagBuffer i) const |
|
357 |
{ |
|
3139
37deb9deaf0e
Add tag serialize methods; add serialize routines to Address
Tom Henderson <tomh@tomh.org>
parents:
3138
diff
changeset
|
358 |
i.WriteU8 (m_ttl); |
3138 | 359 |
} |
360 |
void |
|
361 |
SocketIpTtlTag::Deserialize (TagBuffer i) |
|
362 |
{ |
|
3139
37deb9deaf0e
Add tag serialize methods; add serialize routines to Address
Tom Henderson <tomh@tomh.org>
parents:
3138
diff
changeset
|
363 |
m_ttl = i.ReadU8 (); |
3138 | 364 |
} |
3208
1a754d09c4ba
bug 200: Packet::PrintTags is not implemented.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3167
diff
changeset
|
365 |
void |
1a754d09c4ba
bug 200: Packet::PrintTags is not implemented.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3167
diff
changeset
|
366 |
SocketIpTtlTag::Print (std::ostream &os) const |
1a754d09c4ba
bug 200: Packet::PrintTags is not implemented.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3167
diff
changeset
|
367 |
{ |
1a754d09c4ba
bug 200: Packet::PrintTags is not implemented.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3167
diff
changeset
|
368 |
os << "Ttl=" << (uint32_t) m_ttl; |
1a754d09c4ba
bug 200: Packet::PrintTags is not implemented.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3167
diff
changeset
|
369 |
} |
3138 | 370 |
|
3269
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
371 |
|
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
372 |
}//namespace ns3 |