pl.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 
20 #include <stdint.h>
21 #include "modules.h"
22 
23 #if IS_USED(MODULE_EVTIMER)
24 #include "evtimer.h"
25 #endif
26 #include "net/ipv6/addr.h"
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
35 typedef struct {
37  uint8_t pfx_len;
38  uint16_t iface;
40  uint32_t valid_until;
42  uint32_t pref_until;
45 
74 int gnrc_ipv6_nib_pl_set(unsigned iface,
75  const ipv6_addr_t *pfx, unsigned pfx_len,
76  uint32_t valid_ltime, uint32_t pref_ltime);
77 
87 void gnrc_ipv6_nib_pl_del(unsigned iface,
88  const ipv6_addr_t *pfx, unsigned pfx_len);
89 
123 bool gnrc_ipv6_nib_pl_iter(unsigned iface, void **state,
124  gnrc_ipv6_nib_pl_t *ple);
125 
126 #if IS_USED(MODULE_EVTIMER) || defined(DOXYGEN)
136 static inline uint32_t gnrc_ipv6_nib_pl_valid_offset(const gnrc_ipv6_nib_pl_t *ple)
137 {
138 
139  return (ple->valid_until == UINT32_MAX)
140  ? UINT32_MAX
141  : (ple->valid_until - evtimer_now_msec());
142 }
143 
156 static inline uint32_t gnrc_ipv6_nib_pl_pref_offset(const gnrc_ipv6_nib_pl_t *ple)
157 {
158 
159  return (ple->pref_until == UINT32_MAX)
160  ? UINT32_MAX
161  : (ple->pref_until - evtimer_now_msec());
162 }
163 #endif
164 
173 
174 #ifdef __cplusplus
175 }
176 #endif
177 
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:136
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:156
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:111
Definitions for IPv6 addresses.
Common macros and compiler attributes/pragmas configuration.
Prefix list entry view on NIB.
Definition: pl.h:35
uint16_t iface
interface gnrc_ipv6_nib_pl_t::pfx is assigned to
Definition: pl.h:38
uint32_t valid_until
timestamp (in ms) until which the prefix is valid
Definition: pl.h:40
uint8_t pfx_len
length of gnrc_ipv6_nib_pl_t::pfx in bits
Definition: pl.h:37
ipv6_addr_t pfx
prefix
Definition: pl.h:36
uint32_t pref_until
timestamp (in ms) until which the prefix is preferred
Definition: pl.h:42
Data type to represent an IPv6 address.
Definition: addr.h:64