A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ns3::Ipv6RawSocketImpl Class Reference

IPv6 raw socket. More...

#include <introspected-doxygen.h>

+ Inheritance diagram for ns3::Ipv6RawSocketImpl:

Classes

struct  Data
 IPv6 raw data and additional information. More...
 
struct  icmpv6Filter
 Struct to hold the ICMPv6 filter. More...
 

Public Member Functions

 Ipv6RawSocketImpl ()
 Constructor.
 
virtual ~Ipv6RawSocketImpl ()
 Destructor.
 
virtual int Bind (const Address &address)
 Bind the socket to address. More...
 
virtual int Bind ()
 Bind socket. More...
 
virtual int Bind6 ()
 Allocate a local IPv6 endpoint for this socket. More...
 
virtual int Close ()
 Close the socket. More...
 
virtual int Connect (const Address &address)
 Connect to address. More...
 
bool ForwardUp (Ptr< const Packet > p, Ipv6Header hdr, Ptr< NetDevice > device)
 Forward up to receive method. More...
 
virtual bool GetAllowBroadcast () const
 Query whether broadcast datagram transmissions are allowed. More...
 
virtual enum Socket::SocketErrno GetErrno () const
 Get last error number. More...
 
virtual Ptr< NodeGetNode () const
 Get node. More...
 
virtual uint32_t GetRxAvailable () const
 Get RX size available. More...
 
virtual enum Socket::SocketType GetSocketType () const
 Get socket type (NS3_SOCK_RAW) More...
 
virtual int GetSockName (Address &address) const
 Get socket address. More...
 
virtual uint32_t GetTxAvailable () const
 Get TX size available. More...
 
void Icmpv6FilterSetBlock (uint8_t type)
 Set the filter to block one ICMPv6 type. More...
 
void Icmpv6FilterSetBlockAll ()
 Set the filter to block all the ICMPv6 types.
 
void Icmpv6FilterSetPass (uint8_t type)
 Set the filter to pass one ICMPv6 type. More...
 
void Icmpv6FilterSetPassAll ()
 Clean the ICMPv6 filter structure.
 
bool Icmpv6FilterWillBlock (uint8_t type)
 Ask the filter about the status of one ICMPv6 type. More...
 
bool Icmpv6FilterWillPass (uint8_t type)
 Ask the filter about the status of one ICMPv6 type. More...
 
virtual int Listen ()
 Listen. More...
 
virtual Ptr< PacketRecv (uint32_t maxSize, uint32_t flags)
 Receive packet. More...
 
virtual Ptr< PacketRecvFrom (uint32_t maxSize, uint32_t flags, Address &fromAddress)
 Receive packet. More...
 
virtual int Send (Ptr< Packet > p, uint32_t flags)
 Send a packet. More...
 
virtual int SendTo (Ptr< Packet > p, uint32_t flags, const Address &toAddress)
 Send a packet. More...
 
virtual bool SetAllowBroadcast (bool allowBroadcast)
 Configure whether broadcast datagram transmissions are allowed. More...
 
void SetNode (Ptr< Node > node)
 Set the node. More...
 
void SetProtocol (uint16_t protocol)
 Set protocol field. More...
 
virtual int ShutdownRecv ()
 Shutdown receive capability. More...
 
virtual int ShutdownSend ()
 Shutdown send capability. More...
 
- Public Member Functions inherited from ns3::Socket
virtual void BindToNetDevice (Ptr< NetDevice > netdevice)
 Bind a socket to specific device. More...
 
Ptr< NetDeviceGetBoundNetDevice ()
 Returns socket's bound netdevice, if any. More...
 
uint8_t GetIpTos (void) const
 
virtual uint8_t GetIpTtl (void) const
 
virtual uint8_t GetIpv6HopLimit (void) const
 
uint8_t GetIpv6Tclass (void) const
 
bool IsIpRecvTos (void) const
 Ask if the socket is currently passing information about IP Type of Service up the stack. More...
 
bool IsIpRecvTtl (void) const
 Ask if the socket is currently passing information about IP_TTL up the stack. More...
 
bool IsIpv6RecvHopLimit (void) const
 Ask if the socket is currently passing information about IPv6 Hop Limit up the stack. More...
 
bool IsIpv6RecvTclass (void) const
 Ask if the socket is currently passing information about IPv6 Traffic Class up the stack. More...
 
bool IsRecvPktInfo () const
 Get status indicating whether enable/disable packet information to socket. More...
 
Ptr< PacketRecv (void)
 Read a single packet from the socket. More...
 
