51 linkaddr_t originator;
59 #define PRINTF(...) printf(__VA_ARGS__)
66 received(
struct runicast_conn *uc,
const linkaddr_t *from, uint8_t seqno)
68 struct rmh_conn *c = (
struct rmh_conn *)uc;
72 PRINTF(
"data_packet_received from %d.%d towards %d.%d len %d\n",
73 from->u8[0], from->u8[1],
74 msg->dest.u8[0], msg->dest.u8[1],
81 c->cb->recv(c, &msg->originator, msg->hops);
86 nexthop = c->cb->forward(c, &msg->originator,
87 &msg->dest, from, msg->hops);
90 PRINTF(
"forwarding to %d.%d\n", nexthop->u8[0], nexthop->u8[1]);
92 runicast_send(&c->c, nexthop, c->num_rexmit);
98 sent(
struct runicast_conn *c,
const linkaddr_t *to, uint8_t retransmissions)
104 timedout(
struct runicast_conn *c,
const linkaddr_t *to, uint8_t retransmissions)
109 static const struct runicast_callbacks data_callbacks = { received ,
114 rmh_open(
struct rmh_conn *c, uint16_t channel,
115 const struct rmh_callbacks *callbacks)
117 runicast_open(&c->c, channel, &data_callbacks);
122 rmh_close(
struct rmh_conn *c)
124 runicast_close(&c->c);
128 rmh_send(
struct rmh_conn *c, linkaddr_t *to, uint8_t num_rexmit, uint8_t max_hops)
131 struct data_hdr *hdr;
133 c->num_rexmit = num_rexmit;
135 if(c->cb->forward ==
NULL) {
140 if(nexthop ==
NULL) {
141 PRINTF(
"rmh_send: no route\n");
144 PRINTF(
"rmh_send: sending data\n");
152 hdr->max_rexmits = num_rexmit;
153 runicast_send(&c->c, nexthop, num_rexmit);
int packetbuf_hdralloc(int size)
Extend the header of the packetbuf, for outbound packets.
linkaddr_t linkaddr_node_addr
The Rime address of the node.
Multihop forwarding header file
#define NULL
The null pointer.
Header file for the Rime stack
uint16_t packetbuf_datalen(void)
Get the length of the data in the packetbuf.
void linkaddr_copy(linkaddr_t *dest, const linkaddr_t *src)
Copy a Rime address.
void * packetbuf_hdrptr(void)
Get a pointer to the header in the packetbuf, for outbound packets.
int linkaddr_cmp(const linkaddr_t *addr1, const linkaddr_t *addr2)
Compare two Rime addresses.
void * packetbuf_dataptr(void)
Get a pointer to the data in the packetbuf.
int packetbuf_hdrreduce(int size)
Reduce the header in the packetbuf, for incoming packets.