_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)
37 
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 
52  }
53 
56  }
57 
58  gnrc_netif_ipv6_group_join_internal(netif, &ipv6_addr_all_routers_link_local);
59 }
60 
74 static inline void _call_route_info_cb(gnrc_netif_t *netif, unsigned type,
75  const ipv6_addr_t *ctx_addr,
76  const void *ctx)
77 {
78  assert(netif != NULL);
79  if (netif->ipv6.route_info_cb != NULL) {
80  netif->ipv6.route_info_cb(type, ctx_addr, ctx);
81  }
82 }
83 
89 void _handle_reply_rs(_nib_onl_entry_t *host);
90 
97 void _handle_snd_mc_ra(gnrc_netif_t *netif);
98 
106 void _set_rtr_adv(gnrc_netif_t *netif);
107 
120 void _snd_rtr_advs(gnrc_netif_t *netif, const ipv6_addr_t *dst,
121  bool final);
122 #else /* CONFIG_GNRC_IPV6_NIB_ROUTER */
123 #define _init_iface_router(netif) (void)netif
124 #define _call_route_info_cb(netif, type, ctx_addr, ctx) (void)netif; \
125  (void)type; \
126  (void)ctx_addr; \
127  (void)ctx
128 #define _handle_reply_rs(host) (void)host
129 #define _handle_snd_mc_ra(netif) (void)netif
130 #define _set_rtr_adv(netif) (void)netif
131 #define _snd_rtr_advs(netif, dst, final) (void)netif; \
132  (void)dst; \
133  (void)final
134 #endif /* CONFIG_GNRC_IPV6_NIB_ROUTER */
135 
136 #ifdef __cplusplus
137 }
138 #endif
139 
140 #endif /* PRIV_NIB_ROUTER_H */
141 
#define CONFIG_GNRC_IPV6_NIB_6LR
enable features for 6Lo router
Definition: conf.h:103
Definitions for IPv6 addresses.
const ipv6_addr_t ipv6_addr_all_routers_link_local
uint32_t flags
Flags for the interface.
Definition: netif.h:96
void _set_rtr_adv(gnrc_netif_t *netif)
Sets the GNRC_NETIF_FLAGS_IPV6_RTR_ADV flags of an interface.
#define GNRC_NETIF_FLAGS_6LO_ABR
This interface acts as a 6Lo border router to the LLN.
Definition: flags.h:103
void(* route_info_cb)(unsigned type, const ipv6_addr_t *ctx_addr, const void *ctx)
Route info callback.
Definition: ipv6.h:127
IPv6 definitions for Network interface API.
#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
uint32_t last_ra
Timestamp in milliseconds of last unsolicited router advertisement.
Definition: ipv6.h:178
On-link NIB entry.
Definition: _nib-internal.h:94
static void _init_iface_router(gnrc_netif_t *netif)
Initializes interface for router behavior.
Definition: _nib-router.h:42
#define IS_ACTIVE(macro)
Allows to verify a macro definition outside the preprocessor.
#define assert(cond)
abort the program if assertion is false
Definition: assert.h:104
Configuration macro definitions for neighbor information base.
gnrc_netif_ipv6_t ipv6
IPv6 component.
Definition: netif.h:86
#define GNRC_NETIF_FLAGS_IPV6_FORWARDING
Network interface is enabled for IPv6 forwarding.
Definition: flags.h:52
#define NDP_RTR_LTIME_SEC
default of AdvDefaultLifetime (in sec)
Definition: ndp.h:143
Representation of a network interface.
Definition: netif.h:74
Common macros and compiler attributes/pragmas configuration.
uint8_t ra_sent
number of unsolicited router advertisements sent
Definition: ipv6.h:228
Data type to represent an IPv6 address.
Definition: addr.h:74
IPv6 neighbor discovery message type definitions.
uint16_t rtr_ltime
(Advertised) Router lifetime (default 1800).
Definition: ipv6.h:216
#define CONFIG_GNRC_IPV6_NIB_6LBR
enable features for 6Lo border router
Definition: conf.h:93