ns-3
ns3::Ipv6RawSocketImpl Class Reference

IPv6 raw socket. More...

#include <ipv6-raw-socket-impl.h>

Inheritance diagram for ns3::Ipv6RawSocketImpl:
Collaboration diagram for ns3::Ipv6RawSocketImpl:

List of all members.

Classes

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

Public Member Functions

 Ipv6RawSocketImpl ()
 Constructor.
virtual ~Ipv6RawSocketImpl ()
 Destructor.
void SetNode (Ptr< Node > node)
 Set the node.
virtual enum Socket::SocketErrno GetErrno () const
 Get last error number.
virtual enum Socket::SocketType GetSocketType () const
 Get socket type (NS3_SOCK_RAW)
virtual Ptr< NodeGetNode () const
 Get node.
virtual int Bind (const Address &address)
 Bind the socket to address.
virtual int Bind ()
 Bind socket.
virtual int Bind6 ()
 Allocate a local IPv6 endpoint for this socket.
virtual int GetSockName (Address &address) const
 Get socket address.
virtual int Close ()
 Close the socket.
virtual int ShutdownSend ()
 Shutdown send capability.
virtual int ShutdownRecv ()
 Shutdown receive capability.
virtual int Connect (const Address &address)
 Connect to address.
virtual int Listen ()
 Listen.
virtual uint32_t GetTxAvailable () const
 Get TX size available.
virtual uint32_t GetRxAvailable () const
 Get RX size available.
virtual int Send (Ptr< Packet > p, uint32_t flags)
 Send a packet.
virtual int SendTo (Ptr< Packet > p, uint32_t flags, const Address &toAddress)
 Send a packet.
virtual Ptr< PacketRecv (uint32_t maxSize, uint32_t flags)
 Receive packet.
virtual Ptr< PacketRecvFrom (uint32_t maxSize, uint32_t flags, Address &fromAddress)
 Receive packet.
void SetProtocol (uint16_t protocol)
 Set protocol field.
bool ForwardUp (Ptr< const Packet > p, Ipv6Header hdr, Ptr< NetDevice > device)
 Forward up to receive method.
virtual bool SetAllowBroadcast (bool allowBroadcast)
 Configure whether broadcast datagram transmissions are allowed.
virtual bool GetAllowBroadcast () const
 Query whether broadcast datagram transmissions are allowed.
void Icmpv6FilterSetPassAll ()
 Clean the ICMPv6 filter structure.
void Icmpv6FilterSetBlockAll ()
 Set the filter to block all the ICMPv6 types.
void Icmpv6FilterSetPass (uint8_t type)
 Set the filter to pass one ICMPv6 type.
void Icmpv6FilterSetBlock (uint8_t type)
 Set the filter to block one ICMPv6 type.
bool Icmpv6FilterWillPass (uint8_t type)
 Ask the filter about the status of one ICMPv6 type.
bool Icmpv6FilterWillBlock (uint8_t type)
 Ask the filter about the status of one ICMPv6 type.
- Public Member Functions inherited from ns3::Socket
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.
void SetCloseCallbacks (Callback< void, Ptr< Socket > > normalClose, Callback< void, Ptr< Socket > > errorClose)
 Detect socket recv() events such as graceful shutdown or error.
void SetAcceptCallback (Callback< bool, Ptr< Socket >, const Address & > connectionRequest, Callback< void, Ptr< Socket >, const Address & > newConnectionCreated)
 Accept connection requests from remote hosts.
void SetDataSentCallback (Callback< void, Ptr< Socket >, uint32_t > dataSent)
 Notify application when a packet has been sent from transport protocol (non-standard socket call)
void SetSendCallback (Callback< void, Ptr< Socket >, uint32_t > sendCb)
 Notify application when space in transmit buffer is added.
void SetRecvCallback (Callback< void, Ptr< Socket > >)
 Notify application when new data is available to be read.
int Send (Ptr< Packet > p)
 Send data (or dummy data) to the remote host.
int Send (const uint8_t *buf, uint32_t size, uint32_t flags)
 Send data (or dummy data) to the remote host.
int SendTo (const uint8_t *buf, uint32_t size, uint32_t flags, const Address &address)
 Send data to a specified peer.
Ptr< PacketRecv (void)
 Read a single packet from the socket.
int Recv (uint8_t *buf, uint32_t size, uint32_t flags)
 Recv data (or dummy data) from the remote host.
