A representation of an IPv6 endpoint/connection. More...
#include "ipv6-end-point.h"
Public Member Functions | |
Ipv6EndPoint (Ipv6Address addr, uint16_t port) | |
Constructor. | |
~Ipv6EndPoint () | |
void | BindToNetDevice (Ptr< NetDevice > netdevice) |
Bind a socket to specific device. | |
void | ForwardIcmp (Ipv6Address src, uint8_t ttl, uint8_t type, uint8_t code, uint32_t info) |
Forward the ICMP packet to the upper level. | |
void | ForwardUp (Ptr< Packet > p, Ipv6Header header, uint16_t port, Ptr< Ipv6Interface > incomingInterface) |
Forward the packet to the upper level. | |
Ptr< NetDevice > | GetBoundNetDevice () const |
Returns socket's bound netdevice, if any. | |
Ipv6Address | GetLocalAddress () const |
Get the local address. | |
uint16_t | GetLocalPort () const |
Get the local port. | |
Ipv6Address | GetPeerAddress () const |
Get the peer address. | |
uint16_t | GetPeerPort () const |
Get the peer port. | |
bool | IsRxEnabled () const |
Checks if the endpoint can receive packets. | |
void | SetDestroyCallback (Callback< void > callback) |
Set the default destroy callback. | |
void | SetIcmpCallback (Callback< void, Ipv6Address, uint8_t, uint8_t, uint8_t, uint32_t > callback) |
Set the ICMP callback. | |
void | SetLocalAddress (Ipv6Address addr) |
Set the local address. | |
void | SetLocalPort (uint16_t port) |
Set the local port. | |
void | SetPeer (Ipv6Address addr, uint16_t port) |
Set the peer information (address and port). | |
void | SetRxCallback (Callback< void, Ptr< Packet >, Ipv6Header, uint16_t, Ptr< Ipv6Interface > > callback) |
Set the reception callback. | |
void | SetRxEnabled (bool enabled) |
Enable or Disable the endpoint Rx capability. | |
Private Attributes | |
Ptr< NetDevice > | m_boundnetdevice |
The NetDevice the EndPoint is bound to (if any). | |
Callback< void > | m_destroyCallback |
The destroy callback. | |
Callback< void, Ipv6Address, uint8_t, uint8_t, uint8_t, uint32_t > | m_icmpCallback |
The ICMPv6 callback. | |
Ipv6Address | m_localAddr |
The local address. | |
uint16_t | m_localPort |
The local port. | |
Ipv6Address | m_peerAddr |
The peer address. | |
uint16_t | m_peerPort |
The peer port. | |
Callback< void, Ptr< Packet >, Ipv6Header, uint16_t, Ptr< Ipv6Interface > > | m_rxCallback |
The RX callback. | |
bool | m_rxEnabled |
true if the endpoint can receive packets. | |
A representation of an IPv6 endpoint/connection.
This class provides an Internet four-tuple (source and destination ports and addresses). These are used in the ns3::Ipv6EndPointDemux as targets of lookups. The class also has a callback for notification to higher layers that a packet from a lower layer was received. In the ns3 internet-stack, these notifications are automatically registered to be received by the corresponding socket.
Definition at line 39 of file ipv6-end-point.h.
ns3::Ipv6EndPoint::Ipv6EndPoint | ( | Ipv6Address | addr, |
uint16_t | port ) |
Constructor.
addr | the IPv6 address |
port | the port |
Definition at line 20 of file ipv6-end-point.cc.
ns3::Ipv6EndPoint::~Ipv6EndPoint | ( | ) |
Definition at line 29 of file ipv6-end-point.cc.
References ns3::Callback< R, UArgs >::IsNull(), m_destroyCallback, m_icmpCallback, m_rxCallback, and ns3::Callback< R, UArgs >::Nullify().
Bind a socket to specific device.
This method corresponds to using setsockopt() SO_BINDTODEVICE of real network or BSD sockets. If set on a socket, this option will force packets to leave the bound device regardless of the device that IP routing would naturally choose. In the receive direction, only packets received from the bound interface will be delivered.
This option has no particular relationship to binding sockets to an address via Socket::Bind (). It is possible to bind sockets to a specific IP address on the bound interface by calling both Socket::Bind (address) and Socket::BindToNetDevice (device), but it is also possible to bind to mismatching device and address, even if the socket can not receive any packets as a result.
netdevice | Pointer to Netdevice of desired interface |
Definition at line 77 of file ipv6-end-point.cc.
References m_boundnetdevice.
Referenced by ns3::UdpSocketImpl::Bind(), ns3::UdpSocketImpl::Bind6(), ns3::TcpSocketBase::BindToNetDevice(), and ns3::UdpSocketImpl::BindToNetDevice().
void ns3::Ipv6EndPoint::ForwardIcmp | ( | Ipv6Address | src, |
uint8_t | ttl, | ||
uint8_t | type, | ||
uint8_t | code, | ||
uint32_t | info ) |
Forward the ICMP packet to the upper level.
Called from an L4Protocol implementation to notify an endpoint of an icmp message reception.
src | source IPv6 address |
ttl | time-to-live |
type | ICMPv6 type |
code | ICMPv6 code |
info | ICMPv6 info |
Definition at line 128 of file ipv6-end-point.cc.
References m_icmpCallback.
Referenced by ns3::TcpL4Protocol::ReceiveIcmp(), and ns3::UdpL4Protocol::ReceiveIcmp().
void ns3::Ipv6EndPoint::ForwardUp | ( | Ptr< Packet > | p, |
Ipv6Header | header, | ||
uint16_t | port, | ||
Ptr< Ipv6Interface > | incomingInterface ) |
Forward the packet to the upper level.
Called from an L4Protocol implementation to notify an endpoint of a packet reception.
p | the packet |
header | the packet header |
port | source port |
incomingInterface | incoming interface |
Definition at line 116 of file ipv6-end-point.cc.
References m_rxCallback, and port.
Returns socket's bound netdevice, if any.
This method corresponds to using getsockopt() SO_BINDTODEVICE of real network or BSD sockets.
Definition at line 83 of file ipv6-end-point.cc.
References m_boundnetdevice.
Referenced by ns3::Ipv6EndPointDemux::Lookup().
Ipv6Address ns3::Ipv6EndPoint::GetLocalAddress | ( | ) | const |
Get the local address.
Definition at line 41 of file ipv6-end-point.cc.
References m_localAddr.
Referenced by ns3::UdpSocketImpl::Bind(), ns3::UdpSocketImpl::BindToNetDevice(), ns3::UdpSocketImpl::DoSendTo(), ns3::TcpSocketBase::ForwardUp6(), ns3::TcpSocketBase::GetSockName(), ns3::UdpSocketImpl::GetSockName(), ns3::Ipv6EndPointDemux::Lookup(), ns3::TcpSocketBase::PersistTimeout(), ns3::TcpSocketBase::SendDataPacket(), ns3::TcpSocketCongestedRouter::SendDataPacket(), TcpDctcpCongestedRouter::SendDataPacket(), ns3::TcpSocketBase::SendEmptyPacket(), and ns3::TcpSocketSmallAcks::SendEmptyPacket().
uint16_t ns3::Ipv6EndPoint::GetLocalPort | ( | ) | const |
Get the local port.
Definition at line 53 of file ipv6-end-point.cc.
References m_localPort.
Referenced by ns3::UdpSocketImpl::DoSendTo(), ns3::TcpSocketBase::ForwardUp6(), ns3::TcpSocketBase::GetSockName(), ns3::UdpSocketImpl::GetSockName(), ns3::Ipv6EndPointDemux::Lookup(), ns3::TcpSocketBase::PersistTimeout(), ns3::TcpSocketBase::SendDataPacket(), ns3::TcpSocketCongestedRouter::SendDataPacket(), TcpDctcpCongestedRouter::SendDataPacket(), ns3::TcpSocketBase::SendEmptyPacket(), and ns3::TcpSocketSmallAcks::SendEmptyPacket().
Ipv6Address ns3::Ipv6EndPoint::GetPeerAddress | ( | ) | const |
Get the peer address.
Definition at line 65 of file ipv6-end-point.cc.
References m_peerAddr.
Referenced by ns3::TcpSocketBase::ForwardUp6(), ns3::TcpSocketBase::GetPeerName(), ns3::Ipv6EndPointDemux::Lookup(), ns3::TcpSocketBase::PersistTimeout(), ns3::TcpSocketBase::RecvFrom(), ns3::TcpSocketBase::SendDataPacket(), ns3::TcpSocketCongestedRouter::SendDataPacket(), TcpDctcpCongestedRouter::SendDataPacket(), ns3::TcpSocketBase::SendEmptyPacket(), ns3::TcpSocketSmallAcks::SendEmptyPacket(), and ns3::TcpSocketBase::SetupEndpoint6().
uint16_t ns3::Ipv6EndPoint::GetPeerPort | ( | ) | const |
Get the peer port.
Definition at line 71 of file ipv6-end-point.cc.
References m_peerPort.
Referenced by ns3::TcpSocketBase::ForwardUp6(), ns3::TcpSocketBase::GetPeerName(), ns3::Ipv6EndPointDemux::Lookup(), ns3::TcpSocketBase::PersistTimeout(), ns3::TcpSocketBase::RecvFrom(), ns3::TcpSocketBase::SendDataPacket(), ns3::TcpSocketCongestedRouter::SendDataPacket(), TcpDctcpCongestedRouter::SendDataPacket(), ns3::TcpSocketBase::SendEmptyPacket(), and ns3::TcpSocketSmallAcks::SendEmptyPacket().
bool ns3::Ipv6EndPoint::IsRxEnabled | ( | ) | const |
Checks if the endpoint can receive packets.
Definition at line 143 of file ipv6-end-point.cc.
References m_rxEnabled.
Referenced by ns3::Ipv6EndPointDemux::Lookup().
void ns3::Ipv6EndPoint::SetDestroyCallback | ( | Callback< void > | callback | ) |
Set the default destroy callback.
callback | callback function |
Definition at line 110 of file ipv6-end-point.cc.
References m_destroyCallback.
Referenced by ns3::TcpSocketBase::DeallocateEndPoint(), ns3::UdpSocketImpl::FinishBind(), and ns3::TcpSocketBase::SetupCallback().
void ns3::Ipv6EndPoint::SetIcmpCallback | ( | Callback< void, Ipv6Address, uint8_t, uint8_t, uint8_t, uint32_t > | callback | ) |
Set the ICMP callback.
callback | callback function |
Definition at line 103 of file ipv6-end-point.cc.
References m_icmpCallback.
Referenced by ns3::UdpSocketImpl::FinishBind(), and ns3::TcpSocketBase::SetupCallback().
void ns3::Ipv6EndPoint::SetLocalAddress | ( | Ipv6Address | addr | ) |
Set the local address.
addr | the address to set |
Definition at line 47 of file ipv6-end-point.cc.
References m_localAddr.
Referenced by ns3::TcpSocketBase::SetupEndpoint6().
void ns3::Ipv6EndPoint::SetLocalPort | ( | uint16_t | port | ) |
Set the local port.
port | the port to set |
Definition at line 59 of file ipv6-end-point.cc.
References m_localPort, and port.
void ns3::Ipv6EndPoint::SetPeer | ( | Ipv6Address | addr, |
uint16_t | port ) |
Set the peer information (address and port).
addr | peer address |
port | peer port |
Definition at line 89 of file ipv6-end-point.cc.
References m_peerAddr, m_peerPort, and port.
Referenced by ns3::TcpSocketBase::Connect(), and ns3::TcpSocketBase::ProcessSynRcvd().
void ns3::Ipv6EndPoint::SetRxCallback | ( | Callback< void, Ptr< Packet >, Ipv6Header, uint16_t, Ptr< Ipv6Interface > > | callback | ) |
Set the reception callback.
callback | callback function |
Definition at line 96 of file ipv6-end-point.cc.
References m_rxCallback.
Referenced by ns3::UdpSocketImpl::FinishBind(), and ns3::TcpSocketBase::SetupCallback().
void ns3::Ipv6EndPoint::SetRxEnabled | ( | bool | enabled | ) |
Enable or Disable the endpoint Rx capability.
enabled | true if Rx is enabled |
Definition at line 137 of file ipv6-end-point.cc.
References m_rxEnabled.
Referenced by ns3::UdpSocketImpl::ShutdownRecv().
The NetDevice the EndPoint is bound to (if any).
Definition at line 210 of file ipv6-end-point.h.
Referenced by BindToNetDevice(), and GetBoundNetDevice().
|
private |
The destroy callback.
Definition at line 225 of file ipv6-end-point.h.
Referenced by ~Ipv6EndPoint(), and SetDestroyCallback().
|
private |
The ICMPv6 callback.
Definition at line 220 of file ipv6-end-point.h.
Referenced by ~Ipv6EndPoint(), ForwardIcmp(), and SetIcmpCallback().
|
private |
The local address.
Definition at line 190 of file ipv6-end-point.h.
Referenced by GetLocalAddress(), and SetLocalAddress().
|
private |
The local port.
Definition at line 195 of file ipv6-end-point.h.
Referenced by GetLocalPort(), and SetLocalPort().
|
private |
The peer address.
Definition at line 200 of file ipv6-end-point.h.
Referenced by GetPeerAddress(), and SetPeer().
|
private |
The peer port.
Definition at line 205 of file ipv6-end-point.h.
Referenced by GetPeerPort(), and SetPeer().
|
private |
The RX callback.
Definition at line 215 of file ipv6-end-point.h.
Referenced by ~Ipv6EndPoint(), ForwardUp(), and SetRxCallback().
|
private |
true if the endpoint can receive packets.
Definition at line 230 of file ipv6-end-point.h.
Referenced by IsRxEnabled(), and SetRxEnabled().