src/network/model/socket.h
author Daniel Lertpratchya <nikkipui@gmail.com>
Tue, 20 Nov 2012 17:52:39 -0500
changeset 9145 5752b425cdf5
parent 7870 059b1b83e29b
child 10405 45c8fceae24e
permissions -rw-r--r--
Bug 1361 - Set TOS from Application level (sockets)
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
7353
09fccf6195ea bug 1203: Inconsistently named ifndef/define macros in ns-3 headers
Vedran Miletic <rivanvx@gmail.com>
parents: 7256
diff changeset
    23
#ifndef NS3_SOCKET_H
09fccf6195ea bug 1203: Inconsistently named ifndef/define macros in ns-3 headers
Vedran Miletic <rivanvx@gmail.com>
parents: 7256
diff changeset
    24
#define NS3_SOCKET_H
349
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>
9145
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
    33
#include "ns3/inet-socket-address.h"
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
    34
#include "ns3/inet6-socket-address.h"
349
3c91100689d7 Add base class IPAddr; L4Protocol; Protocol; OnOff Application, and base class Socket
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    35
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
    36
namespace ns3 {
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
    37
3098
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
    38
728
95c426b1cb60 rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 646
diff changeset
    39
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
    40
class Packet;
349
3c91100689d7 Add base class IPAddr; L4Protocol; Protocol; OnOff Application, and base class Socket
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    41
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
    42
/**
7149
87514e0d866b Fix doxygen groups for some new modules
Mitch Watrous <watrous@u.washington.edu>
parents: 6823
diff changeset
    43
 * \ingroup network
3143
681be005f806 some doxygen cleanup
Tom Henderson <tomh@tomh.org>
parents: 3142
diff changeset
    44
 * \defgroup socket Socket
3222
f61c17b62fd1 bug 202: classes disappeared from doxygen output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3213
diff changeset
    45
 */
f61c17b62fd1 bug 202: classes disappeared from doxygen output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3213
diff changeset
    46
f61c17b62fd1 bug 202: classes disappeared from doxygen output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3213
diff changeset
    47
/**
3143
681be005f806 some doxygen cleanup
Tom Henderson <tomh@tomh.org>
parents: 3142
diff changeset
    48
 * \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
    49
 * \ingroup socket
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
    50
 *
3143
681be005f806 some doxygen cleanup
Tom Henderson <tomh@tomh.org>
parents: 3142
diff changeset
    51
 * 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
    52
 * - 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
    53
 *   C-style structs
681be005f806 some doxygen cleanup
Tom Henderson <tomh@tomh.org>
parents: 3142
diff changeset
    54
 * - 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
    55
 *   it does not contain blocking calls.  Sending and receiving operations
681be005f806 some doxygen cleanup
Tom Henderson <tomh@tomh.org>
parents: 3142
diff changeset
    56
 *   must make use of the callbacks provided. 
681be005f806 some doxygen cleanup
Tom Henderson <tomh@tomh.org>
parents: 3142
diff changeset
    57
 * - 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
    58
 *   data to be passed across the API using an ns-3 Packet instead of 
7182
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
    59
 *   a raw data pointer.
3143
681be005f806 some doxygen cleanup
Tom Henderson <tomh@tomh.org>
parents: 3142
diff changeset
    60
 * - Not all of the full POSIX sockets API is supported
681be005f806 some doxygen cleanup
Tom Henderson <tomh@tomh.org>
parents: 3142
diff changeset
    61
 *
681be005f806 some doxygen cleanup
Tom Henderson <tomh@tomh.org>
parents: 3142
diff changeset
    62
 * Other than that, it tries to stick to the BSD API to make it 
7182
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
    63
 * easier for those who know the BSD API to use this API.
3143
681be005f806 some doxygen cleanup
Tom Henderson <tomh@tomh.org>
parents: 3142
diff changeset
    64
 * 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
    65
 */
498
5d5fe14d5751 make capabilities and sockets refcounted
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 487
diff changeset
    66
class Socket : public Object
5d5fe14d5751 make capabilities and sockets refcounted
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 487
diff changeset
    67
{
349
3c91100689d7 Add base class IPAddr; L4Protocol; Protocol; OnOff Application, and base class Socket
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    68
public:
7870
059b1b83e29b Bug 962 - list of paths to reach objects contains bogus entries
Mitch Watrous <watrous@u.washington.edu>
parents: 7758
diff changeset
    69
  static TypeId GetTypeId (void);
3127
f5971b43ee58 Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents: 3124
diff changeset
    70
3107
ec3ed34b2470 API for SocketOptions class
Tom Henderson <tomh@tomh.org>
parents: 3105
diff changeset
    71
  Socket (void);
ec3ed34b2470 API for SocketOptions class
Tom Henderson <tomh@tomh.org>
parents: 3105
diff changeset
    72
  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
    73
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
    74
  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
    75
    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
    76
    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
    77
    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
    78
    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
    79
    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
    80
    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
    81
    ERROR_OPNOTSUPP,
1186
909e9eb2124e rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1172
diff changeset
    82
    ERROR_AFNOSUPPORT,
1172
2e5b994330c7 add InetSocketAddress::IsMatchingType and use it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1162
diff changeset
    83
    ERROR_INVAL,
1186
909e9eb2124e rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1172
diff changeset
    84
    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
    85
    ERROR_NOROUTETOHOST,
6158
44a98463b2d6 add several errno in socket.h
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 6008
diff changeset
    86
    ERROR_NODEV,
44a98463b2d6 add several errno in socket.h
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 6008
diff changeset
    87
    ERROR_ADDRNOTAVAIL,
7440
979d65377d5f Bug 1164 - IPV4 TCP Bind an already used port failed but without setting errno
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
    88
    ERROR_ADDRINUSE,
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
    89
    SOCKET_ERRNO_LAST
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
    90
  };
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
    91
6689
e2de571e920a Implement Socket::GetSocketType
Josh Pelkey <jpelkey@gatech.edu>
parents: 6448
diff changeset
    92
  enum SocketType {
6692
591fb1aa0ca4 Avoid enum name collision in socket
Josh Pelkey <jpelkey@gatech.edu>
parents: 6689
diff changeset
    93
    NS3_SOCK_STREAM,
591fb1aa0ca4 Avoid enum name collision in socket
Josh Pelkey <jpelkey@gatech.edu>
parents: 6689
diff changeset
    94
    NS3_SOCK_SEQPACKET,
591fb1aa0ca4 Avoid enum name collision in socket
Josh Pelkey <jpelkey@gatech.edu>
parents: 6689
diff changeset
    95
    NS3_SOCK_DGRAM,
591fb1aa0ca4 Avoid enum name collision in socket
Josh Pelkey <jpelkey@gatech.edu>
parents: 6689
diff changeset
    96
    NS3_SOCK_RAW
6689
e2de571e920a Implement Socket::GetSocketType
Josh Pelkey <jpelkey@gatech.edu>
parents: 6448
diff changeset
    97
  };
e2de571e920a Implement Socket::GetSocketType
Josh Pelkey <jpelkey@gatech.edu>
parents: 6448
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
  /**
3116
c33b6d2775b7 Move API for socket factory to a Socket::CreateSocket () factory method
Tom Henderson <tomh@tomh.org>
parents: 3107
diff changeset
   100
   * This method wraps the creation of sockets that is performed
7355
68d9cb42e2b4 clarify CreateSocket() doxygen
Tom Henderson <tomh@tomh.org>
parents: 7353
diff changeset
   101
   * on a given node by a SocketFactory specified by TypeId.
3116
c33b6d2775b7 Move API for socket factory to a Socket::CreateSocket () factory method
Tom Henderson <tomh@tomh.org>
parents: 3107
diff changeset
   102
   * 
c33b6d2775b7 Move API for socket factory to a Socket::CreateSocket () factory method
Tom Henderson <tomh@tomh.org>
parents: 3107
diff changeset
   103
   * \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
   104
   * 
c33b6d2775b7 Move API for socket factory to a Socket::CreateSocket () factory method
Tom Henderson <tomh@tomh.org>
parents: 3107
diff changeset
   105
   * \param node The node on which to create the socket
7355
68d9cb42e2b4 clarify CreateSocket() doxygen
Tom Henderson <tomh@tomh.org>
parents: 7353
diff changeset
   106
   * \param tid The TypeId of a SocketFactory class to use
3116
c33b6d2775b7 Move API for socket factory to a Socket::CreateSocket () factory method
Tom Henderson <tomh@tomh.org>
parents: 3107
diff changeset
   107
   */
c33b6d2775b7 Move API for socket factory to a Socket::CreateSocket () factory method
Tom Henderson <tomh@tomh.org>
parents: 3107
diff changeset
   108
  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
   109
  /**
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
   110
   * \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
   111
   *         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
   112
   *         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
   113
   */
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
   114
  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
   115
  /**
6689
e2de571e920a Implement Socket::GetSocketType
Josh Pelkey <jpelkey@gatech.edu>
parents: 6448
diff changeset
   116
    * \return the socket type, analogous to getsockopt (SO_TYPE)
e2de571e920a Implement Socket::GetSocketType
Josh Pelkey <jpelkey@gatech.edu>
parents: 6448
diff changeset
   117
    */
e2de571e920a Implement Socket::GetSocketType
Josh Pelkey <jpelkey@gatech.edu>
parents: 6448
diff changeset
   118
  virtual enum Socket::SocketType GetSocketType (void) const = 0;
e2de571e920a Implement Socket::GetSocketType
Josh Pelkey <jpelkey@gatech.edu>
parents: 6448
diff changeset
   119
  /**
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
   120
   * \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
   121
   */
728
95c426b1cb60 rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 646
diff changeset
   122
  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
   123
  /**
5377
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 5227
diff changeset
   124
   * \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
   125
   * the connection succeeds of fails.
2303
6f94834c2eee formatting cleanup
Tom Henderson <tomh@tomh.org>
parents: 2224
diff changeset
   126
   * \param connectionSucceeded this callback is invoked when the 
6f94834c2eee formatting cleanup
Tom Henderson <tomh@tomh.org>
parents: 2224
diff changeset
   127
   *        connection request initiated by the user is successfully 
6f94834c2eee formatting cleanup
Tom Henderson <tomh@tomh.org>
parents: 2224
diff changeset
   128
   *        completed. The callback is passed  back a pointer to 
6f94834c2eee formatting cleanup
Tom Henderson <tomh@tomh.org>
parents: 2224
diff changeset
   129
   *        the same socket object.
6f94834c2eee formatting cleanup
Tom Henderson <tomh@tomh.org>
parents: 2224
diff changeset
   130
   * \param connectionFailed this callback is invoked when the 
6f94834c2eee formatting cleanup
Tom Henderson <tomh@tomh.org>
parents: 2224
diff changeset
   131
   *        connection request initiated by the user is unsuccessfully 
6f94834c2eee formatting cleanup
Tom Henderson <tomh@tomh.org>
parents: 2224
diff changeset
   132
   *        completed. The callback is passed back a pointer to the 
6f94834c2eee formatting cleanup
Tom Henderson <tomh@tomh.org>
parents: 2224
diff changeset
   133
   *        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
   134
   */
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   135
  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
   136
                           Callback<void,  Ptr<Socket> > connectionFailed);
