From 67d94fd579f59d28b5ef56e98c07ac3e3bda75cc Mon Sep 17 00:00:00 2001 From: bg- Date: Mon, 28 May 2007 16:32:43 +0000 Subject: [PATCH] * Optional AODV BAD_HOP extension. --- core/net/uaodv-def.h | 18 +++++++++++++++++- core/net/uaodv.c | 26 +++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/core/net/uaodv-def.h b/core/net/uaodv-def.h index 03370b88b..7a0f68846 100644 --- a/core/net/uaodv-def.h +++ b/core/net/uaodv-def.h @@ -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__ */ diff --git a/core/net/uaodv.c b/core/net/uaodv.c index 81c7f363e..b78b691ac 100644 --- a/core/net/uaodv.c +++ b/core/net/uaodv.c @@ -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? */