nRF5 IoT SDK
v0.9.0
|
The ICMPv6 module provides functionality for handling Internet Control Message Protocol messages. Depending on the configuration, it will forward packets to the application handler (if declared). The module also implements minimal functionality for neighbor discovery such as generating and sending registration messages (neighbor solicitation with ARO option), and for router solicitation for finding routers. It also implements minimal processing of Router Advertisement messages by getting the 6LoWPAN context option, which is needed for correct compression and decompression. This feature is therefore implemented internally.
Neighbor discovery parameters and data structures such as the routing table, neighbor cache, or prefix cache can easily be managed in the application layer.
Echo request messages are handled by the IPv6 stack internally whenever ICMP6_ENABLE_HANDLE_ECHO_REQUEST_TO_APPLICATION is not set.
Asynchronous callback is used to notify the application of ICMP packets that are received. By default, the application does not receive notifications of echo requests or errors when using ICMP. However, these notifications can be enabled with ICMP6_ENABLE_ALL_MESSAGES_TO_APPLICATION if the application needs to handle them. You can also enable only neighbor discovery messages by setting ICMP6_ENABLE_ND6_MESSAGES_TO_APPLICATION.
The application can also handle echo request itself and disable the internal echo response procedure by using the ICMP6_ENABLE_HANDLE_ECHO_REQUEST_TO_APPLICATION flag.
ICMPv6 callback also informs about the internal process result, which can be either NRF_SUCCESS or one of the following errors:
Process result | Description |
---|---|
ICMP6_UNHANDLED_PACKET_TYPE | ICMPv6 packet type is unknown. |
ICMP6_BAD_CHECKSUM | Calculated checksum does not match. |
ICMP6_MALFORMED_PACKET | ICMPv6 packet is malformed. |
ICMP6_INVALID_PACKET_DATA | Data inside ICMPv6 packet is incorrect. |
This code example shows how to send an echo request message to a remote node on a specific interface (mp_interface). The application must allocate a packet buffer for it and optionally fill the payload. In the example below, 10 bytes of byte 0xA5 will be sent as additional data.
This code example shows how to find routers on the link using a router solicitation message. All buffers are allocated inside a function. If a router is available on the link, it should send a router advertisement message.
This code example shows how to register an IPv6 address (source address in the request) in the default router (m_router_addr). The following example tries to register its global address for one hour (60 minutes).
The following configuration parameters should be defined in sdk_config.h
.
Disables debug tracing in the module. To enable tracing, this flag must be set to 0 and ENABLE_DEBUG_LOG_SUPPORT must be set to 1.
Description | Value |
---|---|
Enable debug trace | 0 |
Disable debug trace | 1 |
Dependencies | ENABLE_DEBUG_LOG_SUPPORT |
Disables API parameter checks in the module. Set this define to 1 to disable checks on API parameters in the module.
API parameter checks are added to ensure that the correct parameters are passed to the module. These checks are useful during development phase, but they might be redundant when the application is finalized. Disabling these checks might improve performance.
Description | Value |
---|---|
Enable API parameters check | 0 |
Disable API parameters check | 1 |
Dependencies | None |
Enables calls to the ICMPv6 event handler when a neighbor discovery message is received.
Description | Value |
---|---|
Enable | 1 |
Disable | 0 |
Dependencies | None |
Enables calls to the ICMPv6 event handler when an ICMPv6 message is received.
Description | Value |
---|---|
Enable | 1 |
Disable | 0 |
Dependencies | None |
Enables the handling of echo requests by the application. Set this parameter to 1 to disable the internal sending of echo responses after processing ICMP packets in the application (if ICMP6_ENABLE_ALL_MESSAGES_TO_APPLICATION is set). Set it to 0 to make sure that echo requests are handled internally and the ICMPv6 module sends automatic replies after processing ICMP packets in the application.
If this parameter is set to 1, the application is responsible for processing echo requests, and it should also generate echo responses.
Description | Value |
---|---|
Enable | 1 |
Disable | 0 |
Dependencies | None |