nRF5 SDK v16.0.0
Modules | Data Structures | Macros | Enumerations | Variables
IoT Defines

Common IoT definitions that are needed by IoT modules. More...

Modules

 ICMPv6 message types.
 

Data Structures

struct  eui64_t
 
union  ipv6_addr_t
 
struct  ipv6_header_t
 
struct  udp6_header_t
 
struct  icmp6_header_t
 

Macros

#define HTONS(val)   ((uint16_t)((((val) & 0xff00) >> 8) | ((((val) & 0x00ff) << 8))))
 Host to network byte-orders on half word.
 
#define HTONL(val)
 Host to network byte-orders on full word. More...
 
#define NTOHS(val)   HTONS(val)
 Network to host byte-orders on half word.
 
#define NTOHL(val)   HTONL(val)
 Network to host byte-orders on full word.
 
#define EUI_64_ADDR_SIZE   8
 
#define IPV6_ADDR_SIZE   16
 
#define IPV6_CONTEXT_IDENTIFIER_NONE   0xFF
 
#define IPV6_IID_FLIP_VALUE   0x00
 
#define IPV6_LL_ADDR_SIZE   6
 
#define IPV6_IP_HEADER_SIZE   40
 
#define ICMP6_HEADER_SIZE   8
 
#define UDP_HEADER_SIZE   8
 
#define COAP_HEADER_SIZE   4
 
#define IPV6_DEFAULT_VER_TC   0x60
 
#define IPV6_DEFAULT_TC_FL   0x00
 
#define IPV6_DEFAULT_FL   0x00
 
#define IPV6_NEXT_HEADER_TCP   6
 
#define IPV6_NEXT_HEADER_UDP   17
 
#define IPV6_NEXT_HEADER_ICMP6   58
 
#define IPV6_NEXT_HEADER_RESERVED   255
 
#define IPV6_ADDRESS_INITIALIZE(ADDR)   memset((ADDR)->u8, 0, IPV6_ADDR_SIZE)
 Initializes IPv6 address.
 
#define IPV6_ADDRESS_PREFIX_CMP(prefix, prefix2, length)
 Checks if prefixes match. Length in bits. More...
 
#define IPV6_ADDRESS_PREFIX_SET(pfx_to, pfx_from, length)
 Sets address prefix. Length in bits. More...
 
#define IPV6_EUI64_CREATE_FROM_EUI48(eui64, eui48, addr_type)
 Creates EUI-64 address from EUI-48. More...
 
#define IPV6_CREATE_LINK_LOCAL_FROM_EUI64(addr, eui64)
 Creates link-local address from EUI-64. More...
 
#define IPV6_ADDRESS_IS_LINK_LOCAL(addr)   ((addr)->u16[0] == HTONS(0xfe80))
 Checks if address is a link-local address.
 
#define IPV6_ADDRESS_IS_MULTICAST(addr)   ((addr)->u8[0] == 0xff)
 Checks if address is a multicast address.
 
#define IPV6_ADDRESS_IS_ALL_NODE(addr)
 Checks if address is a multicast all-node address. More...
 
#define IPV6_ADDRESS_IS_ALL_ROUTER(addr)
 Checks if address is a multicast all-router address. More...
 
#define IPV6_ADDRESS_IS_MLDV2_MCAST(addr)
 Checks if address is a multicast MLDv2 address. More...
 
#define IPV6_ADDRESS_IS_MULTICAST_SOLICITED_NODE(addr)
 Checks if address is a multicast all-node address. More...
 
#define IPV6_ADDRESS_IS_UNSPECIFIED(addr)
 Checks if address is an unspecified address. More...
 
#define IPV6_ADDRESS_CMP(addr1, addr2)   memcmp((addr1)->u8, (addr2)->u8, IPV6_ADDR_SIZE)
 Compares two IPv6 addresses.
 
#define IPV6_ADDRESS_SWAP(addr1, addr2)
 Swaps two IPv6 addresses. More...
 
#define IPV6_ADDRESS_LOG(addr)
 Prints an IPV6 address. More...
 
#define IPV6_ADDR_ANY   &ipv6_addr_any
 
#define EUI64_LOCAL_IID   &eui64_local_iid
 

