src/node/socket.h
author Hajime Tazaki <tazaki@sfc.wide.ad.jp>
Fri, 26 Mar 2010 10:40:31 +0900
changeset 6158 44a98463b2d6
parent 6008 aa1c297a0de2
child 6437 c11291f51d57
permissions -rw-r--r--
add several errno in socket.h
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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"
5856
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5377
diff changeset
    30
#include "ns3/net-device.h"
1162
10f9613bd9be convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 728
diff changeset
    31
#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
    32
#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
    33
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
    34
namespace ns3 {
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
    35
3098
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
    36
728
95c426b1cb60 rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 646
diff changeset
    37
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
    38
class Packet;
349
3c91100689d7 Add base class IPAddr; L4Protocol; Protocol; OnOff Application, and base class Socket
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    39
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
    40
/**
3143
681be005f806 some doxygen cleanup
Tom Henderson <tomh@tomh.org>
parents: 3142
diff changeset
    41
 * \ingroup node
681be005f806 some doxygen cleanup
Tom Henderson <tomh@tomh.org>
parents: 3142
diff changeset
    42
 * \defgroup socket Socket
3222
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
f61c17b62fd1 bug 202: classes disappeared from doxygen output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3213
diff changeset
    45
/**
3143
681be005f806 some doxygen cleanup
Tom Henderson <tomh@tomh.org>
parents: 3142
diff changeset
    46
 * \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
    47
 * \ingroup socket
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
    48
 *
3143
681be005f806 some doxygen cleanup
Tom Henderson <tomh@tomh.org>
parents: 3142
diff changeset
    49
 * A few things to keep in mind about this type of socket:
681be005f806 some doxygen cleanup
Tom Henderson <tomh@tomh.org>
parents: 3142
diff changeset
    50
 * - it uses ns-3 API constructs such as class ns3::Address instead of
681be005f806 some doxygen cleanup
Tom Henderson <tomh@tomh.org>
parents: 3142
diff changeset
    51
 *   C-style structs
681be005f806 some doxygen cleanup
Tom Henderson <tomh@tomh.org>
parents: 3142
diff changeset
    52
 * - in contrast to the original BSD socket API, this API is asynchronous:
681be005f806 some doxygen cleanup
Tom Henderson <tomh@tomh.org>
parents: 3142
diff changeset
    53
 *   it does not contain blocking calls.  Sending and receiving operations
681be005f806 some doxygen cleanup
Tom Henderson <tomh@tomh.org>
parents: 3142
diff changeset
    54
 *   must make use of the callbacks provided. 
681be005f806 some doxygen cleanup
Tom Henderson <tomh@tomh.org>
parents: 3142
diff changeset
    55
 * - It also uses class ns3::Packet as a fancy byte buffer, allowing 
681be005f806 some doxygen cleanup
Tom Henderson <tomh@tomh.org>
parents: 3142
diff changeset
    56
 *   data to be passed across the API using an ns-3 Packet instead of 
681be005f806 some doxygen cleanup
Tom Henderson <tomh@tomh.org>
parents: 3142
diff changeset
    57
 *   a raw data pointer.  
681be005f806 some doxygen cleanup
Tom Henderson <tomh@tomh.org>
parents: 3142
diff changeset
    58
 * - Not all of the full POSIX sockets API is supported
681be005f806 some doxygen cleanup
Tom Henderson <tomh@tomh.org>
parents: 3142
diff changeset
    59
 *
681be005f806 some doxygen cleanup
Tom Henderson <tomh@tomh.org>
parents: 3142
diff changeset
    60
 * Other than that, it tries to stick to the BSD API to make it 
681be005f806 some doxygen cleanup
Tom Henderson <tomh@tomh.org>
parents: 3142
diff changeset
    61
 * easier for those who know the BSD API to use this API.  
681be005f806 some doxygen cleanup
Tom Henderson <tomh@tomh.org>
parents: 3142
diff changeset
    62
 * 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
    63
 */
498
5d5fe14d5751 make capabilities and sockets refcounted
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 487
diff changeset
    64
class Socket : public Object
5d5fe14d5751 make capabilities and sockets refcounted
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 487
diff changeset
    65
{
349
3c91100689d7 Add base class IPAddr; L4Protocol; Protocol; OnOff Application, and base class Socket
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    66
public:
3127
f5971b43ee58 Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents: 3124
diff changeset
    67
3107
ec3ed34b2470 API for SocketOptions class
Tom Henderson <tomh@tomh.org>
parents: 3105
diff changeset
    68
  Socket (void);
ec3ed34b2470 API for SocketOptions class
Tom Henderson <tomh@tomh.org>
parents: 3105
diff changeset
    69
  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
    70
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
    71
  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
    72
    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
    73
    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
    74
    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
    75
    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
    76
    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
    77
    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
    78
    ERROR_OPNOTSUPP,
1186
909e9eb2124e rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1172
diff changeset
    79
    ERROR_AFNOSUPPORT,
1172
2e5b994330c7 add InetSocketAddress::IsMatchingType and use it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1162
diff changeset
    80
    ERROR_INVAL,
1186
909e9eb2124e rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1172
diff changeset
    81
    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
    82
    ERROR_NOROUTETOHOST,
6158
44a98463b2d6 add several errno in socket.h
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 6008
diff changeset
    83
    ERROR_NODEV,
44a98463b2d6 add several errno in socket.h
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 6008
diff changeset
    84
    ERROR_ADDRNOTAVAIL,
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
    85
    SOCKET_ERRNO_LAST
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
    86
  };
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
    87
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
    88
  /**
3116
c33b6d2775b7 Move API for socket factory to a Socket::CreateSocket () factory method
Tom Henderson <tomh@tomh.org>
parents: 3107
diff changeset
    89
   * 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
    90
   * 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
    91
   * 
c33b6d2775b7 Move API for socket factory to a Socket::CreateSocket () factory method
Tom Henderson <tomh@tomh.org>
parents: 3107
diff changeset
    92
   * \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
    93
   * 
c33b6d2775b7 Move API for socket factory to a Socket::CreateSocket () factory method
Tom Henderson <tomh@tomh.org>
parents: 3107
diff changeset
    94
   * \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
    95
   * \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
    96
   */
c33b6d2775b7 Move API for socket factory to a Socket::CreateSocket () factory method
Tom Henderson <tomh@tomh.org>
parents: 3107
diff changeset
    97
  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
    98
  /**
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
    99
   * \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
   100
   *         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
   101
   *         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
   102
   */
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
   103
  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
   104
  /**
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
   105
   * \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
   106
   */
728
95c426b1cb60 rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 646
diff changeset
   107
  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
   108
  /**
5377
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 5227
diff changeset
   109
   * \brief Specify callbacks to allow the caller to determine if
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 5227
diff changeset
   110
   * the connection succeeds of fails.
2303
6f94834c2eee formatting cleanup
Tom Henderson <tomh@tomh.org>
parents: 2224
diff changeset
   111
   * \param connectionSucceeded this callback is invoked when the 
6f94834c2eee formatting cleanup
Tom Henderson <tomh@tomh.org>
parents: 2224
diff changeset
   112
   *        connection request initiated by the user is successfully 
6f94834c2eee formatting cleanup
Tom Henderson <tomh@tomh.org>
parents: 2224
diff changeset
   113
   *        completed. The callback is passed  back a pointer to 
6f94834c2eee formatting cleanup
Tom Henderson <tomh@tomh.org>
parents: 2224
diff changeset
   114
   *        the same socket object.
6f94834c2eee formatting cleanup
Tom Henderson <tomh@tomh.org>
parents: 2224
diff changeset
   115
   * \param connectionFailed this callback is invoked when the 
6f94834c2eee formatting cleanup
Tom Henderson <tomh@tomh.org>
parents: 2224
diff changeset
   116
   *        connection request initiated by the user is unsuccessfully 
6f94834c2eee formatting cleanup
Tom Henderson <tomh@tomh.org>
parents: 2224
diff changeset
   117
   *        completed. The callback is passed back a pointer to the 
6f94834c2eee formatting cleanup
Tom Henderson <tomh@tomh.org>
parents: 2224
diff changeset
   118
   *        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
   119
   */
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   120
  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
   121
                           Callback<void,  Ptr<Socket> > connectionFailed);