7182
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   137
  /**
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   138
   * \brief Detect socket recv() events such as graceful shutdown or error.
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   139
   *
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   140
   * For connection-oriented sockets, the first callback is used to signal
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   141
   * that the remote side has gracefully shut down the connection, and the
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   142
   * second callback denotes an error corresponding to cases in which
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   143
   * a traditional recv() socket call might return -1 (error), such
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   144
   * as a connection reset.  For datagram sockets, these callbacks may
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   145
   * never be invoked.
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   146
   *
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   147
   * \param normalClose this callback is invoked when the
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   148
   *        peer closes the connection gracefully
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   149
   * \param errorClose this callback is invoked when the
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   150
   *        connection closes abnormally
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   151
   */
5377
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 5227
diff changeset
   152
  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
   153
                          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
   154
  /**
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   155
   * \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
   156
   * \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
   157
   *        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
   158
   *        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
   159
   *        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
   160
   *        false otherwise. If the connection is accepted, the 
2303
6f94834c2eee formatting cleanup
Tom Henderson <tomh@tomh.org>
parents: 2224
diff changeset
   161
   *        "newConnectionCreated" callback will be invoked later to 
6f94834c2eee formatting cleanup
Tom Henderson <tomh@tomh.org>
parents: 2224
diff changeset
   162
   *        give access to the user to the socket created to match 
6f94834c2eee formatting cleanup
Tom Henderson <tomh@tomh.org>
parents: 2224
diff changeset
   163
   *        this new connection. If the user does not explicitly 
6f94834c2eee formatting cleanup
Tom Henderson <tomh@tomh.org>
parents: 2224
diff changeset
   164
   *        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
   165
   * \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
   166
   *        is accepted, it is created and the corresponding socket is passed
2303
6f94834c2eee formatting cleanup
Tom Henderson <tomh@tomh.org>
parents: 2224
diff changeset
   167
   *        back to the user through this callback. This user callback is 
6f94834c2eee formatting cleanup
Tom Henderson <tomh@tomh.org>
parents: 2224
diff changeset
   168
   *        passed a pointer to the new socket, and the ip address and 
6f94834c2eee formatting cleanup
Tom Henderson <tomh@tomh.org>
parents: 2224
diff changeset
   169
   *        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
   170
   */
