|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
21 #include <netinet/in.h>
22 #include <sys/socket.h>
23 #include <sys/types.h>
24 #include "ns3/inet6-socket-address.h"
26 #include "ns3/packet.h"
27 #include "ns3/uinteger.h"
29 #include "ns3/ipv6-route.h"
30 #include "ns3/ipv6-routing-protocol.h"
31 #include "ns3/ipv6-packet-info-tag.h"
49 .SetGroupName (
"Internet")
50 .AddAttribute (
"Protocol",
"Protocol number to match.",
53 MakeUintegerChecker<uint16_t> ())
161 ipv6->DeleteRawSocket (
this);
206 return SendTo (p, flags, to);
242 if (ipv6->GetRoutingProtocol ())
252 int32_t index = ipv6->GetInterfaceForAddress (
m_src);
254 oif = ipv6->GetNetDevice (index);
257 route = ipv6->GetRoutingProtocol ()->RouteOutput (p, hdr, oif, err);
281 ipv6->Send (p, route->GetSource (), dst,
m_protocol, route);
304 return RecvFrom (maxSize, flags, tmp);
320 if (
data.packet->GetSize () > maxSize)
323 if (!(flags & MSG_PEEK))
325 data.packet->RemoveAtStart (maxSize);
347 if (filterMode ==
INCLUDE && sourceAddresses.empty ())
353 NS_ASSERT_MSG (index >= 0,
"Interface without a valid index");
354 ipv6l3->RemoveMulticastAddress (
address, index);
358 ipv6l3->RemoveMulticastAddress (
address);
367 NS_ASSERT_MSG (index >= 0,
"Interface without a valid index");
368 ipv6l3->AddMulticastAddress (
address, index);
372 ipv6l3->AddMulticastAddress (
address);
389 for (std::list<Data>::const_iterator it =
m_data.begin (); it !=
m_data.end (); ++it)
409 if (boundNetDevice != device)
426 uint8_t type = icmpHeader.
GetType ();
a unique identifier for an interface.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
static bool IsMatchingType(const Address &addr)
If the address match.
void Icmpv6FilterSetBlock(uint8_t type)
Set the filter to block one ICMPv6 type.
bool m_shutdownRecv
Flag to shutdown receive capability.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
static uint16_t GetStaticProtocolNumber()
Get ICMPv6 protocol number.
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
virtual ~Ipv6RawSocketImpl()
virtual bool GetAllowBroadcast() const
Query whether broadcast datagram transmissions are allowed.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
void AddHeader(const Header &header)
Add header to this packet.
SocketErrno
Enumeration of the possible errors returned by a socket.
virtual uint32_t GetRxAvailable() const
Return number of bytes which can be returned from one or multiple calls to Recv.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void Icmpv6FilterSetPass(uint8_t type)
Set the filter to pass one ICMPv6 type.
virtual bool SetAllowBroadcast(bool allowBroadcast)
Configure whether broadcast datagram transmissions are allowed.
Ptr< Packet > Recv(void)
Read a single packet from the socket.
virtual int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress)
Send data to a specified peer.
IPv6 raw data and additional information.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
void SetAddress(Ipv6Address addr)
Set the tag's address.
IPv6 layer implementation.
uint32_t CopyData(uint8_t *buffer, uint32_t size) const
Copy the packet contents to a byte buffer.
void Icmpv6FilterSetPassAll()
Clean the ICMPv6 filter structure.
void SetHoplimit(uint8_t ttl)
Set the tag's Hop Limit.
Describes an IPv6 address.
bool IsIpv6RecvHopLimit(void) const
Ask if the socket is currently passing information about IPv6 Hop Limit up the stack.
virtual enum Socket::SocketErrno GetErrno() const
Get last error number.
virtual uint32_t GetTxAvailable() const
Returns the number of bytes which can be sent in a single call to Send.
virtual int GetSockName(Address &address) const
Get socket address.
virtual int GetPeerName(Address &address) const
Get the peer address of a connected socket.
uint32_t GetSize(Ptr< const Packet > packet, const WifiMacHeader *hdr, bool isAmpdu)
Return the total size of the packet after WifiMacHeader and FCS trailer have been added.
bool IsIpv6RecvTclass(void) const
Ask if the socket is currently passing information about IPv6 Traffic Class up the stack.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Ipv6MulticastFilterMode
Enumeration of the possible filter of a socket.
bool Icmpv6FilterWillBlock(uint8_t type)
Ask the filter about the status of one ICMPv6 type.
static Inet6SocketAddress ConvertFrom(const Address &addr)
Convert the address to a InetSocketAddress.
virtual uint8_t GetIpv6HopLimit(void) const
Query the value of IP Hop Limit field of this socket.
virtual int Close()
Close a socket.
bool Icmpv6FilterWillPass(uint8_t type)
Ask the filter about the status of one ICMPv6 type.
virtual int Connect(const Address &address)
Initiate a connection to a remote host.
virtual void DoDispose()
Dispose object.
enum Socket::SocketErrno m_err
Last error number.
This class implements a tag that carries socket ancillary data to the socket interface.
uint16_t m_protocol
Protocol.
A low-level Socket API based loosely on the BSD Socket API.
a polymophic address class
bool ForwardUp(Ptr< const Packet > p, Ipv6Header hdr, Ptr< NetDevice > device)
Forward up to receive method.
This class implements a tag that carries the socket-specific HOPLIMIT of a packet to the IPv6 layer.
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
SocketType
Enumeration of the possible socket types.
bool m_shutdownSend
Flag to shutdown send capability.
void SetRecvIf(uint32_t ifindex)
Set the tag's receiving interface.
Ptr< NetDevice > GetBoundNetDevice()
Returns socket's bound NetDevice, if any.
void SetNode(Ptr< Node > node)
Set the node associated with this socket.
Ipv6Address m_dst
Destination address.
bool IsManualIpv6HopLimit(void) const
Checks if the socket has a specific IPv6 Hop Limit set.
indicates whether the socket has IPV6_TCLASS set.
virtual int ShutdownRecv()
uint32_t icmpv6Filt[8]
ICMPv6 filter specification.
void Icmpv6FilterSetBlockAll()
Set the filter to block all the ICMPv6 types.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
virtual void Ipv6LeaveGroup(void)
Leaves IPv6 multicast group this socket is joined to.
std::list< Data > m_data
Packet waiting to be processed.
virtual int Send(Ptr< Packet > p, uint32_t flags)
Send data (or dummy data) to the remote host.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Ipv6Address GetIpv6(void) const
Get the IPv6 address.
void AddPacketTag(const Tag &tag) const
Add a packet tag.
Struct to hold the ICMPv6 filter.
bool IsManualIpv6Tclass(void) const
Checks if the socket has a specific IPv6 Tclass set.
void NotifyDataRecv(void)
Notify through the callback (if set) that some data have been received.
void SetTclass(uint8_t tclass)
Set the tag's Tclass.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
virtual void Ipv6JoinGroup(Ipv6Address address, Socket::Ipv6MulticastFilterMode filterMode, std::vector< Ipv6Address > sourceAddresses)
Joins a IPv6 multicast group.
virtual Ptr< Node > GetNode() const
Return the node this socket is associated with.
virtual int ShutdownSend()
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
static Ipv6Address GetAny()
Get the "any" (::) Ipv6Address.
uint32_t pktSize
packet size used for the simulation (in bytes)
Icmpv6Filter m_icmpFilter
ICMPv6 filter.
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
virtual void DoDispose(void)
Destructor implementation.
virtual int Bind6()
Allocate a local IPv6 endpoint for this socket.
virtual enum Socket::SocketType GetSocketType() const
Get socket type (NS3_SOCK_RAW)
static TypeId GetTypeId()
Get the type ID of this class.
Hold an unsigned integer type.
Ptr< NetDevice > m_boundnetdevice
the device this socket is bound to (might be null).
Ipv6Address m_src
Source address.
bool IsAny() const
If the IPv6 address is the "Any" address.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
void NotifySend(uint32_t spaceAvailable)
Notify through the callback (if set) that some data have been sent.
virtual int Bind()
Allocate a local IPv4 endpoint for this socket.
Ipv6Address m_ipv6MulticastGroupAddress
IPv6 multicast group address.
void NotifyDataSent(uint32_t size)
Notify through the callback (if set) that some data have been sent.
virtual uint32_t GetIfIndex(void) const =0
uint8_t GetIpv6Tclass(void) const
Query the value of IPv6 Traffic Class field of this socket.
void SetHopLimit(uint8_t hopLimit)
Set the tag's Hop Limit.
void SetTrafficClass(uint8_t tclass)
Set the tag's Traffic Class.
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 Listen()
Listen for incoming connections.
virtual uint32_t GetSerializedSize() const
Get the serialized size.
bool IsRecvPktInfo() const
Get status indicating whether enable/disable packet information to socket.