Merge pull request #431 from adamdunkels/push/ipv6-const

Make IP addresses const
This commit is contained in:
Nicolas Tsiftes 2013-11-20 04:26:05 -08:00
commit 263e212427
18 changed files with 55 additions and 54 deletions

View File

@ -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;

View File

@ -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_ */

View File

@ -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);
}
/*---------------------------------------------------------------------------*/

View File

@ -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 */

View File

@ -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;

View File

@ -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;
}

View File

@ -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));

View File

@ -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;
}
/*---------------------------------------------------------------------------*/

View File

@ -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);

View File

@ -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);

View File

@ -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;
}

View File

@ -98,7 +98,7 @@ static unsigned long lasttime;
#endif
static void do_send(void);
uint8_t tapdev_send(uip_lladdr_t *lladdr);
uint8_t tapdev_send(const uip_lladdr_t *lladdr);
/*---------------------------------------------------------------------------*/
int
@ -371,7 +371,8 @@ do_send(void)
}
}
/*---------------------------------------------------------------------------*/
uint8_t tapdev_send(uip_lladdr_t *lladdr)
uint8_t
tapdev_send(const uip_lladdr_t *lladdr)
{
/*
* If L3 dest is multicast, build L2 multicast address

View File

@ -39,7 +39,7 @@
#include "contiki-net.h"
void tapdev_init(void);
uint8_t tapdev_send(uip_lladdr_t *lladdr);
uint8_t tapdev_send(const uip_lladdr_t *lladdr);
uint16_t tapdev_poll(void);
void tapdev_do_send(void);
void tapdev_exit(void); //math

View File

@ -185,7 +185,7 @@ init(void)
/* Nothing to do here */
}
/*---------------------------------------------------------------------------*/
uint8_t wfall_send(uip_lladdr_t *lladdr);
uint8_t wfall_send(const uip_lladdr_t *lladdr);
#if FALLBACK_HAS_ETHERNET_HEADERS
#undef IPBUF
#define IPBUF ((struct uip_tcpip_hdr *)&uip_buf[14])
@ -708,7 +708,7 @@ wfall_poll(void)
/*---------------------------------------------------------------------------*/
#if UIP_CONF_IPV6
uint8_t
wpcap_send(uip_lladdr_t *lladdr)
wpcap_send(const uip_lladdr_t *lladdr)
{
if(lladdr == NULL) {
/* the dest must be multicast*/
@ -745,7 +745,7 @@ return 0;
}
#ifdef UIP_FALLBACK_INTERFACE
uint8_t
wfall_send(uip_lladdr_t *lladdr)
wfall_send(const uip_lladdr_t *lladdr)
{
#if FALLBACK_HAS_ETHERNET_HEADERS
//make room for ethernet header

View File

@ -39,8 +39,8 @@ void wpcap_init(void);
uint16_t wpcap_poll(void);
uint16_t wfall_poll(void);
#if UIP_CONF_IPV6
uint8_t wpcap_send(uip_lladdr_t *lladdr);
uint8_t wfall_send(uip_lladdr_t *lladdr);
uint8_t wpcap_send(const uip_lladdr_t *lladdr);
uint8_t wfall_send(const uip_lladdr_t *lladdr);
#else
void wpcap_send(void);
#endif

View File

@ -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;
}

View File

@ -55,9 +55,9 @@ PROCESS(tcpip_process, "tcpip dummy");
AUTOSTART_PROCESSES(&uip6_bridge);
/*---------------------------------------------------------------------------*/
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)
{
if(outputfunc != NULL) {
outputfunc(a);
@ -73,7 +73,7 @@ tcpip_ipv6_output(void)
{
}
void
tcpip_set_outputfunc(uint8_t (*f)(uip_lladdr_t *))
tcpip_set_outputfunc(uint8_t (*f)(const uip_lladdr_t *))
{
outputfunc = f;
}

View File

@ -57,9 +57,9 @@ PROCESS(tcpip_process, "tcpip dummy");
AUTOSTART_PROCESSES(&uip6_bridge);
/*---------------------------------------------------------------------------*/
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)
{
if(outputfunc != NULL) {
leds_on(LEDS_GREEN);
@ -76,7 +76,7 @@ tcpip_ipv6_output(void)
{
}
void
tcpip_set_outputfunc(uint8_t (*f)(uip_lladdr_t *))
tcpip_set_outputfunc(uint8_t (*f)(const uip_lladdr_t *))
{
outputfunc = f;
}