2303
6f94834c2eee formatting cleanup
Tom Henderson <tomh@tomh.org>
parents: 2224
diff changeset
   171
  void SetAcceptCallback (Callback<bool, Ptr<Socket>, 
7182
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   172
                                   const Address &> connectionRequest,
2303
6f94834c2eee formatting cleanup
Tom Henderson <tomh@tomh.org>
parents: 2224
diff changeset
   173
                          Callback<void, Ptr<Socket>, 
7182
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   174
                                   const Address&> newConnectionCreated);
2999
0b10920623bf bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents: 2303
diff changeset
   175
  /**
0b10920623bf bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents: 2303
diff changeset
   176
   * \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
   177
   *        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
   178
   * \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
   179
   *        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
   180
   *        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
   181
   */
3774
0e11474a0b92 Apply patch to fix bug 363
Craig Dowell <craigdo@ee.washington.edu>
parents: 3772
diff changeset
   182
  void SetDataSentCallback (Callback<void, Ptr<Socket>, 
7182
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   183
                                     uint32_t> dataSent);
2999
0b10920623bf bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents: 2303
diff changeset
   184
  /**
0b10920623bf bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents: 2303
diff changeset
   185
   * \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
   186
   *
0b10920623bf bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents: 2303
diff changeset
   187
   *        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
   188
   *        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
   189
   *        that space is available in the transmit buffer and that it
7182
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   190
   *        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
   191
   *
0b10920623bf bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents: 2303
diff changeset
   192
   * \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
   193
   *        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
   194
   *        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
   195
   *        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
   196
   *        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
   197
   */
0b10920623bf bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents: 2303
diff changeset
   198
  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
   199
  /**
3102
a225be367c1d more cleanup
Tom Henderson <tomh@tomh.org>
parents: 3100
diff changeset
   200
   * \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
   201
   *
3102
a225be367c1d more cleanup
Tom Henderson <tomh@tomh.org>
parents: 3100
diff changeset
   202
   *        This callback is intended to notify a socket that would
a225be367c1d more cleanup
Tom Henderson <tomh@tomh.org>
parents: 3100
diff changeset
   203
   *        have been blocked in a blocking socket model that data
a225be367c1d more cleanup
Tom Henderson <tomh@tomh.org>
parents: 3100
diff changeset
   204
   *        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
   205
   */
3102
a225be367c1d more cleanup
Tom Henderson <tomh@tomh.org>
parents: 3100
diff changeset
   206
  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
   207
  /** 
7719
ff7015f8b776 Fix merge
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 7718
diff changeset
   208
   * \brief Allocate a local endpoint for this socket.
1162
10f9613bd9be convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 728
diff changeset
   209
   * \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
   210
   * \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
   211
   */
10f9613bd9be convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 728
diff changeset
   212
  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
   213
10f9613bd9be convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 728
diff changeset
   214
  /** 
7719
ff7015f8b776 Fix merge
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 7718
diff changeset
   215
   * \brief Allocate a local IPv4 endpoint for this socket.
7718
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 7717
diff changeset
   216
   *
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
   217
   * \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
   218
   */
1162
10f9613bd9be convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 728
diff changeset
   219
  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
   220
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
   221
  /** 
7719
ff7015f8b776 Fix merge
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 7718
diff changeset
   222
   * \brief Allocate a local IPv6 endpoint for this socket.
ff7015f8b776 Fix merge
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 7718
diff changeset
   223
   *
ff7015f8b776 Fix merge
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 7718
diff changeset
   224
   * \returns 0 on success, -1 on failure.
ff7015f8b776 Fix merge
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 7718
diff changeset
   225
   */
ff7015f8b776 Fix merge
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 7718
diff changeset
   226
  virtual int Bind6 () = 0;
ff7015f8b776 Fix merge
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 7718
diff changeset
   227
ff7015f8b776 Fix merge
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 7718
diff changeset
   228
  /**
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
   229
   * \brief Close a socket.
4697
6e048d6486d8 Implement UdpSocketImpl::Close ()
Tom Henderson <tomh@tomh.org>
parents: 4357
diff changeset
   230
   * \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
   231
   *
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
   232
   * 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
   233
   * 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
   234
   */
3000
bd2d3e32ef7b A few minor cleanups to socket.h/cc
Tom Henderson <tomh@tomh.org>
parents: 2999
diff changeset
   235
  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
   236
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
   * \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
   239
   *
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
   240
   * 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
   241
   * 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
   242
   */
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
   243
  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
   244
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
   245
  /**
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
   246
   * \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
   247
   *
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
   248
   * 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
   249
   * 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
   250
   */
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
   251
  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
   252
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
   253
  /**
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
   254
   * \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
   255
   * \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
   256
   */
3000
bd2d3e32ef7b A few minor cleanups to socket.h/cc
Tom Henderson <tomh@tomh.org>
parents: 2999
diff changeset
   257
  virtual int Connect (const Address &address) = 0;
7182
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   258
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
   259
  /**
3000
bd2d3e32ef7b A few minor cleanups to socket.h/cc
Tom Henderson <tomh@tomh.org>
parents: 2999
diff changeset
   260
   * \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
   261
   * \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
   262
   */
3772
f0d8608ab155 Remove queue limit from listen
Craig Dowell <craigdo@ee.washington.edu>
parents: 3521
diff changeset
   263
  virtual int Listen (void) = 0;
3000
bd2d3e32ef7b A few minor cleanups to socket.h/cc
Tom Henderson <tomh@tomh.org>
parents: 2999
diff changeset
   264