5377
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 5227
diff changeset
   122
 /**
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 5227
diff changeset
   123
  * \brief Detect socket recv() events such as graceful shutdown or error.
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 5227
diff changeset
   124
  * 
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 5227
diff changeset
   125
  * For connection-oriented sockets, the first callback is used to signal
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 5227
diff changeset
   126
  * that the remote side has gracefully shut down the connection, and the
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 5227
diff changeset
   127
  * second callback denotes an error corresponding to cases in which
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 5227
diff changeset
   128
  * a traditional recv() socket call might return -1 (error), such 
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 5227
diff changeset
   129
  * as a connection reset.  For datagram sockets, these callbacks may
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 5227
diff changeset
   130
  * never be invoked.
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 5227
diff changeset
   131
  * 
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 5227
diff changeset
   132
  * \param normalClose this callback is invoked when the 
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 5227
diff changeset
   133
  *        peer closes the connection gracefully
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 5227
diff changeset
   134
  * \param errorClose this callback is invoked when the 
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 5227
diff changeset
   135
  *        connection closes abnormally
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 5227
diff changeset
   136
  */
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 5227
diff changeset
   137
  void SetCloseCallbacks (Callback<void, Ptr<Socket> > normalClose,
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 5227
diff changeset
   138
                          Callback<void, Ptr<Socket> > errorClose);
