nl::Inet

Summary

Enumerations

@7{
  kInetEvent_TCPConnectComplete = _INET_CONFIG_EVENT(0),
  kInetEvent_TCPConnectionReceived = _INET_CONFIG_EVENT(1),
  kInetEvent_TCPDataReceived = _INET_CONFIG_EVENT(2),
  kInetEvent_TCPDataSent = _INET_CONFIG_EVENT(3),
  kInetEvent_TCPError = _INET_CONFIG_EVENT(4),
  kInetEvent_UDPDataReceived = _INET_CONFIG_EVENT(5),
  kInetEvent_DNSResolveComplete = _INET_CONFIG_EVENT(6),
  kInetEvent_TunDataReceived = _INET_CONFIG_EVENT(7),
  kInetEvent_RawDataReceived = _INET_CONFIG_EVENT(8)
}
enum
The Inet layer event type definitions.
DNSOptions{
  kDNSOption_AddrFamily_Mask = 0x07,
  kDNSOption_Flags_Mask = 0xF8,
  kDNSOption_AddrFamily_Any = 0x00,
  kDNSOption_AddrFamily_IPv4Only = 0x01,
  kDNSOption_AddrFamily_IPv4Preferred = 0x02,
  kDNSOption_AddrFamily_IPv6Only = 0x03,
  kDNSOption_AddrFamily_IPv6Preferred = 0x04,
  kDNSOption_ValidFlags = 0
}
enum
Options controlling how IP address resolution is performed.
IPAddressType{
  kIPAddressType_Unknown = 0,
  kIPAddressType_IPv4 = 1,
  kIPAddressType_IPv6 = 2,
  kIPAddressType_Any = 3
}
enum
Internet protocol address family.
IPProtocol{
  kIPProtocol_ICMPv6 = 58,
  kIPProtocol_ICMPv4 = 1
}
enum
The numbers of some of the protocols in the IP family.
IPV6MulticastGroup{
  kIPV6MulticastGroup_AllRouters = 2
}
enum
Internet protocol multicast group identifiers.
IPVersion{
  kIPVersion_6 = 6,
  kIPVersion_4 = 4
}
enum
The version of the IP protocol being used.
IPv6MulticastFlag{
  kIPv6MulticastFlag_Transient = 0x01,
  kIPv6MulticastFlag_Prefix = 0x02
}
enum
Internet protocol v6 multicast flags.
IPv6MulticastScope{
  kIPv6MulticastScope_Interface = 1,
  kIPv6MulticastScope_Link = 2,
  kIPv6MulticastScope_IPv4 = 3,
  kIPv6MulticastScope_Admin = 4,
  kIPv6MulticastScope_Site = 5,
  kIPv6MulticastScope_Organization = 8,
  kIPv6MulticastScope_Global = 14
}
enum
Internet protocol multicast address scope.

Typedefs

InterfaceId typedef
struct netif *
Indicator for system network interfaces.

Variables

sIOCTLSocket = -1
int

Functions

CheckMulticastGroupArgs(InterfaceId aInterfaceId, const IPAddress & aAddress)
CloseIOCTLSocket(void)
void
Close the global socket created by GetIOCTLSocket.
FormatInetLayerError(char *buf, uint16_t bufSize, int32_t err)
bool
Given an Inet Layer error, returns a human-readable NULL-terminated C string describing the error.
GetIOCTLSocket(void)
int
Returns a global general purpose socket useful for invoking certain network IOCTLs.
GetInterfaceName(InterfaceId intfId, char *nameBuf, size_t nameBufSize)
NL_DLL_EXPORT INET_ERROR
Get the name of a network interface.
INET_IsInetEvent(Weave::System::EventType aType)
bool
Check to verify if a System::EventType is a valid Inet layer event type.
InterfaceNameToId(const char *intfName, InterfaceId & intfId)
NL_DLL_EXPORT INET_ERROR
Search the list of network interfaces for the indicated name.
LwIPBindInterface(struct raw_pcb *aRaw, InterfaceId intfId)
LwIPBindInterface(struct udp_pcb *aUDP, InterfaceId intfId)
NetmaskToPrefixLength(const uint8_t *netmask, uint16_t netmaskLen)
uint8_t
Compute a prefix length from a variable-length netmask.
ParseHostAndPort(const char *aString, uint16_t aStringLen, const char *& aHost, uint16_t & aHostLen, uint16_t & aPort)
Parse a human-readable string containing a host or IP address and an optional port number (separated by a ':'), supporting the following formats:
ParseHostPortAndInterface(const char *aString, uint16_t aStringLen, const char *& aHost, uint16_t & aHostLen, uint16_t & aPort, const char *& aInterface, uint16_t & aInterfaceLen)
Parse a human-readable string containing a host or IP address, an optional port number (separated by a ':'), and an optional interface name (separated by a ''), supporting the following formats:
RegisterInetLayerErrorFormatter(void)
void
Register a text error formatter for Inet Layer errors.
SocketsIPv4JoinLeaveMulticastGroup(int aSocket, InterfaceId aInterfaceId, const IPAddress & aAddress, int aCommand)
SocketsIPv6JoinLeaveMulticastGroup(int aSocket, InterfaceId aInterfaceId, const IPAddress & aAddress, int aCommand)
SocketsSetMulticastLoopback(int aSocket, bool aLoopback, int aProtocol, int aOption)
SocketsSetMulticastLoopback(int aSocket, IPVersion aIPVersion, bool aLoopback)