bd2d3e32ef7b A few minor cleanups to socket.h/cc
Tom Henderson <tomh@tomh.org>
parents: 2999
diff changeset
   265
  /**
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   266
   * \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
   267
   * to Send. 
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   268
   * 
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   269
   * 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
   270
   * 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
   271
   *
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   272
   * 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
   273
   * left in the transmit buffer.
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   274
   */
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   275
  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
   276
 
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   277
  /**
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 349
diff changeset
   278
   * \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
   279
   *
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
   280
   * This function matches closely in semantics to the send() function
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
   281
   * call in the standard C library (libc):
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
   282
   *   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
   283
   * 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
   284
   * 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
   285
   * by subclasses.
3122
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
   286
   * 
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
   287
   * 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
   288
   * 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
   289
   * 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
   290
   * registered with SetSendCallback() is invoked when the socket
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
   291
   * has space (when it conceptually unblocks); this is an asynchronous
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
   292
   * I/O model for send().
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
   293
   * 
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
   294
   * This variant of Send() uses class ns3::Packet to encapsulate
7182
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   295
   * data, rather than providing a raw pointer and length field.
3122
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
   296
   * 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
   297
   * 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
   298
   * copies.  Despite the appearance of sending Packets on a stream
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
   299
   * socket, just think of it as a fancy byte buffer with streaming
7182
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   300
   * semantics.
3122
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
   301
   *
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
   302
   * 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
   303
   * atomically through the underlying protocol (for datagram sockets), 
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
   304
   * 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
   305
   * (for stream sockets), -1 is returned and SocketErrno is set 
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
   306
   * 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
   307
   * split the Packet (based on information obtained from 
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
   308
   * GetTxAvailable) and reattempt to send the data.
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
   309
   *
7182
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   310
   * The flags argument is formed by or'ing one or more of the values:
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   311
   *        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
   312
   *        MSG_DONTROUTE  bypass routing, use direct interface 
7182
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   313
   * These flags are _unsupported_ as of ns-3.1.
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   314
   *
3122
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
   315
   * \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
   316
   * \param flags Socket control flags
3122
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
   317
   * \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
   318
   *          occurs, and -1 otherwise.
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
   319
   *
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   320
   * \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
   321
   */
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   322
  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
   323
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 2186
diff changeset
   324
  /**
2186
69ad6ed6ccf4 Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 1866
diff changeset
   325
   * \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
   326
   *
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   327
   * 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
   328
   * 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
   329
   * pushed to subclasses.
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   330
   *
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   331
   * \param p packet to send
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   332
   * \param flags Socket control flags
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   333
   * \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
   334
   * \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
   335
   *          internal buffer and accepted for transmission.
69ad6ed6ccf4 Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 1866
diff changeset
   336
   */
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   337
  virtual int SendTo (Ptr<Packet> p, uint32_t flags, 
7182
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   338
                      const Address &toAddress) = 0;
2186
69ad6ed6ccf4 Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 1866
diff changeset
   339
3098
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   340
  /**
3104
24d9d9aa0977 Implement GetRxAvailable ()
Tom Henderson <tomh@tomh.org>
parents: 3103
diff changeset
   341
   * Return number of bytes which can be returned from one or 
24d9d9aa0977 Implement GetRxAvailable ()
Tom Henderson <tomh@tomh.org>
parents: 3103
diff changeset
   342
   * multiple calls to Recv.
24d9d9aa0977 Implement GetRxAvailable ()
Tom Henderson <tomh@tomh.org>
parents: 3103
diff changeset
   343
   * Must be possible to call this method from the Recv callback.
24d9d9aa0977 Implement GetRxAvailable ()
Tom Henderson <tomh@tomh.org>
parents: 3103
diff changeset
   344
   */
24d9d9aa0977 Implement GetRxAvailable ()
Tom Henderson <tomh@tomh.org>
parents: 3103
diff changeset
   345
  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
   346
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   347
  /**
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   348
   * \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
   349
   *
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   350
   * 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
   351
   * 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
   352
   *   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
   353
   * 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
   354
   * 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
   355
   * by subclasses.
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   356
   * 
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   357
   * 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
   358
   * In a typical blocking sockets model, this call would block until
7182
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   359
   * at least one byte is returned or the connection closes.
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   360
   * 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
   361
   * 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
   362
   * 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
   363
   * 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
   364
   * (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
   365
   * I/O model for recv().
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   366
   * 
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   367
   * This variant of Recv() uses class ns3::Packet to encapsulate
7182
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   368
   * data, rather than providing a raw pointer and length field.
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   369
   * 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
   370
   * 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
   371
   * 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
   372
   * socket, just think of it as a fancy byte buffer with streaming
7182
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   373
   * semantics.
3269
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
   * 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
   376
   * 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
   377
   * 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
   378
   * are delivered in order, and on-the-wire packet boundaries are
7182
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   379
   * not preserved.
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   380
   * 
7182
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   381
   * 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
   382
   *        MSG_OOB             process out-of-band data
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   383
   *        MSG_PEEK            peek at incoming message
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   384
   * 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
   385
   *
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   386
   * 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
   387
   * 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
   388
   * 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
   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
   * \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
   393
   * 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
   394
   * to the maxSize and flags.
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   395
   *
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   396
   * \see SetRecvCallback
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> 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
   399
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   400
  /**
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   401
   * \brief 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
   402
   * address.
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   403
   *
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   404
   * 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
   405
   * 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
   406
   *
7182
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   407
   * This method has similar semantics to Recv () but subclasses may
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   408
   * want to provide checks on socket state, so the implementation is
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   409
   * pushed to subclasses.
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 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
   412
   * \param flags Socket control flags
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   413
   * \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
   414
   * 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
   415
   * 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
   416
   * \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
   417
   * 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
   418
   */
7182
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   419
  virtual Ptr<Packet> RecvFrom (uint32_t maxSize, uint32_t flags,
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   420
                                Address &fromAddress) = 0;
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   421
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
  //   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
   424
  //   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
   425
  /////////////////////////////////////////////////////////////////////
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   426
 
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   427
  /**
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   428
   * \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
   429
   * 
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   430
   * 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
   431
   *
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   432
   * \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
   433
   * \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
   434
   *          occurs, and -1 otherwise.
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   435
   */
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   436
  int Send (Ptr<Packet> p);
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
  /**
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   439
   * \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
   440
   * 
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   441
   * This method is provided so as to have an API which is closer in 
7182
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   442
   * appearance to that of real network or BSD sockets.
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   443
   *
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   444
   * \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
   445
   * 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
   446
   * second parameter
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   447
   * \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
   448
   * \param flags Socket control flags
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   449
   */
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   450
  int Send (const uint8_t* buf, uint32_t size, uint32_t flags);
