From 839b6111d686ba5bef53a58cb8a20dc06143ac2e Mon Sep 17 00:00:00 2001 From: nifi Date: Thu, 26 Jun 2008 11:38:59 +0000 Subject: [PATCH] Changed send function to return false if it was not possible to send --- core/net/rime/collect.c | 8 +++++--- core/net/rime/collect.h | 4 ++-- core/net/rime/ipolite.c | 18 ++++++++++-------- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/core/net/rime/collect.c b/core/net/rime/collect.c index bb6be3687..40c87dd88 100644 --- a/core/net/rime/collect.c +++ b/core/net/rime/collect.c @@ -36,7 +36,7 @@ * * This file is part of the Contiki operating system. * - * $Id: collect.c,v 1.8 2008/02/24 22:05:27 adamdunkels Exp $ + * $Id: collect.c,v 1.9 2008/06/26 11:38:59 nifi Exp $ */ /** @@ -300,7 +300,7 @@ collect_set_sink(struct collect_conn *tc, int should_be_sink) update_rtmetric(tc); } /*---------------------------------------------------------------------------*/ -void +int collect_send(struct collect_conn *tc, int rexmits) { struct neighbor *n; @@ -320,6 +320,7 @@ collect_send(struct collect_conn *tc, int rexmits) tc->cb->recv(&hdr->originator, hdr->originator_seqno, hdr->hops); } + return 1; } else { n = neighbor_best(); if(n != NULL) { @@ -327,7 +328,7 @@ collect_send(struct collect_conn *tc, int rexmits) #if NETSIM ether_set_line(n->addr.u8[0], n->addr.u8[1]); #endif /* NETSIM */ - ruc_send(&tc->ruc_conn, &n->addr, rexmits); + return ruc_send(&tc->ruc_conn, &n->addr, rexmits); } else { /* printf("Didn't find any neighbor\n");*/ PRINTF("%d.%d: did not find any neighbor to send to\n", @@ -335,6 +336,7 @@ collect_send(struct collect_conn *tc, int rexmits) } } } + return 0; } /*---------------------------------------------------------------------------*/ int diff --git a/core/net/rime/collect.h b/core/net/rime/collect.h index 0653a96c4..4660c76ed 100644 --- a/core/net/rime/collect.h +++ b/core/net/rime/collect.h @@ -47,7 +47,7 @@ * * This file is part of the Contiki operating system. * - * $Id: collect.h,v 1.4 2008/02/24 22:05:27 adamdunkels Exp $ + * $Id: collect.h,v 1.5 2008/06/26 11:38:59 nifi Exp $ */ /** @@ -83,7 +83,7 @@ void collect_open(struct collect_conn *c, uint16_t channels, const struct collect_callbacks *callbacks); void collect_close(struct collect_conn *c); -void collect_send(struct collect_conn *c, int rexmits); +int collect_send(struct collect_conn *c, int rexmits); void collect_set_sink(struct collect_conn *c, int should_be_sink); diff --git a/core/net/rime/ipolite.c b/core/net/rime/ipolite.c index 6053fd6d7..e1ad672ed 100644 --- a/core/net/rime/ipolite.c +++ b/core/net/rime/ipolite.c @@ -33,7 +33,7 @@ * * This file is part of the Contiki operating system. * - * $Id: ipolite.c,v 1.8 2008/06/26 11:19:22 adamdunkels Exp $ + * $Id: ipolite.c,v 1.9 2008/06/26 11:38:59 nifi Exp $ */ /** @@ -138,22 +138,24 @@ ipolite_send(struct ipolite_conn *c, clock_time_t interval, uint8_t hdrsize) if(interval == 0) { PRINTF("%d.%d: ipolite_send: interval 0\n", rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1]); - broadcast_send(&c->c); - if(c->cb->sent) { - c->cb->sent(c); + if (broadcast_send(&c->c)) { + if(c->cb->sent) { + c->cb->sent(c); + } + return 1; } - return 1; + } else { c->q = queuebuf_new_from_rimebuf(); if(c->q != NULL) { ctimer_set(&c->t, interval / 2 + (random_rand() % (interval / 2)), send, c); + return 1; } - return 1; + PRINTF("%d.%d: ipolite_send: could not allocate queue buffer\n", + rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1]); } - PRINTF("%d.%d: ipolite_send: could not allocate queue buffer\n", - rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1]); return 0; } /*---------------------------------------------------------------------------*/