}
bool meshlink_send(meshlink_handle_t *mesh, meshlink_node_t *destination, const void *data, unsigned int len) {
+
+ /* If there is no outgoing list yet, create one. */
+
+ if(!mesh->outpacketqueue)
+ mesh->outpacketqueue = list_alloc(NULL);
+
+ //add packet to the queue
+ outpacketqueue_t *packet_in_queue = xzalloc(sizeof *packet_in_queue);
+ packet_in_queue->destination=destination;
+ packet_in_queue->data=data;
+ packet_in_queue->len=len;
+ list_insert_tail(mesh->outpacketqueue,packet_in_queue);
+
+ //notify event loop
+
+}
+
+bool meshlink_send_from_queue (meshlink_handle_t *mesh,outpacketqueue_t* p) {
vpn_packet_t packet;
meshlink_packethdr_t *hdr = (meshlink_packethdr_t *)packet.data;
- if (sizeof(meshlink_packethdr_t) + len > MAXSIZE) {
+ if (sizeof(meshlink_packethdr_t) + p->len > MAXSIZE) {
//log something
return false;
}
packet.probe = false;
memset(hdr, 0, sizeof *hdr);
- memcpy(hdr->destination, destination->name, sizeof hdr->destination);
+ memcpy(hdr->destination, p->destination->name, sizeof hdr->destination);
memcpy(hdr->source, mesh->self->name, sizeof hdr->source);
- packet.len = sizeof *hdr + len;
- memcpy(packet.data + sizeof *hdr, data, len);
+ packet.len = sizeof *hdr + p->len;
+ memcpy(packet.data + sizeof *hdr, p->data, p->len);
mesh->self->in_packets++;
mesh->self->in_bytes += packet.len;