ns-3
|
IPv6 raw socket. More...
#include <ipv6-raw-socket-impl.h>
Classes | |
struct | Data |
IPv6 raw data and additionnal information. | |
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< Node > | GetNode () const |
Get node. | |
virtual int | Bind (const Address &address) |
Bind the socket to address. | |
virtual int | Bind () |
Bind 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< Packet > | Recv (uint32_t maxSize, uint32_t flags) |
Receive packet. | |
virtual Ptr< Packet > | RecvFrom (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. | |
Static Public Member Functions | |
static TypeId | GetTypeId () |
Get the type ID of this class. |
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)); }
int ns3::Ipv6RawSocketImpl::Bind | ( | const Address & | address | ) | [virtual] |
Bind the socket to address.
address | bind to this address |
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.
Implements ns3::Socket.
References ns3::Ipv6Address::GetAny(), and NS_LOG_FUNCTION_NOARGS.
int ns3::Ipv6RawSocketImpl::Close | ( | void | ) | [virtual] |
Close the socket.
Implements ns3::Socket.
References ns3::Object::GetObject(), and NS_LOG_FUNCTION_NOARGS.
int ns3::Ipv6RawSocketImpl::Connect | ( | const Address & | address | ) | [virtual] |
Connect to address.
address | address |
Implements ns3::Socket.
References ns3::Inet6SocketAddress::ConvertFrom(), ns3::Inet6SocketAddress::GetIpv6(), ns3::Inet6SocketAddress::IsMatchingType(), and NS_LOG_FUNCTION.
bool ns3::Ipv6RawSocketImpl::ForwardUp | ( | Ptr< const Packet > | p, |
Ipv6Header | hdr, | ||
Ptr< NetDevice > | device | ||
) |
Forward up to receive method.
p | packet |
hdr | IPv6 header |
device | device |
References ns3::Packet::AddHeader(), ns3::Packet::AddPacketTag(), ns3::Packet::Copy(), ns3::Ipv6Address::GetAny(), ns3::Ipv6Header::GetDestinationAddress(), ns3::NetDevice::GetIfIndex(), ns3::Ipv6Header::GetNextHeader(), ns3::Ipv6Header::GetSourceAddress(), ns3::Icmpv6L4Protocol::GetStaticProtocolNumber(), ns3::Icmpv6Header::GetType(), NS_LOG_FUNCTION, ns3::Packet::PeekHeader(), and ns3::Packet::RemovePacketTag().
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.
Implements ns3::Socket.
enum Socket::SocketErrno ns3::Ipv6RawSocketImpl::GetErrno | ( | void | ) | const [virtual] |
Get last error number.
Implements ns3::Socket.
References NS_LOG_FUNCTION_NOARGS.
Ptr< Node > ns3::Ipv6RawSocketImpl::GetNode | ( | void | ) | const [virtual] |
uint32_t ns3::Ipv6RawSocketImpl::GetRxAvailable | ( | void | ) | const [virtual] |
enum Socket::SocketType ns3::Ipv6RawSocketImpl::GetSocketType | ( | void | ) | const [virtual] |
int ns3::Ipv6RawSocketImpl::GetSockName | ( | Address & | address | ) | const [virtual] |
Get socket address.
address | socket address if method success |
Implements ns3::Socket.
References NS_LOG_FUNCTION_NOARGS.
uint32_t ns3::Ipv6RawSocketImpl::GetTxAvailable | ( | void | ) | const [virtual] |
TypeId ns3::Ipv6RawSocketImpl::GetTypeId | ( | void | ) | [static] |
Get the type ID of this class.
This method returns the TypeId associated to ns3::Ipv6RawSocketImpl.
This object is accessible through the following paths with Config::Set and Config::Connect:
Attributes defined for this type:
No TraceSources defined for this type.
Reimplemented from ns3::Object.
References ns3::TypeId::SetParent().
int ns3::Ipv6RawSocketImpl::Listen | ( | void | ) | [virtual] |
Listen.
Implements ns3::Socket.
References NS_LOG_FUNCTION_NOARGS.
Ptr< Packet > ns3::Ipv6RawSocketImpl::Recv | ( | uint32_t | maxSize, |
uint32_t | flags | ||
) | [virtual] |
Receive packet.
maxSize | maximum size |
flags | additionnal flags |
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.
maxSize | maximum size |
flags | additionnal flags |
fromAddress | source address |
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.
p | packet to send |
flags | additionnal flags |
Implements ns3::Socket.
References NS_LOG_FUNCTION, and SendTo().
int ns3::Ipv6RawSocketImpl::SendTo | ( | Ptr< Packet > | p, |
uint32_t | flags, | ||
const Address & | toAddress | ||
) | [virtual] |
Send a packet.
p | packet to send |
flags | additionnal flags |
toAddress | destination address |
Implements ns3::Socket.
References ns3::Packet::AddHeader(), ns3::Icmpv6Header::CalculatePseudoHeaderChecksum(), ns3::Inet6SocketAddress::ConvertFrom(), ns3::Packet::CopyData(), ns3::Inet6SocketAddress::GetIpv6(), ns3::Object::GetObject(), ns3::Icmpv6Echo::GetSerializedSize(), ns3::Packet::GetSize(), ns3::Icmpv6L4Protocol::GetStaticProtocolNumber(), ns3::Ipv6Address::IsAny(), ns3::Inet6SocketAddress::IsMatchingType(), NS_ASSERT, NS_LOG_DEBUG, NS_LOG_FUNCTION, NS_LOG_LOGIC, ns3::Packet::RemoveHeader(), and ns3::Ipv6Header::SetDestinationAddress().
Referenced by Send().
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.
allowBroadcast | Whether broadcast is allowed |
Implements ns3::Socket.
void ns3::Ipv6RawSocketImpl::SetNode | ( | Ptr< Node > | node | ) |
void ns3::Ipv6RawSocketImpl::SetProtocol | ( | uint16_t | protocol | ) |
Set protocol field.
protocol | protocol to set |
int ns3::Ipv6RawSocketImpl::ShutdownRecv | ( | void | ) | [virtual] |
Shutdown receive capability.
Implements ns3::Socket.
References NS_LOG_FUNCTION_NOARGS.
int ns3::Ipv6RawSocketImpl::ShutdownSend | ( | void | ) | [virtual] |
Shutdown send capability.
Implements ns3::Socket.
References NS_LOG_FUNCTION_NOARGS.