1264
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   139
  /**
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   140
   * \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
   141
   * \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
   142
   *        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
   143
   *        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
   144
   *        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
   145
   *        false otherwise. If the connection is accepted, the 
2303
6f94834c2eee formatting cleanup
Tom Henderson <tomh@tomh.org>
parents: 2224
diff changeset
   146
   *        "newConnectionCreated" callback will be invoked later to 
6f94834c2eee formatting cleanup
Tom Henderson <tomh@tomh.org>
parents: 2224
diff changeset
   147
   *        give access to the user to the socket created to match 
6f94834c2eee formatting cleanup
Tom Henderson <tomh@tomh.org>
parents: 2224
diff changeset
   148
   *        this new connection. If the user does not explicitly 
6f94834c2eee formatting cleanup
Tom Henderson <tomh@tomh.org>
parents: 2224
diff changeset
   149
   *        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
   150
   * \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
   151
   *        is accepted, it is created and the corresponding socket is passed
2303
6f94834c2eee formatting cleanup
Tom Henderson <tomh@tomh.org>
parents: 2224
diff changeset
   152
   *        back to the user through this callback. This user callback is 
6f94834c2eee formatting cleanup
Tom Henderson <tomh@tomh.org>
parents: 2224
diff changeset
   153
   *        passed a pointer to the new socket, and the ip address and 
6f94834c2eee formatting cleanup
Tom Henderson <tomh@tomh.org>
parents: 2224
diff changeset
   154
   *        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
   155
   */
2303
6f94834c2eee formatting cleanup
Tom Henderson <tomh@tomh.org>
parents: 2224
diff changeset
   156
  void SetAcceptCallback (Callback<bool, Ptr<Socket>, 
6f94834c2eee formatting cleanup
Tom Henderson <tomh@tomh.org>
parents: 2224
diff changeset
   157
                            const Address &> connectionRequest,
6f94834c2eee formatting cleanup
Tom Henderson <tomh@tomh.org>
parents: 2224
diff changeset
   158
                          Callback<void, Ptr<Socket>, 
3276
8869a79a391f Changes for bug 205, unlisted FIN bug
Craig Dowell <craigdo@ee.washington.edu>
parents: 3269
diff changeset
   159
                            const Address&> newConnectionCreated);