7182
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   451
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   452
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
   * \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
   455
   *
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   456
   * This method is provided so as to have an API which is closer in 
7182
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   457
   * appearance to that of real network or BSD sockets.
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   458
   *
7182
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   459
   * \param buf A pointer to a raw byte buffer of some data to send.
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   460
   * 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
   461
   * third parameter
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   462
   * \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
   463
   * \param flags Socket control flags
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   464
   * \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
   465
   * \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
   466
   *          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
   467
   *
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   468
   */
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   469
  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
   470
              const Address &address); 
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   471
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   472
  /**
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   473
   * \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
   474
   *
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   475
   * 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
   476
   * 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
   477
   *
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   478
   * \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
   479
   * 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
   480
   */
7182
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   481
  Ptr<Packet> Recv (void);
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   482
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   483
  /**
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   484
   * \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
   485
   *
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   486
   * This method is provided so as to have an API which is closer in 
7182
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   487
   * appearance to that of real network or BSD sockets.
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   488
   * 
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   489
   * 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
   490
   * 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
   491
   *
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   492
   * \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
   493
   * \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
   494
   * \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
   495
   * \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
   496
   */
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   497
  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
   498
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
   * \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
   501
   * address.
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   502
   *
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   503
   * 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
   504
   * 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
   505
   *
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   506
   * \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
   507
   * 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
   508
   * 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
   509
   * \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
   510
   * 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
   511
   */
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   512
  Ptr<Packet> RecvFrom (Address &fromAddress);
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   513
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   514
  /**
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   515
   * \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
   516
   * address.
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   517
   *
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   518
   * This method is provided so as to have an API which is closer in 
7182
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   519
   * appearance to that of real network or BSD sockets.
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   520
   * 
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   521
   * \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
   522
   * 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
   523
   * 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
   524
   * \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
   525
   * \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
   526
   * \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
   527
   * 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
   528
   * 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
   529
   * \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
   530
   */
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   531
  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
   532
                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
   533
  /**
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
   534
   * \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
   535
   * \returns 0 if success, -1 otherwise
3778
78c4c41557f3 Liu's GetSockName patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   536
   */
78c4c41557f3 Liu's GetSockName patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   537
  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
   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 Bind a socket to specific device.
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 setsockopt() 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.   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
   544
   * 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
   545
   * 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
   546
   * 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
   547
   *
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5377
diff changeset
   548
   * 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
   549
   * 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
   550
   * 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
   551
   * 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
   552
   * 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
   553
   * 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
   554
   *
6008
aa1c297a0de2 Fix non-undocumented warnings in doxygen, also update doxygen.conf
Josh Pelkey <jpelkey@gatech.edu>
parents: 5856
diff changeset
   555
   * \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
   556
   * \returns nothing
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5377
diff changeset
   557
   */
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5377
diff changeset
   558
  virtual void BindToNetDevice (Ptr<NetDevice> netdevice);
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5377
diff changeset
   559
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5377
diff changeset
   560
  /**
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5377
diff changeset
   561
   * \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
   562
   *
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5377
diff changeset
   563
   * This method corresponds to using getsockopt() SO_BINDTODEVICE
7182
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   564
   * of real network or BSD sockets.
5856
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5377
diff changeset
   565
   * 
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5377
diff changeset
   566
   * 
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5377
diff changeset
   567
   * \returns Pointer to interface.
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5377
diff changeset
   568
   */
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5377
diff changeset
   569
  Ptr<NetDevice> GetBoundNetDevice (); 
6437
c11291f51d57 Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6158
diff changeset
   570
c11291f51d57 Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6158
diff changeset
   571
c11291f51d57 Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6158
diff changeset
   572
  /**
c11291f51d57 Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6158
diff changeset
   573
   * \brief Configure whether broadcast datagram transmissions are allowed
c11291f51d57 Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6158
diff changeset
   574
   *
c11291f51d57 Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6158
diff changeset
   575
   * This method corresponds to using setsockopt() SO_BROADCAST of
c11291f51d57 Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6158
diff changeset
   576
   * real network or BSD sockets.  If set on a socket, this option
c11291f51d57 Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6158
diff changeset
   577
   * will enable or disable packets to be transmitted to broadcast
c11291f51d57 Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6158
diff changeset
   578
   * destination addresses.
c11291f51d57 Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6158
diff changeset
   579
   *
c11291f51d57 Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6158
diff changeset
   580
   * \param allowBroadcast Whether broadcast is allowed
6448
184a509cc71d Still Bug 943: fix UdpSocketImpl::GetAllowBroadcast, let Socket::SetAllowBroadcast return a bool indicating success/failure, instead of a fatal error.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6445
diff changeset
   581
   * \return true if operation succeeds
6437
c11291f51d57 Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6158
diff changeset
   582
   */
6448
184a509cc71d Still Bug 943: fix UdpSocketImpl::GetAllowBroadcast, let Socket::SetAllowBroadcast return a bool indicating success/failure, instead of a fatal error.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6445
diff changeset
   583
  virtual bool SetAllowBroadcast (bool allowBroadcast) = 0;
6437
c11291f51d57 Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6158
diff changeset
   584
c11291f51d57 Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6158
diff changeset
   585
  /**
c11291f51d57 Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6158
diff changeset
   586
   * \brief Query whether broadcast datagram transmissions are allowed
c11291f51d57 Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6158
diff changeset
   587
   *
c11291f51d57 Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6158
diff changeset
   588
   * This method corresponds to using getsockopt() SO_BROADCAST of
c11291f51d57 Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6158
diff changeset
   589
   * real network or BSD sockets.
c11291f51d57 Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6158
diff changeset
   590
   *
c11291f51d57 Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6158
diff changeset
   591
   * \returns true if broadcast is allowed, false otherwise
c11291f51d57 Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6158
diff changeset
   592
   */
c11291f51d57 Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6158
diff changeset
   593
  virtual bool GetAllowBroadcast () const = 0;
c11291f51d57 Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6158
diff changeset
   594
