From 9a74ada90c02a13787b413313fa76812a9b5ce68 Mon Sep 17 00:00:00 2001 From: Adam Dunkels Date: Sun, 11 Aug 2013 23:50:37 +0200 Subject: [PATCH] Added a function rpl_get_parent_link_metric() for obtaining the link metric of a given parent --- core/net/rpl/rpl-dag.c | 11 +++++++++++ core/net/rpl/rpl.h | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/core/net/rpl/rpl-dag.c b/core/net/rpl/rpl-dag.c index 379461a0b..826c7152b 100644 --- a/core/net/rpl/rpl-dag.c +++ b/core/net/rpl/rpl-dag.c @@ -95,6 +95,17 @@ rpl_get_parent_rank(uip_lladdr_t *addr) } } /*---------------------------------------------------------------------------*/ +uint16_t +rpl_get_parent_link_metric(uip_lladdr_t *addr) +{ + rpl_parent_t *p = nbr_table_get_from_lladdr(rpl_parents, (rimeaddr_t *)addr); + if(p != NULL) { + return p->link_metric; + } else { + return 0; + } +} +/*---------------------------------------------------------------------------*/ uip_ipaddr_t * rpl_get_parent_ipaddr(rpl_parent_t *p) { diff --git a/core/net/rpl/rpl.h b/core/net/rpl/rpl.h index 6109874ef..689e2063b 100644 --- a/core/net/rpl/rpl.h +++ b/core/net/rpl/rpl.h @@ -244,6 +244,7 @@ void rpl_remove_header(void); uint8_t rpl_invert_header(void); uip_ipaddr_t *rpl_get_parent_ipaddr(rpl_parent_t *nbr); rpl_rank_t rpl_get_parent_rank(uip_lladdr_t *addr); -void rpl_dag_init(); +uint16_t rpl_get_parent_link_metric(uip_lladdr_t *addr); +void rpl_dag_init(void); /*---------------------------------------------------------------------------*/ #endif /* RPL_H */