ns-3
|
IPv6 raw socket. More...
#include <ipv6-raw-socket-impl.h>
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< Node > | GetNode () 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< 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. | |
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. | |
![]() | |
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< Packet > | Recv (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< Packet > | RecvFrom (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< NetDevice > | GetBoundNetDevice () |
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. | |
![]() | |
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) |
![]() | |
SimpleRefCount (const SimpleRefCount &o) | |
SimpleRefCount & | operator= (const SimpleRefCount &o) |
void | Ref (void) const |
void | Unref (void) const |
uint32_t | GetReferenceCount (void) const |
![]() | |
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 Ptr< Socket > | CreateSocket (Ptr< Node > node, TypeId tid) |
Additional Inherited Members | |
![]() | |
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 } |
![]() | |
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) |
![]() | |
virtual void | NotifyNewAggregate (void) |
virtual void | DoStart (void) |
Object (const Object &o) | |
![]() | |
Ptr< NetDevice > | m_boundnetdevice |
bool | m_recvPktInfo |
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):
|
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.
|
virtual |
Bind socket.
Implements ns3::Socket.
References ns3::Ipv6Address::GetAny(), and NS_LOG_FUNCTION_NOARGS.
Referenced by Bind6().
|
virtual |
Allocate a local IPv6 endpoint for this socket.
Implements ns3::Socket.
References Bind().
|
virtual |
Close the socket.
Implements ns3::Socket.
References ns3::Object::GetObject(), and NS_LOG_FUNCTION_NOARGS.
|
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(), Icmpv6FilterWillBlock(), ns3::Socket::IsRecvPktInfo(), NS_LOG_FUNCTION, ns3::Packet::PeekHeader(), and ns3::Packet::RemovePacketTag().
|
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.
|
virtual |
Get last error number.
Implements ns3::Socket.
References NS_LOG_FUNCTION_NOARGS.
|
virtual |
|
virtual |
|
virtual |
Get socket address.
address | socket address if method success |
Implements ns3::Socket.
References NS_LOG_FUNCTION_NOARGS.
|
virtual |
|
static |
Get the type ID of this class.
This method returns the TypeId associated to ns3::Ipv6RawSocketImpl.
Attributes defined for this type:
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.
the | ICMPv6 type to block |
void ns3::Ipv6RawSocketImpl::Icmpv6FilterSetPass | ( | uint8_t | type | ) |
Set the filter to pass one ICMPv6 type.
the | ICMPv6 type to pass |
bool ns3::Ipv6RawSocketImpl::Icmpv6FilterWillBlock | ( | uint8_t | type | ) |
Ask the filter about the status of one ICMPv6 type.
the | ICMPv6 type |
Referenced by ForwardUp().
bool ns3::Ipv6RawSocketImpl::Icmpv6FilterWillPass | ( | uint8_t | type | ) |
Ask the filter about the status of one ICMPv6 type.
the | ICMPv6 type |
|
virtual |
Listen.
Implements ns3::Socket.
References NS_LOG_FUNCTION_NOARGS.
Receive packet.
maxSize | maximum size |
flags | additionnal flags |
Implements ns3::Socket.
References NS_LOG_FUNCTION, and RecvFrom().
|
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().
Send a packet.
p | packet to send |
flags | additionnal flags |
Implements ns3::Socket.
References NS_LOG_FUNCTION, and SendTo().
|
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().
|
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::SetProtocol | ( | uint16_t | protocol | ) |
Set protocol field.
protocol | protocol to set |
|
virtual |
Shutdown receive capability.
Implements ns3::Socket.
References NS_LOG_FUNCTION_NOARGS.
|
virtual |
Shutdown send capability.
Implements ns3::Socket.
References NS_LOG_FUNCTION_NOARGS.