6442
f380cf1aa4d8 Bug 671 add packet-info-tag.cc for IP_PKTINFO/IPV6_PKTINFO
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 6437
diff changeset
   595
  /**
f380cf1aa4d8 Bug 671 add packet-info-tag.cc for IP_PKTINFO/IPV6_PKTINFO
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 6437
diff changeset
   596
   * \brief Enable/Disable receive packet information to socket.
f380cf1aa4d8 Bug 671 add packet-info-tag.cc for IP_PKTINFO/IPV6_PKTINFO
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 6437
diff changeset
   597
   *
f380cf1aa4d8 Bug 671 add packet-info-tag.cc for IP_PKTINFO/IPV6_PKTINFO
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 6437
diff changeset
   598
   * For IP_PKTINFO/IP6_PKTINFO. This method is only usable for 
f380cf1aa4d8 Bug 671 add packet-info-tag.cc for IP_PKTINFO/IPV6_PKTINFO
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 6437
diff changeset
   599
   * Raw socket and Datagram Socket. Not supported for Stream socket.
f380cf1aa4d8 Bug 671 add packet-info-tag.cc for IP_PKTINFO/IPV6_PKTINFO
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 6437
diff changeset
   600
   *
7758
c678188af993 Replace references to m_recvpktinfo with method call IsRecvPktInfo()
frederic.urbani@inria.fr
parents: 7719
diff changeset
   601
   * Method doesn't make distinction between IPv4 and IPv6. If it is enabled,
c678188af993 Replace references to m_recvpktinfo with method call IsRecvPktInfo()
frederic.urbani@inria.fr
parents: 7719
diff changeset
   602
   * it is enabled for all types of sockets that supports packet information
c678188af993 Replace references to m_recvpktinfo with method call IsRecvPktInfo()
frederic.urbani@inria.fr
parents: 7719
diff changeset
   603
   *
6445
43d91786d268 simple doxygen fixes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6442
diff changeset
   604
   * \param flag Enable/Disable receive information
6442
f380cf1aa4d8 Bug 671 add packet-info-tag.cc for IP_PKTINFO/IPV6_PKTINFO
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 6437
diff changeset
   605
   * \returns nothing
f380cf1aa4d8 Bug 671 add packet-info-tag.cc for IP_PKTINFO/IPV6_PKTINFO
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 6437
diff changeset
   606
   */
f380cf1aa4d8 Bug 671 add packet-info-tag.cc for IP_PKTINFO/IPV6_PKTINFO
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 6437
diff changeset
   607
  void SetRecvPktInfo (bool flag);
7758
c678188af993 Replace references to m_recvpktinfo with method call IsRecvPktInfo()
frederic.urbani@inria.fr
parents: 7719
diff changeset
   608
c678188af993 Replace references to m_recvpktinfo with method call IsRecvPktInfo()
frederic.urbani@inria.fr
parents: 7719
diff changeset
   609
  /**
c678188af993 Replace references to m_recvpktinfo with method call IsRecvPktInfo()
frederic.urbani@inria.fr
parents: 7719
diff changeset
   610
   * \brief Get status indicating whether enable/disable packet information to socket
c678188af993 Replace references to m_recvpktinfo with method call IsRecvPktInfo()
frederic.urbani@inria.fr
parents: 7719
diff changeset
   611
   *
c678188af993 Replace references to m_recvpktinfo with method call IsRecvPktInfo()
frederic.urbani@inria.fr
parents: 7719
diff changeset
   612
   * \returns True if packet information should be sent to socket
c678188af993 Replace references to m_recvpktinfo with method call IsRecvPktInfo()
frederic.urbani@inria.fr
parents: 7719
diff changeset
   613
   */
c678188af993 Replace references to m_recvpktinfo with method call IsRecvPktInfo()
frederic.urbani@inria.fr
parents: 7719
diff changeset
   614
  bool IsRecvPktInfo () const;
