_nib-internal.h

_EMPTY

empty

1
(0x00)
_NC

neighbor cache

1
(0x01)
_DC

destination cache

1
(0x02)
_PL

prefix list

1
(0x04)
_DRL

default router list

1
(0x08)
_FT

forwarding table

1
(0x10)
_DAD

6LoWPAN duplicate address detection table

1
(0x20)
_DST

there is _nib_offl_entry_t pointing to this

1
(0x40)
_PFX_ON_LINK
1
(0x0001)
_PFX_SLAAC
1
(0x0002)
_NIB_IF_MASK

Shorter name for convenience ;-)

1
(GNRC_IPV6_NIB_NC_INFO_IFACE_MASK)
_NIB_IF_POS

Shorter name for convenience ;-)

1
(GNRC_IPV6_NIB_NC_INFO_IFACE_POS)
_NIB_IF_MAX

Maximum identifier for the interface.

1
(_NIB_IF_MASK >> _NIB_IF_POS)
struct _nib_onl_entry _nib_onl_entry_t

On-link NIB entry.

mutex_t _nib_mutex

Mutex for locking the NIB.

evtimer_msg.h::evtimer_msg_t _nib_evtimer

Event timer for the NIB.

_nib_dr_entry_t * _prime_def_router

Primary default router.

This value is returned by () when it is not NULL and it is reachable. Otherwise it is selected with the default router selection algoritm by that function. Exposed to be settable by Forwarding table.

void _nib_init(void)

Initializes NIB internally.

unsigned _nib_onl_get_if(const _nib_onl_entry_t * node)

Gets interface identifier from a NIB entry.

Parameters

node:A NIB entry.

Return values

  • The NIB entry’s interface identifier.
void _nib_onl_set_if(_nib_onl_entry_t * node, unsigned iface)

Sets interface for a NIB entry.

Parameters

node:A NIB entry.
iface:An interface identifier.

_nib_onl_entry_t * _nib_onl_alloc(const ipv6_addr_t * addr, unsigned iface)

Creates or gets an existing on-link entry by address.

Parameters

addr:An IPv6 address. May be NULL (to be pointed to by a prefix list entry). May also be a global address!
iface:The interface to the node.

Return values

  • A new or existing on-link entry with _nib-internal.h::_nib_onl_entry::ipv6 set to addr.
  • NULL, if no space is left.
bool _nib_onl_clear(_nib_onl_entry_t * node)

Clears out a NIB entry (on-link version)

Parameters

node:An entry.

Return values

  • true, if entry was cleared.
  • false, if entry was not cleared.
_nib_onl_entry_t * _nib_onl_iter(const _nib_onl_entry_t * last)

Iterates over on-link entries.

Parameters

last:Last entry (NULL to start).

Return values

  • entry after last.
_nib_onl_entry_t * _nib_onl_get(const ipv6_addr_t * addr, unsigned iface)

Gets a node by IPv6 address and interface.

Parameters

addr:The address of a node. Must not be NULL.
iface:The interface to the node. May be 0 for any interface.

Return values

  • The NIB entry for node with addr and iface on success.
  • NULL, if there is no such entry.
_nib_onl_entry_t * _nib_nc_add(const ipv6_addr_t * addr, unsigned iface, uint16_t cstate)

Creates or gets an existing node from the neighbor cache by address.

Parameters

addr:The address of a node. May be NULL for prefix list entries.
iface:The interface to the node.
cstate:Creation state. State of the entry if the entry is newly created.

Return values

  • The NIB entry for the new neighbor cache entry on success.
  • NULL, if there is no space left.
void _nib_nc_remove(_nib_onl_entry_t * node)

Removes a node from the neighbor cache.

Parameters

node:A node.

void _nib_nc_get(const _nib_onl_entry_t * node, gnrc_ipv6_nib_nc_t * nce)

Gets external neighbor cache entry representation from on-link entry.

Parameters

node:On-link entry.
nce:External representation of the neighbor cache entry.

void _nib_nc_set_reachable(_nib_onl_entry_t * node)

Sets a NUD-managed neighbor cache entry to reachable and sets the respective event in event timer (GNRC_IPV6_NIB_MSG_NUD_SET_STALE)

Parameters

node:A node.

_nib_onl_entry_t * _nib_dad_add(const ipv6_addr_t * addr)

Creates or gets an existing node from the DAD table by address.

Parameters

addr:The address of a node. Must not be NULL.

Return values

  • The NIB entry for the new DAD table entry on success.
  • NULL, if there is no space left.
void _nib_dad_remove(_nib_onl_entry_t * node)

Removes a node from the DAD table.

