Loading...
Searching...
No Matches

Neighbor cache component of neighbor information base. More...

Detailed Description

Neighbor cache component of neighbor information base.

Files

file  nc.h
 Neighbor cache definitions.
 

Data Structures

struct  gnrc_ipv6_nib_nc_t
 Neighbor cache entry view on NIB. More...
 

Functions

static unsigned gnrc_ipv6_nib_nc_get_nud_state (const gnrc_ipv6_nib_nc_t *entry)
 Gets neighbor unreachability state from entry.
 
static bool gnrc_ipv6_nib_nc_is_router (const gnrc_ipv6_nib_nc_t *entry)
 Gets router flag of a neighbor.
 
static unsigned gnrc_ipv6_nib_nc_get_iface (const gnrc_ipv6_nib_nc_t *entry)
 Gets interface from entry.
 
static unsigned gnrc_ipv6_nib_nc_get_ar_state (const gnrc_ipv6_nib_nc_t *entry)
 Gets address registration state of an entry.
 
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.
 
void gnrc_ipv6_nib_nc_del (const ipv6_addr_t *ipv6, unsigned iface)
 Deletes neighbor with address ipv6 from NIB.
 
void gnrc_ipv6_nib_nc_mark_reachable (const ipv6_addr_t *ipv6)
 Mark neighbor with address ipv6 as reachable.
 
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.
 
void gnrc_ipv6_nib_nc_print (gnrc_ipv6_nib_nc_t *nce)
 Prints a neighbor cache entry.
 

Info values

Values for gnrc_ipv6_nib_nc_t::info

#define GNRC_IPV6_NIB_NC_INFO_NUD_STATE_MASK   (0x0007)
 Mask for neighbor unreachability detection (NUD) states.
 
#define GNRC_IPV6_NIB_NC_INFO_NUD_STATE_UNMANAGED   (0x0000)
 Not managed by NUD.
 
#define GNRC_IPV6_NIB_NC_INFO_NUD_STATE_UNREACHABLE   (0x0001)
 Entry is not reachable.
 
#define GNRC_IPV6_NIB_NC_INFO_NUD_STATE_INCOMPLETE   (0x0002)
 Address resolution is currently performed.
 
#define GNRC_IPV6_NIB_NC_INFO_NUD_STATE_STALE   (0x0003)
 Address might not be reachable.
 
#define GNRC_IPV6_NIB_NC_INFO_NUD_STATE_DELAY   (0x0004)
 NUD will be performed in a moment.
 
#define GNRC_IPV6_NIB_NC_INFO_NUD_STATE_PROBE   (0x0005)
 NUD is performed.
 
#define GNRC_IPV6_NIB_NC_INFO_NUD_STATE_REACHABLE   (0x0006)
 Entry is reachable.
 
#define GNRC_IPV6_NIB_NC_INFO_IS_ROUTER   (0x0008)
 gnrc_ipv6_nib_t::next_hop is router
 
#define GNRC_IPV6_NIB_NC_INFO_IFACE_MASK   (0x01f0)
 Mask for interface identifier.
 
#define GNRC_IPV6_NIB_NC_INFO_IFACE_POS   (4)
 Shift position of interface identifier.
 
#define GNRC_IPV6_NIB_NC_INFO_AR_STATE_MASK   (0x0600)
 Mask for 6LoWPAN address registration (6Lo-AR) states.
 
#define GNRC_IPV6_NIB_NC_INFO_AR_STATE_POS   (9)
 Shift position of address registration states.
 
