47 #include "lib/random.h"
52 #define MAX(a, b) ((a) > (b)? (a) : (b))
56 #define MIN(a, b) ((a) < (b)? (a) : (b))
62 #define PRINTF(...) printf(__VA_ARGS__)
69 recv(
struct broadcast_conn *broadcast,
const linkaddr_t *from)
80 if(c->dups == c->maxdups) {
95 sent(
struct broadcast_conn *bc,
int status,
int num_tx)
105 PRINTF(
"%d.%d: ipolite: send queuebuf %p\n",
110 queuebuf_to_packetbuf(c->q);
129 PRINTF(
"ipolite open channel %d\n", channel);
148 PRINTF(
"%d.%d: ipolite_send: cancel old send\n",
155 c->hdrsize = hdrsize;
157 PRINTF(
"%d.%d: ipolite_send: interval 0\n",
167 c->q = queuebuf_new_from_packetbuf();
174 PRINTF(
"%d.%d: ipolite_send: could not allocate queue buffer\n",
A structure with callback functions for an ipolite connection.
linkaddr_t linkaddr_node_addr
The Rime address of the node.
void broadcast_close(struct broadcast_conn *c)
Close a broadcast connection.
void(* recv)(struct broadcast_conn *ptr, const linkaddr_t *sender)
Called when a packet has been received by the broadcast module.
void ipolite_cancel(struct ipolite_conn *c)
Cancel a pending packet.
#define NULL
The null pointer.
void(* recv)(struct ipolite_conn *c, const linkaddr_t *from)
Called when a packet is received on the connection.
Header file for the Rime stack
uint16_t packetbuf_datalen(void)
Get the length of the data in the packetbuf.
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 ctimer_set(struct ctimer *c, clock_time_t t, void(*f)(void *), void *ptr)
Set a callback timer.
void(* dropped)(struct ipolite_conn *c)
Called when a packet is dropped because a packet was heard from a neighbor.
Callback structure for broadcast.
Header file for Ipolite best effort local Broadcast (ipolite)
An opaque structure with no user-visible elements that holds the state of an ipolite connection...
int broadcast_send(struct broadcast_conn *c)
Send an identified best-effort broadcast packet.
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.
void broadcast_open(struct broadcast_conn *c, uint16_t channel, const struct broadcast_callbacks *u)
Set up an identified best-effort broadcast connection.
int ipolite_send(struct ipolite_conn *c, clock_time_t interval, uint8_t hdrsize)
Send a packet on an ipolite connection.
void ctimer_stop(struct ctimer *c)
Stop a pending callback timer.
unsigned short random_rand(void)
Generate the next state and return the upper part of it.