Parameters

node:A node.

_nib_dr_entry_t * _nib_drl_add(const ipv6_addr_t * addr, unsigned iface)

Creates or gets an existing default router list entry by address.

Parameters

addr:An IPv6 address. Must not be NULL. May also be a global address!
iface:The interface to the router.

Return values

  • A new or existing default router entry with _nib-internal.h::_nib_onl_entry::ipv6 of _nib-internal.h::_nib_dr_entry_t::next_hop set to router_addr.
  • NULL, if no space is left.
void _nib_drl_remove(_nib_dr_entry_t * nib_dr)

Removes a default router list entry.

Parameters

nib_dr:An entry.
Corresponding on-link entry is removed, too.

_nib_dr_entry_t * _nib_drl_iter(const _nib_dr_entry_t * last)

Iterates over default router list.

Parameters

last:Last entry (NULL to start).

Return values

  • entry after last.
_nib_dr_entry_t * _nib_drl_get(const ipv6_addr_t * router_addr, unsigned iface)

Gets a default router by IPv6 address and interface.

Parameters

router_addr:The address of a default router. Must not be NULL.
iface:The interface to the node. May be 0 for any interface.

Return values

  • The NIB entry for node with router_addr and iface onsuccess.
  • NULL, if there is no such entry.
void _nib_drl_ft_get(const _nib_dr_entry_t * drl, gnrc_ipv6_nib_ft_t * fte)

Gets external forwarding table entry representation from default router entry.

Parameters

drl:Default router entry.
fte:External representation of the forwarding table entry.

_nib_dr_entry_t * _nib_drl_get_dr(void)

Gets the default router.

Return values

  • The current default router, on success.
  • NULL, if there is no default router in the list.
_nib_offl_entry_t * _nib_offl_alloc(const ipv6_addr_t * next_hop, unsigned iface, const ipv6_addr_t * pfx, unsigned pfx_len)

Creates or gets an existing off-link entry by next hop and prefix.

Parameters

next_hop:An IPv6 address to next hop. May be NULL (for prefix list). May also be a global address!
iface:The interface to next_hop.
pfx:The IPv6 prefix or address of the destination. Must not be NULL or unspecified address. Use _nib_drl_add() for default route destinations.
pfx_len:The length in bits of pfx in bits.

Return values

  • A new or existing off-link entry with _nib_dr_entry_t::pfx set to pfx.
  • NULL, if no space is left.
void _nib_offl_clear(_nib_offl_entry_t * dst)

Clears out a NIB entry (off-link version)

Parameters

dst:An entry.

_nib_offl_entry_t * _nib_offl_iter(const _nib_offl_entry_t * last)

Iterates over off-link entries.

Parameters

last:Last entry (NULL to start).

Return values

  • entry after last.
bool _nib_offl_is_entry(const _nib_offl_entry_t * entry)

Checks if entry was allocated using _nib_offl_alloc()

Parameters

entry:An entry.

Return values

  • true, if entry was allocated using _nib_offl_alloc()
  • false, if entry was not allocated using _nib_offl_alloc()
_nib_offl_entry_t * _nib_offl_add(const ipv6_addr_t * next_hop, unsigned iface, const ipv6_addr_t * pfx, unsigned pfx_len, uint8_t mode)

Helper function for view-level add-functions below.

Parameters

next_hop:An IPv6 address to next hop. May be NULL (for prefix list). May also be a global address!
iface:The interface to the destination.
pfx:The IPv6 prefix or address of the destination. Must not be NULL or unspecified address. Use _nib_drl_add() for default route destinations.
pfx_len:The length in bits of pfx in bits.
mode:[NIB-mode](_nib-internal.h::_nib_onl_entry::mode).

Return values

  • A new or existing off-link entry with _nib-internal.h::_nib_offl_entry_t::pfx set to pfx.
  • NULL, if no space is left.
void _nib_offl_remove(_nib_offl_entry_t * nib_offl, uint8_t mode)

Helper function for the view-level remove-functions below.

Parameters

nib_offl:An entry.

_nib_offl_entry_t * _nib_dc_add(const ipv6_addr_t * next_hop, unsigned iface, const ipv6_addr_t * dst)

Creates or gets an existing destination cache entry by its addresses.

Parameters

next_hop:Next hop to the destination. Must not be NULL. May also be a global address!
iface:The interface to the destination.

Note

Only available if ipv6/nib/conf.h::GNRC_IPV6_NIB_CONF_DC.

Return values

  • A new or existing off-link entry with _nib-internal.h::_nib_offl_entry_t::pfx set to pfx.
  • NULL, if no space is left.
