uip-ds6-nbr: make ds6_neighbors a local variable

All the nbr_table API calls with ds6_neighbors are replaced with
uip_ds6_nbr APIs accordingly.
This commit is contained in:
Yasuyuki Tanaka 2018-03-31 18:35:25 +02:00 committed by Yasuyuki Tanaka
parent e29093efec
commit 8ef5c8b8c6
10 changed files with 25 additions and 24 deletions

View File

@ -38,6 +38,7 @@
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
#include "contiki.h" #include "contiki.h"
#include "httpd-simple.h" #include "httpd-simple.h"
#include "net/ipv6/uip-ds6-nbr.h"
#include "net/ipv6/uip-ds6-route.h" #include "net/ipv6/uip-ds6-route.h"
#include "batmon-sensor.h" #include "batmon-sensor.h"
#include "lib/sensors.h" #include "lib/sensors.h"
@ -436,8 +437,8 @@ PT_THREAD(generate_index(struct httpd_state *s))
PT_WAIT_THREAD(&s->generate_pt, PT_WAIT_THREAD(&s->generate_pt,
enqueue_chunk(s, 0, SECTION_OPEN "Neighbors" CONTENT_OPEN)); enqueue_chunk(s, 0, SECTION_OPEN "Neighbors" CONTENT_OPEN));
for(s->nbr = nbr_table_head(ds6_neighbors); s->nbr != NULL; for(s->nbr = uip_ds6_nbr_head(); s->nbr != NULL;
s->nbr = nbr_table_next(ds6_neighbors, s->nbr)) { s->nbr = uip_ds6_nbr_next(s->nbr)) {
PT_WAIT_THREAD(&s->generate_pt, enqueue_chunk(s, 0, "\n")); PT_WAIT_THREAD(&s->generate_pt, enqueue_chunk(s, 0, "\n"));

View File

@ -45,6 +45,7 @@
#include "contiki-net.h" #include "contiki-net.h"
#include "net/ipv6/uip.h" #include "net/ipv6/uip.h"
#include "net/ipv6/uip-ds6.h" #include "net/ipv6/uip-ds6.h"
#include "net/ipv6/uip-ds6-nbr.h"
#include "net/routing/routing.h" #include "net/routing/routing.h"
#include "dev/leds.h" #include "dev/leds.h"
#include "ip64/ip64.h" #include "ip64/ip64.h"
@ -142,9 +143,9 @@ PT_THREAD(generate_routes(struct httpd_state *s))
#endif #endif
ADD("Neighbors<pre>"); ADD("Neighbors<pre>");
for(nbr = nbr_table_head(ds6_neighbors); for(nbr = uip_ds6_nbr_head();
nbr != NULL; nbr != NULL;
nbr = nbr_table_next(ds6_neighbors, nbr)) { nbr = uip_ds6_nbr_next(nbr)) {
#if WEBSERVER_CONF_NEIGHBOR_STATUS #if WEBSERVER_CONF_NEIGHBOR_STATUS
#if BUF_USES_STACK #if BUF_USES_STACK

View File

@ -32,6 +32,7 @@
#include "contiki.h" #include "contiki.h"
#include "net/routing/routing.h" #include "net/routing/routing.h"
#include "net/ipv6/uip-ds6-nbr.h"
#include "net/ipv6/uip-ds6-route.h" #include "net/ipv6/uip-ds6-route.h"
#include "net/ipv6/uip-sr.h" #include "net/ipv6/uip-sr.h"
@ -90,9 +91,9 @@ PT_THREAD(generate_routes(struct httpd_state *s))
ADD(" Neighbors\n <ul>\n"); ADD(" Neighbors\n <ul>\n");
SEND(&s->sout); SEND(&s->sout);
for(nbr = nbr_table_head(ds6_neighbors); for(nbr = uip_ds6_nbr_head();
nbr != NULL; nbr != NULL;
nbr = nbr_table_next(ds6_neighbors, nbr)) { nbr = uip_ds6_nbr_next(nbr)) {
ADD(" <li>"); ADD(" <li>");
ipaddr_add(&nbr->ipaddr); ipaddr_add(&nbr->ipaddr);
ADD("</li>\n"); ADD("</li>\n");

View File

@ -60,7 +60,7 @@
#define LOG_MODULE "IPv6 Nbr" #define LOG_MODULE "IPv6 Nbr"
#define LOG_LEVEL LOG_LEVEL_IPV6 #define LOG_LEVEL LOG_LEVEL_IPV6
NBR_TABLE_GLOBAL(uip_ds6_nbr_t, ds6_neighbors); NBR_TABLE(uip_ds6_nbr_t, ds6_neighbors);
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void void

View File

@ -63,8 +63,6 @@
#define NBR_DELAY 3 #define NBR_DELAY 3
#define NBR_PROBE 4 #define NBR_PROBE 4
NBR_TABLE_DECLARE(ds6_neighbors);
/** \brief An entry in the nbr cache */ /** \brief An entry in the nbr cache */
typedef struct uip_ds6_nbr { typedef struct uip_ds6_nbr {
uip_ipaddr_t ipaddr; uip_ipaddr_t ipaddr;

View File

@ -126,7 +126,7 @@ rpl_get_nbr(rpl_parent_t *parent)
{ {
const linkaddr_t *lladdr = rpl_get_parent_lladdr(parent); const linkaddr_t *lladdr = rpl_get_parent_lladdr(parent);
if(lladdr != NULL) { if(lladdr != NULL) {
return nbr_table_get_from_lladdr(ds6_neighbors, lladdr); return uip_ds6_nbr_ll_lookup((const uip_lladdr_t *)lladdr);
} else { } else {
return NULL; return NULL;
} }
@ -145,9 +145,9 @@ rpl_dag_init(void)
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
rpl_parent_t * rpl_parent_t *
rpl_get_parent(uip_lladdr_t *addr) rpl_get_parent(const uip_lladdr_t *addr)
{ {
rpl_parent_t *p = nbr_table_get_from_lladdr(rpl_parents, (linkaddr_t *)addr); rpl_parent_t *p = nbr_table_get_from_lladdr(rpl_parents, (const linkaddr_t *)addr);
return p; return p;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/

View File

@ -70,7 +70,7 @@
static int num_parents; /* any node that are possible parents */ static int num_parents; /* any node that are possible parents */
static int num_children; /* all children that we have as nexthop */ static int num_children; /* all children that we have as nexthop */
static int num_free; static int num_free;
static linkaddr_t *worst_rank_nbr; /* the parent that has the worst rank */ static const linkaddr_t *worst_rank_nbr; /* the parent that has the worst rank */
static rpl_rank_t worst_rank; static rpl_rank_t worst_rank;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
#if LOG_DBG_ENABLED #if LOG_DBG_ENABLED
@ -112,9 +112,9 @@ update_nbr(void)
num_parents = 0; num_parents = 0;
num_children = 0; num_children = 0;
nbr = nbr_table_head(ds6_neighbors); nbr = uip_ds6_nbr_head();
while(nbr != NULL) { while(nbr != NULL) {
linkaddr_t *lladdr = nbr_table_get_lladdr(ds6_neighbors, nbr); const linkaddr_t *lladdr = (const linkaddr_t *)uip_ds6_nbr_get_ll(nbr);
is_used = 0; is_used = 0;
/* /*
@ -127,7 +127,7 @@ update_nbr(void)
num_children++; num_children++;
} }
parent = rpl_get_parent((uip_lladdr_t *)lladdr); parent = rpl_get_parent((const uip_lladdr_t *)lladdr);
if(parent != NULL) { if(parent != NULL) {
num_parents++; num_parents++;
@ -159,7 +159,7 @@ update_nbr(void)
LOG_DBG_("\n"); LOG_DBG_("\n");
} }
nbr = nbr_table_next(ds6_neighbors, nbr); nbr = uip_ds6_nbr_next(nbr);
num_used++; num_used++;
} }
/* how many more IP neighbors can be have? */ /* how many more IP neighbors can be have? */

View File

@ -285,7 +285,7 @@ uint16_t rpl_get_parent_link_metric(rpl_parent_t *p);
rpl_rank_t rpl_rank_via_parent(rpl_parent_t *p); rpl_rank_t rpl_rank_via_parent(rpl_parent_t *p);
const linkaddr_t *rpl_get_parent_lladdr(rpl_parent_t *p); const linkaddr_t *rpl_get_parent_lladdr(rpl_parent_t *p);
uip_ipaddr_t *rpl_parent_get_ipaddr(rpl_parent_t *nbr); uip_ipaddr_t *rpl_parent_get_ipaddr(rpl_parent_t *nbr);
rpl_parent_t *rpl_get_parent(uip_lladdr_t *addr); rpl_parent_t *rpl_get_parent(const uip_lladdr_t *addr);
rpl_rank_t rpl_get_parent_rank(uip_lladdr_t *addr); rpl_rank_t rpl_get_parent_rank(uip_lladdr_t *addr);
void rpl_dag_init(void); void rpl_dag_init(void);
uip_ds6_nbr_t *rpl_get_nbr(rpl_parent_t *parent); uip_ds6_nbr_t *rpl_get_nbr(rpl_parent_t *parent);

View File

@ -63,7 +63,7 @@
static int num_parents; /* all nodes that are possible parents */ static int num_parents; /* all nodes that are possible parents */
static int num_free; static int num_free;
static linkaddr_t *worst_rank_nbr_lladdr; /* lladdr of the the neighbor with the worst rank */ static const linkaddr_t *worst_rank_nbr_lladdr; /* lladdr of the the neighbor with the worst rank */
static rpl_rank_t worst_rank; static rpl_rank_t worst_rank;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
@ -79,10 +79,10 @@ update_state(void)
worst_rank_nbr_lladdr = NULL; worst_rank_nbr_lladdr = NULL;
num_parents = 0; num_parents = 0;
ds6_nbr = nbr_table_head(ds6_neighbors); ds6_nbr = uip_ds6_nbr_head();
while(ds6_nbr != NULL) { while(ds6_nbr != NULL) {
linkaddr_t *nbr_lladdr = nbr_table_get_lladdr(ds6_neighbors, ds6_nbr); const linkaddr_t *nbr_lladdr = (const linkaddr_t *)uip_ds6_nbr_get_ll(ds6_nbr);
rpl_nbr = rpl_neighbor_get_from_lladdr((uip_lladdr_t *)nbr_lladdr); rpl_nbr = rpl_neighbor_get_from_lladdr((uip_lladdr_t *)nbr_lladdr);
if(rpl_nbr != NULL && rpl_neighbor_is_parent(rpl_nbr)) { if(rpl_nbr != NULL && rpl_neighbor_is_parent(rpl_nbr)) {
@ -98,7 +98,7 @@ update_state(void)
worst_rank_nbr_lladdr = nbr_lladdr; worst_rank_nbr_lladdr = nbr_lladdr;
} }
ds6_nbr = nbr_table_next(ds6_neighbors, ds6_nbr); ds6_nbr = uip_ds6_nbr_next(ds6_nbr);
num_used++; num_used++;
} }
/* how many more IP neighbors can be have? */ /* how many more IP neighbors can be have? */

View File

@ -181,9 +181,9 @@ rpl_neighbor_count(void)
static uip_ds6_nbr_t * static uip_ds6_nbr_t *
rpl_get_ds6_nbr(rpl_nbr_t *nbr) rpl_get_ds6_nbr(rpl_nbr_t *nbr)
{ {
const linkaddr_t *lladdr = rpl_neighbor_get_lladdr(nbr); const uip_lladdr_t *lladdr = (const uip_lladdr_t *)rpl_neighbor_get_lladdr(nbr);
if(lladdr != NULL) { if(lladdr != NULL) {
return nbr_table_get_from_lladdr(ds6_neighbors, lladdr); return uip_ds6_nbr_ll_lookup(lladdr);
} else { } else {
return NULL; return NULL;
} }