author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Wed, 02 Jul 2008 13:22:46 -0700 | |
changeset 3375 | 86a8eceb023e |
parent 3309 | d761a70dfd03 |
child 3521 | 4bc5b06f92df |
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 |
*/ |
349
3c91100689d7
Add base class IPAddr; L4Protocol; Protocol; OnOff Application, and base class Socket
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
22 |
|
3c91100689d7
Add base class IPAddr; L4Protocol; Protocol; OnOff Application, and base class Socket
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
23 |
#ifndef __SOCKET_H__ |
3c91100689d7
Add base class IPAddr; L4Protocol; Protocol; OnOff Application, and base class Socket
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
24 |
#define __SOCKET_H__ |
3c91100689d7
Add base class IPAddr; L4Protocol; Protocol; OnOff Application, and base class Socket
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
25 |
|
3c91100689d7
Add base class IPAddr; L4Protocol; Protocol; OnOff Application, and base class Socket
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
26 |
#include "ns3/callback.h" |
557
927a5bb6432a
convert UdpSocket and Udp to Ptr<Node>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
498
diff
changeset
|
27 |
#include "ns3/ptr.h" |
3098
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
28 |
#include "ns3/tag.h" |
498
5d5fe14d5751
make capabilities and sockets refcounted
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
29 |
#include "ns3/object.h" |
1162
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
728
diff
changeset
|
30 |
#include "address.h" |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
349
diff
changeset
|
31 |
#include <stdint.h> |
349
3c91100689d7
Add base class IPAddr; L4Protocol; Protocol; OnOff Application, and base class Socket
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
32 |
|
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
349
diff
changeset
|
33 |
namespace ns3 { |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
349
diff
changeset
|
34 |
|
3098
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
35 |
|
728
95c426b1cb60
rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
646
diff
changeset
|
36 |
class Node; |
1264
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
37 |
class Packet; |
349
3c91100689d7
Add base class IPAddr; L4Protocol; Protocol; OnOff Application, and base class Socket
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
38 |
|
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
349
diff
changeset
|
39 |
/** |
3143 | 40 |
* \ingroup node |
41 |
* \defgroup socket Socket |
|
3222
f61c17b62fd1
bug 202: classes disappeared from doxygen output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3213
diff
changeset
|
42 |
*/ |
f61c17b62fd1
bug 202: classes disappeared from doxygen output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3213
diff
changeset
|
43 |
|
f61c17b62fd1
bug 202: classes disappeared from doxygen output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3213
diff
changeset
|
44 |
/** |
3143 | 45 |
* \brief A low-level Socket API based loosely on the BSD Socket API. |
3222
f61c17b62fd1
bug 202: classes disappeared from doxygen output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3213
diff
changeset
|
46 |
* \ingroup socket |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
349
diff
changeset
|
47 |
* |
3143 | 48 |
* A few things to keep in mind about this type of socket: |
49 |
* - it uses ns-3 API constructs such as class ns3::Address instead of |
|
50 |
* C-style structs |
|
51 |
* - in contrast to the original BSD socket API, this API is asynchronous: |
|
52 |
* it does not contain blocking calls. Sending and receiving operations |
|
53 |
* must make use of the callbacks provided. |
|
54 |
* - It also uses class ns3::Packet as a fancy byte buffer, allowing |
|
55 |
* data to be passed across the API using an ns-3 Packet instead of |
|
56 |
* a raw data pointer. |
|
57 |
* - Not all of the full POSIX sockets API is supported |
|
58 |
* |
|
59 |
* Other than that, it tries to stick to the BSD API to make it |
|
60 |
* easier for those who know the BSD API to use this API. |
|
61 |
* More details are provided in the ns-3 tutorial. |
|
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
349
diff
changeset
|
62 |
*/ |
498
5d5fe14d5751
make capabilities and sockets refcounted
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
63 |
class Socket : public Object |
5d5fe14d5751
make capabilities and sockets refcounted
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
64 |
{ |
349
3c91100689d7
Add base class IPAddr; L4Protocol; Protocol; OnOff Application, and base class Socket
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
65 |
public: |
3127
f5971b43ee58
Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents:
3124
diff
changeset
|
66 |
|
3107 | 67 |
Socket (void); |
68 |
virtual ~Socket (void); |
|
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
349
diff
changeset
|
69 |
|
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
349
diff
changeset
|
70 |
enum SocketErrno { |
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
|
71 |
ERROR_NOTERROR, |
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
|
72 |
ERROR_ISCONN, |
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
|
73 |
ERROR_NOTCONN, |
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
|
74 |
ERROR_MSGSIZE, |
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
|
75 |
ERROR_AGAIN, |
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
|
76 |
ERROR_SHUTDOWN, |
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
|
77 |
ERROR_OPNOTSUPP, |
1186
909e9eb2124e
rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1172
diff
changeset
|
78 |
ERROR_AFNOSUPPORT, |
1172
2e5b994330c7
add InetSocketAddress::IsMatchingType and use it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1162
diff
changeset
|
79 |
ERROR_INVAL, |
1186
909e9eb2124e
rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1172
diff
changeset
|
80 |
ERROR_BADF, |
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
|
81 |
ERROR_NOROUTETOHOST, |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
349
diff
changeset
|
82 |
SOCKET_ERRNO_LAST |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
349
diff
changeset
|
83 |
}; |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
349
diff
changeset
|
84 |
|
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
349
diff
changeset
|
85 |
/** |
3116
c33b6d2775b7
Move API for socket factory to a Socket::CreateSocket () factory method
Tom Henderson <tomh@tomh.org>
parents:
3107
diff
changeset
|
86 |
* This method wraps the creation of sockets that is performed |
c33b6d2775b7
Move API for socket factory to a Socket::CreateSocket () factory method
Tom Henderson <tomh@tomh.org>
parents:
3107
diff
changeset
|
87 |
* by a socket factory on a given node based on a TypeId. |
c33b6d2775b7
Move API for socket factory to a Socket::CreateSocket () factory method
Tom Henderson <tomh@tomh.org>
parents:
3107
diff
changeset
|
88 |
* |
c33b6d2775b7
Move API for socket factory to a Socket::CreateSocket () factory method
Tom Henderson <tomh@tomh.org>
parents:
3107
diff
changeset
|
89 |
* \return A smart pointer to a newly created socket. |
c33b6d2775b7
Move API for socket factory to a Socket::CreateSocket () factory method
Tom Henderson <tomh@tomh.org>
parents:
3107
diff
changeset
|
90 |
* |
c33b6d2775b7
Move API for socket factory to a Socket::CreateSocket () factory method
Tom Henderson <tomh@tomh.org>
parents:
3107
diff
changeset
|
91 |
* \param node The node on which to create the socket |
c33b6d2775b7
Move API for socket factory to a Socket::CreateSocket () factory method
Tom Henderson <tomh@tomh.org>
parents:
3107
diff
changeset
|
92 |
* \param tid The TypeId of the socket to create |
c33b6d2775b7
Move API for socket factory to a Socket::CreateSocket () factory method
Tom Henderson <tomh@tomh.org>
parents:
3107
diff
changeset
|
93 |
*/ |
c33b6d2775b7
Move API for socket factory to a Socket::CreateSocket () factory method
Tom Henderson <tomh@tomh.org>
parents:
3107
diff
changeset
|
94 |
static Ptr<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
|
95 |
/** |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
349
diff
changeset
|
96 |
* \return the errno associated to the last call which failed in this |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
349
diff
changeset
|
97 |
* socket. Each socket's errno is initialized to zero |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
349
diff
changeset
|
98 |
* when the socket is created. |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
349
diff
changeset
|
99 |
*/ |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
349
diff
changeset
|
100 |
virtual enum Socket::SocketErrno GetErrno (void) const = 0; |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
349
diff
changeset
|
101 |
/** |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
349
diff
changeset
|
102 |
* \returns the node this socket is associated with. |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
349
diff
changeset
|
103 |
*/ |
728
95c426b1cb60
rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
646
diff
changeset
|
104 |
virtual Ptr<Node> GetNode (void) const = 0; |
1264
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
105 |
/** |
2303 | 106 |
* \param connectionSucceeded this callback is invoked when the |
107 |
* connection request initiated by the user is successfully |
|
108 |
* completed. The callback is passed back a pointer to |
|
109 |
* the same socket object. |
|
110 |
* \param connectionFailed this callback is invoked when the |
|
111 |
* connection request initiated by the user is unsuccessfully |
|
112 |
* completed. The callback is passed back a pointer to the |
|
113 |
* same socket object. |
|
1264
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
114 |
*/ |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
115 |
void SetConnectCallback (Callback<void, Ptr<Socket> > connectionSucceeded, |
3276
8869a79a391f
Changes for bug 205, unlisted FIN bug
Craig Dowell <craigdo@ee.washington.edu>
parents:
3269
diff
changeset
|
116 |
Callback<void, Ptr<Socket> > connectionFailed); |
1264
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
117 |
/** |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
118 |
* \brief Accept connection requests from remote hosts |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
119 |
* \param connectionRequest Callback for connection request from peer. |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
120 |
* This user callback is passed a pointer to this socket, the |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
121 |
* ip address and the port number of the connection originator. |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
122 |
* This callback must return true to accept the incoming connection, |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
123 |
* false otherwise. If the connection is accepted, the |
2303 | 124 |
* "newConnectionCreated" callback will be invoked later to |
125 |
* give access to the user to the socket created to match |
|
126 |
* this new connection. If the user does not explicitly |
|
127 |
* specify this callback, all incoming connections will be refused. |
|
1264
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
128 |
* \param newConnectionCreated Callback for new connection: when a new |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
129 |
* is accepted, it is created and the corresponding socket is passed |
2303 | 130 |
* back to the user through this callback. This user callback is |
131 |
* passed a pointer to the new socket, and the ip address and |
|
132 |
* port number of the connection originator. |
|
1264
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
133 |
*/ |
2303 | 134 |
void SetAcceptCallback (Callback<bool, Ptr<Socket>, |
135 |
const Address &> connectionRequest, |
|
136 |
Callback<void, Ptr<Socket>, |
|
3276
8869a79a391f
Changes for bug 205, unlisted FIN bug
Craig Dowell <craigdo@ee.washington.edu>
parents:
3269
diff
changeset
|
137 |
const Address&> newConnectionCreated); |
2999
0b10920623bf
bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents:
2303
diff
changeset
|
138 |
/** |
0b10920623bf
bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents:
2303
diff
changeset
|
139 |
* \brief Notify application when a packet has been sent from transport |
0b10920623bf
bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents:
2303
diff
changeset
|
140 |
* protocol (non-standard socket call) |
0b10920623bf
bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents:
2303
diff
changeset
|
141 |
* \param dataSent Callback for the event that data is sent from the |
0b10920623bf
bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents:
2303
diff
changeset
|
142 |
* underlying transport protocol. This callback is passed a |
0b10920623bf
bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents:
2303
diff
changeset
|
143 |
* pointer to the socket, and the number of bytes sent. |
0b10920623bf
bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents:
2303
diff
changeset
|
144 |
* \returns whether or not this socket supports this callback. Note |
0b10920623bf
bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents:
2303
diff
changeset
|
145 |
* that this is a non-standard socket call. Some socket |
0b10920623bf
bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents:
2303
diff
changeset
|
146 |
* implementations in ns-3 may not support this call, so the |
0b10920623bf
bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents:
2303
diff
changeset
|
147 |
* user should check this return value to confirm that the |
0b10920623bf
bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents:
2303
diff
changeset
|
148 |
* callback is supported. |
0b10920623bf
bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents:
2303
diff
changeset
|
149 |
*/ |
3269
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
150 |
virtual bool SetDataSentCallback (Callback<void, Ptr<Socket>, |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
151 |
uint32_t> dataSent); |
2999
0b10920623bf
bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents:
2303
diff
changeset
|
152 |
/** |
0b10920623bf
bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents:
2303
diff
changeset
|
153 |
* \brief Notify application when space in transmit buffer is added |
0b10920623bf
bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents:
2303
diff
changeset
|
154 |
* |
0b10920623bf
bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents:
2303
diff
changeset
|
155 |
* This callback is intended to notify a |
0b10920623bf
bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents:
2303
diff
changeset
|
156 |
* socket that would have been blocked in a blocking socket model |
3000
bd2d3e32ef7b
A few minor cleanups to socket.h/cc
Tom Henderson <tomh@tomh.org>
parents:
2999
diff
changeset
|
157 |
* that space is available in the transmit buffer and that it |
bd2d3e32ef7b
A few minor cleanups to socket.h/cc
Tom Henderson <tomh@tomh.org>
parents:
2999
diff
changeset
|
158 |
* can call Send() again. |
2999
0b10920623bf
bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents:
2303
diff
changeset
|
159 |
* |
0b10920623bf
bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents:
2303
diff
changeset
|
160 |
* \param sendCb Callback for the event that the socket transmit buffer |
0b10920623bf
bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents:
2303
diff
changeset
|
161 |
* fill level has decreased. This callback is passed a pointer to |
0b10920623bf
bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents:
2303
diff
changeset
|
162 |
* the socket, and the number of bytes available for writing |
0b10920623bf
bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents:
2303
diff
changeset
|
163 |
* into the buffer (an absolute value). If there is no transmit |
0b10920623bf
bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents:
2303
diff
changeset
|
164 |
* buffer limit, a maximum-sized integer is always returned. |
0b10920623bf
bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents:
2303
diff
changeset
|
165 |
*/ |
0b10920623bf
bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents:
2303
diff
changeset
|
166 |
void SetSendCallback (Callback<void, Ptr<Socket>, uint32_t> sendCb); |
1264
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
167 |
/** |
3102 | 168 |
* \brief Notify application when new data is available to be read. |
1264
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
169 |
* |
3102 | 170 |
* This callback is intended to notify a socket that would |
171 |
* have been blocked in a blocking socket model that data |
|
172 |
* is available to be read. |
|
1264
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
173 |
*/ |
3102 | 174 |
void SetRecvCallback (Callback<void, Ptr<Socket> >); |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
349
diff
changeset
|
175 |
/** |
1162
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
728
diff
changeset
|
176 |
* \param address the address to try to allocate |
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
728
diff
changeset
|
177 |
* \returns 0 on success, -1 on failure. |
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
728
diff
changeset
|
178 |
* |
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
728
diff
changeset
|
179 |
* Allocate a local endpoint for this socket. |
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
728
diff
changeset
|
180 |
*/ |
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
728
diff
changeset
|
181 |
virtual int Bind (const Address &address) = 0; |
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
728
diff
changeset
|
182 |
|
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
728
diff
changeset
|
183 |
/** |
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
728
diff
changeset
|
184 |
* Allocate a local endpoint for this socket. |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
349
diff
changeset
|
185 |
* |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
349
diff
changeset
|
186 |
* \returns 0 on success, -1 on failure. |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
349
diff
changeset
|
187 |
*/ |
1162
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
728
diff
changeset
|
188 |
virtual int Bind () = 0; |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
349
diff
changeset
|
189 |
|
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
349
diff
changeset
|
190 |
/** |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
349
diff
changeset
|
191 |
* \brief Close a socket. |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
349
diff
changeset
|
192 |
* |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
349
diff
changeset
|
193 |
* After the Close call, the socket is no longer valid, and cannot |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
349
diff
changeset
|
194 |
* safely be used for subsequent operations. |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
349
diff
changeset
|
195 |
*/ |
3000
bd2d3e32ef7b
A few minor cleanups to socket.h/cc
Tom Henderson <tomh@tomh.org>
parents:
2999
diff
changeset
|
196 |
virtual int Close (void) = 0; |
349
3c91100689d7
Add base class IPAddr; L4Protocol; Protocol; OnOff Application, and base class Socket
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
197 |
|
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
349
diff
changeset
|
198 |
/** |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
349
diff
changeset
|
199 |
* \returns zero on success, -1 on failure. |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
349
diff
changeset
|
200 |
* |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
349
diff
changeset
|
201 |
* Do not allow any further Send calls. This method is typically |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
349
diff
changeset
|
202 |
* implemented for Tcp sockets by a half close. |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
349
diff
changeset
|
203 |
*/ |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
349
diff
changeset
|
204 |
virtual int ShutdownSend (void) = 0; |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
349
diff
changeset
|
205 |
|
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
349
diff
changeset
|
206 |
/** |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
349
diff
changeset
|
207 |
* \returns zero on success, -1 on failure. |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
349
diff
changeset
|
208 |
* |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
349
diff
changeset
|
209 |
* Do not allow any further Recv calls. This method is typically |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
349
diff
changeset
|
210 |
* implemented for Tcp sockets by a half close. |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
349
diff
changeset
|
211 |
*/ |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
349
diff
changeset
|
212 |
virtual int ShutdownRecv (void) = 0; |
349
3c91100689d7
Add base class IPAddr; L4Protocol; Protocol; OnOff Application, and base class Socket
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
213 |
|
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
349
diff
changeset
|
214 |
/** |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
349
diff
changeset
|
215 |
* \brief Initiate a connection to a remote host |
1162
10f9613bd9be
convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
728
diff
changeset
|
216 |
* \param address Address of remote. |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
349
diff
changeset
|
217 |
*/ |
3000
bd2d3e32ef7b
A few minor cleanups to socket.h/cc
Tom Henderson <tomh@tomh.org>
parents:
2999
diff
changeset
|
218 |
virtual int Connect (const Address &address) = 0; |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
349
diff
changeset
|
219 |
|
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
349
diff
changeset
|
220 |
/** |
3000
bd2d3e32ef7b
A few minor cleanups to socket.h/cc
Tom Henderson <tomh@tomh.org>
parents:
2999
diff
changeset
|
221 |
* \brief Listen for incoming connections. |
bd2d3e32ef7b
A few minor cleanups to socket.h/cc
Tom Henderson <tomh@tomh.org>
parents:
2999
diff
changeset
|
222 |
* \param queueLimit maximum number of incoming request to queue |
3213
08a0424399fb
bug 203: Listen must be implemented for Udp and Packet sockets.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3208
diff
changeset
|
223 |
* \returns 0 on success, -1 on error (in which case errno is set). |
3000
bd2d3e32ef7b
A few minor cleanups to socket.h/cc
Tom Henderson <tomh@tomh.org>
parents:
2999
diff
changeset
|
224 |
*/ |
3213
08a0424399fb
bug 203: Listen must be implemented for Udp and Packet sockets.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3208
diff
changeset
|
225 |
virtual int Listen (uint32_t queueLimit) = 0; |
3000
bd2d3e32ef7b
A few minor cleanups to socket.h/cc
Tom Henderson <tomh@tomh.org>
parents:
2999
diff
changeset
|
226 |
|
bd2d3e32ef7b
A few minor cleanups to socket.h/cc
Tom Henderson <tomh@tomh.org>
parents:
2999
diff
changeset
|
227 |
/** |
3269
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
228 |
* \brief Returns the number of bytes which can be sent in a single call |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
229 |
* to Send. |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
230 |
* |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
231 |
* For datagram sockets, this returns the number of bytes that |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
232 |
* can be passed atomically through the underlying protocol. |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
233 |
* |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
234 |
* For stream sockets, this returns the available space in bytes |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
235 |
* left in the transmit buffer. |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
236 |
*/ |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
237 |
virtual uint32_t GetTxAvailable (void) const = 0; |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
238 |
|
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
239 |
/** |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
349
diff
changeset
|
240 |
* \brief Send data (or dummy data) to the remote host |
3122
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
241 |
* |
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
242 |
* This function matches closely in semantics to the send() function |
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
243 |
* call in the standard C library (libc): |
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
244 |
* ssize_t send (int s, const void *msg, size_t len, int flags); |
3269
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
245 |
* except that the send I/O is asynchronous. This is the |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
246 |
* primary Send method at this low-level API and must be implemented |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
247 |
* by subclasses. |
3122
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
248 |
* |
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
249 |
* In a typical blocking sockets model, this call would block upon |
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
250 |
* lack of space to hold the message to be sent. In ns-3 at this |
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
251 |
* API, the call returns immediately in such a case, but the callback |
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
252 |
* registered with SetSendCallback() is invoked when the socket |
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
253 |
* has space (when it conceptually unblocks); this is an asynchronous |
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
254 |
* I/O model for send(). |
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
255 |
* |
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
256 |
* This variant of Send() uses class ns3::Packet to encapsulate |
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
257 |
* data, rather than providing a raw pointer and length field. |
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
258 |
* This allows an ns-3 application to attach tags if desired (such |
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
259 |
* as a flow ID) and may allow the simulator to avoid some data |
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
260 |
* copies. Despite the appearance of sending Packets on a stream |
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
261 |
* socket, just think of it as a fancy byte buffer with streaming |
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
262 |
* semantics. |
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
263 |
* |
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
264 |
* If either the message buffer within the Packet is too long to pass |
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
265 |
* atomically through the underlying protocol (for datagram sockets), |
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
266 |
* or the message buffer cannot entirely fit in the transmit buffer |
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
267 |
* (for stream sockets), -1 is returned and SocketErrno is set |
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
268 |
* to ERROR_MSGSIZE. If the packet does not fit, the caller can |
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
269 |
* split the Packet (based on information obtained from |
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
270 |
* GetTxAvailable) and reattempt to send the data. |
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
271 |
* |
3269
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
272 |
* The flags argument is formed by or'ing one or more of the values: |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
273 |
* MSG_OOB process out-of-band data |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
274 |
* MSG_DONTROUTE bypass routing, use direct interface |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
275 |
* These flags are _unsupported_ as of ns-3.1. |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
276 |
* |
3122
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
277 |
* \param p ns3::Packet to send |
3269
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
278 |
* \param flags Socket control flags |
3122
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
279 |
* \returns the number of bytes accepted for transmission if no error |
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
280 |
* occurs, and -1 otherwise. |
dfa83ab5172d
improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents:
3120
diff
changeset
|
281 |
* |
3269
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
282 |
* \see SetSendCallback |
3105
682950a37ea6
Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents:
3104
diff
changeset
|
283 |
*/ |
3269
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
284 |
virtual int Send (Ptr<Packet> p, uint32_t flags) = 0; |
2224
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
2186
diff
changeset
|
285 |
|
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
2186
diff
changeset
|
286 |
/** |
2186
69ad6ed6ccf4
Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
1866
diff
changeset
|
287 |
* \brief Send data to a specified peer. |
3269
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
288 |
* |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
289 |
* This method has similar semantics to Send () but subclasses may |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
290 |
* want to provide checks on socket state, so the implementation is |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
291 |
* pushed to subclasses. |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
292 |
* |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
293 |
* \param p packet to send |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
294 |
* \param flags Socket control flags |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
295 |
* \param toAddress IP Address of remote host |
2186
69ad6ed6ccf4
Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
1866
diff
changeset
|
296 |
* \returns -1 in case of error or the number of bytes copied in the |
69ad6ed6ccf4
Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
1866
diff
changeset
|
297 |
* internal buffer and accepted for transmission. |
69ad6ed6ccf4
Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
1866
diff
changeset
|
298 |
*/ |
3269
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
299 |
virtual int SendTo (Ptr<Packet> p, uint32_t flags, |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
300 |
const Address &toAddress) = 0; |
2186
69ad6ed6ccf4
Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
1866
diff
changeset
|
301 |
|
3098
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
302 |
/** |
3104 | 303 |
* Return number of bytes which can be returned from one or |
304 |
* multiple calls to Recv. |
|
305 |
* Must be possible to call this method from the Recv callback. |
|
306 |
*/ |
|
307 |
virtual uint32_t GetRxAvailable (void) const = 0; |
|
3269
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
308 |
|
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
309 |
/** |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
310 |
* \brief Read data from the socket |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
311 |
* |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
312 |
* This function matches closely in semantics to the recv() function |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
313 |
* call in the standard C library (libc): |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
314 |
* ssize_t recv (int s, void *buf, size_t len, int flags); |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
315 |
* except that the receive I/O is asynchronous. This is the |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
316 |
* primary Recv method at this low-level API and must be implemented |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
317 |
* by subclasses. |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
318 |
* |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
319 |
* This method is normally used only on a connected socket. |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
320 |
* In a typical blocking sockets model, this call would block until |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
321 |
* at least one byte is returned or the connection closes. |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
322 |
* In ns-3 at this API, the call returns immediately in such a case |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
323 |
* and returns 0 if nothing is available to be read. |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
324 |
* However, an application can set a callback, ns3::SetRecvCallback, |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
325 |
* to be notified of data being available to be read |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
326 |
* (when it conceptually unblocks); this is an asynchronous |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
327 |
* I/O model for recv(). |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
328 |
* |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
329 |
* This variant of Recv() uses class ns3::Packet to encapsulate |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
330 |
* data, rather than providing a raw pointer and length field. |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
331 |
* This allows an ns-3 application to attach tags if desired (such |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
332 |
* as a flow ID) and may allow the simulator to avoid some data |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
333 |
* copies. Despite the appearance of receiving Packets on a stream |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
334 |
* socket, just think of it as a fancy byte buffer with streaming |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
335 |
* semantics. |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
336 |
* |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
337 |
* The semantics depend on the type of socket. For a datagram socket, |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
338 |
* each Recv() returns the data from at most one Send(), and order |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
339 |
* is not necessarily preserved. For a stream socket, the bytes |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
340 |
* are delivered in order, and on-the-wire packet boundaries are |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
341 |
* not preserved. |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
342 |
* |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
343 |
* The flags argument is formed by or'ing one or more of the values: |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
344 |
* MSG_OOB process out-of-band data |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
345 |
* MSG_PEEK peek at incoming message |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
346 |
* These flags are _unsupported_ as of ns-3.1. |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
347 |
* |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
348 |
* Some variants of Recv() are supported as additional API, |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
349 |
* including RecvFrom(), overloaded Recv() without arguments, |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
350 |
* and variants that use raw character buffers. |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
351 |
* |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
352 |
* \param maxSize reader will accept packet up to maxSize |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
353 |
* \param flags Socket control flags |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
354 |
* \returns Ptr<Packet> of the next in-sequence packet. Returns |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
355 |
* 0 if the socket cannot return a next in-sequence packet conforming |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
356 |
* to the maxSize and flags. |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
357 |
* |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
358 |
* \see SetRecvCallback |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
359 |
*/ |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
360 |
virtual Ptr<Packet> Recv (uint32_t maxSize, uint32_t flags) = 0; |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
361 |
|
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
362 |
/** |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
363 |
* \brief Read a single packet from the socket and retrieve the sender |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
364 |
* address. |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
365 |
* |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
366 |
* Calls Recv(maxSize, flags) with maxSize |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
367 |
* implicitly set to maximum sized integer, and flags set to zero. |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
368 |
* |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
369 |
* This method has similar semantics to Recv () but subclasses may |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
370 |
* want to provide checks on socket state, so the implementation is |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
371 |
* pushed to subclasses. |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
372 |
* |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
373 |
* \param maxSize reader will accept packet up to maxSize |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
374 |
* \param flags Socket control flags |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
375 |
* \param fromAddress output parameter that will return the |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
376 |
* address of the sender of the received packet, if any. Remains |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
377 |
* untouched if no packet is received. |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
378 |
* \returns Ptr<Packet> of the next in-sequence packet. Returns |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
379 |
* 0 if the socket cannot return a next in-sequence packet. |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
380 |
*/ |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
381 |
virtual Ptr<Packet> RecvFrom (uint32_t maxSize, uint32_t flags, |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
382 |
Address &fromAddress) = 0; |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
383 |
|
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
384 |
///////////////////////////////////////////////////////////////////// |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
385 |
// The remainder of these public methods are overloaded methods // |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
386 |
// or variants of Send() and Recv(), and they are non-virtual // |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
387 |
///////////////////////////////////////////////////////////////////// |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
388 |
|
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
389 |
/** |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
390 |
* \brief Send data (or dummy data) to the remote host |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
391 |
* |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
392 |
* Overloaded version of Send(..., flags) with flags set to zero. |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
393 |
* |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
394 |
* \param p ns3::Packet to send |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
395 |
* \returns the number of bytes accepted for transmission if no error |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
396 |
* occurs, and -1 otherwise. |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
397 |
*/ |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
398 |
int Send (Ptr<Packet> p); |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
399 |
|
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
400 |
/** |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
401 |
* \brief Send data (or dummy data) to the remote host |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
402 |
* |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
403 |
* This method is provided so as to have an API which is closer in |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
404 |
* appearance to that of real network or BSD sockets. |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
405 |
* |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
406 |
* \param buf A pointer to a raw byte buffer of some data to send. If |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
407 |
* this buffer is 0, we send dummy data whose size is specified by the |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
408 |
* second parameter |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
409 |
* \param size the number of bytes to copy from the buffer |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
410 |
* \param flags Socket control flags |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
411 |
*/ |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
412 |
int Send (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
|
413 |
|
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
414 |
|
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
415 |
/** |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
416 |
* \brief Send data to a specified peer. |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
417 |
* |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
418 |
* This method is provided so as to have an API which is closer in |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
419 |
* appearance to that of real network or BSD sockets. |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
420 |
* |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
421 |
* \param buf A pointer to a raw byte buffer of some data to send. |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
422 |
* If this is 0, we send dummy data whose size is specified by the |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
423 |
* third parameter |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
424 |
* \param size the number of bytes to copy from the buffer |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
425 |
* \param flags Socket control flags |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
426 |
* \param address IP Address of remote host |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
427 |
* \returns -1 in case of error or the number of bytes copied in the |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
428 |
* internal buffer and accepted for transmission. |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
429 |
* |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
430 |
*/ |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
431 |
int 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
|
432 |
const Address &address); |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
433 |
|
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
434 |
/** |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
435 |
* \brief Read a single packet from the socket |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
436 |
* |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
437 |
* Overloaded version of Recv(maxSize, flags) with maxSize |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
438 |
* implicitly set to maximum sized integer, and flags set to zero. |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
439 |
* |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
440 |
* \returns Ptr<Packet> of the next in-sequence packet. Returns |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
441 |
* 0 if the socket cannot return a next in-sequence packet. |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
442 |
*/ |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
443 |
Ptr<Packet> Recv (void); |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
444 |
|
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
445 |
/** |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
446 |
* \brief Recv data (or dummy data) from the remote host |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
447 |
* |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
448 |
* This method is provided so as to have an API which is closer in |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
449 |
* appearance to that of real network or BSD sockets. |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
450 |
* |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
451 |
* If the underlying packet was carring null (fake) data, this buffer |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
452 |
* will be zeroed up to the length specified by the return value. |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
453 |
* |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
454 |
* \param buf A pointer to a raw byte buffer to write the data to. |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
455 |
* \param size Number of bytes (at most) to copy to buf |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
456 |
* \param flags any flags to pass to the socket |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
457 |
* \returns number of bytes copied into buf |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
458 |
*/ |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
459 |
int 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
|
460 |
|
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
461 |
/** |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
462 |
* \brief Read a single packet from the socket and retrieve the sender |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
463 |
* address. |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
464 |
* |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
465 |
* Calls RecvFrom (maxSize, flags, fromAddress) with maxSize |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
466 |
* implicitly set to maximum sized integer, and flags set to zero. |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
467 |
* |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
468 |
* \param fromAddress output parameter that will return the |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
469 |
* address of the sender of the received packet, if any. Remains |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
470 |
* untouched if no packet is received. |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
471 |
* \returns Ptr<Packet> of the next in-sequence packet. Returns |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
472 |
* 0 if the socket cannot return a next in-sequence packet. |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
473 |
*/ |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
474 |
Ptr<Packet> RecvFrom (Address &fromAddress); |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
475 |
|
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
476 |
/** |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
477 |
* \brief Read a single packet from the socket and retrieve the sender |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
478 |
* address. |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
479 |
* |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
480 |
* This method is provided so as to have an API which is closer in |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
481 |
* appearance to that of real network or BSD sockets. |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
482 |
* |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
483 |
* \param buf A pointer to a raw byte buffer to write the data to. |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
484 |
* If the underlying packet was carring null (fake) data, this buffer |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
485 |
* will be zeroed up to the length specified by the return value. |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
486 |
* \param size Number of bytes (at most) to copy to buf |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
487 |
* \param flags any flags to pass to the socket |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
488 |
* \param fromAddress output parameter that will return the |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
489 |
* address of the sender of the received packet, if any. Remains |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
490 |
* untouched if no packet is received. |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
491 |
* \returns number of bytes copied into buf |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
492 |
*/ |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
493 |
int 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
|
494 |
Address &fromAddress); |
3104 | 495 |
|
1264
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
496 |
protected: |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
497 |
void NotifyConnectionSucceeded (void); |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
498 |
void NotifyConnectionFailed (void); |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
499 |
bool NotifyConnectionRequest (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
|
500 |
void 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
|
501 |
void NotifyDataSent (uint32_t size); |
2999
0b10920623bf
bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents:
2303
diff
changeset
|
502 |
void NotifySend (uint32_t spaceAvailable); |
3097
1b1661bbfa33
Plumb in socket receive pull model, in parallel to existing Receive framework
Tom Henderson <tomh@tomh.org>
parents:
3000
diff
changeset
|
503 |
void NotifyDataRecv (void); |
3375
86a8eceb023e
no need for protected variables
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3309
diff
changeset
|
504 |
private: |
1264
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
505 |
Callback<void, Ptr<Socket> > m_connectionSucceeded; |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
506 |
Callback<void, Ptr<Socket> > m_connectionFailed; |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
507 |
Callback<bool, Ptr<Socket>, const Address &> m_connectionRequest; |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
508 |
Callback<void, Ptr<Socket>, const Address&> m_newConnectionCreated; |
577875bb5a65
split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
509 |
Callback<void, Ptr<Socket>, uint32_t> m_dataSent; |
2999
0b10920623bf
bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents:
2303
diff
changeset
|
510 |
Callback<void, Ptr<Socket>, uint32_t > m_sendCb; |
3102 | 511 |
Callback<void, Ptr<Socket> > m_receivedData; |
3107 | 512 |
|
349
3c91100689d7
Add base class IPAddr; L4Protocol; Protocol; OnOff Application, and base class Socket
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
513 |
}; |
3c91100689d7
Add base class IPAddr; L4Protocol; Protocol; OnOff Application, and base class Socket
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
514 |
|
3098
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
515 |
/** |
3269
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
516 |
* \brief This class implements a tag that carries an address |
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
517 |
* of a packet across the socket interface. |
3098
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
518 |
*/ |
3269
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
519 |
class SocketAddressTag : public Tag |
3098
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
520 |
{ |
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
521 |
public: |
3269
448134601b03
RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents:
3248
diff
changeset
|
522 |
SocketAddressTag (); |
3098
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
523 |
void SetAddress (Address addr); |
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
524 |
Address GetAddress (void) const; |
3138 | 525 |
|
526 |
static TypeId GetTypeId (void); |
|
527 |
virtual TypeId GetInstanceTypeId (void) const; |
|
528 |
virtual uint32_t GetSerializedSize (void) const; |
|
529 |
virtual void Serialize (TagBuffer i) const; |
|
530 |
virtual void Deserialize (TagBuffer i); |
|
3208
1a754d09c4ba
bug 200: Packet::PrintTags is not implemented.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3143
diff
changeset
|
531 |
virtual void Print (std::ostream &os) const; |
3138 | 532 |
|
3098
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
533 |
private: |
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
534 |
Address m_address; |
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
535 |
}; |
d384d52f8f6e
Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents:
3097
diff
changeset
|
536 |
|
3124
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
537 |
/** |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
538 |
* \brief This class implements a tag that carries the socket-specific |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
539 |
* TTL of a packet to the IP layer |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
540 |
*/ |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
541 |
class SocketIpTtlTag : public Tag |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
542 |
{ |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
543 |
public: |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
544 |
SocketIpTtlTag (); |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
545 |
void SetTtl (uint8_t ttl); |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
546 |
uint8_t GetTtl (void) const; |
3138 | 547 |
|
548 |
static TypeId GetTypeId (void); |
|
549 |
virtual TypeId GetInstanceTypeId (void) const; |
|
550 |
virtual uint32_t GetSerializedSize (void) const; |
|
551 |
virtual void Serialize (TagBuffer i) const; |
|
552 |
virtual void Deserialize (TagBuffer i); |
|
3208
1a754d09c4ba
bug 200: Packet::PrintTags is not implemented.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3143
diff
changeset
|
553 |
virtual void Print (std::ostream &os) const; |
3138 | 554 |
|
3124
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
555 |
private: |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
556 |
uint8_t m_ttl; |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
557 |
}; |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
3123
diff
changeset
|
558 |
|
349
3c91100689d7
Add base class IPAddr; L4Protocol; Protocol; OnOff Application, and base class Socket
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
559 |
} //namespace ns3 |
3c91100689d7
Add base class IPAddr; L4Protocol; Protocol; OnOff Application, and base class Socket
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
560 |
|
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
349
diff
changeset
|
561 |
#endif /* SOCKET_H */ |
349
3c91100689d7
Add base class IPAddr; L4Protocol; Protocol; OnOff Application, and base class Socket
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
562 |
|
3c91100689d7
Add base class IPAddr; L4Protocol; Protocol; OnOff Application, and base class Socket
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
563 |