_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 "net/gnrc/ipv6/nib/conf.h"
23 #include "net/gnrc/netif/internal.h"
24 #include "net/gnrc/netif/ipv6.h"
25 #include "net/ipv6/addr.h"
26 #include "net/ndp.h"
27 
28 #include "_nib-internal.h"
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 #if GNRC_IPV6_NIB_CONF_ROUTER || defined(DOXYGEN)
35 
40 static inline void _init_iface_router(gnrc_netif_t *netif)
41 {
43  netif->ipv6.last_ra = UINT32_MAX;
44  netif->ipv6.ra_sent = 0;
46 #if !GNRC_IPV6_NIB_CONF_6LR || GNRC_IPV6_NIB_CONF_6LBR
48 #endif /* !GNRC_IPV6_NIB_CONF_6LR || GNRC_IPV6_NIB_CONF_6LBR */
49 #if GNRC_IPV6_NIB_CONF_6LBR
51 #endif /* GNRC_IPV6_NIB_CONF_6LBR */
52  gnrc_netif_ipv6_group_join(netif, &ipv6_addr_all_routers_link_local);
53 }
54 
66 static inline void _call_route_info_cb(gnrc_netif_t *netif, unsigned type,
67  const ipv6_addr_t *ctx_addr,
68  const void *ctx)
69 {
70  if (netif->ipv6.route_info_cb != NULL) {
71  netif->ipv6.route_info_cb(type, ctx_addr, ctx);
72  }
73 }
74 
80 void _handle_reply_rs(_nib_onl_entry_t *host);
81 
88 void _handle_snd_mc_ra(gnrc_netif_t *netif);
89 
97 void _set_rtr_adv(gnrc_netif_t *netif);
98 
111 void _snd_rtr_advs(gnrc_netif_t *netif, const ipv6_addr_t *dst,
112  bool final);
113 #else /* GNRC_IPV6_NIB_CONF_ROUTER */
114 #define _init_iface_router(netif) (void)netif
115 #define _call_route_info_cb(netif, type, ctx_addr, ctx) (void)netif; \
116  (void)type; \
117  (void)ctx_addr; \
118  (void)ctx
119 #define _handle_reply_rs(host) (void)host
120 #define _handle_snd_mc_ra(netif) (void)netif
121 #define _set_rtr_adv(netif) (void)netif
122 #define _snd_rtr_advs(netif, dst, final) (void)netif; \
123  (void)dst; \
124  (void)final
125 #endif /* GNRC_IPV6_NIB_CONF_ROUTER */
126 
127 #ifdef __cplusplus
128 }
129 #endif
130 
131 #endif /* PRIV_NIB_ROUTER_H */
132 
Definitions for IPv6 addresses.
const ipv6_addr_t ipv6_addr_all_routers_link_local
uint32_t flags
Flags for the interface.
Definition: netif.h:76
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.
IPv6 defintions for New 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.
On-link NIB entry.
Definition: _nib-internal.h:92
static void _init_iface_router(gnrc_netif_t *netif)
Initializes interface for router behavior.
Definition: _nib-router.h:40
Configuration macro definitions for neighbor information base.
gnrc_netif_ipv6_t ipv6
IPv6 component.
Definition: netif.h:66
#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:136
Representation of a network interface.
Definition: netif.h:61
uint8_t ra_sent
number of unsolicited router advertisements sent
Data type to represent an IPv6 address.
Definition: ipv6/addr.h:74
IPv6 neighbor discovery message type definitions.
uint16_t rtr_ltime
(Advertised) Router lifetime (default 1800).