nd.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2015 Martine Lenders <mlenders@inf.fu-berlin.de>
3  * SPDX-License-Identifier: LGPL-2.1-only
4  */
5 
6 #pragma once
7 
22 #include <stdint.h>
23 
24 #include "byteorder.h"
25 #include "net/eui64.h"
26 #include "net/ipv6/addr.h"
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
37 #define SIXLOWPAN_ND_OPT_6CTX_LEN_MIN (2U)
38 #define SIXLOWPAN_ND_OPT_6CTX_LEN_MAX (3U)
39 #define SIXLOWPAN_ND_OPT_AR_LEN (2U)
40 #define SIXLOWPAN_ND_OPT_ABR_LEN (3U)
54 #define SIXLOWPAN_ND_OPT_ABR_LTIME_DEFAULT (10000U)
63 #define SIXLOWPAN_ND_STATUS_SUCCESS (0)
64 #define SIXLOWPAN_ND_STATUS_DUP (1)
65 #define SIXLOWPAN_ND_STATUS_NC_FULL (2)
74 #define SIXLOWPAN_ND_OPT_6CTX_FLAGS_MASK (0x1f)
75 #define SIXLOWPAN_ND_OPT_6CTX_FLAGS_C (0x10)
76 #define SIXLOWPAN_ND_OPT_6CTX_FLAGS_CID_MASK (0x0f)
86 #define SIXLOWPAN_ND_MIN_CTX_CHANGE_SEC_DELAY (300U)
94 #define SIXLOWPAN_ND_MAX_RA_NUMOF (3U)
95 #define SIXLOWPAN_ND_MIN_MS_DELAY_BETWEEN_RAS (10000U)
96 #define SIXLOWPAN_ND_MAX_RA_MS_DELAY (2000U)
97 #define SIXLOWPAN_ND_TENTATIVE_NCE_SEC_LTIME (20U)
105 #define SIXLOWPAN_ND_MULTIHOP_HL (64U)
120 #define SIXLOWPAN_ND_REG_TRANSMIT_NUMOF (3U)
124 #define SIXLOWPAN_ND_RS_MSEC_INTERVAL (10000U)
125 #define SIXLOWPAN_ND_MAX_RS_NUMOF (3U)
129 #define SIXLOWPAN_ND_MAX_RS_SEC_INTERVAL (60U)
138 typedef struct __attribute__((packed)) {
139  uint8_t type;
140  uint8_t code;
142  uint8_t status;
143  uint8_t resv;
148 
155 typedef struct __attribute__((packed)) {
156  uint8_t type;
157  uint8_t len;
158  uint8_t status;
160  uint8_t resv[3];
164 
171 typedef struct __attribute__((packed)) {
172  uint8_t type;
173  uint8_t len;
174  uint8_t ctx_len;
175  uint8_t resv_c_cid;
179 
186 typedef struct __attribute__((packed)) {
187  uint8_t type;
188  uint8_t len;
194 
204 static inline bool sixlowpan_nd_opt_6ctx_is_comp(const sixlowpan_nd_opt_6ctx_t *ctx_opt)
205 {
206  return (bool)(ctx_opt->resv_c_cid & SIXLOWPAN_ND_OPT_6CTX_FLAGS_C);
207 }
208 
216 static inline uint8_t sixlowpan_nd_opt_6ctx_get_cid(const sixlowpan_nd_opt_6ctx_t *ctx_opt)
217 {
219 }
220 
227 static inline void sixlowpan_nd_opt_6ctx_set_cid(sixlowpan_nd_opt_6ctx_t *ctx_opt, uint8_t cid)
228 {
231 }
232 
241 static inline uint32_t sixlowpan_nd_opt_abr_get_version(const sixlowpan_nd_opt_abr_t *abr_opt)
242 {
243  return ((uint32_t)byteorder_ntohs(abr_opt->vlow)) |
244  (((uint32_t)byteorder_ntohs(abr_opt->vhigh)) << 16);
245 }
246 
254  uint32_t version)
255 {
256  abr_opt->vlow = byteorder_htons((uint16_t)(version & 0xffff));
257  abr_opt->vhigh = byteorder_htons((uint16_t)(version >> 16));
258 }
259 
268 static inline uint16_t gnrc_sixlowpan_nd_opt_get_ltime(const sixlowpan_nd_opt_abr_t *abr_opt)
269 {
270  uint16_t ltime = byteorder_ntohs(abr_opt->ltime);
271  return (ltime == 0) ? SIXLOWPAN_ND_OPT_ABR_LTIME_DEFAULT : ltime;
272 }
273 
274 #ifdef __cplusplus
275 }
276 #endif
277 
Functions to work with different byte orders.
static network_uint16_t byteorder_htons(uint16_t v)
Convert from host byte order to network byte order, 16 bit.
Definition: byteorder.h:481
static uint16_t byteorder_ntohs(network_uint16_t v)
Convert from network byte order to host byte order, 16 bit.
Definition: byteorder.h:502
EUI-64 data type definition.
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:216
#define SIXLOWPAN_ND_OPT_ABR_LTIME_DEFAULT
Valid lifetime (in minutes) assumed if sixlowpan_nd_opt_abr_t::ltime is 0.
Definition: nd.h:54
#define SIXLOWPAN_ND_OPT_6CTX_FLAGS_C
valid for compression
Definition: nd.h:75
static uint16_t gnrc_sixlowpan_nd_opt_get_ltime(const sixlowpan_nd_opt_abr_t *abr_opt)
Get the lifetime of an Authoritative Border Router from an ABR option.
Definition: nd.h:268
#define SIXLOWPAN_ND_OPT_6CTX_FLAGS_CID_MASK
mask for CID
Definition: nd.h:76
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:204
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:227
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:241
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:253
Definitions for IPv6 addresses.
Duplicate address request and confirmation message format.
Definition: nd.h:138
uint8_t code
message code
Definition: nd.h:140
eui64_t eui64
EUI-64.
Definition: nd.h:145
uint8_t status
indicates registration status in DAC; must be 0 in DAR.
Definition: nd.h:142
uint8_t resv
reserved field
Definition: nd.h:143
network_uint16_t ltime
registration lifetime
Definition: nd.h:144
ipv6_addr_t addr
registered address
Definition: nd.h:146
network_uint16_t csum
checksum
Definition: nd.h:141
uint8_t type
message type
Definition: nd.h:139
6LoWPAN context option format
Definition: nd.h:171
uint8_t type
option type
Definition: nd.h:172
uint8_t ctx_len
context length
Definition: nd.h:174
network_uint16_t ltime
valid lifetime
Definition: nd.h:177
uint8_t len
length in units of 8 octets
Definition: nd.h:173
network_uint16_t resv
reserved field
Definition: nd.h:176
uint8_t resv_c_cid
3-bit reserved, 1-bit c flag, 4 bit CID
Definition: nd.h:175
Authoritative border router option format.
Definition: nd.h:186
network_uint16_t vhigh
version high
Definition: nd.h:190
ipv6_addr_t braddr
6LoWPAN border router address
Definition: nd.h:192
network_uint16_t vlow
version low
Definition: nd.h:189
network_uint16_t ltime
valid lifetime
Definition: nd.h:191
uint8_t type
option type
Definition: nd.h:187
uint8_t len
length in units of 8 octets
Definition: nd.h:188
Address registration option format.
Definition: nd.h:155
uint8_t len
length in units of 8 octets
Definition: nd.h:157
uint8_t status
indicates registration status in NA response; must be 0 in NS messages
Definition: nd.h:158
network_uint16_t ltime
registration lifetime
Definition: nd.h:161
eui64_t eui64
EUI-64.
Definition: nd.h:162
uint8_t type
option type
Definition: nd.h:156
A 16 bit integer in big endian aka network byte order.
Definition: byteorder.h:70
Data type to represent an EUI-64.
Definition: eui64.h:52
Data type to represent an IPv6 address.
Definition: addr.h:64