1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

gnrc_ndp_internal: adapt nbr_sol send function to get src

This commit is contained in:
Martine Lenders 2015-09-17 14:31:13 +02:00
parent b19592c478
commit 1682b76866
5 changed files with 19 additions and 13 deletions

View File

@ -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);
/**

View File

@ -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);

View File

@ -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) {

View File

@ -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);

View File

@ -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);