Browse Source

gnrc_ndp_internal: adapt nbr_sol send function to get src

dev/timer
Martine Lenders 7 years ago
parent
commit
1682b76866
  1. 4
      sys/include/net/gnrc/ndp/internal.h
  2. 7
      sys/net/gnrc/network_layer/ndp/gnrc_ndp.c
  3. 15
      sys/net/gnrc/network_layer/ndp/internal/gnrc_ndp_internal.c
  4. 4
      sys/net/gnrc/network_layer/ndp/node/gnrc_ndp_node.c
  5. 2
      sys/net/gnrc/network_layer/sixlowpan/nd/gnrc_sixlowpan_nd.c

4
sys/include/net/gnrc/ndp/internal.h

@ -61,12 +61,14 @@ void gnrc_ndp_internal_set_state(gnrc_ipv6_nc_t *nc_entry, uint8_t state);
* @internal
*
* @param[in] iface Interface to send over. May not be KERNEL_PID_UNDEF.
* @param[in] src Source address for the neighbor solicitation. Will be chosen from the
* interface according to @p dst, if NULL.
* @param[in] tgt Target address for the neighbor solicitation. May not be
* NULL.
* @param[in] dst Destination address for neighbor solicitation. May not be
* NULL.
*/
void gnrc_ndp_internal_send_nbr_sol(kernel_pid_t iface, ipv6_addr_t *tgt,
void gnrc_ndp_internal_send_nbr_sol(kernel_pid_t iface, ipv6_addr_t *src, ipv6_addr_t *tgt,
ipv6_addr_t *dst);
/**

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

@ -611,7 +611,8 @@ void gnrc_ndp_rtr_adv_handle(kernel_pid_t iface, gnrc_pktsnip_t *pkt, ipv6_hdr_t
* Hence, reset router solicitation counter and reset timer. */
if_entry->rtr_sol_count = 0;
gnrc_sixlowpan_nd_rtr_sol_reschedule(nc_entry, next_rtr_sol);
gnrc_ndp_internal_send_nbr_sol(nc_entry->iface, &nc_entry->ipv6_addr, &nc_entry->ipv6_addr);
gnrc_ndp_internal_send_nbr_sol(nc_entry->iface, NULL, &nc_entry->ipv6_addr,
&nc_entry->ipv6_addr);
}
#endif
}
@ -643,7 +644,7 @@ void gnrc_ndp_retrans_nbr_sol(gnrc_ipv6_nc_t *nc_entry)
size_t ifnum = gnrc_netif_get(ifs);
for (size_t i = 0; i < ifnum; i++) {
gnrc_ndp_internal_send_nbr_sol(ifs[i], &nc_entry->ipv6_addr, &dst);
gnrc_ndp_internal_send_nbr_sol(ifs[i], NULL, &nc_entry->ipv6_addr, &dst);
}
vtimer_remove(&nc_entry->nbr_sol_timer);
@ -653,7 +654,7 @@ void gnrc_ndp_retrans_nbr_sol(gnrc_ipv6_nc_t *nc_entry)
else {
gnrc_ipv6_netif_t *ipv6_iface = gnrc_ipv6_netif_get(nc_entry->iface);
gnrc_ndp_internal_send_nbr_sol(nc_entry->iface, &nc_entry->ipv6_addr, &dst);
gnrc_ndp_internal_send_nbr_sol(nc_entry->iface, NULL, &nc_entry->ipv6_addr, &dst);
mutex_lock(&ipv6_iface->mutex);
vtimer_remove(&nc_entry->nbr_sol_timer);

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

@ -127,7 +127,7 @@ void gnrc_ndp_internal_set_state(gnrc_ipv6_nc_t *nc_entry, uint8_t state)
ipv6_iface->retrans_timer.seconds,
ipv6_iface->retrans_timer.microseconds);
gnrc_ndp_internal_send_nbr_sol(nc_entry->iface, &nc_entry->ipv6_addr,
gnrc_ndp_internal_send_nbr_sol(nc_entry->iface, NULL, &nc_entry->ipv6_addr,
&nc_entry->ipv6_addr);
mutex_lock(&ipv6_iface->mutex);
@ -228,7 +228,7 @@ void gnrc_ndp_internal_send_nbr_adv(kernel_pid_t iface, ipv6_addr_t *tgt, ipv6_a
}
}
void gnrc_ndp_internal_send_nbr_sol(kernel_pid_t iface, ipv6_addr_t *tgt,
void gnrc_ndp_internal_send_nbr_sol(kernel_pid_t iface, ipv6_addr_t *src, ipv6_addr_t *tgt,
ipv6_addr_t *dst)
{
#ifdef MODULE_GNRC_SIXLOWPAN_ND
@ -236,19 +236,22 @@ void gnrc_ndp_internal_send_nbr_sol(kernel_pid_t iface, ipv6_addr_t *tgt,
assert(ipv6_iface != NULL);
#endif
gnrc_pktsnip_t *hdr, *pkt = NULL;
ipv6_addr_t *src = NULL;
/* both suppressions, since they are needed in the MODULE_GNRC_SIXLOWPAN_ND branch */
/* cppcheck-suppress variableScope */
uint8_t l2src[8];
/* cppcheck-suppress variableScope */
size_t l2src_len = 0;
DEBUG("ndp internal: send neighbor solicitation (iface: %" PRIkernel_pid ", tgt: %s, ",
iface, ipv6_addr_to_str(addr_str, tgt, sizeof(addr_str)));
DEBUG("ndp internal: send neighbor solicitation (iface: %" PRIkernel_pid ", src: %s, ",
ipv6_addr_to_str(addr_str, src, sizeof(addr_str)));
DEBUG(" tgt: %s, ", ipv6_addr_to_str(addr_str, tgt, sizeof(addr_str)));
DEBUG("dst: %s)\n", ipv6_addr_to_str(addr_str, dst, sizeof(addr_str)));
/* check if there is a fitting source address to target */
if ((src = gnrc_ipv6_netif_find_best_src_addr(iface, tgt)) != NULL) {
if (src == NULL) {
src = gnrc_ipv6_netif_find_best_src_addr(iface, tgt);
}
if (src != NULL) {
l2src_len = _get_l2src(iface, l2src, sizeof(l2src));
if (l2src_len > 0) {

4
sys/net/gnrc/network_layer/ndp/node/gnrc_ndp_node.c

@ -166,7 +166,7 @@ kernel_pid_t gnrc_ndp_node_next_hop_l2addr(uint8_t *l2addr, uint8_t *l2addr_len,
size_t ifnum = gnrc_netif_get(ifs);
for (size_t i = 0; i < ifnum; i++) {
gnrc_ndp_internal_send_nbr_sol(ifs[i], next_hop_ip, &dst_sol);
gnrc_ndp_internal_send_nbr_sol(ifs[i], NULL, next_hop_ip, &dst_sol);
}
vtimer_remove(&nc_entry->nbr_sol_timer);
@ -176,7 +176,7 @@ kernel_pid_t gnrc_ndp_node_next_hop_l2addr(uint8_t *l2addr, uint8_t *l2addr_len,
else {
gnrc_ipv6_netif_t *ipv6_iface = gnrc_ipv6_netif_get(iface);
gnrc_ndp_internal_send_nbr_sol(iface, next_hop_ip, &dst_sol);
gnrc_ndp_internal_send_nbr_sol(iface, NULL, next_hop_ip, &dst_sol);
mutex_lock(&ipv6_iface->mutex);
vtimer_remove(&nc_entry->nbr_sol_timer);

2
sys/net/gnrc/network_layer/sixlowpan/nd/gnrc_sixlowpan_nd.c

@ -377,7 +377,7 @@ void gnrc_sixlowpan_nd_wakeup(void)
timex_t t = { 0, GNRC_NDP_RETRANS_TIMER };
vtimer_remove(&router->rtr_sol_timer);
gnrc_sixlowpan_nd_uc_rtr_sol(router);
gnrc_ndp_internal_send_nbr_sol(router->iface, &router->ipv6_addr, &router->ipv6_addr);
gnrc_ndp_internal_send_nbr_sol(router->iface, NULL, &router->ipv6_addr, &router->ipv6_addr);
vtimer_remove(&router->nbr_sol_timer);
vtimer_set_msg(&router->nbr_sol_timer, t, gnrc_ipv6_pid, GNRC_NDP_MSG_NBR_SOL_RETRANS,
router);

Loading…
Cancel
Save