9145
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   615
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   616
  /*
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   617
   * \brief Manually set IP Type of Service field
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   618
   * 
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   619
   * This method corresponds to using setsockopt () IP_TOS of
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   620
   * real network or BSD sockets. This option is for IPv4 only.
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   621
   * Setting the IP TOS should also change the socket queueing
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   622
   * priority as stated in the man page. However, socket priority
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   623
   * is not yet supported.
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   624
   *
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   625
   * \param ipTos The desired TOS value for IP headers
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   626
   */
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   627
  void SetIpTos (uint8_t ipTos);
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   628
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   629
  /*
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   630
   * \brief Query the value of IP Type of Service of this socket
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   631
   *
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   632
   * This method corresponds to using getsockopt () IP_TOS of real network
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   633
   * or BSD sockets.
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   634
   *
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   635
   * \return The raw IP TOS value
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   636
   */
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   637
  uint8_t GetIpTos (void) const;
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   638
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   639
  /**
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   640
   * \brief Tells a socket to pass information about IP Type of Service up the stack
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   641
   *
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   642
   * This method corresponds to using setsockopt () IP_RECVTOS of real
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   643
   * network or BSD sockets. In our implementation, the socket simply 
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   644
   * adds a SocketIpTosTag tag to the packet before passing the
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   645
   * packet up the stack.
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   646
   *
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   647
   * \param ipv4RecvTos Whether the socket should add SocketIpv4TosTag tag
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   648
   * to the packet
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   649
   */
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   650
  void SetIpRecvTos (bool ipv4RecvTos);
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   651
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   652
  /**
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   653
   * \brief Ask if the socket is currently passing information about IP Type of Service up the stack
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   654
   *
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   655
   * This method corresponds to using getsockopt () IP_RECVTOS of real
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   656
   * network or BSD sockets.
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   657
   *
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   658
   * \return Wheter the IP_RECVTOS is set
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   659
   */
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   660
  bool IsIpRecvTos (void) const;
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   661
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   662
  /*
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   663
   * \brief Manually set IPv6 Traffic Class field
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   664
   * 
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   665
   * This method corresponds to using setsockopt () IPV6_TCLASS of
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   666
   * real network or BSD sockets. This option is for IPv6 only.
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   667
   * Setting the IPV6_TCLASSS to -1 clears the option and let the socket
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   668
   * uses the default value.
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   669
   *
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   670
   * \param ipTclass The desired TCLASS value for IPv6 headers
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   671
   */
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   672
  void SetIpv6Tclass (int ipTclass);
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   673
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   674
  /*
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   675
   * \brief Query the value of IPv6 Traffic Class field of this socket
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   676
   *
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   677
   * This method corresponds to using getsockopt () IPV6_TCLASS of real network
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   678
   * or BSD sockets.
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   679
   *
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   680
   * \return The raw IPV6_TCLASS value
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   681
   */
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   682
  uint8_t GetIpv6Tclass (void) const;
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   683
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   684
  /**
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   685
   * \brief Tells a socket to pass information about IPv6 Traffic Class up the stack
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   686
   *
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   687
   * This method corresponds to using setsockopt () IPV6_RECVTCLASS of real
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   688
   * network or BSD sockets. In our implementation, the socket simply 
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   689
   * adds a SocketIpv6TclasssTag tag to the packet before passing the
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   690
   * packet up the stack.
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   691
   *
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   692
   * \param ipv6RecvTclass Whether the socket should add SocketIpv6TclassTag tag
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   693
   * to the packet
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   694
   */
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   695
  void SetIpv6RecvTclass (bool ipv6RecvTclass);
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   696
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   697
  /**
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   698
   * \brief Ask if the socket is currently passing information about IPv6 Traffic Class up the stack
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   699
   *
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   700
   * This method corresponds to using getsockopt () IPV6_RECVTCLASS of real
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   701
   * network or BSD sockets.
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   702
   *
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   703
   * \return Wheter the IPV6_RECVTCLASS is set
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   704
   */
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   705
  bool IsIpv6RecvTclass (void) const;
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   706
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   707
  /*
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   708
   * \brief Manually set IP Time to Live field
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   709
   * 
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   710
   * This method corresponds to using setsockopt () IP_TTL of
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   711
   * real network or BSD sockets.
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   712
   *
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   713
   * \param ipTtl The desired TTL value for IP headers
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   714
   */
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   715
  virtual void SetIpTtl (uint8_t ipTtl);
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   716
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   717
  /*
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   718
   * \brief Query the value of IP Time to Live field of this socket
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   719
   *
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   720
   * This method corresponds to using getsockopt () IP_TTL of real network
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   721
   * or BSD sockets.
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   722
   *
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   723
   * \return The raw IP TTL value
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   724
   */
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   725
  virtual uint8_t GetIpTtl (void) const;
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   726
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   727
  /**
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   728
   * \brief Tells a socket to pass information about IP_TTL up the stack
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   729
   *
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   730
   * This method corresponds to using setsockopt () IP_RECVTTL of real
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   731
   * network or BSD sockets. In our implementation, the socket simply 
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   732
   * adds a SocketIpTtlTag tag to the packet before passing the
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   733
   * packet up the stack.
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   734
   *
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   735
   * \param ipv4RecvTtl Whether the socket should add SocketIpv4TtlTag tag
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   736
   * to the packet
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   737
   */
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   738
  void SetIpRecvTtl (bool ipv4RecvTtl);
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   739
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   740
  /**
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   741
   * \brief Ask if the socket is currently passing information about IP_TTL up the stack
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   742
   *
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   743
   * This method corresponds to using getsockopt () IP_RECVTTL of real
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   744
   * network or BSD sockets.
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   745
   *
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   746
   * \return Wheter the IP_RECVTTL is set
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   747
   */
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   748
  bool IsIpRecvTtl (void) const;
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   749
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   750
  /*
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   751
   * \brief Manually set IPv6 Hop Limit
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   752
   * 
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   753
   * This method corresponds to using setsockopt () IPV6_HOPLIMIT of
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   754
   * real network or BSD sockets.
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   755
   *
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   756
   * \param ipHopLimit The desired Hop Limit value for IPv6 headers
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   757
   */
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   758
  virtual void SetIpv6HopLimit (uint8_t ipHopLimit);
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   759
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   760
  /*
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   761
   * \brief Query the value of IP Hop Limit field of this socket
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   762
   *
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   763
   * This method corresponds to using getsockopt () IPV6_HOPLIMIT of real network
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   764
   * or BSD sockets.
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   765
   *
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   766
   * \return The raw IPv6 Hop Limit value
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   767
   */
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   768
  virtual uint8_t GetIpv6HopLimit (void) const;
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   769
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   770
  /**
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   771
   * \brief Tells a socket to pass information about IPv6 Hop Limit up the stack
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   772
   *
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   773
   * This method corresponds to using setsockopt () IPV6_RECVHOPLIMIT of real
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   774
   * network or BSD sockets. In our implementation, the socket simply 
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   775
   * adds a SocketIpv6HopLimitTag tag to the packet before passing the
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   776
   * packet up the stack.
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   777
   *
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   778
   * \param ipv6RecvHopLimit Whether the socket should add SocketIpv6HopLimitTag tag
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   779
   * to the packet
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   780
   */
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   781
  void SetIpv6RecvHopLimit (bool ipv6RecvHopLimit);
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   782
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   783
  /**
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   784
   * \brief Ask if the socket is currently passing information about IPv6 Hop Limit up the stack
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   785
   *
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   786
   * This method corresponds to using getsockopt () IPV6_RECVHOPLIMIT of real
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   787
   * network or BSD sockets.
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   788
   *
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   789
   * \return Wheter the IPV6_RECVHOPLIMIT is set
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   790
   */
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   791
  bool IsIpv6RecvHopLimit (void) const;
3104
24d9d9aa0977 Implement GetRxAvailable ()
Tom Henderson <tomh@tomh.org>
parents: 3103
diff changeset
   792
 
1264
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   793
protected:
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   794
  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
   795
  void NotifyConnectionFailed (void);
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7182
diff changeset
   796
  void NotifyNormalClose (void);
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7182
diff changeset
   797
  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
   798
  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
   799
  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
   800
  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
   801
  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
   802
  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
   803
  virtual void DoDispose (void);
9145
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   804
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   805
  bool IsManualIpTos (void) const;
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   806
  bool IsManualIpv6Tclass (void) const;
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   807
  bool IsManualIpTtl (void) const;
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   808
  bool IsManualIpv6HopLimit (void) const;
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   809
5856
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5377
diff changeset
   810
  Ptr<NetDevice> m_boundnetdevice;
7758
c678188af993 Replace references to m_recvpktinfo with method call IsRecvPktInfo()
frederic.urbani@inria.fr
parents: 7719
diff changeset
   811
  bool m_recvPktInfo;
9145
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   812
3375
86a8eceb023e no need for protected variables
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3309
diff changeset
   813
private:
5377
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 5227
diff changeset
   814
  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
   815
  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
   816
  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
   817
  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
   818
  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
   819
  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
   820
  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
   821
  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
   822
  Callback<void, Ptr<Socket> >                   m_receivedData;
3107
ec3ed34b2470 API for SocketOptions class
Tom Henderson <tomh@tomh.org>
parents: 3105
diff changeset
   823
