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-- |
3129 | 1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 |
/* |
|
3 |
* Copyright (c) 2006 Georgia Tech Research Corporation |
|
4 |
* 2007 INRIA |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or modify |
|
7 |
* it under the terms of the GNU General Public License version 2 as |
|
8 |
* published by the Free Software Foundation; |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
18 |
* |
|
19 |
* Authors: George F. Riley<riley@ece.gatech.edu> |
|
20 |
* Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
|
21 |
*/ |
|
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 | 25 |
|
26 |
#include "socket.h" |
|
27 |
#include "ns3/traced-callback.h" |
|
28 |
#include "ns3/callback.h" |
|
29 |
#include "ns3/ptr.h" |
|
30 |
#include "ns3/object.h" |
|
31 |
||
32 |
namespace ns3 { |
|
33 |
||
34 |
class Node; |
|
35 |
class Packet; |
|
36 |
||
37 |
/** |
|
3183 | 38 |
* \ingroup socket |
39 |
* |
|
3129 | 40 |
* \brief (abstract) base class of all UdpSockets |
41 |
* |
|
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 | 45 |
*/ |
3130
881cc06cd651
rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
3129
diff
changeset
|
46 |
class UdpSocket : public Socket |
3129 | 47 |
{ |
48 |
public: |
|
49 |
static TypeId GetTypeId (void); |
|
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 | 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 | 101 |
// Indirect the attribute setting and getting through private virtual methods |
102 |
virtual void SetRcvBufSize (uint32_t size) = 0; |
|
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 | 112 |
virtual void SetMtuDiscover (bool discover) = 0; |
113 |
virtual bool GetMtuDiscover (void) const = 0; |
|
3129 | 114 |
}; |
115 |
||
116 |
} //namespace ns3 |
|
117 |
||
118 |
#endif /* UDP_SOCKET_H */ |
|
119 |
||
120 |