abr.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2017 Freie Universität Berlin
3  * SPDX-License-Identifier: LGPL-2.1-only
4  */
5 
6 #pragma once
7 
21 #include "modules.h"
22 
23 /* prevent cascading include error to xtimer if it is not compiled in or not
24  * supported by board */
25 #if IS_USED(MODULE_EVTIMER)
26 #include "timex.h"
27 #include "evtimer.h"
28 #endif
29 #include "net/ipv6/addr.h"
30 #include "net/gnrc/ipv6/nib/conf.h"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
39 typedef struct {
41  uint32_t version;
42  uint32_t valid_until_ms;
45 
46 #if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_MULTIHOP_P6C) || defined(DOXYGEN)
47 #if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_6LBR) || defined(DOXYGEN)
59 
66 #else /* CONFIG_GNRC_IPV6_NIB_6LBR || defined(DOXYGEN) */
67 #define gnrc_ipv6_nib_abr_add(addr) (-ENOTSUP)
68 #define gnrc_ipv6_nib_abr_del(addr) (void)(addr)
69 #endif /* CONFIG_GNRC_IPV6_NIB_6LBR || defined(DOXYGEN) */
70 
104 
105 #if IS_USED(MODULE_EVTIMER) || defined(DOXYGEN)
115 static inline uint32_t gnrc_ipv6_nib_abr_valid_offset(const gnrc_ipv6_nib_abr_t *abr)
116 {
117  return (abr->valid_until_ms - evtimer_now_msec()) / ( MS_PER_SEC * SEC_PER_MIN);
118 }
119 #endif
120 
129 #else /* CONFIG_GNRC_IPV6_NIB_MULTIHOP_P6C || defined(DOXYGEN) */
130 #define gnrc_ipv6_nib_abr_add(addr) (-ENOTSUP)
131 #define gnrc_ipv6_nib_abr_del(addr) (void)(addr)
132 #define gnrc_ipv6_nib_abr_iter(state, abr) (false)
133 #define gnrc_ipv6_nib_abr_print(abr) (void)(abr)
134 #endif /* CONFIG_GNRC_IPV6_NIB_MULTIHOP_P6C || defined(DOXYGEN) */
135 
136 #ifdef __cplusplus
137 }
138 #endif
139 
evtimer API definitions
bool gnrc_ipv6_nib_abr_iter(void **state, gnrc_ipv6_nib_abr_t *abr)
Iterates over all authoritative border router in the NIB.
int gnrc_ipv6_nib_abr_add(const ipv6_addr_t *addr)
Adds the address of an authoritative border router to the NIB.
static uint32_t gnrc_ipv6_nib_abr_valid_offset(const gnrc_ipv6_nib_abr_t *abr)
Provides the time in minutes for which the authoritative border router entry is valid.
Definition: abr.h:115
void gnrc_ipv6_nib_abr_del(const ipv6_addr_t *addr)
Removes an authoritative border router from the NIB.
void gnrc_ipv6_nib_abr_print(gnrc_ipv6_nib_abr_t *abr)
Prints an authoritative border router list entry.
static uint32_t evtimer_now_msec(void)
Return the current system time in msec.
Definition: evtimer.h:111
#define MS_PER_SEC
The number of milliseconds per second.
Definition: time_units.h:71
#define SEC_PER_MIN
The number of seconds per minute.
Definition: time_units.h:61
Definitions for IPv6 addresses.
Configuration macro definitions for neighbor information base.
Common macros and compiler attributes/pragmas configuration.
Authoritative border router list entry view on NIB.
Definition: abr.h:39
uint32_t valid_until_ms
timestamp (in ms) until which the information is valid (needs resolution in minutes an 16 bits of the...
Definition: abr.h:42
uint32_t version
last received version
Definition: abr.h:41
ipv6_addr_t addr
The address of the border router.
Definition: abr.h:40
Utility library for comparing and computing timestamps.
Data type to represent an IPv6 address.
Definition: addr.h:64