int Recv (uint8_t *buf, uint32_t size, uint32_t flags)
 Recv data (or dummy data) from the remote host. More...
 
Ptr< PacketRecvFrom (Address &fromAddress)
 Read a single packet from the socket and retrieve the sender address. More...
 
int RecvFrom (uint8_t *buf, uint32_t size, uint32_t flags, Address &fromAddress)
 Read a single packet from the socket and retrieve the sender address. More...
 
int Send (Ptr< Packet > p)
 Send data (or dummy data) to the remote host. More...
 
int Send (const uint8_t *buf, uint32_t size, uint32_t flags)
 Send data (or dummy data) to the remote host. More...
 
int SendTo (const uint8_t *buf, uint32_t size, uint32_t flags, const Address &address)
 Send data to a specified peer. More...
 
void SetAcceptCallback (Callback< bool, Ptr< Socket >, const Address & > connectionRequest, Callback< void, Ptr< Socket >, const Address & > newConnectionCreated)
 Accept connection requests from remote hosts. More...
 
void SetCloseCallbacks (Callback< void, Ptr< Socket > > normalClose, Callback< void, Ptr< Socket > > errorClose)
 Detect socket recv() events such as graceful shutdown or error. More...
 
void SetConnectCallback (Callback< void, Ptr< Socket > > connectionSucceeded, Callback< void, Ptr< Socket > > connectionFailed)
 Specify callbacks to allow the caller to determine if the connection succeeds of fails. More...
 
void SetDataSentCallback (Callback< void, Ptr< Socket >, uint32_t > dataSent)
 Notify application when a packet has been sent from transport protocol (non-standard socket call) More...
 
void SetIpRecvTos (bool ipv4RecvTos)
 Tells a socket to pass information about IP Type of Service up the stack. More...
 
void SetIpRecvTtl (bool ipv4RecvTtl)
 Tells a socket to pass information about IP_TTL up the stack. More...
 
void SetIpTos (uint8_t ipTos)
 
virtual void SetIpTtl (uint8_t ipTtl)
 
virtual void SetIpv6HopLimit (uint8_t ipHopLimit)
 
void SetIpv6RecvHopLimit (bool ipv6RecvHopLimit)
 Tells a socket to pass information about IPv6 Hop Limit up the stack. More...
 
void SetIpv6RecvTclass (bool ipv6RecvTclass)
 Tells a socket to pass information about IPv6 Traffic Class up the stack. More...
 
void SetIpv6Tclass (int ipTclass)
 
void SetRecvCallback (Callback< void, Ptr< Socket > >)
 Notify application when new data is available to be read. More...
 
void SetRecvPktInfo (bool flag)
 Enable/Disable receive packet information to socket. More...
 
void SetSendCallback (Callback< void, Ptr< Socket >, uint32_t > sendCb)
 Notify application when space in transmit buffer is added. More...
 
- Public Member Functions inherited from ns3::Object
void AggregateObject (Ptr< Object > other)
 
void Dispose (void)
 
AggregateIterator GetAggregateIterator (void) const
 
virtual TypeId GetInstanceTypeId (void) const
 
template<typename T >
Ptr< T > GetObject (void) const
 
template<typename T >
Ptr< T > GetObject (TypeId tid) const
 
void Initialize (void)
 
- Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
 SimpleRefCount (const SimpleRefCount &o)
 
uint32_t GetReferenceCount (void) const
 
SimpleRefCountoperator= (const SimpleRefCount &o)
 
void Ref (void) const
 
void Unref (void) const
 
- Public Member Functions inherited from ns3::ObjectBase
void GetAttribute (std::string name, AttributeValue &value) const
 
bool GetAttributeFailSafe (std::string name, AttributeValue &attribute) const
 
void SetAttribute (std::string name, const AttributeValue &value)
 
bool SetAttributeFailSafe (std::string name, const AttributeValue &value)
 
bool TraceConnect (std::string name, std::string context, const CallbackBase &cb)
 
bool TraceConnectWithoutContext (std::string name, const CallbackBase &cb)
 
bool TraceDisconnect (std::string name, std::string context, const CallbackBase &cb)
 
bool TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb)
 

Static Public Member Functions

static TypeId GetTypeId ()
 Get the type ID of this class. More...
 
- Static Public Member Functions inherited from ns3::Socket
static Ptr< SocketCreateSocket (Ptr< Node > node, TypeId tid)
 
static TypeId GetTypeId (void)
 
- Static Public Member Functions inherited from ns3::Object
static TypeId GetTypeId (void)
 