Enumerations

enum  ipv6_addr_state_t {
  IPV6_ADDR_STATE_UNUSED = 0,
  IPV6_ADDR_STATE_TENTATIVE,
  IPV6_ADDR_STATE_PREFERRED,
  IPV6_ADDR_STATE_DEPRECATED
}
 IPv6 address states. More...
 

Variables

ipv6_addr_t ipv6_addr_any
 
eui64_t eui64_local_iid
 

Detailed Description

Common IoT definitions that are needed by IoT modules.

This module abstracts common data structures and constants related to IoT. These definitions can be used by all the IoT modules.

Macro Definition Documentation

#define COAP_HEADER_SIZE   4

CoAP header size.

#define EUI64_LOCAL_IID   &eui64_local_iid

EUI-64 IID of the device.

#define EUI_64_ADDR_SIZE   8

Size of EUI-64.

#define HTONL (   val)
Value:
((((uint32_t) (val) & 0xff000000) >> 24) | \
(((uint32_t) (val) & 0x00ff0000) >> 8) | \
(((uint32_t) (val) & 0x0000ff00) << 8) | \
(((uint32_t) (val) & 0x000000ff) << 24))

Host to network byte-orders on full word.

#define ICMP6_HEADER_SIZE   8

ICMP header size.

#define IPV6_ADDR_ANY   &ipv6_addr_any

IPV6 address represents any address.

#define IPV6_ADDR_SIZE   16

Size of IPv6 128-bit address.

#define IPV6_ADDRESS_IS_ALL_NODE (   addr)
Value:
(((addr)->u32[0] == HTONL(0xff020000)) && \
((addr)->u32[1] == 0) && \
((addr)->u32[2] == 0) && \
((addr)->u32[3] == HTONL(0x01)))

Checks if address is a multicast all-node address.

#define IPV6_ADDRESS_IS_ALL_ROUTER (   addr)
Value:
(((addr)->u32[0] == HTONL(0xff020000)) && \
((addr)->u32[1] == 0) && \
((addr)->u32[2] == 0) && \
((addr)->u32[3] == HTONL(0x02)))

Checks if address is a multicast all-router address.

#define IPV6_ADDRESS_IS_MLDV2_MCAST (   addr)
Value:
(((addr)->u32[0] == HTONL(0xff020000)) && \
((addr)->u32[1] == 0) && \
((addr)->u32[2] == 0) && \
((addr)->u32[3] == HTONL(0x16)))

Checks if address is a multicast MLDv2 address.

#define IPV6_ADDRESS_IS_MULTICAST_SOLICITED_NODE (   addr)
Value:
(((addr)->u32[0] == HTONL(0xff020000)) && \
((addr)->u32[1] == 0) && \
((addr)->u32[2] == HTONL(0x00000001)) && \
((addr)->u8[12] == 0xFF))

Checks if address is a multicast all-node address.

#define IPV6_ADDRESS_IS_UNSPECIFIED (   addr)
Value:
(((addr)->u32[0] == 0) && \
((addr)->u32[1] == 0) && \
((addr)->u32[2] == 0) && \
((addr)->u32[3] == 0) \
)

Checks if address is an unspecified address.

#define IPV6_ADDRESS_LOG (   addr)
Value:
NRF_LOG_RAW_INFO("%02x%02x:%02x%02x:",(addr).u8[0],(addr).u8[1],(addr).u8[2],(addr).u8[3]); \
NRF_LOG_RAW_INFO("%02x%02x:%02x%02x:",(addr).u8[4],(addr).u8[5],(addr).u8[6],(addr).u8[7]); \
NRF_LOG_RAW_INFO("%02x%02x:%02x%02x:",(addr).u8[8],(addr).u8[9],(addr).u8[10],(addr).u8[11]); \
NRF_LOG_RAW_INFO("%02x%02x:%02x%02x\r\n",(addr).u8[12],(addr).u8[13],(addr).u8[14],(addr).u8[15]);

Prints an IPV6 address.

EUI 64 data type.

