aboutsummaryrefslogtreecommitdiff
path: root/src/cadet/gnunet-cadet.c
diff options
context:
space:
mode:
authorCarlo von lynX <lynX@time.to.get.psyced.org>2016-08-08 19:51:46 +0000
committerCarlo von lynX <lynX@time.to.get.psyced.org>2016-08-08 19:51:46 +0000
commit06f44db8a9a4c1b6b4a2a4a707067feb7164e609 (patch)
tree70d992450fe010e5ef8c2fd8882b745bb8841772 /src/cadet/gnunet-cadet.c
parent86a3fcdd55ad2cb221fbc2d495a90def1532b01a (diff)
downloadgnunet-06f44db8a9a4c1b6b4a2a4a707067feb7164e609.tar.gz
gnunet-06f44db8a9a4c1b6b4a2a4a707067feb7164e609.zip
Merge branch 'master' of /RAM/proj/gnunet
Diffstat (limited to 'src/cadet/gnunet-cadet.c')
-rw-r--r--src/cadet/gnunet-cadet.c37
1 files changed, 24 insertions, 13 deletions
diff --git a/src/cadet/gnunet-cadet.c b/src/cadet/gnunet-cadet.c
index 4801dbbdf..88ee41096 100644
--- a/src/cadet/gnunet-cadet.c
+++ b/src/cadet/gnunet-cadet.c
@@ -65,7 +65,7 @@ static char *conn_id;
65static char *channel_id; 65static char *channel_id;
66 66
67/** 67/**
68 * Port to listen on (-p). 68 * Port to listen on (-o).
69 */ 69 */
70static uint32_t listen_port; 70static uint32_t listen_port;
71 71
@@ -120,6 +120,11 @@ static struct GNUNET_CADET_Channel *ch;
120static struct GNUNET_CADET_TransmitHandle *th; 120static struct GNUNET_CADET_TransmitHandle *th;
121 121
122/** 122/**
123 * Data structure for ongoing reception of incoming virtual circuits.
124 */
125struct GNUNET_CADET_Port *lp;
126
127/**
123 * Shutdown task handle. 128 * Shutdown task handle.
124 */ 129 */
125static struct GNUNET_SCHEDULER_Task *sd; 130static struct GNUNET_SCHEDULER_Task *sd;
@@ -376,8 +381,8 @@ channel_ended (void *cls,
376 * Only called (once) upon reception of data with a message type which was 381 * Only called (once) upon reception of data with a message type which was
377 * subscribed to in #GNUNET_CADET_connect. 382 * subscribed to in #GNUNET_CADET_connect.
378 * 383 *
379 * A call to #GNUNET_CADET_channel_destroy causes te channel to be ignored. In 384 * A call to #GNUNET_CADET_channel_destroy causes the channel to be ignored.
380 * this case the handler MUST return NULL. 385 * In this case the handler MUST return NULL.
381 * 386 *
382 * @param cls closure 387 * @param cls closure
383 * @param channel new handle to the channel 388 * @param channel new handle to the channel
@@ -395,9 +400,9 @@ channel_incoming (void *cls,
395 const struct GNUNET_HashCode *port, 400 const struct GNUNET_HashCode *port,
396 enum GNUNET_CADET_ChannelOption options) 401 enum GNUNET_CADET_ChannelOption options)
397{ 402{
398 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 403 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
399 "Incoming channel %p on port %s\n", 404 "Incoming channel %p from %s on port %s\n",
400 channel, GNUNET_h2s (port)); 405 channel, GNUNET_i2s_full (initiator), GNUNET_h2s (port));
401 if (NULL != ch) 406 if (NULL != ch)
402 { 407 {
403 GNUNET_break (0); 408 GNUNET_break (0);
@@ -409,9 +414,15 @@ channel_incoming (void *cls,
409 } 414 }
410 if (0 == listen_port) 415 if (0 == listen_port)
411 { 416 {
412 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Not listening to channels\n"); 417 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Not listening to channels\n");
413 return NULL; 418 return NULL;
414 } 419 }
420 if (NULL != lp) {
421 /* Now that we have our circuit up and running, let's not
422 * get confused by further incoming circuits.
423 */
424 GNUNET_CADET_close_port (lp);
425 }
415 ch = channel; 426 ch = channel;
416 if (GNUNET_NO == echo) 427 if (GNUNET_NO == echo)
417 { 428 {
@@ -901,13 +912,13 @@ run (void *cls,
901 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Show all tunnels\n"); 912 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Show all tunnels\n");
902 job = GNUNET_SCHEDULER_add_now (&get_tunnels, NULL); 913 job = GNUNET_SCHEDULER_add_now (&get_tunnels, NULL);
903 } 914 }
904 else 915 else if (0 == listen_port)
905 { 916 {
906 FPRINTF (stderr, "No action requested\n"); 917 FPRINTF (stderr, "No action requested\n");
907 return; 918 return;
908 } 919 }
909 920
910 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting to cadet\n"); 921 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting to CADET service\n");
911 mh = GNUNET_CADET_connect (cfg, 922 mh = GNUNET_CADET_connect (cfg,
912 NULL, /* cls */ 923 NULL, /* cls */
913 &channel_ended, /* cleaner */ 924 &channel_ended, /* cleaner */
@@ -919,9 +930,9 @@ run (void *cls,
919 930
920 if (0 != listen_port) 931 if (0 != listen_port)
921 { 932 {
922 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Opening listen port\n"); 933 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Opening CADET listen port\n");
923 GNUNET_CADET_open_port (mh, GC_u2h (listen_port), 934 lp = GNUNET_CADET_open_port (mh, GC_u2h (listen_port),
924 &channel_incoming, NULL); 935 &channel_incoming, NULL);
925 } 936 }
926} 937}
927 938
@@ -955,7 +966,7 @@ main (int argc, char *const *argv)
955// gettext_noop ("provide information about all events (continuously)"), 966// gettext_noop ("provide information about all events (continuously)"),
956// GNUNET_NO, &GNUNET_GETOPT_set_one, &monitor_mode}, 967// GNUNET_NO, &GNUNET_GETOPT_set_one, &monitor_mode},
957 {'o', "open-port", NULL, 968 {'o', "open-port", NULL,
958 gettext_noop ("port to listen to (default; 0)"), 969 gettext_noop ("port to listen to"),
959 GNUNET_YES, &GNUNET_GETOPT_set_uint, &listen_port}, 970 GNUNET_YES, &GNUNET_GETOPT_set_uint, &listen_port},
960 {'p', "peer", "PEER_ID", 971 {'p', "peer", "PEER_ID",
961 gettext_noop ("provide information about a patricular peer"), 972 gettext_noop ("provide information about a patricular peer"),