A Discrete-Event Network Simulator
API
ipv6-raw-socket-impl.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2007-2009 Strasbourg University
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
19  */
20 
21 #ifndef IPV6_RAW_SOCKET_IMPL_H
22 #define IPV6_RAW_SOCKET_IMPL_H
23 
24 #include <list>
25 
26 #include "ns3/socket.h"
27 #include "ns3/ipv6-address.h"
28 #include "ns3/ipv6-header.h"
29 
30 namespace ns3
31 {
32 
33 class NetDevice;
34 class Node;
35 
66 class Ipv6RawSocketImpl : public Socket
67 {
68 public:
73  static TypeId GetTypeId ();
74 
76  virtual ~Ipv6RawSocketImpl ();
77 
82  void SetNode (Ptr<Node> node);
83 
84  virtual enum Socket::SocketErrno GetErrno () const;
85 
90  virtual enum Socket::SocketType GetSocketType () const;
91 
92  virtual Ptr<Node> GetNode () const;
93 
94  virtual int Bind (const Address& address);
95  virtual int Bind ();
96  virtual int Bind6 ();
97 
98  virtual int GetSockName (Address& address) const;
99  virtual int GetPeerName (Address& address) const;
100 
101  virtual int Close ();
102  virtual int ShutdownSend ();
103  virtual int ShutdownRecv ();
104  virtual int Connect (const Address& address);
105  virtual int Listen ();
106  virtual uint32_t GetTxAvailable () const;
107  virtual uint32_t GetRxAvailable () const;
108  virtual int Send (Ptr<Packet> p, uint32_t flags);
109  virtual int SendTo (Ptr<Packet> p, uint32_t flags, const Address& toAddress);
110  virtual Ptr<Packet> Recv (uint32_t maxSize, uint32_t flags);
111  virtual Ptr<Packet> RecvFrom (uint32_t maxSize, uint32_t flags, Address& fromAddress);
112  virtual void Ipv6JoinGroup (Ipv6Address address, Socket::Ipv6MulticastFilterMode filterMode, std::vector<Ipv6Address> sourceAddresses);
113 
118  void SetProtocol (uint16_t protocol);
119 
128 
129  virtual bool SetAllowBroadcast (bool allowBroadcast);
130  virtual bool GetAllowBroadcast () const;
131 
135  void Icmpv6FilterSetPassAll();
136 
141 
146  void Icmpv6FilterSetPass(uint8_t type);
147 
152  void Icmpv6FilterSetBlock(uint8_t type);
153 
159  bool Icmpv6FilterWillPass(uint8_t type);
160 
166  bool Icmpv6FilterWillBlock(uint8_t type);
167 
168 
169 private:
173  typedef struct
174  {
177  uint16_t fromProtocol;
178  } Data;
179 
183  virtual void DoDispose ();
184 
188  mutable enum Socket::SocketErrno m_err;
189 
194 
199 
204 
208  uint16_t m_protocol;
209 
213  std::list<Data> m_data;
214 
219 
224 
228  typedef struct
229  {
230  uint32_t icmpv6Filt[8];
231  } Icmpv6Filter;
232 
237 };
238 
239 } /* namespace ns3 */
240 
241 #endif /* IPV6_RAW_SOCKET_IMPL_H */
242 
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
ns3::Ipv6RawSocketImpl::Icmpv6FilterSetBlock
void Icmpv6FilterSetBlock(uint8_t type)
Set the filter to block one ICMPv6 type.
Definition: ipv6-raw-socket-impl.cc:509
ns3::Ipv6RawSocketImpl::m_shutdownRecv
bool m_shutdownRecv
Flag to shutdown receive capability.
Definition: ipv6-raw-socket-impl.h:223
ns3::Ipv6RawSocketImpl::~Ipv6RawSocketImpl
virtual ~Ipv6RawSocketImpl()
Definition: ipv6-raw-socket-impl.cc:71
ns3::Ipv6RawSocketImpl::GetAllowBroadcast
virtual bool GetAllowBroadcast() const
Query whether broadcast datagram transmissions are allowed.
Definition: ipv6-raw-socket-impl.cc:485
ns3::Socket::SocketErrno
SocketErrno
Enumeration of the possible errors returned by a socket.
Definition: socket.h:82
ns3::Ipv6RawSocketImpl::GetRxAvailable
virtual uint32_t GetRxAvailable() const
Return number of bytes which can be returned from one or multiple calls to Recv.
Definition: ipv6-raw-socket-impl.cc:384
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::Ipv6RawSocketImpl::Ipv6RawSocketImpl
Ipv6RawSocketImpl()
Definition: ipv6-raw-socket-impl.cc:58
ns3::Ipv6RawSocketImpl::Icmpv6FilterSetPass
void Icmpv6FilterSetPass(uint8_t type)
Set the filter to pass one ICMPv6 type.
Definition: ipv6-raw-socket-impl.cc:503
ns3::Ipv6RawSocketImpl::SetAllowBroadcast
virtual bool SetAllowBroadcast(bool allowBroadcast)
Configure whether broadcast datagram transmissions are allowed.
Definition: ipv6-raw-socket-impl.cc:475
ns3::Socket::Recv
Ptr< Packet > Recv(void)
Read a single packet from the socket.
Definition: socket.cc:175
ns3::Ipv6RawSocketImpl::SendTo
virtual int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress)
Send data to a specified peer.
Definition: ipv6-raw-socket-impl.cc:209
ns3::Ipv6RawSocketImpl::Data
IPv6 raw data and additional information.
Definition: ipv6-raw-socket-impl.h:174
ns3::Ipv6RawSocketImpl::Icmpv6FilterSetPassAll
void Icmpv6FilterSetPassAll()
Clean the ICMPv6 filter structure.
Definition: ipv6-raw-socket-impl.cc:491
ns3::Ipv6Address
Describes an IPv6 address.
Definition: ipv6-address.h:50
ns3::Ipv6RawSocketImpl::GetErrno
virtual enum Socket::SocketErrno GetErrno() const
Get last error number.
Definition: ipv6-raw-socket-impl.cc:93
ns3::Ipv6RawSocketImpl::GetTxAvailable
virtual uint32_t GetTxAvailable() const
Returns the number of bytes which can be sent in a single call to Send.
Definition: ipv6-raw-socket-impl.cc:378
ns3::Ipv6RawSocketImpl::GetSockName
virtual int GetSockName(Address &address) const
Get socket address.
Definition: ipv6-raw-socket-impl.cc:130
ns3::Ipv6RawSocketImpl::GetPeerName
virtual int GetPeerName(Address &address) const
Get the peer address of a connected socket.
Definition: ipv6-raw-socket-impl.cc:138
ns3::Ipv6Header
Packet header for IPv6.
Definition: ipv6-header.h:36
ns3::Socket::Ipv6MulticastFilterMode
Ipv6MulticastFilterMode
Enumeration of the possible filter of a socket.
Definition: socket.h:139
ns3::Ipv6RawSocketImpl::Icmpv6FilterWillBlock
bool Icmpv6FilterWillBlock(uint8_t type)
Ask the filter about the status of one ICMPv6 type.
Definition: ipv6-raw-socket-impl.cc:521
ns3::Ipv6RawSocketImpl::SetProtocol
void SetProtocol(uint16_t protocol)
Set protocol field.
ns3::Ipv6RawSocketImpl::Close
virtual int Close()
Close a socket.
Definition: ipv6-raw-socket-impl.cc:153
ns3::Ipv6RawSocketImpl::Data::packet
Ptr< Packet > packet
Packet data.
Definition: ipv6-raw-socket-impl.h:175
ns3::Ipv6RawSocketImpl::Icmpv6FilterWillPass
bool Icmpv6FilterWillPass(uint8_t type)
Ask the filter about the status of one ICMPv6 type.
Definition: ipv6-raw-socket-impl.cc:515
ns3::Ipv6RawSocketImpl::Connect
virtual int Connect(const Address &address)
Initiate a connection to a remote host.
Definition: ipv6-raw-socket-impl.cc:180
ns3::Ptr< Node >
ns3::Ipv6RawSocketImpl::DoDispose
virtual void DoDispose()
Dispose object.
Definition: ipv6-raw-socket-impl.cc:75
ns3::Ipv6RawSocketImpl::m_err
enum Socket::SocketErrno m_err
Last error number.
Definition: ipv6-raw-socket-impl.h:188
ns3::Ipv6RawSocketImpl::m_protocol
uint16_t m_protocol
Protocol.
Definition: ipv6-raw-socket-impl.h:208
ns3::Socket
A low-level Socket API based loosely on the BSD Socket API.
Definition: socket.h:67
ns3::Address
a polymophic address class
Definition: address.h:91
ns3::Ipv6RawSocketImpl::ForwardUp
bool ForwardUp(Ptr< const Packet > p, Ipv6Header hdr, Ptr< NetDevice > device)
Forward up to receive method.
Definition: ipv6-raw-socket-impl.cc:397
ns3::Ipv6RawSocketImpl::Data::fromIp
Ipv6Address fromIp
Source address.
Definition: ipv6-raw-socket-impl.h:176
ns3::Socket::SocketType
SocketType
Enumeration of the possible socket types.
Definition: socket.h:104
ns3::Ipv6RawSocketImpl::m_shutdownSend
bool m_shutdownSend
Flag to shutdown send capability.
Definition: ipv6-raw-socket-impl.h:218
ns3::Ipv6RawSocketImpl::SetNode
void SetNode(Ptr< Node > node)
Set the node associated with this socket.
Definition: ipv6-raw-socket-impl.cc:82
ns3::Ipv6RawSocketImpl::m_dst
Ipv6Address m_dst
Destination address.
Definition: ipv6-raw-socket-impl.h:203
first.address
address
Definition: first.py:44
ns3::Ipv6RawSocketImpl::ShutdownRecv
virtual int ShutdownRecv()
Definition: ipv6-raw-socket-impl.cc:173
ns3::Ipv6RawSocketImpl::Icmpv6FilterSetBlockAll
void Icmpv6FilterSetBlockAll()
Set the filter to block all the ICMPv6 types.
Definition: ipv6-raw-socket-impl.cc:497
ns3::Ipv6RawSocketImpl::m_data
std::list< Data > m_data
Packet waiting to be processed.
Definition: ipv6-raw-socket-impl.h:213
ns3::Ipv6RawSocketImpl::Send
virtual int Send(Ptr< Packet > p, uint32_t flags)
Send data (or dummy data) to the remote host.
Definition: ipv6-raw-socket-impl.cc:202
ns3::Ipv6RawSocketImpl
IPv6 raw socket.
Definition: ipv6-raw-socket-impl.h:67
ns3::Ipv6RawSocketImpl::Icmpv6Filter
Struct to hold the ICMPv6 filter.
Definition: ipv6-raw-socket-impl.h:229
ns3::Ipv6RawSocketImpl::Ipv6JoinGroup
virtual void Ipv6JoinGroup(Ipv6Address address, Socket::Ipv6MulticastFilterMode filterMode, std::vector< Ipv6Address > sourceAddresses)
Joins a IPv6 multicast group.
Definition: ipv6-raw-socket-impl.cc:335
ns3::Ipv6RawSocketImpl::GetNode
virtual Ptr< Node > GetNode() const
Return the node this socket is associated with.
Definition: ipv6-raw-socket-impl.cc:88
ns3::Ipv6RawSocketImpl::ShutdownSend
virtual int ShutdownSend()
Definition: ipv6-raw-socket-impl.cc:166
ns3::Ipv6RawSocketImpl::m_node
Ptr< Node > m_node
Node.
Definition: ipv6-raw-socket-impl.h:193
ns3::Ipv6RawSocketImpl::m_icmpFilter
Icmpv6Filter m_icmpFilter
ICMPv6 filter.
Definition: ipv6-raw-socket-impl.h:236
ns3::Ipv6RawSocketImpl::Bind6
virtual int Bind6()
Allocate a local IPv6 endpoint for this socket.
Definition: ipv6-raw-socket-impl.cc:125
ns3::Ipv6RawSocketImpl::GetSocketType
virtual enum Socket::SocketType GetSocketType() const
Get socket type (NS3_SOCK_RAW)
Definition: ipv6-raw-socket-impl.cc:99
ns3::Ipv6RawSocketImpl::GetTypeId
static TypeId GetTypeId()
Get the type ID of this class.
Definition: ipv6-raw-socket-impl.cc:45
ns3::Ipv6RawSocketImpl::m_src
Ipv6Address m_src
Source address.
Definition: ipv6-raw-socket-impl.h:198
ns3::Ipv6RawSocketImpl::Bind
virtual int Bind()
Allocate a local IPv4 endpoint for this socket.
Definition: ipv6-raw-socket-impl.cc:118
ns3::Ipv6RawSocketImpl::Data::fromProtocol
uint16_t fromProtocol
Protocol used.
Definition: ipv6-raw-socket-impl.h:177
ns3::Ipv6RawSocketImpl::RecvFrom
virtual Ptr< Packet > RecvFrom(uint32_t maxSize, uint32_t flags, Address &fromAddress)
Read a single packet from the socket and retrieve the sender address.
Definition: ipv6-raw-socket-impl.cc:307
ns3::Ipv6RawSocketImpl::Listen
virtual int Listen()
Listen for incoming connections.
Definition: ipv6-raw-socket-impl.cc:195