* Optional AODV BAD_HOP extension.

This commit is contained in:
bg- 2007-05-28 16:32:43 +00:00
parent ceb423c007
commit 67d94fd579
2 changed files with 42 additions and 2 deletions

View file

@ -28,7 +28,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: uaodv-def.h,v 1.4 2007/05/21 15:24:44 bg- Exp $
* $Id: uaodv-def.h,v 1.5 2007/05/28 16:33:19 bg- Exp $
*/
/**
@ -127,4 +127,20 @@ struct uaodv_msg_rrep_ack {
u8_t reserved;
};
#define RREP_HELLO_INTERVAL_EXT 1 /* Per RFC 3561. */
#define RREQ_BAD_HOP_EXT 101 /* Non standard extension /bg */
struct uaodv_extension {
u8_t type;
u8_t length;
/* u8_t value[length]; */
};
struct uaodv_bad_hop_ext {
u8_t type;
u8_t length;
u8_t unused1, unused2;
uip_ipaddr_t addrs[1];
};
#endif /* __UAODV_DEF_H__ */

View file

@ -28,7 +28,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: uaodv.c,v 1.22 2007/05/21 15:26:57 bg- Exp $
* $Id: uaodv.c,v 1.23 2007/05/28 16:32:43 bg- Exp $
*/
/**
@ -348,6 +348,30 @@ handle_incoming_rrep(void)
rm->hop_count,
uip_ipaddr_to_quad(&rm->orig_addr));
#ifdef AODV_BAD_HOP_EXTENSION
if(uip_len > (sizeof(*rm) + 2)) {
struct uaodv_bad_hop_ext *ext = (void *)(uip_appdata + sizeof(*rm));
u8_t *end = uip_appdata + uip_len;
for(;
(u8_t *)ext < end;
ext = (void *)((u8_t *)ext + ext->length + 2)) {
u8_t *eend = (u8_t *)ext + ext->length;
if(eend > end)
eend = end;
if(ext->type == RREQ_BAD_HOP_EXT) {
uip_ipaddr_t *a;
for(a = ext->addrs; (u8_t *)a < eend; a++) {
if(uip_ipaddr_cmp(a, &uip_hostaddr)) {
print_debug("BAD_HOP drop\n");
return;
}
}
}
}
}
#endif /* AODV_BAD_HOP_EXTENSION */
rt = uaodv_rt_lookup(&rm->dest_addr);
/* New forward route? */