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