Classes

nl::Inet::AsyncDNSResolverSockets

This is an internal class to InetLayer that provides helper APIs for Asynchronous Domain Name System (DNS) resolution in InetLayer.

nl::Inet::DNSResolver

This is an internal class to InetLayer that provides the abstraction of Domain Name System (DNS) resolution in InetLayer.

nl::Inet::EndPointBasis

Basis of internet transport endpoint classes.

nl::Inet::IPAddress

Internet protocol address.

nl::Inet::IPEndPointBasis

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

nl::Inet::IPPacketInfo

Information about an incoming/outgoing message/connection.

nl::Inet::IPPrefix

Internet protocol address prefix.

nl::Inet::InetLayer

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.

nl::Inet::InetLayerBasis

This is the basis class of reference-counted objects managed by an InetLayer object.

nl::Inet::InterfaceAddressIterator

Iterator for the list of system network interface IP addresses.

nl::Inet::InterfaceIterator

Iterator for the list of system network interfaces.

nl::Inet::RawEndPoint

Objects of this class represent raw IP network endpoints.

nl::Inet::SocketEvents

Represent a set of I/O events requested/pending on a socket.

nl::Inet::TCPEndPoint

Objects of this class represent TCP transport endpoints.

nl::Inet::TunEndPoint

Objects of this class represent tunnel interfaces.

nl::Inet::UDPEndPoint

Objects of this class represent UDP transport endpoints.

Unions

nl::Inet::PeerSockAddr

Namespaces

nl::Inet::Platform

Enumerations

@7

 @7

The Inet layer event type definitions.

Properties
kInetEvent_DNSResolveComplete

The event for DNS name resolution completion.

kInetEvent_RawDataReceived

The event for data reception over an InetLayer raw endpoint.

kInetEvent_TCPConnectComplete

The event for TCP connection completion.

kInetEvent_TCPConnectionReceived

The event for TCP connection reception.

kInetEvent_TCPDataReceived

The event for data reception over a TCP connection.

kInetEvent_TCPDataSent

The event for data transmission over a TCP connection.

kInetEvent_TCPError

The event for an error on a TCP connection.

kInetEvent_TunDataReceived

The event for data reception over a Weave tunnel.

kInetEvent_UDPDataReceived

The event for data reception over UDP.

DNSOptions

 DNSOptions

Options controlling how IP address resolution is performed.

Properties
kDNSOption_AddrFamily_Any

Return IPv4 and/or IPv6 addresses in the order returned by the nameserver.

kDNSOption_AddrFamily_IPv4Only

Return only IPv4 addresses.

kDNSOption_AddrFamily_IPv4Preferred

Return IPv4 and/or IPv6 addresses, with IPv4 addresses listed first.

kDNSOption_AddrFamily_IPv6Only

Return only IPv6 addresses.

kDNSOption_AddrFamily_IPv6Preferred

Return IPv4 and/or IPv6 addresses, with IPv6 addresses listed first.

kDNSOption_AddrFamily_Mask

Bits within a DNSOptions integer value representing the desired address family.

kDNSOption_Flags_Mask

Bits within a DNSOptions integer value reserved for flags.

kDNSOption_ValidFlags

Set of all valid DNSOption flags.

IPAddressType

 IPAddressType

Internet protocol address family.

Values of the IPAddressType type are returned by the IPAddress::Type() method. They indicate the address family entailed by the use of the address.

Properties
kIPAddressType_Any

The unspecified internet address (independent of protocol version)

kIPAddressType_IPv4

Internet protocol version 4.

