nl::Inet::InetLayer

#include <src/inet/InetLayer.h>

This provides access to Internet services, including timers, Domain Name System (DNS) resolution, TCP network transport, UDP network transport, and raw network transport, for a single thread.

Summary

For BSD/POSIX Sockets, event readiness notification is handled via file descriptors and a traditional poll / select implementation on the platform adaptation.

For LwIP, event readiness notification is handle via events / messages and platform- and system-specific hooks for the event / message system.

Constructors and Destructors

InetLayer(void)
This is the InetLayer default constructor.

Public types

@3{
  kState_NotInitialized = 0,
  kState_Initialized = 1,
  kState_ShutdownInProgress = 2
}
enum
The current state of the InetLayer object.

Public attributes

State
enum nl::Inet::InetLayer::@3
The current state of the InetLayer object.

Public static attributes

sInetEventHandlerDelegate

Public functions

CanEnqueueDroppableEvent(void)
bool
DroppableEventDequeued(void)
void
GetInterfaceFromAddr(const IPAddress & addr, InterfaceId & intfId)
Get the interface identifier for the specified IP address.
GetLinkLocalAddr(InterfaceId link, IPAddress *llAddr)
Get the link local IPv6 address for a specified link or interface.
GetPlatformData(void)
void *
This returns any client-specific platform data assigned to the instance, if it has been previously set.
HandleSelectResult(int selectRes, fd_set *readfds, fd_set *writefds, fd_set *exceptfds)
void
Handle I/O from a select call.
Init(Weave::System::Layer & aSystemLayer, void *aContext)
This is the InetLayer explicit initializer.
InitQueueLimiter(void)
MatchLocalIPv6Subnet(const IPAddress & addr)
bool
Check if there is a prefix match between the specified IPv6 address and any of the locally configured IPv6 addresses.
PrepareSelect(int & nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval & sleepTime)
void
Prepare the sets of file descriptors for select() to work with.
SetPlatformData(void *aPlatformData)
void
This sets the specified client-specific platform data to the instance for later retrieval by the client platform.
Shutdown(void)
This is the InetLayer explicit deinitializer and should be called prior to disposing of an instantiated InetLayer instance.
SystemLayer(void) const

Public static functions

HandleInetLayerEvent(Weave::System::Object & aTarget, Weave::System::EventType aEventType, uintptr_t aArgument)
Weave::System::Error
IsDroppableEvent(Weave::System::EventType aType)
bool
UpdateSnapshot(nl::Weave::System::Stats::Snapshot & aSnapshot)
void

Public types

@3

 @3

The current state of the InetLayer object.

Properties
kState_Initialized

Initialized state.

kState_NotInitialized

Not initialized state.

kState_ShutdownInProgress

State where Shutdown has been triggered.

Public attributes

State

enum nl::Inet::InetLayer::@3 State

The current state of the InetLayer object.

[READ-ONLY] Current state.

Public static attributes

sInetEventHandlerDelegate

Weave::System::LwIPEventHandlerDelegate sInetEventHandlerDelegate

Public functions

CanEnqueueDroppableEvent

bool CanEnqueueDroppableEvent(
  void
)

DroppableEventDequeued

void DroppableEventDequeued(
  void
)

GetInterfaceFromAddr

INET_ERROR GetInterfaceFromAddr(
  const IPAddress & addr,
  InterfaceId & intfId
)

Get the interface identifier for the specified IP address.

If the interface identifier cannot be derived it is set to the INET_NULL_INTERFACEID.

Details
Parameters
[in] addr
A reference to the IPAddress object.
[out] intfId
A reference to the InterfaceId object.
Returns
INET_NO_ERROR unconditionally.

GetLinkLocalAddr

INET_ERROR GetLinkLocalAddr(
  InterfaceId link,
  IPAddress *llAddr
)

Get the link local IPv6 address for a specified link or interface.

Details
Parameters
[in] link
The interface for which the link local IPv6 address is being sought.
[out] llAddr
The link local IPv6 address for the link.
Return Values
INET_ERROR_NOT_IMPLEMENTED
If IPv6 is not supported.
INET_ERROR_BAD_ARGS
If the link local address is NULL.
INET_ERROR_ADDRESS_NOT_FOUND
If the link does not have any address configured.
INET_NO_ERROR
On success.

GetPlatformData

void * GetPlatformData(
  void
)

This returns any client-specific platform data assigned to the instance, if it has been previously set.

