Merge pull request #4216 from cgundogan/pr/network_layer/remove_timex
net/gnrc/network_layer: remove timex_t
This commit is contained in:
commit
fc831f0ec2
@ -180,7 +180,6 @@ endif
|
||||
ifneq (,$(filter gnrc_ndp,$(USEMODULE)))
|
||||
USEMODULE += gnrc_icmpv6
|
||||
USEMODULE += random
|
||||
USEMODULE += timex
|
||||
USEMODULE += xtimer
|
||||
endif
|
||||
|
||||
|
||||
@ -331,14 +331,14 @@ 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
|
||||
* neighbor.
|
||||
* The default value is @ref GNRC_NDP_RETRANS_TIMER.
|
||||
*/
|
||||
timex_t retrans_timer;
|
||||
uint32_t retrans_timer;
|
||||
xtimer_t rtr_sol_timer; /**< Timer for periodic router solicitations */
|
||||
msg_t rtr_sol_msg; /**< msg_t for gnrc_ipv6_netif_t::rtr_sol_timer */
|
||||
#if defined (MODULE_GNRC_NDP_ROUTER) || defined (MODULE_GNRC_SIXLOWPAN_ND_ROUTER)
|
||||
|
||||
@ -23,7 +23,6 @@
|
||||
#include "net/gnrc/pktbuf.h"
|
||||
#include "net/gnrc/sixlowpan/nd.h"
|
||||
#include "thread.h"
|
||||
#include "timex.h"
|
||||
#include "xtimer.h"
|
||||
|
||||
#define ENABLE_DEBUG (0)
|
||||
@ -243,9 +242,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
|
||||
|
||||
|
||||
@ -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,
|
||||
@ -541,8 +540,7 @@ void gnrc_ndp_rtr_adv_handle(kernel_pid_t iface, gnrc_pktsnip_t *pkt, ipv6_hdr_t
|
||||
}
|
||||
/* set retransmission timer from message */
|
||||
if (rtr_adv->retrans_timer.u32 != 0) {
|
||||
if_entry->retrans_timer = timex_set(0, byteorder_ntohl(rtr_adv->retrans_timer));
|
||||
timex_normalize(&if_entry->retrans_timer);
|
||||
if_entry->retrans_timer = byteorder_ntohl(rtr_adv->retrans_timer);
|
||||
}
|
||||
mutex_unlock(&if_entry->mutex);
|
||||
sicmpv6_size -= sizeof(ndp_rtr_adv_t);
|
||||
@ -674,9 +672,7 @@ void gnrc_ndp_retrans_nbr_sol(gnrc_ipv6_nc_t *nc_entry)
|
||||
gnrc_ndp_internal_send_nbr_sol(nc_entry->iface, NULL, &nc_entry->ipv6_addr, &dst);
|
||||
|
||||
mutex_lock(&ipv6_iface->mutex);
|
||||
gnrc_ndp_internal_reset_nbr_sol_timer(nc_entry, (uint32_t) timex_uint64(
|
||||
ipv6_iface->retrans_timer
|
||||
),
|
||||
gnrc_ndp_internal_reset_nbr_sol_timer(nc_entry, ipv6_iface->retrans_timer,
|
||||
GNRC_NDP_MSG_NBR_SOL_RETRANS, gnrc_ipv6_pid);
|
||||
mutex_unlock(&ipv6_iface->mutex);
|
||||
}
|
||||
@ -723,8 +719,7 @@ void gnrc_ndp_netif_add(gnrc_ipv6_netif_t *iface)
|
||||
/* set default values */
|
||||
mutex_lock(&iface->mutex);
|
||||
_set_reach_time(iface, GNRC_NDP_REACH_TIME);
|
||||
iface->retrans_timer = timex_set(0, GNRC_NDP_RETRANS_TIMER);
|
||||
timex_normalize(&iface->retrans_timer);
|
||||
iface->retrans_timer = GNRC_NDP_RETRANS_TIMER;
|
||||
mutex_unlock(&iface->mutex);
|
||||
}
|
||||
|
||||
|
||||
@ -24,13 +24,12 @@
|
||||
#define ENABLE_DEBUG (0)
|
||||
#include "debug.h"
|
||||
|
||||
static inline void _reschedule_rtr_sol(gnrc_ipv6_netif_t *iface, timex_t delay)
|
||||
static inline void _reschedule_rtr_sol(gnrc_ipv6_netif_t *iface, uint32_t delay)
|
||||
{
|
||||
xtimer_remove(&iface->rtr_sol_timer);
|
||||
iface->rtr_sol_msg.type = GNRC_NDP_MSG_RTR_SOL_RETRANS;
|
||||
iface->rtr_sol_msg.content.ptr = (char *) iface;
|
||||
xtimer_set_msg(&iface->rtr_sol_timer, (uint32_t) timex_uint64(delay), &iface->rtr_sol_msg,
|
||||
gnrc_ipv6_pid);
|
||||
xtimer_set_msg(&iface->rtr_sol_timer, delay, &iface->rtr_sol_msg, gnrc_ipv6_pid);
|
||||
}
|
||||
|
||||
void gnrc_ndp_host_init(gnrc_ipv6_netif_t *iface)
|
||||
@ -39,7 +38,7 @@ void gnrc_ndp_host_init(gnrc_ipv6_netif_t *iface)
|
||||
mutex_lock(&iface->mutex);
|
||||
iface->rtr_sol_count = GNRC_NDP_MAX_RTR_SOL_NUMOF;
|
||||
DEBUG("ndp host: delayed initial router solicitation by %" PRIu32 " usec.\n", interval);
|
||||
_reschedule_rtr_sol(iface, timex_set(0, interval));
|
||||
_reschedule_rtr_sol(iface, interval);
|
||||
mutex_unlock(&iface->mutex);
|
||||
}
|
||||
|
||||
@ -49,7 +48,7 @@ void gnrc_ndp_host_retrans_rtr_sol(gnrc_ipv6_netif_t *iface)
|
||||
if (iface->rtr_sol_count > 1) { /* regard off-by-one error */
|
||||
DEBUG("ndp hst: retransmit rtr sol in %d sec\n", GNRC_NDP_MAX_RTR_SOL_INT);
|
||||
iface->rtr_sol_count--;
|
||||
_reschedule_rtr_sol(iface, timex_set(GNRC_NDP_MAX_RTR_SOL_INT, 0));
|
||||
_reschedule_rtr_sol(iface, GNRC_NDP_MAX_RTR_SOL_INT * SEC_IN_USEC);
|
||||
}
|
||||
mutex_unlock(&iface->mutex);
|
||||
gnrc_ndp_internal_send_rtr_sol(iface->pid, NULL);
|
||||
|
||||
@ -20,7 +20,6 @@
|
||||
#include "net/gnrc/sixlowpan/ctx.h"
|
||||
#include "net/gnrc/sixlowpan/nd.h"
|
||||
#include "random.h"
|
||||
#include "timex.h"
|
||||
#include "xtimer.h"
|
||||
|
||||
#include "net/gnrc/ndp/internal.h"
|
||||
@ -92,7 +91,7 @@ ipv6_addr_t *gnrc_ndp_internal_default_router(void)
|
||||
void gnrc_ndp_internal_set_state(gnrc_ipv6_nc_t *nc_entry, uint8_t state)
|
||||
{
|
||||
gnrc_ipv6_netif_t *ipv6_iface;
|
||||
timex_t t = { GNRC_NDP_FIRST_PROBE_DELAY, 0 };
|
||||
uint32_t t = GNRC_NDP_FIRST_PROBE_DELAY * SEC_IN_USEC;
|
||||
|
||||
nc_entry->flags &= ~GNRC_IPV6_NC_STATE_MASK;
|
||||
nc_entry->flags |= state;
|
||||
@ -103,9 +102,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,26 +113,22 @@ 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:
|
||||
ipv6_iface = gnrc_ipv6_netif_get(nc_entry->iface);
|
||||
|
||||
nc_entry->probes_remaining = GNRC_NDP_MAX_UC_NBR_SOL_NUMOF;
|
||||
DEBUG("PROBE (probe with %" PRIu8 " unicast NS every %" PRIu32
|
||||
".%06" PRIu32 " seconds)\n", nc_entry->probes_remaining,
|
||||
ipv6_iface->retrans_timer.seconds,
|
||||
ipv6_iface->retrans_timer.microseconds);
|
||||
DEBUG("PROBE (probe with %" PRIu8 " unicast NS every %" PRIu32 " us)\n",
|
||||
nc_entry->probes_remaining, ipv6_iface->retrans_timer);
|
||||
|
||||
gnrc_ndp_internal_send_nbr_sol(nc_entry->iface, NULL, &nc_entry->ipv6_addr,
|
||||
&nc_entry->ipv6_addr);
|
||||
|
||||
mutex_lock(&ipv6_iface->mutex);
|
||||
gnrc_ndp_internal_reset_nbr_sol_timer(nc_entry, (uint32_t) timex_uint64(
|
||||
ipv6_iface->retrans_timer
|
||||
),
|
||||
gnrc_ndp_internal_reset_nbr_sol_timer(nc_entry, ipv6_iface->retrans_timer,
|
||||
GNRC_NDP_MSG_NBR_SOL_RETRANS, gnrc_ipv6_pid);
|
||||
mutex_unlock(&ipv6_iface->mutex);
|
||||
break;
|
||||
@ -550,20 +543,16 @@ 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;
|
||||
if (tmp > UINT32_MAX) {
|
||||
tmp = UINT32_MAX;
|
||||
}
|
||||
retrans_timer = (uint32_t)tmp;
|
||||
retrans_timer = ipv6_iface->retrans_timer / MS_IN_USEC;
|
||||
}
|
||||
if (!fin) {
|
||||
adv_ltime = ipv6_iface->adv_ltime;
|
||||
|
||||
@ -180,9 +180,7 @@ kernel_pid_t gnrc_ndp_node_next_hop_l2addr(uint8_t *l2addr, uint8_t *l2addr_len,
|
||||
gnrc_ndp_internal_send_nbr_sol(iface, NULL, next_hop_ip, &dst_sol);
|
||||
|
||||
mutex_lock(&ipv6_iface->mutex);
|
||||
gnrc_ndp_internal_reset_nbr_sol_timer(nc_entry, (uint32_t) timex_uint64(
|
||||
ipv6_iface->retrans_timer
|
||||
),
|
||||
gnrc_ndp_internal_reset_nbr_sol_timer(nc_entry, ipv6_iface->retrans_timer,
|
||||
GNRC_NDP_MSG_NBR_SOL_RETRANS, gnrc_ipv6_pid);
|
||||
mutex_unlock(&ipv6_iface->mutex);
|
||||
}
|
||||
|
||||
@ -16,7 +16,6 @@
|
||||
#include "net/gnrc/ndp.h"
|
||||
#include "net/gnrc/ndp/internal.h"
|
||||
#include "random.h"
|
||||
#include "timex.h"
|
||||
#include "xtimer.h"
|
||||
|
||||
#include "net/gnrc/ndp/router.h"
|
||||
|
||||
@ -23,7 +23,6 @@
|
||||
#include "net/gnrc/sixlowpan/frag.h"
|
||||
#include "net/sixlowpan.h"
|
||||
#include "thread.h"
|
||||
#include "timex.h"
|
||||
#include "xtimer.h"
|
||||
#include "utlist.h"
|
||||
|
||||
|
||||
@ -23,7 +23,6 @@
|
||||
|
||||
#include "net/gnrc/netif/hdr.h"
|
||||
#include "net/gnrc/pkt.h"
|
||||
#include "timex.h"
|
||||
|
||||
#include "net/gnrc/sixlowpan/frag.h"
|
||||
#ifdef __cplusplus
|
||||
|
||||
@ -20,7 +20,6 @@
|
||||
#include "net/gnrc/sixlowpan.h"
|
||||
#include "net/gnrc/sixlowpan/ctx.h"
|
||||
#include "random.h"
|
||||
#include "timex.h"
|
||||
|
||||
#include "net/gnrc/sixlowpan/nd.h"
|
||||
|
||||
|
||||
@ -192,7 +192,7 @@ void gnrc_sixlowpan_nd_opt_abr_handle(kernel_pid_t iface, ndp_rtr_adv_t *rtr_adv
|
||||
uint16_t opt_offset = 0;
|
||||
uint8_t *buf = (uint8_t *)(rtr_adv + 1);
|
||||
gnrc_sixlowpan_nd_router_abr_t *abr;
|
||||
timex_t t = { 0, 0 };
|
||||
uint32_t t = 0;
|
||||
|
||||
if (_is_me(&abr_opt->braddr)) {
|
||||
return;
|
||||
@ -239,12 +239,12 @@ void gnrc_sixlowpan_nd_opt_abr_handle(kernel_pid_t iface, ndp_rtr_adv_t *rtr_adv
|
||||
memset(abr->ctxs, 0, sizeof(abr->ctxs));
|
||||
abr->prfs = NULL;
|
||||
|
||||
t.seconds = abr->ltime * 60;
|
||||
t = abr->ltime * 60 * SEC_IN_USEC;
|
||||
|
||||
xtimer_remove(&abr->ltimer);
|
||||
abr->ltimer_msg.type = GNRC_SIXLOWPAN_ND_MSG_ABR_TIMEOUT;
|
||||
abr->ltimer_msg.content.ptr = (char *) abr;
|
||||
xtimer_set_msg(&abr->ltimer, (uint32_t) timex_uint64(t), &abr->ltimer_msg, gnrc_ipv6_pid);
|
||||
xtimer_set_msg(&abr->ltimer, t, &abr->ltimer_msg, gnrc_ipv6_pid);
|
||||
}
|
||||
|
||||
gnrc_pktsnip_t *gnrc_sixlowpan_nd_opt_6ctx_build(uint8_t prefix_len, uint8_t flags, uint16_t ltime,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user