kIPAddressType_IPv6

Internet protocol version 6.

kIPAddressType_Unknown

Not used.

IPProtocol

 IPProtocol

The numbers of some of the protocols in the IP family.

Properties
kIPProtocol_ICMPv4

ICMPv4.

kIPProtocol_ICMPv6

ICMPv6.

IPV6MulticastGroup

 IPV6MulticastGroup

Internet protocol multicast group identifiers.

Values of the IPV6MulticastGroup type are used to call the IPAddress::MakeIPv6Multicast() method. They indicate distinguished group identifiers registered by IETF with IANA.

Properties
kIPV6MulticastGroup_AllRouters

RFC 4291.

IPVersion

 IPVersion

The version of the IP protocol being used.

Properties
kIPVersion_4

IPv4.

kIPVersion_6

IPv6.

IPv6MulticastFlag

 IPv6MulticastFlag

Internet protocol v6 multicast flags.

Values of the IPv6MulticastFlag type are used to call the IPAddress::MakeIPv6Multicast() methods. They indicate the type of IPv6 multicast address to create. These numbers are registered by IETF with IANA.

Properties
kIPv6MulticastFlag_Prefix

The multicast address is (1) based on a network prefix.

kIPv6MulticastFlag_Transient

The multicast address is (1) transient (i.e., dynamically-assigned) rather than (0) well-known (i.e, IANA-assigned).

IPv6MulticastScope

 IPv6MulticastScope

Internet protocol multicast address scope.

Values of the IPv6MulticastScope type are used to call the IPAddress::MakeIPv6Multicast() method. They indicate the routable scope of the multicast group designated by the result. These numbers are registered by IETF with IANA.

Properties
kIPv6MulticastScope_Admin

Realm-local scope.

kIPv6MulticastScope_Global

Global scope.

kIPv6MulticastScope_IPv4

Realm-local ("IPv4") scope.

kIPv6MulticastScope_Interface

Interface-local scope.

kIPv6MulticastScope_Link

Link-local scope.

kIPv6MulticastScope_Organization

Organization-local scope.

kIPv6MulticastScope_Site

Realm-local scope.

Typedefs

InterfaceId

struct netif * InterfaceId

Indicator for system network interfaces.

Portability depends on never witnessing this alias. It may be replaced by a concrete opaque class in the future.

Note Well: The term "interface identifier" also conventionally refers to the lower 64 bits of an IPv6 address in all the relevant IETF standards documents, where the abbreviation "IID" is often used. In this text, the term "interface indicator" refers to values of this type alias.

Variables

sIOCTLSocket

int sIOCTLSocket = -1

Functions

CheckMulticastGroupArgs

INET_ERROR CheckMulticastGroupArgs(
  InterfaceId aInterfaceId,
  const IPAddress & aAddress
)

CloseIOCTLSocket

void CloseIOCTLSocket(
  void
)

Close the global socket created by GetIOCTLSocket.

This function is provided for cases were leaving the global IOCTL socket open would register as a leak.

NB: This function is NOT thread-safe with respect to GetIOCTLSocket.

FormatInetLayerError

bool FormatInetLayerError(
  char *buf,
  uint16_t bufSize,
  int32_t err
)

Given an Inet Layer error, returns a human-readable NULL-terminated C string describing the error.

Details
Parameters
[in] buf
Buffer into which the error string will be placed.
[in] bufSize
Size of the supplied buffer in bytes.
[in] err
The error to be described.
Returns
true If a description string was written into the supplied buffer.
Returns
false If the supplied error was not an Inet Layer error.

GetIOCTLSocket

int GetIOCTLSocket(
  void
)

Returns a global general purpose socket useful for invoking certain network IOCTLs.

This function is thread-safe on all platforms.

GetInterfaceName

NL_DLL_EXPORT INET_ERROR GetInterfaceName(
  InterfaceId intfId,
  char *nameBuf,
  size_t nameBufSize
)

Get the name of a network interface.

Writes the name of the network interface as \c NUL terminated text string
at \c nameBuf. The name of the unspecified network interface is the empty
string.

Details
Parameters
[in] intfId
a network interface
[in] nameBuf
region of memory to write the interface name
[in] nameBufSize
size of the region denoted by nameBuf
Return Values
INET_NO_ERROR
successful result, interface name written
INET_ERROR_NO_MEMORY
name is too large to be written in buffer
other
another system or platform error

INET_IsInetEvent

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

Check to verify if a System::EventType is a valid Inet layer event type.