Details
Returns
Client-specific platform data, if is has been previously set; otherwise, NULL.

HandleSelectResult

void HandleSelectResult(
  int selectRes,
  fd_set *readfds,
  fd_set *writefds,
  fd_set *exceptfds
)

Handle I/O from a select call.

This method registers the pending I/O event in each active endpoint and then invokes the respective I/O handling functions for those endpoints.

Details
Parameters
[in] selectRes
The return value of the select call.
[in] readfds
A pointer to the set of read file descriptors.
[in] writefds
A pointer to the set of write file descriptors.
[in] exceptfds
A pointer to the set of file descriptors with errors.

InetLayer

 InetLayer(
  void
)

This is the InetLayer default constructor.

It performs some basic data member initialization; however, since InetLayer follows an explicit initializer design pattern, the InetLayer::Init method must be called successfully prior to using the object.

Init

INET_ERROR Init(
  Weave::System::Layer & aSystemLayer,
  void *aContext
)

This is the InetLayer explicit initializer.

This must be called and complete successfully before the InetLayer may be used.

The caller may provide an optional context argument which will be passed back via any platform-specific hook functions. For LwIP-based adaptations, this will typically be a pointer to the event queue associated with the InetLayer instance.

Platforms may choose to assert INET_CONFIG_WILL_OVERRIDE_PLATFORM_XTOR_FUNCS in their platform-specific configuration header and enable the Platform::InetLayer::WillInit and Platform::InetLayer::DidInit hooks to effect platform-specific customizations or data extensions to InetLayer.

Details
Parameters
[in] aSystemLayer
A required instance of the Weave System Layer already successfully initialized.
[in] aContext
An optional context argument which will be passed back to the caller via any platform-specific hook functions.
Return Values
INET_ERROR_INCORRECT_STATE
If the InetLayer is in an incorrect state.
INET_ERROR_NO_MEMORY
If the InetLayer runs out of resource for this request for a new timer.
other
Platform-specific errors indicating the reason for initialization failure.
INET_NO_ERROR
On success.

InitQueueLimiter

INET_ERROR InitQueueLimiter(
  void
)

MatchLocalIPv6Subnet

bool MatchLocalIPv6Subnet(
  const IPAddress & addr
)

Check if there is a prefix match between the specified IPv6 address and any of the locally configured IPv6 addresses.

Details
Parameters
[in] addr
The IPv6 address to check for the prefix-match.
Returns
true if a successful match is found, otherwise false.

PrepareSelect

void PrepareSelect(
  int & nfds,
  fd_set *readfds,
  fd_set *writefds,
  fd_set *exceptfds,
  struct timeval & sleepTime
)

Prepare the sets of file descriptors for select() to work with.

Details
Parameters
[out] nfds
The range of file descriptors in the file descriptor set.
[in] readfds
A pointer to the set of readable file descriptors.
[in] writefds
A pointer to the set of writable file descriptors.
[in] exceptfds
A pointer to the set of file descriptors with errors.
[in] sleepTimeTV
A pointer to a structure specifying how long the select should sleep

SetPlatformData

void SetPlatformData(
  void *aPlatformData
)

This sets the specified client-specific platform data to the instance for later retrieval by the client platform.

Details
Parameters
[in] aPlatformData
The client-specific platform data to set.

Shutdown

INET_ERROR Shutdown(
  void
)

This is the InetLayer explicit deinitializer and should be called prior to disposing of an instantiated InetLayer instance.

Platforms may choose to assert INET_CONFIG_WILL_OVERRIDE_PLATFORM_XTOR_FUNCS in their platform-specific configuration header and enable the Platform::InetLayer::WillShutdown and Platform::InetLayer::DidShutdown hooks to effect clean-up of platform-specific customizations or data extensions to InetLayer.

Details
Returns
INET_NO_ERROR on success; otherwise, a specific error indicating the reason for shutdown failure.

SystemLayer

Weave::System::Layer * SystemLayer(
  void
) const 

Public static functions

HandleInetLayerEvent

Weave::System::Error HandleInetLayerEvent(
  Weave::System::Object & aTarget,
  Weave::System::EventType aEventType,
  uintptr_t aArgument
)

IsDroppableEvent

bool IsDroppableEvent(
  Weave::System::EventType aType
)

UpdateSnapshot

void UpdateSnapshot(
  nl::Weave::System::Stats::Snapshot & aSnapshot
)