_nib-arsm.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 
21 #ifndef PRIV_NIB_ARSM_H
22 #define PRIV_NIB_ARSM_H
23 
24 #include <stdint.h>
25 
26 #include "net/gnrc/ipv6/nib/conf.h"
27 #include "net/gnrc/netif.h"
28 #include "net/ndp.h"
29 #include "net/icmpv6.h"
30 
31 #include "_nib-internal.h"
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
51 void _snd_ns(const ipv6_addr_t *tgt, gnrc_netif_t *netif,
52  const ipv6_addr_t *src, const ipv6_addr_t *dst);
53 
66 void _snd_uc_ns(_nib_onl_entry_t *nbr, bool reset);
67 
81 void _handle_sl2ao(gnrc_netif_t *netif, const ipv6_hdr_t *ipv6,
82  const icmpv6_hdr_t *icmpv6, const ndp_opt_t *sl2ao);
83 
103 static inline uint32_t _exp_backoff_retrans_timer_factor(uint8_t ns_sent,
104  uint32_t retrans_timer,
105  uint32_t factor)
106 {
107  assert(NDP_MIN_RANDOM_FACTOR <= factor);
108  assert(factor < NDP_MAX_RANDOM_FACTOR);
109  assert(ns_sent <= NDP_MAX_NS_NUMOF);
110  /* backoff according to https://tools.ietf.org/html/rfc7048 with
111  * BACKOFF_MULTIPLE == 2 */
112  uint32_t res = (uint32_t)(((uint64_t)(((uint32_t) 1) << ns_sent) *
113  retrans_timer * factor) / US_PER_MS);
114  /* random factors were statically multiplied with 1000 */
115  if (res > NDP_MAX_RETRANS_TIMER_MS) {
117  }
118  return res;
119 }
120 
121 #if GNRC_IPV6_NIB_CONF_ARSM || defined(DOXYGEN)
122 
128 void _handle_snd_ns(_nib_onl_entry_t *nbr);
129 
136 void _handle_state_timeout(_nib_onl_entry_t *nbr);
137 
144 void _probe_nbr(_nib_onl_entry_t *nbr, bool reset);
145 
161 void _handle_adv_l2(gnrc_netif_t *netif, _nib_onl_entry_t *nce,
162  const icmpv6_hdr_t *icmpv6, const ndp_opt_t *tl2ao);
163 
164 
173 void _recalc_reach_time(gnrc_netif_ipv6_t *netif);
174 
182 void _set_reachable(gnrc_netif_t *netif, _nib_onl_entry_t *nce);
183 
189 static inline void _init_iface_arsm(gnrc_netif_t *netif)
190 {
192  _recalc_reach_time(&netif->ipv6);
193 }
194 
202 static inline uint16_t _get_nud_state(_nib_onl_entry_t *nbr)
203 {
205 }
206 
215 void _set_nud_state(gnrc_netif_t *netif, _nib_onl_entry_t *nbr,
216  uint16_t state);
217 
228 bool _is_reachable(_nib_onl_entry_t *entry);
229 #else /* GNRC_IPV6_NIB_CONF_ARSM || defined(DOXYGEN) */
230 #define _handle_snd_ns(ctx) (void)ctx
231 #define _handle_state_timeout(ctx) (void)ctx
232 #define _probe_nbr(nbr, reset) (void)nbr; (void)reset
233 #define _init_iface_arsm(netif) (void)netif
234 #define _handle_adv_l2(netif, nce, icmpv6, tl2ao) (void)netif; (void)nce; \
235  (void)icmpv6; (void)tl2ao
236 #define _recalc_reach_time(netif) (void)netif
237 #define _set_reachable(netif, nce) (void)netif; (void)nce
238 #define _init_iface_arsm(netif) (void)netif
239 
240 #define _get_nud_state(nbr) (GNRC_IPV6_NIB_NC_INFO_NUD_STATE_UNMANAGED)
241 #define _set_nud_state(netif, nce, state) (void)netif; (void)nbr; (void)state
242 #define _is_reachable(entry) (true)
243 #endif /* GNRC_IPV6_NIB_CONF_ARSM || defined(DOXYGEN) */
244 
245 #ifdef __cplusplus
246 }
247 #endif
248 
249 #endif /* PRIV_NIB_ARSM_H */
250 
Data type to represent an IPv6 packet header.
Definition: hdr.h:66
uint16_t info
Information flags.
General NDP option format.
Definition: ndp.h:286
#define NDP_MAX_RANDOM_FACTOR
MAX_RANDOM_FACTOR (x 1000)
Definition: ndp.h:193
#define NDP_MIN_RANDOM_FACTOR
MIN_RANDOM_FACTOR (x 1000)
Definition: ndp.h:192
On-link NIB entry.
Definition: _nib-internal.h:93
IPv6 component for gnrc_netif_t.
Definition: ipv6.h:78
#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
uint32_t reach_time_base
Base for random reachable time calculation and advertised reachable time in ms (if GNRC_NETIF_FLAGS_I...
Definition: ipv6.h:189
#define NDP_MAX_NS_NUMOF
Maximum retransmission of neighbor solicitations when UNREACHABLE.
Definition: ndp.h:190
#define NDP_REACH_MS
REACHABLE_TIME (in ms)
Definition: ndp.h:174
Representation of a network interface.
Definition: netif.h:74
#define NDP_MAX_RETRANS_TIMER_MS
MAX_RETRANS_TIMER (in ms)
Definition: ndp.h:181
Definition for GNRC&#39;s network interfaces.
General ICMPv6 message format.
Definition: icmpv6.h:144
ICMPv6 type and function definitions.
#define GNRC_IPV6_NIB_NC_INFO_NUD_STATE_MASK
Mask for neighbor unreachability detection (NUD) states.
Definition: nc.h:47
Data type to represent an IPv6 address.
Definition: addr.h:74
#define US_PER_MS
The number of microseconds per millisecond.
Definition: timex.h:54
IPv6 neighbor discovery message type definitions.
void _snd_ns(const ipv6_addr_t *tgt, gnrc_netif_t *netif, const ipv6_addr_t *src, const ipv6_addr_t *dst)
Sends neighbor solicitation (including ARO if required)