*/
#include "platform.h"
-#include "gnunet_common.h"
-#include "gnunet_client_lib.h"
#include "gnunet_util_lib.h"
-#include "gnunet_peer_lib.h"
#include "gnunet_mesh_service_enc.h"
-#include "mesh.h"
-#include "mesh_protocol.h"
+#include "mesh_enc.h"
+#include "mesh_protocol_enc.h"
#define LOG(kind,...) GNUNET_log_from (kind, "mesh-api",__VA_ARGS__)
* Time to the next reconnect in case one reconnect fails
*/
struct GNUNET_TIME_Relative reconnect_time;
-
+
/**
* Task for trying to reconnect.
*/
/**
* Flag indicating whether service has informed about its connection
+ * FIXME-BART: is this flag used? Seems dead right now...
*/
int connected;
/**
* Check whether there is any message ready in the queue and find the size.
- *
+ *
* @param h Mesh handle.
- *
+ *
* @return The size of the first ready message in the queue,
* 0 if there is none.
*/
/* clean up request */
if (GNUNET_SCHEDULER_NO_TASK != th->timeout_task)
GNUNET_SCHEDULER_cancel (th->timeout_task);
- GNUNET_free (th);
+ GNUNET_free (th);
}
/* if there are no more pending requests with mesh service, cancel active request */
/**
* Notify client that the transmission has timed out
- *
+ *
* @param cls closure
* @param tc task context
*/
struct GNUNET_MESH_TransmitHandle *th)
{
GNUNET_CONTAINER_DLL_insert_tail (h->th_head, h->th_tail, th);
- if (GNUNET_TIME_UNIT_FOREVER_ABS.abs_value == th->timeout.abs_value)
+ if (GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us == th->timeout.abs_value_us)
return;
th->timeout_task =
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining
/**
* Send an ack on the channel to confirm the processing of a message.
- *
+ *
* @param ch Channel on which to send the ACK.
*/
static void
GNUNET_TIME_relative_min (GNUNET_TIME_UNIT_SECONDS,
GNUNET_TIME_relative_multiply
(h->reconnect_time, 2));
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Next retry in %s\n",
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Next retry in %s\n",
GNUNET_STRINGS_relative_time_to_string (h->reconnect_time,
- GNUNET_NO));
+ GNUNET_NO));
GNUNET_break (0);
return GNUNET_NO;
}
*/
continue;
}
- ch->allow_send = GNUNET_NO;
- tmsg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_CHANNEL_CREATE);
+ ch->allow_send = GNUNET_NO;
+ tmsg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_CHANNEL_CREATE);
tmsg.header.size = htons (sizeof (struct GNUNET_MESH_ChannelMessage));
tmsg.channel_id = htonl (ch->chid);
tmsg.port = htonl (ch->port);
else
ch->ooorder = GNUNET_NO;
- LOG (GNUNET_ERROR_TYPE_DEBUG, " created channel %p\n", t);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, " created channel %p\n", ch);
ch->ctx = h->new_channel (h->cls, ch, &msg->peer, ch->port);
LOG (GNUNET_ERROR_TYPE_DEBUG, "User notified\n");
}
LOG (GNUNET_ERROR_TYPE_DEBUG, "No handler for incoming channels\n");
- d_msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_CHANNEL_DESTROY);
+ d_msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_CHANNEL_DESTROY);
d_msg.header.size = htons (sizeof (struct GNUNET_MESH_ChannelMessage));
d_msg.channel_id = msg->channel_id;
memset (&d_msg.peer, 0, sizeof (struct GNUNET_PeerIdentity));
dmsg = (struct GNUNET_MESH_LocalData *) message;
- ch = retrieve_channel (h, ntohl (dmsg->chid));
+ ch = retrieve_channel (h, ntohl (dmsg->id));
payload = (struct GNUNET_MessageHeader *) &dmsg[1];
LOG (GNUNET_ERROR_TYPE_DEBUG, " %s data on channel %s [%X]\n",
ch->chid >= GNUNET_MESH_LOCAL_CHANNEL_ID_SERV ? "fwd" : "bck",
- GNUNET_i2s (GNUNET_PEER_resolve2 (ch->peer)), ntohl (dmsg->chid));
+ GNUNET_i2s (GNUNET_PEER_resolve2 (ch->peer)), ntohl (dmsg->id));
if (NULL == ch)
{
/* Channel was ignored/destroyed, probably service didn't get it yet */
/**
* Process a local ACK message, enabling the client to send
* more data to the service.
- *
+ *
* @param h Mesh handle.
* @param message Message itself.
*/
MESH_ChannelNumber chid;
LOG (GNUNET_ERROR_TYPE_DEBUG, "Got an ACK!\n");
- h->acks_recv++;
msg = (struct GNUNET_MESH_LocalAck *) message;
chid = ntohl (msg->channel_id);
ch = retrieve_channel (h, chid);
if (msg == NULL)
{
- LOG (GNUNET_ERROR_TYPE_DEBUG,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"Mesh service disconnected, reconnecting\n", h);
reconnect (h);
return;
switch (type)
{
/* Notify of a new incoming channel */
- case GNUNET_MESSAGE_TYPE_MESH_LOCAL_CHANNEL_CREATE:
+ case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_CREATE:
process_channel_created (h, (struct GNUNET_MESH_ChannelMessage *) msg);
break;
/* Notify of a channel disconnection */
- case GNUNET_MESSAGE_TYPE_MESH_LOCAL_CHANNEL_DESTROY:
+ case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_DESTROY:
process_channel_destroy (h, (struct GNUNET_MESH_ChannelMessage *) msg);
break;
/* Notify of a new data packet in the channel */
psize += sizeof (struct GNUNET_MESH_LocalData);
GNUNET_assert (size >= psize);
dmsg->header.size = htons (psize);
- dmsg->chid = htonl (ch->chid);
+ dmsg->id = htonl (ch->chid);
dmsg->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_DATA);
LOG (GNUNET_ERROR_TYPE_DEBUG, "# payload type %s\n",
GNUNET_MESH_DEBUG_M2S (ntohs (mh->type)));
* Auxiliary function to send an already constructed packet to the service.
* Takes care of creating a new queue element, copying the message and
* calling the tmt_rdy function if necessary.
- *
+ *
* @param h mesh handle
* @param msg message to transmit
* @param channel channel this send is related to (NULL if N/A)
switch (ntohs(msg->type))
{
case GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT:
- case GNUNET_MESSAGE_TYPE_MESH_LOCAL_CHANNEL_DESTROY:
+ case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_CREATE:
+ case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_DESTROY:
case GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_CHANNELS:
case GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_CHANNEL:
break;
* @return handle to the channel
*/
struct GNUNET_MESH_Channel *
-GNUNET_MESH_channel_create (struct GNUNET_MESH_Handle *h,
+GNUNET_MESH_channel_create (struct GNUNET_MESH_Handle *h,
void *channel_ctx,
const struct GNUNET_PeerIdentity *peer,
uint32_t port,
LOG (GNUNET_ERROR_TYPE_DEBUG, " number %X\n", ch->chid);
ch->ctx = channel_ctx;
ch->peer = GNUNET_PEER_intern (peer);
- msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_CHANNEL_CREATE);
+ msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_CHANNEL_CREATE);
msg.header.size = htons (sizeof (struct GNUNET_MESH_ChannelMessage));
msg.channel_id = htonl (ch->chid);
msg.port = htonl (port);
LOG (GNUNET_ERROR_TYPE_DEBUG, "Destroying channel\n");
h = channel->mesh;
- msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_CHANNEL_DESTROY);
+ msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_CHANNEL_DESTROY);
msg.header.size = htons (sizeof (struct GNUNET_MESH_ChannelMessage));
msg.channel_id = htonl (channel->chid);
memset (&msg.peer, 0, sizeof (struct GNUNET_PeerIdentity));
*
* @return Union with an answer to the query.
*/
-const union MeshChannelInfo *
+const union GNUNET_MESH_ChannelInfo *
GNUNET_MESH_channel_get_info (struct GNUNET_MESH_Channel *channel,
- enum MeshChannelOption option, ...)
+ enum MeshOption option, ...)
{
- const union MeshChannelInfo *ret;
+ const union GNUNET_MESH_ChannelInfo *ret;
switch (option)
{
case GNUNET_MESH_OPTION_NOBUFFER:
- ret = (const union MeshChannelInfo *) &channel->nobuffer;
+ ret = (const union GNUNET_MESH_ChannelInfo *) &channel->nobuffer;
break;
case GNUNET_MESH_OPTION_RELIABLE:
- ret = (const union MeshChannelInfo *) &channel->reliable;
+ ret = (const union GNUNET_MESH_ChannelInfo *) &channel->reliable;
break;
case GNUNET_MESH_OPTION_OOORDER:
- ret = (const union MeshChannelInfo *) &channel->ooorder;
+ ret = (const union GNUNET_MESH_ChannelInfo *) &channel->ooorder;
break;
case GNUNET_MESH_OPTION_PEER:
- ret = (const union MeshChannelInfo *) &channel->peer;
+ ret = (const union GNUNET_MESH_ChannelInfo *) &channel->peer;
break;
default:
GNUNET_break (0);
mesh_mq_ntr (void *cls, size_t size,
void *buf)
{
- struct GNUNET_MQ_Handle *mq = cls;
+ struct GNUNET_MQ_Handle *mq = cls;
struct MeshMQState *state = GNUNET_MQ_impl_state (mq);
const struct GNUNET_MessageHeader *msg = GNUNET_MQ_impl_current (mq);
uint16_t msize;
GNUNET_MESH_notify_transmit_ready (state->channel,
/* FIXME: add option for corking */
GNUNET_NO,
- GNUNET_TIME_UNIT_FOREVER_REL,
+ GNUNET_TIME_UNIT_FOREVER_REL,
ntohs (msg->size),
mesh_mq_ntr, mq);
* destruction of a message queue.
* Implementations must not free 'mq', but should
* take care of 'impl_state'.
- *
+ *
* @param mq the message queue to destroy
* @param impl_state state of the implementation
*/