52 rimeaddr_t originator;
60 #define PRINTF(...) printf(__VA_ARGS__)
67 received(
struct runicast_conn *uc,
const rimeaddr_t *from, uint8_t seqno)
69 struct rmh_conn *c = (
struct rmh_conn *)uc;
73 PRINTF(
"data_packet_received from %d.%d towards %d.%d len %d\n",
74 from->u8[0], from->u8[1],
75 msg->dest.u8[0], msg->dest.u8[1],
82 c->cb->recv(c, &msg->originator, msg->hops);
87 nexthop = c->cb->forward(c, &msg->originator,
88 &msg->dest, from, msg->hops);
91 PRINTF(
"forwarding to %d.%d\n", nexthop->u8[0], nexthop->u8[1]);
93 runicast_send(&c->c, nexthop, c->num_rexmit);
99 sent(
struct runicast_conn *c,
const rimeaddr_t *to, uint8_t retransmissions)
105 timedout(
struct runicast_conn *c,
const rimeaddr_t *to, uint8_t retransmissions)
110 static const struct runicast_callbacks data_callbacks = { received ,
115 rmh_open(
struct rmh_conn *c, uint16_t channel,
116 const struct rmh_callbacks *callbacks)
118 runicast_open(&c->c, channel, &data_callbacks);
123 rmh_close(
struct rmh_conn *c)
125 runicast_close(&c->c);
129 rmh_send(
struct rmh_conn *c, rimeaddr_t *to, uint8_t num_rexmit, uint8_t max_hops)
132 struct data_hdr *hdr;
134 c->num_rexmit = num_rexmit;
136 if(c->cb->forward ==
NULL) {
141 if(nexthop ==
NULL) {
142 PRINTF(
"rmh_send: no route\n");
145 PRINTF(
"rmh_send: sending data\n");
153 hdr->max_rexmits = num_rexmit;
154 runicast_send(&c->c, nexthop, num_rexmit);