/**
* Double Linked list
*/
- struct GNUNET_MESH_queue *next;
- struct GNUNET_MESH_queue *prev;
+ struct GNUNET_MESH_queue *next;
+ struct GNUNET_MESH_queue *prev;
/**
* Size of the data to follow
*/
- uint16_t size;
+ uint16_t size;
/**
* Data itself
*/
- void *data;
+ void *data;
};
/**
* Messages to send to the service
*/
- struct GNUNET_MESH_queue *queue_head;
- struct GNUNET_MESH_queue *queue_tail;
+ struct GNUNET_MESH_queue *queue_head;
+ struct GNUNET_MESH_queue *queue_tail;
};
/**
* All peers added to the tunnel
*/
GNUNET_PEER_Id *peers;
-
+
/**
* Number of peer added to the tunnel
*/
uint32_t i;
/* count */
- for (q = h->queue_head, i = 0; NULL != q; q = q->next, i++);
+ for (q = h->queue_head, i = 0; NULL != q; q = q->next, i++) ;
return i;
}
{
GNUNET_break (0);
GNUNET_assert (sizeof (struct GNUNET_MessageHeader) > q->size);
- h->th = GNUNET_CLIENT_notify_transmit_ready (h->client, q->size,
- GNUNET_TIME_UNIT_FOREVER_REL,
- GNUNET_YES, &send_raw, h);
+ h->th =
+ GNUNET_CLIENT_notify_transmit_ready (h->client, q->size,
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ GNUNET_YES, &send_raw, h);
return 0;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh: type: %i\n",
- ntohs(((struct GNUNET_MessageHeader *)q->data)->type));
- memcpy(buf, q->data, q->size);
+ ntohs (((struct GNUNET_MessageHeader *) q->data)->type));
+ memcpy (buf, q->data, q->size);
GNUNET_free (q->data);
size = q->size;
- GNUNET_CONTAINER_DLL_remove(h->queue_head, h->queue_tail, q);
- GNUNET_free(q);
+ GNUNET_CONTAINER_DLL_remove (h->queue_head, h->queue_tail, q);
+ GNUNET_free (q);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh: size: %u\n", size);
if (NULL != h->queue_head)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh: next size: %u\n",
h->queue_head->size);
- h->th = GNUNET_CLIENT_notify_transmit_ready (h->client, h->queue_head->size,
- GNUNET_TIME_UNIT_FOREVER_REL,
- GNUNET_YES, &send_raw, h);
+ h->th =
+ GNUNET_CLIENT_notify_transmit_ready (h->client, h->queue_head->size,
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ GNUNET_YES, &send_raw, h);
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh: Send packet() END\n");
GNUNET_CONTAINER_DLL_insert_tail (h->queue_head, h->queue_tail, q);
if (NULL == h->th)
{
- h->th = GNUNET_CLIENT_notify_transmit_ready (h->client, size,
- GNUNET_TIME_UNIT_FOREVER_REL,
- GNUNET_YES, &send_raw, h);
+ h->th =
+ GNUNET_CLIENT_notify_transmit_ready (h->client, size,
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ GNUNET_YES, &send_raw, h);
}
}
size += h->n_applications * sizeof (GNUNET_MESH_ApplicationType);
/* build connection packet */
- msg = GNUNET_malloc(size);
+ msg = GNUNET_malloc (size);
msg->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT);
msg->header.size = htons (size);
- types = (uint16_t *) &msg[1];
+ types = (uint16_t *) & msg[1];
for (ntypes = 0; ntypes < h->n_handlers; ntypes++)
{
types[ntypes] = h->message_handlers[ntypes].type;
"mesh: Sending %lu bytes long message %d types and %d apps\n",
ntohs (msg->header.size), ntypes, napps);
- send_packet(h, size, msg);
+ send_packet (h, size, msg);
GNUNET_CLIENT_receive (h->client, &msg_received, h,
GNUNET_TIME_UNIT_FOREVER_REL);
msg->header.size = htons (sizeof (struct GNUNET_MESH_TunnelMessage));
msg->tunnel_id = htonl (t->tid);
- send_packet(h, sizeof (struct GNUNET_MESH_TunnelMessage), msg);
+ send_packet (h, sizeof (struct GNUNET_MESH_TunnelMessage), msg);
return t;
}
GNUNET_free (tun);
- send_packet(h, sizeof (struct GNUNET_MESH_TunnelMessage), msg);
+ send_packet (h, sizeof (struct GNUNET_MESH_TunnelMessage), msg);
}
}
}
tunnel->npeers++;
- tunnel->peers = GNUNET_realloc (tunnel->peers,
- tunnel->npeers * sizeof (GNUNET_PEER_Id));
+ tunnel->peers =
+ GNUNET_realloc (tunnel->peers, tunnel->npeers * sizeof (GNUNET_PEER_Id));
tunnel->peers[tunnel->npeers - 1] = peer_id;
msg = GNUNET_malloc (sizeof (struct GNUNET_MESH_PeerControl));
msg->header.size = htons (sizeof (struct GNUNET_MESH_PeerControl));
msg->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_ADD);
- msg->tunnel_id = htonl(tunnel->tid);
+ msg->tunnel_id = htonl (tunnel->tid);
memcpy (&msg->peer, peer, sizeof (struct GNUNET_PeerIdentity));
- send_packet(tunnel->mesh, sizeof (struct GNUNET_MESH_PeerControl), msg);
+ send_packet (tunnel->mesh, sizeof (struct GNUNET_MESH_PeerControl), msg);
// tunnel->connect_handler (tunnel->cls, peer, NULL); FIXME call this later
// TODO: remember timeout
int i;
peer_id = GNUNET_PEER_search (peer);
- if (0 == peer_id) return;
+ if (0 == peer_id)
+ return;
for (i = 0; i < tunnel->npeers; i++)
{
if (tunnel->peers[i] == peer_id)
tunnel->npeers--;
while (i < tunnel->npeers)
{
- tunnel->peers[i] = tunnel->peers[i+1];
+ tunnel->peers[i] = tunnel->peers[i + 1];
i++;
}
- tunnel->peers = GNUNET_realloc (tunnel->peers,
- tunnel->npeers * sizeof (GNUNET_PEER_Id));
+ tunnel->peers =
+ GNUNET_realloc (tunnel->peers,
+ tunnel->npeers * sizeof (GNUNET_PEER_Id));
msg = GNUNET_malloc (sizeof (struct GNUNET_MESH_PeerControl));
- msg->header.size = htons(sizeof (struct GNUNET_MESH_PeerControl));
- msg->header.type = htons(GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_DEL);
- msg->tunnel_id = htonl(tunnel->tid);
+ msg->header.size = htons (sizeof (struct GNUNET_MESH_PeerControl));
+ msg->header.type =
+ htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_DEL);
+ msg->tunnel_id = htonl (tunnel->tid);
memcpy (&msg->peer, peer, sizeof (struct GNUNET_PeerIdentity));
- send_packet(tunnel->mesh, sizeof (struct GNUNET_MESH_PeerControl), msg);
+ send_packet (tunnel->mesh, sizeof (struct GNUNET_MESH_PeerControl), msg);
return;
}
GNUNET_MESH_ApplicationType app_type)
{
struct GNUNET_MESH_ConnectPeerByType *msg;
- msg = GNUNET_malloc (sizeof (struct GNUNET_MESH_ConnectPeerByType));
- msg->header.size = htons(sizeof (struct GNUNET_MESH_ConnectPeerByType));
- msg->header.type = htons(GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_BY_TYPE);
- msg->tunnel_id = htonl(tunnel->tid);
- msg->type = htonl(app_type);
- send_packet(tunnel->mesh, sizeof (struct GNUNET_MESH_ConnectPeerByType), msg);
+ msg = GNUNET_malloc (sizeof (struct GNUNET_MESH_ConnectPeerByType));
+ msg->header.size = htons (sizeof (struct GNUNET_MESH_ConnectPeerByType));
+ msg->header.type =
+ htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_BY_TYPE);
+ msg->tunnel_id = htonl (tunnel->tid);
+ msg->type = htonl (app_type);
+
+ send_packet (tunnel->mesh, sizeof (struct GNUNET_MESH_ConnectPeerByType),
+ msg);
// TODO: remember timeout
return;
}
handle->q->size = notify_size;
handle->q->data = GNUNET_malloc (notify_size);
- if (get_queue_length(tunnel->mesh) < MESH_API_MAX_QUEUE)
+ if (get_queue_length (tunnel->mesh) < MESH_API_MAX_QUEUE)
{
notify (notify_cls, notify_size, handle->q->data);
- GNUNET_CONTAINER_DLL_insert_tail(tunnel->mesh->queue_head,
- tunnel->mesh->queue_tail,
- handle->q);
- } else {
+ GNUNET_CONTAINER_DLL_insert_tail (tunnel->mesh->queue_head,
+ tunnel->mesh->queue_tail, handle->q);
+ }
+ else
+ {
// TODO dataless - queue
}
void
GNUNET_MESH_notify_transmit_ready_cancel (struct GNUNET_MESH_TransmitHandle *th)
{
- GNUNET_CONTAINER_DLL_remove(th->t->mesh->queue_head,
- th->t->mesh->queue_tail,
- th->q);
- // TODO remove from dataless queue
- GNUNET_free (th->q->data);
- GNUNET_free (th->q);
- GNUNET_free (th);
+ GNUNET_CONTAINER_DLL_remove (th->t->mesh->queue_head, th->t->mesh->queue_tail,
+ th->q);
+ // TODO remove from dataless queue
+ GNUNET_free (th->q->data);
+ GNUNET_free (th->q);
+ GNUNET_free (th);
}