bugfix: refresh correct source route

+
refreshing gateway route whenever data is received via a gateway
This commit is contained in:
fros4943 2010-03-31 09:38:42 +00:00
parent 70ab82761b
commit 3bd07ea55a

View file

@ -28,7 +28,7 @@
* *
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
* $Id: uip-over-mesh.c,v 1.18 2010/02/04 18:57:33 adamdunkels Exp $ * $Id: uip-over-mesh.c,v 1.19 2010/03/31 09:38:42 fros4943 Exp $
*/ */
/** /**
@ -90,13 +90,22 @@ recv_data(struct unicast_conn *c, const rimeaddr_t *from)
source.u8[0] = BUF->srcipaddr.u8[2]; source.u8[0] = BUF->srcipaddr.u8[2];
source.u8[1] = BUF->srcipaddr.u8[3]; source.u8[1] = BUF->srcipaddr.u8[3];
e = route_lookup(from); e = route_lookup(&source);
if(e == NULL) { if(e == NULL) {
route_add(&source, from, 10, 0); route_add(&source, from, 10, 0);
} else { } else {
route_refresh(e); route_refresh(e);
} }
/* If we received data via a gateway, we refresh the gateway route.
* Note: we refresh OUR gateway route, although we are not sure it forwarded the data. */
if(!uip_ipaddr_maskcmp(&BUF->srcipaddr, &netaddr, &netmask)) {
e = route_lookup(&gateway);
if(e != NULL) {
route_refresh(e);
}
}
/* uip_len = hc_inflate(&uip_buf[UIP_LLH_LEN], uip_len);*/ /* uip_len = hc_inflate(&uip_buf[UIP_LLH_LEN], uip_len);*/
PRINTF("uip-over-mesh: %d.%d: recv_data with len %d\n", PRINTF("uip-over-mesh: %d.%d: recv_data with len %d\n",