_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  gnrc_netif_ipv6_group_join_internal(netif, &ipv6_addr_all_routers_link_local);
58 }
59 
73 static inline void _call_route_info_cb(gnrc_netif_t *netif, unsigned type,
74  const ipv6_addr_t *ctx_addr,
75  const void *ctx)
76 {
77  assert(netif != NULL);
78  if (netif->ipv6.route_info_cb != NULL) {
79  netif->ipv6.route_info_cb(type, ctx_addr, ctx);
80  }
81 }
82 
88 void _handle_reply_rs(_nib_onl_entry_t *host);
89 
96 void _handle_snd_mc_ra(gnrc_netif_t *netif);
97 
105 void _set_rtr_adv(gnrc_netif_t *netif);
106 
119 void _snd_rtr_advs(gnrc_netif_t *netif, const ipv6_addr_t *dst,
120  bool final);
129 void _snd_rtr_advs_drop_pfx(gnrc_netif_t *netif, const ipv6_addr_t *dst,
130  _nib_offl_entry_t *pfx);
131 #else /* CONFIG_GNRC_IPV6_NIB_ROUTER */
132 #define _init_iface_router(netif) (void)netif
133 #define _call_route_info_cb(netif, type, ctx_addr, ctx) (void)netif; \
134  (void)type; \
135  (void)ctx_addr; \
136  (void)ctx
137 #define _handle_reply_rs(host) (void)host
138 #define _handle_snd_mc_ra(netif) (void)netif
139 #define _set_rtr_adv(netif) (void)netif
140 #define _snd_rtr_advs(netif, dst, final) (void)netif; \
141  (void)dst; \
142  (void)final
143 #define _snd_rtr_advs_drop_pfx(netif, dst, pfx) (void)netif; \
144  (void)dst; \
145  (void)pfx;
146 #endif /* CONFIG_GNRC_IPV6_NIB_ROUTER */
147 
148 #ifdef __cplusplus
149 }
150 #endif
151 
152 #endif /* PRIV_NIB_ROUTER_H */
#define assert(cond)
abort the program if assertion is false
Definition: assert.h:113
#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:96
#define CONFIG_GNRC_IPV6_NIB_ADV_ROUTER
(de-)activate router advertising at interface start-up
Definition: conf.h:142
static void _init_iface_router(gnrc_netif_t *netif)
Initializes interface for router behavior.
Definition: _nib-router.h:42
const ipv6_addr_t ipv6_addr_all_routers_link_local
#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.
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:116
uint32_t flags
Flags for the interface.
Definition: netif.h:141
gnrc_netif_ipv6_t ipv6
IPv6 component.
Definition: netif.h:128
Data type to represent an IPv6 address.
Definition: addr.h:72