#define IPV6_ADDRESS_PREFIX_CMP (   prefix,
  prefix2,
  length 
)
Value:
((0 == memcmp(prefix, prefix2, (length>>3) - ((length & 0x7) ? 1 : 0) )) && \
(((prefix[(length>>3)] & (((0xff00) >> (length & 0x7))))) == \
(prefix2[(length>>3)] & (((0xff00) >> (length & 0x7))))) \
)

Checks if prefixes match. Length in bits.

#define IPV6_ADDRESS_PREFIX_SET (   pfx_to,
  pfx_from,
  length 
)
Value:
do { \
memcpy(pfx_to, pfx_from, length>>3); \
if (length & 0x7) { \
uint8_t mask = ((0xff00) >> (length & 0x7)); \
uint8_t last = pfx_from[length>>3] & mask; \
pfx_to[length>>3] &= ~mask; \
pfx_to[length>>3] |= last; \
} \
} while (0)

Sets address prefix. Length in bits.

#define IPV6_ADDRESS_SWAP (   addr1,
  addr2 
)
Value:
do { \
ipv6_addr_t addr_temp; \
\
addr_temp = *addr1; \
*addr1 = *addr2; \
*addr2 = addr_temp; \
} while (0);

Swaps two IPv6 addresses.

#define IPV6_CONTEXT_IDENTIFIER_NONE   0xFF

No context identifier in use.

#define IPV6_CREATE_LINK_LOCAL_FROM_EUI64 (   addr,
  eui64 
)
Value:
(addr)->u32[0] = HTONL(0xFE800000); \
(addr)->u32[1] = 0; \
memcpy((addr)->u8 + 8, eui64, EUI_64_ADDR_SIZE); \
(addr)->u8[8] ^= IPV6_IID_FLIP_VALUE;

Creates link-local address from EUI-64.

#define IPV6_DEFAULT_FL   0x00

Default value of the flow label's two last bytes in IPv6 header.

#define IPV6_DEFAULT_TC_FL   0x00

Default value of traffic class and flow label fields in IPv6 header.

#define IPV6_DEFAULT_VER_TC   0x60

Default value of version and traffic class fields in IPv6 header.

#define IPV6_EUI64_CREATE_FROM_EUI48 (   eui64,
  eui48,
  addr_type 
)
Value:
eui64[0] = eui48[5]; \
eui64[1] = eui48[4]; \
eui64[2] = eui48[3]; \
eui64[3] = 0xFF; \
eui64[4] = 0xFE; \
eui64[5] = eui48[2]; \
eui64[6] = eui48[1]; \
eui64[7] = eui48[0]; \
if ((addr_type) == BLE_GAP_ADDR_TYPE_PUBLIC) \
{ \
eui64[0] &= ~(IPV6_IID_FLIP_VALUE); \
} \
else \
{ \
eui64[0] |= IPV6_IID_FLIP_VALUE; \
}

Creates EUI-64 address from EUI-48.

#define IPV6_IID_FLIP_VALUE   0x00

RFC 7668 specifies that no bit is flipped when IID is generated from a Bluetooth Device Address.

#define IPV6_IP_HEADER_SIZE   40

IPv6 header size.

#define IPV6_LL_ADDR_SIZE   6

The link-layer address size used in Neighbor Discovery messages.

#define IPV6_NEXT_HEADER_ICMP6   58

ICMPv6: protocol number.

#define IPV6_NEXT_HEADER_RESERVED   255

Reserved value.

#define IPV6_NEXT_HEADER_TCP   6

TCP: protocol number.

#define IPV6_NEXT_HEADER_UDP   17

UDP: protocol number.

#define UDP_HEADER_SIZE   8

UDP header size.

Enumeration Type Documentation

IPv6 address states.

Enumerator
IPV6_ADDR_STATE_UNUSED 

IPv6 address is unused.

IPV6_ADDR_STATE_TENTATIVE 

IPv6 tentative address; DUD must be performed.

IPV6_ADDR_STATE_PREFERRED 

IPv6 preferred address; normal. state.

IPV6_ADDR_STATE_DEPRECATED 

IPv6 deprecated address.

Variable Documentation

eui64_t eui64_local_iid

External variable assumed to be implemented in the application with desired EUI-64 to be used as the IID for SLAAC.


Documentation feedback | Developer Zone | Subscribe | Updated