nRF5 IoT SDK  v0.9.0
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
IoT Defines

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

Data Structures

struct  eui64_t
 
union  ipv6_addr_t
 
struct  ipv6_header_t
 
struct  udp6_header_t
 
struct  icmp6_header_t
 

Macros

#define EUI_64_ADDR_SIZE   8
 
#define IPV6_ADDR_SIZE   16
 
#define IPV6_CONTEXT_IDENTIFIER_NONE   0xFF
 
#define IPV6_IID_FLIP_VALUE   0x02
 
#define IPV6_IP_HEADER_SIZE   40
 
#define ICMP6_HEADER_SIZE   4
 
#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 ICMP6_TYPE_DESTINATION_UNREACHABLE   1
 
#define ICMP6_TYPE_PACKET_TOO_LONG   2
 
#define ICMP6_TYPE_TIME_EXCEED   3
 
#define ICMP6_TYPE_PARAMETER_PROBLEM   4
 
#define ICMP6_TYPE_ECHO_REQUEST   128
 
#define ICMP6_TYPE_ECHO_REPLY   129
 
#define ICMP6_TYPE_ROUTER_SOLICITATION   133
 
#define ICMP6_TYPE_ROUTER_ADVERTISEMENT   134
 
#define ICMP6_TYPE_NEIGHBOR_SOLICITATION   135
 
#define ICMP6_TYPE_NEIGHBOR_ADVERTISEMENT   136
 
#define HTONS(val)   ((((uint16_t) (val) & 0xff00) >> 8) | ((((uint16_t) (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 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. Universal/local bit set, according to BT 6LoWPAN draft ch. 3.2.1. 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_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_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 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   4

ICMP header size.

#define ICMP6_TYPE_DESTINATION_UNREACHABLE   1

ICMPv6: Destination unreachable error message.

#define ICMP6_TYPE_ECHO_REPLY   129

ICMPv6: Echo reply message.

#define ICMP6_TYPE_ECHO_REQUEST   128

ICMPv6: Echo request message.

#define ICMP6_TYPE_NEIGHBOR_ADVERTISEMENT   136

ICMPv6: Neighbor discovery, neighbor advertisement message.

#define ICMP6_TYPE_NEIGHBOR_SOLICITATION   135

ICMPv6: Neighbor discovery, neighbor solicitation message.

#define ICMP6_TYPE_PACKET_TOO_LONG   2

ICMPv6: Packet too long error message.

#define ICMP6_TYPE_PARAMETER_PROBLEM   4

ICMPv6: Parameter problem error message.

#define ICMP6_TYPE_ROUTER_ADVERTISEMENT   134

ICMPv6: Neighbor discovery, router advertisement message.

#define ICMP6_TYPE_ROUTER_SOLICITATION   133

ICMPv6: Neighbor discovery, router solicitation message.

#define ICMP6_TYPE_TIME_EXCEED   3

ICMPv6: Time-out error message.

#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_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_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.

EUI 64 data type.

#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. Universal/local bit set, according to BT 6LoWPAN draft ch. 3.2.1.

#define IPV6_IID_FLIP_VALUE   0x02

Value XORed with first byte of EUI-64 to get IID. In some older linux implementation, this value could be 0x03.

#define IPV6_IP_HEADER_SIZE   40

IPv6 header size.

#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.