void _nib_dc_remove(_nib_offl_entry_t * nib_offl)

Removes a destination cache entry.

Parameters

nib_dr:An entry.
Corresponding on-link entry is removed, too.

Note

Only available if ipv6/nib/conf.h::GNRC_IPV6_NIB_CONF_DC.

_nib_offl_entry_t * _nib_pl_add(unsigned iface, const ipv6_addr_t * pfx, unsigned pfx_len, uint32_t valid_ltime, uint32_t pref_ltime)

Creates or gets an existing prefix list entry by its prefix.

Parameters

iface:The interface to the prefix is added to.
pfx:The IPv6 prefix or address of the destination. Must not be NULL or unspecified address. Use _nib_drl_add() for default route destinations.
pfx_len:The length in bits of pfx in bits.
valid_ltime:Valid lifetime in microseconds. UINT32_MAX for infinite.
pref_ltime:Preferred lifetime in microseconds. UINT32_MAX for infinite.

Return values

  • A new or existing off-link entry with _nib-internal.h::_nib_offl_entry_t::pfx set to pfx.
  • NULL, if no space is left.
void _nib_pl_remove(_nib_offl_entry_t * nib_offl)

Removes a prefix list entry.

Parameters

nib_offl:An entry.
Corresponding on-link entry is removed, too.

_nib_offl_entry_t * _nib_ft_add(const ipv6_addr_t * next_hop, unsigned iface, const ipv6_addr_t * pfx, unsigned pfx_len)

Creates or gets an existing forwarding table entry by its prefix.

Parameters

next_hop:Next hop to the destination. Must not be NULL. May also be a global address!
iface:The interface to the destination.
pfx:The IPv6 prefix or address of the destination. Must not be NULL or unspecified address. Use _nib_drl_add() for default route destinations.
pfx_len:The length in bits of pfx in bits.

Return values

  • A new or existing off-link entry with _nib-internal.h::_nib_offl_entry_t::pfx set to pfx.
  • NULL, if no space is left.
void _nib_ft_remove(_nib_offl_entry_t * nib_offl)

Removes a forwarding table entry.

Parameters

nib_offl:An entry.
Corresponding on-link entry is removed, too.

_nib_abr_entry_t * _nib_abr_add(const ipv6_addr_t * addr)

Creates or gets an existing authoritative border router.

Parameters

addr:Address of the authoritative border router.

Return values

  • An authoritative border router entry, on success.
  • NULL, if no space is left.
void _nib_abr_remove(const ipv6_addr_t * addr)

Removes an authoritative border router.

Parameters

addr:Address of the authoritative border router.

void _nib_abr_add_pfx(_nib_abr_entry_t * abr, const _nib_offl_entry_t * offl)

Adds a prefix to the managed prefix of the authoritative border router.

Parameters

abr:The border router.
offl:The prefix to add.

_nib_offl_entry_t * _nib_abr_iter_pfx(const _nib_abr_entry_t * abr, const _nib_offl_entry_t * last)

Iterates over an authoritative border router’s prefixes.

Parameters

abr:The border router
last:Last prefix (NULL to start)

Return values

  • entry after last.
  • NULL, if last is the last prefix of abr or if last wasn’t in NIB (and != NULL).
_nib_abr_entry_t * _nib_abr_iter(const _nib_abr_entry_t * last)

Iterates over authoritative border router entries.

Parameters

last:Last entry (NULL to start).

Return values

  • entry after last.
  • NULL, if last is the last ABR in the NIB.
void _nib_ft_get(const _nib_offl_entry_t * dst, gnrc_ipv6_nib_ft_t * fte)

Gets external forwarding table entry representation from off-link entry.

Parameters

dst:Off-link entry.
fte:External representation of the forwarding table entry.

int _nib_get_route(const ipv6_addr_t * dst, include/net/gnrc/pkt.h::gnrc_pktsnip_t * ctx, gnrc_ipv6_nib_ft_t * entry)

Gets best match to dst from all off-link entries and default route.

Parameters

dst:Destination address to get the off-link entry for.
pkt:Packet causing the route look-up (provided to allow reactive routing protocols to queue it if needed). May be NULL.
fte:Resulting forwarding table entry.

Return values

  • 0, on success.
  • -ENETUNREACH, when no route was found.
uint32_t _evtimer_lookup(const void * ctx, uint16_t type)

Looks up if an event is queued in the event timer.

Parameters

ctx:Context of the event. May be NULL for any event context.
type:.

Return values

  • Milliseconds to the event, if event in queue.
  • UINT32_MAX, event is not in queue.
void _evtimer_add(void * ctx, int16_t type, evtimer_msg_event_t * event, uint32_t offset)

