nl::Inet::IPEndPointBasis

#include <src/inet/IPEndPointBasis.h>

Objects of this class represent non-instantiable IP protocol endpoints.

Summary

Inheritance

Inherits from: nl::Inet::EndPointBasis
Direct Known Subclasses:
  nl::Inet::RawEndPoint
  nl::Inet::UDPEndPoint

Public types

@7{
  kState_Ready = kBasisState_Closed,
  kState_Bound = 1,
  kState_Listening = 2,
  kState_Closed = 3
}
enum
Basic dynamic state of the underlying endpoint.
@8{
  kSendFlag_RetainBuffer = 0x0040
}
enum
Transmit option flags for the SendTo methods.
OnMessageReceivedFunct)(IPEndPointBasis *endPoint, Weave::System::PacketBuffer *msg, const IPPacketInfo *pktInfo) typedef
void(*
Type of message text reception event handling function.
OnReceiveErrorFunct)(IPEndPointBasis *endPoint, INET_ERROR err, const IPPacketInfo *pktInfo) typedef
void(*
Type of reception error event handling function.

Public attributes

OnMessageReceived
The endpoint's message reception event handling function delegate.
OnReceiveError
The endpoint's receive error event handling function delegate.
mState
enum nl::Inet::IPEndPointBasis::@7
Basic dynamic state of the underlying endpoint.

Protected attributes

mBoundIntfId
InterfaceId

Public functions

JoinMulticastGroup(InterfaceId aInterfaceId, const IPAddress & aAddress)
Join an IP multicast group.
LeaveMulticastGroup(InterfaceId aInterfaceId, const IPAddress & aAddress)
Leave an IP multicast group.
SetMulticastLoopback(IPVersion aIPVersion, bool aLoopback)
Set whether IP multicast traffic should be looped back.

Protected functions

Bind(IPAddressType aAddressType, IPAddress aAddress, uint16_t aPort, InterfaceId aInterfaceId)
BindInterface(IPAddressType aAddressType, InterfaceId aInterfaceId)
GetSocket(IPAddressType aAddressType, int aType, int aProtocol)
HandleDataReceived(Weave::System::PacketBuffer *aBuffer)
void
HandlePendingIO(uint16_t aPort)
void
Init(InetLayer *aInetLayer)
void
PrepareIO(void)
SendTo(const IPAddress & aAddress, uint16_t aPort, InterfaceId aInterfaceId, Weave::System::PacketBuffer *aBuffer, uint16_t aSendFlags)

Public static functions

FindNetifFromInterfaceId(InterfaceId aInterfaceId)
struct netif *

Protected static functions

GetPacketInfo(Weave::System::PacketBuffer *buf)
Get LwIP IP layer source and destination addressing information.

Public types

@7

 @7

Basic dynamic state of the underlying endpoint.

Objects are initialized in the "ready" state, proceed to the "bound" state after binding to a local interface address, then proceed to the "listening" state when they have continuations registered for handling events for reception of ICMP messages.

Note:The kBasisState_Closed state enumeration is mapped to kState_Ready for historical binary-compatibility reasons. The existing kState_Closed exists to identify separately the distinction between "not opened yet" and "previously opened now closed" that existed previously in the kState_Ready and kState_Closed states.

Properties
kState_Bound

Endpoint bound, but not listening.

kState_Closed

Endpoint closed, ready for release.

kState_Listening

Endpoint receiving datagrams.

kState_Ready

Endpoint initialized, but not open.

@8

 @8

Transmit option flags for the SendTo methods.

Properties
kSendFlag_RetainBuffer

Do not destructively queue the message directly.

Queue a copy.

OnMessageReceivedFunct

void(* OnMessageReceivedFunct)(IPEndPointBasis *endPoint, Weave::System::PacketBuffer *msg, const IPPacketInfo *pktInfo)

Type of message text reception event handling function.

Provide a function of this type to the OnMessageReceived delegate member to process message text reception events on endPoint where msg is the message text received from the sender at senderAddr.

Details
Parameters
[in] endPoint
The endpoint associated with the event.
[in] msg
The message text received.
[in] senderAddr
The IP address of the sender.

OnReceiveErrorFunct

void(* OnReceiveErrorFunct)(IPEndPointBasis *endPoint, INET_ERROR err, const IPPacketInfo *pktInfo)

Type of reception error event handling function.

Provide a function of this type to the OnReceiveError delegate member to process reception error events on endPoint. The err argument provides specific detail about the type of the error.

Details
Parameters
[in] endPoint
The endpoint associated with the event.
[in] err
The reason for the error.

Public attributes

OnMessageReceived

OnMessageReceivedFunct OnMessageReceived

The endpoint's message reception event handling function delegate.

OnReceiveError

OnReceiveErrorFunct OnReceiveError

The endpoint's receive error event handling function delegate.

mState

enum nl::Inet::IPEndPointBasis::@7 mState

Basic dynamic state of the underlying endpoint.

Objects are initialized in the "ready" state, proceed to the "bound" state after binding to a local interface address, then proceed to the "listening" state when they have continuations registered for handling events for reception of ICMP messages.

Note:The kBasisState_Closed state enumeration is mapped to kState_Ready for historical binary-compatibility reasons. The existing kState_Closed exists to identify separately the distinction between "not opened yet" and "previously opened now closed" that existed previously in the kState_Ready and kState_Closed states.

Protected attributes

mBoundIntfId

InterfaceId mBoundIntfId

Public functions

JoinMulticastGroup

INET_ERROR JoinMulticastGroup(
  InterfaceId aInterfaceId,
  const IPAddress & aAddress
)

Join an IP multicast group.

Join the endpoint to the supplied multicast group on the specified interface.

Details
Parameters
[in] aInterfaceId
the indicator of the network interface to add to the multicast group
[in] aAddress
the multicast group to add the interface to
Return Values
INET_NO_ERROR
success: multicast group removed
INET_ERROR_UNKNOWN_INTERFACE
unknown network interface, aInterfaceId
INET_ERROR_WRONG_ADDRESS_TYPE
aAddress is not kIPAddressType_IPv4 or kIPAddressType_IPv6 or is not multicast
other
another system or platform error

LeaveMulticastGroup

INET_ERROR LeaveMulticastGroup(
  InterfaceId aInterfaceId,
  const IPAddress & aAddress
)

Leave an IP multicast group.

Remove the endpoint from the supplied multicast group on the specified interface.

Details
Parameters
[in] aInterfaceId
the indicator of the network interface to remove from the multicast group
[in] aAddress
the multicast group to remove the interface from
Return Values
INET_NO_ERROR
success: multicast group removed
INET_ERROR_UNKNOWN_INTERFACE
unknown network interface, aInterfaceId
INET_ERROR_WRONG_ADDRESS_TYPE
aAddress is not kIPAddressType_IPv4 or kIPAddressType_IPv6 or is not multicast
other
another system or platform error

SetMulticastLoopback

INET_ERROR SetMulticastLoopback(
  IPVersion aIPVersion,
  bool aLoopback
)

Set whether IP multicast traffic should be looped back.

Set whether or not IP multicast traffic should be looped back to this endpoint.

Details
Parameters
[in] aIPVersion
[in] aLoop
Return Values
INET_NO_ERROR
success: multicast loopback behavior set
other
another system or platform error

Protected functions

Bind

INET_ERROR Bind(
  IPAddressType aAddressType,
  IPAddress aAddress,
  uint16_t aPort,
  InterfaceId aInterfaceId
)

BindInterface

INET_ERROR BindInterface(
  IPAddressType aAddressType,
  InterfaceId aInterfaceId
)

GetSocket

INET_ERROR GetSocket(
  IPAddressType aAddressType,
  int aType,
  int aProtocol
)

HandleDataReceived

void HandleDataReceived(
  Weave::System::PacketBuffer *aBuffer
)

HandlePendingIO

void HandlePendingIO(
  uint16_t aPort
)

Init

void Init(
  InetLayer *aInetLayer
)

PrepareIO

SocketEvents PrepareIO(
  void
)

SendTo

INET_ERROR SendTo(
  const IPAddress & aAddress,
  uint16_t aPort,
  InterfaceId aInterfaceId,
  Weave::System::PacketBuffer *aBuffer,
  uint16_t aSendFlags
)

Public static functions

FindNetifFromInterfaceId

struct netif * FindNetifFromInterfaceId(
  InterfaceId aInterfaceId
)

Protected static functions

GetPacketInfo

IPPacketInfo * GetPacketInfo(
  Weave::System::PacketBuffer *buf
)

Get LwIP IP layer source and destination addressing information.

When using LwIP information about the packet is 'hidden' in the reserved space before the start of the data in the packet buffer. This is necessary because the system layer events only have two arguments, which in this case are used to convey the pointer to the end point and the pointer to the buffer.

Details
Parameters
[in] aBuffer
the packet buffer containing the IP message
Returns
a pointer to the address information on success; otherwise, NULL if there is insufficient space in the packet for the address information.

In most cases this trick of storing information before the data works because the first buffer in an LwIP IP message contains the space that was used for the Ethernet/IP/UDP headers. However, given the current size of the IPPacketInfo structure (40 bytes), it is possible for there to not be enough room to store the structure along with the payload in a single packet buffer. In practice, this should only happen for extremely large IPv4 packets that arrive without an Ethernet header.