Details
Parameters
[in] aType
A Weave System Layer event type.
Returns
true if it falls within the enumerated range; otherwise, false.

InterfaceNameToId

NL_DLL_EXPORT INET_ERROR InterfaceNameToId(
  const char *intfName,
  InterfaceId & intfId
)

Search the list of network interfaces for the indicated name.

On LwIP, this function must be called with the LwIP stack lock acquired.

The \c intfId parameter is not updated unless the value returned is
\c INET_NO_ERROR. It should be initialized with \c INET_NULL_INTERFACEID
before calling this function.

Details
Parameters
[in] intfName
name of the network interface to find
[out] intfId
indicator of the network interface to assign
Return Values
INET_NO_ERROR
success, network interface indicated
INET_ERROR_UNKNOWN_INTERFACE
no network interface found
other
another system or platform error

LwIPBindInterface

INET_ERROR LwIPBindInterface(
  struct raw_pcb *aRaw,
  InterfaceId intfId
)

LwIPBindInterface

INET_ERROR LwIPBindInterface(
  struct udp_pcb *aUDP,
  InterfaceId intfId
)

NetmaskToPrefixLength

uint8_t NetmaskToPrefixLength(
  const uint8_t *netmask,
  uint16_t netmaskLen
)

Compute a prefix length from a variable-length netmask.

ParseHostAndPort

INET_ERROR ParseHostAndPort(
  const char *aString,
  uint16_t aStringLen,
  const char *& aHost,
  uint16_t & aHostLen,
  uint16_t & aPort
)

Parse a human-readable string containing a host or IP address and an optional port number (separated by a ':'), supporting the following formats:

  • :
  • :
  • []:

Details
Parameters
[in] aString
The human-reable string to parse.
[in] aStringLen
The length, in characters, of aString.
[out] aHost
A pointer to the host name portion of the parsed string.
[out] aHostLen
The length, in characters, of aHost.
[out] aPort
The port number, if present and successfully parsed; otherwise, 0.
Returns
INET_ERROR_INVALID_HOST_NAME If the input to be parsed is of zero-length or otherwise malformed.
Returns
INET_ERROR_HOST_NAME_TOO_LONG If the host name exceeds 253 characters.
Returns
INET_NO_ERROR On success.

ParseHostPortAndInterface

INET_ERROR ParseHostPortAndInterface(
  const char *aString,
  uint16_t aStringLen,
  const char *& aHost,
  uint16_t & aHostLen,
  uint16_t & aPort,
  const char *& aInterface,
  uint16_t & aInterfaceLen
)

Parse a human-readable string containing a host or IP address, an optional port number (separated by a ':'), and an optional interface name (separated by a ''), supporting the following formats:

  • %
  • :
  • :%
  • %
  • :
  • :%
  • %
  • []:
  • []:%

Details
Parameters
[in] aString
The human-reable string to parse.
[in] aStringLen
The length, in characters, of aString.
[out] aHost
A pointer to the host name portion of the parsed string.
[out] aHostLen
The length, in characters, of aHost.
[out] aPort
The port number, if present and successfully parsed; otherwise, 0.
[out] aInterface
A pointer to the interface portion of the parsed string.
[out] aInterfaceLen
The length, in characters, of aInterface.
Returns
INET_ERROR_INVALID_HOST_NAME If the input to be parsed is of zero-length or otherwise malformed.
Returns
INET_ERROR_HOST_NAME_TOO_LONG If the host name exceeds 253 characters.
Returns
INET_NO_ERROR On success.

RegisterInetLayerErrorFormatter

void RegisterInetLayerErrorFormatter(
  void
)

Register a text error formatter for Inet Layer errors.

SocketsIPv4JoinLeaveMulticastGroup

INET_ERROR SocketsIPv4JoinLeaveMulticastGroup(
  int aSocket,
  InterfaceId aInterfaceId,
  const IPAddress & aAddress,
  int aCommand
)

SocketsIPv6JoinLeaveMulticastGroup

INET_ERROR SocketsIPv6JoinLeaveMulticastGroup(
  int aSocket,
  InterfaceId aInterfaceId,
  const IPAddress & aAddress,
  int aCommand
)

SocketsSetMulticastLoopback

INET_ERROR SocketsSetMulticastLoopback(
  int aSocket,
  bool aLoopback,
  int aProtocol,
  int aOption
)

SocketsSetMulticastLoopback

INET_ERROR SocketsSetMulticastLoopback(
  int aSocket,
  IPVersion aIPVersion,
  bool aLoopback
)