52 uint16_t originator_seqno;
53 linkaddr_t originator;
60 #define PRINTF(...) printf(__VA_ARGS__)
67 send(
struct netflood_conn *c)
69 PRINTF(
"%d.%d: netflood send to ipolite\n",
75 recv_from_ipolite(
struct ipolite_conn *ipolite,
const linkaddr_t *from)
77 struct netflood_conn *c = (
struct netflood_conn *)ipolite;
78 struct netflood_hdr hdr;
80 struct queuebuf *queuebuf;
86 queuebuf = queuebuf_new_from_packetbuf();
89 if(c->u->recv !=
NULL) {
90 if(!(
linkaddr_cmp(&hdr.originator, &c->last_originator) &&
91 hdr.originator_seqno <= c->last_originator_seqno)) {
93 if(c->u->recv(c, from, &hdr.originator, hdr.originator_seqno,
96 if(queuebuf !=
NULL) {
97 queuebuf_to_packetbuf(queuebuf);
98 queuebuf_free(queuebuf);
103 if(hops < HOPS_MAX) {
104 PRINTF(
"%d.%d: netflood rebroadcasting %d.%d/%d (%d.%d/%d) hops %d\n",
106 hdr.originator.u8[0], hdr.originator.u8[1],
107 hdr.originator_seqno,
108 c->last_originator.u8[0], c->last_originator.u8[1],
109 c->last_originator_seqno,
115 c->last_originator_seqno = hdr.originator_seqno;
121 if(queuebuf !=
NULL) {
122 queuebuf_free(queuebuf);
129 struct netflood_conn *c = (
struct netflood_conn *)ipolite;
130 if(c->u->sent !=
NULL) {
138 struct netflood_conn *c = (
struct netflood_conn *)ipolite;
139 if(c->u->dropped !=
NULL) {
147 netflood_open(
struct netflood_conn *c, clock_time_t queue_time,
148 uint16_t channel,
const struct netflood_callbacks *u)
152 c->queue_time = queue_time;
156 netflood_close(
struct netflood_conn *c)
162 netflood_send(
struct netflood_conn *c, uint8_t seqno)
168 c->last_originator_seqno = hdr->originator_seqno = seqno;
170 PRINTF(
"%d.%d: netflood sending '%s'\n",
179 netflood_cancel(
struct netflood_conn *c)
A structure with callback functions for an ipolite connection.
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.
void ipolite_cancel(struct ipolite_conn *c)
Cancel a pending packet.
#define NULL
The null pointer.
void linkaddr_copy(linkaddr_t *dest, const linkaddr_t *src)
Copy a Rime address.
void ipolite_close(struct ipolite_conn *c)
Close an ipolite connection.
void ipolite_open(struct ipolite_conn *c, uint16_t channel, uint8_t dups, const struct ipolite_callbacks *cb)
Open an ipolite connection.
void * packetbuf_hdrptr(void)
Get a pointer to the header in the packetbuf, for outbound packets.
void(* dropped)(struct ipolite_conn *c)
Called when a packet is dropped because a packet was heard from a neighbor.
An opaque structure with no user-visible elements that holds the state of an ipolite connection...
Header file for the best-effort network flooding (netflood)
int linkaddr_cmp(const linkaddr_t *addr1, const linkaddr_t *addr2)
Compare two Rime addresses.
void(* sent)(struct ipolite_conn *c)
Called when a packet is sent on the connection.
void * packetbuf_dataptr(void)
Get a pointer to the data in the packetbuf.
int ipolite_send(struct ipolite_conn *c, clock_time_t interval, uint8_t hdrsize)
Send a packet on an ipolite connection.
int packetbuf_hdrreduce(int size)
Reduce the header in the packetbuf, for incoming packets.