Loading...
Searching...
No Matches
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
9#pragma once
10
22
23#include <stdbool.h>
24#include <stdint.h>
25
26#include "compiler_hints.h"
27#include "net/eui64.h"
28#include "net/gnrc/netif/hdr.h"
30#include "net/ipv6/addr.h"
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
48#define GNRC_IPV6_NIB_NC_INFO_NUD_STATE_MASK (0x0007)
49
53#define GNRC_IPV6_NIB_NC_INFO_NUD_STATE_UNMANAGED (0x0000)
54
58#define GNRC_IPV6_NIB_NC_INFO_NUD_STATE_UNREACHABLE (0x0001)
59
63#define GNRC_IPV6_NIB_NC_INFO_NUD_STATE_INCOMPLETE (0x0002)
64
68#define GNRC_IPV6_NIB_NC_INFO_NUD_STATE_STALE (0x0003)
69
73#define GNRC_IPV6_NIB_NC_INFO_NUD_STATE_DELAY (0x0004)
74
78#define GNRC_IPV6_NIB_NC_INFO_NUD_STATE_PROBE (0x0005)
79
83#define GNRC_IPV6_NIB_NC_INFO_NUD_STATE_REACHABLE (0x0006)
84
95#define GNRC_IPV6_NIB_NC_INFO_IS_ROUTER (0x0008)
96
100#define GNRC_IPV6_NIB_NC_INFO_IFACE_MASK (0x01f0)
101
105#define GNRC_IPV6_NIB_NC_INFO_IFACE_POS (4)
106
112#define GNRC_IPV6_NIB_NC_INFO_AR_STATE_MASK (0x0600)
113
117#define GNRC_IPV6_NIB_NC_INFO_AR_STATE_POS (9)
118
122#define GNRC_IPV6_NIB_NC_INFO_AR_STATE_GC (0x0000)
123
127#define GNRC_IPV6_NIB_NC_INFO_AR_STATE_TENTATIVE (0x0200)
128
132#define GNRC_IPV6_NIB_NC_INFO_AR_STATE_REGISTERED (0x0400)
133
137#define GNRC_IPV6_NIB_NC_INFO_AR_STATE_MANUAL (0x0600)
139
156
164static inline unsigned gnrc_ipv6_nib_nc_get_nud_state(const gnrc_ipv6_nib_nc_t *entry)
165{
167}
168
177static inline bool gnrc_ipv6_nib_nc_is_router(const gnrc_ipv6_nib_nc_t *entry)
178{
179 return (entry->info & GNRC_IPV6_NIB_NC_INFO_IS_ROUTER);
180}
181
190static inline unsigned gnrc_ipv6_nib_nc_get_iface(const gnrc_ipv6_nib_nc_t *entry)
191{
192 return (entry->info & GNRC_IPV6_NIB_NC_INFO_IFACE_MASK) >>
194}
195
203static inline unsigned gnrc_ipv6_nib_nc_get_ar_state(const gnrc_ipv6_nib_nc_t *entry)
204{
206}
207
234ACCESS(read_only, 3, 4)
235int gnrc_ipv6_nib_nc_set(const ipv6_addr_t *ipv6, unsigned iface,
236 const uint8_t *l2addr, size_t l2addr_len);
237
238#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_6LN) || defined(DOXYGEN)
254ACCESS(read_only, 2, 3)
255int gnrc_ipv6_nib_nc_set_6ln(unsigned iface, const uint8_t *l2addr,
256 size_t l2addr_len);
257#else /* CONFIG_GNRC_IPV6_NIB_6LN */
258static inline int gnrc_ipv6_nib_nc_set_6ln(unsigned iface, const uint8_t *l2addr,
259 size_t l2addr_len)
260{
261 (void)iface;
262 (void)l2addr;
263 (void)l2addr_len;
264
265 return -ENOTSUP;
266}
267#endif /* CONFIG_GNRC_IPV6_NIB_6LN */
268
279void gnrc_ipv6_nib_nc_del(const ipv6_addr_t *ipv6, unsigned iface);
280
281#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_ARSM) || defined(DOXYGEN)
295ACCESS(read_only, 2, 3)
296bool gnrc_ipv6_nib_nc_del_l2(unsigned iface, const uint8_t *l2addr, size_t l2addr_len);
297#endif /* CONFIG_GNRC_IPV6_NIB_ARSM */
298
317
351bool gnrc_ipv6_nib_nc_iter(unsigned iface, void **state,
352 gnrc_ipv6_nib_nc_t *nce);
353
362
363#ifdef __cplusplus
364}
365#endif
366
Common macros and compiler attributes/pragmas configuration.
#define ACCESS(mode, ptr_idx, size_idx)
Emit an attribute (if supported by the compiler) that declares how a function will access its paramet...
EUI-64 data type definition.
#define ENOTSUP
Not supported (may be the same value as [EOPNOTSUPP]).
Definition errno.h:129
#define CONFIG_GNRC_IPV6_NIB_L2ADDR_MAX_LEN
Maximum link-layer address length (aligned)
Definition conf.h:281
#define GNRC_IPV6_NIB_NC_INFO_NUD_STATE_MASK
Mask for neighbor unreachability detection (NUD) states.
Definition nc.h:48
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:164
static bool gnrc_ipv6_nib_nc_is_router(const gnrc_ipv6_nib_nc_t *entry)
Gets router flag of a neighbor.
Definition nc.h:177
#define GNRC_IPV6_NIB_NC_INFO_IFACE_POS
Shift position of interface identifier.
Definition nc.h:105
int gnrc_ipv6_nib_nc_set_6ln(unsigned iface, const uint8_t *l2addr, size_t l2addr_len)
Adds an unmanaged neighbor entry to the NIB if the interface represents a 6LN node and the IPv6 addre...
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:112
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:203
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:100
static unsigned gnrc_ipv6_nib_nc_get_iface(const gnrc_ipv6_nib_nc_t *entry)
Gets interface from entry.
Definition nc.h:190
bool gnrc_ipv6_nib_nc_del_l2(unsigned iface, const uint8_t *l2addr, size_t l2addr_len)
Deletes neighbor with link-layer address l2addr from NIB.
#define GNRC_IPV6_NIB_NC_INFO_IS_ROUTER
gnrc_ipv6_nib_t::next_hop is router
Definition nc.h:95
Definitions for IPv6 addresses.
Configuration macro definitions for neighbor information base.
Generic network interface header.
Neighbor cache entry view on NIB.
Definition nc.h:143
uint8_t l2addr_len
Length of gnrc_ipv6_nib_nc_t::l2addr in bytes.
Definition nc.h:154
ipv6_addr_t ipv6
Neighbor's IPv6 address.
Definition nc.h:144
uint8_t l2addr[CONFIG_GNRC_IPV6_NIB_L2ADDR_MAX_LEN]
Neighbor's link-layer address.
Definition nc.h:148
uint16_t info
Neighbor information as defined in info values.
Definition nc.h:153
Data type to represent an IPv6 address.
Definition addr.h:67