mirror of
https://github.com/oliverschmidt/contiki.git
synced 2025-01-10 11:29:38 +00:00
replaces with aligned lladdress and also fixed the second memcpy to avoid risk of inconsistency when nodes change MAC address
This commit is contained in:
parent
510fc9e51e
commit
b2f72fc996
@ -490,16 +490,16 @@ na_input(void)
|
|||||||
PRINTF("NA received is bad\n");
|
PRINTF("NA received is bad\n");
|
||||||
goto discard;
|
goto discard;
|
||||||
} else {
|
} else {
|
||||||
uip_lladdr_t *lladdr;
|
uip_lladdr_t lladdr_aligned;
|
||||||
nbr = uip_ds6_nbr_lookup(&UIP_ND6_NA_BUF->tgtipaddr);
|
nbr = uip_ds6_nbr_lookup(&UIP_ND6_NA_BUF->tgtipaddr);
|
||||||
if(nbr == NULL) {
|
if(nbr == NULL) {
|
||||||
goto discard;
|
goto discard;
|
||||||
}
|
}
|
||||||
lladdr = (uip_lladdr_t *)uip_ds6_nbr_get_ll(nbr);
|
extract_lladdr_aligned(&lladdr_aligned);
|
||||||
|
|
||||||
if(nd6_opt_llao != 0) {
|
if(nd6_opt_llao != 0) {
|
||||||
is_llchange =
|
is_llchange =
|
||||||
memcmp(&nd6_opt_llao[UIP_ND6_OPT_DATA_OFFSET], (void *)lladdr,
|
memcmp(&nd6_opt_llao[UIP_ND6_OPT_DATA_OFFSET], (void *)&lladdr_aligned,
|
||||||
UIP_LLADDR_LEN);
|
UIP_LLADDR_LEN);
|
||||||
}
|
}
|
||||||
if(nbr->state == NBR_INCOMPLETE) {
|
if(nbr->state == NBR_INCOMPLETE) {
|
||||||
@ -511,7 +511,7 @@ na_input(void)
|
|||||||
uip_ds6_nbr_rm(nbr);
|
uip_ds6_nbr_rm(nbr);
|
||||||
/* Re-add this neighbor - now with a correct MAC address */
|
/* Re-add this neighbor - now with a correct MAC address */
|
||||||
nbr = uip_ds6_nbr_add(&UIP_ND6_NA_BUF->tgtipaddr,
|
nbr = uip_ds6_nbr_add(&UIP_ND6_NA_BUF->tgtipaddr,
|
||||||
(const uip_lladdr_t *) &nd6_opt_llao[UIP_ND6_OPT_DATA_OFFSET],
|
&lladdr_aligned,
|
||||||
is_router, NBR_STALE);
|
is_router, NBR_STALE);
|
||||||
if(nbr == NULL) {
|
if(nbr == NULL) {
|
||||||
goto discard;
|
goto discard;
|
||||||
@ -537,8 +537,15 @@ na_input(void)
|
|||||||
if(is_override || (!is_override && nd6_opt_llao != 0 && !is_llchange)
|
if(is_override || (!is_override && nd6_opt_llao != 0 && !is_llchange)
|
||||||
|| nd6_opt_llao == 0) {
|
|| nd6_opt_llao == 0) {
|
||||||
if(nd6_opt_llao != 0) {
|
if(nd6_opt_llao != 0) {
|
||||||
memcpy(lladdr, &nd6_opt_llao[UIP_ND6_OPT_DATA_OFFSET],
|
/* Remove this neighbor - since it has updated its MAC address */
|
||||||
UIP_LLADDR_LEN);
|
uip_ds6_nbr_rm(nbr);
|
||||||
|
/* Re-add this neighbor - now with a correct (new) MAC address */
|
||||||
|
nbr = uip_ds6_nbr_add(&UIP_ND6_NA_BUF->tgtipaddr,
|
||||||
|
&lladdr_aligned,
|
||||||
|
is_router, NBR_STALE);
|
||||||
|
if(nbr == NULL) {
|
||||||
|
goto discard;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(is_solicited) {
|
if(is_solicited) {
|
||||||
nbr->state = NBR_REACHABLE;
|
nbr->state = NBR_REACHABLE;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user