nc.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2017 Freie Universität Berlin
3  * SPDX-License-Identifier: LGPL-2.1-only
4  */
5 
6 #pragma once
7 
20 #include <stdbool.h>
21 #include <stdint.h>
22 
23 #include "net/eui64.h"
24 #include "net/gnrc/netif/hdr.h"
25 #include "net/gnrc/ipv6/nib/conf.h"
26 #include "net/ipv6/addr.h"
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
44 #define GNRC_IPV6_NIB_NC_INFO_NUD_STATE_MASK (0x0007)
45 
49 #define GNRC_IPV6_NIB_NC_INFO_NUD_STATE_UNMANAGED (0x0000)
50 
54 #define GNRC_IPV6_NIB_NC_INFO_NUD_STATE_UNREACHABLE (0x0001)
55 
59 #define GNRC_IPV6_NIB_NC_INFO_NUD_STATE_INCOMPLETE (0x0002)
60 
64 #define GNRC_IPV6_NIB_NC_INFO_NUD_STATE_STALE (0x0003)
65 
69 #define GNRC_IPV6_NIB_NC_INFO_NUD_STATE_DELAY (0x0004)
70 
74 #define GNRC_IPV6_NIB_NC_INFO_NUD_STATE_PROBE (0x0005)
75 
79 #define GNRC_IPV6_NIB_NC_INFO_NUD_STATE_REACHABLE (0x0006)
80 
91 #define GNRC_IPV6_NIB_NC_INFO_IS_ROUTER (0x0008)
92 
96 #define GNRC_IPV6_NIB_NC_INFO_IFACE_MASK (0x01f0)
97 
101 #define GNRC_IPV6_NIB_NC_INFO_IFACE_POS (4)
102 
108 #define GNRC_IPV6_NIB_NC_INFO_AR_STATE_MASK (0x0600)
109 
113 #define GNRC_IPV6_NIB_NC_INFO_AR_STATE_POS (9)
114 
118 #define GNRC_IPV6_NIB_NC_INFO_AR_STATE_GC (0x0000)
119 
123 #define GNRC_IPV6_NIB_NC_INFO_AR_STATE_TENTATIVE (0x0200)
124 
128 #define GNRC_IPV6_NIB_NC_INFO_AR_STATE_REGISTERED (0x0400)
129 
133 #define GNRC_IPV6_NIB_NC_INFO_AR_STATE_MANUAL (0x0600)
139 typedef struct {
149  uint16_t info;
150  uint8_t l2addr_len;
152 
160 static inline unsigned gnrc_ipv6_nib_nc_get_nud_state(const gnrc_ipv6_nib_nc_t *entry)
161 {
162  return (entry->info & GNRC_IPV6_NIB_NC_INFO_NUD_STATE_MASK);
163 }
164 
173 static inline bool gnrc_ipv6_nib_nc_is_router(const gnrc_ipv6_nib_nc_t *entry)
174 {
175  return (entry->info & GNRC_IPV6_NIB_NC_INFO_IS_ROUTER);
176 }
177 
186 static inline unsigned gnrc_ipv6_nib_nc_get_iface(const gnrc_ipv6_nib_nc_t *entry)
187 {
188  return (entry->info & GNRC_IPV6_NIB_NC_INFO_IFACE_MASK) >>
190 }
191 
199 static inline unsigned gnrc_ipv6_nib_nc_get_ar_state(const gnrc_ipv6_nib_nc_t *entry)
200 {
201  return (entry->info & GNRC_IPV6_NIB_NC_INFO_AR_STATE_MASK);
202 }
203 
230 int gnrc_ipv6_nib_nc_set(const ipv6_addr_t *ipv6, unsigned iface,
231  const uint8_t *l2addr, size_t l2addr_len);
232 
243 void gnrc_ipv6_nib_nc_del(const ipv6_addr_t *ipv6, unsigned iface);
244 
263 
297 bool gnrc_ipv6_nib_nc_iter(unsigned iface, void **state,
298  gnrc_ipv6_nib_nc_t *nce);
299 
308 
309 #ifdef __cplusplus
310 }
311 #endif
312 
EUI-64 data type definition.
#define CONFIG_GNRC_IPV6_NIB_L2ADDR_MAX_LEN
Maximum link-layer address length (aligned)
Definition: conf.h:264
#define GNRC_IPV6_NIB_NC_INFO_NUD_STATE_MASK
Mask for neighbor unreachability detection (NUD) states.
Definition: nc.h:44
void gnrc_ipv6_nib_nc_mark_reachable(const ipv6_addr_t *ipv6)
Mark neighbor with address ipv6 as reachable.
void gnrc_ipv6_nib_nc_print(gnrc_ipv6_nib_nc_t *nce)
Prints a neighbor cache entry.
void gnrc_ipv6_nib_nc_del(const ipv6_addr_t *ipv6, unsigned iface)
Deletes neighbor with address ipv6 from NIB.
static unsigned gnrc_ipv6_nib_nc_get_nud_state(const gnrc_ipv6_nib_nc_t *entry)
Gets neighbor unreachability state from entry.
Definition: nc.h:160
static bool gnrc_ipv6_nib_nc_is_router(const gnrc_ipv6_nib_nc_t *entry)
Gets router flag of a neighbor.
Definition: nc.h:173
#define GNRC_IPV6_NIB_NC_INFO_IFACE_POS
Shift position of interface identifier.
Definition: nc.h:101
bool gnrc_ipv6_nib_nc_iter(unsigned iface, void **state, gnrc_ipv6_nib_nc_t *nce)
Iterates over all neighbor cache entries in the NIB.
#define GNRC_IPV6_NIB_NC_INFO_AR_STATE_MASK
Mask for 6LoWPAN address registration (6Lo-AR) states.
Definition: nc.h:108
static unsigned gnrc_ipv6_nib_nc_get_ar_state(const gnrc_ipv6_nib_nc_t *entry)
Gets address registration state of an entry.
Definition: nc.h:199
int gnrc_ipv6_nib_nc_set(const ipv6_addr_t *ipv6, unsigned iface, const uint8_t *l2addr, size_t l2addr_len)
Adds an unmanaged neighbor entry to NIB.
#define GNRC_IPV6_NIB_NC_INFO_IFACE_MASK
Mask for interface identifier.
Definition: nc.h:96
static unsigned gnrc_ipv6_nib_nc_get_iface(const gnrc_ipv6_nib_nc_t *entry)
Gets interface from entry.
Definition: nc.h:186
#define GNRC_IPV6_NIB_NC_INFO_IS_ROUTER
gnrc_ipv6_nib_t::next_hop is router
Definition: nc.h:91
Definitions for IPv6 addresses.
Configuration macro definitions for neighbor information base.
Generic network interface header.
Neighbor cache entry view on NIB.
Definition: nc.h:139
uint8_t l2addr_len
Length of gnrc_ipv6_nib_nc_t::l2addr in bytes.
Definition: nc.h:150
ipv6_addr_t ipv6
Neighbor's IPv6 address.
Definition: nc.h:140
uint16_t info
Neighbor information as defined in info values.
Definition: nc.h:149
Data type to represent an IPv6 address.
Definition: addr.h:64