Neighbor Cache

Neighbor cache component of neighbor information base.

GNRC_IPV6_NIB_NC_INFO_NUD_STATE_MASK

Mask for neighbor unreachability detection (NUD) states.

1
(0x0007)

See also

RFC 7048

GNRC_IPV6_NIB_NC_INFO_NUD_STATE_UNMANAGED

Not managed by NUD.

1
(0x0000)
GNRC_IPV6_NIB_NC_INFO_NUD_STATE_UNREACHABLE

Entry is not reachable.

1
(0x0001)
GNRC_IPV6_NIB_NC_INFO_NUD_STATE_INCOMPLETE

Address resolution is currently performed.

1
(0x0002)
GNRC_IPV6_NIB_NC_INFO_NUD_STATE_STALE

Address might not be reachable.

1
(0x0003)
GNRC_IPV6_NIB_NC_INFO_NUD_STATE_DELAY

NUD will be performed in a moment.

1
(0x0004)
GNRC_IPV6_NIB_NC_INFO_NUD_STATE_PROBE

NUD is performed.

1
(0x0005)
GNRC_IPV6_NIB_NC_INFO_NUD_STATE_REACHABLE

Entry is reachable.

1
(0x0006)
GNRC_IPV6_NIB_NC_INFO_IS_ROUTER

gnrc_ipv6_nib_t::next_hop is router

1
(0x0008)

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.

GNRC_IPV6_NIB_NC_INFO_IFACE_MASK

Mask for interface identifier.

1
(0x01f0)
GNRC_IPV6_NIB_NC_INFO_IFACE_POS

Shift position of interface identifier.

1
(4)
GNRC_IPV6_NIB_NC_INFO_AR_STATE_MASK

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

1
(0x0600)

GNRC_IPV6_NIB_NC_INFO_AR_STATE_POS

Shift position of address registration states.

1
(9)
GNRC_IPV6_NIB_NC_INFO_AR_STATE_GC

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

1
(0x0000)
GNRC_IPV6_NIB_NC_INFO_AR_STATE_TENTATIVE

Address registration still pending at upstream router.

1
(0x0200)
GNRC_IPV6_NIB_NC_INFO_AR_STATE_REGISTERED

Address is registered.

1
(0x0400)
GNRC_IPV6_NIB_NC_INFO_AR_STATE_MANUAL

Address was added manually.

1
(0x0600)
unsigned gnrc_ipv6_nib_nc_get_nud_state(const gnrc_ipv6_nib_nc_t * entry)

Gets neighbor unreachability state from entry.

Parameters

entry:A neighbor cache entry.

Return values

  • The neighbor unreachability state of entry.
bool gnrc_ipv6_nib_nc_is_router(const gnrc_ipv6_nib_nc_t * entry)

Gets router flag of a neighbor.

Parameters

entry:A neighbor cache entry.

Return values

  • true, if entry is a router.
  • false, if entry is not a router.
unsigned gnrc_ipv6_nib_nc_get_iface(const gnrc_ipv6_nib_nc_t * entry)

Gets interface from entry.

Parameters

entry:A neighbor cache entry

Return values

  • The interface identifier of entry.
  • 0 if no interface is identified for entry.
unsigned gnrc_ipv6_nib_nc_get_ar_state(const gnrc_ipv6_nib_nc_t * entry)

Gets address registration state of an entry.

Parameters

entry:A neighbor cache entry

Return values

  • The address registration state of entry.
int gnrc_ipv6_nib_nc_set(const ipv6_addr_t * ipv6, unsigned iface, const uint8_t * l2addr, msp430_types.h::size_t l2addr_len)

Adds an unmanaged neighbor entry to NIB.

Parameters

ipv6:The neighbor’s IPv6 address.
iface:The interface to the neighbor.
l2addr:The neighbor’s L2 address.
l2addr_len:Length 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 ipv6/nib/conf.h::GNRC_IPV6_NIB_CONF_ARSM != 0 l2addr and l2addr_len won’t be set.

Return values

  • 0 on success.
  • -ENOMEM, if no space is left in neighbor cache.
void gnrc_ipv6_nib_nc_del(const ipv6_addr_t * ipv6, unsigned iface)

Deletes neighbor with address ipv6 from NIB.

Parameters

ipv6:The neighbor’s IPv6 address.
iface:The interface to the neighbor.
If the ipv6 can’t be found for a neighbor in the NIB nothing happens.

void gnrc_ipv6_nib_nc_mark_reachable(const ipv6_addr_t * ipv6)

Mark neighbor with address ipv6 as reachable.

Parameters

ipv6:A 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 nc.h::gnrc_ipv6_nib_nc_set()) or entries whose next-hop are not yet in the neighbor cache are ignored.

Entries in state nc.h::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

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.

Parameters

iface:Restrict iteration to entries on this interface. 0 for any interface.
state:Iteration state of the neighbor cache. Must point to a NULL pointer to start iteration.
nce:The next neighbor cache entry.
Usage example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
#include "net/gnrc/ipv6/nib/nc.h"

int main(void) {
    void *state = NULL;
    gnrc_ipv6_nib_nc_t nce;

    puts("My neighbors:");
    while (gnrc_ipv6_nib_nc_iter(0, &state, &nce)) {
        gnrc_ipv6_nib_nc_print(&nce);
    }
    return 0;
}

Note

The list may change during iteration.

Return values

  • true, if iteration can be continued.
  • false, if nce is the last neighbor cache entry in the NIB.
void gnrc_ipv6_nib_nc_print(gnrc_ipv6_nib_nc_t * nce)

Prints a neighbor cache entry.

Parameters

nce:A neighbor cache entry.

struct gnrc_ipv6_nib_nc_t

Neighbor cache entry view on NIB.

ipv6_addr_t ipv6

Neighbor’s IPv6 address.

uint8_t l2addr()

Neighbor’s link-layer address.

uint16_t info

Neighbor information as defined in .

uint8_t l2addr_len

Length of nc.h::gnrc_ipv6_nib_nc_t::l2addr in bytes.