diff --git a/core/net/mac/cxmac.c b/core/net/mac/cxmac.c index 6db52dd0d..5120f8afa 100644 --- a/core/net/mac/cxmac.c +++ b/core/net/mac/cxmac.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: cxmac.c,v 1.12 2010/03/01 13:30:22 nifi Exp $ + * $Id: cxmac.c,v 1.13 2010/06/15 19:22:25 adamdunkels Exp $ */ /** @@ -365,7 +365,7 @@ format_announcement(char *hdr) adata.num = 0; for(a = announcement_list(); a != NULL && adata.num < ANNOUNCEMENT_MAX; - a = a->next) { + a = list_item_next(a)) { adata.data[adata.num].id = a->id; adata.data[adata.num].value = a->value; adata.num++; @@ -389,7 +389,7 @@ register_encounter(const rimeaddr_t *neighbor, rtimer_clock_t time) struct encounter *e; /* If we have an entry for this neighbor already, we renew it. */ - for(e = list_head(encounter_list); e != NULL; e = e->next) { + for(e = list_head(encounter_list); e != NULL; e = list_item_next(e)) { if(rimeaddr_cmp(neighbor, &e->neighbor)) { e->time = time; break; @@ -499,7 +499,7 @@ send_packet(void) an encounter with this particular neighbor. If so, we can compute the time for the next expected encounter and setup a ctimer to switch on the radio just before the encounter. */ - for(e = list_head(encounter_list); e != NULL; e = e->next) { + for(e = list_head(encounter_list); e != NULL; e = list_item_next(e)) { const rimeaddr_t *neighbor = packetbuf_addr(PACKETBUF_ADDR_RECEIVER); if(rimeaddr_cmp(neighbor, &e->neighbor)) { @@ -559,6 +559,7 @@ send_packet(void) while(got_strobe_ack == 0 && RTIMER_CLOCK_LT(RTIMER_NOW(), t + cxmac_config.strobe_wait_time)) { rtimer_clock_t now = RTIMER_NOW(); + /* See if we got an ACK */ packetbuf_clear(); len = NETSTACK_RADIO.read(packetbuf_dataptr(), PACKETBUF_SIZE); @@ -587,9 +588,8 @@ send_packet(void) } t = RTIMER_NOW(); - /* Send the strobe packet. */ + /* Send the strobe packet. */ if(got_strobe_ack == 0 && collisions == 0) { - if(is_broadcast) { #if WITH_STROBE_BROADCAST NETSTACK_RADIO.send(strobe, strobe_len); @@ -602,7 +602,7 @@ send_packet(void) } else { rtimer_clock_t wt; NETSTACK_RADIO.send(strobe, strobe_len); -#if 1 +#if 0 /* Turn off the radio for a while to let the other side respond. We don't need to keep our radio on when we know that the other side needs some time to produce a reply. */ @@ -794,8 +794,8 @@ input_packet(void) } else if(hdr->type == TYPE_STROBE_ACK) { PRINTDEBUG("cxmac: stray strobe ack\n"); } else { - PRINTF("cxmac: unknown type %u (%u/%u)\n", hdr->type, - packetbuf_datalen(), len); + PRINTF("cxmac: unknown type %u (%u)\n", hdr->type, + packetbuf_datalen()); } } else { PRINTF("cxmac: failed to parse (%u)\n", packetbuf_totlen()); diff --git a/core/net/mac/lpp.c b/core/net/mac/lpp.c index 537c5860c..65415e022 100644 --- a/core/net/mac/lpp.c +++ b/core/net/mac/lpp.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: lpp.c,v 1.35 2010/06/14 19:19:17 adamdunkels Exp $ + * $Id: lpp.c,v 1.36 2010/06/15 19:22:25 adamdunkels Exp $ */ /** @@ -220,7 +220,7 @@ register_encounter(rimeaddr_t *neighbor, clock_time_t time) struct encounter *e; /* If we have an entry for this neighbor already, we renew it. */ - for(e = list_head(encounter_list); e != NULL; e = e->next) { + for(e = list_head(encounter_list); e != NULL; e = list_item_next(e)) { if(rimeaddr_cmp(neighbor, &e->neighbor)) { e->time = time; ctimer_set(&e->remove_timer, ENCOUNTER_LIFETIME, remove_encounter, e); @@ -300,7 +300,7 @@ turn_radio_on_for_neighbor(rimeaddr_t *neighbor, struct queue_list_item *i) an encounter with this particular neighbor. If so, we can compute the time for the next expected encounter and setup a ctimer to switch on the radio just before the encounter. */ - for(e = list_head(encounter_list); e != NULL; e = e->next) { + for(e = list_head(encounter_list); e != NULL; e = list_item_next(e)) { if(rimeaddr_cmp(neighbor, &e->neighbor)) { clock_time_t wait, now; @@ -430,7 +430,7 @@ send_probe(void) adata = (struct announcement_msg *)((char *)hdr + sizeof(struct lpp_hdr)); adata->num = 0; - for(a = announcement_list(); a != NULL; a = a->next) { + for(a = announcement_list(); a != NULL; a = list_item_next(a)) { adata->data[adata->num].id = a->id; adata->data[adata->num].value = a->value; adata->num++; @@ -472,7 +472,7 @@ num_packets_to_send(void) struct queue_list_item *i; int num = 0; - for(i = list_head(queued_packets_list); i != NULL; i = i->next) { + for(i = list_head(queued_packets_list); i != NULL; i = list_item_next(i)) { if(i->broadcast_flag == BROADCAST_FLAG_SEND || i->broadcast_flag == BROADCAST_FLAG_NONE) { ++num; @@ -505,7 +505,7 @@ dutycycle(void *ptr) our output queue to be pending. This means that they are ready to be sent, once we know that no neighbor is currently broadcasting. */ - for(p = list_head(queued_packets_list); p != NULL; p = p->next) { + for(p = list_head(queued_packets_list); p != NULL; p = list_item_next(p)) { if(p->broadcast_flag == BROADCAST_FLAG_WAITING) { PRINTF("wait -> pending\n"); set_broadcast_flag(p, BROADCAST_FLAG_PENDING); @@ -533,7 +533,7 @@ dutycycle(void *ptr) there are pending broadcasts, and we did not receive any broadcast packets from a neighbor in response to our probe, we mark the broadcasts as being ready to send. */ - for(p = list_head(queued_packets_list); p != NULL; p = p->next) { + for(p = list_head(queued_packets_list); p != NULL; p = list_item_next(p)) { if(p->broadcast_flag == BROADCAST_FLAG_PENDING) { PRINTF("pending -> send\n"); set_broadcast_flag(p, BROADCAST_FLAG_SEND); @@ -760,7 +760,7 @@ input_packet(void) broadcast packet that should be sent. */ if(list_length(queued_packets_list) > 0) { struct queue_list_item *i; - for(i = list_head(queued_packets_list); i != NULL; i = i->next) { + for(i = list_head(queued_packets_list); i != NULL; i = list_item_next(i)) { const rimeaddr_t *receiver; receiver = queuebuf_addr(i->packet, PACKETBUF_ADDR_RECEIVER); @@ -873,7 +873,7 @@ input_packet(void) finished sending. */ struct queue_list_item *i; - for(i = list_head(queued_packets_list); i != NULL; i = i->next) { + for(i = list_head(queued_packets_list); i != NULL; i = list_item_next(i)) { /* If the packet is a broadcast packet that is not yet ready to be sent, we do not send it. */ if(i->broadcast_flag == BROADCAST_FLAG_PENDING) { diff --git a/core/net/mac/phase.c b/core/net/mac/phase.c index cbe062613..e97e7eb02 100644 --- a/core/net/mac/phase.c +++ b/core/net/mac/phase.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: phase.c,v 1.13 2010/06/14 19:19:17 adamdunkels Exp $ + * $Id: phase.c,v 1.14 2010/06/15 19:22:25 adamdunkels Exp $ */ /** @@ -75,7 +75,7 @@ struct phase * find_neighbor(const struct phase_list *list, const rimeaddr_t *addr) { struct phase *e; - for(e = list_head(*list->list); e != NULL; e = e->next) { + for(e = list_head(*list->list); e != NULL; e = list_item_next(e)) { if(rimeaddr_cmp(addr, &e->neighbor)) { return e; } diff --git a/core/net/mac/xmac.c b/core/net/mac/xmac.c index 342cdcd06..4d13ff193 100644 --- a/core/net/mac/xmac.c +++ b/core/net/mac/xmac.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: xmac.c,v 1.57 2010/06/14 06:52:41 adamdunkels Exp $ + * $Id: xmac.c,v 1.58 2010/06/15 19:22:25 adamdunkels Exp $ */ /** @@ -370,7 +370,7 @@ format_announcement(char *hdr) adata.num = 0; for(a = announcement_list(); a != NULL && adata.num < ANNOUNCEMENT_MAX; - a = a->next) { + a = list_item_next(a)) { adata.data[adata.num].id = a->id; adata.data[adata.num].value = a->value; adata.num++; @@ -394,7 +394,7 @@ register_encounter(const rimeaddr_t *neighbor, rtimer_clock_t time) struct encounter *e; /* If we have an entry for this neighbor already, we renew it. */ - for(e = list_head(encounter_list); e != NULL; e = e->next) { + for(e = list_head(encounter_list); e != NULL; e = list_item_next(e)) { if(rimeaddr_cmp(neighbor, &e->neighbor)) { e->time = time; break; @@ -503,7 +503,7 @@ send_packet(void) an encounter with this particular neighbor. If so, we can compute the time for the next expected encounter and setup a ctimer to switch on the radio just before the encounter. */ - for(e = list_head(encounter_list); e != NULL; e = e->next) { + for(e = list_head(encounter_list); e != NULL; e = list_item_next(e)) { const rimeaddr_t *neighbor = packetbuf_addr(PACKETBUF_ADDR_RECEIVER); if(rimeaddr_cmp(neighbor, &e->neighbor)) { diff --git a/core/net/rime/announcement.c b/core/net/rime/announcement.c index 99fb4694a..a4792acdf 100644 --- a/core/net/rime/announcement.c +++ b/core/net/rime/announcement.c @@ -33,7 +33,7 @@ * * This file is part of the Contiki operating system. * - * $Id: announcement.c,v 1.5 2010/03/25 08:49:56 adamdunkels Exp $ + * $Id: announcement.c,v 1.6 2010/06/15 19:22:25 adamdunkels Exp $ */ /** @@ -93,6 +93,7 @@ void announcement_set_value(struct announcement *a, uint16_t value) { uint16_t oldvalue = a->value; + a->has_value = 1; a->value = value; if(observer_callback) { @@ -140,7 +141,7 @@ void announcement_heard(const rimeaddr_t *from, uint16_t id, uint16_t value) { struct announcement *a; - for(a = list_head(announcements); a != NULL; a = a->next) { + for(a = list_head(announcements); a != NULL; a = list_item_next(a)) { if(a->id == id) { if(a->callback != NULL) { a->callback(a, from, id, value); diff --git a/core/net/rime/broadcast-announcement.c b/core/net/rime/broadcast-announcement.c index 2d0aa03cf..8c3de1272 100644 --- a/core/net/rime/broadcast-announcement.c +++ b/core/net/rime/broadcast-announcement.c @@ -33,7 +33,7 @@ * * This file is part of the Contiki operating system. * - * $Id: broadcast-announcement.c,v 1.4 2010/03/31 12:17:24 adamdunkels Exp $ + * $Id: broadcast-announcement.c,v 1.5 2010/06/15 19:22:25 adamdunkels Exp $ */ /** @@ -104,7 +104,7 @@ send_adv(void *ptr) packetbuf_clear(); adata = packetbuf_dataptr(); adata->num = 0; - for(a = announcement_list(); a != NULL && a->has_value; a = a->next) { + for(a = announcement_list(); a != NULL && a->has_value; a = list_item_next(a)) { adata->data[adata->num].id = a->id; adata->data[adata->num].value = a->value; adata->num++; @@ -169,9 +169,8 @@ static void set_timers(void) { ctimer_set(&c.interval_timer, c.current_interval, send_timer, NULL); - ctimer_set(&c.send_timer, c.current_interval / 2 + random_rand() % - (c.current_interval / 2), - send_adv, NULL); + ctimer_set(&c.send_timer, random_rand() % c.current_interval, + send_adv, NULL); } /*---------------------------------------------------------------------------*/ static void diff --git a/core/net/rime/channel.c b/core/net/rime/channel.c index ada1e5788..835c43a22 100644 --- a/core/net/rime/channel.c +++ b/core/net/rime/channel.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: channel.c,v 1.2 2009/03/12 21:58:20 adamdunkels Exp $ + * $Id: channel.c,v 1.3 2010/06/15 19:22:25 adamdunkels Exp $ */ /** @@ -80,7 +80,7 @@ struct channel * channel_lookup(uint16_t channelno) { struct channel *c; - for(c = list_head(channel_list); c != NULL; c = c->next) { + for(c = list_head(channel_list); c != NULL; c = list_item_next(c)) { if(c->channelno == channelno) { return c; } diff --git a/core/net/rime/collect-neighbor.c b/core/net/rime/collect-neighbor.c index cc47a8605..a859ecf55 100644 --- a/core/net/rime/collect-neighbor.c +++ b/core/net/rime/collect-neighbor.c @@ -33,7 +33,7 @@ * * This file is part of the Contiki operating system. * - * $Id: collect-neighbor.c,v 1.2 2010/06/14 07:34:37 adamdunkels Exp $ + * $Id: collect-neighbor.c,v 1.3 2010/06/15 19:22:25 adamdunkels Exp $ */ /** @@ -98,13 +98,13 @@ periodic(void *ptr) rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1], n->addr.u8[0], n->addr.u8[1]); rimeaddr_copy(&n->addr, &rimeaddr_null); - next = n->next; + next = list_item_next(n); list_remove(collect_neighbors_list, n); memb_free(&collect_neighbors_mem, n); } } if(next == NULL) { - next = n->next; + next = list_item_next(n); } } /* PRINTF("collect_neighbor periodic\n");*/ @@ -127,7 +127,7 @@ struct collect_neighbor * collect_neighbor_find(const rimeaddr_t *addr) { struct collect_neighbor *n; - for(n = list_head(collect_neighbors_list); n != NULL; n = n->next) { + for(n = list_head(collect_neighbors_list); n != NULL; n = list_item_next(n)) { if(rimeaddr_cmp(&n->addr, addr)) { return n; } @@ -192,7 +192,7 @@ collect_neighbor_add(const rimeaddr_t *addr, uint8_t nrtmetric, uint8_t netx) PRINTF("collect_neighbor_add: adding %d.%d\n", addr->u8[0], addr->u8[1]); /* Check if the collect_neighbor is already on the list. */ - for(n = list_head(collect_neighbors_list); n != NULL; n = n->next) { + for(n = list_head(collect_neighbors_list); n != NULL; n = list_item_next(n)) { if(rimeaddr_cmp(&n->addr, &rimeaddr_null) || rimeaddr_cmp(&n->addr, addr)) { PRINTF("collect_neighbor_add: already on list %d.%d\n", addr->u8[0], addr->u8[1]); @@ -220,7 +220,7 @@ collect_neighbor_add(const rimeaddr_t *addr, uint8_t nrtmetric, uint8_t netx) etx = 0; max = NULL; - for(n = list_head(collect_neighbors_list); n != NULL; n = n->next) { + for(n = list_head(collect_neighbors_list); n != NULL; n = list_item_next(n)) { if(!rimeaddr_cmp(&n->addr, &rimeaddr_null)) { if(n->rtmetric > rtmetric) { rtmetric = n->rtmetric; @@ -259,7 +259,7 @@ collect_neighbor_remove(const rimeaddr_t *addr) { struct collect_neighbor *n; - for(n = list_head(collect_neighbors_list); n != NULL; n = n->next) { + for(n = list_head(collect_neighbors_list); n != NULL; n = list_item_next(n)) { if(rimeaddr_cmp(&n->addr, addr)) { PRINTF("%d.%d: removing %d.%d\n", rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1], @@ -298,7 +298,7 @@ collect_neighbor_best(void) /* PRINTF("%d: ", node_id);*/ /* Find the lowest rtmetric. */ - for(n = list_head(collect_neighbors_list); n != NULL; n = n->next) { + for(n = list_head(collect_neighbors_list); n != NULL; n = list_item_next(n)) { PRINTF("collect_neighbor_best: checking %d.%d with rtmetric %d + %d\n", n->addr.u8[0], n->addr.u8[1], n->rtmetric, collect_neighbor_etx(n)); @@ -334,7 +334,7 @@ collect_neighbor_get(int num) PRINTF("collect_neighbor_get %d\n", num); i = 0; - for(n = list_head(collect_neighbors_list); n != NULL; n = n->next) { + for(n = list_head(collect_neighbors_list); n != NULL; n = list_item_next(n)) { if(i == num) { PRINTF("collect_neighbor_get found %d.%d\n", n->addr.u8[0], n->addr.u8[1]); return n; diff --git a/core/net/rime/polite-announcement.c b/core/net/rime/polite-announcement.c index 8077e6a27..7ca297b05 100644 --- a/core/net/rime/polite-announcement.c +++ b/core/net/rime/polite-announcement.c @@ -33,7 +33,7 @@ * * This file is part of the Contiki operating system. * - * $Id: polite-announcement.c,v 1.14 2010/03/29 12:13:35 fros4943 Exp $ + * $Id: polite-announcement.c,v 1.15 2010/06/15 19:22:25 adamdunkels Exp $ */ /** @@ -102,7 +102,7 @@ send_adv(clock_time_t interval) packetbuf_clear(); adata = packetbuf_dataptr(); adata->num = 0; - for(a = announcement_list(); a != NULL; a = a->next) { + for(a = announcement_list(); a != NULL; a = list_item_next(a)) { adata->data[adata->num].id = a->id; adata->data[adata->num].value = a->value; adata->num++; diff --git a/core/net/rime/route.c b/core/net/rime/route.c index 4ab81289d..231b5ebe2 100644 --- a/core/net/rime/route.c +++ b/core/net/rime/route.c @@ -33,7 +33,7 @@ * * This file is part of the Contiki operating system. * - * $Id: route.c,v 1.17 2010/06/14 07:34:37 adamdunkels Exp $ + * $Id: route.c,v 1.18 2010/06/15 19:22:25 adamdunkels Exp $ */ /** @@ -94,7 +94,7 @@ periodic(void *ptr) { struct route_entry *e; - for(e = list_head(route_table); e != NULL; e = e->next) { + for(e = list_head(route_table); e != NULL; e = list_item_next(e)) { e->time++; if(e->time >= max_time) { PRINTF("route periodic: removing entry to %d.%d with nexthop %d.%d and cost %d\n", @@ -170,7 +170,7 @@ route_lookup(const rimeaddr_t *dest) best_entry = NULL; /* Find the route with the lowest cost. */ - for(e = list_head(route_table); e != NULL; e = e->next) { + for(e = list_head(route_table); e != NULL; e = list_item_next(e)) { /* printf("route_lookup: comparing %d.%d.%d.%d with %d.%d.%d.%d\n", uip_ipaddr_to_quad(dest), uip_ipaddr_to_quad(&e->dest));*/ @@ -263,7 +263,7 @@ route_num(void) struct route_entry *e; int i = 0; - for(e = list_head(route_table); e != NULL; e = e->next) { + for(e = list_head(route_table); e != NULL; e = list_item_next(e)) { i++; } return i; @@ -275,7 +275,7 @@ route_get(int num) struct route_entry *e; int i = 0; - for(e = list_head(route_table); e != NULL; e = e->next) { + for(e = list_head(route_table); e != NULL; e = list_item_next(e)) { if(i == num) { return e; } diff --git a/doc/example-list.c b/doc/example-list.c index af05632a2..179fa2f9b 100644 --- a/doc/example-list.c +++ b/doc/example-list.c @@ -24,7 +24,7 @@ example_function(void) for(s = list_head(example_list); s != NULL; - s = s->next) { + s = list_item_next(s)) { printf("List element number %d\n", s->number); } }