aboutsummaryrefslogtreecommitdiff
path: root/src/mesh/mesh_api.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesh/mesh_api.c')
-rw-r--r--src/mesh/mesh_api.c65
1 files changed, 17 insertions, 48 deletions
diff --git a/src/mesh/mesh_api.c b/src/mesh/mesh_api.c
index 0d1d70026..46dfe546f 100644
--- a/src/mesh/mesh_api.c
+++ b/src/mesh/mesh_api.c
@@ -277,19 +277,9 @@ struct GNUNET_MESH_Channel
277 unsigned int packet_size; 277 unsigned int packet_size;
278 278
279 /** 279 /**
280 * Is the channel allowed to buffer? 280 * Channel options: reliability, etc.
281 */ 281 */
282 int nobuffer; 282 enum MeshOption options;
283
284 /**
285 * Is the channel realiable?
286 */
287 int reliable;
288
289 /**
290 * If reliable, is the channel out of order?
291 */
292 int ooorder;
293 283
294 /** 284 /**
295 * Are we allowed to send to the service? 285 * Are we allowed to send to the service?
@@ -439,7 +429,6 @@ create_channel (struct GNUNET_MESH_Handle *h, MESH_ChannelNumber chid)
439 ch->chid = chid; 429 ch->chid = chid;
440 } 430 }
441 ch->allow_send = GNUNET_NO; 431 ch->allow_send = GNUNET_NO;
442 ch->nobuffer = GNUNET_NO;
443 return ch; 432 return ch;
444} 433}
445 434
@@ -782,24 +771,10 @@ process_channel_created (struct GNUNET_MESH_Handle *h,
782 ch->mesh = h; 771 ch->mesh = h;
783 ch->chid = chid; 772 ch->chid = chid;
784 ch->port = port; 773 ch->port = port;
785 if (0 != (msg->opt & GNUNET_MESH_OPTION_NOBUFFER)) 774 ch->options = ntohl (msg->opt);
786 ch->nobuffer = GNUNET_YES;
787 else
788 ch->nobuffer = GNUNET_NO;
789
790 if (0 != (msg->opt & GNUNET_MESH_OPTION_RELIABLE))
791 ch->reliable = GNUNET_YES;
792 else
793 ch->reliable = GNUNET_NO;
794
795 if (GNUNET_YES == ch->reliable &&
796 0 != (msg->opt & GNUNET_MESH_OPTION_OOORDER))
797 ch->ooorder = GNUNET_YES;
798 else
799 ch->ooorder = GNUNET_NO;
800 775
801 LOG (GNUNET_ERROR_TYPE_DEBUG, " created channel %p\n", ch); 776 LOG (GNUNET_ERROR_TYPE_DEBUG, " created channel %p\n", ch);
802 ctx = h->new_channel (h->cls, ch, &msg->peer, ch->port); 777 ctx = h->new_channel (h->cls, ch, &msg->peer, ch->port, ch->options);
803 if (NULL != ctx) 778 if (NULL != ctx)
804 ch->ctx = ctx; 779 ch->ctx = ctx;
805 LOG (GNUNET_ERROR_TYPE_DEBUG, "User notified\n"); 780 LOG (GNUNET_ERROR_TYPE_DEBUG, "User notified\n");
@@ -1398,18 +1373,16 @@ GNUNET_MESH_disconnect (struct GNUNET_MESH_Handle *handle)
1398 * @param channel_ctx client's channel context to associate with the channel 1373 * @param channel_ctx client's channel context to associate with the channel
1399 * @param peer peer identity the channel should go to 1374 * @param peer peer identity the channel should go to
1400 * @param port Port number. 1375 * @param port Port number.
1401 * @param nobuffer Flag for disabling buffering on relay nodes. 1376 * @param options MeshOption flag field, with all desired option bits set to 1.
1402 * @param reliable Flag for end-to-end reliability.
1403 * 1377 *
1404 * @return handle to the channel 1378 * @return handle to the channel
1405 */ 1379 */
1406struct GNUNET_MESH_Channel * 1380struct GNUNET_MESH_Channel *
1407GNUNET_MESH_channel_create (struct GNUNET_MESH_Handle *h, 1381GNUNET_MESH_channel_create (struct GNUNET_MESH_Handle *h,
1408 void *channel_ctx, 1382 void *channel_ctx,
1409 const struct GNUNET_PeerIdentity *peer, 1383 const struct GNUNET_PeerIdentity *peer,
1410 uint32_t port, 1384 uint32_t port,
1411 int nobuffer, 1385 enum MeshOption options)
1412 int reliable)
1413{ 1386{
1414 struct GNUNET_MESH_Channel *ch; 1387 struct GNUNET_MESH_Channel *ch;
1415 struct GNUNET_MESH_ChannelMessage msg; 1388 struct GNUNET_MESH_ChannelMessage msg;
@@ -1427,12 +1400,7 @@ GNUNET_MESH_channel_create (struct GNUNET_MESH_Handle *h,
1427 msg.channel_id = htonl (ch->chid); 1400 msg.channel_id = htonl (ch->chid);
1428 msg.port = htonl (port); 1401 msg.port = htonl (port);
1429 msg.peer = *peer; 1402 msg.peer = *peer;
1430 msg.opt = 0; 1403 msg.opt = htonl (options);
1431 if (GNUNET_YES == reliable)
1432 msg.opt |= GNUNET_MESH_OPTION_RELIABLE;
1433 if (GNUNET_YES == nobuffer)
1434 msg.opt |= GNUNET_MESH_OPTION_NOBUFFER;
1435 msg.opt = htonl (msg.opt);
1436 ch->allow_send = 0; 1404 ch->allow_send = 0;
1437 send_packet (h, &msg.header, ch); 1405 send_packet (h, &msg.header, ch);
1438 return ch; 1406 return ch;
@@ -1489,20 +1457,21 @@ GNUNET_MESH_channel_destroy (struct GNUNET_MESH_Channel *channel)
1489 */ 1457 */
1490const union GNUNET_MESH_ChannelInfo * 1458const union GNUNET_MESH_ChannelInfo *
1491GNUNET_MESH_channel_get_info (struct GNUNET_MESH_Channel *channel, 1459GNUNET_MESH_channel_get_info (struct GNUNET_MESH_Channel *channel,
1492 enum MeshOption option, ...) 1460 enum MeshOption option, ...)
1493{ 1461{
1462 static int bool_flag;
1494 const union GNUNET_MESH_ChannelInfo *ret; 1463 const union GNUNET_MESH_ChannelInfo *ret;
1495 1464
1496 switch (option) 1465 switch (option)
1497 { 1466 {
1498 case GNUNET_MESH_OPTION_NOBUFFER: 1467 case GNUNET_MESH_OPTION_NOBUFFER:
1499 ret = (const union GNUNET_MESH_ChannelInfo *) &channel->nobuffer;
1500 break;
1501 case GNUNET_MESH_OPTION_RELIABLE: 1468 case GNUNET_MESH_OPTION_RELIABLE:
1502 ret = (const union GNUNET_MESH_ChannelInfo *) &channel->reliable;
1503 break;
1504 case GNUNET_MESH_OPTION_OOORDER: 1469 case GNUNET_MESH_OPTION_OOORDER:
1505 ret = (const union GNUNET_MESH_ChannelInfo *) &channel->ooorder; 1470 if (0 != (option & channel->options))
1471 bool_flag = GNUNET_YES;
1472 else
1473 bool_flag = GNUNET_NO;
1474 ret = (const union GNUNET_MESH_ChannelInfo *) &bool_flag;
1506 break; 1475 break;
1507 case GNUNET_MESH_OPTION_PEER: 1476 case GNUNET_MESH_OPTION_PEER:
1508 ret = (const union GNUNET_MESH_ChannelInfo *) GNUNET_PEER_resolve2 (channel->peer); 1477 ret = (const union GNUNET_MESH_ChannelInfo *) GNUNET_PEER_resolve2 (channel->peer);