Browse Source

netif: nc: ndp: gnrc_ipv6_netif_t::reach_time -> uint32_t

cc430
Cenk Gündoğan 7 years ago
parent
commit
b59fc825a3
  1. 2
      sys/include/net/gnrc/ipv6/netif.h
  2. 3
      sys/net/gnrc/network_layer/ipv6/nc/gnrc_ipv6_nc.c
  3. 3
      sys/net/gnrc/network_layer/ndp/gnrc_ndp.c
  4. 18
      sys/net/gnrc/network_layer/ndp/internal/gnrc_ndp_internal.c

2
sys/include/net/gnrc/ipv6/netif.h

@ -331,7 +331,7 @@ typedef struct {
* gnrc_ipv6_netif_t::reach_time_base microseconds devided by 10.
* Can't be greater than 1 hour.
*/
timex_t reach_time;
uint32_t reach_time;
/**
* @brief Time between retransmissions of neighbor solicitations to a

3
sys/net/gnrc/network_layer/ipv6/nc/gnrc_ipv6_nc.c

@ -243,9 +243,8 @@ gnrc_ipv6_nc_t *gnrc_ipv6_nc_still_reachable(const ipv6_addr_t *ipv6_addr)
(gnrc_ipv6_nc_get_state(entry) != GNRC_IPV6_NC_STATE_UNMANAGED)) {
#if defined(MODULE_GNRC_IPV6_NETIF) && defined(MODULE_VTIMER) && defined(MODULE_GNRC_IPV6)
gnrc_ipv6_netif_t *iface = gnrc_ipv6_netif_get(entry->iface);
timex_t t = iface->reach_time;
gnrc_ndp_internal_reset_nbr_sol_timer(entry, (uint32_t) timex_uint64(t),
gnrc_ndp_internal_reset_nbr_sol_timer(entry, iface->reach_time,
GNRC_NDP_MSG_NC_STATE_TIMEOUT, gnrc_ipv6_pid);
#endif

3
sys/net/gnrc/network_layer/ndp/gnrc_ndp.c

@ -474,8 +474,7 @@ static inline void _set_reach_time(gnrc_ipv6_netif_t *if_entry, uint32_t mean)
/* to avoid floating point number computation and have higher value entropy, the
* boundaries for the random value are multiplied by 10 and we need to account for that */
reach_time = (reach_time * if_entry->reach_time_base) / 10;
if_entry->reach_time = timex_set(0, reach_time);
timex_normalize(&if_entry->reach_time);
if_entry->reach_time = reach_time;
}
void gnrc_ndp_rtr_adv_handle(kernel_pid_t iface, gnrc_pktsnip_t *pkt, ipv6_hdr_t *ipv6,

18
sys/net/gnrc/network_layer/ndp/internal/gnrc_ndp_internal.c

@ -103,9 +103,7 @@ void gnrc_ndp_internal_set_state(gnrc_ipv6_nc_t *nc_entry, uint8_t state)
switch (state) {
case GNRC_IPV6_NC_STATE_REACHABLE:
ipv6_iface = gnrc_ipv6_netif_get(nc_entry->iface);
DEBUG("REACHABLE (reachable time = %" PRIu32 ".%06" PRIu32 ")\n",
ipv6_iface->reach_time.seconds,
ipv6_iface->reach_time.microseconds);
DEBUG("REACHABLE (reachable time = %" PRIu32 " us)\n", ipv6_iface->reach_time);
t = ipv6_iface->reach_time;
/* we intentionally fall through here to set the desired timeout t */
@ -116,8 +114,8 @@ void gnrc_ndp_internal_set_state(gnrc_ipv6_nc_t *nc_entry, uint8_t state)
GNRC_NDP_FIRST_PROBE_DELAY);
}
#endif
gnrc_ndp_internal_reset_nbr_sol_timer(nc_entry, (uint32_t) timex_uint64(t),
GNRC_NDP_MSG_NC_STATE_TIMEOUT, gnrc_ipv6_pid);
gnrc_ndp_internal_reset_nbr_sol_timer(nc_entry, t, GNRC_NDP_MSG_NC_STATE_TIMEOUT,
gnrc_ipv6_pid);
break;
case GNRC_IPV6_NC_STATE_PROBE:
@ -550,13 +548,13 @@ void gnrc_ndp_internal_send_rtr_adv(kernel_pid_t iface, ipv6_addr_t *src, ipv6_a
cur_hl = ipv6_iface->cur_hl;
}
if (ipv6_iface->flags & GNRC_IPV6_NETIF_FLAGS_ADV_REACH_TIME) {
uint64_t tmp = timex_uint64(ipv6_iface->reach_time) / MS_IN_USEC;
if (tmp > (3600 * SEC_IN_MS)) { /* tmp > 1 hour */
tmp = (3600 * SEC_IN_MS);
if (ipv6_iface->reach_time > (3600 * SEC_IN_USEC)) { /* reach_time > 1 hour */
reach_time = (3600 * SEC_IN_MS);
}
else {
reach_time = ipv6_iface->reach_time / MS_IN_USEC;
}
reach_time = (uint32_t)tmp;
}
if (ipv6_iface->flags & GNRC_IPV6_NETIF_FLAGS_ADV_RETRANS_TIMER) {
uint64_t tmp = timex_uint64(ipv6_iface->retrans_timer) / MS_IN_USEC;

Loading…
Cancel
Save