diff --git a/core/net/nbr-table.c b/core/net/nbr-table.c index f5d53c333..d8eaaa385 100644 --- a/core/net/nbr-table.c +++ b/core/net/nbr-table.c @@ -86,7 +86,7 @@ index_from_key(nbr_table_key_t *key) /*---------------------------------------------------------------------------*/ /* Get the neighbor index of an item */ static int -index_from_item(nbr_table_t *table, nbr_table_item_t *item) +index_from_item(nbr_table_t *table, const nbr_table_item_t *item) { return table != NULL && item != NULL ? ((int)((char *)item - (char *)table->data)) / table->item_size : -1; } @@ -100,7 +100,7 @@ item_from_key(nbr_table_t *table, nbr_table_key_t *key) /*---------------------------------------------------------------------------*/ /* Get the key af an item */ static nbr_table_key_t * -key_from_item(nbr_table_t *table, nbr_table_item_t *item) +key_from_item(nbr_table_t *table, const nbr_table_item_t *item) { return key_from_index(index_from_item(table, item)); } @@ -343,7 +343,7 @@ nbr_table_unlock(nbr_table_t *table, void *item) /*---------------------------------------------------------------------------*/ /* Get link-layer address of an item */ rimeaddr_t * -nbr_table_get_lladdr(nbr_table_t *table, void *item) +nbr_table_get_lladdr(nbr_table_t *table, const void *item) { nbr_table_key_t *key = key_from_item(table, item); return key != NULL ? &key->lladdr : NULL; diff --git a/core/net/nbr-table.h b/core/net/nbr-table.h index 113db94b6..763c0d2a5 100644 --- a/core/net/nbr-table.h +++ b/core/net/nbr-table.h @@ -97,7 +97,7 @@ int nbr_table_unlock(nbr_table_t *table, nbr_table_item_t *item); /** \name Neighbor tables: address manipulation */ /** @{ */ -rimeaddr_t *nbr_table_get_lladdr(nbr_table_t *table, nbr_table_item_t *item); +rimeaddr_t *nbr_table_get_lladdr(nbr_table_t *table, const nbr_table_item_t *item); /** @} */ #endif /* _NBR_TABLE_H_ */ diff --git a/core/net/rpl/rpl-dag.c b/core/net/rpl/rpl-dag.c index 9f396202f..f7d37a6e5 100644 --- a/core/net/rpl/rpl-dag.c +++ b/core/net/rpl/rpl-dag.c @@ -96,9 +96,9 @@ rpl_get_parent_rank(uip_lladdr_t *addr) } /*---------------------------------------------------------------------------*/ uint16_t -rpl_get_parent_link_metric(uip_lladdr_t *addr) +rpl_get_parent_link_metric(const uip_lladdr_t *addr) { - rpl_parent_t *p = nbr_table_get_from_lladdr(rpl_parents, (rimeaddr_t *)addr); + rpl_parent_t *p = nbr_table_get_from_lladdr(rpl_parents, (const rimeaddr_t *)addr); if(p != NULL) { return p->link_metric; } else { @@ -539,7 +539,7 @@ rpl_add_parent(rpl_dag_t *dag, rpl_dio_t *dio, uip_ipaddr_t *addr) rpl_parent_t *p = NULL; /* Is the parent known by ds6? Drop this request if not. * Typically, the parent is added upon receiving a DIO. */ - uip_lladdr_t *lladdr = uip_ds6_nbr_lladdr_from_ipaddr(addr); + const uip_lladdr_t *lladdr = uip_ds6_nbr_lladdr_from_ipaddr(addr); PRINTF("RPL: rpl_add_parent lladdr %p\n", lladdr); if(lladdr != NULL) { @@ -561,7 +561,7 @@ static rpl_parent_t * find_parent_any_dag_any_instance(uip_ipaddr_t *addr) { uip_ds6_nbr_t *ds6_nbr = uip_ds6_nbr_lookup(addr); - uip_lladdr_t *lladdr = uip_ds6_nbr_get_ll(ds6_nbr); + const uip_lladdr_t *lladdr = uip_ds6_nbr_get_ll(ds6_nbr); return nbr_table_get_from_lladdr(rpl_parents, (rimeaddr_t *)lladdr); } /*---------------------------------------------------------------------------*/ diff --git a/core/net/rpl/rpl.h b/core/net/rpl/rpl.h index dd3ccd9eb..b83e140ed 100644 --- a/core/net/rpl/rpl.h +++ b/core/net/rpl/rpl.h @@ -245,7 +245,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); -uint16_t rpl_get_parent_link_metric(uip_lladdr_t *addr); +uint16_t rpl_get_parent_link_metric(const uip_lladdr_t *addr); void rpl_dag_init(void); /*---------------------------------------------------------------------------*/ #endif /* RPL_H */ diff --git a/core/net/sicslowpan.c b/core/net/sicslowpan.c index cdbe33fc8..be6a2dc8d 100644 --- a/core/net/sicslowpan.c +++ b/core/net/sicslowpan.c @@ -1354,7 +1354,7 @@ send_packet(rimeaddr_t *dest) * MAC. */ static uint8_t -output(uip_lladdr_t *localdest) +output(const uip_lladdr_t *localdest) { int framer_hdrlen; diff --git a/core/net/tcpip.c b/core/net/tcpip.c index 1bd84f6e2..5d9d8858a 100644 --- a/core/net/tcpip.c +++ b/core/net/tcpip.c @@ -109,10 +109,10 @@ enum { /* Called on IP packet output. */ #if UIP_CONF_IPV6 -static uint8_t (* outputfunc)(uip_lladdr_t *a); +static uint8_t (* outputfunc)(const uip_lladdr_t *a); uint8_t -tcpip_output(uip_lladdr_t *a) +tcpip_output(const uip_lladdr_t *a) { int ret; if(outputfunc != NULL) { @@ -124,7 +124,7 @@ tcpip_output(uip_lladdr_t *a) } void -tcpip_set_outputfunc(uint8_t (*f)(uip_lladdr_t *)) +tcpip_set_outputfunc(uint8_t (*f)(const uip_lladdr_t *)) { outputfunc = f; } diff --git a/core/net/tcpip.h b/core/net/tcpip.h index 705fe4554..bb4b412b5 100644 --- a/core/net/tcpip.h +++ b/core/net/tcpip.h @@ -340,8 +340,8 @@ CCIF void tcpip_input(void); * The eventual parameter is the MAC address of the destination. */ #if UIP_CONF_IPV6 -uint8_t tcpip_output(uip_lladdr_t *); -void tcpip_set_outputfunc(uint8_t (* f)(uip_lladdr_t *)); +uint8_t tcpip_output(const uip_lladdr_t *); +void tcpip_set_outputfunc(uint8_t (* f)(const uip_lladdr_t *)); #else uint8_t tcpip_output(void); void tcpip_set_outputfunc(uint8_t (* f)(void)); diff --git a/core/net/uip-ds6-nbr.c b/core/net/uip-ds6-nbr.c index 924e9ba3d..2f07154dc 100644 --- a/core/net/uip-ds6-nbr.c +++ b/core/net/uip-ds6-nbr.c @@ -78,7 +78,7 @@ uip_ds6_neighbors_init(void) } /*---------------------------------------------------------------------------*/ uip_ds6_nbr_t * -uip_ds6_nbr_add(uip_ipaddr_t *ipaddr, uip_lladdr_t *lladdr, +uip_ds6_nbr_add(const uip_ipaddr_t *ipaddr, const uip_lladdr_t *lladdr, uint8_t isrouter, uint8_t state) { uip_ds6_nbr_t *nbr = nbr_table_add_lladdr(ds6_neighbors, (rimeaddr_t*)lladdr); @@ -125,17 +125,17 @@ uip_ds6_nbr_rm(uip_ds6_nbr_t *nbr) } /*---------------------------------------------------------------------------*/ -uip_ipaddr_t * -uip_ds6_nbr_get_ipaddr(uip_ds6_nbr_t *nbr) +const uip_ipaddr_t * +uip_ds6_nbr_get_ipaddr(const uip_ds6_nbr_t *nbr) { return (nbr != NULL) ? &nbr->ipaddr : NULL; } /*---------------------------------------------------------------------------*/ -uip_lladdr_t * -uip_ds6_nbr_get_ll(uip_ds6_nbr_t *nbr) +const uip_lladdr_t * +uip_ds6_nbr_get_ll(const uip_ds6_nbr_t *nbr) { - return (uip_lladdr_t *)nbr_table_get_lladdr(ds6_neighbors, nbr); + return (const uip_lladdr_t *)nbr_table_get_lladdr(ds6_neighbors, nbr); } /*---------------------------------------------------------------------------*/ int @@ -154,7 +154,7 @@ uip_ds6_nbr_num(void) } /*---------------------------------------------------------------------------*/ uip_ds6_nbr_t * -uip_ds6_nbr_lookup(uip_ipaddr_t *ipaddr) +uip_ds6_nbr_lookup(const uip_ipaddr_t *ipaddr) { uip_ds6_nbr_t *nbr = nbr_table_head(ds6_neighbors); if(ipaddr != NULL) { @@ -169,22 +169,22 @@ uip_ds6_nbr_lookup(uip_ipaddr_t *ipaddr) } /*---------------------------------------------------------------------------*/ uip_ds6_nbr_t * -uip_ds6_nbr_ll_lookup(uip_lladdr_t *lladdr) +uip_ds6_nbr_ll_lookup(const uip_lladdr_t *lladdr) { return nbr_table_get_from_lladdr(ds6_neighbors, (rimeaddr_t*)lladdr); } /*---------------------------------------------------------------------------*/ uip_ipaddr_t * -uip_ds6_nbr_ipaddr_from_lladdr(uip_lladdr_t *lladdr) +uip_ds6_nbr_ipaddr_from_lladdr(const uip_lladdr_t *lladdr) { uip_ds6_nbr_t *nbr = uip_ds6_nbr_ll_lookup(lladdr); return nbr ? &nbr->ipaddr : NULL; } /*---------------------------------------------------------------------------*/ -uip_lladdr_t * -uip_ds6_nbr_lladdr_from_ipaddr(uip_ipaddr_t *ipaddr) +const uip_lladdr_t * +uip_ds6_nbr_lladdr_from_ipaddr(const uip_ipaddr_t *ipaddr) { uip_ds6_nbr_t *nbr = uip_ds6_nbr_lookup(ipaddr); return nbr ? uip_ds6_nbr_get_ll(nbr) : NULL; @@ -276,7 +276,6 @@ uip_ds6_neighbor_periodic(void) nbr = nbr_table_next(ds6_neighbors, nbr); } } - /*---------------------------------------------------------------------------*/ uip_ds6_nbr_t * uip_ds6_get_least_lifetime_neighbor(void) @@ -296,3 +295,4 @@ uip_ds6_get_least_lifetime_neighbor(void) } return nbr_expiring; } +/*---------------------------------------------------------------------------*/ diff --git a/core/net/uip-ds6-nbr.h b/core/net/uip-ds6-nbr.h index 18251e189..059162710 100644 --- a/core/net/uip-ds6-nbr.h +++ b/core/net/uip-ds6-nbr.h @@ -83,15 +83,15 @@ typedef struct uip_ds6_nbr { void uip_ds6_neighbors_init(void); /** \brief Neighbor Cache basic routines */ -uip_ds6_nbr_t *uip_ds6_nbr_add(uip_ipaddr_t *ipaddr, uip_lladdr_t *lladdr, +uip_ds6_nbr_t *uip_ds6_nbr_add(const uip_ipaddr_t *ipaddr, const uip_lladdr_t *lladdr, uint8_t isrouter, uint8_t state); void uip_ds6_nbr_rm(uip_ds6_nbr_t *nbr); -uip_lladdr_t *uip_ds6_nbr_get_ll(uip_ds6_nbr_t *nbr); -uip_ipaddr_t *uip_ds6_nbr_get_ipaddr(uip_ds6_nbr_t *nbr); -uip_ds6_nbr_t *uip_ds6_nbr_lookup(uip_ipaddr_t *ipaddr); -uip_ds6_nbr_t *uip_ds6_nbr_ll_lookup(uip_lladdr_t *lladdr); -uip_ipaddr_t *uip_ds6_nbr_ipaddr_from_lladdr(uip_lladdr_t *lladdr); -uip_lladdr_t *uip_ds6_nbr_lladdr_from_ipaddr(uip_ipaddr_t *ipaddr); +const uip_lladdr_t *uip_ds6_nbr_get_ll(const uip_ds6_nbr_t *nbr); +const uip_ipaddr_t *uip_ds6_nbr_get_ipaddr(const uip_ds6_nbr_t *nbr); +uip_ds6_nbr_t *uip_ds6_nbr_lookup(const uip_ipaddr_t *ipaddr); +uip_ds6_nbr_t *uip_ds6_nbr_ll_lookup(const uip_lladdr_t *lladdr); +uip_ipaddr_t *uip_ds6_nbr_ipaddr_from_lladdr(const uip_lladdr_t *lladdr); +const uip_lladdr_t *uip_ds6_nbr_lladdr_from_ipaddr(const uip_ipaddr_t *ipaddr); void uip_ds6_link_neighbor_callback(int status, int numtx); void uip_ds6_neighbor_periodic(void); int uip_ds6_nbr_num(void); diff --git a/core/net/uip-ds6-route.c b/core/net/uip-ds6-route.c index 917ee266e..137191f55 100644 --- a/core/net/uip-ds6-route.c +++ b/core/net/uip-ds6-route.c @@ -261,7 +261,7 @@ uip_ds6_route_add(uip_ipaddr_t *ipaddr, uint8_t length, #endif /* DEBUG != DEBUG_NONE */ /* Get link-layer address of next hop, make sure it is in neighbor table */ - uip_lladdr_t *nexthop_lladdr = uip_ds6_nbr_lladdr_from_ipaddr(nexthop); + const uip_lladdr_t *nexthop_lladdr = uip_ds6_nbr_lladdr_from_ipaddr(nexthop); if(nexthop_lladdr == NULL) { PRINTF("uip_ds6_route_add: neighbor link-local address unknown "); PRINT6ADDR(ipaddr); @@ -440,7 +440,7 @@ void uip_ds6_route_rm_by_nexthop(uip_ipaddr_t *nexthop) { /* Get routing entry list of this neighbor */ - uip_lladdr_t *nexthop_lladdr; + const uip_lladdr_t *nexthop_lladdr; struct uip_ds6_route_neighbor_routes *routes; nexthop_lladdr = uip_ds6_nbr_lladdr_from_ipaddr(nexthop); diff --git a/core/net/uip-nd6.c b/core/net/uip-nd6.c index 85b7e6154..4c9c1b775 100644 --- a/core/net/uip-nd6.c +++ b/core/net/uip-nd6.c @@ -191,7 +191,7 @@ uip_nd6_ns_input(void) (uip_lladdr_t *)&nd6_opt_llao[UIP_ND6_OPT_DATA_OFFSET], 0, NBR_STALE); } else { - uip_lladdr_t *lladdr = uip_ds6_nbr_get_ll(nbr); + uip_lladdr_t *lladdr = (uip_lladdr_t *)uip_ds6_nbr_get_ll(nbr); if(memcmp(&nd6_opt_llao[UIP_ND6_OPT_DATA_OFFSET], lladdr, UIP_LLADDR_LEN) != 0) { memcpy(lladdr, &nd6_opt_llao[UIP_ND6_OPT_DATA_OFFSET], @@ -463,7 +463,7 @@ uip_nd6_na_input(void) } else { uip_lladdr_t *lladdr; nbr = uip_ds6_nbr_lookup(&UIP_ND6_NA_BUF->tgtipaddr); - lladdr = uip_ds6_nbr_get_ll(nbr); + lladdr = (uip_lladdr_t *)uip_ds6_nbr_get_ll(nbr); if(nbr == NULL) { goto discard; } diff --git a/examples/ravenusbstick/fakeuip.c b/examples/ravenusbstick/fakeuip.c index f7d4fff81..a1e980aab 100644 --- a/examples/ravenusbstick/fakeuip.c +++ b/examples/ravenusbstick/fakeuip.c @@ -25,14 +25,14 @@ void tcpip_input( void ) mac_LowpanToEthernet(); } -uint8_t tcpip_output(uip_lladdr_t * lladdr){ +uint8_t tcpip_output(const uip_lladdr_t * lladdr){ if(output != NULL) { return output(lladdr); } return 0; } //Called from sicslowpan.c -void tcpip_set_outputfunc(uint8_t (* f)(uip_lladdr_t *)) { +void tcpip_set_outputfunc(uint8_t (* f)(const uip_lladdr_t *)) { output = f; }