nl::Inet::RawEndPoint

#include <src/inet/RawEndPoint.h>

Objects of this class represent raw IP protocol endpoints.

Summary

Nest Inet Layer encapsulates methods for interacting with PF_RAW sockets (on Linux and BSD-derived systems) or LwIP raw protocol control blocks, as the system is configured accordingly.

Inheritance

Inherits from: nl::Inet::EndPointBasis

Public types

@6{
  kState_Closed = kBasisState_Closed,
  kState_Bound,
  kState_Listening
}
enum
Basic dynamic state of the underlying endpoint.
OnMessageReceivedFunct)(RawEndPoint *endPoint, Weave::System::PacketBuffer *msg, IPAddress senderAddr) typedef
void(*
Type of message text reception event handling function.
OnReceiveErrorFunct)(RawEndPoint *endPoint, INET_ERROR err, IPAddress senderAddr) typedef
void(*
Type of reception error event handling function.

Public attributes

IPProto
IPProtocol
version of the Internet Control Message Protocol (ICMP)
IPVer
IPVersion
Version of the Internet protocol.
OnMessageReceived
The endpoint's message reception event handling function delegate.
OnReceiveError
The endpoint's receive error event handling function delegate.
mState
enum nl::Inet::RawEndPoint::@6
Basic dynamic state of the underlying endpoint.

Public functions

Bind(IPAddressType addrType, IPAddress addr)
Bind the endpoint to an interface IP address.
BindIPv6LinkLocal(InterfaceId intf, IPAddress addr)
Bind the endpoint to an interface IPv6 link-local address.
BindInterface(InterfaceId intf)
Bind the endpoint to a network interface.
Free(void)
void
Close the endpoint and recycle its memory.
Listen(void)
Prepare the endpoint to receive ICMP messages.
SendTo(IPAddress addr, Weave::System::PacketBuffer *msg)
Send an ICMP message to the specified destination address.
SetICMPFilter(uint8_t numICMPTypes, const uint8_t *aICMPTypes)
Set the ICMP6 filter parameters in the network stack.

Public types

@6

 @6

Basic dynamic state of the underlying endpoint.

Objects are initialized in the "closed" 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.

Properties
kState_Bound

Endpoint bound, but not listening.

kState_Closed

Endpoint initialized, but not bound.

kState_Listening

Endpoint receiving ICMP messages.

OnMessageReceivedFunct

void(* OnMessageReceivedFunct)(RawEndPoint *endPoint, Weave::System::PacketBuffer *msg, IPAddress senderAddr)

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 raw endpoint associated with the event.
[in] msg
The message text received.
[in] senderAddr
The IP address of the sender.

OnReceiveErrorFunct

void(* OnReceiveErrorFunct)(RawEndPoint *endPoint, INET_ERROR err, IPAddress senderAddr)

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 raw endpoint associated with the event.
[in] err
The reason for the error.

Public attributes

IPProto

IPProtocol IPProto

version of the Internet Control Message Protocol (ICMP)

While this field is a mutable class variable, it is an invariant of the class that it not be modified.

IPVer

IPVersion IPVer

Version of the Internet protocol.

While this field is a mutable class variable, it is an invariant of the class that it not be modified.

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::RawEndPoint::@6 mState

Basic dynamic state of the underlying endpoint.

Objects are initialized in the "closed" 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.

Public functions

Bind

INET_ERROR Bind(
  IPAddressType addrType,
  IPAddress addr
)

Bind the endpoint to an interface IP address.

Bind the raw endpoint to an IP address of the specified type.

Binds the endpoint to the specified network interface IP address.

Details
Parameters
[in] addrType
the protocol version of the IP address
[in] addr
the IP address (must be an interface address)
Return Values
INET_NO_ERROR
success: endpoint bound to address
INET_ERROR_INCORRECT_STATE
endpoint has been bound previously
INET_NO_MEMORY
insufficient memory for endpoint
INET_ERROR_WRONG_PROTOCOL_TYPE
addrType does not match IPVer.
INET_ERROR_WRONG_ADDRESS_TYPE
addrType is kIPAddressType_Any, or the type of addr is not equal to addrType.
other
another system or platform error

On LwIP, this method must not be called with the LwIP stack lock already acquired.

Details
Parameters
[in] addrType
An IPAddressType to identify the type of the address.
[in] addr
An IPAddress object required to be of the specified type.
Returns
INET_NO_ERROR on success, or a mapped OS error on failure. An invalid parameter list can result in INET_ERROR_WRONG_ADDRESS_TYPE. If the raw endpoint is already bound or is listening, then returns INET_ERROR_INCORRECT_STATE.

BindIPv6LinkLocal

INET_ERROR BindIPv6LinkLocal(
  InterfaceId intf,
  IPAddress addr
)

Bind the endpoint to an interface IPv6 link-local address.

Bind the raw endpoint to an IPv6 link-local scope address at the specified interface index.

Binds the endpoint to the IPv6 link-local address addr on the network interface indicated by intf.

Details
Parameters
[in] intf
the indicator of the network interface
[in] addr
the IP address (must be an interface address)
Return Values
INET_NO_ERROR
success: endpoint bound to address
INET_ERROR_INCORRECT_STATE
endpoint has been bound previously
INET_NO_MEMORY
insufficient memory for endpoint
INET_ERROR_WRONG_PROTOCOL_TYPE
addrType does not match IPVer.
INET_ERROR_WRONG_ADDRESS_TYPE
addr is not an IPv6 link-local address or intf is INET_NULL_INTERFACEID.
other
another system or platform error

On LwIP, this method must not be called with the LwIP stack lock already acquired.

Also sets various IPv6 socket options appropriate for transmitting packets to and from on-link destinations.

Details
Parameters
[in] intf
An InterfaceId to identify the scope of the address.
[in] addr
An IPv6 link-local scope IPAddress object.
Returns
INET_NO_ERROR on success, or a mapped OS error on failure. An invalid parameter list can result in INET_ERROR_WRONG_ADDRESS_TYPE. If the raw endpoint is already bound or is listening, then returns INET_ERROR_INCORRECT_STATE.

BindInterface

INET_ERROR BindInterface(
  InterfaceId intf
)

Bind the endpoint to a network interface.

Binds the endpoint to the specified network interface IP address.

Details
Parameters
[in] intf
indicator of the network interface.
Return Values
INET_NO_ERROR
success: endpoint bound to address
INET_NO_MEMORY
insufficient memory for endpoint
INET_ERROR_UNKNOWN_INTERFACE
On LwIP systems, the interface is not present.
other
another system or platform error

On LwIP, this method must not be called with the LwIP stack lock already acquired.

Free

void Free(
  void
)

Close the endpoint and recycle its memory.

Invokes the Close method, then invokes the InetLayerBasis::Release method to return the object to its memory pool.

On LwIP systems, an event handler is dispatched to release the object within the context of the LwIP thread. This method must not be called with the LwIP stack lock already acquired.

Listen

INET_ERROR Listen(
  void
)

Prepare the endpoint to receive ICMP messages.

If mState is already kState_Listening, then no operation is performed, otherwise the mState is set to kState_Listening and the endpoint is prepared to received ICMPv6 messages, according to the semantics of the platform.

Details
Return Values
INET_NO_ERROR
always returned.

On LwIP, this method must not be called with the LwIP stack lock already acquired

SendTo

INET_ERROR SendTo(
  IPAddress addr,
  Weave::System::PacketBuffer *msg
)

Send an ICMP message to the specified destination address.

 Sends the ICMP message if possible. Always calls
 Weave::System::PacketBuffer::Free on behalf of the caller.

Details
Parameters
[in] addr
the destination address
[in] msg
the packet buffer containing the ICMP message
Return Values
INET_NO_ERROR
success: msg is queued for transmit.
INET_ERROR_WRONG_ADDRESS_TYPE
the destination address and the bound interface address do not have matching protocol versions or address type.
INET_ERROR_MESSAGE_TOO_LONG
Returned on some platforms, msg does not contain the whole ICMP message.
INET_ERROR_OUTBOUND_MESSAGE_TRUNCATED
Returned on some platforms, only a truncated portion of msg was queued for transmit.
other
another system or platform error

SetICMPFilter

INET_ERROR SetICMPFilter(
  uint8_t numICMPTypes,
  const uint8_t *aICMPTypes
)

Set the ICMP6 filter parameters in the network stack.

Apply the ICMPv6 filtering parameters for the codes in aICMPTypes to the underlying endpoint in the system networking stack.

Details
Parameters
[in] numICMPTypes
length of array at aICMPTypes
[in] aICMPTypes
the set of ICMPv6 type codes to filter.
Return Values
INET_NO_ERROR
success: filter parameters set
INET_ERROR_NOT_IMPLEMENTED
system does not implement
INET_ERROR_WRONG_ADDRESS_TYPE
endpoint not IPv6 type
INET_ERROR_WRONG_PROTOCOL_TYPE
endpoint not ICMP6 type
other
another system or platform error