nd.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Martine Lenders <mlenders@inf.fu-berlin.de>
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
22 #ifndef NET_SIXLOWPAN_ND_H
23 #define NET_SIXLOWPAN_ND_H
24 
25 #include <stdint.h>
26 
27 #include "byteorder.h"
28 #include "net/eui64.h"
29 #include "net/ipv6/addr.h"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
40 #define SIXLOWPAN_ND_OPT_6CTX_LEN_MIN (2U)
41 #define SIXLOWPAN_ND_OPT_6CTX_LEN_MAX (3U)
42 #define SIXLOWPAN_ND_OPT_AR_LEN (2U)
43 #define SIXLOWPAN_ND_OPT_ABR_LEN (3U)
44 
57 #define SIXLOWPAN_ND_OPT_ABR_LTIME_DEFAULT (10000U)
58 
65 #define SIXLOWPAN_ND_STATUS_SUCCESS (0)
66 #define SIXLOWPAN_ND_STATUS_DUP (1)
67 #define SIXLOWPAN_ND_STATUS_NC_FULL (2)
76 #define SIXLOWPAN_ND_OPT_6CTX_FLAGS_MASK (0x1f)
77 #define SIXLOWPAN_ND_OPT_6CTX_FLAGS_C (0x10)
78 #define SIXLOWPAN_ND_OPT_6CTX_FLAGS_CID_MASK (0x0f)
88 #define SIXLOWPAN_ND_MIN_CTX_CHANGE_SEC_DELAY (300U)
96 #define SIXLOWPAN_ND_MAX_RA_NUMOF (3U)
97 #define SIXLOWPAN_ND_MIN_MS_DELAY_BETWEEN_RAS (10000U)
98 #define SIXLOWPAN_ND_MAX_RA_MS_DELAY (2000U)
99 #define SIXLOWPAN_ND_TENTATIVE_NCE_SEC_LTIME (20U)
107 #define SIXLOWPAN_ND_MULTIHOP_HL (64U)
122 #define SIXLOWPAN_ND_REG_TRANSMIT_NUMOF (3U)
123 
126 #define SIXLOWPAN_ND_RS_MSEC_INTERVAL (10000U)
127 #define SIXLOWPAN_ND_MAX_RS_NUMOF (3U)
131 #define SIXLOWPAN_ND_MAX_RS_SEC_INTERVAL (60U)
132 
140 typedef struct __attribute__((packed)) {
141  uint8_t type;
142  uint8_t code;
144  uint8_t status;
145  uint8_t resv;
150 
157 typedef struct __attribute__((packed)) {
158  uint8_t type;
159  uint8_t len;
160  uint8_t status;
162  uint8_t resv[3];
166 
173 typedef struct __attribute__((packed)) {
174  uint8_t type;
175  uint8_t len;
176  uint8_t ctx_len;
177  uint8_t resv_c_cid;
181 
188 typedef struct __attribute__((packed)) {
189  uint8_t type;
190  uint8_t len;
196 
206 static inline bool sixlowpan_nd_opt_6ctx_is_comp(const sixlowpan_nd_opt_6ctx_t *ctx_opt)
207 {
208  return (bool)(ctx_opt->resv_c_cid & SIXLOWPAN_ND_OPT_6CTX_FLAGS_C);
209 }
210 
218 static inline uint8_t sixlowpan_nd_opt_6ctx_get_cid(const sixlowpan_nd_opt_6ctx_t *ctx_opt)
219 {
221 }
222 
229 static inline void sixlowpan_nd_opt_6ctx_set_cid(sixlowpan_nd_opt_6ctx_t *ctx_opt, uint8_t cid)
230 {
233 }
234 
243 static inline uint32_t sixlowpan_nd_opt_abr_get_version(const sixlowpan_nd_opt_abr_t *abr_opt)
244 {
245  return ((uint32_t)byteorder_ntohs(abr_opt->vlow)) |
246  (((uint32_t)byteorder_ntohs(abr_opt->vhigh)) << 16);
247 }
248 
256  uint32_t version)
257 {
258  abr_opt->vlow = byteorder_htons((uint16_t)(version & 0xffff));
259  abr_opt->vhigh = byteorder_htons((uint16_t)(version >> 16));
260 }
261 
262 #ifdef __cplusplus
263 }
264 #endif
265 
266 #endif /* NET_SIXLOWPAN_ND_H */
267 
sixlowpan_nd_opt_6ctx_t::len
uint8_t len
length in units of 8 octets
Definition: nd.h:175
sixlowpan_nd_opt_ar_t::ltime
network_uint16_t ltime
registration lifetime
Definition: nd.h:163
sixlowpan_nd_da_t::code
uint8_t code
message code
Definition: nd.h:142
sixlowpan_nd_opt_abr_t
Authoritative border router option format.
Definition: nd.h:188
sixlowpan_nd_opt_ar_t
Address registration option format.
Definition: nd.h:157
sixlowpan_nd_opt_abr_get_version
static uint32_t sixlowpan_nd_opt_abr_get_version(const sixlowpan_nd_opt_abr_t *abr_opt)
Gets the version in correct order from an Authoritative Border Router option.
Definition: nd.h:243
byteorder.h
Functions to work with different byte orders.
be_uint16_t
A 16 bit integer in big endian aka network byte order.
Definition: byteorder.h:77
ipv6_addr_t
Data type to represent an IPv6 address.
Definition: addr.h:74
sixlowpan_nd_da_t
Duplicate address request and confirmation message format.
Definition: nd.h:140
addr.h
Definitions for IPv6 addresses.
sixlowpan_nd_opt_ar_t::status
uint8_t status
indicates registration status in NA response; must be 0 in NS messages
Definition: nd.h:160
sixlowpan_nd_opt_6ctx_get_cid
static uint8_t sixlowpan_nd_opt_6ctx_get_cid(const sixlowpan_nd_opt_6ctx_t *ctx_opt)
Gets a CID (context identifier) from a 6LoWPAN context option.
Definition: nd.h:218
sixlowpan_nd_opt_abr_set_version
static void sixlowpan_nd_opt_abr_set_version(sixlowpan_nd_opt_abr_t *abr_opt, uint32_t version)
Sets the version of an Authoritative Border Router option.
Definition: nd.h:255
sixlowpan_nd_opt_6ctx_is_comp
static bool sixlowpan_nd_opt_6ctx_is_comp(const sixlowpan_nd_opt_6ctx_t *ctx_opt)
Checks if a 6LoWPAN context in an 6LoWPAN context option is valid for compression.
Definition: nd.h:206
sixlowpan_nd_opt_6ctx_t
6LoWPAN context option format
Definition: nd.h:173
sixlowpan_nd_opt_abr_t::type
uint8_t type
option type
Definition: nd.h:189
sixlowpan_nd_da_t::eui64
eui64_t eui64
EUI-64.
Definition: nd.h:147
sixlowpan_nd_opt_6ctx_t::ltime
network_uint16_t ltime
valid lifetime
Definition: nd.h:179
sixlowpan_nd_opt_6ctx_t::ctx_len
uint8_t ctx_len
context length
Definition: nd.h:176
sixlowpan_nd_opt_abr_t::ltime
network_uint16_t ltime
valid lifetime
Definition: nd.h:193
sixlowpan_nd_da_t::csum
network_uint16_t csum
checksum
Definition: nd.h:143
sixlowpan_nd_opt_ar_t::eui64
eui64_t eui64
EUI-64.
Definition: nd.h:164
byteorder_htons
static network_uint16_t byteorder_htons(uint16_t v)
Convert from host byte order to network byte order, 16 bit.
Definition: byteorder.h:437
sixlowpan_nd_da_t::type
uint8_t type
message type
Definition: nd.h:141
sixlowpan_nd_da_t::status
uint8_t status
indicates registration status in DAC; must be 0 in DAR.
Definition: nd.h:144
sixlowpan_nd_opt_6ctx_t::resv_c_cid
uint8_t resv_c_cid
3-bit reserved, 1-bit c flag, 4 bit CID
Definition: nd.h:177
sixlowpan_nd_da_t::addr
ipv6_addr_t addr
registered address
Definition: nd.h:148
sixlowpan_nd_opt_6ctx_t::type
uint8_t type
option type
Definition: nd.h:174
sixlowpan_nd_opt_abr_t::braddr
ipv6_addr_t braddr
6LoWPAN border router address
Definition: nd.h:194
sixlowpan_nd_opt_abr_t::vhigh
network_uint16_t vhigh
version high
Definition: nd.h:192
SIXLOWPAN_ND_OPT_6CTX_FLAGS_CID_MASK
#define SIXLOWPAN_ND_OPT_6CTX_FLAGS_CID_MASK
mask for CID
Definition: nd.h:78
sixlowpan_nd_opt_abr_t::len
uint8_t len
length in units of 8 octets
Definition: nd.h:190
SIXLOWPAN_ND_OPT_6CTX_FLAGS_C
#define SIXLOWPAN_ND_OPT_6CTX_FLAGS_C
valid for compression
Definition: nd.h:77
sixlowpan_nd_opt_ar_t::type
uint8_t type
option type
Definition: nd.h:158
sixlowpan_nd_opt_6ctx_t::resv
network_uint16_t resv
reserved field
Definition: nd.h:178
sixlowpan_nd_opt_abr_t::vlow
network_uint16_t vlow
version low
Definition: nd.h:191
sixlowpan_nd_opt_6ctx_set_cid
static void sixlowpan_nd_opt_6ctx_set_cid(sixlowpan_nd_opt_6ctx_t *ctx_opt, uint8_t cid)
Sets a CID (context identifier) for a 6LoWPAN context option.
Definition: nd.h:229
byteorder_ntohs
static uint16_t byteorder_ntohs(network_uint16_t v)
Convert from network byte order to host byte order, 16 bit.
Definition: byteorder.h:458
eui64_t
Data type to represent an EUI-64.
Definition: eui64.h:55
sixlowpan_nd_da_t::ltime
network_uint16_t ltime
registration lifetime
Definition: nd.h:146
eui64.h
EUI-64 data type definition.
sixlowpan_nd_da_t::resv
uint8_t resv
reserved field
Definition: nd.h:145
sixlowpan_nd_opt_ar_t::len
uint8_t len
length in units of 8 octets
Definition: nd.h:159