- Static Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
static void Cleanup (void)
 
- Static Public Member Functions inherited from ns3::ObjectBase
static TypeId GetTypeId (void)
 

Private Member Functions

virtual void DoDispose ()
 Dispose object.
 

Private Attributes

std::list< struct Datam_data
 Packet waiting to be processed.
 
Ipv6Address m_dst
 Destination address.
 
enum Socket::SocketErrno m_err
 Last error number.
 
icmpv6Filter m_icmpFilter
 ICMPv6 filter.
 
Ptr< Nodem_node
 Node.
 
uint16_t m_protocol
 Protocol.
 
bool m_shutdownRecv
 Flag to shutdown receive capability.
 
bool m_shutdownSend
 Flag to shutdown send capability.
 
Ipv6Address m_src
 Source address.
 

Additional Inherited Members

- Public Types inherited from ns3::Socket
enum  SocketErrno {
  ERROR_NOTERROR, ERROR_ISCONN, ERROR_NOTCONN, ERROR_MSGSIZE,
  ERROR_AGAIN, ERROR_SHUTDOWN, ERROR_OPNOTSUPP, ERROR_AFNOSUPPORT,
  ERROR_INVAL, ERROR_BADF, ERROR_NOROUTETOHOST, ERROR_NODEV,
  ERROR_ADDRNOTAVAIL, ERROR_ADDRINUSE, SOCKET_ERRNO_LAST
}
 
enum  SocketType { NS3_SOCK_STREAM, NS3_SOCK_SEQPACKET, NS3_SOCK_DGRAM, NS3_SOCK_RAW }
 
- Protected Member Functions inherited from ns3::Socket
bool IsManualIpTos (void) const
 
bool IsManualIpTtl (void) const
 
bool IsManualIpv6HopLimit (void) const
 
bool IsManualIpv6Tclass (void) const
 
void NotifyConnectionFailed (void)
 
bool NotifyConnectionRequest (const Address &from)
 
void NotifyConnectionSucceeded (void)
 
void NotifyDataRecv (void)
 
void NotifyDataSent (uint32_t size)
 
void NotifyErrorClose (void)
 
void NotifyNewConnectionCreated (Ptr< Socket > socket, const Address &from)
 
void NotifyNormalClose (void)
 
void NotifySend (uint32_t spaceAvailable)
 
- Protected Member Functions inherited from ns3::Object
 Object (const Object &o)
 
virtual void DoInitialize (void)
 
virtual void NotifyNewAggregate (void)
 
- Protected Member Functions inherited from ns3::ObjectBase
void ConstructSelf (const AttributeConstructionList &attributes)
 
virtual void NotifyConstructionCompleted (void)
 
- Protected Attributes inherited from ns3::Socket
Ptr< NetDevicem_boundnetdevice
 
bool m_recvPktInfo
 

Detailed Description

IPv6 raw socket.

Doxygen introspection did not find any typical Config paths.

Attributes

  • Protocol: Protocol number to match.

No TraceSources are defined for this type.

A RAW Socket typically is used to access specific IP layers not usually available through L4 sockets, e.g., ICMP. The implementer should take particular care to define the Ipv6RawSocketImpl Attributes, and in particular the Protocol attribute. Not setting it will result in a zero protocol at IP level (corresponding to the HopByHop IPv6 Extension header, i.e., Ipv6ExtensionHopByHopHeader) when sending data through the socket, which is probably not the intended behavior.

A correct example is (from src/applications/model/radvd.cc):

if (!m_socket)
{
TypeId tid = TypeId::LookupByName ("ns3::Ipv6RawSocketFactory");
m_socket = Socket::CreateSocket (GetNode (), tid);
NS_ASSERT (m_socket);
m_socket->SetAttribute ("Protocol", UintegerValue(Ipv6Header::IPV6_ICMPV6));
m_socket->SetRecvCallback (MakeCallback (&Radvd::HandleRead, this));
}

Definition at line 64 of file ipv6-raw-socket-impl.h.

Member Function Documentation

int ns3::Ipv6RawSocketImpl::Bind ( const Address address)
virtual

Bind the socket to address.

Parameters
addressbind to this address
Returns
0 if success, -1 otherwise

Implements ns3::Socket.

Definition at line 104 of file ipv6-raw-socket-impl.cc.

References ns3::Inet6SocketAddress::ConvertFrom(), ns3::Inet6SocketAddress::GetIpv6(), ns3::Inet6SocketAddress::IsMatchingType(), m_err, m_src, and NS_LOG_FUNCTION.

