IPv6 raw socket. More...
#include <ipv6-raw-socket-impl.h>
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. | |
virtual int | Bind () |
Bind socket. | |
virtual int | Bind6 () |
Allocate a local IPv6 endpoint for this socket. | |
virtual int | Close () |
Close the socket. | |
virtual int | Connect (const Address &address) |
Connect to address. | |
bool | ForwardUp (Ptr< const Packet > p, Ipv6Header hdr, Ptr< NetDevice > device) |
Forward up to receive method. | |
virtual bool | GetAllowBroadcast () const |
Query whether broadcast datagram transmissions are allowed. | |
virtual enum Socket::SocketErrno | GetErrno () const |
Get last error number. | |
virtual Ptr< Node > | GetNode () const |
Get node. | |
virtual uint32_t | GetRxAvailable () const |
Get RX size available. | |
virtual enum Socket::SocketType | GetSocketType () const |
Get socket type (NS3_SOCK_RAW) | |
virtual int | GetSockName (Address &address) const |
Get socket address. | |
virtual uint32_t | GetTxAvailable () const |
Get TX size available. | |
void | Icmpv6FilterSetBlock (uint8_t type) |
Set the filter to block one ICMPv6 type. | |
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 | Icmpv6FilterSetPassAll () |
Clean the ICMPv6 filter structure. | |
bool | Icmpv6FilterWillBlock (uint8_t type) |
Ask the filter about the status of one ICMPv6 type. | |
bool | Icmpv6FilterWillPass (uint8_t type) |
Ask the filter about the status of one ICMPv6 type. | |
virtual int | Listen () |
Listen. | |
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. | |
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 bool | SetAllowBroadcast (bool allowBroadcast) |
Configure whether broadcast datagram transmissions are allowed. | |
void | SetNode (Ptr< Node > node) |
Set the node. | |
void | SetProtocol (uint16_t protocol) |
Set protocol field. | |
virtual int | ShutdownRecv () |
Shutdown receive capability. | |
virtual int | ShutdownSend () |
Shutdown send capability. | |
![]() | |
Socket (void) | |
virtual | ~Socket (void) |
virtual void | BindToNetDevice (Ptr< NetDevice > netdevice) |
Bind a socket to specific device. | |
Ptr< NetDevice > | GetBoundNetDevice () |
Returns socket's bound netdevice, if any. | |
bool | IsRecvPktInfo () const |
Get status indicating whether enable/disable packet information to socket. | |
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. | |
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. | |
void | SetAcceptCallback (Callback< bool, Ptr< Socket >, const Address & > connectionRequest, Callback< void, Ptr< Socket >, const Address & > newConnectionCreated) |
Accept connection requests from remote hosts. | |
void | SetCloseCallbacks (Callback< void, Ptr< Socket > > normalClose, Callback< void, Ptr< Socket > > errorClose) |
Detect socket recv() events such as graceful shutdown or error. | |
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 | SetDataSentCallback (Callback< void, Ptr< Socket >, uint32_t > dataSent) |
Notify application when a packet has been sent from transport protocol (non-standard socket call) | |
void | SetRecvCallback (Callback< void, Ptr< Socket > >) |
Notify application when new data is available to be read. | |
void | SetRecvPktInfo (bool flag) |
Enable/Disable receive packet information to socket. | |
void | SetSendCallback (Callback< void, Ptr< Socket >, uint32_t > sendCb) |
Notify application when space in transmit buffer is added. | |
![]() | |
Object () | |
virtual | ~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 | Start (void) |
![]() | |
SimpleRefCount () | |
SimpleRefCount (const SimpleRefCount &o) | |
uint32_t | GetReferenceCount (void) const |
SimpleRefCount & | operator= (const SimpleRefCount &o) |
void | Ref (void) const |
void | Unref (void) const |
![]() | |
virtual | ~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. | |
![]() | |
static Ptr< Socket > | CreateSocket (Ptr< Node > node, TypeId tid) |
Private Member Functions | |
virtual void | DoDispose () |
Dispose object. |
Private Attributes | |
std::list< struct Data > | m_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< Node > | m_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 | |
![]() | |
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 } |
![]() | |
virtual void | DoDispose (void) |
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) |
![]() | |
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):
Definition at line 64 of file ipv6-raw-socket-impl.h.
ns3::Ipv6RawSocketImpl::Ipv6RawSocketImpl | ( | ) |
Constructor.
Definition at line 58 of file ipv6-raw-socket-impl.cc.
References ns3::Socket::ERROR_NOTERROR, ns3::Ipv6Address::GetAny(), Icmpv6FilterSetPassAll(), m_dst, m_err, m_node, m_protocol, m_shutdownRecv, m_shutdownSend, m_src, and NS_LOG_FUNCTION_NOARGS.
|
virtual |
Destructor.
Definition at line 71 of file ipv6-raw-socket-impl.cc.
|
virtual |
Bind the socket to address.
address | bind to this address |
Implements ns3::Socket.
Definition at line 104 of file ipv6-raw-socket-impl.cc.
References ns3::Inet6SocketAddress::ConvertFrom(), ns3::Socket::ERROR_INVAL, ns3::Inet6SocketAddress::GetIpv6(), ns3::Inet6SocketAddress::IsMatchingType(), m_err, m_src, and NS_LOG_FUNCTION.
|
virtual |
Bind socket.
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().
|
virtual |
Allocate a local IPv6 endpoint for this socket.
Implements ns3::Socket.
Definition at line 125 of file ipv6-raw-socket-impl.cc.
References Bind().
|
virtual |
Close the socket.
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.
|
virtual |
Connect to address.
address | address |
Implements ns3::Socket.
Definition at line 163 of file ipv6-raw-socket-impl.cc.
References ns3::Inet6SocketAddress::ConvertFrom(), ns3::Socket::ERROR_INVAL, ns3::Inet6SocketAddress::GetIpv6(), ns3::Inet6SocketAddress::IsMatchingType(), m_dst, m_err, and NS_LOG_FUNCTION.
|
privatevirtual |
Dispose object.
Definition at line 75 of file ipv6-raw-socket-impl.cc.
References m_node, and NS_LOG_FUNCTION_NOARGS.
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 |
Definition at line 311 of file ipv6-raw-socket-impl.cc.
References ns3::Packet::AddHeader(), ns3::Packet::AddPacketTag(), ns3::Packet::Copy(), ns3::Ipv6RawSocketImpl::Data::fromIp, ns3::Ipv6RawSocketImpl::Data::fromProtocol, 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(), m_data, m_dst, m_protocol, m_shutdownRecv, m_src, ns3::Socket::NotifyDataRecv(), NS_LOG_FUNCTION, ns3::Ipv6RawSocketImpl::Data::packet, ns3::Packet::PeekHeader(), ns3::Packet::RemovePacketTag(), and ns3::Ipv6PacketInfoTag::SetRecvIf().
Referenced by ns3::Ipv6L3Protocol::Receive().
|
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.
Definition at line 372 of file ipv6-raw-socket-impl.cc.
|
virtual |
Get last error number.
Implements ns3::Socket.
Definition at line 93 of file ipv6-raw-socket-impl.cc.
References m_err, and NS_LOG_FUNCTION_NOARGS.
Get node.
Implements ns3::Socket.
Definition at line 88 of file ipv6-raw-socket-impl.cc.
References m_node.
|
virtual |
Get RX size available.
Implements ns3::Socket.
Definition at line 298 of file ipv6-raw-socket-impl.cc.
References m_data, and NS_LOG_FUNCTION_NOARGS.
|
virtual |
Get socket type (NS3_SOCK_RAW)
Implements ns3::Socket.
Definition at line 99 of file ipv6-raw-socket-impl.cc.
References ns3::Socket::NS3_SOCK_RAW.
|
virtual |
Get socket address.
address | socket address if method success |
Implements ns3::Socket.
Definition at line 130 of file ipv6-raw-socket-impl.cc.
References m_src, and NS_LOG_FUNCTION_NOARGS.
|
virtual |
Get TX size available.
Implements ns3::Socket.
Definition at line 292 of file ipv6-raw-socket-impl.cc.
References NS_LOG_FUNCTION_NOARGS.
|
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.
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.
the | ICMPv6 type to block |
Definition at line 396 of file ipv6-raw-socket-impl.cc.
References ns3::Ipv6RawSocketImpl::icmpv6Filter::icmpv6Filt, and m_icmpFilter.
void ns3::Ipv6RawSocketImpl::Icmpv6FilterSetBlockAll | ( | ) |
Set the filter to block all the ICMPv6 types.
Definition at line 384 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.
the | ICMPv6 type to pass |
Definition at line 390 of file ipv6-raw-socket-impl.cc.
References ns3::Ipv6RawSocketImpl::icmpv6Filter::icmpv6Filt, and m_icmpFilter.
void ns3::Ipv6RawSocketImpl::Icmpv6FilterSetPassAll | ( | ) |
Clean the ICMPv6 filter structure.
Definition at line 378 of file ipv6-raw-socket-impl.cc.
References m_icmpFilter.
Referenced by Ipv6RawSocketImpl().
bool ns3::Ipv6RawSocketImpl::Icmpv6FilterWillBlock | ( | uint8_t | type | ) |
Ask the filter about the status of one ICMPv6 type.
the | ICMPv6 type |
Definition at line 408 of file ipv6-raw-socket-impl.cc.
References ns3::Ipv6RawSocketImpl::icmpv6Filter::icmpv6Filt, and m_icmpFilter.
Referenced by ForwardUp().
bool ns3::Ipv6RawSocketImpl::Icmpv6FilterWillPass | ( | uint8_t | type | ) |
Ask the filter about the status of one ICMPv6 type.
the | ICMPv6 type |
Definition at line 402 of file ipv6-raw-socket-impl.cc.
References ns3::Ipv6RawSocketImpl::icmpv6Filter::icmpv6Filt, and m_icmpFilter.
|
virtual |
Listen.
Implements ns3::Socket.
Definition at line 178 of file ipv6-raw-socket-impl.cc.
References ns3::Socket::ERROR_OPNOTSUPP, m_err, and NS_LOG_FUNCTION_NOARGS.
Receive packet.
maxSize | maximum size |
flags | additionnal flags |
Implements ns3::Socket.
Definition at line 257 of file ipv6-raw-socket-impl.cc.
References NS_LOG_FUNCTION, and RecvFrom().
|
virtual |
Receive packet.
maxSize | maximum size |
flags | additionnal flags |
fromAddress | source address |
Implements ns3::Socket.
Definition at line 264 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().
Send a packet.
p | packet to send |
flags | additionnal flags |
Implements ns3::Socket.
Definition at line 185 of file ipv6-raw-socket-impl.cc.
References m_dst, m_protocol, NS_LOG_FUNCTION, and SendTo().
|
virtual |
Send a packet.
p | packet to send |
flags | additionnal flags |
toAddress | destination address |
Implements ns3::Socket.
Definition at line 192 of file ipv6-raw-socket-impl.cc.
References ns3::Packet::AddHeader(), ns3::Icmpv6Header::CalculatePseudoHeaderChecksum(), ns3::Inet6SocketAddress::ConvertFrom(), ns3::Packet::CopyData(), ns3::Socket::ERROR_INVAL, ns3::Socket::ERROR_NOTERROR, ns3::Inet6SocketAddress::GetIpv6(), ns3::Object::GetObject(), ns3::Icmpv6Echo::GetSerializedSize(), ns3::Packet::GetSize(), ns3::Icmpv6L4Protocol::GetStaticProtocolNumber(), ns3::Icmpv6Header::ICMPV6_ECHO_REQUEST, ns3::Ipv6Address::IsAny(), ns3::Inet6SocketAddress::IsMatchingType(), m_err, m_node, m_protocol, m_shutdownSend, m_src, 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.
Definition at line 362 of file ipv6-raw-socket-impl.cc.
Set the node.
node | node 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.
protocol | protocol to set |
|
virtual |
Shutdown receive capability.
Implements ns3::Socket.
Definition at line 156 of file ipv6-raw-socket-impl.cc.
References m_shutdownRecv, and NS_LOG_FUNCTION_NOARGS.
|
virtual |
Shutdown send capability.
Implements ns3::Socket.
Definition at line 149 of file ipv6-raw-socket-impl.cc.
References m_shutdownSend, and NS_LOG_FUNCTION_NOARGS.
Packet waiting to be processed.
Definition at line 305 of file ipv6-raw-socket-impl.h.
Referenced by ForwardUp(), GetRxAvailable(), and RecvFrom().
|
private |
Destination address.
Definition at line 295 of file ipv6-raw-socket-impl.h.
Referenced by Connect(), ForwardUp(), Ipv6RawSocketImpl(), and Send().
|
private |
Last error number.
Definition at line 280 of file ipv6-raw-socket-impl.h.
Referenced by Bind(), Connect(), GetErrno(), Ipv6RawSocketImpl(), Listen(), and SendTo().
|
private |
ICMPv6 filter.
Definition at line 328 of file ipv6-raw-socket-impl.h.
Referenced by Icmpv6FilterSetBlock(), Icmpv6FilterSetBlockAll(), Icmpv6FilterSetPass(), Icmpv6FilterSetPassAll(), Icmpv6FilterWillBlock(), and Icmpv6FilterWillPass().
Node.
Definition at line 285 of file ipv6-raw-socket-impl.h.
Referenced by Close(), DoDispose(), GetNode(), Ipv6RawSocketImpl(), SendTo(), and SetNode().
|
private |
Protocol.
Definition at line 300 of file ipv6-raw-socket-impl.h.
Referenced by ForwardUp(), GetTypeId(), Ipv6RawSocketImpl(), Send(), and SendTo().
|
private |
Flag to shutdown receive capability.
Definition at line 315 of file ipv6-raw-socket-impl.h.
Referenced by ForwardUp(), Ipv6RawSocketImpl(), and ShutdownRecv().
|
private |
Flag to shutdown send capability.
Definition at line 310 of file ipv6-raw-socket-impl.h.
Referenced by Ipv6RawSocketImpl(), SendTo(), and ShutdownSend().
|
private |
Source address.
Definition at line 290 of file ipv6-raw-socket-impl.h.
Referenced by Bind(), ForwardUp(), GetSockName(), Ipv6RawSocketImpl(), and SendTo().