9145
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   824
  //IPv4 options
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   825
  bool m_manualIpTos;
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   826
  bool m_manualIpTtl;
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   827
  bool m_ipRecvTos;
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   828
  bool m_ipRecvTtl;
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   829
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   830
  uint8_t m_ipTos;
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   831
  uint8_t m_ipTtl;
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   832
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   833
  //IPv6 options
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   834
  bool m_manualIpv6Tclass;
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   835
  bool m_manualIpv6HopLimit;
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   836
  bool m_ipv6RecvTclass;
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   837
  bool m_ipv6RecvHopLimit;
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   838
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   839
  uint8_t m_ipv6Tclass;
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   840
  uint8_t m_ipv6HopLimit;
349
3c91100689d7 Add base class IPAddr; L4Protocol; Protocol; OnOff Application, and base class Socket
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   841
};
3c91100689d7 Add base class IPAddr; L4Protocol; Protocol; OnOff Application, and base class Socket
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   842
3098
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   843
/**
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   844
 * \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
   845
 * 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
   846
 */
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   847
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
   848
{
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   849
public:
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   850
  SocketAddressTag ();
3098
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   851
  void SetAddress (Address addr);
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   852
  Address GetAddress (void) const;
3138
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   853
7182
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   854
  static TypeId GetTypeId (void);
3138
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   855
  virtual TypeId GetInstanceTypeId (void) const;
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   856
  virtual uint32_t GetSerializedSize (void) const;
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   857
  virtual void Serialize (TagBuffer i) const;
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   858
  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
   859
  virtual void Print (std::ostream &os) const;
3138
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   860
3098
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   861
private:
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   862
  Address m_address;
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   863
};
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   864
3124
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   865
/**
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   866
 * \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
   867
 * TTL of a packet to the IP layer
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   868
 */
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   869
class SocketIpTtlTag : public Tag
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   870
{
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   871
public:
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   872
  SocketIpTtlTag ();
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   873
  void SetTtl (uint8_t ttl);
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   874
  uint8_t GetTtl (void) const;
3138
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   875
7182
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   876
  static TypeId GetTypeId (void);
3138
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   877
  virtual TypeId GetInstanceTypeId (void) const;
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   878
  virtual uint32_t GetSerializedSize (void) const;
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   879
  virtual void Serialize (TagBuffer i) const;
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   880
  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
   881
  virtual void Print (std::ostream &os) const;
3138
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   882
3124
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   883
private:
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   884
  uint8_t m_ttl;
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   885
};
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   886
9145
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   887
/**
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   888
 * \brief This class implements a tag that carries the socket-specific
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   889
 * HOPLIMIT of a packet to the IPv6 layer
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   890
 */
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   891
class SocketIpv6HopLimitTag : public Tag
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   892
{
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   893
public:
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   894
  SocketIpv6HopLimitTag ();
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   895
  void SetHopLimit (uint8_t hopLimit);
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   896
  uint8_t GetHopLimit (void) const;
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   897
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   898
  static TypeId GetTypeId (void);
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   899
  virtual TypeId GetInstanceTypeId (void) const;
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   900
  virtual uint32_t GetSerializedSize (void) const;
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   901
  virtual void Serialize (TagBuffer i) const;
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   902
  virtual void Deserialize (TagBuffer i);
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   903
  virtual void Print (std::ostream &os) const;
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   904
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   905
private:
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   906
  uint8_t m_hopLimit;
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   907
};
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   908
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   909
/**
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   910
 * \brief indicated whether packets should be sent out with
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   911
 * the DF flag set.
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   912
 */
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   913
class SocketSetDontFragmentTag : public Tag
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   914
{
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   915
public:
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   916
  SocketSetDontFragmentTag ();
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   917
  void Enable (void);
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   918
  void Disable (void);
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   919
  bool IsEnabled (void) const;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   920
7182
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   921
  static TypeId GetTypeId (void);
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   922
  virtual TypeId GetInstanceTypeId (void) const;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   923
  virtual uint32_t GetSerializedSize (void) const;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   924
  virtual void Serialize (TagBuffer i) const;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   925
  virtual void Deserialize (TagBuffer i);
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   926
  virtual void Print (std::ostream &os) const;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   927
private:
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   928
  bool m_dontFragment;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   929
};
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   930
9145
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   931
/*
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   932
 * \brief indicated whether the socket has IP_TOS set.
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   933
 * This tag is for IPv4 socket.
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   934
 */
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   935
class SocketIpTosTag : public Tag
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   936
{
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   937
public:
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   938
  SocketIpTosTag ();
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   939
  void SetTos (uint8_t tos);
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   940
  uint8_t GetTos (void) const;
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   941
  
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   942
  static TypeId GetTypeId (void);
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   943
  virtual TypeId GetInstanceTypeId (void) const;
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   944
  virtual uint32_t GetSerializedSize (void) const;
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   945
  virtual void Serialize (TagBuffer i) const;
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   946
  virtual void Deserialize (TagBuffer i);
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   947
  virtual void Print (std::ostream &os) const;
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   948
private:
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   949
  uint8_t m_ipTos;
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   950
};
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   951
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   952
/*
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   953
 * \brief indicated whether the socket has IPV6_TCLASS set.
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   954
 * This tag is for IPv6 socket.
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   955
 */
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   956
class SocketIpv6TclassTag : public Tag
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   957
{
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   958
public:
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   959
  SocketIpv6TclassTag ();
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   960
  void SetTclass (uint8_t tclass);
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   961
  uint8_t GetTclass (void) const;
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   962
  
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   963
  static TypeId GetTypeId (void);
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   964
  virtual TypeId GetInstanceTypeId (void) const;
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   965
  virtual uint32_t GetSerializedSize (void) const;
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   966
  virtual void Serialize (TagBuffer i) const;
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   967
  virtual void Deserialize (TagBuffer i);
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   968
  virtual void Print (std::ostream &os) const;
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   969
private:
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   970
  uint8_t m_ipv6Tclass;
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   971
};
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7870
diff changeset
   972
7386
2310ed220a61 standardize ns-3 namespace declaration format
Vedran Miletić <rivanvx@gmail.com>
parents: 7355
diff changeset
   973
} // namespace ns3
349
3c91100689d7 Add base class IPAddr; L4Protocol; Protocol; OnOff Application, and base class Socket
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   974
7353
09fccf6195ea bug 1203: Inconsistently named ifndef/define macros in ns-3 headers
Vedran Miletic <rivanvx@gmail.com>
parents: 7256
diff changeset
   975
#endif /* NS3_SOCKET_H */