2999
0b10920623bf bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents: 2303
diff changeset
   160
  /**
0b10920623bf bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents: 2303
diff changeset
   161
   * \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
   162
   *        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
   163
   * \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
   164
   *        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
   165
   *        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
   166
   */
3774
0e11474a0b92 Apply patch to fix bug 363
Craig Dowell <craigdo@ee.washington.edu>
parents: 3772
diff changeset
   167
  void SetDataSentCallback (Callback<void, Ptr<Socket>, 
3521
4bc5b06f92df remove uneeded virtual keyword
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3375
diff changeset
   168
                            uint32_t> dataSent);
2999
0b10920623bf bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents: 2303
diff changeset
   169
  /**
0b10920623bf bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents: 2303
diff changeset
   170
   * \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
   171
   *
0b10920623bf bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents: 2303
diff changeset
   172
   *        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
   173
   *        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
   174
   *        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
   175
   *        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
   176
   *
0b10920623bf bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents: 2303
diff changeset
   177
   * \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
   178
   *        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
   179
   *        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
   180
   *        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
   181
   *        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
   182
   */
0b10920623bf bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents: 2303
diff changeset
   183
  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
   184
  /**
3102
a225be367c1d more cleanup
Tom Henderson <tomh@tomh.org>
parents: 3100
diff changeset
   185
   * \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
   186
   *
3102
a225be367c1d more cleanup
Tom Henderson <tomh@tomh.org>
parents: 3100
diff changeset
   187
   *        This callback is intended to notify a socket that would
a225be367c1d more cleanup
Tom Henderson <tomh@tomh.org>
parents: 3100
diff changeset
   188
   *        have been blocked in a blocking socket model that data
a225be367c1d more cleanup
Tom Henderson <tomh@tomh.org>
parents: 3100
diff changeset
   189
   *        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
   190
   */
3102
a225be367c1d more cleanup
Tom Henderson <tomh@tomh.org>
parents: 3100
diff changeset
   191
  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
   192
  /** 
1162
10f9613bd9be convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 728
diff changeset
   193
   * \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
   194
   * \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
   195
   *
10f9613bd9be convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 728
diff changeset
   196
   * 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
   197
   */
10f9613bd9be convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 728
diff changeset
   198
  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
   199
10f9613bd9be convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 728
diff changeset
   200
  /** 
10f9613bd9be convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 728
diff changeset
   201
   * 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
   202
   *
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
   203
   * \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
   204
   */
1162
10f9613bd9be convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 728
diff changeset
   205
  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
   206
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
   207
  /** 
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
   208
   * \brief Close a socket.
4697
6e048d6486d8 Implement UdpSocketImpl::Close ()
Tom Henderson <tomh@tomh.org>
parents: 4357
diff changeset
   209
   * \returns zero on success, -1 on failure.
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
   210
   *
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
   211
   * 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
   212
   * 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
   213
   */
3000
bd2d3e32ef7b A few minor cleanups to socket.h/cc
Tom Henderson <tomh@tomh.org>
parents: 2999
diff changeset
   214
  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
   215
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
   216
  /**
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
   217
   * \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
   218
   *
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
   219
   * 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
   220
   * 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
   221
   */
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
   222
  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
   223
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
   224
  /**
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
   225
   * \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
   226
   *
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
   227
   * 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
   228
   * 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
   229
   */
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
   230
  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
   231
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
   232
  /**
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
   233
   * \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
   234
   * \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
   235
   */
3000
bd2d3e32ef7b A few minor cleanups to socket.h/cc
Tom Henderson <tomh@tomh.org>
parents: 2999
diff changeset
   236
  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
   237
    
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
   238
  /**
3000
bd2d3e32ef7b A few minor cleanups to socket.h/cc
Tom Henderson <tomh@tomh.org>
parents: 2999
diff changeset
   239
   * \brief Listen for incoming connections.
3213
08a0424399fb bug 203: Listen must be implemented for Udp and Packet sockets.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3208
diff changeset
   240
   * \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
   241
   */
