src/node/udp-socket.h
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Sat, 04 Jul 2009 08:15:48 +0200
changeset 4654 2eaebe77d66b
parent 4472 e20a31541404
permissions -rw-r--r--
Added tag ns-3.5 for changeset c975274c9707
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3129
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     2
/*
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     3
 * Copyright (c) 2006 Georgia Tech Research Corporation
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     4
 *               2007 INRIA
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     5
 *
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     6
 * This program is free software; you can redistribute it and/or modify
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     7
 * it under the terms of the GNU General Public License version 2 as
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     8
 * published by the Free Software Foundation;
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     9
 *
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    10
 * This program is distributed in the hope that it will be useful,
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    13
 * GNU General Public License for more details.
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    14
 *
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    16
 * along with this program; if not, write to the Free Software
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    17
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    18
 *
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    19
 * Authors: George F. Riley<riley@ece.gatech.edu>
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    20
 *          Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    21
 */
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    22
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
    23
#ifndef __UDP_SOCKET_H__
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
    24
#define __UDP_SOCKET_H__
3129
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    25
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    26
#include "socket.h"
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    27
#include "ns3/traced-callback.h"
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    28
#include "ns3/callback.h"
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    29
#include "ns3/ptr.h"
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    30
#include "ns3/object.h"
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    31
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    32
namespace ns3 {
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    33
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    34
class Node;
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    35
class Packet;
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    36
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    37
/**
3183
fc3b2e03e61e more doxygen
Tom Henderson <tomh@tomh.org>
parents: 3136
diff changeset
    38
 * \ingroup socket
fc3b2e03e61e more doxygen
Tom Henderson <tomh@tomh.org>
parents: 3136
diff changeset
    39
 *
3129
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    40
 * \brief (abstract) base class of all UdpSockets
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    41
 *
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    42
 * This class exists solely for hosting UdpSocket attributes that can
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
    43
 * be reused across different implementations, and for declaring
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
    44
 * UDP-specific multicast API.
3129
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    45
 */
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
    46
class UdpSocket : public Socket
3129
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    47
{
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    48
public:
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    49
 static TypeId GetTypeId (void);
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    50
 
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
    51
  UdpSocket (void);
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
    52
  virtual ~UdpSocket (void);
3129
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    53
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
    54
  /**
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
    55
   * \brief Corresponds to socket option MCAST_JOIN_GROUP
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
    56
   *
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
    57
   * \param interface interface number, or 0
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
    58
   * \param groupAddress multicast group address
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
    59
   * \returns on success, zero is returned.  On error, -1 is returned,
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
    60
   *          and errno is set appropriately
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
    61
   *
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
    62
   * Enable reception of multicast datagrams for this socket on the
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
    63
   * interface number specified.  If zero is specified as
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
    64
   * the interface, then a single local interface is chosen by
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
    65
   * system.  In the future, this function will generate trigger IGMP
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
    66
   * joins as necessary when IGMP is implemented, but for now, this
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
    67
   * just enables multicast datagram reception in the system if not already
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
    68
   * enabled for this interface/groupAddress combination.
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
    69
   *
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
    70
   * \attention IGMP is not yet implemented in ns-3
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
    71
   *
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
    72
   * This function may be called repeatedly on a given socket but each
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
    73
   * join must be for a different multicast address, or for the same
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
    74
   * multicast address but on a different interface from previous joins.
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
    75
   * This enables host multihoming, and the ability to join the same 
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
    76
   * group on different interfaces.
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
    77
   */
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
    78
  virtual int MulticastJoinGroup (uint32_t interface, const Address &groupAddress) = 0;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
    79
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
    80
  /**
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
    81
   * \brief Corresponds to socket option MCAST_LEAVE_GROUP
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
    82
   *
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
    83
   * \param interface interface number, or 0
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
    84
   * \param groupAddress multicast group address
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
    85
   * \returns on success, zero is returned.  On error, -1 is returned,
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
    86
   *          and errno is set appropriately
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
    87
   *
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
    88
   * Disable reception of multicast datagrams for this socket on the
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
    89
   * interface number specified.  If zero is specified as
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
    90
   * the interfaceIndex, then a single local interface is chosen by
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
    91
   * system.  In the future, this function will generate trigger IGMP
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
    92
   * leaves as necessary when IGMP is implemented, but for now, this
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
    93
   * just disables multicast datagram reception in the system if this
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
    94
   * socket is the last for this interface/groupAddress combination.
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
    95
   *
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
    96
   * \attention IGMP is not yet implemented in ns-3
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
    97
   */
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
    98
  virtual int MulticastLeaveGroup (uint32_t interface, const Address &groupAddress) = 0;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
    99
3136
a59b9ce95b6b Move Tcp attributes from factory to TcpSocket
Tom Henderson <tomh@tomh.org>
parents: 3130
diff changeset
   100
private:
3129
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   101
  // Indirect the attribute setting and getting through private virtual methods
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   102
  virtual void SetRcvBufSize (uint32_t size) = 0;
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   103
  virtual uint32_t GetRcvBufSize (void) const = 0;
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
   104
  virtual void SetIpTtl (uint8_t ipTtl) = 0;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
   105
  virtual uint8_t GetIpTtl (void) const = 0;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
   106
  virtual void SetIpMulticastTtl (uint8_t ipTtl) = 0;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
   107
  virtual uint8_t GetIpMulticastTtl (void) const = 0;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
   108
  virtual void SetIpMulticastIf (int32_t ipIf) = 0;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
   109
  virtual int32_t GetIpMulticastIf (void) const = 0;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
   110
  virtual void SetIpMulticastLoop (bool loop) = 0;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
   111
  virtual bool GetIpMulticastLoop (void) const = 0;
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3398
diff changeset
   112
  virtual void SetMtuDiscover (bool discover) = 0;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3398
diff changeset
   113
  virtual bool GetMtuDiscover (void) const = 0;
3129
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   114
};
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   115
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   116
} //namespace ns3
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   117
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   118
#endif /* UDP_SOCKET_H */
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   119
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   120