A Discrete-Event Network Simulator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
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>
11 namespace ns3 {
13 class NetDevice;
14 class Node;
16 class Ipv4RawSocketImpl : public Socket
17 {
18 public:
19  static TypeId GetTypeId (void);
23  void SetNode (Ptr<Node> node);
25  virtual enum Socket::SocketErrno GetErrno (void) const;
26  virtual enum Socket::SocketType GetSocketType (void) const;
27  virtual Ptr<Node> GetNode (void) const;
28  virtual int Bind (const Address &address);
29  virtual int Bind ();
30  virtual int Bind6 ();
31  virtual int GetSockName (Address &address) const;
32  virtual int Close (void);
33  virtual int ShutdownSend (void);
34  virtual int ShutdownRecv (void);
35  virtual int Connect (const Address &address);
36  virtual int Listen (void);
37  virtual uint32_t GetTxAvailable (void) const;
38  virtual int Send (Ptr<Packet> p, uint32_t flags);
39  virtual int SendTo (Ptr<Packet> p, uint32_t flags,
40  const Address &toAddress);
41  virtual uint32_t GetRxAvailable (void) const;
42  virtual Ptr<Packet> Recv (uint32_t maxSize, uint32_t flags);
43  virtual Ptr<Packet> RecvFrom (uint32_t maxSize, uint32_t flags,
44  Address &fromAddress);
46  void SetProtocol (uint16_t protocol);
47  bool ForwardUp (Ptr<const Packet> p, Ipv4Header ipHeader, Ptr<Ipv4Interface> incomingInterface);
48  virtual bool SetAllowBroadcast (bool allowBroadcast);
49  virtual bool GetAllowBroadcast () const;
51 private:
52  virtual void DoDispose (void);
54  struct Data {
55  Ptr<Packet> packet;
56  Ipv4Address fromIp;
57  uint16_t fromProtocol;
58  };
60  enum Socket::SocketErrno m_err;
61  Ptr<Node> m_node;
62  Ipv4Address m_src;
63  Ipv4Address m_dst;
64  uint16_t m_protocol;
65  std::list<struct Data> m_recv;
66  bool m_shutdownSend;
67  bool m_shutdownRecv;
68  uint32_t m_icmpFilter;
69  bool m_iphdrincl;
70 };
72 } // namespace ns3
74 #endif /* IPV4_RAW_SOCKET_IMPL_H */
virtual int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress)
Send data to a specified peer.
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:174
virtual int Send(Ptr< Packet > p, uint32_t flags)
Send data (or dummy data) to the remote host.
virtual uint32_t GetRxAvailable(void) const
virtual void DoDispose(void)
a polymophic address class
Definition: address.h:86
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.A few things to keep in mind about this ty...
Definition: socket.h:66
virtual enum Socket::SocketErrno GetErrno(void) const
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.
virtual int ShutdownRecv(void)
virtual enum Socket::SocketType GetSocketType(void) const
virtual bool GetAllowBroadcast() const
Query whether broadcast datagram transmissions are allowed.
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:38
virtual uint32_t GetTxAvailable(void) const
Returns the number of bytes which can be sent in a single call to Send.
virtual int Listen(void)
Listen for incoming connections.
virtual Ptr< Node > GetNode(void) const
a unique identifier for an interface.
Definition: type-id.h:44
virtual int ShutdownSend(void)
virtual int GetSockName(Address &address) const