3772
f0d8608ab155 Remove queue limit from listen
Craig Dowell <craigdo@ee.washington.edu>
parents: 3521
diff changeset
   242
  virtual int Listen (void) = 0;
3000
bd2d3e32ef7b A few minor cleanups to socket.h/cc
Tom Henderson <tomh@tomh.org>
parents: 2999
diff changeset
   243
bd2d3e32ef7b A few minor cleanups to socket.h/cc
Tom Henderson <tomh@tomh.org>
parents: 2999
diff changeset
   244
  /**
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   245
   * \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
   246
   * to Send. 
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   247
   * 
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   248
   * 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
   249
   * 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
   250
   *
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   251
   * 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
   252
   * left in the transmit buffer.
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   253
   */
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   254
  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
   255
 
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   256
  /**
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
   257
   * \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
   258
   *
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
   259
   * This function matches closely in semantics to the send() function
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
   260
   * call in the standard C library (libc):
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
   261
   *   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
   262
   * 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
   263
   * 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
   264
   * by subclasses.
3122
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
   265
   * 
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
   266
   * 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
   267
   * 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
   268
   * 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
   269
   * registered with SetSendCallback() is invoked when the socket
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
   270
   * has space (when it conceptually unblocks); this is an asynchronous
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
   271
   * I/O model for send().
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
   272
   * 
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
   273
   * This variant of Send() uses class ns3::Packet to encapsulate
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
   274
   * data, rather than providing a raw pointer and length field.  
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
   275
   * 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
   276
   * 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
   277
   * copies.  Despite the appearance of sending Packets on a stream
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
   278
   * 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
   279
   * semantics.    
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
   280
   *
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
   281
   * 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
   282
   * atomically through the underlying protocol (for datagram sockets), 
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
   283
   * 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
   284
   * (for stream sockets), -1 is returned and SocketErrno is set 
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
   285
   * 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
   286
   * split the Packet (based on information obtained from 
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
   287
   * GetTxAvailable) and reattempt to send the data.
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
   288
   *
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   289
   * 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
   290
   *        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
   291
   *        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
   292
   * 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
   293
   *
3122
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
   294
   * \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
   295
   * \param flags Socket control flags
3122
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
   296
   * \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
   297
   *          occurs, and -1 otherwise.
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
   298
   *
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   299
   * \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
   300
   */
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   301
  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
   302
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 2186
diff changeset
   303
  /**
2186
69ad6ed6ccf4 Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 1866
diff changeset
   304
   * \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
   305
   *
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   306
   * 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
   307
   * 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
   308
   * pushed to subclasses.
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
   * \param p packet to send
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   311
   * \param flags Socket control flags
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   312
   * \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
   313
   * \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
   314
   *          internal buffer and accepted for transmission.
69ad6ed6ccf4 Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 1866
diff changeset
   315
   */
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   316
  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
   317
    const Address &toAddress) = 0;
2186
69ad6ed6ccf4 Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 1866
diff changeset
   318
3098
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   319
  /**
3104
24d9d9aa0977 Implement GetRxAvailable ()
Tom Henderson <tomh@tomh.org>
parents: 3103
diff changeset
   320
   * Return number of bytes which can be returned from one or 
24d9d9aa0977 Implement GetRxAvailable ()
Tom Henderson <tomh@tomh.org>
parents: 3103
diff changeset
   321
   * multiple calls to Recv.
24d9d9aa0977 Implement GetRxAvailable ()
Tom Henderson <tomh@tomh.org>
parents: 3103
diff changeset
   322
   * Must be possible to call this method from the Recv callback.
24d9d9aa0977 Implement GetRxAvailable ()
Tom Henderson <tomh@tomh.org>
parents: 3103
diff changeset
   323
   */
