From 06f44db8a9a4c1b6b4a2a4a707067feb7164e609 Mon Sep 17 00:00:00 2001 From: Carlo von lynX Date: Mon, 8 Aug 2016 19:51:46 +0000 Subject: [PATCH] Merge branch 'master' of /RAM/proj/gnunet --- src/cadet/gnunet-cadet.c | 37 +++++++++++++++++--------- src/cadet/gnunet-service-cadet_local.c | 1 + src/include/gnunet_common.h | 12 ++++++--- src/util/common_logging.c | 9 +++++-- 4 files changed, 40 insertions(+), 19 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; static char *channel_id; /** - * Port to listen on (-p). + * Port to listen on (-o). */ static uint32_t listen_port; @@ -119,6 +119,11 @@ static struct GNUNET_CADET_Channel *ch; */ static struct GNUNET_CADET_TransmitHandle *th; +/** + * Data structure for ongoing reception of incoming virtual circuits. + */ +struct GNUNET_CADET_Port *lp; + /** * Shutdown task handle. */ @@ -376,8 +381,8 @@ channel_ended (void *cls, * Only called (once) upon reception of data with a message type which was * subscribed to in #GNUNET_CADET_connect. * - * A call to #GNUNET_CADET_channel_destroy causes te channel to be ignored. In - * this case the handler MUST return NULL. + * A call to #GNUNET_CADET_channel_destroy causes the channel to be ignored. + * In this case the handler MUST return NULL. * * @param cls closure * @param channel new handle to the channel @@ -395,9 +400,9 @@ channel_incoming (void *cls, const struct GNUNET_HashCode *port, enum GNUNET_CADET_ChannelOption options) { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Incoming channel %p on port %s\n", - channel, GNUNET_h2s (port)); + GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, + "Incoming channel %p from %s on port %s\n", + channel, GNUNET_i2s_full (initiator), GNUNET_h2s (port)); if (NULL != ch) { GNUNET_break (0); @@ -409,9 +414,15 @@ channel_incoming (void *cls, } if (0 == listen_port) { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Not listening to channels\n"); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Not listening to channels\n"); return NULL; } + if (NULL != lp) { + /* Now that we have our circuit up and running, let's not + * get confused by further incoming circuits. + */ + GNUNET_CADET_close_port (lp); + } ch = channel; if (GNUNET_NO == echo) { @@ -901,13 +912,13 @@ run (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Show all tunnels\n"); job = GNUNET_SCHEDULER_add_now (&get_tunnels, NULL); } - else + else if (0 == listen_port) { FPRINTF (stderr, "No action requested\n"); return; } - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting to cadet\n"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting to CADET service\n"); mh = GNUNET_CADET_connect (cfg, NULL, /* cls */ &channel_ended, /* cleaner */ @@ -919,9 +930,9 @@ run (void *cls, if (0 != listen_port) { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Opening listen port\n"); - GNUNET_CADET_open_port (mh, GC_u2h (listen_port), - &channel_incoming, NULL); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Opening CADET listen port\n"); + lp = GNUNET_CADET_open_port (mh, GC_u2h (listen_port), + &channel_incoming, NULL); } } @@ -955,7 +966,7 @@ main (int argc, char *const *argv) // gettext_noop ("provide information about all events (continuously)"), // GNUNET_NO, &GNUNET_GETOPT_set_one, &monitor_mode}, {'o', "open-port", NULL, - gettext_noop ("port to listen to (default; 0)"), + gettext_noop ("port to listen to"), GNUNET_YES, &GNUNET_GETOPT_set_uint, &listen_port}, {'p', "peer", "PEER_ID", gettext_noop ("provide information about a patricular peer"), diff --git a/src/cadet/gnunet-service-cadet_local.c b/src/cadet/gnunet-service-cadet_local.c index d2efb7bef..c6e2fe30d 100644 --- a/src/cadet/gnunet-service-cadet_local.c +++ b/src/cadet/gnunet-service-cadet_local.c @@ -379,6 +379,7 @@ static void handle_port_close (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { + // FIXME } diff --git a/src/include/gnunet_common.h b/src/include/gnunet_common.h index 52322e05e..5b2338998 100644 --- a/src/include/gnunet_common.h +++ b/src/include/gnunet_common.h @@ -332,10 +332,14 @@ enum GNUNET_ErrorType GNUNET_ERROR_TYPE_NONE = 0, GNUNET_ERROR_TYPE_ERROR = 1, GNUNET_ERROR_TYPE_WARNING = 2, - GNUNET_ERROR_TYPE_INFO = 4, - GNUNET_ERROR_TYPE_DEBUG = 8, - GNUNET_ERROR_TYPE_INVALID = 16, - GNUNET_ERROR_TYPE_BULK = 32 + /* UX: We need a message type that is output by + * default without looking like there is a problem. + */ + GNUNET_ERROR_TYPE_MESSAGE = 4, + GNUNET_ERROR_TYPE_INFO = 8, + GNUNET_ERROR_TYPE_DEBUG = 16, + GNUNET_ERROR_TYPE_INVALID = 32, + GNUNET_ERROR_TYPE_BULK = 64 }; diff --git a/src/util/common_logging.c b/src/util/common_logging.c index 4d78f4898..a80081011 100644 --- a/src/util/common_logging.c +++ b/src/util/common_logging.c @@ -256,6 +256,8 @@ get_type (const char *log) if (0 == strcasecmp (log, _("DEBUG"))) return GNUNET_ERROR_TYPE_DEBUG; if (0 == strcasecmp (log, _("INFO"))) + return GNUNET_ERROR_TYPE_MESSAGE; + if (0 == strcasecmp (log, _("MESSAGE"))) return GNUNET_ERROR_TYPE_INFO; if (0 == strcasecmp (log, _("WARNING"))) return GNUNET_ERROR_TYPE_WARNING; @@ -520,9 +522,10 @@ GNUNET_get_log_call_status (int caller_level, if (min_level >= 0) return caller_level <= min_level; /* All programs/services previously defaulted to WARNING. - * Now WE default to WARNING, and THEY default to NULL. + * Now *we* default to WARNING, and THEY default to NULL. + * Or rather we default to MESSAGE, since things aren't always bad. */ - return caller_level <= GNUNET_ERROR_TYPE_WARNING; + return caller_level <= GNUNET_ERROR_TYPE_MESSAGE; } @@ -1066,6 +1069,8 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind) return _("ERROR"); if ((kind & GNUNET_ERROR_TYPE_WARNING) > 0) return _("WARNING"); + if ((kind & GNUNET_ERROR_TYPE_MESSAGE) > 0) + return _("MESSAGE"); if ((kind & GNUNET_ERROR_TYPE_INFO) > 0) return _("INFO"); if ((kind & GNUNET_ERROR_TYPE_DEBUG) > 0) -- 2.25.1