A Discrete-Event Network Simulator
API
ipv4-raw-socket-impl.h
Go to the documentation of this file.
1 #ifndef IPV4_RAW_SOCKET_IMPL_H
2 #define IPV4_RAW_SOCKET_IMPL_H
3 
4 #include "ipv4-header.h"
5 #include "ipv4-interface.h"
6 #include "ipv4-route.h"
7 
8 #include "ns3/socket.h"
9 
10 #include <list>
11 
12 namespace ns3
13 {
14 
15 class NetDevice;
16 class Node;
17 
29 class Ipv4RawSocketImpl : public Socket
30 {
31  public:
36  static TypeId GetTypeId();
37 
39 
44  void SetNode(Ptr<Node> node);
45 
46  Socket::SocketErrno GetErrno() const override;
47 
52  Socket::SocketType GetSocketType() const override;
53 
54  Ptr<Node> GetNode() const override;
55  int Bind(const Address& address) override;
56  int Bind() override;
57  int Bind6() override;
58  int GetSockName(Address& address) const override;
59  int GetPeerName(Address& address) const override;
60  int Close() override;
61  int ShutdownSend() override;
62  int ShutdownRecv() override;
63  int Connect(const Address& address) override;
64  int Listen() override;
65  uint32_t GetTxAvailable() const override;
66  int Send(Ptr<Packet> p, uint32_t flags) override;
67  int SendTo(Ptr<Packet> p, uint32_t flags, const Address& toAddress) override;
68  uint32_t GetRxAvailable() const override;
69  Ptr<Packet> Recv(uint32_t maxSize, uint32_t flags) override;
70  Ptr<Packet> RecvFrom(uint32_t maxSize, uint32_t flags, Address& fromAddress) override;
71 
76  void SetProtocol(uint16_t protocol);
77 
85  bool ForwardUp(Ptr<const Packet> p, Ipv4Header ipHeader, Ptr<Ipv4Interface> incomingInterface);
86  bool SetAllowBroadcast(bool allowBroadcast) override;
87  bool GetAllowBroadcast() const override;
88 
89  private:
90  void DoDispose() override;
91 
96  struct Data
97  {
100  uint16_t fromProtocol;
101  };
102 
107  uint16_t m_protocol;
108  std::list<Data> m_recv;
111  uint32_t m_icmpFilter;
112  bool m_iphdrincl;
113 };
114 
115 } // namespace ns3
116 
117 #endif /* IPV4_RAW_SOCKET_IMPL_H */
a polymophic address class
Definition: address.h:101
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:42
Packet header for IPv4.
Definition: ipv4-header.h:34
Ptr< Node > GetNode() const override
Return the node this socket is associated with.
Socket::SocketType GetSocketType() const override
Get socket type (NS3_SOCK_RAW)
int GetPeerName(Address &address) const override
Get the peer address of a connected socket.
Ipv4Address m_src
Source address.
std::list< Data > m_recv
Packet waiting to be processed.
int Bind() override
Allocate a local IPv4 endpoint for this socket.
int Send(Ptr< Packet > p, uint32_t flags) override
Send data (or dummy data) to the remote host.
Ipv4Address m_dst
Destination address.
void DoDispose() override
Destructor implementation.
int Close() override
Close a socket.
int Listen() override
Listen for incoming connections.
bool GetAllowBroadcast() const override
Query whether broadcast datagram transmissions are allowed.
uint32_t GetRxAvailable() const override
Return number of bytes which can be returned from one or multiple calls to Recv.
Socket::SocketErrno m_err
Last error number.
void SetProtocol(uint16_t protocol)
Set protocol field.
Ptr< Packet > RecvFrom(uint32_t maxSize, uint32_t flags, Address &fromAddress) override
Read a single packet from the socket and retrieve the sender address.
bool m_iphdrincl
Include IP Header information (a.k.a setsockopt (IP_HDRINCL))
uint16_t m_protocol
Protocol.
Socket::SocketErrno GetErrno() const override
Get last error number.
int Connect(const Address &address) override
Initiate a connection to a remote host.
int Bind6() override
Allocate a local IPv6 endpoint for this socket.
bool SetAllowBroadcast(bool allowBroadcast) override
Configure whether broadcast datagram transmissions are allowed.
bool ForwardUp(Ptr< const Packet > p, Ipv4Header ipHeader, Ptr< Ipv4Interface > incomingInterface)
Forward up to receive method.
uint32_t m_icmpFilter
ICMPv4 filter specification.
bool m_shutdownRecv
Flag to shutdown receive capability.
static TypeId GetTypeId()
Get the type ID of this class.
void SetNode(Ptr< Node > node)
Set the node associated with this socket.
uint32_t GetTxAvailable() const override
Returns the number of bytes which can be sent in a single call to Send.
bool m_shutdownSend
Flag to shutdown send capability.
int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress) override
Send data to a specified peer.
int GetSockName(Address &address) const override
Get socket address.
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
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.
IPv4 raw data and additional information.
Ipv4Address fromIp
Source address.
uint16_t fromProtocol
Protocol used.
Ptr< Packet > packet
Packet data.