24d9d9aa0977 Implement GetRxAvailable ()
Tom Henderson <tomh@tomh.org>
parents: 3103
diff changeset
   324
  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
   325
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   326
  /**
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   327
   * \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
   328
   *
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   329
   * 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
   330
   * 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
   331
   *   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
   332
   * 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
   333
   * 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
   334
   * by subclasses.
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   335
   * 
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   336
   * 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
   337
   * 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
   338
   * 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
   339
   * 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
   340
   * 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
   341
   * 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
   342
   * 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
   343
   * (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
   344
   * I/O model for recv().
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   345
   * 
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   346
   * 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
   347
   * 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
   348
   * 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
   349
   * 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
   350
   * 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
   351
   * 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
   352
   * semantics.    
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   353
   *
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   354
   * 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
   355
   * 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
   356
   * 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
   357
   * 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
   358
   * not preserved.  
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
   * The flags argument is formed by or'ing one or more of the values:     
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   361
   *        MSG_OOB             process out-of-band data
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   362
   *        MSG_PEEK            peek at incoming message
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   363
   * None of these flags are supported for now.
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   364
   *
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   365
   * 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
   366
   * 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
   367
   * 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
   368
   *
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   369
   * \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
   370
   * \param flags Socket control flags
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   371
   * \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
   372
   * 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
   373
   * to the maxSize and flags.
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   374
   *
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   375
   * \see SetRecvCallback
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   376
   */
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   377
  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
   378
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   379
  /**
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   380
   * \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
   381
   * address.
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   382
   *
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   383
   * 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
   384
   * 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
   385
   *
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   386
   * 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
   387
   * 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
   388
   * pushed to subclasses.
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
   * \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
   391
   * \param flags Socket control flags
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   392
   * \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
   393
   * 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
   394
   * 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
   395
   * \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
   396
   * 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
   397
   */
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   398
  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
   399
    Address &fromAddress) = 0;
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
  /////////////////////////////////////////////////////////////////////
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   402
  //   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
   403
  //   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
   404
  /////////////////////////////////////////////////////////////////////
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
  /**
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   407
   * \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
   408
   * 
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   409
   * 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
   410
   *
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   411
   * \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
   412
   * \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
   413
   *          occurs, and -1 otherwise.
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
  int Send (Ptr<Packet> p);
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   416
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
   * \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
   419
   * 
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   420
   * 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
   421
   * 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
   422
   *
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   423
   * \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
   424
   * 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
   425
   * second parameter
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   426
   * \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
   427
   * \param flags Socket control flags
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   428
   */
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   429
  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
   430
  
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   431
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   432
  /**
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   433
   * \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
   434
   *
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   435
   * 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
   436
   * 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
   437
   *
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   438
   * \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
   439
   * 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
   440
   * third parameter
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   441
   * \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
   442
   * \param flags Socket control flags
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   443
   * \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
   444
   * \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
   445
   *          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
   446
   *
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
  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
   449
              const Address &address); 
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
  /**
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   452
   * \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
   453
   *
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   454
   * 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
   455
   * 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
   456
   *
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   457
   * \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
   458
   * 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
   459
   */
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   460
   Ptr<Packet> Recv (void);
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
  /**
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   463
   * \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
   464
   *
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   465
   * 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
   466
   * 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
   467
   * 
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   468
   * 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
   469
   * 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
   470
   *
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   471
   * \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
   472
   * \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
   473
   * \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
   474
   * \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
   475
   */
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   476
  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
   477
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   478
  /**
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   479
   * \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
   480
   * address.
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   481
   *
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   482
   * 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
   483
   * 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
   484
   *
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   485
   * \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
   486
   * 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
   487
   * 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
   488
   * \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
   489
   * 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
   490
   */
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   491
  Ptr<Packet> RecvFrom (Address &fromAddress);
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
  /**
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   494
   * \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
   495
   * address.
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   496
   *
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   497
   * 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
   498
   * 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
   499
   * 
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   500
   * \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
   501
   * 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
   502
   * 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
   503
   * \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
   504
   * \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
   505
   * \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
   506
   * 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
   507
   * 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
   508
   * \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
   509
   */
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   510
  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
   511
                Address &fromAddress);