Adds an event to the event timer.

Parameters

ctx:The context of the event
type:.
event:Representation of the event.
offset:Offset in milliseconds to the event.

struct _nib_onl_entry

On-link NIB entry.

struct _nib_onl_entry * next

next removable entry

pktqueue.h::gnrc_pktqueue_t * pktqueue

queue for packets currently in address resolution

Note

Only available if ipv6/nib/conf.h::GNRC_IPV6_NIB_CONF_QUEUE_PKT != 0.

ipv6_addr_t ipv6

Neighbors IPv6 address.

eui64_t eui64

The neighbors EUI-64 (used for DAD)

Note

Only available if ipv6/nib/conf.h::GNRC_IPV6_NIB_CONF_6LR != 0.

uint8_t l2addr()

Link-layer address of _nib_onl_entry_t::next_hop.

Note

Only available if ipv6/nib/conf.h::GNRC_IPV6_NIB_CONF_ARSM != 0.

evtimer_msg_event_t nud_timeout

Event for nib.h::GNRC_IPV6_NIB_SND_UC_NS, nib.h::GNRC_IPV6_NIB_SND_MC_NS, nib.h::GNRC_IPV6_NIB_REACH_TIMEOUT and nib.h::GNRC_IPV6_NIB_DELAY_TIMEOUT.

Note

Four event types

  1. To easier distinguish multicast probes in _evtimer_lookup for rate-limiting from unicast probes.
  2. Since the types can’t be in the event queue at the same time (since they only have one NUD state at a time and probing is one of these states). Because of this we can use one event for all of them (but need the different types, since the events are handled differently).

Note

This is also available with ipv6/nib/conf.h::GNRC_IPV6_NIB_CONF_ARSM == 0, since 6Lo address registration uses it to time the sending of neighbor solicitations.

evtimer_msg_event_t snd_na

Event for nib.h::GNRC_IPV6_NIB_SND_NA.

evtimer_msg_event_t reply_rs

Event for nib.h::GNRC_IPV6_NIB_REPLY_RS.

evtimer_msg_event_t addr_reg_timeout

Event for nib.h::GNRC_IPV6_NIB_ADDR_REG_TIMEOUT.

uint16_t info

Information flags.

See also

uint8_t mode

NIB entry mode.

This field identifies which “views” of the NIB the entry belongs to.

See also

.

uint8_t ns_sent

Neighbor solicitations sent for probing.

Note

Only available if ipv6/nib/conf.h::GNRC_IPV6_NIB_CONF_ARSM != 0.

uint8_t l2addr_len

length in bytes of _nib-internal.h::_nib_onl_entry::l2addr

Note

Only available if ipv6/nib/conf.h::GNRC_IPV6_NIB_CONF_ARSM != 0.

struct _nib_dr_entry_t

Default route NIB entry.

_nib_onl_entry_t * next_hop

next hop to destination

evtimer_msg_event_t rtr_timeout

Event for nib.h::GNRC_IPV6_NIB_RTR_TIMEOUT.

struct _nib_offl_entry_t

Off-link NIB entry.

_nib_onl_entry_t * next_hop

next hop to destination

ipv6_addr_t pfx

prefix to the destination

evtimer_msg_event_t pfx_timeout

Event for nib.h::GNRC_IPV6_NIB_PFX_TIMEOUT.

uint8_t mode

of the off-link entry

uint8_t pfx_len

prefix-length in bits of _nib_onl_entry_t::pfx

uint16_t flags

[flags](

uint32_t valid_until

timestamp (in ms) until which the prefix valid (UINT32_MAX means forever)

uint32_t pref_until

timestamp (in ms) until which the prefix preferred (UINT32_MAX means forever)

struct _nib_abr_entry_t

Internal NIB-representation of the authoritative border router for multihop prefix and 6LoWPAN context dissemination.

ipv6_addr_t addr

The address of the border router.

uint32_t version

last received version of the info of the _nib-internal.h::_nib_abr_entry_t::addr

uint32_t valid_until

timestamp (in minutes) until which information is valid

evtimer_msg_event_t timeout

timeout of the information

BITFIELD(pfxs, ipv6/nib/conf.h::GNRC_IPV6_NIB_OFFL_NUMOF)

Bitfield marking the prefixes in the NIB’s off-link entries disseminated by _nib-internal.h::_nib_abr_entry_t::addr.

BITFIELD(ctxs, ctx.h::GNRC_SIXLOWPAN_CTX_SIZE)

Bitfield marking the contexts disseminated by _nib-internal.h::_nib_abr_entry_t::addr.