#define GNRC_IPV6_NIB_NC_INFO_AR_STATE_GC   (0x0000)
 Not managed by 6Lo-AR (address can be removed when memory is low.
 
#define GNRC_IPV6_NIB_NC_INFO_AR_STATE_TENTATIVE   (0x0200)
 Address registration still pending at upstream router.
 
#define GNRC_IPV6_NIB_NC_INFO_AR_STATE_REGISTERED   (0x0400)
 Address is registered.
 
#define GNRC_IPV6_NIB_NC_INFO_AR_STATE_MANUAL   (0x0600)
 Address was added manually.
 

Macro Definition Documentation

◆ GNRC_IPV6_NIB_NC_INFO_AR_STATE_GC

#define GNRC_IPV6_NIB_NC_INFO_AR_STATE_GC   (0x0000)

Not managed by 6Lo-AR (address can be removed when memory is low.

Definition at line 121 of file nc.h.

◆ GNRC_IPV6_NIB_NC_INFO_AR_STATE_MANUAL

#define GNRC_IPV6_NIB_NC_INFO_AR_STATE_MANUAL   (0x0600)

Address was added manually.

Definition at line 136 of file nc.h.

◆ GNRC_IPV6_NIB_NC_INFO_AR_STATE_MASK

#define GNRC_IPV6_NIB_NC_INFO_AR_STATE_MASK   (0x0600)

Mask for 6LoWPAN address registration (6Lo-AR) states.

See also
RFC 6775, section 3.5

Definition at line 111 of file nc.h.

◆ GNRC_IPV6_NIB_NC_INFO_AR_STATE_POS

#define GNRC_IPV6_NIB_NC_INFO_AR_STATE_POS   (9)

Shift position of address registration states.

Definition at line 116 of file nc.h.

◆ GNRC_IPV6_NIB_NC_INFO_AR_STATE_REGISTERED

#define GNRC_IPV6_NIB_NC_INFO_AR_STATE_REGISTERED   (0x0400)

Address is registered.

Definition at line 131 of file nc.h.

◆ GNRC_IPV6_NIB_NC_INFO_AR_STATE_TENTATIVE

#define GNRC_IPV6_NIB_NC_INFO_AR_STATE_TENTATIVE   (0x0200)

Address registration still pending at upstream router.

Definition at line 126 of file nc.h.

◆ GNRC_IPV6_NIB_NC_INFO_IFACE_MASK

#define GNRC_IPV6_NIB_NC_INFO_IFACE_MASK   (0x01f0)

Mask for interface identifier.

Definition at line 99 of file nc.h.

◆ GNRC_IPV6_NIB_NC_INFO_IFACE_POS

#define GNRC_IPV6_NIB_NC_INFO_IFACE_POS   (4)

Shift position of interface identifier.

Definition at line 104 of file nc.h.

◆ GNRC_IPV6_NIB_NC_INFO_IS_ROUTER

#define GNRC_IPV6_NIB_NC_INFO_IS_ROUTER   (0x0008)

gnrc_ipv6_nib_t::next_hop is router

This flag indicates that gnrc_ipv6_nib_t::next_hop is a router, but it does not necessarily indicate that it is in the default router list! A neighbor that has this flag unset however must not appear in the default router list.

See also
RFC 4861, Appendix D

Definition at line 94 of file nc.h.

◆ GNRC_IPV6_NIB_NC_INFO_NUD_STATE_DELAY

#define GNRC_IPV6_NIB_NC_INFO_NUD_STATE_DELAY   (0x0004)

NUD will be performed in a moment.

Definition at line 72 of file nc.h.

◆ GNRC_IPV6_NIB_NC_INFO_NUD_STATE_INCOMPLETE

#define GNRC_IPV6_NIB_NC_INFO_NUD_STATE_INCOMPLETE   (0x0002)

Address resolution is currently performed.

Definition at line 62 of file nc.h.

◆ GNRC_IPV6_NIB_NC_INFO_NUD_STATE_MASK

#define GNRC_IPV6_NIB_NC_INFO_NUD_STATE_MASK   (0x0007)

Mask for neighbor unreachability detection (NUD) states.

See also
RFC 4861, section 7.3.2
RFC 7048

Definition at line 47 of file nc.h.

◆ GNRC_IPV6_NIB_NC_INFO_NUD_STATE_PROBE

#define GNRC_IPV6_NIB_NC_INFO_NUD_STATE_PROBE   (0x0005)

NUD is performed.

Definition at line 77 of file nc.h.

◆ GNRC_IPV6_NIB_NC_INFO_NUD_STATE_REACHABLE

#define GNRC_IPV6_NIB_NC_INFO_NUD_STATE_REACHABLE   (0x0006)

Entry is reachable.

Definition at line 82 of file nc.h.

◆ GNRC_IPV6_NIB_NC_INFO_NUD_STATE_STALE

#define GNRC_IPV6_NIB_NC_INFO_NUD_STATE_STALE   (0x0003)

Address might not be reachable.

Definition at line 67 of file nc.h.

◆ GNRC_IPV6_NIB_NC_INFO_NUD_STATE_UNMANAGED

#define GNRC_IPV6_NIB_NC_INFO_NUD_STATE_UNMANAGED   (0x0000)

Not managed by NUD.

Definition at line 52 of file nc.h.

◆ GNRC_IPV6_NIB_NC_INFO_NUD_STATE_UNREACHABLE

#define GNRC_IPV6_NIB_NC_INFO_NUD_STATE_UNREACHABLE   (0x0001)

Entry is not reachable.

Definition at line 57 of file nc.h.

Function Documentation

◆ 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.

Precondition
ipv6 != NULL
Parameters
[in]ipv6The neighbor's IPv6 address.
[in]ifaceThe interface to the neighbor.

If the ipv6 can't be found for a neighbor in the NIB nothing happens.

◆ gnrc_ipv6_nib_nc_get_ar_state()

static unsigned gnrc_ipv6_nib_nc_get_ar_state ( const gnrc_ipv6_nib_nc_t entry)
inlinestatic

Gets address registration state of an entry.

Parameters
[in]entryA neighbor cache entry
Returns
The address registration state of entry.

Definition at line 202 of file nc.h.

◆ gnrc_ipv6_nib_nc_get_iface()

static unsigned gnrc_ipv6_nib_nc_get_iface ( const gnrc_ipv6_nib_nc_t entry)
inlinestatic

Gets interface from entry.

Parameters
[in]entryA neighbor cache entry
Returns
The interface identifier of entry.
0 if no interface is identified for entry.

Definition at line 189 of file nc.h.

◆ gnrc_ipv6_nib_nc_get_nud_state()

static unsigned gnrc_ipv6_nib_nc_get_nud_state ( const gnrc_ipv6_nib_nc_t entry)
inlinestatic

Gets neighbor unreachability state from entry.

Parameters
[in]entryA neighbor cache entry.
Returns
The neighbor unreachability state of entry.

Definition at line 163 of file nc.h.

◆ gnrc_ipv6_nib_nc_is_router()

static bool gnrc_ipv6_nib_nc_is_router ( const gnrc_ipv6_nib_nc_t entry)
inlinestatic

Gets router flag of a neighbor.

Parameters
[in]entryA neighbor cache entry.
Returns
true, if entry is a router.
false, if entry is not a router.

Definition at line 176 of file nc.h.

◆ 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.

Precondition
(state != NULL) && (nce != NULL)
Parameters
[in]ifaceRestrict iteration to entries on this interface. 0 for any interface.
[in,out]stateIteration state of the neighbor cache. Must point to a NULL pointer to start iteration.
[out]nceThe next neighbor cache entry.

Usage example:

int main(void) {
void *state = NULL;
puts("My neighbors:");
while (gnrc_ipv6_nib_nc_iter(0, &state, &nce)) {
}
return 0;
}
void gnrc_ipv6_nib_nc_print(gnrc_ipv6_nib_nc_t *nce)
Prints a neighbor cache entry.
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.
Neighbor cache definitions.
Neighbor cache entry view on NIB.
Definition nc.h:142
Note
The list may change during iteration.
Returns
true, if iteration can be continued.
false, if nce is the last neighbor cache entry in the NIB.

◆ 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.

Precondition
ipv6 != NULL
Parameters
[in]ipv6A neighbor's IPv6 address. Must not be NULL.

This function shall be called if an upper layer gets reachability confirmation via its own means (e.g. a TCP connection build-up or confirmation). Unmanaged neighbor cache entries (i.e. entries created using gnrc_ipv6_nib_nc_set()) or entries whose next-hop are not yet in the neighbor cache are ignored.

Entries in state GNRC_IPV6_NIB_NC_INFO_NUD_STATE_UNMANAGED are not affected by this, since they are assumed to always be reachable and kept out of the NUD state-machine

◆ gnrc_ipv6_nib_nc_print()

void gnrc_ipv6_nib_nc_print ( gnrc_ipv6_nib_nc_t nce)

Prints a neighbor cache entry.

Precondition
nce != NULL
Parameters
[in]nceA neighbor cache entry.

◆ 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.

Precondition
ipv6 != NULL
l2addr_len <= CONFIG_GNRC_IPV6_NIB_L2ADDR_MAX_LEN
(iface > KERNEL_PID_UNDEF) && (iface <= KERNEL_PID_LAST)
Parameters
[in]ipv6The neighbor's IPv6 address.
[in]ifaceThe interface to the neighbor.
[in]l2addrThe neighbor's L2 address.
[in]l2addr_lenLength of l2addr.

A neighbor cache entry created this way is marked as persistent. Also, a non-persistent neighbor or destination cache entry already in the NIB might be removed to make room for the new entry. If an entry pointing to the same IPv6 address as ipv6 exists already it will be overwritten and marked as unmanaged.

If CONFIG_GNRC_IPV6_NIB_ARSM == 0 l2addr and l2addr_len won't be set and ipv6 must be a link-local address.

Returns
0 on success.
-ENOMEM, if no space is left in neighbor cache.
-EINVAL, if ipv6 is invalid (i.e. CONFIG_GNRC_IPV6_NIB_ARSM == 0 and ipv6 is not link-local).