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 "ipv6-header.h"
24 
25 #include "ns3/ipv6-address.h"
26 #include "ns3/socket.h"
27 
28 #include <list>
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  ~Ipv6RawSocketImpl() override;
77 
82  void SetNode(Ptr<Node> node);
83 
84  Socket::SocketErrno GetErrno() const override;
85 
90  Socket::SocketType GetSocketType() const override;
91 
92  Ptr<Node> GetNode() const override;
93 
94  int Bind(const Address& address) override;
95  int Bind() override;
96  int Bind6() override;
97 
98  int GetSockName(Address& address) const override;
99  int GetPeerName(Address& address) const override;
100 
101  int Close() override;
102  int ShutdownSend() override;
103  int ShutdownRecv() override;
104  int Connect(const Address& address) override;
105  int Listen() override;
106  uint32_t GetTxAvailable() const override;
107  uint32_t GetRxAvailable() const override;
108  int Send(Ptr<Packet> p, uint32_t flags) override;
109  int SendTo(Ptr<Packet> p, uint32_t flags, const Address& toAddress) override;
110  Ptr<Packet> Recv(uint32_t maxSize, uint32_t flags) override;
111  Ptr<Packet> RecvFrom(uint32_t maxSize, uint32_t flags, Address& fromAddress) override;
114  std::vector<Ipv6Address> sourceAddresses) override;
115 
120  void SetProtocol(uint16_t protocol);
121 
130 
131  bool SetAllowBroadcast(bool allowBroadcast) override;
132  bool GetAllowBroadcast() const override;
133 
137  void Icmpv6FilterSetPassAll();
138 
143 
148  void Icmpv6FilterSetPass(uint8_t type);
149 
154  void Icmpv6FilterSetBlock(uint8_t type);
155 
161  bool Icmpv6FilterWillPass(uint8_t type);
162 
168  bool Icmpv6FilterWillBlock(uint8_t type);
169 
170  private:
174  struct Data
175  {
178  uint16_t fromProtocol;
179  };
180 
184  void DoDispose() override;
185 
190 
195 
200 
205 
209  uint16_t m_protocol;
210 
214  std::list<Data> m_data;
215 
220 
225 
230  {
231  uint32_t icmpv6Filt[8];
232  };
233 
238 };
239 
240 } /* namespace ns3 */
241 
242 #endif /* IPV6_RAW_SOCKET_IMPL_H */
a polymophic address class
Definition: address.h:101
Describes an IPv6 address.
Definition: ipv6-address.h:49
Packet header for IPv6.
Definition: ipv6-header.h:35
bool Icmpv6FilterWillBlock(uint8_t type)
Ask the filter about the status of one ICMPv6 type.
Socket::SocketErrno m_err
Last error number.
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.
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.
Socket::SocketType GetSocketType() const override
Get socket type (NS3_SOCK_RAW)
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.
Socket::SocketErrno GetErrno() const override
Get last error number.
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.
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:174
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:59
address
Definition: first.py:47
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.