5227
ecb08c1fc273 Fix some doxygen warnings revealed by WARN_NO_PARAMDOC=YES in doc/doxygen.conf.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 4697
diff changeset
   512
  /**
ecb08c1fc273 Fix some doxygen warnings revealed by WARN_NO_PARAMDOC=YES in doc/doxygen.conf.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 4697
diff changeset
   513
   * \param address the address name this socket is associated with.
ecb08c1fc273 Fix some doxygen warnings revealed by WARN_NO_PARAMDOC=YES in doc/doxygen.conf.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 4697
diff changeset
   514
   * \returns 0 if success, -1 otherwise
3778
78c4c41557f3 Liu's GetSockName patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   515
   */
78c4c41557f3 Liu's GetSockName patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   516
  virtual int GetSockName (Address &address) const = 0; 
5856
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5377
diff changeset
   517
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5377
diff changeset
   518
  /**
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5377
diff changeset
   519
   * \brief Bind a socket to specific device.
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5377
diff changeset
   520
   *
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5377
diff changeset
   521
   * This method corresponds to using setsockopt() SO_BINDTODEVICE
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5377
diff changeset
   522
   * of real network or BSD sockets.   If set on a socket, this option will
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5377
diff changeset
   523
   * force packets to leave the bound device regardless of the device that
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5377
diff changeset
   524
   * IP routing would naturally choose.  In the receive direction, only
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5377
diff changeset
   525
   * packets received from the bound interface will be delivered.
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5377
diff changeset
   526
   *
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5377
diff changeset
   527
   * This option has no particular relationship to binding sockets to
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5377
diff changeset
   528
   * an address via Socket::Bind ().  It is possible to bind sockets to a 
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5377
diff changeset
   529
   * specific IP address on the bound interface by calling both 
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5377
diff changeset
   530
   * Socket::Bind (address) and Socket::BindToNetDevice (device), but it
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5377
diff changeset
   531
   * is also possible to bind to mismatching device and address, even if
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5377
diff changeset
   532
   * the socket can not receive any packets as a result.
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5377
diff changeset
   533
   *
6008
aa1c297a0de2 Fix non-undocumented warnings in doxygen, also update doxygen.conf
Josh Pelkey <jpelkey@gatech.edu>
parents: 5856
diff changeset
   534
   * \param netdevice Pointer to Netdevice of desired interface
5856
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5377
diff changeset
   535
   * \returns nothing
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5377
diff changeset
   536
   */
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5377
diff changeset
   537
  virtual void BindToNetDevice (Ptr<NetDevice> netdevice);
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5377
diff changeset
   538
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5377
diff changeset
   539
  /**
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5377
diff changeset
   540
   * \brief Returns socket's bound netdevice, if any.
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5377
diff changeset
   541
   *
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5377
diff changeset
   542
   * This method corresponds to using getsockopt() SO_BINDTODEVICE
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5377
diff changeset
   543
   * of real network or BSD sockets.  
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5377
diff changeset
   544
   * 
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5377
diff changeset
   545
   * 
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5377
diff changeset
   546
   * \returns Pointer to interface.
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5377
diff changeset
   547
   */
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5377
diff changeset
   548
  Ptr<NetDevice> GetBoundNetDevice (); 
3104
24d9d9aa0977 Implement GetRxAvailable ()
Tom Henderson <tomh@tomh.org>
parents: 3103
diff changeset
   549
 
1264
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   550
protected:
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   551
  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
   552
  void NotifyConnectionFailed (void);
5377
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 5227
diff changeset
   553
  void NotifyNormalClose(void);
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 5227
diff changeset
   554
  void NotifyErrorClose(void);
1264
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   555
  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
   556
  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
   557
  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
   558
  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
   559
  void NotifyDataRecv (void);
4357
9c638ff9f732 actually reset callbacks in the socket's DoDispose method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3997
diff changeset
   560
  virtual void DoDispose (void);
5856
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5377
diff changeset
   561
  Ptr<NetDevice> m_boundnetdevice;
