Added hopcount to callbacks
This commit is contained in:
parent
0c748d7dd2
commit
601560b1eb
|
@ -33,7 +33,7 @@
|
|||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* $Id: mesh.c,v 1.10 2007/12/05 13:40:26 adamdunkels Exp $
|
||||
* $Id: mesh.c,v 1.11 2008/01/08 07:55:56 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -68,13 +68,13 @@ struct data_hdr {
|
|||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
data_packet_received(struct mh_conn *mh, rimeaddr_t *from)
|
||||
data_packet_received(struct mh_conn *mh, rimeaddr_t *from, u8_t hops)
|
||||
{
|
||||
struct mesh_conn *c = (struct mesh_conn *)
|
||||
((char *)mh - offsetof(struct mesh_conn, mh));
|
||||
|
||||
if(c->cb->recv) {
|
||||
c->cb->recv(c, from);
|
||||
c->cb->recv(c, from, hops);
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
@ -82,9 +82,6 @@ static rimeaddr_t *
|
|||
data_packet_forward(struct mh_conn *mh, rimeaddr_t *originator,
|
||||
rimeaddr_t *dest, rimeaddr_t *prevhop, u8_t hops)
|
||||
{
|
||||
struct mesh_conn *c = (struct mesh_conn *)
|
||||
((char *)mh - offsetof(struct mesh_conn, mh));
|
||||
|
||||
struct route_entry *rt;
|
||||
|
||||
rt = route_lookup(dest);
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* $Id: mesh.h,v 1.9 2007/12/17 09:14:08 adamdunkels Exp $
|
||||
* $Id: mesh.h,v 1.10 2008/01/08 07:55:56 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -73,7 +73,7 @@ struct mesh_conn;
|
|||
*/
|
||||
struct mesh_callbacks {
|
||||
/** Called when a packet is received. */
|
||||
void (* recv)(struct mesh_conn *c, rimeaddr_t *from);
|
||||
void (* recv)(struct mesh_conn *c, rimeaddr_t *from, u8_t hops);
|
||||
/** Called when a packet, sent with mesh_send(), is actually transmitted. */
|
||||
void (* sent)(struct mesh_conn *c);
|
||||
/** Called when a packet, sent with mesh_send(), times out and is dropped. */
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* $Id: mh.c,v 1.6 2007/12/05 13:40:34 adamdunkels Exp $
|
||||
* $Id: mh.c,v 1.7 2008/01/08 07:55:56 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -79,7 +79,7 @@ data_packet_received(struct uc_conn *uc, rimeaddr_t *from)
|
|||
PRINTF("for us!\n");
|
||||
rimebuf_hdrreduce(sizeof(struct data_hdr));
|
||||
if(c->cb->recv) {
|
||||
c->cb->recv(c, &msg->originator);
|
||||
c->cb->recv(c, &msg->originator, msg->hops);
|
||||
}
|
||||
} else {
|
||||
nexthop = NULL;
|
||||
|
@ -132,7 +132,7 @@ mh_send(struct mh_conn *c, rimeaddr_t *to)
|
|||
hdr = rimebuf_hdrptr();
|
||||
rimeaddr_copy(&hdr->dest, to);
|
||||
rimeaddr_copy(&hdr->originator, &rimeaddr_node_addr);
|
||||
hdr->hops = 0;
|
||||
hdr->hops = 1;
|
||||
uc_send(&c->c, nexthop);
|
||||
}
|
||||
return 1;
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* $Id: mh.h,v 1.3 2007/11/28 19:55:27 adamdunkels Exp $
|
||||
* $Id: mh.h,v 1.4 2008/01/08 07:55:56 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -67,7 +67,7 @@
|
|||
struct mh_conn;
|
||||
|
||||
struct mh_callbacks {
|
||||
void (* recv)(struct mh_conn *ptr, rimeaddr_t *sender);
|
||||
void (* recv)(struct mh_conn *ptr, rimeaddr_t *sender, u8_t hops);
|
||||
rimeaddr_t *(* forward)(struct mh_conn *ptr,
|
||||
rimeaddr_t *originator,
|
||||
rimeaddr_t *dest,
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* $Id: rmh.c,v 1.4 2007/12/05 13:25:07 adamdunkels Exp $
|
||||
* $Id: rmh.c,v 1.5 2008/01/08 07:55:56 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -78,7 +78,7 @@ received(struct ruc_conn *uc, rimeaddr_t *from, u8_t seqno)
|
|||
PRINTF("for us!\n");
|
||||
rimebuf_hdrreduce(sizeof(struct data_hdr));
|
||||
if(c->cb->recv) {
|
||||
c->cb->recv(c, &msg->originator);
|
||||
c->cb->recv(c, &msg->originator, msg->hops);
|
||||
}
|
||||
} else {
|
||||
nexthop = NULL;
|
||||
|
@ -148,7 +148,7 @@ rmh_send(struct rmh_conn *c, rimeaddr_t *to, u8_t num_rexmit, u8_t max_hops)
|
|||
hdr = rimebuf_hdrptr();
|
||||
rimeaddr_copy(&hdr->dest, to);
|
||||
rimeaddr_copy(&hdr->originator, &rimeaddr_node_addr);
|
||||
hdr->hops = 0;
|
||||
hdr->hops = 1;
|
||||
hdr->max_rexmits = num_rexmit;
|
||||
ruc_send(&c->c, nexthop, num_rexmit);
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* $Id: rmh.h,v 1.2 2007/11/28 20:00:07 adamdunkels Exp $
|
||||
* $Id: rmh.h,v 1.3 2008/01/08 07:55:56 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -67,7 +67,7 @@
|
|||
struct rmh_conn;
|
||||
|
||||
struct rmh_callbacks {
|
||||
void (* recv)(struct rmh_conn *ptr, rimeaddr_t *sender);
|
||||
void (* recv)(struct rmh_conn *ptr, rimeaddr_t *sender, u8_t hops);
|
||||
rimeaddr_t *(* forward)(struct rmh_conn *ptr,
|
||||
rimeaddr_t *originator,
|
||||
rimeaddr_t *dest,
|
||||
|
|
Loading…
Reference in a new issue