A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
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 "ns3/ipv4-header.h"
5#include "ns3/ipv4-interface.h"
6#include "ns3/ipv4-route.h"
7#include "ns3/socket.h"
8
9#include <list>
10
11namespace ns3
12{
13
14class NetDevice;
15class Node;
16
29{
30 public:
35 static TypeId GetTypeId();
36
38
43 void SetNode(Ptr<Node> node);
44
45 Socket::SocketErrno GetErrno() const override;
46
51 Socket::SocketType GetSocketType() const override;
52
53 Ptr<Node> GetNode() const override;
54 int Bind(const Address& address) override;
55 int Bind() override;
56 int Bind6() override;
57 int GetSockName(Address& address) const override;
58 int GetPeerName(Address& address) const override;
59 int Close() override;
60 int ShutdownSend() override;
61 int ShutdownRecv() override;
62 int Connect(const Address& address) override;
63 int Listen() override;
64 uint32_t GetTxAvailable() const override;
65 int Send(Ptr<Packet> p, uint32_t flags) override;
66 int SendTo(Ptr<Packet> p, uint32_t flags, const Address& toAddress) override;
67 uint32_t GetRxAvailable() const override;
68 Ptr<Packet> Recv(uint32_t maxSize, uint32_t flags) override;
69 Ptr<Packet> RecvFrom(uint32_t maxSize, uint32_t flags, Address& fromAddress) override;
70
75 void SetProtocol(uint16_t protocol);
76
84 bool ForwardUp(Ptr<const Packet> p, Ipv4Header ipHeader, Ptr<Ipv4Interface> incomingInterface);
85 bool SetAllowBroadcast(bool allowBroadcast) override;
86 bool GetAllowBroadcast() const override;
87
88 private:
89 void DoDispose() override;
90
95 struct Data
96 {
99 uint16_t fromProtocol;
100 };
101
106 uint16_t m_protocol;
107 std::list<Data> m_recv;
112};
113
114} // namespace ns3
115
116#endif /* IPV4_RAW_SOCKET_IMPL_H */
a polymophic address class
Definition: address.h:100
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.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
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:172
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
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.