_nib-6ln.h
Go to the documentation of this file.
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_6LN_H
20 #define PRIV_NIB_6LN_H
21 
22 #include <stdint.h>
23 
24 #include "net/gnrc/ipv6/nib/conf.h"
25 #include "net/sixlowpan/nd.h"
26 #include "timex.h"
27 #include "xtimer.h"
28 
29 #include "_nib-arsm.h"
30 #include "_nib-internal.h"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 static inline uint32_t _now_min(void)
37 {
38  return (uint32_t)((xtimer_now_usec64() / (US_PER_SEC * SEC_PER_MIN)) &
39  UINT32_MAX);
40 }
41 
42 #if GNRC_IPV6_NIB_CONF_6LN || defined(DOXYGEN)
43 
47 #define _ADDR_REG_STATUS_TENTATIVE (3)
48 
53 #define _ADDR_REG_STATUS_IGNORE (4)
54 
65 bool _resolve_addr_from_ipv6(const ipv6_addr_t *dst, gnrc_netif_t *netif,
66  gnrc_ipv6_nib_nc_t *nce);
67 
77 static inline uint32_t _get_next_rs_interval(const gnrc_netif_t *netif)
78 {
79  if (gnrc_netif_is_6ln(netif)) {
80  if (netif->ipv6.rs_sent < SIXLOWPAN_ND_MAX_RS_NUMOF) {
82  }
83  else {
84  unsigned exp = netif->ipv6.rs_sent - SIXLOWPAN_ND_MAX_RS_NUMOF;
85  uint32_t tmp = SIXLOWPAN_ND_RS_MSEC_INTERVAL +
86  ((1 << exp) * (NDP_RS_MS_INTERVAL));
87 
90  }
91  return tmp;
92  }
93  }
94  else {
95  return NDP_RS_MS_INTERVAL;
96  }
97 }
98 
112 uint8_t _handle_aro(gnrc_netif_t *netif, const ipv6_hdr_t *ipv6,
113  const icmpv6_hdr_t *icmpv6,
114  const sixlowpan_nd_opt_ar_t *aro, const ndp_opt_t *sl2ao,
115  _nib_onl_entry_t *nce);
116 
122 void _handle_rereg_address(const ipv6_addr_t *addr);
123 
124 #if GNRC_IPV6_NIB_CONF_MULTIHOP_P6C || defined(DOXYGEN)
125 _nib_abr_entry_t *_handle_abro(const sixlowpan_nd_opt_abr_t *abro);
126 uint32_t _handle_6co(const icmpv6_hdr_t *icmpv6,
127  const sixlowpan_nd_opt_6ctx_t *sixco,
128  _nib_abr_entry_t *abr);
129 #else /* GNRC_IPV6_NIB_CONF_MULTIHOP_P6C || defined(DOXYGEN) */
130 uint32_t _handle_6co(const icmpv6_hdr_t *icmpv6,
131  const sixlowpan_nd_opt_6ctx_t *sixco);
132 #endif /* GNRC_IPV6_NIB_CONF_MULTIHOP_P6C || defined(DOXYGEN) */
133 #else /* GNRC_IPV6_NIB_CONF_6LN || defined(DOXYGEN) */
134 #define _resolve_addr_from_ipv6(dst, netif, nce) (false)
135 /* _handle_aro() doesn't make sense without 6LR so don't even use it
136  * => throw error in case it is compiled in => don't define it here as NOP macro
137  */
138 #define _get_next_rs_interval(netif) (NDP_RS_MS_INTERVAL)
139 #define _handle_rereg_address(netif) (void)netif
140 #if GNRC_IPV6_NIB_CONF_MULTIHOP_P6C || defined(DOXYGEN)
141 #define _handle_abro(abro) (NULL)
142 #define _handle_6co(icmpv6, sixco, abr) (UINT32_MAX)
143 #else /* GNRC_IPV6_NIB_CONF_MULTIHOP_P6C || defined(DOXYGEN) */
144 #define _handle_6co(icmpv6, sixco) (UINT32_MAX)
145 #endif /* GNRC_IPV6_NIB_CONF_MULTIHOP_P6C || defined(DOXYGEN) */
146 #endif /* GNRC_IPV6_NIB_CONF_6LN || defined(DOXYGEN) */
147 
148 
149 #ifdef __cplusplus
150 }
151 #endif
152 
153 #endif /* PRIV_NIB_6LN_H */
154 
Address registration option format.
Definition: sixlowpan/nd.h:155
uint8_t rs_sent
number of unsolicited router solicitations scheduled
static uint64_t xtimer_now_usec64(void)
get the current system time in microseconds since start
#define SEC_PER_MIN
The number of seconds per minute.
Definition: timex.h:39
Data type to represent an IPv6 packet header.
Definition: ipv6/hdr.h:68
static uint32_t _get_next_rs_interval(const gnrc_netif_t *netif)
Calculates exponential backoff for RS retransmissions.
Definition: _nib-6ln.h:77
Neighbor cache entry view on NIB.
Definition: nc.h:142
#define SIXLOWPAN_ND_MAX_RS_NUMOF
MAX_RTR_SOLICITATIONS.
Definition: sixlowpan/nd.h:125
#define SIXLOWPAN_ND_MAX_RS_SEC_INTERVAL
MAX_RTR_SOLICITATIONS_INTERVAL (in seconds)
Definition: sixlowpan/nd.h:129
Authoritative border router option format.
Definition: sixlowpan/nd.h:186
#define SIXLOWPAN_ND_RS_MSEC_INTERVAL
RTR_SOLICITATION_INTERVAL (in msec)
Definition: sixlowpan/nd.h:124
General NDP option format.
Definition: ndp.h:265
On-link NIB entry.
Definition: _nib-internal.h:92
bool _resolve_addr_from_ipv6(const ipv6_addr_t *dst, gnrc_netif_t *netif, gnrc_ipv6_nib_nc_t *nce)
Resolves address statically from destination address using reverse translation of the IID...
Utility library for comparing and computing timestamps.
#define MS_PER_SEC
The number of milliseconds per second.
Definition: timex.h:49
Message type and helper function definitions for 6LoWPAN-ND.
Configuration macro definitions for neighbor information base.
gnrc_netif_ipv6_t ipv6
IPv6 component.
Definition: netif.h:66
xtimer interface definitions
Representation of a network interface.
Definition: netif.h:61
uint8_t _handle_aro(gnrc_netif_t *netif, const ipv6_hdr_t *ipv6, const icmpv6_hdr_t *icmpv6, const sixlowpan_nd_opt_ar_t *aro, const ndp_opt_t *sl2ao, _nib_onl_entry_t *nce)
Handles ARO.
General ICMPv6 message format.
Definition: icmpv6.h:141
6LoWPAN context option format
Definition: sixlowpan/nd.h:171
#define US_PER_SEC
The number of microseconds per second.
Definition: timex.h:34
Internal NIB-representation of the authoritative border router for multihop prefix and 6LoWPAN contex...
Data type to represent an IPv6 address.
Definition: ipv6/addr.h:74
#define NDP_RS_MS_INTERVAL
RTR_SOLICITATION_INTERVAL (in ms)
Definition: ndp.h:145
void _handle_rereg_address(const ipv6_addr_t *addr)
Handler for GNRC_IPV6_NIB_REREG_ADDRESS event handler.