A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
26 class Ipv4RawSocketImpl : public Socket
27 {
28 public:
33  static TypeId GetTypeId (void);
34 
36 
41  void SetNode (Ptr<Node> node);
42 
43  virtual enum Socket::SocketErrno GetErrno () const;
44 
49  virtual enum Socket::SocketType GetSocketType (void) const;
50 
51  virtual Ptr<Node> GetNode (void) const;
52  virtual int Bind (const Address &address);
53  virtual int Bind ();
54  virtual int Bind6 ();
55  virtual int GetSockName (Address &address) const;
56  virtual int GetPeerName (Address &address) const;
57  virtual int Close (void);
58  virtual int ShutdownSend (void);
59  virtual int ShutdownRecv (void);
60  virtual int Connect (const Address &address);
61  virtual int Listen (void);
62  virtual uint32_t GetTxAvailable (void) const;
63  virtual int Send (Ptr<Packet> p, uint32_t flags);
64  virtual int SendTo (Ptr<Packet> p, uint32_t flags,
65  const Address &toAddress);
66  virtual uint32_t GetRxAvailable (void) const;
67  virtual Ptr<Packet> Recv (uint32_t maxSize, uint32_t flags);
68  virtual Ptr<Packet> RecvFrom (uint32_t maxSize, uint32_t flags,
69  Address &fromAddress);
70 
71 
76  void SetProtocol (uint16_t protocol);
77 
85  bool ForwardUp (Ptr<const Packet> p, Ipv4Header ipHeader, Ptr<Ipv4Interface> incomingInterface);
86  virtual bool SetAllowBroadcast (bool allowBroadcast);
87  virtual bool GetAllowBroadcast () const;
88 
89 private:
90  virtual void DoDispose (void);
91 
96  struct Data {
99  uint16_t fromProtocol;
100  };
101 
102  mutable enum Socket::SocketErrno m_err;
106  uint16_t m_protocol;
107  std::list<struct Data> m_recv;
110  uint32_t m_icmpFilter;
111  bool m_iphdrincl;
112 };
113 
114 } // namespace ns3
115 
116 #endif /* IPV4_RAW_SOCKET_IMPL_H */
Ipv4Address m_src
Source address.
virtual int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress)
Send data to a specified peer.
Ptr< Packet > packet
Packet data.
virtual bool SetAllowBroadcast(bool allowBroadcast)
Configure whether broadcast datagram transmissions are allowed.
Ptr< Packet > Recv(void)
Read a single packet from the socket.
Definition: socket.cc:175
virtual int Send(Ptr< Packet > p, uint32_t flags)
Send data (or dummy data) to the remote host.
static TypeId GetTypeId(void)
Get the type ID of this class.
Ipv4Address fromIp
Source address.
void SetNode(Ptr< Node > node)
Set the node associated with this socket.
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.
SocketErrno
Enumeration of the possible errors returned by a socket.
Definition: socket.h:82
a polymophic address class
Definition: address.h:90
virtual int Close(void)
Close a socket.
Packet header for IPv4.
Definition: ipv4-header.h:31
A low-level Socket API based loosely on the BSD Socket API.
Definition: socket.h:66
bool m_shutdownSend
Flag to shutdown send capability.
Ipv4Address m_dst
Destination address.
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 int Bind6()
Allocate a local IPv6 endpoint for this socket.
virtual int Bind()
Allocate a local IPv4 endpoint for this socket.
virtual int Connect(const Address &address)
Initiate a connection to a remote host.
std::list< struct Data > m_recv
Packet waiting to be processed.
virtual int ShutdownRecv(void)
virtual enum Socket::SocketType GetSocketType(void) const
Get socket type (NS3_SOCK_RAW)
virtual bool GetAllowBroadcast() const
Query whether broadcast datagram transmissions are allowed.
virtual int GetPeerName(Address &address) const
Get the peer address of a connected socket.
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:40
virtual uint32_t GetTxAvailable(void) const
Returns the number of bytes which can be sent in a single call to Send.
Introspection did not find any typical Config paths.
virtual int Listen(void)
Listen for incoming connections.
uint16_t m_protocol
Protocol.
IPv4 raw data and additional information.
bool ForwardUp(Ptr< const Packet > p, Ipv4Header ipHeader, Ptr< Ipv4Interface > incomingInterface)
Forward up to receive method.
virtual Ptr< Node > GetNode(void) const
Return the node this socket is associated with.
tuple address
Definition: first.py:37
uint32_t m_icmpFilter
ICMPv4 filter specification.
SocketType
Enumeration of the possible socket types.
Definition: socket.h:104
a unique identifier for an interface.
Definition: type-id.h:58
bool m_shutdownRecv
Flag to shutdown receive capability.
uint16_t fromProtocol
Protocol used.
void SetProtocol(uint16_t protocol)
Set protocol field.
virtual enum Socket::SocketErrno GetErrno() const
Get last error number.
bool m_iphdrincl
Include IP Header information (a.k.a setsockopt (IP_HDRINCL))
virtual int ShutdownSend(void)
enum Socket::SocketErrno m_err
Last error number.
virtual int GetSockName(Address &address) const
Get socket address.