Ptr< PacketRecvFrom (Address &fromAddress)
 Read a single packet from the socket and retrieve the sender address.
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.
virtual void BindToNetDevice (Ptr< NetDevice > netdevice)
 Bind a socket to specific device.
Ptr< NetDeviceGetBoundNetDevice ()
 Returns socket's bound netdevice, if any.
void SetRecvPktInfo (bool flag)
 Enable/Disable receive packet information to socket.
bool IsRecvPktInfo () const
 Get status indicating whether enable/disable packet information to socket.
- Public Member Functions inherited from ns3::Object
virtual TypeId GetInstanceTypeId (void) const
template<typename T >
Ptr< T > GetObject (void) const
template<typename T >
Ptr< T > GetObject (TypeId tid) const
void Dispose (void)
void AggregateObject (Ptr< Object > other)
AggregateIterator GetAggregateIterator (void) const
void Start (void)
- Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
 SimpleRefCount (const SimpleRefCount &o)
SimpleRefCountoperator= (const SimpleRefCount &o)
void Ref (void) const
void Unref (void) const
uint32_t GetReferenceCount (void) const
- Public Member Functions inherited from ns3::ObjectBase
void SetAttribute (std::string name, const AttributeValue &value)
bool SetAttributeFailSafe (std::string name, const AttributeValue &value)
void GetAttribute (std::string name, AttributeValue &value) const
bool GetAttributeFailSafe (std::string name, AttributeValue &attribute) const
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.
- Static Public Member Functions inherited from ns3::Socket
static Ptr< SocketCreateSocket (Ptr< Node > node, TypeId tid)

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
void NotifyConnectionSucceeded (void)
void NotifyConnectionFailed (void)
void NotifyNormalClose (void)
void NotifyErrorClose (void)
bool NotifyConnectionRequest (const Address &from)
void NotifyNewConnectionCreated (Ptr< Socket > socket, const Address &from)
void NotifyDataSent (uint32_t size)
void NotifySend (uint32_t spaceAvailable)
void NotifyDataRecv (void)
- Protected Member Functions inherited from ns3::Object
virtual void NotifyNewAggregate (void)
virtual void DoStart (void)
 Object (const Object &o)
- Protected Attributes inherited from ns3::Socket
Ptr< NetDevicem_boundnetdevice
bool m_recvPktInfo

Detailed Description

IPv6 raw socket.

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));
}

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.

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

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

Bind socket.

Returns:
0 if success, -1 otherwise

Implements ns3::Socket.

References ns3::Ipv6Address::GetAny(), 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.

References Bind().

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

Close the socket.

Returns:
0 if success, -1 otherwise

Implements ns3::Socket.

References ns3::Object::GetObject(), 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.

References ns3::Inet6SocketAddress::ConvertFrom(), ns3::Inet6SocketAddress::GetIpv6(), ns3::Inet6SocketAddress::IsMatchingType(), 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.

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

Get last error number.

Returns:
error number

Implements ns3::Socket.

References NS_LOG_FUNCTION_NOARGS.

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

Get node.

Returns:
node associated with this raw socket.

Implements ns3::Socket.

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

Get RX size available.

Returns:
RX size

Implements ns3::Socket.

References 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.

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.

References NS_LOG_FUNCTION_NOARGS.

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

Get TX size available.

Returns:
TX size

Implements ns3::Socket.

References NS_LOG_FUNCTION_NOARGS.

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

Get the type ID of this class.

This method returns the TypeId associated to ns3::Ipv6RawSocketImpl.

Returns:
type ID

Attributes defined for this type:

  • Protocol: Protocol number to match.

No TraceSources defined for this type.

Reimplemented from ns3::Socket.

References ns3::TypeId::SetParent().

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

Set the filter to block one ICMPv6 type.

Parameters:
theICMPv6 type to block
void ns3::Ipv6RawSocketImpl::Icmpv6FilterSetPass ( uint8_t  type)

Set the filter to pass one ICMPv6 type.

Parameters:
theICMPv6 type to pass
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

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
int ns3::Ipv6RawSocketImpl::Listen ( void  )
virtual

Listen.

Returns:
0 if success, -1 otherwise

Implements ns3::Socket.

References 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.

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.

References ns3::Packet::CreateFragment(), NS_LOG_FUNCTION, 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.

References 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.

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

Set the node.

Parameters:
nodenode to set

References NS_LOG_FUNCTION.

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.

References NS_LOG_FUNCTION_NOARGS.

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

Shutdown send capability.

Returns:
0 if success, -1 otherwise

Implements ns3::Socket.

References NS_LOG_FUNCTION_NOARGS.


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