From c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 5 Oct 2019 15:09:28 +0200 Subject: global reindent, now with uncrustify hook enabled --- src/vpn/gnunet-vpn.c | 334 +++++++++++++++++++++++++-------------------------- 1 file changed, 167 insertions(+), 167 deletions(-) (limited to 'src/vpn/gnunet-vpn.c') diff --git a/src/vpn/gnunet-vpn.c b/src/vpn/gnunet-vpn.c index e5b79be6e..6dcd227c7 100644 --- a/src/vpn/gnunet-vpn.c +++ b/src/vpn/gnunet-vpn.c @@ -95,21 +95,21 @@ static struct GNUNET_TIME_Relative duration = { 5 * 60 * 1000 }; * Shutdown. */ static void -do_disconnect(void *cls) +do_disconnect (void *cls) { if (NULL != request) - { - GNUNET_VPN_cancel_request(request); - request = NULL; - } + { + GNUNET_VPN_cancel_request (request); + request = NULL; + } if (NULL != handle) - { - GNUNET_VPN_disconnect(handle); - handle = NULL; - } - GNUNET_free_non_null(peer_id); - GNUNET_free_non_null(service_name); - GNUNET_free_non_null(target_ip); + { + GNUNET_VPN_disconnect (handle); + handle = NULL; + } + GNUNET_free_non_null (peer_id); + GNUNET_free_non_null (service_name); + GNUNET_free_non_null (target_ip); } @@ -127,27 +127,27 @@ do_disconnect(void *cls) * specified target peer; NULL on error */ static void -allocation_cb(void *cls, int af, const void *address) +allocation_cb (void *cls, int af, const void *address) { char buf[INET6_ADDRSTRLEN]; request = NULL; switch (af) - { - case AF_INET6: - case AF_INET: - fprintf(stdout, "%s\n", inet_ntop(af, address, buf, sizeof(buf))); - break; - - case AF_UNSPEC: - GNUNET_log(GNUNET_ERROR_TYPE_ERROR, _("Error creating tunnel\n")); - ret = 1; - break; - - default: - break; - } - GNUNET_SCHEDULER_shutdown(); + { + case AF_INET6: + case AF_INET: + fprintf (stdout, "%s\n", inet_ntop (af, address, buf, sizeof(buf))); + break; + + case AF_UNSPEC: + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _ ("Error creating tunnel\n")); + ret = 1; + break; + + default: + break; + } + GNUNET_SCHEDULER_shutdown (); } @@ -160,10 +160,10 @@ allocation_cb(void *cls, int af, const void *address) * @param cfg configuration */ static void -run(void *cls, - char *const *args, - const char *cfgfile, - const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, + char *const *args, + const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { int dst_af; int req_af; @@ -175,189 +175,189 @@ run(void *cls, uint8_t protocol; struct GNUNET_TIME_Absolute etime; - etime = GNUNET_TIME_relative_to_absolute(duration); - GNUNET_SCHEDULER_add_shutdown(&do_disconnect, NULL); - handle = GNUNET_VPN_connect(cfg); + etime = GNUNET_TIME_relative_to_absolute (duration); + GNUNET_SCHEDULER_add_shutdown (&do_disconnect, NULL); + handle = GNUNET_VPN_connect (cfg); if (NULL == handle) goto error; req_af = AF_UNSPEC; if (ipv4) + { + if (ipv6) { - if (ipv6) - { - fprintf(stderr, - _("Option `%s' makes no sense with option `%s'.\n"), - "-4", - "-6"); - goto error; - } - req_af = AF_INET; + fprintf (stderr, + _ ("Option `%s' makes no sense with option `%s'.\n"), + "-4", + "-6"); + goto error; } + req_af = AF_INET; + } if (ipv6) req_af = AF_INET6; if (NULL == target_ip) + { + if (NULL == service_name) + { + fprintf (stderr, _ ("Option `%s' or `%s' is required.\n"), "-i", "-s"); + goto error; + } + if (NULL == peer_id) { - if (NULL == service_name) - { - fprintf(stderr, _("Option `%s' or `%s' is required.\n"), "-i", "-s"); - goto error; - } - if (NULL == peer_id) - { - fprintf(stderr, - _("Option `%s' is required when using option `%s'.\n"), - "-p", - "-s"); - goto error; - } - if (!(tcp | udp)) - { - fprintf(stderr, - _("Option `%s' or `%s' is required when using option `%s'.\n"), - "-t", - "-u", - "-s"); - goto error; - } - if (tcp & udp) - { - fprintf(stderr, - _("Option `%s' makes no sense with option `%s'.\n"), - "-t", - "-u"); - goto error; - } - if (tcp) - protocol = IPPROTO_TCP; - if (udp) - protocol = IPPROTO_UDP; - if (GNUNET_OK != - GNUNET_CRYPTO_eddsa_public_key_from_string(peer_id, - strlen(peer_id), - &peer.public_key)) - { - fprintf(stderr, _("`%s' is not a valid peer identifier.\n"), peer_id); - goto error; - } - GNUNET_TUN_service_name_to_hash(service_name, &sd); - request = GNUNET_VPN_redirect_to_peer(handle, - req_af, - protocol, - &peer, - &sd, - etime, - &allocation_cb, - NULL); + fprintf (stderr, + _ ("Option `%s' is required when using option `%s'.\n"), + "-p", + "-s"); + goto error; } + if (! (tcp | udp)) + { + fprintf (stderr, + _ ("Option `%s' or `%s' is required when using option `%s'.\n"), + "-t", + "-u", + "-s"); + goto error; + } + if (tcp & udp) + { + fprintf (stderr, + _ ("Option `%s' makes no sense with option `%s'.\n"), + "-t", + "-u"); + goto error; + } + if (tcp) + protocol = IPPROTO_TCP; + if (udp) + protocol = IPPROTO_UDP; + if (GNUNET_OK != + GNUNET_CRYPTO_eddsa_public_key_from_string (peer_id, + strlen (peer_id), + &peer.public_key)) + { + fprintf (stderr, _ ("`%s' is not a valid peer identifier.\n"), peer_id); + goto error; + } + GNUNET_TUN_service_name_to_hash (service_name, &sd); + request = GNUNET_VPN_redirect_to_peer (handle, + req_af, + protocol, + &peer, + &sd, + etime, + &allocation_cb, + NULL); + } else + { + if (1 != inet_pton (AF_INET6, target_ip, &v6)) { - if (1 != inet_pton(AF_INET6, target_ip, &v6)) - { - if (1 != inet_pton(AF_INET, target_ip, &v4)) - { - fprintf(stderr, _("`%s' is not a valid IP address.\n"), target_ip); - goto error; - } - else - { - dst_af = AF_INET; - addr = &v4; - } - } + if (1 != inet_pton (AF_INET, target_ip, &v4)) + { + fprintf (stderr, _ ("`%s' is not a valid IP address.\n"), target_ip); + goto error; + } else - { - dst_af = AF_INET6; - addr = &v6; - } - request = GNUNET_VPN_redirect_to_ip(handle, - req_af, - dst_af, - addr, - etime, - &allocation_cb, - NULL); + { + dst_af = AF_INET; + addr = &v4; + } + } + else + { + dst_af = AF_INET6; + addr = &v6; } + request = GNUNET_VPN_redirect_to_ip (handle, + req_af, + dst_af, + addr, + etime, + &allocation_cb, + NULL); + } return; error: - GNUNET_SCHEDULER_shutdown(); + GNUNET_SCHEDULER_shutdown (); ret = 1; } int -main(int argc, char *const *argv) +main (int argc, char *const *argv) { struct GNUNET_GETOPT_CommandLineOption options[] = - { GNUNET_GETOPT_option_flag('4', - "ipv4", - gettext_noop( - "request that result should be an IPv4 address"), - &ipv4), - - GNUNET_GETOPT_option_flag('6', - "ipv6", - gettext_noop( - "request that result should be an IPv6 address"), - &ipv6), - - GNUNET_GETOPT_option_relative_time( + { GNUNET_GETOPT_option_flag ('4', + "ipv4", + gettext_noop ( + "request that result should be an IPv4 address"), + &ipv4), + + GNUNET_GETOPT_option_flag ('6', + "ipv6", + gettext_noop ( + "request that result should be an IPv6 address"), + &ipv6), + + GNUNET_GETOPT_option_relative_time ( 'd', "duration", "TIME", - gettext_noop("how long should the mapping be valid for new tunnels?"), + gettext_noop ("how long should the mapping be valid for new tunnels?"), &duration), - GNUNET_GETOPT_option_string('i', - "ip", - "IP", - gettext_noop( - "destination IP for the tunnel"), - &target_ip), + GNUNET_GETOPT_option_string ('i', + "ip", + "IP", + gettext_noop ( + "destination IP for the tunnel"), + &target_ip), - GNUNET_GETOPT_option_string( + GNUNET_GETOPT_option_string ( 'p', "peer", "PEERID", - gettext_noop("peer offering the service we would like to access"), + gettext_noop ("peer offering the service we would like to access"), &peer_id), - GNUNET_GETOPT_option_string('s', - "service", - "NAME", - gettext_noop( - "name of the service we would like to access"), - &service_name), + GNUNET_GETOPT_option_string ('s', + "service", + "NAME", + gettext_noop ( + "name of the service we would like to access"), + &service_name), - GNUNET_GETOPT_option_flag('t', - "tcp", - gettext_noop("service is offered via TCP"), - &tcp), + GNUNET_GETOPT_option_flag ('t', + "tcp", + gettext_noop ("service is offered via TCP"), + &tcp), - GNUNET_GETOPT_option_flag('u', - "udp", - gettext_noop("service is offered via UDP"), - &udp), + GNUNET_GETOPT_option_flag ('u', + "udp", + gettext_noop ("service is offered via UDP"), + &udp), - GNUNET_GETOPT_option_verbose(&verbosity), + GNUNET_GETOPT_option_verbose (&verbosity), GNUNET_GETOPT_OPTION_END }; - if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args(argc, argv, &argc, &argv)) + if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) return 2; ret = - (GNUNET_OK == GNUNET_PROGRAM_run(argc, - argv, - "gnunet-vpn", - gettext_noop("Setup tunnels via VPN."), - options, - &run, - NULL)) + (GNUNET_OK == GNUNET_PROGRAM_run (argc, + argv, + "gnunet-vpn", + gettext_noop ("Setup tunnels via VPN."), + options, + &run, + NULL)) ? ret : 1; - GNUNET_free((void *)argv); + GNUNET_free ((void *) argv); return ret; } -- cgit v1.2.3