int ns3::Ipv6RawSocketImpl::Bind ( void  )
virtual

Bind socket.

Returns
0 if success, -1 otherwise

Implements ns3::Socket.

Definition at line 118 of file ipv6-raw-socket-impl.cc.

References ns3::Ipv6Address::GetAny(), m_src, and NS_LOG_FUNCTION_NOARGS.

Referenced by Bind6().

int ns3::Ipv6RawSocketImpl::Bind6 ( )
virtual

Allocate a local IPv6 endpoint for this socket.

Returns
0 on success, -1 on failure.

Implements ns3::Socket.

Definition at line 125 of file ipv6-raw-socket-impl.cc.

References Bind().

int ns3::Ipv6RawSocketImpl::Close ( void  )
virtual

Close the socket.

Returns
0 if success, -1 otherwise

Implements ns3::Socket.

Definition at line 137 of file ipv6-raw-socket-impl.cc.

References ns3::Object::GetObject(), m_node, and NS_LOG_FUNCTION_NOARGS.

int ns3::Ipv6RawSocketImpl::Connect ( const Address address)
virtual

Connect to address.

Parameters
addressaddress
Returns
0 if success, -1 otherwise

Implements ns3::Socket.

Definition at line 163 of file ipv6-raw-socket-impl.cc.

References ns3::Inet6SocketAddress::ConvertFrom(), ns3::Inet6SocketAddress::GetIpv6(), ns3::Inet6SocketAddress::IsMatchingType(), m_dst, m_err, and NS_LOG_FUNCTION.

bool ns3::Ipv6RawSocketImpl::GetAllowBroadcast ( ) const
virtual

Query whether broadcast datagram transmissions are allowed.

This method corresponds to using getsockopt() SO_BROADCAST of real network or BSD sockets.

Returns
true if broadcast is allowed, false otherwise

Implements ns3::Socket.

Definition at line 382 of file ipv6-raw-socket-impl.cc.

enum Socket::SocketErrno ns3::Ipv6RawSocketImpl::GetErrno ( void  ) const
virtual

Get last error number.

Returns
error number

Implements ns3::Socket.

Definition at line 93 of file ipv6-raw-socket-impl.cc.

References m_err, and NS_LOG_FUNCTION_NOARGS.

Ptr< Node > ns3::Ipv6RawSocketImpl::GetNode ( void  ) const
virtual

Get node.

Returns
node associated with this raw socket.

Implements ns3::Socket.

Definition at line 88 of file ipv6-raw-socket-impl.cc.

References m_node.

uint32_t ns3::Ipv6RawSocketImpl::GetRxAvailable ( void  ) const
virtual

Get RX size available.

Returns
RX size

Implements ns3::Socket.

Definition at line 299 of file ipv6-raw-socket-impl.cc.

References m_data, and NS_LOG_FUNCTION_NOARGS.

enum Socket::SocketType ns3::Ipv6RawSocketImpl::GetSocketType ( void  ) const
virtual

Get socket type (NS3_SOCK_RAW)

Returns
socket type

Implements ns3::Socket.

Definition at line 99 of file ipv6-raw-socket-impl.cc.

int ns3::Ipv6RawSocketImpl::GetSockName ( Address address) const
virtual

Get socket address.

Parameters
addresssocket address if method success
Returns
0 if success, -1 otherwise

Implements ns3::Socket.

Definition at line 130 of file ipv6-raw-socket-impl.cc.

References m_src, and NS_LOG_FUNCTION_NOARGS.

uint32_t ns3::Ipv6RawSocketImpl::GetTxAvailable ( void  ) const
virtual

Get TX size available.

Returns
TX size

Implements ns3::Socket.

Definition at line 293 of file ipv6-raw-socket-impl.cc.

References NS_LOG_FUNCTION_NOARGS.

TypeId ns3::Ipv6RawSocketImpl::GetTypeId ( void  )
static

Get the type ID of this class.

Returns
type ID

Definition at line 46 of file ipv6-raw-socket-impl.cc.

References m_protocol, and ns3::TypeId::SetParent().

void ns3::Ipv6RawSocketImpl::Icmpv6FilterSetBlock ( uint8_t  type)

Set the filter to block one ICMPv6 type.

Parameters
theICMPv6 type to block

Definition at line 406 of file ipv6-raw-socket-impl.cc.

References m_icmpFilter.

void ns3::Ipv6RawSocketImpl::Icmpv6FilterSetPass ( uint8_t  type)

Set the filter to pass one ICMPv6 type.

Parameters
theICMPv6 type to pass

