nc.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 Freie Universität Berlin
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 
20 #ifndef NET_GNRC_IPV6_NIB_NC_H
21 #define NET_GNRC_IPV6_NIB_NC_H
22 
23 #include <stdbool.h>
24 #include <stdint.h>
25 
26 #include "net/eui64.h"
27 #include "net/gnrc/netif/hdr.h"
28 #include "net/gnrc/ipv6/nib/conf.h"
29 #include "net/ipv6/addr.h"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
47 #define GNRC_IPV6_NIB_NC_INFO_NUD_STATE_MASK (0x0007)
48 
52 #define GNRC_IPV6_NIB_NC_INFO_NUD_STATE_UNMANAGED (0x0000)
53 
57 #define GNRC_IPV6_NIB_NC_INFO_NUD_STATE_UNREACHABLE (0x0001)
58 
62 #define GNRC_IPV6_NIB_NC_INFO_NUD_STATE_INCOMPLETE (0x0002)
63 
67 #define GNRC_IPV6_NIB_NC_INFO_NUD_STATE_STALE (0x0003)
68 
72 #define GNRC_IPV6_NIB_NC_INFO_NUD_STATE_DELAY (0x0004)
73 
77 #define GNRC_IPV6_NIB_NC_INFO_NUD_STATE_PROBE (0x0005)
78 
82 #define GNRC_IPV6_NIB_NC_INFO_NUD_STATE_REACHABLE (0x0006)
83 
94 #define GNRC_IPV6_NIB_NC_INFO_IS_ROUTER (0x0008)
95 
99 #define GNRC_IPV6_NIB_NC_INFO_IFACE_MASK (0x01f0)
100 
104 #define GNRC_IPV6_NIB_NC_INFO_IFACE_POS (4)
105 
111 #define GNRC_IPV6_NIB_NC_INFO_AR_STATE_MASK (0x0600)
112 
116 #define GNRC_IPV6_NIB_NC_INFO_AR_STATE_POS (9)
117 
121 #define GNRC_IPV6_NIB_NC_INFO_AR_STATE_GC (0x0000)
122 
126 #define GNRC_IPV6_NIB_NC_INFO_AR_STATE_TENTATIVE (0x0200)
127 
131 #define GNRC_IPV6_NIB_NC_INFO_AR_STATE_REGISTERED (0x0400)
132 
136 #define GNRC_IPV6_NIB_NC_INFO_AR_STATE_MANUAL (0x0600)
137 
142 typedef struct {
152  uint16_t info;
153  uint8_t l2addr_len;
155 
163 static inline unsigned gnrc_ipv6_nib_nc_get_nud_state(const gnrc_ipv6_nib_nc_t *entry)
164 {
165  return (entry->info & GNRC_IPV6_NIB_NC_INFO_NUD_STATE_MASK);
166 }
167 
176 static inline bool gnrc_ipv6_nib_nc_is_router(const gnrc_ipv6_nib_nc_t *entry)
177 {
178  return (entry->info & GNRC_IPV6_NIB_NC_INFO_IS_ROUTER);
179 }
180 
189 static inline unsigned gnrc_ipv6_nib_nc_get_iface(const gnrc_ipv6_nib_nc_t *entry)
190 {
191  return (entry->info & GNRC_IPV6_NIB_NC_INFO_IFACE_MASK) >>
193 }
194 
202 static inline unsigned gnrc_ipv6_nib_nc_get_ar_state(const gnrc_ipv6_nib_nc_t *entry)
203 {
204  return (entry->info & GNRC_IPV6_NIB_NC_INFO_AR_STATE_MASK);
205 }
206 
233 int gnrc_ipv6_nib_nc_set(const ipv6_addr_t *ipv6, unsigned iface,
234  const uint8_t *l2addr, size_t l2addr_len);
235 
246 void gnrc_ipv6_nib_nc_del(const ipv6_addr_t *ipv6, unsigned iface);
247 
266 
300 bool gnrc_ipv6_nib_nc_iter(unsigned iface, void **state,
301  gnrc_ipv6_nib_nc_t *nce);
302 
311 
312 #ifdef __cplusplus
313 }
314 #endif
315 
316 #endif /* NET_GNRC_IPV6_NIB_NC_H */
317 
gnrc_ipv6_nib_nc_get_ar_state
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:202
gnrc_ipv6_nib_nc_mark_reachable
void gnrc_ipv6_nib_nc_mark_reachable(const ipv6_addr_t *ipv6)
Mark neighbor with address ipv6 as reachable.
gnrc_ipv6_nib_nc_print
void gnrc_ipv6_nib_nc_print(gnrc_ipv6_nib_nc_t *nce)
Prints a neighbor cache entry.
CONFIG_GNRC_IPV6_NIB_L2ADDR_MAX_LEN
#define CONFIG_GNRC_IPV6_NIB_L2ADDR_MAX_LEN
Maximum link-layer address length (aligned)
Definition: conf.h:241
ipv6_addr_t
Data type to represent an IPv6 address.
Definition: addr.h:74
GNRC_IPV6_NIB_NC_INFO_IFACE_POS
#define GNRC_IPV6_NIB_NC_INFO_IFACE_POS
Shift position of interface identifier.
Definition: nc.h:104
addr.h
Definitions for IPv6 addresses.
gnrc_ipv6_nib_nc_t::ipv6
ipv6_addr_t ipv6
Neighbor's IPv6 address.
Definition: nc.h:143
gnrc_ipv6_nib_nc_iter
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.
gnrc_ipv6_nib_nc_get_iface
static unsigned gnrc_ipv6_nib_nc_get_iface(const gnrc_ipv6_nib_nc_t *entry)
Gets interface from entry.
Definition: nc.h:189
gnrc_ipv6_nib_nc_is_router
static bool gnrc_ipv6_nib_nc_is_router(const gnrc_ipv6_nib_nc_t *entry)
Gets router flag of a neighbor.
Definition: nc.h:176
conf.h
Configuration macro definitions for neighbor information base.
gnrc_ipv6_nib_nc_t
Neighbor cache entry view on NIB.
Definition: nc.h:142
GNRC_IPV6_NIB_NC_INFO_NUD_STATE_MASK
#define GNRC_IPV6_NIB_NC_INFO_NUD_STATE_MASK
Mask for neighbor unreachability detection (NUD) states.
Definition: nc.h:47
gnrc_ipv6_nib_nc_del
void gnrc_ipv6_nib_nc_del(const ipv6_addr_t *ipv6, unsigned iface)
Deletes neighbor with address ipv6 from NIB.
gnrc_ipv6_nib_nc_set
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.
GNRC_IPV6_NIB_NC_INFO_IFACE_MASK
#define GNRC_IPV6_NIB_NC_INFO_IFACE_MASK
Mask for interface identifier.
Definition: nc.h:99
gnrc_ipv6_nib_nc_t::l2addr_len
uint8_t l2addr_len
Length of gnrc_ipv6_nib_nc_t::l2addr in bytes.
Definition: nc.h:153
gnrc_ipv6_nib_nc_get_nud_state
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:163
eui64.h
EUI-64 data type definition.
GNRC_IPV6_NIB_NC_INFO_AR_STATE_MASK
#define GNRC_IPV6_NIB_NC_INFO_AR_STATE_MASK
Mask for 6LoWPAN address registration (6Lo-AR) states.
Definition: nc.h:111
hdr.h
Generic network interface header.
gnrc_ipv6_nib_nc_t::info
uint16_t info
Neighbor information as defined in info values.
Definition: nc.h:152
GNRC_IPV6_NIB_NC_INFO_IS_ROUTER
#define GNRC_IPV6_NIB_NC_INFO_IS_ROUTER
gnrc_ipv6_nib_t::next_hop is router
Definition: nc.h:94