* Channel this peer belongs to
*/
struct GNUNET_MESH_Channel *t;
-
- /**
- * Flag indicating whether service has informed about its connection
- * FIXME-BART: is this flag used? Seems dead right now...
- */
- int connected;
-
};
unsigned int packet_size;
/**
- * Is the channel allowed to buffer?
- */
- int nobuffer;
-
- /**
- * Is the channel realiable?
- */
- int reliable;
-
- /**
- * If reliable, is the channel out of order?
+ * Channel options: reliability, etc.
*/
- int ooorder;
+ enum GNUNET_MESH_ChannelOption options;
/**
* Are we allowed to send to the service?
ch->chid = chid;
}
ch->allow_send = GNUNET_NO;
- ch->nobuffer = GNUNET_NO;
return ch;
}
ch->mesh = h;
ch->chid = chid;
ch->port = port;
- if (0 != (msg->opt & GNUNET_MESH_OPTION_NOBUFFER))
- ch->nobuffer = GNUNET_YES;
- else
- ch->nobuffer = GNUNET_NO;
-
- if (0 != (msg->opt & GNUNET_MESH_OPTION_RELIABLE))
- ch->reliable = GNUNET_YES;
- else
- ch->reliable = GNUNET_NO;
-
- if (GNUNET_YES == ch->reliable &&
- 0 != (msg->opt & GNUNET_MESH_OPTION_OOORDER))
- ch->ooorder = GNUNET_YES;
- else
- ch->ooorder = GNUNET_NO;
+ ch->options = ntohl (msg->opt);
LOG (GNUNET_ERROR_TYPE_DEBUG, " created channel %p\n", ch);
- ctx = h->new_channel (h->cls, ch, &msg->peer, ch->port);
+ ctx = h->new_channel (h->cls, ch, &msg->peer, ch->port, ch->options);
if (NULL != ctx)
ch->ctx = ctx;
LOG (GNUNET_ERROR_TYPE_DEBUG, "User notified\n");
type = ntohs (msg->type);
LOG (GNUNET_ERROR_TYPE_DEBUG, "\n");
LOG (GNUNET_ERROR_TYPE_DEBUG, "Received a message: %s\n",
- GNUNET_MESH_DEBUG_M2S (type));
+ GM_m2s (type));
switch (type)
{
/* Notify of a new incoming channel */
process_channel_created (h, (struct GNUNET_MESH_ChannelMessage *) msg);
break;
/* Notify of a channel disconnection */
- case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_DESTROY:
+ case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_DESTROY: /* TODO separate(gid problem)*/
case GNUNET_MESSAGE_TYPE_MESH_LOCAL_NACK:
process_channel_destroy (h, (struct GNUNET_MESH_ChannelMessage *) msg);
break;
/* We shouldn't get any other packages, log and ignore */
LOG (GNUNET_ERROR_TYPE_WARNING,
"unsolicited message form service (type %s)\n",
- GNUNET_MESH_DEBUG_M2S (ntohs (msg->type)));
+ GM_m2s (ntohs (msg->type)));
}
LOG (GNUNET_ERROR_TYPE_DEBUG, "message processed\n");
if (GNUNET_YES == h->in_receive)
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)));
+ GM_m2s (ntohs (mh->type)));
ch->allow_send = GNUNET_NO;
}
else
struct GNUNET_MessageHeader *mh = (struct GNUNET_MessageHeader *) &th[1];
LOG (GNUNET_ERROR_TYPE_DEBUG, "# mesh internal traffic, type %s\n",
- GNUNET_MESH_DEBUG_M2S (ntohs (mh->type)));
+ GM_m2s (ntohs (mh->type)));
memcpy (cbuf, &th[1], th->size);
psize = th->size;
}
size_t msize;
LOG (GNUNET_ERROR_TYPE_DEBUG, " Sending message to service: %s\n",
- GNUNET_MESH_DEBUG_M2S(ntohs(msg->type)));
+ GM_m2s(ntohs(msg->type)));
msize = ntohs (msg->size);
th = GNUNET_malloc (sizeof (struct GNUNET_MESH_TransmitHandle) + msize);
th->timeout = GNUNET_TIME_UNIT_FOREVER_ABS;
* @param channel_ctx client's channel context to associate with the channel
* @param peer peer identity the channel should go to
* @param port Port number.
- * @param nobuffer Flag for disabling buffering on relay nodes.
- * @param reliable Flag for end-to-end reliability.
+ * @param options MeshOption flag field, with all desired option bits set to 1.
*
* @return handle to the channel
*/
struct GNUNET_MESH_Channel *
GNUNET_MESH_channel_create (struct GNUNET_MESH_Handle *h,
- void *channel_ctx,
- const struct GNUNET_PeerIdentity *peer,
- uint32_t port,
- int nobuffer,
- int reliable)
+ void *channel_ctx,
+ const struct GNUNET_PeerIdentity *peer,
+ uint32_t port,
+ enum GNUNET_MESH_ChannelOption options)
{
struct GNUNET_MESH_Channel *ch;
struct GNUNET_MESH_ChannelMessage msg;
msg.channel_id = htonl (ch->chid);
msg.port = htonl (port);
msg.peer = *peer;
- msg.opt = 0;
- if (GNUNET_YES == reliable)
- msg.opt |= GNUNET_MESH_OPTION_RELIABLE;
- if (GNUNET_YES == nobuffer)
- msg.opt |= GNUNET_MESH_OPTION_NOBUFFER;
- msg.opt = htonl (msg.opt);
+ msg.opt = htonl (options);
ch->allow_send = 0;
send_packet (h, &msg.header, ch);
return ch;
*/
const union GNUNET_MESH_ChannelInfo *
GNUNET_MESH_channel_get_info (struct GNUNET_MESH_Channel *channel,
- enum MeshOption option, ...)
+ enum GNUNET_MESH_ChannelOption option, ...)
{
+ static int bool_flag;
const union GNUNET_MESH_ChannelInfo *ret;
switch (option)
{
case GNUNET_MESH_OPTION_NOBUFFER:
- ret = (const union GNUNET_MESH_ChannelInfo *) &channel->nobuffer;
- break;
case GNUNET_MESH_OPTION_RELIABLE:
- ret = (const union GNUNET_MESH_ChannelInfo *) &channel->reliable;
- break;
case GNUNET_MESH_OPTION_OOORDER:
- ret = (const union GNUNET_MESH_ChannelInfo *) &channel->ooorder;
+ if (0 != (option & channel->options))
+ bool_flag = GNUNET_YES;
+ else
+ bool_flag = GNUNET_NO;
+ ret = (const union GNUNET_MESH_ChannelInfo *) &bool_flag;
break;
case GNUNET_MESH_OPTION_PEER:
ret = (const union GNUNET_MESH_ChannelInfo *) GNUNET_PEER_resolve2 (channel->peer);