pl.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 
20 #ifndef NET_GNRC_IPV6_NIB_PL_H
21 #define NET_GNRC_IPV6_NIB_PL_H
22 
23 #include <stdint.h>
24 #include "modules.h"
25 
26 #if IS_USED(MODULE_EVTIMER)
27 #include "evtimer.h"
28 #endif
29 #include "net/ipv6/addr.h"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
38 typedef struct {
40  uint8_t pfx_len;
41  uint16_t iface;
43  uint32_t valid_until;
45  uint32_t pref_until;
48 
77 int gnrc_ipv6_nib_pl_set(unsigned iface,
78  const ipv6_addr_t *pfx, unsigned pfx_len,
79  uint32_t valid_ltime, uint32_t pref_ltime);
80 
90 void gnrc_ipv6_nib_pl_del(unsigned iface,
91  const ipv6_addr_t *pfx, unsigned pfx_len);
92 
126 bool gnrc_ipv6_nib_pl_iter(unsigned iface, void **state,
127  gnrc_ipv6_nib_pl_t *ple);
128 
129 #if IS_USED(MODULE_EVTIMER) || defined(DOXYGEN)
139 static inline uint32_t gnrc_ipv6_nib_pl_valid_offset(const gnrc_ipv6_nib_pl_t *ple)
140 {
141 
142  return (ple->valid_until == UINT32_MAX)
143  ? UINT32_MAX
144  : (ple->valid_until - evtimer_now_msec());
145 }
146 
159 static inline uint32_t gnrc_ipv6_nib_pl_pref_offset(const gnrc_ipv6_nib_pl_t *ple)
160 {
161 
162  return (ple->pref_until == UINT32_MAX)
163  ? UINT32_MAX
164  : (ple->pref_until - evtimer_now_msec());
165 }
166 #endif
167 
176 
177 #ifdef __cplusplus
178 }
179 #endif
180 
181 #endif /* NET_GNRC_IPV6_NIB_PL_H */
evtimer API definitions
static uint32_t gnrc_ipv6_nib_pl_valid_offset(const gnrc_ipv6_nib_pl_t *ple)
Provides the time in milliseconds for which the prefix list entry is valid.
Definition: pl.h:139
bool gnrc_ipv6_nib_pl_iter(unsigned iface, void **state, gnrc_ipv6_nib_pl_t *ple)
Iterates over all prefix list entries in the NIB.
void gnrc_ipv6_nib_pl_print(gnrc_ipv6_nib_pl_t *ple)
Prints a prefix list entry.
static uint32_t gnrc_ipv6_nib_pl_pref_offset(const gnrc_ipv6_nib_pl_t *ple)
Provides the time in milliseconds for which the prefix list entry is preferred.
Definition: pl.h:159
int gnrc_ipv6_nib_pl_set(unsigned iface, const ipv6_addr_t *pfx, unsigned pfx_len, uint32_t valid_ltime, uint32_t pref_ltime)
Adds (or updates) prefix to NIB.
void gnrc_ipv6_nib_pl_del(unsigned iface, const ipv6_addr_t *pfx, unsigned pfx_len)
Deletes prefix from NIB.
static uint32_t evtimer_now_msec(void)
Return the current system time in msec.
Definition: evtimer.h:115
Definitions for IPv6 addresses.
Common macros and compiler attributes/pragmas configuration.
Prefix list entry view on NIB.
Definition: pl.h:38
uint16_t iface
interface gnrc_ipv6_nib_pl_t::pfx is assigned to
Definition: pl.h:41
uint32_t valid_until
timestamp (in ms) until which the prefix is valid
Definition: pl.h:43
uint8_t pfx_len
length of gnrc_ipv6_nib_pl_t::pfx in bits
Definition: pl.h:40
ipv6_addr_t pfx
prefix
Definition: pl.h:39
uint32_t pref_until
timestamp (in ms) until which the prefix is preferred
Definition: pl.h:45
Data type to represent an IPv6 address.
Definition: addr.h:72