Definition at line 400 of file ipv6-raw-socket-impl.cc.

References m_icmpFilter.

bool ns3::Ipv6RawSocketImpl::Icmpv6FilterWillBlock ( uint8_t  type)

Ask the filter about the status of one ICMPv6 type.

Parameters
theICMPv6 type
Returns
true if the ICMP type is being blocked

Definition at line 418 of file ipv6-raw-socket-impl.cc.

References m_icmpFilter.

Referenced by ForwardUp().

bool ns3::Ipv6RawSocketImpl::Icmpv6FilterWillPass ( uint8_t  type)

Ask the filter about the status of one ICMPv6 type.

Parameters
theICMPv6 type
Returns
true if the ICMP type is passing through

Definition at line 412 of file ipv6-raw-socket-impl.cc.

References m_icmpFilter.

int ns3::Ipv6RawSocketImpl::Listen ( void  )
virtual

Listen.

Returns
0 if success, -1 otherwise

Implements ns3::Socket.

Definition at line 178 of file ipv6-raw-socket-impl.cc.

References m_err, and NS_LOG_FUNCTION_NOARGS.

Ptr< Packet > ns3::Ipv6RawSocketImpl::Recv ( uint32_t  maxSize,
uint32_t  flags 
)
virtual

Receive packet.

Parameters
maxSizemaximum size
flagsadditionnal flags
Returns
packet received

Implements ns3::Socket.

Definition at line 259 of file ipv6-raw-socket-impl.cc.

References NS_LOG_FUNCTION, and RecvFrom().

Ptr< Packet > ns3::Ipv6RawSocketImpl::RecvFrom ( uint32_t  maxSize,
uint32_t  flags,
Address fromAddress 
)
virtual

Receive packet.

Parameters
maxSizemaximum size
flagsadditionnal flags
fromAddresssource address
Returns
packet received

Implements ns3::Socket.

Definition at line 266 of file ipv6-raw-socket-impl.cc.

References ns3::Packet::CreateFragment(), ns3::Ipv6RawSocketImpl::Data::fromIp, ns3::Ipv6RawSocketImpl::Data::fromProtocol, ns3::Packet::GetSize(), m_data, NS_LOG_FUNCTION, ns3::Ipv6RawSocketImpl::Data::packet, and ns3::Packet::RemoveAtStart().

Referenced by Recv().

int ns3::Ipv6RawSocketImpl::Send ( Ptr< Packet p,
uint32_t  flags 
)
virtual

Send a packet.

Parameters
ppacket to send
flagsadditionnal flags
Returns
0 if success, -1 otherwise

Implements ns3::Socket.

Definition at line 185 of file ipv6-raw-socket-impl.cc.

References m_dst, m_protocol, NS_LOG_FUNCTION, and SendTo().

bool ns3::Ipv6RawSocketImpl::SetAllowBroadcast ( bool  allowBroadcast)
virtual

Configure whether broadcast datagram transmissions are allowed.

This method corresponds to using setsockopt() SO_BROADCAST of real network or BSD sockets. If set on a socket, this option will enable or disable packets to be transmitted to broadcast destination addresses.

Parameters
allowBroadcastWhether broadcast is allowed
Returns
true if operation succeeds

Implements ns3::Socket.

Definition at line 372 of file ipv6-raw-socket-impl.cc.

void ns3::Ipv6RawSocketImpl::SetNode ( Ptr< Node node)

Set the node.

Parameters
nodenode to set

Definition at line 82 of file ipv6-raw-socket-impl.cc.

References m_node, and NS_LOG_FUNCTION.

Referenced by ns3::Ipv6L3Protocol::CreateRawSocket().

void ns3::Ipv6RawSocketImpl::SetProtocol ( uint16_t  protocol)

Set protocol field.

Parameters
protocolprotocol to set
int ns3::Ipv6RawSocketImpl::ShutdownRecv ( void  )
virtual

Shutdown receive capability.

Returns
0 if success, -1 otherwise

Implements ns3::Socket.

Definition at line 156 of file ipv6-raw-socket-impl.cc.

References m_shutdownRecv, and NS_LOG_FUNCTION_NOARGS.

int ns3::Ipv6RawSocketImpl::ShutdownSend ( void  )
virtual

Shutdown send capability.

Returns
0 if success, -1 otherwise

Implements ns3::Socket.

Definition at line 149 of file ipv6-raw-socket-impl.cc.

References m_shutdownSend, and NS_LOG_FUNCTION_NOARGS.


The documentation for this class was generated from the following files: