nRF51 IoT SDK
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Internet Protocol version 6 (IPv6)

The core IPv6 module handles the initialization of various modules and registers a callback function.

To start Nordic's IPv6 Stack, call ipv6_init with the EUI-64 that was constructed using IPV6_EUI64_CREATE_FROM_EUI48. The application must also define an asynchronous callback to receive information about the IPv6 interface.

ipv6_init function initializes the following modules:

Asynchronous Event Notification Callback

IPv6 notifies the application of the following asynchronous events, using the callback function that was registered during initialization:

Event Description
IPV6_EVT_INTERFACE_ADD Notification that an IPv6 interface was added.
IPV6_EVT_INTERFACE_DELETE Notification that an IPv6 interface was deleted.
IPV6_EVT_INTERFACE_RX_DATA Notification of IPv6 data, depending on the configuration (see IPV6_ENABLE_UNSUPPORTED_PROTOCOLS_TO_APPLICATION)

The IPv6 stack supports only ICMPv6 and UDP, but other transport protocols like TCP can be implemented using asynchronous unsupported protocol events. In this case, you must enable IPV6_ENABLE_UNSUPPORTED_PROTOCOLS_TO_APPLICATION.

Code examples

IPv6 initialization

// Bluetooth Device Address.
static ble_gap_addr_t m_my_addr;
void ip_app_handler(iot_interface_t * p_interface, ipv6_event_t * p_event)
{
APPL_LOG("[APPL]: Got IP Application Handler Event on interface 0x%08x\r\n", p_interface);
switch(p_event->event_id)
{
APPL_LOG("[APPL]: New interface added!\r\n");
break;
APPL_LOG("[APPL]: Interface removed!\r\n");
break;
APPL_LOG("[APPL]: Got unsupported protocol data!\r\n");
break;
default:
//Unknown event. Should not happen.
break;
}
}
void ip_stack_init(void)
{
uint32_t err_code;
eui64_t eui64_addr;
ipv6_init_t init_param;
err_code = sd_ble_gap_address_get(&m_my_addr);
APP_ERROR_CHECK(err_code);
m_my_addr.addr[5] = 0x00;
m_my_addr.addr_type = BLE_GAP_ADDR_TYPE_PUBLIC;
err_code = sd_ble_gap_address_set(&m_my_addr);
APP_ERROR_CHECK(err_code);
// Create EUI-64 address from EUI-48
m_my_addr.addr,
m_my_addr.addr_type);
// Set parameters.
init_param.p_eui64 = &eui64_addr;
init_param.event_handler = ip_app_handler;
err_code = ipv6_init(&init_param);
APP_ERROR_CHECK(err_code);
}

Configuration parameters

The following configuration parameters should be defined in sdk_config.h.

IPV6_DISABLE_LOGS

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

IPV6_DISABLE_API_PARAM_CHECK

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

IPV6_MAX_INTERFACE

Maximum number of interfaces that can be managed by the module. This is usually as many 6LoWPAN channels as the application is configured to support.

Restriction Value
Minimum value 1
Maximum value BLE_6LOWPAN_MAX_INTERFACE
Recommended value BLE_6LOWPAN_MAX_INTERFACE
Dependencies BLE_6LOWPAN_MAX_INTERFACE

IPV6_DEFAULT_HOP_LIMIT

Default value of the hop limit in IPv6 header.

Restriction Value
Minimum value 1
Maximum value 255
Dependencies None

IPV6_ENABLE_UNSUPPORTED_PROTOCOLS_TO_APPLICATION

Enables calls of the application event handler if using an unsupported transport protocols (for example, TCP).

Description Value
Enable 1
Disable 0
Dependencies None