aboutsummaryrefslogtreecommitdiff
path: root/src/cadet/gnunet-cadet.c
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/gnunet-cadet.c
parenta603aaacbb3e786ab50644ca6fb49add439c8d8b (diff)
Change CADET ports from uint32 to HashCode
Diffstat (limited to 'src/cadet/gnunet-cadet.c')
-rw-r--r--src/cadet/gnunet-cadet.c42
1 files changed, 18 insertions, 24 deletions
diff --git a/src/cadet/gnunet-cadet.c b/src/cadet/gnunet-cadet.c
index cf415448f9..4801dbbdff 100644
--- a/src/cadet/gnunet-cadet.c
+++ b/src/cadet/gnunet-cadet.c
@@ -390,20 +390,21 @@ channel_ended (void *cls,
*/
static void *
channel_incoming (void *cls,
- struct GNUNET_CADET_Channel * channel,
- const struct GNUNET_PeerIdentity * initiator,
- uint32_t port, enum GNUNET_CADET_ChannelOption options)
+ struct GNUNET_CADET_Channel *channel,
+ const struct GNUNET_PeerIdentity *initiator,
+ const struct GNUNET_HashCode *port,
+ enum GNUNET_CADET_ChannelOption options)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Incoming channel %p on port %u\n",
- channel, port);
+ "Incoming channel %p on port %s\n",
+ channel, GNUNET_h2s (port));
if (NULL != ch)
{
GNUNET_break (0);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"A channel already exists (%p)\n", ch);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Incoming channel %p on port %u\n", channel, port);
+ "Incoming channel %p on port %s\n", channel, GNUNET_h2s (port));
return NULL;
}
if (0 == listen_port)
@@ -480,7 +481,7 @@ create_channel (void *cls)
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting to `%s'\n", target_id);
opt = GNUNET_CADET_OPTION_DEFAULT | GNUNET_CADET_OPTION_RELIABLE;
- ch = GNUNET_CADET_channel_create (mh, NULL, &pid, target_port, opt);
+ ch = GNUNET_CADET_channel_create (mh, NULL, &pid, GC_u2h (target_port), opt);
if (GNUNET_NO == echo)
listen_stdio ();
else
@@ -835,13 +836,11 @@ run (void *cls,
const char *cfgfile,
const struct GNUNET_CONFIGURATION_Handle *cfg)
{
- GNUNET_CADET_InboundChannelNotificationHandler *newch = NULL;
- GNUNET_CADET_ChannelEndHandler *endch = NULL;
static const struct GNUNET_CADET_MessageHandler handlers[] = {
{&data_callback, GNUNET_MESSAGE_TYPE_CADET_CLI, 0},
{NULL, 0, 0} /* FIXME add option to monitor msg types */
};
- static uint32_t *ports = NULL;
+
/* FIXME add option to monitor apps */
target_id = args[0];
@@ -871,15 +870,6 @@ run (void *cls,
"Creating channel to %s\n",
target_id);
GNUNET_SCHEDULER_add_now (&create_channel, NULL);
- endch = &channel_ended;
- }
- else if (0 != listen_port)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Listen\n");
- newch = &channel_incoming;
- endch = &channel_ended;
- ports = GNUNET_malloc (sizeof (uint32_t) * 2);
- ports[0] = listen_port;
}
else if (NULL != peer_id)
{
@@ -920,15 +910,19 @@ run (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting to cadet\n");
mh = GNUNET_CADET_connect (cfg,
NULL, /* cls */
- newch, /* new channel */
- endch, /* cleaner */
- handlers,
- ports);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Done\n");
+ &channel_ended, /* cleaner */
+ handlers);
if (NULL == mh)
GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
else
sd = GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL);
+
+ 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);
+ }
}