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 */
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
ns3::Ipv4Header
Packet header for IPv4.
Definition: ipv4-header.h:34
ns3::Ipv4RawSocketImpl::Connect
virtual int Connect(const Address &address)
Initiate a connection to a remote host.
Definition: ipv4-raw-socket-impl.cc:175
ns3::Ipv4RawSocketImpl::ForwardUp
bool ForwardUp(Ptr< const Packet > p, Ipv4Header ipHeader, Ptr< Ipv4Interface > incomingInterface)
Forward up to receive method.
Definition: ipv4-raw-socket-impl.cc:415
ns3::Ipv4RawSocketImpl::Data
IPv4 raw data and additional information.
Definition: ipv4-raw-socket-impl.h:97
ns3::Socket::SocketErrno
SocketErrno
Enumeration of the possible errors returned by a socket.
Definition: socket.h:82
ns3::Ipv4RawSocketImpl::GetErrno
virtual enum Socket::SocketErrno GetErrno() const
Get last error number.
Definition: ipv4-raw-socket-impl.cc:82
ns3::Ipv4RawSocketImpl::Close
virtual int Close(void)
Close a socket.
Definition: ipv4-raw-socket-impl.cc:150
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::Socket::Recv
Ptr< Packet > Recv(void)
Read a single packet from the socket.
Definition: socket.cc:175
ns3::Ipv4RawSocketImpl::m_recv
std::list< struct Data > m_recv
Packet waiting to be processed.
Definition: ipv4-raw-socket-impl.h:108
ns3::Ipv4RawSocketImpl::RecvFrom
virtual Ptr< Packet > RecvFrom(uint32_t maxSize, uint32_t flags, Address &fromAddress)
Read a single packet from the socket and retrieve the sender address.
Definition: ipv4-raw-socket-impl.cc:382
ns3::Ipv4RawSocketImpl::GetPeerName
virtual int GetPeerName(Address &address) const
Get the peer address of a connected socket.
Definition: ipv4-raw-socket-impl.cc:135
ns3::Ipv4RawSocketImpl::SetProtocol
void SetProtocol(uint16_t protocol)
Set protocol field.
Definition: ipv4-raw-socket-impl.cc:408
ns3::Ipv4RawSocketImpl::m_err
enum Socket::SocketErrno m_err
Last error number.
Definition: ipv4-raw-socket-impl.h:103
ns3::Ipv4RawSocketImpl::m_node
Ptr< Node > m_node
Node.
Definition: ipv4-raw-socket-impl.h:104
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
ns3::Ipv4RawSocketImpl::Data::fromProtocol
uint16_t fromProtocol
Protocol used.
Definition: ipv4-raw-socket-impl.h:100
ns3::Ipv4RawSocketImpl::SendTo
virtual int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress)
Send data to a specified peer.
Definition: ipv4-raw-socket-impl.cc:211
ns3::Ipv4RawSocketImpl::Bind
virtual int Bind()
Allocate a local IPv4 endpoint for this socket.
Definition: ipv4-raw-socket-impl.cc:115
ns3::Ipv4RawSocketImpl::m_protocol
uint16_t m_protocol
Protocol.
Definition: ipv4-raw-socket-impl.h:107
ns3::Ipv4RawSocketImpl::Data::fromIp
Ipv4Address fromIp
Source address.
Definition: ipv4-raw-socket-impl.h:99
ns3::Ipv4RawSocketImpl::Bind6
virtual int Bind6()
Allocate a local IPv6 endpoint for this socket.
Definition: ipv4-raw-socket-impl.cc:122
ns3::Ipv4RawSocketImpl::m_iphdrincl
bool m_iphdrincl
Include IP Header information (a.k.a setsockopt (IP_HDRINCL))
Definition: ipv4-raw-socket-impl.h:112
ns3::Ptr< Node >
ns3::Ipv4RawSocketImpl::Listen
virtual int Listen(void)
Listen for incoming connections.
Definition: ipv4-raw-socket-impl.cc:190
ns3::Ipv4RawSocketImpl::ShutdownSend
virtual int ShutdownSend(void)
Definition: ipv4-raw-socket-impl.cc:161
ns3::Socket
A low-level Socket API based loosely on the BSD Socket API.
Definition: socket.h:67
ns3::Ipv4RawSocketImpl::GetAllowBroadcast
virtual bool GetAllowBroadcast() const
Query whether broadcast datagram transmissions are allowed.
Definition: ipv4-raw-socket-impl.cc:500
ns3::Address
a polymophic address class
Definition: address.h:91
ns3::Ipv4RawSocketImpl::Ipv4RawSocketImpl
Ipv4RawSocketImpl()
Definition: ipv4-raw-socket-impl.cc:54
ns3::Ipv4RawSocketImpl::m_src
Ipv4Address m_src
Source address.
Definition: ipv4-raw-socket-impl.h:105
ns3::Socket::SocketType
SocketType
Enumeration of the possible socket types.
Definition: socket.h:104
ns3::Ipv4RawSocketImpl::m_icmpFilter
uint32_t m_icmpFilter
ICMPv4 filter specification.
Definition: ipv4-raw-socket-impl.h:111
ns3::Ipv4RawSocketImpl::m_shutdownRecv
bool m_shutdownRecv
Flag to shutdown receive capability.
Definition: ipv4-raw-socket-impl.h:110
ns3::Ipv4RawSocketImpl::SetNode
void SetNode(Ptr< Node > node)
Set the node associated with this socket.
Definition: ipv4-raw-socket-impl.cc:67
first.address
address
Definition: first.py:44
ns3::Ipv4RawSocketImpl::DoDispose
virtual void DoDispose(void)
Destructor implementation.
Definition: ipv4-raw-socket-impl.cc:74
ns3::Ipv4RawSocketImpl::GetSockName
virtual int GetSockName(Address &address) const
Get socket address.
Definition: ipv4-raw-socket-impl.cc:128
ns3::Ipv4RawSocketImpl::Data::packet
Ptr< Packet > packet
Packet data.
Definition: ipv4-raw-socket-impl.h:98
ns3::Ipv4RawSocketImpl::GetTypeId
static TypeId GetTypeId(void)
Get the type ID of this class.
Definition: ipv4-raw-socket-impl.cc:23
ns3::Ipv4RawSocketImpl::SetAllowBroadcast
virtual bool SetAllowBroadcast(bool allowBroadcast)
Configure whether broadcast datagram transmissions are allowed.
Definition: ipv4-raw-socket-impl.cc:489
ns3::Ipv4RawSocketImpl::Send
virtual int Send(Ptr< Packet > p, uint32_t flags)
Send data (or dummy data) to the remote host.
Definition: ipv4-raw-socket-impl.cc:203
ns3::Ipv4RawSocketImpl::GetTxAvailable
virtual uint32_t GetTxAvailable(void) const
Returns the number of bytes which can be sent in a single call to Send.
Definition: ipv4-raw-socket-impl.cc:197
ns3::Ipv4RawSocketImpl::GetRxAvailable
virtual uint32_t GetRxAvailable(void) const
Return number of bytes which can be returned from one or multiple calls to Recv.
Definition: ipv4-raw-socket-impl.cc:364
ns3::Ipv4RawSocketImpl::m_shutdownSend
bool m_shutdownSend
Flag to shutdown send capability.
Definition: ipv4-raw-socket-impl.h:109
ns3::Ipv4RawSocketImpl
IPv4 raw socket.
Definition: ipv4-raw-socket-impl.h:28
ns3::Ipv4RawSocketImpl::ShutdownRecv
virtual int ShutdownRecv(void)
Definition: ipv4-raw-socket-impl.cc:168
ns3::Ipv4RawSocketImpl::GetNode
virtual Ptr< Node > GetNode(void) const
Return the node this socket is associated with.
Definition: ipv4-raw-socket-impl.cc:96
ns3::Ipv4RawSocketImpl::GetSocketType
virtual enum Socket::SocketType GetSocketType(void) const
Get socket type (NS3_SOCK_RAW)
Definition: ipv4-raw-socket-impl.cc:89
ns3::Ipv4RawSocketImpl::m_dst
Ipv4Address m_dst
Destination address.
Definition: ipv4-raw-socket-impl.h:106