2 #include <netinet/in.h>
3 #include <sys/socket.h>
8 #include "ns3/ipv4-packet-info-tag.h"
9 #include "ns3/inet-socket-address.h"
11 #include "ns3/packet.h"
12 #include "ns3/uinteger.h"
13 #include "ns3/boolean.h"
27 .AddAttribute (
"Protocol",
"Protocol number to match.",
30 MakeUintegerChecker<uint16_t> ())
31 .AddAttribute (
"IcmpFilter",
32 "Any icmp header whose type field matches a bit in this filter is dropped. Type must be less than 32.",
35 MakeUintegerChecker<uint32_t> ())
44 .AddAttribute (
"IpHeaderInclude",
45 "Include IP Header information (a.k.a setsockopt (IP_HDRINCL)).",
48 MakeBooleanChecker ())
140 ipv4->DeleteRawSocket (
this);
189 return SendTo (p, flags, to);
209 if (ipv4->GetRoutingProtocol ())
228 int32_t index = ipv4->GetInterfaceForAddress (src);
230 oif = ipv4->GetNetDevice (index);
231 NS_LOG_LOGIC (
"Set index " << oif <<
"from source " << src);
235 route = ipv4->GetRoutingProtocol ()->RouteOutput (p, header, oif, errno_);
245 ipv4->SendWithHeader (p, header, route);
264 for (std::list<Data>::const_iterator i =
m_recv.begin (); i !=
m_recv.end (); ++i)
266 rx += (i->packet)->GetSize ();
275 return RecvFrom (maxSize, flags, tmp);
293 if (!(flags & MSG_PEEK))
322 if (boundNetDevice != incomingInterface->
GetDevice())
346 uint8_t type = icmpHeader.
GetType ();
uint32_t RemoveHeader(Header &header)
virtual int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress)
Send data to a specified peer.
Ipv4Address GetIpv4(void) const
static Ipv4Address GetAny(void)
#define NS_LOG_FUNCTION(parameters)
void NotifyDataRecv(void)
virtual bool SetAllowBroadcast(bool allowBroadcast)
Configure whether broadcast datagram transmissions are allowed.
Ptr< Packet > Recv(void)
Read a single packet from the socket.
void AddPacketTag(const Tag &tag) const
virtual int Send(Ptr< Packet > p, uint32_t flags)
Send data (or dummy data) to the remote host.
static TypeId GetTypeId(void)
#define NS_ASSERT(condition)
#define NS_LOG_COMPONENT_DEFINE(name)
void SetNode(Ptr< Node > node)
uint32_t GetSize(void) const
virtual uint32_t GetRxAvailable(void) const
virtual void DoDispose(void)
bool IsRecvPktInfo() const
Get status indicating whether enable/disable packet information to socket.
a polymophic address class
virtual int Close(void)
Close a socket.
Ptr< NetDevice > GetBoundNetDevice()
Returns socket's bound netdevice, if any.
Ptr< Packet > CreateFragment(uint32_t start, uint32_t length) const
A low-level Socket API based loosely on the BSD Socket API.A few things to keep in mind about this ty...
void RemoveAtStart(uint32_t size)
Hold an unsigned integer type.
virtual enum Socket::SocketErrno GetErrno(void) const
NS_OBJECT_ENSURE_REGISTERED(AntennaModel)
void NotifyDataSent(uint32_t size)
Ipv4Address GetSource(void) const
#define NS_LOG_LOGIC(msg)
Access to the Ipv4 forwarding table, interfaces, and configuration.
Ptr< Packet > Copy(void) const
uint32_t PeekHeader(Header &header) const
static InetSocketAddress ConvertFrom(const Address &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
virtual int ShutdownRecv(void)
This class implements Linux struct pktinfo in order to deliver ancillary information to the socket in...
virtual enum Socket::SocketType GetSocketType(void) const
virtual bool GetAllowBroadcast() const
Query whether broadcast datagram transmissions are allowed.
virtual void DoDispose(void)
Ipv4 addresses are stored in host order in this class.
Ptr< NetDevice > m_boundnetdevice
virtual uint32_t GetTxAvailable(void) const
Returns the number of bytes which can be sent in a single call to Send.
Ptr< NetDevice > GetDevice(void) const
virtual int Listen(void)
Listen for incoming connections.
bool RemovePacketTag(Tag &tag)
#define NS_LOG_DEBUG(msg)
bool ForwardUp(Ptr< const Packet > p, Ipv4Header ipHeader, Ptr< Ipv4Interface > incomingInterface)
virtual Ptr< Node > GetNode(void) const
Ptr< T > GetObject(void) const
a unique identifier for an interface.
void NotifySend(uint32_t spaceAvailable)
TypeId SetParent(TypeId tid)
void SetProtocol(uint16_t protocol)
static bool IsMatchingType(const Address &address)
void AddHeader(const Header &header)
virtual int ShutdownSend(void)
enum Socket::SocketErrno m_err
virtual int GetSockName(Address &address) const
void SetRecvIf(uint32_t ifindex)