diff options
author | Bart Polot <bart@net.in.tum.de> | 2016-07-20 12:07:02 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2016-07-20 12:07:02 +0000 |
commit | caa4196867da8684c5b1fd2e747ecb9d21cbba8b (patch) | |
tree | a8d2ab68b81df8040c013118b7197209c70fa4c2 /src/cadet/gnunet-cadet.c | |
parent | a603aaacbb3e786ab50644ca6fb49add439c8d8b (diff) | |
download | gnunet-caa4196867da8684c5b1fd2e747ecb9d21cbba8b.tar.gz gnunet-caa4196867da8684c5b1fd2e747ecb9d21cbba8b.zip |
Change CADET ports from uint32 to HashCode
Diffstat (limited to 'src/cadet/gnunet-cadet.c')
-rw-r--r-- | src/cadet/gnunet-cadet.c | 42 |
1 files changed, 18 insertions, 24 deletions
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 | */ |
391 | static void * | 391 | static void * |
392 | channel_incoming (void *cls, | 392 | channel_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 | ||