A Discrete-Event Network Simulator
API
ipv4-raw-socket-impl.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 #ifndef IPV4_RAW_SOCKET_IMPL_H
3 #define IPV4_RAW_SOCKET_IMPL_H
4 
5 #include "ns3/socket.h"
6 #include "ns3/ipv4-header.h"
7 #include "ns3/ipv4-route.h"
8 #include "ns3/ipv4-interface.h"
9 #include <list>
10 
11 namespace ns3 {
12 
13 class NetDevice;
14 class Node;
15 
27 class Ipv4RawSocketImpl : public Socket
28 {
29 public:
34  static TypeId GetTypeId (void);
35 
37 
42  void SetNode (Ptr<Node> node);
43 
44  virtual enum Socket::SocketErrno GetErrno () const;
45 
50  virtual enum Socket::SocketType GetSocketType (void) const;
51 
52  virtual Ptr<Node> GetNode (void) const;
53  virtual int Bind (const Address &address);
54  virtual int Bind ();
55  virtual int Bind6 ();
56  virtual int GetSockName (Address &address) const;
57  virtual int GetPeerName (Address &address) const;
58  virtual int Close (void);
59  virtual int ShutdownSend (void);
60  virtual int ShutdownRecv (void);
61  virtual int Connect (const Address &address);
62  virtual int Listen (void);
63  virtual uint32_t GetTxAvailable (void) const;
64  virtual int Send (Ptr<Packet> p, uint32_t flags);
65  virtual int SendTo (Ptr<Packet> p, uint32_t flags,
66  const Address &toAddress);
67  virtual uint32_t GetRxAvailable (void) const;
68  virtual Ptr<Packet> Recv (uint32_t maxSize, uint32_t flags);
69  virtual Ptr<Packet> RecvFrom (uint32_t maxSize, uint32_t flags,
70  Address &fromAddress);
71 
72 
77  void SetProtocol (uint16_t protocol);
78 
86  bool ForwardUp (Ptr<const Packet> p, Ipv4Header ipHeader, Ptr<Ipv4Interface> incomingInterface);
87  virtual bool SetAllowBroadcast (bool allowBroadcast);
88  virtual bool GetAllowBroadcast () const;
89 
90 private:
91  virtual void DoDispose (void);
92 
97  struct Data {
100  uint16_t fromProtocol;
101  };
102 
103  mutable enum Socket::SocketErrno m_err;
107  uint16_t m_protocol;
108  std::list<struct 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:91
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
Packet header for IPv4.
Definition: ipv4-header.h:34
virtual int GetPeerName(Address &address) const
Get the peer address of a connected socket.
virtual int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress)
Send data to a specified peer.
virtual int ShutdownSend(void)
Ipv4Address m_src
Source address.
virtual int ShutdownRecv(void)
virtual int Bind()
Allocate a local IPv4 endpoint for this socket.
virtual int Connect(const Address &address)
Initiate a connection to a remote host.
virtual uint32_t GetRxAvailable(void) const
Return number of bytes which can be returned from one or multiple calls to Recv.
virtual void DoDispose(void)
Destructor implementation.
Ipv4Address m_dst
Destination address.
static TypeId GetTypeId(void)
Get the type ID of this class.
std::list< struct Data > m_recv
Packet waiting to be processed.
virtual Ptr< Packet > RecvFrom(uint32_t maxSize, uint32_t flags, Address &fromAddress)
Read a single packet from the socket and retrieve the sender address.
virtual enum Socket::SocketType GetSocketType(void) const
Get socket type (NS3_SOCK_RAW)
void SetProtocol(uint16_t protocol)
Set protocol field.
virtual int Close(void)
Close a socket.
virtual int GetSockName(Address &address) const
Get socket address.
bool m_iphdrincl
Include IP Header information (a.k.a setsockopt (IP_HDRINCL))
uint16_t m_protocol
Protocol.
virtual bool GetAllowBroadcast() const
Query whether broadcast datagram transmissions are allowed.
virtual bool SetAllowBroadcast(bool allowBroadcast)
Configure whether broadcast datagram transmissions are allowed.
virtual int Listen(void)
Listen for incoming connections.
enum Socket::SocketErrno m_err
Last error number.
virtual uint32_t GetTxAvailable(void) const
Returns the number of bytes which can be sent in a single call to Send.
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.
virtual Ptr< Node > GetNode(void) const
Return the node this socket is associated with.
void SetNode(Ptr< Node > node)
Set the node associated with this socket.
virtual int Bind6()
Allocate a local IPv6 endpoint for this socket.
virtual enum Socket::SocketErrno GetErrno() const
Get last error number.
bool m_shutdownSend
Flag to shutdown send capability.
virtual int Send(Ptr< Packet > p, uint32_t flags)
Send data (or dummy data) to the remote host.
A low-level Socket API based loosely on the BSD Socket API.
Definition: socket.h:67
SocketType
Enumeration of the possible socket types.
Definition: socket.h:104
SocketErrno
Enumeration of the possible errors returned by a socket.
Definition: socket.h:82
Ptr< Packet > Recv(void)
Read a single packet from the socket.
Definition: socket.cc:175
a unique identifier for an interface.
Definition: type-id.h:59
address
Definition: first.py:44
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.