53 uint16_t originator_seqno;
54 rimeaddr_t originator;
61 #define PRINTF(...) printf(__VA_ARGS__)
68 send(
struct netflood_conn *c)
70 PRINTF(
"%d.%d: netflood send to ipolite\n",
76 recv_from_ipolite(
struct ipolite_conn *ipolite,
const rimeaddr_t *from)
78 struct netflood_conn *c = (
struct netflood_conn *)ipolite;
79 struct netflood_hdr hdr;
81 struct queuebuf *queuebuf;
87 queuebuf = queuebuf_new_from_packetbuf();
90 if(c->u->recv !=
NULL) {
91 if(!(
rimeaddr_cmp(&hdr.originator, &c->last_originator) &&
92 hdr.originator_seqno <= c->last_originator_seqno)) {
94 if(c->u->recv(c, from, &hdr.originator, hdr.originator_seqno,
97 if(queuebuf !=
NULL) {
98 queuebuf_to_packetbuf(queuebuf);
99 queuebuf_free(queuebuf);
104 if(hops < HOPS_MAX) {
105 PRINTF(
"%d.%d: netflood rebroadcasting %d.%d/%d (%d.%d/%d) hops %d\n",
107 hdr.originator.u8[0], hdr.originator.u8[1],
108 hdr.originator_seqno,
109 c->last_originator.u8[0], c->last_originator.u8[1],
110 c->last_originator_seqno,
116 c->last_originator_seqno = hdr.originator_seqno;
122 if(queuebuf !=
NULL) {
123 queuebuf_free(queuebuf);
130 struct netflood_conn *c = (
struct netflood_conn *)ipolite;
131 if(c->u->sent !=
NULL) {
139 struct netflood_conn *c = (
struct netflood_conn *)ipolite;
140 if(c->u->dropped !=
NULL) {
148 netflood_open(
struct netflood_conn *c, clock_time_t queue_time,
149 uint16_t channel,
const struct netflood_callbacks *u)
153 c->queue_time = queue_time;
157 netflood_close(
struct netflood_conn *c)
163 netflood_send(
struct netflood_conn *c, uint8_t seqno)
169 c->last_originator_seqno = hdr->originator_seqno = seqno;
171 PRINTF(
"%d.%d: netflood sending '%s'\n",
180 netflood_cancel(
struct netflood_conn *c)