_nib-router.h
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 
19 #ifndef PRIV_NIB_ROUTER_H
20 #define PRIV_NIB_ROUTER_H
21 
22 #include <kernel_defines.h>
23 
24 #include "net/gnrc/ipv6/nib/conf.h"
25 #include "net/gnrc/netif/internal.h"
26 #include "net/gnrc/netif/ipv6.h"
27 #include "net/ipv6/addr.h"
28 #include "net/ndp.h"
29 
30 #include "_nib-internal.h"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 #if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_ROUTER) || defined(DOXYGEN)
42 static inline void _init_iface_router(gnrc_netif_t *netif)
43 {
45  netif->ipv6.last_ra = UINT32_MAX;
46  netif->ipv6.ra_sent = 0;
48 
51  }
52 
55  }
56 }
57 
71 static inline void _call_route_info_cb(gnrc_netif_t *netif, unsigned type,
72  const ipv6_addr_t *ctx_addr,
73  const void *ctx)
74 {
75  assert(netif != NULL);
76  if (netif->ipv6.route_info_cb != NULL) {
77  netif->ipv6.route_info_cb(type, ctx_addr, ctx);
78  }
79 }
80 
86 void _handle_reply_rs(_nib_onl_entry_t *host);
87 
94 void _handle_snd_mc_ra(gnrc_netif_t *netif);
95 
103 void _set_rtr_adv(gnrc_netif_t *netif);
104 
117 void _snd_rtr_advs(gnrc_netif_t *netif, const ipv6_addr_t *dst,
118  bool final);
127 void _snd_rtr_advs_drop_pfx(gnrc_netif_t *netif, const ipv6_addr_t *dst,
128  _nib_offl_entry_t *pfx);
129 #else /* CONFIG_GNRC_IPV6_NIB_ROUTER */
130 #define _init_iface_router(netif) (void)netif
131 #define _call_route_info_cb(netif, type, ctx_addr, ctx) (void)netif; \
132  (void)type; \
133  (void)ctx_addr; \
134  (void)ctx
135 #define _handle_reply_rs(host) (void)host
136 #define _handle_snd_mc_ra(netif) (void)netif
137 #define _set_rtr_adv(netif) (void)netif
138 #define _snd_rtr_advs(netif, dst, final) (void)netif; \
139  (void)dst; \
140  (void)final
141 #define _snd_rtr_advs_drop_pfx(netif, dst, pfx) (void)netif; \
142  (void)dst; \
143  (void)pfx;
144 #endif /* CONFIG_GNRC_IPV6_NIB_ROUTER */
145 
146 #ifdef __cplusplus
147 }
148 #endif
149 
150 #endif /* PRIV_NIB_ROUTER_H */
#define assert(cond)
abort the program if assertion is false
Definition: assert.h:136
#define GNRC_NETIF_FLAGS_IPV6_RTR_ADV
Network interface advertises itself as an IPv6 router (implies GNRC_NETIF_FLAGS_IPV6_FORWARDING to be...
Definition: flags.h:58
#define GNRC_NETIF_FLAGS_6LO_ABR
This interface acts as a 6Lo border router to the LLN.
Definition: flags.h:103
#define GNRC_NETIF_FLAGS_IPV6_FORWARDING
Network interface is enabled for IPv6 forwarding.
Definition: flags.h:52
IPv6 definitions for Network interface API.
#define CONFIG_GNRC_IPV6_NIB_6LBR
enable features for 6Lo border router
Definition: conf.h:91
#define CONFIG_GNRC_IPV6_NIB_ADV_ROUTER
activate router advertising at interface start-up
Definition: conf.h:131
static void _init_iface_router(gnrc_netif_t *netif)
Initializes interface for router behavior.
Definition: _nib-router.h:42
#define NDP_RTR_LTIME_SEC
default of AdvDefaultLifetime (in sec)
Definition: ndp.h:155
Definitions for IPv6 addresses.
Configuration macro definitions for neighbor information base.
Common macros and compiler attributes/pragmas configuration.
#define IS_ACTIVE(macro)
Allows to verify a macro definition outside the preprocessor.
Definition: modules.h:60
IPv6 neighbor discovery message type definitions.
Off-link NIB entry.
On-link NIB entry .
Definition: _nib-internal.h:94
uint8_t ra_sent
number of unsolicited router advertisements sent
Definition: ipv6.h:227
uint16_t rtr_ltime
(Advertised) Router lifetime (default 1800).
Definition: ipv6.h:215
uint32_t last_ra
Timestamp in milliseconds of last unsolicited router advertisement.
Definition: ipv6.h:177
void(* route_info_cb)(unsigned type, const ipv6_addr_t *ctx_addr, const void *ctx)
Route info callback.
Definition: ipv6.h:126
Representation of a network interface.
Definition: netif.h:135
uint32_t flags
Flags for the interface.
Definition: netif.h:160
gnrc_netif_ipv6_t ipv6
IPv6 component.
Definition: netif.h:147
Data type to represent an IPv6 address.
Definition: addr.h:72