3375
86a8eceb023e no need for protected variables
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3309
diff changeset
   562
private:
5377
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 5227
diff changeset
   563
  Callback<void, Ptr<Socket> >                   m_connectionSucceeded;
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 5227
diff changeset
   564
  Callback<void, Ptr<Socket> >                   m_connectionFailed;
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 5227
diff changeset
   565
  Callback<void, Ptr<Socket> >                   m_normalClose;
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 5227
diff changeset
   566
  Callback<void, Ptr<Socket> >                   m_errorClose;
1264
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   567
  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
   568
  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
   569
  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
   570
  Callback<void, Ptr<Socket>, uint32_t >         m_sendCb;
5377
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 5227
diff changeset
   571
  Callback<void, Ptr<Socket> >                   m_receivedData;
3107
ec3ed34b2470 API for SocketOptions class
Tom Henderson <tomh@tomh.org>
parents: 3105
diff changeset
   572
349
3c91100689d7 Add base class IPAddr; L4Protocol; Protocol; OnOff Application, and base class Socket
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   573
};
3c91100689d7 Add base class IPAddr; L4Protocol; Protocol; OnOff Application, and base class Socket
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   574
3098
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   575
/**
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   576
 * \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
   577
 * 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
   578
 */
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   579
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
   580
{
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   581
public:
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   582
  SocketAddressTag ();
3098
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   583
  void SetAddress (Address addr);
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   584
  Address GetAddress (void) const;
3138
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   585
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   586
  static TypeId GetTypeId (void);  
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   587
  virtual TypeId GetInstanceTypeId (void) const;
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   588
  virtual uint32_t GetSerializedSize (void) const;
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   589
  virtual void Serialize (TagBuffer i) const;
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   590
  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
   591
  virtual void Print (std::ostream &os) const;
3138
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   592
3098
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   593
private:
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   594
  Address m_address;
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   595
};
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   596
3124
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   597
/**
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   598
 * \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
   599
 * TTL of a packet to the IP layer
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   600
 */
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   601
class SocketIpTtlTag : public Tag
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   602
{
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   603
public:
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   604
  SocketIpTtlTag ();
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   605
  void SetTtl (uint8_t ttl);
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   606
  uint8_t GetTtl (void) const;
3138
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   607
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   608
  static TypeId GetTypeId (void);  
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   609
  virtual TypeId GetInstanceTypeId (void) const;
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   610
  virtual uint32_t GetSerializedSize (void) const;
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   611
  virtual void Serialize (TagBuffer i) const;
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   612
  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
   613
  virtual void Print (std::ostream &os) const;
3138
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   614
3124
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   615
private:
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   616
  uint8_t m_ttl;
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   617
};
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   618
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   619
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   620
/**
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   621
 * \brief indicated whether packets should be sent out with
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   622
 * the DF flag set.
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   623
 */
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   624
class SocketSetDontFragmentTag : public Tag
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   625
{
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   626
public:
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   627
  SocketSetDontFragmentTag ();
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   628
  void Enable (void);
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   629
  void Disable (void);
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   630
  bool IsEnabled (void) const;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   631
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   632
  static TypeId GetTypeId (void);  
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   633
  virtual TypeId GetInstanceTypeId (void) const;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   634
  virtual uint32_t GetSerializedSize (void) const;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   635
  virtual void Serialize (TagBuffer i) const;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   636
  virtual void Deserialize (TagBuffer i);
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   637
  virtual void Print (std::ostream &os) const;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   638
private:
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   639
  bool m_dontFragment;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   640
};
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   641
349
3c91100689d7 Add base class IPAddr; L4Protocol; Protocol; OnOff Application, and base class Socket
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   642
} //namespace ns3
3c91100689d7 Add base class IPAddr; L4Protocol; Protocol; OnOff Application, and base class Socket
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   643
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
   644
#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
   645
3c91100689d7 Add base class IPAddr; L4Protocol; Protocol; OnOff Application, and base class Socket
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   646