aboutsummaryrefslogtreecommitdiff
path: root/src/cadet
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2016-07-20 12:07:02 +0000
committerBart Polot <bart@net.in.tum.de>2016-07-20 12:07:02 +0000
commitcaa4196867da8684c5b1fd2e747ecb9d21cbba8b (patch)
treea8d2ab68b81df8040c013118b7197209c70fa4c2 /src/cadet
parenta603aaacbb3e786ab50644ca6fb49add439c8d8b (diff)
downloadgnunet-caa4196867da8684c5b1fd2e747ecb9d21cbba8b.tar.gz
gnunet-caa4196867da8684c5b1fd2e747ecb9d21cbba8b.zip
Change CADET ports from uint32 to HashCode
Diffstat (limited to 'src/cadet')
-rw-r--r--src/cadet/cadet.h48
-rw-r--r--src/cadet/cadet_api.c265
-rw-r--r--src/cadet/cadet_common.c15
-rw-r--r--src/cadet/cadet_protocol.h2
-rw-r--r--src/cadet/cadet_test_lib.c4
-rw-r--r--src/cadet/gnunet-cadet.c42
-rw-r--r--src/cadet/gnunet-service-cadet_channel.c31
-rw-r--r--src/cadet/gnunet-service-cadet_channel.h2
-rw-r--r--src/cadet/gnunet-service-cadet_local.c151
-rw-r--r--src/cadet/gnunet-service-cadet_local.h6
-rw-r--r--src/cadet/gnunet-service-cadet_tunnel.c2
-rw-r--r--src/cadet/test_cadet.c2
12 files changed, 326 insertions, 244 deletions
diff --git a/src/cadet/cadet.h b/src/cadet/cadet.h
index df0f02a22..61388bb15 100644
--- a/src/cadet/cadet.h
+++ b/src/cadet/cadet.h
@@ -63,22 +63,24 @@ extern "C"
63 63
64GNUNET_NETWORK_STRUCT_BEGIN 64GNUNET_NETWORK_STRUCT_BEGIN
65 65
66
66/** 67/**
67 * Message for a client to register to the service 68 * Message for a client to create and destroy channels.
68 */ 69 */
69struct GNUNET_CADET_ClientConnect 70struct GNUNET_CADET_PortMessage
70{ 71{
71 /** 72 /**
72 * Type: GNUNET_MESSAGE_TYPE_CADET_LOCAL_CONNECT 73 * Type: GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_[OPEN|CLOSE]
73 * 74 *
74 * Size: sizeof(struct GNUNET_CADET_ClientConnect) + 75 * Size: sizeof(struct GNUNET_CADET_ChannelMessage)
75 * sizeof(CADET_ApplicationType) * applications +
76 * sizeof(uint16_t) * types
77 */ 76 */
78 struct GNUNET_MessageHeader header; 77 struct GNUNET_MessageHeader header;
79 /* uint32_t list_ports[] */
80};
81 78
79 /**
80 * Port to open/close.
81 */
82 struct GNUNET_HashCode port GNUNET_PACKED;
83};
82 84
83/** 85/**
84 * Type for channel numbering. 86 * Type for channel numbering.
@@ -90,14 +92,14 @@ typedef uint32_t CADET_ChannelNumber;
90 92
91 93
92/** 94/**
93 * Message for a client to create and destroy channels. 95 * Message for a client to create channels.
94 */ 96 */
95struct GNUNET_CADET_ChannelMessage 97struct GNUNET_CADET_ChannelCreateMessage
96{ 98{
97 /** 99 /**
98 * Type: GNUNET_MESSAGE_TYPE_CADET_LOCAL_TUNNEL_[CREATE|DESTROY] 100 * Type: GNUNET_MESSAGE_TYPE_CADET_LOCAL_TUNNEL_CREATE
99 * 101 *
100 * Size: sizeof(struct GNUNET_CADET_ChannelMessage) 102 * Size: sizeof(struct GNUNET_CADET_ChannelCreateMessage)
101 */ 103 */
102 struct GNUNET_MessageHeader header; 104 struct GNUNET_MessageHeader header;
103 105
@@ -114,7 +116,7 @@ struct GNUNET_CADET_ChannelMessage
114 /** 116 /**
115 * Port of the channel. 117 * Port of the channel.
116 */ 118 */
117 uint32_t port GNUNET_PACKED; 119 struct GNUNET_HashCode port;
118 120
119 /** 121 /**
120 * Options. 122 * Options.
@@ -124,6 +126,25 @@ struct GNUNET_CADET_ChannelMessage
124 126
125 127
126/** 128/**
129 * Message for a client to destroy channels.
130 */
131struct GNUNET_CADET_ChannelDestroyMessage
132{
133 /**
134 * Type: GNUNET_MESSAGE_TYPE_CADET_LOCAL_TUNNEL_DESTROY
135 *
136 * Size: sizeof(struct GNUNET_CADET_ChannelDestroyMessage)
137 */
138 struct GNUNET_MessageHeader header;
139
140 /**
141 * ID of a channel controlled by this client.
142 */
143 CADET_ChannelNumber channel_id GNUNET_PACKED;
144};
145
146
147/**
127 * Message for cadet data traffic. 148 * Message for cadet data traffic.
128 */ 149 */
129struct GNUNET_CADET_LocalData 150struct GNUNET_CADET_LocalData
@@ -262,7 +283,6 @@ struct GNUNET_CADET_LocalInfoTunnel
262GNUNET_NETWORK_STRUCT_END 283GNUNET_NETWORK_STRUCT_END
263 284
264 285
265
266/** 286/**
267 * @brief Translate a fwd variable into a string representation, for logging. 287 * @brief Translate a fwd variable into a string representation, for logging.
268 * 288 *
diff --git a/src/cadet/cadet_api.c b/src/cadet/cadet_api.c
index 1ad3ec5b0..1ca8bad9d 100644
--- a/src/cadet/cadet_api.c
+++ b/src/cadet/cadet_api.c
@@ -142,12 +142,7 @@ struct GNUNET_CADET_Handle
142 /** 142 /**
143 * Ports open. 143 * Ports open.
144 */ 144 */
145 const uint32_t *ports; 145 struct GNUNET_CONTAINER_MultiHashMap *ports;
146
147 /**
148 * Number of ports.
149 */
150 unsigned int n_ports;
151 146
152 /** 147 /**
153 * Double linked list of the channels this client is connected to, head. 148 * Double linked list of the channels this client is connected to, head.
@@ -160,11 +155,6 @@ struct GNUNET_CADET_Handle
160 struct GNUNET_CADET_Channel *channels_tail; 155 struct GNUNET_CADET_Channel *channels_tail;
161 156
162 /** 157 /**
163 * Callback for inbound channel creation
164 */
165 GNUNET_CADET_InboundChannelNotificationHandler *new_channel;
166
167 /**
168 * Callback for inbound channel disconnection 158 * Callback for inbound channel disconnection
169 */ 159 */
170 GNUNET_CADET_ChannelEndHandler *cleaner; 160 GNUNET_CADET_ChannelEndHandler *cleaner;
@@ -249,7 +239,6 @@ struct GNUNET_CADET_Peer
249 */ 239 */
250struct GNUNET_CADET_Channel 240struct GNUNET_CADET_Channel
251{ 241{
252
253 /** 242 /**
254 * DLL next 243 * DLL next
255 */ 244 */
@@ -271,9 +260,9 @@ struct GNUNET_CADET_Channel
271 CADET_ChannelNumber chid; 260 CADET_ChannelNumber chid;
272 261
273 /** 262 /**
274 * Port number. 263 * Channel's port, if any.
275 */ 264 */
276 uint32_t port; 265 struct GNUNET_CADET_Port *port;
277 266
278 /** 267 /**
279 * Other end of the channel. 268 * Other end of the channel.
@@ -302,6 +291,32 @@ struct GNUNET_CADET_Channel
302 291
303}; 292};
304 293
294/**
295 * Opaque handle to a port.
296 */
297struct GNUNET_CADET_Port
298{
299 /**
300 * Handle to the CADET session this port belongs to.
301 */
302 struct GNUNET_CADET_Handle *cadet;
303
304 /**
305 * Port ID.
306 */
307 struct GNUNET_HashCode *hash;
308
309 /**
310 * Callback handler for incoming channels on this port.
311 */
312 GNUNET_CADET_InboundChannelNotificationHandler *handler;
313
314 /**
315 * Closure for @a handler.
316 */
317 void *cls;
318};
319
305 320
306/** 321/**
307 * Implementation state for cadet's message queue. 322 * Implementation state for cadet's message queue.
@@ -359,6 +374,25 @@ th_is_payload (struct GNUNET_CADET_TransmitHandle *th)
359 374
360 375
361/** 376/**
377 * Find the Port struct for a hash.
378 *
379 * @param h CADET handle.
380 * @param hash HashCode for the port number.
381 *
382 * @return The port handle if known, NULL otherwise.
383 */
384static struct GNUNET_CADET_Port *
385find_port (const struct GNUNET_CADET_Handle *h,
386 const struct GNUNET_HashCode *hash)
387{
388 struct GNUNET_CADET_Port *p;
389
390 p = GNUNET_CONTAINER_multihashmap_get (h->ports, hash);
391
392 return p;
393}
394
395/**
362 * Check whether there is any message ready in the queue and find the size. 396 * Check whether there is any message ready in the queue and find the size.
363 * 397 *
364 * @param h Cadet handle. 398 * @param h Cadet handle.
@@ -604,45 +638,6 @@ reconnect_cbk (void *cls);
604 638
605 639
606/** 640/**
607 * Send a connect packet to the service with the applications and types
608 * requested by the user.
609 *
610 * @param h The cadet handle.
611 *
612 */
613static void
614send_connect (struct GNUNET_CADET_Handle *h)
615{
616 size_t size;
617
618 size = sizeof (struct GNUNET_CADET_ClientConnect);
619 size += h->n_ports * sizeof (uint32_t);
620 {
621 char buf[size] GNUNET_ALIGN;
622 struct GNUNET_CADET_ClientConnect *msg;
623 uint32_t *ports;
624 uint16_t i;
625
626 /* build connection packet */
627 msg = (struct GNUNET_CADET_ClientConnect *) buf;
628 msg->header.type = htons (GNUNET_MESSAGE_TYPE_CADET_LOCAL_CONNECT);
629 msg->header.size = htons (size);
630 ports = (uint32_t *) &msg[1];
631 for (i = 0; i < h->n_ports; i++)
632 {
633 ports[i] = htonl (h->ports[i]);
634 LOG (GNUNET_ERROR_TYPE_DEBUG, " port %u\n",
635 h->ports[i]);
636 }
637 LOG (GNUNET_ERROR_TYPE_DEBUG,
638 "Sending %lu bytes long message with %u ports\n",
639 ntohs (msg->header.size), h->n_ports);
640 send_packet (h, &msg->header, NULL);
641 }
642}
643
644
645/**
646 * Reconnect to the service, retransmit all infomation to try to restore the 641 * Reconnect to the service, retransmit all infomation to try to restore the
647 * original state. 642 * original state.
648 * 643 *
@@ -690,7 +685,6 @@ do_reconnect (struct GNUNET_CADET_Handle *h)
690 { 685 {
691 h->reconnect_time = GNUNET_TIME_UNIT_MILLISECONDS; 686 h->reconnect_time = GNUNET_TIME_UNIT_MILLISECONDS;
692 } 687 }
693 send_connect (h);
694 return GNUNET_YES; 688 return GNUNET_YES;
695} 689}
696 690
@@ -746,21 +740,24 @@ reconnect (struct GNUNET_CADET_Handle *h)
746 */ 740 */
747static void 741static void
748process_channel_created (struct GNUNET_CADET_Handle *h, 742process_channel_created (struct GNUNET_CADET_Handle *h,
749 const struct GNUNET_CADET_ChannelMessage *msg) 743 const struct GNUNET_CADET_ChannelCreateMessage *msg)
750{ 744{
751 struct GNUNET_CADET_Channel *ch; 745 struct GNUNET_CADET_Channel *ch;
746 struct GNUNET_CADET_Port *port;
747 const struct GNUNET_HashCode *port_number;
752 CADET_ChannelNumber chid; 748 CADET_ChannelNumber chid;
753 uint32_t port;
754 749
755 chid = ntohl (msg->channel_id); 750 chid = ntohl (msg->channel_id);
756 port = ntohl (msg->port); 751 port_number = &msg->port;
757 LOG (GNUNET_ERROR_TYPE_DEBUG, "Creating incoming channel %X:%u\n", chid, port); 752 LOG (GNUNET_ERROR_TYPE_DEBUG, "Creating incoming channel %X [%s]\n",
753 chid, GNUNET_h2s (port_number));
758 if (chid < GNUNET_CADET_LOCAL_CHANNEL_ID_SERV) 754 if (chid < GNUNET_CADET_LOCAL_CHANNEL_ID_SERV)
759 { 755 {
760 GNUNET_break (0); 756 GNUNET_break (0);
761 return; 757 return;
762 } 758 }
763 if (NULL != h->new_channel) 759 port = find_port (h, port_number);
760 if (NULL != port)
764 { 761 {
765 void *ctx; 762 void *ctx;
766 763
@@ -773,23 +770,20 @@ process_channel_created (struct GNUNET_CADET_Handle *h,
773 ch->options = ntohl (msg->opt); 770 ch->options = ntohl (msg->opt);
774 771
775 LOG (GNUNET_ERROR_TYPE_DEBUG, " created channel %p\n", ch); 772 LOG (GNUNET_ERROR_TYPE_DEBUG, " created channel %p\n", ch);
776 ctx = h->new_channel (h->cls, ch, &msg->peer, ch->port, ch->options); 773 ctx = port->handler (port->cls, ch, &msg->peer, port->hash, ch->options);
777 if (NULL != ctx) 774 if (NULL != ctx)
778 ch->ctx = ctx; 775 ch->ctx = ctx;
779 LOG (GNUNET_ERROR_TYPE_DEBUG, "User notified\n"); 776 LOG (GNUNET_ERROR_TYPE_DEBUG, "User notified\n");
780 } 777 }
781 else 778 else
782 { 779 {
783 struct GNUNET_CADET_ChannelMessage d_msg; 780 struct GNUNET_CADET_ChannelDestroyMessage d_msg;
784 781
785 LOG (GNUNET_ERROR_TYPE_DEBUG, "No handler for incoming channels\n"); 782 LOG (GNUNET_ERROR_TYPE_DEBUG, "No handler for incoming channels\n");
786 783
787 d_msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY); 784 d_msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY);
788 d_msg.header.size = htons (sizeof (struct GNUNET_CADET_ChannelMessage)); 785 d_msg.header.size = htons (sizeof (struct GNUNET_CADET_ChannelDestroyMessage));
789 d_msg.channel_id = msg->channel_id; 786 d_msg.channel_id = msg->channel_id;
790 memset (&d_msg.peer, 0, sizeof (struct GNUNET_PeerIdentity));
791 d_msg.port = 0;
792 d_msg.opt = 0;
793 787
794 send_packet (h, &d_msg.header, NULL); 788 send_packet (h, &d_msg.header, NULL);
795 } 789 }
@@ -805,7 +799,7 @@ process_channel_created (struct GNUNET_CADET_Handle *h,
805 */ 799 */
806static void 800static void
807process_channel_destroy (struct GNUNET_CADET_Handle *h, 801process_channel_destroy (struct GNUNET_CADET_Handle *h,
808 const struct GNUNET_CADET_ChannelMessage *msg) 802 const struct GNUNET_CADET_ChannelDestroyMessage *msg)
809{ 803{
810 struct GNUNET_CADET_Channel *ch; 804 struct GNUNET_CADET_Channel *ch;
811 CADET_ChannelNumber chid; 805 CADET_ChannelNumber chid;
@@ -1270,12 +1264,14 @@ msg_received (void *cls, const struct GNUNET_MessageHeader *msg)
1270 { 1264 {
1271 /* Notify of a new incoming channel */ 1265 /* Notify of a new incoming channel */
1272 case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_CREATE: 1266 case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_CREATE:
1273 process_channel_created (h, (struct GNUNET_CADET_ChannelMessage *) msg); 1267 process_channel_created (h,
1268 (struct GNUNET_CADET_ChannelCreateMessage *) msg);
1274 break; 1269 break;
1275 /* Notify of a channel disconnection */ 1270 /* Notify of a channel disconnection */
1276 case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY: /* TODO separate(gid problem)*/ 1271 case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY: /* TODO separate(gid problem)*/
1277 case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_NACK: 1272 case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_NACK:
1278 process_channel_destroy (h, (struct GNUNET_CADET_ChannelMessage *) msg); 1273 process_channel_destroy (h,
1274 (struct GNUNET_CADET_ChannelDestroyMessage *) msg);
1279 break; 1275 break;
1280 case GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA: 1276 case GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA:
1281 process_incoming_data (h, msg); 1277 process_incoming_data (h, msg);
@@ -1496,10 +1492,8 @@ send_packet (struct GNUNET_CADET_Handle *h,
1496 1492
1497struct GNUNET_CADET_Handle * 1493struct GNUNET_CADET_Handle *
1498GNUNET_CADET_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, void *cls, 1494GNUNET_CADET_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, void *cls,
1499 GNUNET_CADET_InboundChannelNotificationHandler new_channel,
1500 GNUNET_CADET_ChannelEndHandler cleaner, 1495 GNUNET_CADET_ChannelEndHandler cleaner,
1501 const struct GNUNET_CADET_MessageHandler *handlers, 1496 const struct GNUNET_CADET_MessageHandler *handlers)
1502 const uint32_t *ports)
1503{ 1497{
1504 struct GNUNET_CADET_Handle *h; 1498 struct GNUNET_CADET_Handle *h;
1505 1499
@@ -1507,8 +1501,8 @@ GNUNET_CADET_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, void *cls,
1507 h = GNUNET_new (struct GNUNET_CADET_Handle); 1501 h = GNUNET_new (struct GNUNET_CADET_Handle);
1508 LOG (GNUNET_ERROR_TYPE_DEBUG, " addr %p\n", h); 1502 LOG (GNUNET_ERROR_TYPE_DEBUG, " addr %p\n", h);
1509 h->cfg = cfg; 1503 h->cfg = cfg;
1510 h->new_channel = new_channel;
1511 h->cleaner = cleaner; 1504 h->cleaner = cleaner;
1505 h->ports = GNUNET_CONTAINER_multihashmap_create (4, GNUNET_YES);
1512 h->client = GNUNET_CLIENT_connect ("cadet", cfg); 1506 h->client = GNUNET_CLIENT_connect ("cadet", cfg);
1513 if (h->client == NULL) 1507 if (h->client == NULL)
1514 { 1508 {
@@ -1518,31 +1512,14 @@ GNUNET_CADET_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, void *cls,
1518 } 1512 }
1519 h->cls = cls; 1513 h->cls = cls;
1520 h->message_handlers = handlers; 1514 h->message_handlers = handlers;
1521 h->ports = ports;
1522 h->next_chid = GNUNET_CADET_LOCAL_CHANNEL_ID_CLI; 1515 h->next_chid = GNUNET_CADET_LOCAL_CHANNEL_ID_CLI;
1523 h->reconnect_time = GNUNET_TIME_UNIT_MILLISECONDS; 1516 h->reconnect_time = GNUNET_TIME_UNIT_MILLISECONDS;
1524 h->reconnect_task = NULL; 1517 h->reconnect_task = NULL;
1525 1518
1526 if (NULL != ports && ports[0] != 0 && NULL == new_channel)
1527 {
1528 GNUNET_break (0);
1529 LOG (GNUNET_ERROR_TYPE_DEBUG,
1530 "no new channel handler given, ports parameter is useless!!\n");
1531 }
1532 if ((NULL == ports || ports[0] == 0) && NULL != new_channel)
1533 {
1534 GNUNET_break (0);
1535 LOG (GNUNET_ERROR_TYPE_DEBUG,
1536 "no ports given, new channel handler will never be called!!\n");
1537 }
1538 /* count handlers */ 1519 /* count handlers */
1539 for (h->n_handlers = 0; 1520 for (h->n_handlers = 0;
1540 handlers && handlers[h->n_handlers].type; 1521 handlers && handlers[h->n_handlers].type;
1541 h->n_handlers++) ; 1522 h->n_handlers++) ;
1542 for (h->n_ports = 0;
1543 ports && ports[h->n_ports];
1544 h->n_ports++) ;
1545 send_connect (h);
1546 LOG (GNUNET_ERROR_TYPE_DEBUG, "GNUNET_CADET_connect() END\n"); 1523 LOG (GNUNET_ERROR_TYPE_DEBUG, "GNUNET_CADET_connect() END\n");
1547 return h; 1524 return h;
1548} 1525}
@@ -1580,9 +1557,10 @@ GNUNET_CADET_disconnect (struct GNUNET_CADET_Handle *handle)
1580 msg = (struct GNUNET_MessageHeader *) &th[1]; 1557 msg = (struct GNUNET_MessageHeader *) &th[1];
1581 switch (ntohs(msg->type)) 1558 switch (ntohs(msg->type))
1582 { 1559 {
1583 case GNUNET_MESSAGE_TYPE_CADET_LOCAL_CONNECT:
1584 case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_CREATE: 1560 case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_CREATE:
1585 case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY: 1561 case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY:
1562 case GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_OPEN:
1563 case GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_CLOSE:
1586 case GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_CHANNELS: 1564 case GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_CHANNELS:
1587 case GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_CHANNEL: 1565 case GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_CHANNEL:
1588 case GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEER: 1566 case GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEER:
@@ -1615,11 +1593,76 @@ GNUNET_CADET_disconnect (struct GNUNET_CADET_Handle *handle)
1615 GNUNET_SCHEDULER_cancel(handle->reconnect_task); 1593 GNUNET_SCHEDULER_cancel(handle->reconnect_task);
1616 handle->reconnect_task = NULL; 1594 handle->reconnect_task = NULL;
1617 } 1595 }
1596
1597 GNUNET_CONTAINER_multihashmap_destroy (handle->ports);
1598 handle->ports = NULL;
1618 GNUNET_free (handle); 1599 GNUNET_free (handle);
1619} 1600}
1620 1601
1621 1602
1622/** 1603/**
1604 * Open a port to receive incomming channels.
1605 *
1606 * @param h CADET handle.
1607 * @param port Hash representing the port number.
1608 * @param new_channel Function called when an channel is received.
1609 * @param new_channel_cls Closure for @a new_channel.
1610 *
1611 * @return Port handle.
1612 */
1613struct GNUNET_CADET_Port *
1614GNUNET_CADET_open_port (struct GNUNET_CADET_Handle *h,
1615 const struct GNUNET_HashCode *port,
1616 GNUNET_CADET_InboundChannelNotificationHandler
1617 new_channel,
1618 void *new_channel_cls)
1619{
1620 struct GNUNET_CADET_Port *p;
1621 struct GNUNET_CADET_PortMessage msg;
1622
1623 GNUNET_assert (NULL != new_channel);
1624 p = GNUNET_new (struct GNUNET_CADET_Port);
1625 p->cadet = h;
1626 p->hash = GNUNET_new (struct GNUNET_HashCode);
1627 *p->hash = *port;
1628 p->handler = new_channel;
1629 p->cls = new_channel_cls;
1630 GNUNET_assert (GNUNET_OK ==
1631 GNUNET_CONTAINER_multihashmap_put (h->ports,
1632 p->hash,
1633 p,
1634 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
1635
1636 msg.header.size = htons (sizeof (msg));
1637 msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_OPEN);
1638 msg.port = *p->hash;
1639 send_packet (p->cadet, &msg.header, NULL);
1640
1641 return p;
1642}
1643
1644/**
1645 * Close a port opened with @a GNUNET_CADET_open_port.
1646 * The @a new_channel callback will no longer be called.
1647 *
1648 * @param p Port handle.
1649 */
1650void
1651GNUNET_CADET_close_port (struct GNUNET_CADET_Port *p)
1652{
1653 struct GNUNET_CADET_PortMessage msg;
1654
1655 msg.header.size = htons (sizeof (msg));
1656 msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_CLOSE);
1657 msg.port = *p->hash;
1658 send_packet (p->cadet, &msg.header, NULL);
1659 GNUNET_CONTAINER_multihashmap_remove (p->cadet->ports, p->hash, p);
1660 GNUNET_free (p->hash);
1661 GNUNET_free (p);
1662}
1663
1664
1665/**
1623 * Create a new channel towards a remote peer. 1666 * Create a new channel towards a remote peer.
1624 * 1667 *
1625 * If the destination port is not open by any peer or the destination peer 1668 * If the destination port is not open by any peer or the destination peer
@@ -1629,7 +1672,7 @@ GNUNET_CADET_disconnect (struct GNUNET_CADET_Handle *handle)
1629 * @param h cadet handle 1672 * @param h cadet handle
1630 * @param channel_ctx client's channel context to associate with the channel 1673 * @param channel_ctx client's channel context to associate with the channel
1631 * @param peer peer identity the channel should go to 1674 * @param peer peer identity the channel should go to
1632 * @param port Port number. 1675 * @param port Port hash (port number).
1633 * @param options CadetOption flag field, with all desired option bits set to 1. 1676 * @param options CadetOption flag field, with all desired option bits set to 1.
1634 * 1677 *
1635 * @return handle to the channel 1678 * @return handle to the channel
@@ -1638,11 +1681,11 @@ struct GNUNET_CADET_Channel *
1638GNUNET_CADET_channel_create (struct GNUNET_CADET_Handle *h, 1681GNUNET_CADET_channel_create (struct GNUNET_CADET_Handle *h,
1639 void *channel_ctx, 1682 void *channel_ctx,
1640 const struct GNUNET_PeerIdentity *peer, 1683 const struct GNUNET_PeerIdentity *peer,
1641 uint32_t port, 1684 const struct GNUNET_HashCode *port,
1642 enum GNUNET_CADET_ChannelOption options) 1685 enum GNUNET_CADET_ChannelOption options)
1643{ 1686{
1644 struct GNUNET_CADET_Channel *ch; 1687 struct GNUNET_CADET_Channel *ch;
1645 struct GNUNET_CADET_ChannelMessage msg; 1688 struct GNUNET_CADET_ChannelCreateMessage msg;
1646 1689
1647 LOG (GNUNET_ERROR_TYPE_DEBUG, 1690 LOG (GNUNET_ERROR_TYPE_DEBUG,
1648 "Creating new channel to %s:%u\n", 1691 "Creating new channel to %s:%u\n",
@@ -1652,14 +1695,16 @@ GNUNET_CADET_channel_create (struct GNUNET_CADET_Handle *h,
1652 LOG (GNUNET_ERROR_TYPE_DEBUG, " number %X\n", ch->chid); 1695 LOG (GNUNET_ERROR_TYPE_DEBUG, " number %X\n", ch->chid);
1653 ch->ctx = channel_ctx; 1696 ch->ctx = channel_ctx;
1654 ch->peer = GNUNET_PEER_intern (peer); 1697 ch->peer = GNUNET_PEER_intern (peer);
1698
1655 msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_CREATE); 1699 msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_CREATE);
1656 msg.header.size = htons (sizeof (struct GNUNET_CADET_ChannelMessage)); 1700 msg.header.size = htons (sizeof (struct GNUNET_CADET_ChannelCreateMessage));
1657 msg.channel_id = htonl (ch->chid); 1701 msg.channel_id = htonl (ch->chid);
1658 msg.port = htonl (port); 1702 msg.port = *port;
1659 msg.peer = *peer; 1703 msg.peer = *peer;
1660 msg.opt = htonl (options); 1704 msg.opt = htonl (options);
1661 ch->allow_send = GNUNET_NO; 1705 ch->allow_send = GNUNET_NO;
1662 send_packet (h, &msg.header, ch); 1706 send_packet (h, &msg.header, ch);
1707
1663 return ch; 1708 return ch;
1664} 1709}
1665 1710
@@ -1668,18 +1713,15 @@ void
1668GNUNET_CADET_channel_destroy (struct GNUNET_CADET_Channel *channel) 1713GNUNET_CADET_channel_destroy (struct GNUNET_CADET_Channel *channel)
1669{ 1714{
1670 struct GNUNET_CADET_Handle *h; 1715 struct GNUNET_CADET_Handle *h;
1671 struct GNUNET_CADET_ChannelMessage msg; 1716 struct GNUNET_CADET_ChannelDestroyMessage msg;
1672 struct GNUNET_CADET_TransmitHandle *th; 1717 struct GNUNET_CADET_TransmitHandle *th;
1673 1718
1674 LOG (GNUNET_ERROR_TYPE_DEBUG, "Destroying channel\n"); 1719 LOG (GNUNET_ERROR_TYPE_DEBUG, "Destroying channel\n");
1675 h = channel->cadet; 1720 h = channel->cadet;
1676 1721
1677 msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY); 1722 msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY);
1678 msg.header.size = htons (sizeof (struct GNUNET_CADET_ChannelMessage)); 1723 msg.header.size = htons (sizeof (struct GNUNET_CADET_ChannelDestroyMessage));
1679 msg.channel_id = htonl (channel->chid); 1724 msg.channel_id = htonl (channel->chid);
1680 memset (&msg.peer, 0, sizeof (struct GNUNET_PeerIdentity));
1681 msg.port = 0;
1682 msg.opt = 0;
1683 th = h->th_head; 1725 th = h->th_head;
1684 while (th != NULL) 1726 while (th != NULL)
1685 { 1727 {
@@ -2179,3 +2221,26 @@ GNUNET_CADET_mq_create (struct GNUNET_CADET_Channel *channel)
2179 NULL); /* no handler cls */ 2221 NULL); /* no handler cls */
2180 return mq; 2222 return mq;
2181} 2223}
2224
2225
2226/**
2227 * Transitional function to convert an unsigned int port to a hash value.
2228 * WARNING: local static value returned, NOT reentrant!
2229 * WARNING: do not use this function for new code!
2230 *
2231 * @param port Numerical port (unsigned int format).
2232 *
2233 * @return A GNUNET_HashCode usable for the new CADET API.
2234 */
2235const struct GNUNET_HashCode *
2236GC_u2h (uint32_t port)
2237{
2238 static struct GNUNET_HashCode hash;
2239
2240 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
2241 "This is a transitional function, "
2242 "use proper crypto hashes as CADET ports\n");
2243 GNUNET_CRYPTO_hash (&port, sizeof (port), &hash);
2244
2245 return &hash;
2246}
diff --git a/src/cadet/cadet_common.c b/src/cadet/cadet_common.c
index 2376722fa..2fbd97283 100644
--- a/src/cadet/cadet_common.c
+++ b/src/cadet/cadet_common.c
@@ -247,11 +247,18 @@ GC_m2s (uint16_t m)
247 s = "KEEPALIVE"; 247 s = "KEEPALIVE";
248 break; 248 break;
249 249
250 /** 250 /**
251 * Connect to the cadet service, specifying subscriptions 251 * Open port
252 */
253 case GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_OPEN:
254 s = "OPEN_PORT";
255 break;
256
257 /**
258 * Close port
252 */ 259 */
253 case GNUNET_MESSAGE_TYPE_CADET_LOCAL_CONNECT: 260 case GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_CLOSE:
254 s = "LOC_CONNCT"; 261 s = "CLOSE_PORT";
255 break; 262 break;
256 263
257 /** 264 /**
diff --git a/src/cadet/cadet_protocol.h b/src/cadet/cadet_protocol.h
index dbb4f604f..1a42e920f 100644
--- a/src/cadet/cadet_protocol.h
+++ b/src/cadet/cadet_protocol.h
@@ -362,7 +362,7 @@ struct GNUNET_CADET_ChannelCreate
362 /** 362 /**
363 * Destination port. 363 * Destination port.
364 */ 364 */
365 uint32_t port GNUNET_PACKED; 365 struct GNUNET_HashCode port;
366 366
367 /** 367 /**
368 * Channel options. 368 * Channel options.
diff --git a/src/cadet/cadet_test_lib.c b/src/cadet/cadet_test_lib.c
index ce348018f..cd9e47b0b 100644
--- a/src/cadet/cadet_test_lib.c
+++ b/src/cadet/cadet_test_lib.c
@@ -122,10 +122,8 @@ cadet_connect_adapter (void *cls,
122 122
123 h = GNUNET_CADET_connect (cfg, 123 h = GNUNET_CADET_connect (cfg,
124 (void *) (long) actx->peer, 124 (void *) (long) actx->peer,
125 ctx->new_channel,
126 ctx->cleaner, 125 ctx->cleaner,
127 ctx->handlers, 126 ctx->handlers);
128 ctx->ports);
129 return h; 127 return h;
130} 128}
131 129
diff --git a/src/cadet/gnunet-cadet.c b/src/cadet/gnunet-cadet.c
index cf415448f..4801dbbdf 100644
--- a/src/cadet/gnunet-cadet.c
+++ b/src/cadet/gnunet-cadet.c
@@ -390,20 +390,21 @@ channel_ended (void *cls,
390 */ 390 */
391static void * 391static void *
392channel_incoming (void *cls, 392channel_incoming (void *cls,
393 struct GNUNET_CADET_Channel * channel, 393 struct GNUNET_CADET_Channel *channel,
394 const struct GNUNET_PeerIdentity * initiator, 394 const struct GNUNET_PeerIdentity *initiator,
395 uint32_t port, enum GNUNET_CADET_ChannelOption options) 395 const struct GNUNET_HashCode *port,
396 enum GNUNET_CADET_ChannelOption options)
396{ 397{
397 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 398 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
398 "Incoming channel %p on port %u\n", 399 "Incoming channel %p on port %s\n",
399 channel, port); 400 channel, GNUNET_h2s (port));
400 if (NULL != ch) 401 if (NULL != ch)
401 { 402 {
402 GNUNET_break (0); 403 GNUNET_break (0);
403 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 404 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
404 "A channel already exists (%p)\n", ch); 405 "A channel already exists (%p)\n", ch);
405 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 406 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
406 "Incoming channel %p on port %u\n", channel, port); 407 "Incoming channel %p on port %s\n", channel, GNUNET_h2s (port));
407 return NULL; 408 return NULL;
408 } 409 }
409 if (0 == listen_port) 410 if (0 == listen_port)
@@ -480,7 +481,7 @@ create_channel (void *cls)
480 } 481 }
481 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting to `%s'\n", target_id); 482 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting to `%s'\n", target_id);
482 opt = GNUNET_CADET_OPTION_DEFAULT | GNUNET_CADET_OPTION_RELIABLE; 483 opt = GNUNET_CADET_OPTION_DEFAULT | GNUNET_CADET_OPTION_RELIABLE;
483 ch = GNUNET_CADET_channel_create (mh, NULL, &pid, target_port, opt); 484 ch = GNUNET_CADET_channel_create (mh, NULL, &pid, GC_u2h (target_port), opt);
484 if (GNUNET_NO == echo) 485 if (GNUNET_NO == echo)
485 listen_stdio (); 486 listen_stdio ();
486 else 487 else
@@ -835,13 +836,11 @@ run (void *cls,
835 const char *cfgfile, 836 const char *cfgfile,
836 const struct GNUNET_CONFIGURATION_Handle *cfg) 837 const struct GNUNET_CONFIGURATION_Handle *cfg)
837{ 838{
838 GNUNET_CADET_InboundChannelNotificationHandler *newch = NULL;
839 GNUNET_CADET_ChannelEndHandler *endch = NULL;
840 static const struct GNUNET_CADET_MessageHandler handlers[] = { 839 static const struct GNUNET_CADET_MessageHandler handlers[] = {
841 {&data_callback, GNUNET_MESSAGE_TYPE_CADET_CLI, 0}, 840 {&data_callback, GNUNET_MESSAGE_TYPE_CADET_CLI, 0},
842 {NULL, 0, 0} /* FIXME add option to monitor msg types */ 841 {NULL, 0, 0} /* FIXME add option to monitor msg types */
843 }; 842 };
844 static uint32_t *ports = NULL; 843
845 /* FIXME add option to monitor apps */ 844 /* FIXME add option to monitor apps */
846 845
847 target_id = args[0]; 846 target_id = args[0];
@@ -871,15 +870,6 @@ run (void *cls,
871 "Creating channel to %s\n", 870 "Creating channel to %s\n",
872 target_id); 871 target_id);
873 GNUNET_SCHEDULER_add_now (&create_channel, NULL); 872 GNUNET_SCHEDULER_add_now (&create_channel, NULL);
874 endch = &channel_ended;
875 }
876 else if (0 != listen_port)
877 {
878 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Listen\n");
879 newch = &channel_incoming;
880 endch = &channel_ended;
881 ports = GNUNET_malloc (sizeof (uint32_t) * 2);
882 ports[0] = listen_port;
883 } 873 }
884 else if (NULL != peer_id) 874 else if (NULL != peer_id)
885 { 875 {
@@ -920,15 +910,19 @@ run (void *cls,
920 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting to cadet\n"); 910 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting to cadet\n");
921 mh = GNUNET_CADET_connect (cfg, 911 mh = GNUNET_CADET_connect (cfg,
922 NULL, /* cls */ 912 NULL, /* cls */
923 newch, /* new channel */ 913 &channel_ended, /* cleaner */
924 endch, /* cleaner */ 914 handlers);
925 handlers,
926 ports);
927 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Done\n");
928 if (NULL == mh) 915 if (NULL == mh)
929 GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); 916 GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
930 else 917 else
931 sd = GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); 918 sd = GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL);
919
920 if (0 != listen_port)
921 {
922 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Opening listen port\n");
923 GNUNET_CADET_open_port (mh, GC_u2h (listen_port),
924 &channel_incoming, NULL);
925 }
932} 926}
933 927
934 928
diff --git a/src/cadet/gnunet-service-cadet_channel.c b/src/cadet/gnunet-service-cadet_channel.c
index 3d204e5b3..d01356c3a 100644
--- a/src/cadet/gnunet-service-cadet_channel.c
+++ b/src/cadet/gnunet-service-cadet_channel.c
@@ -211,7 +211,7 @@ struct CadetChannel
211 /** 211 /**
212 * Destination port of the channel. 212 * Destination port of the channel.
213 */ 213 */
214 uint32_t port; 214 struct GNUNET_HashCode port;
215 215
216 /** 216 /**
217 * Global channel number ( < GNUNET_CADET_LOCAL_CHANNEL_ID_CLI) 217 * Global channel number ( < GNUNET_CADET_LOCAL_CHANNEL_ID_CLI)
@@ -552,7 +552,7 @@ send_client_create (struct CadetChannel *ch)
552 opt = 0; 552 opt = 0;
553 opt |= GNUNET_YES == ch->reliable ? GNUNET_CADET_OPTION_RELIABLE : 0; 553 opt |= GNUNET_YES == ch->reliable ? GNUNET_CADET_OPTION_RELIABLE : 0;
554 opt |= GNUNET_YES == ch->nobuffer ? GNUNET_CADET_OPTION_NOBUFFER : 0; 554 opt |= GNUNET_YES == ch->nobuffer ? GNUNET_CADET_OPTION_NOBUFFER : 0;
555 GML_send_channel_create (ch->dest, ch->lid_dest, ch->port, opt, 555 GML_send_channel_create (ch->dest, ch->lid_dest, &ch->port, opt,
556 GCT_get_destination (ch->t)); 556 GCT_get_destination (ch->t));
557 557
558} 558}
@@ -884,7 +884,7 @@ send_create (struct CadetChannel *ch)
884 msgcc.header.size = htons (sizeof (msgcc)); 884 msgcc.header.size = htons (sizeof (msgcc));
885 msgcc.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_CREATE); 885 msgcc.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_CREATE);
886 msgcc.chid = htonl (ch->gid); 886 msgcc.chid = htonl (ch->gid);
887 msgcc.port = htonl (ch->port); 887 msgcc.port = ch->port;
888 msgcc.opt = htonl (channel_get_options (ch)); 888 msgcc.opt = htonl (channel_get_options (ch));
889 889
890 GCCH_send_prebuilt_message (&msgcc.header, ch, GNUNET_YES, NULL); 890 GCCH_send_prebuilt_message (&msgcc.header, ch, GNUNET_YES, NULL);
@@ -1840,7 +1840,7 @@ GCCH_handle_local_destroy (struct CadetChannel *ch,
1840 */ 1840 */
1841int 1841int
1842GCCH_handle_local_create (struct CadetClient *c, 1842GCCH_handle_local_create (struct CadetClient *c,
1843 struct GNUNET_CADET_ChannelMessage *msg) 1843 struct GNUNET_CADET_ChannelCreateMessage *msg)
1844{ 1844{
1845 struct CadetChannel *ch; 1845 struct CadetChannel *ch;
1846 struct CadetTunnel *t; 1846 struct CadetTunnel *t;
@@ -1848,7 +1848,7 @@ GCCH_handle_local_create (struct CadetClient *c,
1848 CADET_ChannelNumber chid; 1848 CADET_ChannelNumber chid;
1849 1849
1850 LOG (GNUNET_ERROR_TYPE_DEBUG, " towards %s:%u\n", 1850 LOG (GNUNET_ERROR_TYPE_DEBUG, " towards %s:%u\n",
1851 GNUNET_i2s (&msg->peer), ntohl (msg->port)); 1851 GNUNET_i2s (&msg->peer), GNUNET_h2s (&msg->port));
1852 chid = ntohl (msg->channel_id); 1852 chid = ntohl (msg->channel_id);
1853 1853
1854 /* Sanity check for duplicate channel IDs */ 1854 /* Sanity check for duplicate channel IDs */
@@ -1879,7 +1879,7 @@ GCCH_handle_local_create (struct CadetClient *c,
1879 GNUNET_break (0); 1879 GNUNET_break (0);
1880 return GNUNET_SYSERR; 1880 return GNUNET_SYSERR;
1881 } 1881 }
1882 ch->port = ntohl (msg->port); 1882 ch->port = msg->port;
1883 channel_set_options (ch, ntohl (msg->opt)); 1883 channel_set_options (ch, ntohl (msg->opt));
1884 1884
1885 /* In unreliable channels, we'll use the DLL to buffer BCK data */ 1885 /* In unreliable channels, we'll use the DLL to buffer BCK data */
@@ -2149,7 +2149,7 @@ GCCH_handle_create (struct CadetTunnel *t,
2149 struct CadetChannel *ch; 2149 struct CadetChannel *ch;
2150 struct CadetClient *c; 2150 struct CadetClient *c;
2151 int new_channel; 2151 int new_channel;
2152 uint32_t port; 2152 struct GNUNET_HashCode *port;
2153 2153
2154 chid = ntohl (msg->chid); 2154 chid = ntohl (msg->chid);
2155 2155
@@ -2166,7 +2166,7 @@ GCCH_handle_create (struct CadetTunnel *t,
2166 { 2166 {
2167 new_channel = GNUNET_NO; 2167 new_channel = GNUNET_NO;
2168 } 2168 }
2169 port = ntohl (msg->port); 2169 port = &msg->port;
2170 2170
2171 LOG (GNUNET_ERROR_TYPE_INFO, 2171 LOG (GNUNET_ERROR_TYPE_INFO,
2172 "<== %s ( 0x%08X %4u) on chan %s (%p) %s [%5u]\n", 2172 "<== %s ( 0x%08X %4u) on chan %s (%p) %s [%5u]\n",
@@ -2176,9 +2176,9 @@ GCCH_handle_create (struct CadetTunnel *t,
2176 if (GNUNET_YES == new_channel || GCT_is_loopback (t)) 2176 if (GNUNET_YES == new_channel || GCT_is_loopback (t))
2177 { 2177 {
2178 /* Find a destination client */ 2178 /* Find a destination client */
2179 ch->port = port; 2179 ch->port = *port;
2180 LOG (GNUNET_ERROR_TYPE_DEBUG, " port %u\n", ch->port); 2180 LOG (GNUNET_ERROR_TYPE_DEBUG, " port %s\n", GNUNET_h2s (port));
2181 c = GML_client_get_by_port (ch->port); 2181 c = GML_client_get_by_port (port);
2182 if (NULL == c) 2182 if (NULL == c)
2183 { 2183 {
2184 LOG (GNUNET_ERROR_TYPE_DEBUG, " no client has port registered\n"); 2184 LOG (GNUNET_ERROR_TYPE_DEBUG, " no client has port registered\n");
@@ -2371,6 +2371,7 @@ GCCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
2371 type = ntohs (message->type); 2371 type = ntohs (message->type);
2372 size = ntohs (message->size); 2372 size = ntohs (message->size);
2373 2373
2374 data_id = 0;
2374 switch (type) 2375 switch (type)
2375 { 2376 {
2376 case GNUNET_MESSAGE_TYPE_CADET_DATA: 2377 case GNUNET_MESSAGE_TYPE_CADET_DATA:
@@ -2399,7 +2400,6 @@ GCCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
2399 { 2400 {
2400 struct GNUNET_CADET_ChannelCreate *cc_msg; 2401 struct GNUNET_CADET_ChannelCreate *cc_msg;
2401 cc_msg = (struct GNUNET_CADET_ChannelCreate *) message; 2402 cc_msg = (struct GNUNET_CADET_ChannelCreate *) message;
2402 data_id = ntohl (cc_msg->port);
2403 SPRINTF (info, " 0x%08X", ntohl (cc_msg->chid)); 2403 SPRINTF (info, " 0x%08X", ntohl (cc_msg->chid));
2404 break; 2404 break;
2405 } 2405 }
@@ -2409,12 +2409,10 @@ GCCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
2409 { 2409 {
2410 struct GNUNET_CADET_ChannelManage *m_msg; 2410 struct GNUNET_CADET_ChannelManage *m_msg;
2411 m_msg = (struct GNUNET_CADET_ChannelManage *) message; 2411 m_msg = (struct GNUNET_CADET_ChannelManage *) message;
2412 data_id = 0;
2413 SPRINTF (info, " 0x%08X", ntohl (m_msg->chid)); 2412 SPRINTF (info, " 0x%08X", ntohl (m_msg->chid));
2414 break; 2413 break;
2415 } 2414 }
2416 default: 2415 default:
2417 data_id = 0;
2418 info[0] = '\0'; 2416 info[0] = '\0';
2419 } 2417 }
2420 LOG (GNUNET_ERROR_TYPE_INFO, 2418 LOG (GNUNET_ERROR_TYPE_INFO,
@@ -2540,8 +2538,9 @@ GCCH_2s (const struct CadetChannel *ch)
2540 if (NULL == ch) 2538 if (NULL == ch)
2541 return "(NULL Channel)"; 2539 return "(NULL Channel)";
2542 2540
2543 SPRINTF (buf, "%s:%u gid:%X (%X / %X)", 2541 SPRINTF (buf, "%s:%s gid:%X (%X / %X)",
2544 GCT_2s (ch->t), ch->port, ch->gid, ch->lid_root, ch->lid_dest); 2542 GCT_2s (ch->t), GNUNET_h2s (&ch->port),
2543 ch->gid, ch->lid_root, ch->lid_dest);
2545 2544
2546 return buf; 2545 return buf;
2547} 2546}
diff --git a/src/cadet/gnunet-service-cadet_channel.h b/src/cadet/gnunet-service-cadet_channel.h
index 0508a10f1..cc1eb4d8a 100644
--- a/src/cadet/gnunet-service-cadet_channel.h
+++ b/src/cadet/gnunet-service-cadet_channel.h
@@ -223,7 +223,7 @@ GCCH_handle_local_destroy (struct CadetChannel *ch,
223 */ 223 */
224int 224int
225GCCH_handle_local_create (struct CadetClient *c, 225GCCH_handle_local_create (struct CadetClient *c,
226 struct GNUNET_CADET_ChannelMessage *msg); 226 struct GNUNET_CADET_ChannelCreateMessage *msg);
227 227
228/** 228/**
229 * Handler for cadet network payload traffic. 229 * Handler for cadet network payload traffic.
diff --git a/src/cadet/gnunet-service-cadet_local.c b/src/cadet/gnunet-service-cadet_local.c
index ce1f45a10..5e73887e6 100644
--- a/src/cadet/gnunet-service-cadet_local.c
+++ b/src/cadet/gnunet-service-cadet_local.c
@@ -81,7 +81,7 @@ struct CadetClient
81 * Ports that this client has declared interest in. 81 * Ports that this client has declared interest in.
82 * Indexed by port, contains *Client. 82 * Indexed by port, contains *Client.
83 */ 83 */
84 struct GNUNET_CONTAINER_MultiHashMap32 *ports; 84 struct GNUNET_CONTAINER_MultiHashMap *ports;
85 85
86 /** 86 /**
87 * Whether the client is active or shutting down (don't send confirmations 87 * Whether the client is active or shutting down (don't send confirmations
@@ -127,7 +127,7 @@ unsigned int next_client_id;
127/** 127/**
128 * All ports clients of this peer have opened. 128 * All ports clients of this peer have opened.
129 */ 129 */
130static struct GNUNET_CONTAINER_MultiHashMap32 *ports; 130static struct GNUNET_CONTAINER_MultiHashMap *ports;
131 131
132/** 132/**
133 * Notification context, to send messages to local clients. 133 * Notification context, to send messages to local clients.
@@ -150,18 +150,18 @@ static struct GNUNET_SERVER_NotificationContext *nc;
150 */ 150 */
151static int 151static int
152client_release_ports (void *cls, 152client_release_ports (void *cls,
153 uint32_t key, 153 const struct GNUNET_HashCode *key,
154 void *value) 154 void *value)
155{ 155{
156 int res; 156 int res;
157 157
158 res = GNUNET_CONTAINER_multihashmap32_remove (ports, key, value); 158 res = GNUNET_CONTAINER_multihashmap_remove (ports, key, value);
159 if (GNUNET_YES != res) 159 if (GNUNET_YES != res)
160 { 160 {
161 GNUNET_break (0); 161 GNUNET_break (0);
162 LOG (GNUNET_ERROR_TYPE_WARNING, 162 LOG (GNUNET_ERROR_TYPE_WARNING,
163 "Port %u by client %p was not registered.\n", 163 "Port %s by client %p was not registered.\n",
164 key, value); 164 GNUNET_h2s (key), value);
165 } 165 }
166 return GNUNET_OK; 166 return GNUNET_OK;
167} 167}
@@ -219,9 +219,9 @@ client_destroy (struct CadetClient *c)
219 } 219 }
220 if (NULL != c->ports) 220 if (NULL != c->ports)
221 { 221 {
222 GNUNET_CONTAINER_multihashmap32_iterate (c->ports, 222 GNUNET_CONTAINER_multihashmap_iterate (c->ports,
223 &client_release_ports, c); 223 &client_release_ports, c);
224 GNUNET_CONTAINER_multihashmap32_destroy (c->ports); 224 GNUNET_CONTAINER_multihashmap_destroy (c->ports);
225 } 225 }
226 226
227 GNUNET_CONTAINER_DLL_remove (clients_head, clients_tail, c); 227 GNUNET_CONTAINER_DLL_remove (clients_head, clients_tail, c);
@@ -312,81 +312,78 @@ handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client)
312 312
313 313
314/** 314/**
315 * Handler for new clients 315 * Handler for port open requests.
316 * 316 *
317 * @param cls closure 317 * @param cls Closure.
318 * @param client identification of the client 318 * @param client Identification of the client.
319 * @param message the actual message, which includes messages the client wants 319 * @param message The actual message.
320 */ 320 */
321static void 321static void
322handle_new_client (void *cls, struct GNUNET_SERVER_Client *client, 322handle_port_open (void *cls, struct GNUNET_SERVER_Client *client,
323 const struct GNUNET_MessageHeader *message) 323 const struct GNUNET_MessageHeader *message)
324{ 324{
325 struct GNUNET_CADET_ClientConnect *cc_msg;
326 struct CadetClient *c; 325 struct CadetClient *c;
327 unsigned int size; 326 struct GNUNET_CADET_PortMessage *pmsg;
328 uint32_t *p;
329 unsigned int i;
330 327
331 LOG (GNUNET_ERROR_TYPE_DEBUG, "new client registering %p\n", client); 328 LOG (GNUNET_ERROR_TYPE_DEBUG, "open port requested\n");
332 329
333 /* Check data sanity */ 330 /* Sanity check for client registration */
334 size = ntohs (message->size); 331 if (NULL == (c = GML_client_get (client)))
335 if (size < sizeof (struct GNUNET_CADET_ClientConnect))
336 { 332 {
337 GNUNET_break (0); 333 GNUNET_break (0);
338 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 334 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
339 return; 335 return;
340 } 336 }
341 size -= sizeof (struct GNUNET_CADET_ClientConnect); /* Array size */ 337 LOG (GNUNET_ERROR_TYPE_DEBUG, " by client %u\n", c->id);
342 if (0 != (size % sizeof (uint32_t))) 338
339 /* Message size sanity check */
340 if (sizeof (struct GNUNET_CADET_PortMessage) != ntohs (message->size))
343 { 341 {
344 GNUNET_break (0); 342 GNUNET_break (0);
345 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 343 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
346 return; 344 return;
347 } 345 }
348 size /= sizeof (uint32_t); /* Number of ports */
349 cc_msg = (struct GNUNET_CADET_ClientConnect *) message;
350 346
351 /* Retrieve client structure */ 347 pmsg = (struct GNUNET_CADET_PortMessage *) message;
352 c = GNUNET_SERVER_client_get_user_context (client, struct CadetClient); 348 if (NULL == c->ports)
353 if (NULL == c) 349 {
350 c->ports = GNUNET_CONTAINER_multihashmap_create (4, GNUNET_NO);
351 }
352 /* store in client's hashmap */
353 if (GNUNET_OK !=
354 GNUNET_CONTAINER_multihashmap_put (c->ports, &pmsg->port, c,
355 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY))
354 { 356 {
355 GNUNET_break (0); 357 GNUNET_break (0);
356 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 358 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
357 return; 359 return;
358 } 360 }
359 361 /* store in global hashmap */
360 LOG (GNUNET_ERROR_TYPE_DEBUG, " client %u has %u ports\n", c-> id, size); 362 /* FIXME only allow one client to have the port open,
361 if (size > 0) 363 * have a backup hashmap with waiting clients */
362 { 364 GNUNET_CONTAINER_multihashmap_put (ports, &pmsg->port, c,
363 uint32_t u32; 365 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
364
365 p = (uint32_t *) &cc_msg[1];
366 c->ports = GNUNET_CONTAINER_multihashmap32_create (size);
367 for (i = 0; i < size; i++)
368 {
369 u32 = ntohl (p[i]);
370 LOG (GNUNET_ERROR_TYPE_DEBUG, " port: %u\n", u32);
371
372 /* store in client's hashmap */
373 GNUNET_CONTAINER_multihashmap32_put (c->ports, u32, c,
374 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
375 /* store in global hashmap */
376 /* FIXME only allow one client to have the port open,
377 * have a backup hashmap with waiting clients */
378 GNUNET_CONTAINER_multihashmap32_put (ports, u32, c,
379 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
380 }
381 }
382 366
383 GNUNET_SERVER_receive_done (client, GNUNET_OK); 367 GNUNET_SERVER_receive_done (client, GNUNET_OK);
384 LOG (GNUNET_ERROR_TYPE_DEBUG, "new regitering processed\n");
385} 368}
386 369
387 370
388/** 371/**
389 * Handler for requests of new tunnels 372 * Handler for port close requests.
373 *
374 * @param cls Closure.
375 * @param client Identification of the client.
376 * @param message The actual message.
377 */
378static void
379handle_port_close (void *cls, struct GNUNET_SERVER_Client *client,
380 const struct GNUNET_MessageHeader *message)
381{
382}
383
384
385/**
386 * Handler for requests of new channels.
390 * 387 *
391 * @param cls Closure. 388 * @param cls Closure.
392 * @param client Identification of the client. 389 * @param client Identification of the client.
@@ -411,7 +408,8 @@ handle_channel_create (void *cls, struct GNUNET_SERVER_Client *client,
411 LOG (GNUNET_ERROR_TYPE_DEBUG, " by client %u\n", c->id); 408 LOG (GNUNET_ERROR_TYPE_DEBUG, " by client %u\n", c->id);
412 409
413 /* Message size sanity check */ 410 /* Message size sanity check */
414 if (sizeof (struct GNUNET_CADET_ChannelMessage) != ntohs (message->size)) 411 if (sizeof (struct GNUNET_CADET_ChannelCreateMessage)
412 != ntohs (message->size))
415 { 413 {
416 GNUNET_break (0); 414 GNUNET_break (0);
417 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 415 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
@@ -420,14 +418,14 @@ handle_channel_create (void *cls, struct GNUNET_SERVER_Client *client,
420 418
421 if (GNUNET_OK != 419 if (GNUNET_OK !=
422 GCCH_handle_local_create (c, 420 GCCH_handle_local_create (c,
423 (struct GNUNET_CADET_ChannelMessage *) message)) 421 (struct GNUNET_CADET_ChannelCreateMessage *)
422 message))
424 { 423 {
425 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 424 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
426 return; 425 return;
427 } 426 }
428 427
429 GNUNET_SERVER_receive_done (client, GNUNET_OK); 428 GNUNET_SERVER_receive_done (client, GNUNET_OK);
430 return;
431} 429}
432 430
433 431
@@ -442,7 +440,7 @@ static void
442handle_channel_destroy (void *cls, struct GNUNET_SERVER_Client *client, 440handle_channel_destroy (void *cls, struct GNUNET_SERVER_Client *client,
443 const struct GNUNET_MessageHeader *message) 441 const struct GNUNET_MessageHeader *message)
444{ 442{
445 struct GNUNET_CADET_ChannelMessage *msg; 443 struct GNUNET_CADET_ChannelDestroyMessage *msg;
446 struct CadetClient *c; 444 struct CadetClient *c;
447 struct CadetChannel *ch; 445 struct CadetChannel *ch;
448 CADET_ChannelNumber chid; 446 CADET_ChannelNumber chid;
@@ -459,14 +457,15 @@ handle_channel_destroy (void *cls, struct GNUNET_SERVER_Client *client,
459 LOG (GNUNET_ERROR_TYPE_DEBUG, " by client %u\n", c->id); 457 LOG (GNUNET_ERROR_TYPE_DEBUG, " by client %u\n", c->id);
460 458
461 /* Message sanity check */ 459 /* Message sanity check */
462 if (sizeof (struct GNUNET_CADET_ChannelMessage) != ntohs (message->size)) 460 if (sizeof (struct GNUNET_CADET_ChannelDestroyMessage)
461 != ntohs (message->size))
463 { 462 {
464 GNUNET_break (0); 463 GNUNET_break (0);
465 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 464 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
466 return; 465 return;
467 } 466 }
468 467
469 msg = (struct GNUNET_CADET_ChannelMessage *) message; 468 msg = (struct GNUNET_CADET_ChannelDestroyMessage *) message;
470 469
471 /* Retrieve tunnel */ 470 /* Retrieve tunnel */
472 chid = ntohl (msg->channel_id); 471 chid = ntohl (msg->channel_id);
@@ -1069,7 +1068,7 @@ handle_info_dump (void *cls, struct GNUNET_SERVER_Client *client,
1069 c->id, c, c->handle); 1068 c->id, c, c->handle);
1070 if (NULL != c->ports) 1069 if (NULL != c->ports)
1071 LOG (GNUNET_ERROR_TYPE_ERROR, "\t%3u ports registered\n", 1070 LOG (GNUNET_ERROR_TYPE_ERROR, "\t%3u ports registered\n",
1072 GNUNET_CONTAINER_multihashmap32_size (c->ports)); 1071 GNUNET_CONTAINER_multihashmap_size (c->ports));
1073 else 1072 else
1074 LOG (GNUNET_ERROR_TYPE_ERROR, "\t no ports registered\n"); 1073 LOG (GNUNET_ERROR_TYPE_ERROR, "\t no ports registered\n");
1075 LOG (GNUNET_ERROR_TYPE_ERROR, "\t%3u own channles\n", 1074 LOG (GNUNET_ERROR_TYPE_ERROR, "\t%3u own channles\n",
@@ -1091,11 +1090,14 @@ handle_info_dump (void *cls, struct GNUNET_SERVER_Client *client,
1091 * Functions to handle messages from clients 1090 * Functions to handle messages from clients
1092 */ 1091 */
1093static struct GNUNET_SERVER_MessageHandler client_handlers[] = { 1092static struct GNUNET_SERVER_MessageHandler client_handlers[] = {
1094 {&handle_new_client, NULL, GNUNET_MESSAGE_TYPE_CADET_LOCAL_CONNECT, 0}, 1093 {&handle_port_open, NULL, GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_OPEN,
1094 sizeof (struct GNUNET_CADET_PortMessage)},
1095 {&handle_port_close, NULL, GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_CLOSE,
1096 sizeof (struct GNUNET_CADET_PortMessage)},
1095 {&handle_channel_create, NULL, GNUNET_MESSAGE_TYPE_CADET_CHANNEL_CREATE, 1097 {&handle_channel_create, NULL, GNUNET_MESSAGE_TYPE_CADET_CHANNEL_CREATE,
1096 sizeof (struct GNUNET_CADET_ChannelMessage)}, 1098 sizeof (struct GNUNET_CADET_ChannelCreateMessage)},
1097 {&handle_channel_destroy, NULL, GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY, 1099 {&handle_channel_destroy, NULL, GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY,
1098 sizeof (struct GNUNET_CADET_ChannelMessage)}, 1100 sizeof (struct GNUNET_CADET_ChannelDestroyMessage)},
1099 {&handle_data, NULL, GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA, 0}, 1101 {&handle_data, NULL, GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA, 0},
1100 {&handle_ack, NULL, GNUNET_MESSAGE_TYPE_CADET_LOCAL_ACK, 1102 {&handle_ack, NULL, GNUNET_MESSAGE_TYPE_CADET_LOCAL_ACK,
1101 sizeof (struct GNUNET_CADET_LocalAck)}, 1103 sizeof (struct GNUNET_CADET_LocalAck)},
@@ -1129,7 +1131,7 @@ GML_init (struct GNUNET_SERVER_Handle *handle)
1129 LOG (GNUNET_ERROR_TYPE_DEBUG, "init\n"); 1131 LOG (GNUNET_ERROR_TYPE_DEBUG, "init\n");
1130 server_handle = handle; 1132 server_handle = handle;
1131 GNUNET_SERVER_suspend (server_handle); 1133 GNUNET_SERVER_suspend (server_handle);
1132 ports = GNUNET_CONTAINER_multihashmap32_create (32); 1134 ports = GNUNET_CONTAINER_multihashmap_create (16, GNUNET_NO);
1133} 1135}
1134 1136
1135 1137
@@ -1310,9 +1312,9 @@ GML_client_get (struct GNUNET_SERVER_Client *client)
1310 * @return non-NULL if a client has the port. 1312 * @return non-NULL if a client has the port.
1311 */ 1313 */
1312struct CadetClient * 1314struct CadetClient *
1313GML_client_get_by_port (uint32_t port) 1315GML_client_get_by_port (struct GNUNET_HashCode *port)
1314{ 1316{
1315 return GNUNET_CONTAINER_multihashmap32_get (ports, port); 1317 return GNUNET_CONTAINER_multihashmap_get (ports, port);
1316} 1318}
1317 1319
1318 1320
@@ -1390,15 +1392,15 @@ GML_send_ack (struct CadetClient *c, CADET_ChannelNumber id)
1390 */ 1392 */
1391void 1393void
1392GML_send_channel_create (struct CadetClient *c, 1394GML_send_channel_create (struct CadetClient *c,
1393 uint32_t id, uint32_t port, uint32_t opt, 1395 uint32_t id, struct GNUNET_HashCode *port,
1394 const struct GNUNET_PeerIdentity *peer) 1396 uint32_t opt, const struct GNUNET_PeerIdentity *peer)
1395{ 1397{
1396 struct GNUNET_CADET_ChannelMessage msg; 1398 struct GNUNET_CADET_ChannelCreateMessage msg;
1397 1399
1398 msg.header.size = htons (sizeof (msg)); 1400 msg.header.size = htons (sizeof (msg));
1399 msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_CREATE); 1401 msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_CREATE);
1400 msg.channel_id = htonl (id); 1402 msg.channel_id = htonl (id);
1401 msg.port = htonl (port); 1403 msg.port = *port;
1402 msg.opt = htonl (opt); 1404 msg.opt = htonl (opt);
1403 msg.peer = *peer; 1405 msg.peer = *peer;
1404 GNUNET_SERVER_notification_context_unicast (nc, c->handle, 1406 GNUNET_SERVER_notification_context_unicast (nc, c->handle,
@@ -1440,7 +1442,7 @@ GML_send_channel_nack (struct CadetClient *c, CADET_ChannelNumber id)
1440void 1442void
1441GML_send_channel_destroy (struct CadetClient *c, uint32_t id) 1443GML_send_channel_destroy (struct CadetClient *c, uint32_t id)
1442{ 1444{
1443 struct GNUNET_CADET_ChannelMessage msg; 1445 struct GNUNET_CADET_ChannelDestroyMessage msg;
1444 1446
1445 if (NULL == c) 1447 if (NULL == c)
1446 { 1448 {
@@ -1452,9 +1454,6 @@ GML_send_channel_destroy (struct CadetClient *c, uint32_t id)
1452 msg.header.size = htons (sizeof (msg)); 1454 msg.header.size = htons (sizeof (msg));
1453 msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY); 1455 msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY);
1454 msg.channel_id = htonl (id); 1456 msg.channel_id = htonl (id);
1455 msg.port = htonl (0);
1456 memset (&msg.peer, 0, sizeof (msg.peer));
1457 msg.opt = htonl (0);
1458 GNUNET_SERVER_notification_context_unicast (nc, c->handle, 1457 GNUNET_SERVER_notification_context_unicast (nc, c->handle,
1459 &msg.header, GNUNET_NO); 1458 &msg.header, GNUNET_NO);
1460} 1459}
diff --git a/src/cadet/gnunet-service-cadet_local.h b/src/cadet/gnunet-service-cadet_local.h
index 6ca79c90d..877f8ad6e 100644
--- a/src/cadet/gnunet-service-cadet_local.h
+++ b/src/cadet/gnunet-service-cadet_local.h
@@ -134,7 +134,7 @@ GML_client_get (struct GNUNET_SERVER_Client *client);
134 * @return non-NULL if a client has the port. 134 * @return non-NULL if a client has the port.
135 */ 135 */
136struct CadetClient * 136struct CadetClient *
137GML_client_get_by_port (uint32_t port); 137GML_client_get_by_port (struct GNUNET_HashCode *port);
138 138
139/** 139/**
140 * Deletes a tunnel from a client (either owner or destination). 140 * Deletes a tunnel from a client (either owner or destination).
@@ -170,8 +170,8 @@ GML_send_ack (struct CadetClient *c, CADET_ChannelNumber id);
170 */ 170 */
171void 171void
172GML_send_channel_create (struct CadetClient *c, 172GML_send_channel_create (struct CadetClient *c,
173 uint32_t id, uint32_t port, uint32_t opt, 173 uint32_t id, struct GNUNET_HashCode *port,
174 const struct GNUNET_PeerIdentity *peer); 174 uint32_t opt, const struct GNUNET_PeerIdentity *peer);
175 175
176/** 176/**
177 * Build a local channel NACK message and send it to a local client. 177 * Build a local channel NACK message and send it to a local client.
diff --git a/src/cadet/gnunet-service-cadet_tunnel.c b/src/cadet/gnunet-service-cadet_tunnel.c
index fe763e655..bdb8a8ea4 100644
--- a/src/cadet/gnunet-service-cadet_tunnel.c
+++ b/src/cadet/gnunet-service-cadet_tunnel.c
@@ -40,7 +40,7 @@
40#if !defined(GNUNET_CULL_LOGGING) 40#if !defined(GNUNET_CULL_LOGGING)
41#define DUMP_KEYS_TO_STDERR GNUNET_YES 41#define DUMP_KEYS_TO_STDERR GNUNET_YES
42#else 42#else
43#define DUMP_KEYS_TO_STDERR GNUNET_NO 43#define DUMP_KEYS_TO_STDERR GNUNET_YES
44#endif 44#endif
45 45
46#define MIN_TUNNEL_BUFFER 8 46#define MIN_TUNNEL_BUFFER 8
diff --git a/src/cadet/test_cadet.c b/src/cadet/test_cadet.c
index 8c8d7223e..557524ca3 100644
--- a/src/cadet/test_cadet.c
+++ b/src/cadet/test_cadet.c
@@ -33,7 +33,7 @@
33/** 33/**
34 * How many messages to send 34 * How many messages to send
35 */ 35 */
36#define TOTAL_PACKETS 200 /* Cannot exceed 64k! */ 36#define TOTAL_PACKETS 5000 /* Cannot exceed 64k! */
37 37
38/** 38/**
39 * How long until we give up on connecting the peers? 39 * How long until we give up on connecting the peers?