From 86823a84fbaf8f66fdf66799b3c2438a16b5e8f2 Mon Sep 17 00:00:00 2001 From: nvt-se Date: Fri, 22 Oct 2010 13:50:13 +0000 Subject: [PATCH] Export fix-point representation of the ETX. Make RPL temporarily use the same representation as before. --- core/net/neighbor-info.c | 10 ++++------ core/net/neighbor-info.h | 11 ++++++++++- core/net/rpl/rpl.c | 4 +++- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/core/net/neighbor-info.c b/core/net/neighbor-info.c index 334542a84..61609015b 100644 --- a/core/net/neighbor-info.c +++ b/core/net/neighbor-info.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: neighbor-info.c,v 1.13 2010/10/22 11:34:24 joxe Exp $ + * $Id: neighbor-info.c,v 1.14 2010/10/22 13:50:13 nvt-se Exp $ */ /** * \file @@ -52,9 +52,6 @@ #define ETX_SCALE 100 #define ETX_ALPHA 70 #define ETX_FIRST_GUESS 3 - -#define ETX2FIX(etx) ((etx) << 4) -#define FIX2ETX(fix) ((fix) >> 4) /*---------------------------------------------------------------------------*/ NEIGHBOR_ATTRIBUTE(uint8_t, etx, NULL); @@ -83,7 +80,7 @@ update_etx(const rimeaddr_t *dest, int packet_etx) if(neighbor_attr_has_neighbor(dest)) { neighbor_attr_set_data(&etx, dest, &new_etx); if(new_etx != recorded_etx && subscriber_callback != NULL) { - subscriber_callback(dest, 1, FIX2ETX(new_etx)); + subscriber_callback(dest, 1, new_etx); } } } @@ -168,7 +165,8 @@ uint8_t neighbor_info_get_etx(const rimeaddr_t *addr) { uint8_t *etxp; + etxp = (uint8_t *)neighbor_attr_get_data(&etx, addr); - return etxp == NULL ? 0 : etxp; + return etxp == NULL ? 0 : *etxp; } /*---------------------------------------------------------------------------*/ diff --git a/core/net/neighbor-info.h b/core/net/neighbor-info.h index 9ab7822aa..14712bdf5 100644 --- a/core/net/neighbor-info.h +++ b/core/net/neighbor-info.h @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: neighbor-info.h,v 1.3 2010/10/22 11:34:24 joxe Exp $ + * $Id: neighbor-info.h,v 1.4 2010/10/22 13:50:13 nvt-se Exp $ */ /** * \file @@ -42,6 +42,15 @@ #include "net/rime.h" +/* ETX_DIVISOR is the value that a fix-point representation of the ETX + should be divided by in order to obtain the integer representation. */ +#define ETX_DIVISOR 16 + +/* Macros for converting between a fix-point representation of the ETX + and a integer representation. */ +#define ETX2FIX(etx) ((etx) << 4) +#define FIX2ETX(fix) ((fix) >> 4) + typedef void (*neighbor_info_subscriber_t)(const rimeaddr_t *, int known, int etx); /** diff --git a/core/net/rpl/rpl.c b/core/net/rpl/rpl.c index 543fd1c54..dede06a29 100644 --- a/core/net/rpl/rpl.c +++ b/core/net/rpl/rpl.c @@ -32,7 +32,7 @@ * * This file is part of the Contiki operating system. * - * $Id: rpl.c,v 1.9 2010/09/20 15:30:12 joxe Exp $ + * $Id: rpl.c,v 1.10 2010/10/22 13:50:13 nvt-se Exp $ */ /** * \file @@ -123,6 +123,8 @@ rpl_link_neighbor_callback(const rimeaddr_t *addr, int known, int etx) rpl_dag_t *dag; rpl_parent_t *parent; + etx = FIX2ETX(etx); + uip_ip6addr(&ipaddr, 0xfe80, 0, 0, 0, 0, 0, 0, 0); uip_ds6_set_addr_iid(&ipaddr, (uip_lladdr_t *)addr); PRINTF("RPL: Neighbor ");