diff options
author | Christian Grothoff <christian@grothoff.org> | 2020-09-05 21:49:16 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2020-09-05 21:49:16 +0200 |
commit | 6656636f73c1e6d12403fe1ea86e0e0c13ab0cc3 (patch) | |
tree | 51c16de1f4ac5c45f8f48a7150df9f13b0824190 | |
parent | afc13e32896257b7ed0e5aa88e280950419148ac (diff) | |
parent | ac165b5babe8a0fb77177aafc9990abefb053c0f (diff) |
Merge branch 'master' of git+ssh://gnunet.org/gnunet
-rwxr-xr-x | .buildbot/firefly-x86_64-amdepyc_test.sh | 10 | ||||
-rw-r--r-- | README | 2 | ||||
-rw-r--r-- | configure.ac | 5 | ||||
-rw-r--r-- | src/gns/test_gns_proxy.c | 8 | ||||
-rw-r--r-- | src/include/gnunet_transport_communication_service.h | 8 | ||||
-rw-r--r-- | src/reclaim/gnunet-reclaim.c | 2 | ||||
-rw-r--r-- | src/reclaim/plugin_reclaim_credential_jwt.c | 2 | ||||
-rw-r--r-- | src/transport/gnunet-communicator-tcp.c | 352 | ||||
-rw-r--r-- | src/transport/test_communicator_tcp_rekey_peer2.conf | 4 | ||||
-rw-r--r-- | src/transport/transport-testing2.c | 10 | ||||
-rw-r--r-- | src/transport/transport_api2_communication.c | 15 | ||||
-rw-r--r-- | src/util/gnunet-qr.c | 7 | ||||
-rw-r--r-- | src/util/gnunet-uri.c | 2 |
13 files changed, 321 insertions, 106 deletions
diff --git a/.buildbot/firefly-x86_64-amdepyc_test.sh b/.buildbot/firefly-x86_64-amdepyc_test.sh index db202a112..d665d3a7c 100755 --- a/.buildbot/firefly-x86_64-amdepyc_test.sh +++ b/.buildbot/firefly-x86_64-amdepyc_test.sh @@ -1,3 +1,11 @@ #!/bin/bash -echo "Skipped" +# echo "Skipped" + +pushd src/transport +make check TESTS='test_communicator_basic-tcp' +cat test-suite.log +pkill --signal 9 -U buildbot gnunet +make check TESTS='test_communicator_rekey-tcp' +pkill --signal 9 -U buildbot gnunet +popd @@ -96,7 +96,7 @@ These are the direct dependencies for running GNUnet: - which (contrib/apparmor(?), gnunet-bugreport, and possibly more) - zlib -- libsodium >= 1.0.11 (for elliptic curve cryptography) +- libsodium >= 1.0.17 (for elliptic curve cryptography) These are the dependencies for GNUnet's testsuite: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/configure.ac b/configure.ac index bd92bd0e9..75e11bd4f 100644 --- a/configure.ac +++ b/configure.ac @@ -1036,9 +1036,10 @@ AC_CHECK_LIB([kvm],[kvm_open]) AC_CHECK_LIB([kstat],[kstat_open]) libsodium=0 -# test for libsodium +# test for libsodium >=1.017 (introduction of +# crypto_scalarmult_ed25519_base_noclamp API) AC_CHECK_HEADER([sodium.h], - [AC_CHECK_LIB([sodium], [crypto_pwhash_argon2id], + [AC_CHECK_LIB([sodium], [crypto_scalarmult_ed25519_base_noclamp], [libsodium=1])]) AS_IF([test x$libsodium = x0], diff --git a/src/gns/test_gns_proxy.c b/src/gns/test_gns_proxy.c index 13764d520..579de774f 100644 --- a/src/gns/test_gns_proxy.c +++ b/src/gns/test_gns_proxy.c @@ -189,7 +189,7 @@ copy_buffer (void *ptr, size_t size, size_t nmemb, void *ctx) } -static int +static enum MHD_Result mhd_ahc (void *cls, struct MHD_Connection *connection, const char *url, @@ -528,8 +528,6 @@ run (void *cls, int main (int argc, char *const *argv) { - char *tmp_argv; - struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_option_uint16 ('p', "port", @@ -559,7 +557,7 @@ main (int argc, char *const *argv) } if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, - &argc, &tmp_argv)) + &argc, &argv)) return 2; GNUNET_log_setup ("gnunet-gns-proxy-test", "WARNING", @@ -570,7 +568,7 @@ main (int argc, char *const *argv) options, &run, NULL)) return 1; - GNUNET_free (tmp_argv); + GNUNET_free_nz ((void*) argv); return global_ret; } diff --git a/src/include/gnunet_transport_communication_service.h b/src/include/gnunet_transport_communication_service.h index ea6b95e2d..431b9a671 100644 --- a/src/include/gnunet_transport_communication_service.h +++ b/src/include/gnunet_transport_communication_service.h @@ -336,6 +336,14 @@ void GNUNET_TRANSPORT_communicator_address_remove ( struct GNUNET_TRANSPORT_AddressIdentifier *ai); +/** + * Notify transport service that this communicator no longer provides all its addresses for this peer. + * + * @param ch The communicator handle. + */ +void +GNUNET_TRANSPORT_communicator_address_remove_all ( + struct GNUNET_TRANSPORT_CommunicatorHandle *ch); /** * The communicator asks the transport service to route a message via diff --git a/src/reclaim/gnunet-reclaim.c b/src/reclaim/gnunet-reclaim.c index ab281a645..b9306b802 100644 --- a/src/reclaim/gnunet-reclaim.c +++ b/src/reclaim/gnunet-reclaim.c @@ -862,7 +862,7 @@ main (int argc, char *const argv[]) gettext_noop ("List credentials for EGO"), &list_credentials), GNUNET_GETOPT_option_string ('I', - "Credential ID", + "credential-id", "CREDENTIAL_ID", gettext_noop ( "Credential to use for attribute"), diff --git a/src/reclaim/plugin_reclaim_credential_jwt.c b/src/reclaim/plugin_reclaim_credential_jwt.c index 148865223..6f52f3a4e 100644 --- a/src/reclaim/plugin_reclaim_credential_jwt.c +++ b/src/reclaim/plugin_reclaim_credential_jwt.c @@ -177,6 +177,8 @@ jwt_parse_attributes (void *cls, json_object_foreach (json_val, key, value) { if (0 == strcmp ("iss", key)) continue; + if (0 == strcmp ("jti", key)) + continue; if (0 == strcmp ("exp", key)) continue; if (0 == strcmp ("iat", key)) diff --git a/src/transport/gnunet-communicator-tcp.c b/src/transport/gnunet-communicator-tcp.c index 880145424..4caef909c 100644 --- a/src/transport/gnunet-communicator-tcp.c +++ b/src/transport/gnunet-communicator-tcp.c @@ -308,6 +308,38 @@ struct TCPRekey struct GNUNET_TIME_AbsoluteNBO monotonic_time; }; +/** + * Signature we use to verify that the ephemeral key was really chosen by + * the specified sender. + */ +struct TcpRekeySignature +{ + /** + * Purpose must be #GNUNET_SIGNATURE_COMMUNICATOR_TCP_REKEY + */ + struct GNUNET_CRYPTO_EccSignaturePurpose purpose; + + /** + * Identity of the inititor of the TCP connection (TCP client). + */ + struct GNUNET_PeerIdentity sender; + + /** + * Presumed identity of the target of the TCP connection (TCP server) + */ + struct GNUNET_PeerIdentity receiver; + + /** + * Ephemeral key used by the @e sender. + */ + struct GNUNET_CRYPTO_EcdhePublicKey ephemeral; + + /** + * Monotonic time of @e sender, to possibly help detect replay attacks + * (if receiver persists times by sender). + */ + struct GNUNET_TIME_AbsoluteNBO monotonic_time; +}; /** * TCP finish. Sender asks for the connection to be closed. @@ -799,6 +831,16 @@ size_t unverified_size; static struct GNUNET_PEERSTORE_Handle *peerstore; /** + * A flag indicating we are already doing a shutdown. + */ +int shutdown_running = GNUNET_NO; + +/** + * The port the communicator should be assigned to. + */ +unsigned int bind_port; + +/** * We have been notified that our listen socket has something to * read. Do the read and reschedule this function to be called again * once more is available. @@ -819,7 +861,6 @@ listen_cb (void *cls); static void queue_destroy (struct Queue *queue) { - struct GNUNET_MQ_Handle *mq; struct ListenTask *lt; lt = GNUNET_new (struct ListenTask); lt->listen_sock = queue->listen_sock; @@ -858,11 +899,6 @@ queue_destroy (struct Queue *queue) GNUNET_PEERSTORE_iterate_cancel (queue->handshake_ack_monotime_get); queue->handshake_ack_monotime_get = NULL; } - if (NULL != (mq = queue->mq)) - { - queue->mq = NULL; - GNUNET_MQ_destroy (mq); - } if (NULL != queue->qh) { GNUNET_TRANSPORT_communicator_mq_del (queue->qh); @@ -885,7 +921,11 @@ queue_destroy (struct Queue *queue) GNUNET_SCHEDULER_cancel (queue->write_task); queue->write_task = NULL; } - GNUNET_NETWORK_socket_close (queue->sock); + if (GNUNET_SYSERR == GNUNET_NETWORK_socket_close (queue->sock)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "closing socket failed\n"); + } gcry_cipher_close (queue->in_cipher); gcry_cipher_close (queue->out_cipher); GNUNET_free (queue->address); @@ -894,12 +934,18 @@ queue_destroy (struct Queue *queue) else GNUNET_free (queue); - if (NULL == lt->listen_task) + if ((NULL != lt->listen_sock) && (NULL == lt->listen_task)) + { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "add read net listen\n"); lt->listen_task = GNUNET_SCHEDULER_add_read_net ( GNUNET_TIME_UNIT_FOREVER_REL, lt->listen_sock, &listen_cb, lt); + } + else + GNUNET_free (lt); } @@ -1001,6 +1047,13 @@ core_read_finished_cb (void *cls, int success) "# messages lost in communicator API towards CORE", 1, GNUNET_NO); + if (NULL == queue) + return; + + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "backpressure %u\n", + queue->backpressure); + queue->backpressure--; /* handle deferred queue destruction */ if ((queue->destroyed) && (0 == queue->backpressure)) @@ -1008,15 +1061,18 @@ core_read_finished_cb (void *cls, int success) GNUNET_free (queue); return; } - reschedule_queue_timeout (queue); - /* possibly unchoke reading, now that CORE made progress */ - if (NULL == queue->read_task) - queue->read_task = - GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_absolute_get_remaining ( - queue->timeout), - queue->sock, - &queue_read, - queue); + else if (GNUNET_YES != queue->destroyed) + { + reschedule_queue_timeout (queue); + /* possibly unchoke reading, now that CORE made progress */ + if (NULL == queue->read_task) + queue->read_task = + GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_absolute_get_remaining ( + queue->timeout), + queue->sock, + &queue_read, + queue); + } } @@ -1219,13 +1275,34 @@ rekey_monotime_cb (void *cls, static void do_rekey (struct Queue *queue, const struct TCPRekey *rekey) { - struct TcpHandshakeSignature thp; + struct TcpRekeySignature thp; + thp.purpose.purpose = htonl (GNUNET_SIGNATURE_COMMUNICATOR_TCP_REKEY); thp.purpose.size = htonl (sizeof(thp)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "do_rekey size %u\n", + thp.purpose.size); thp.sender = queue->target; + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "sender %s\n", + GNUNET_p2s (&thp.sender.public_key)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "sender %s\n", + GNUNET_p2s (&queue->target.public_key)); thp.receiver = my_identity; + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "receiver %s\n", + GNUNET_p2s (&thp.receiver.public_key)); thp.ephemeral = rekey->ephemeral; + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "ephemeral %s\n", + GNUNET_e2s (&thp.ephemeral)); thp.monotonic_time = rekey->monotonic_time; + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "time %s\n", + GNUNET_STRINGS_absolute_time_to_string ( + GNUNET_TIME_absolute_ntoh (thp.monotonic_time))); + GNUNET_assert (ntohl ((&thp)->purpose.size) == sizeof (*(&thp))); if (GNUNET_OK != GNUNET_CRYPTO_eddsa_verify (GNUNET_SIGNATURE_COMMUNICATOR_TCP_REKEY, &thp, @@ -1359,7 +1436,7 @@ try_handle_plaintext (struct Queue *queue) if ((-1 != unverified_size) && (unverified_size > INITIAL_CORE_KX_SIZE)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Already received data of size %u bigger than KX size %u!\n", + "Already received data of size %lu bigger than KX size %lu!\n", unverified_size, INITIAL_CORE_KX_SIZE); GNUNET_break_op (0); @@ -1636,6 +1713,8 @@ tcp_address_to_sockaddr_numeric_v6 (socklen_t *sock_len, struct sockaddr_in6 v6, #if HAVE_SOCKADDR_IN_SIN_LEN v6.sin6_len = sizeof(sizeof(struct sockaddr_in6)); #endif + v6.sin6_flowinfo = 0; + v6.sin6_scope_id = 0; in = GNUNET_memdup (&v6, sizeof(v6)); *sock_len = sizeof(struct sockaddr_in6); @@ -1739,11 +1818,19 @@ extract_address (const char *bindto) char *cp; char *rest = NULL; + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "extract address with bindto %s\n", + bindto); + if (NULL == bindto) - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "bindto is NULL\n"); cp = GNUNET_strdup (bindto); + + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "extract address 2\n"); + start = cp; if (('[' == *cp) && (']' == cp[strlen (cp) - 1])) { @@ -1763,7 +1850,11 @@ extract_address (const char *bindto) } } - GNUNET_free (cp); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "extract address 3\n"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "extract address with start %s\n", + start); return start; } @@ -1865,10 +1956,25 @@ tcp_address_to_sockaddr (const char *bindto, socklen_t *sock_len) // cp = GNUNET_strdup (bindto); start = extract_address (bindto); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "start %s\n", + start); + + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "!bindto %s\n", + bindto); + + + if (1 == inet_pton (AF_INET, start, &v4.sin_addr)) { // colon = strrchr (cp, ':'); port = extract_port (bindto); + + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "port %u\n", + port); + in = tcp_address_to_sockaddr_numeric_v4 (sock_len, v4, port); } else if (1 == inet_pton (AF_INET6, start, &v6.sin6_addr)) @@ -1876,8 +1982,12 @@ tcp_address_to_sockaddr (const char *bindto, socklen_t *sock_len) // colon = strrchr (cp, ':'); port = extract_port (bindto); in = tcp_address_to_sockaddr_numeric_v6 (sock_len, v6, port); + }else{ + GNUNET_assert (0); } + // GNUNET_free (start); + return in; } @@ -1913,7 +2023,7 @@ static void inject_rekey (struct Queue *queue) { struct TCPRekey rekey; - struct TcpHandshakeSignature thp; + struct TcpRekeySignature thp; GNUNET_assert (0 == queue->pwrite_off); memset (&rekey, 0, sizeof(rekey)); @@ -1925,10 +2035,26 @@ inject_rekey (struct Queue *queue) GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get_monotonic (cfg)); thp.purpose.purpose = htonl (GNUNET_SIGNATURE_COMMUNICATOR_TCP_REKEY); thp.purpose.size = htonl (sizeof(thp)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "inject_rekey size %u\n", + thp.purpose.size); thp.sender = my_identity; + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "sender %s\n", + GNUNET_p2s (&thp.sender.public_key)); thp.receiver = queue->target; + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "receiver %s\n", + GNUNET_p2s (&thp.receiver.public_key)); thp.ephemeral = rekey.ephemeral; + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "ephemeral %s\n", + GNUNET_e2s (&thp.ephemeral)); thp.monotonic_time = rekey.monotonic_time; + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "time %s\n", + GNUNET_STRINGS_absolute_time_to_string ( + GNUNET_TIME_absolute_ntoh (thp.monotonic_time))); GNUNET_CRYPTO_eddsa_sign (my_private_key, &thp, &rekey.sender_sig); @@ -2004,10 +2130,11 @@ queue_write (void *cls) queue->cwrite_off += queue->pwrite_off; queue->pwrite_off = 0; } - if ((0 == queue->pwrite_off) && - ((0 == queue->rekey_left_bytes) || - (0 == - GNUNET_TIME_absolute_get_remaining (queue->rekey_time).rel_value_us))) + if ((-1 != unverified_size)&& ((0 == queue->pwrite_off) && + ((0 == queue->rekey_left_bytes) || + (0 == + GNUNET_TIME_absolute_get_remaining ( + queue->rekey_time).rel_value_us)))) { inject_rekey (queue); } @@ -2707,7 +2834,7 @@ mq_init (void *cls, const struct GNUNET_PeerIdentity *peer, const char *address) struct Queue *queue; const char *path; struct sockaddr *in; - socklen_t in_len; + socklen_t in_len = 0; struct GNUNET_NETWORK_Handle *sock; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -2729,6 +2856,10 @@ mq_init (void *cls, const struct GNUNET_PeerIdentity *peer, const char *address) return GNUNET_SYSERR; } + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "in %s\n", + GNUNET_a2s (in, in_len)); + sock = GNUNET_NETWORK_socket_create (in->sa_family, SOCK_STREAM, IPPROTO_TCP); if (NULL == sock) { @@ -2794,6 +2925,11 @@ get_queue_delete_it (void *cls, (void) cls; (void) target; + if (NULL != queue->listen_task) + { + GNUNET_SCHEDULER_cancel (queue->listen_task); + queue->listen_task = NULL; + } queue_destroy (queue); return GNUNET_OK; } @@ -2807,6 +2943,16 @@ get_queue_delete_it (void *cls, static void do_shutdown (void *cls) { + + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Shutdown %s!\n", + shutdown_running ? "running" : "not running"); + + if (GNUNET_YES == shutdown_running) + return; + else + shutdown_running = GNUNET_YES; + while (NULL != proto_head) free_proto_queue (proto_head); if (NULL != nat) @@ -2816,6 +2962,7 @@ do_shutdown (void *cls) } GNUNET_CONTAINER_multipeermap_iterate (queue_map, &get_queue_delete_it, NULL); GNUNET_CONTAINER_multipeermap_destroy (queue_map); + GNUNET_TRANSPORT_communicator_address_remove_all (ch); if (NULL != ch) { GNUNET_TRANSPORT_communicator_disconnect (ch); @@ -2836,6 +2983,16 @@ do_shutdown (void *cls) GNUNET_NT_scanner_done (is); is = NULL; } + if (NULL != peerstore) + { + GNUNET_PEERSTORE_disconnect (peerstore, GNUNET_NO); + peerstore = NULL; + } + if (NULL != resolve_request_handle) + { + GNUNET_RESOLVER_request_cancel (resolve_request_handle); + resolve_request_handle = NULL; + } } @@ -2886,6 +3043,11 @@ nat_address_cb (void *cls, char *my_addr; struct GNUNET_TRANSPORT_AddressIdentifier *ai; + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "nat address cb %s %s\n", + add_remove ? "add" : "remove", + GNUNET_a2s (addr, addrlen)); + if (GNUNET_YES == add_remove) { enum GNUNET_NetworkType nt; @@ -2912,6 +3074,35 @@ nat_address_cb (void *cls, } /** + * This method adds addresses to the DLL, that are later register at the NAT service. + */ +static void +add_addr (struct sockaddr *in, socklen_t in_len) +{ + + struct Addresses *saddrs; + + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "add address %s\n", + GNUNET_a2s (in, in_len)); + + saddrs = GNUNET_new (struct Addresses); + saddrs->addr = in; + saddrs->addr_len = in_len; + GNUNET_CONTAINER_DLL_insert (addrs_head, addrs_tail, saddrs); + + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "after add address %s\n", + GNUNET_a2s (in, in_len)); + + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "add address %s\n", + GNUNET_a2s (saddrs->addr, saddrs->addr_len)); + + addrs_lens++; +} + +/** * This method launch network interactions for each address we like to bind to. * * @param addr The address we will listen to. @@ -2919,7 +3110,7 @@ nat_address_cb (void *cls, * @return GNUNET_SYSERR in case of error. GNUNET_OK in case we are successfully listen to the address. */ static int -init_socket (const struct sockaddr *addr, +init_socket (struct sockaddr *addr, socklen_t in_len) { struct sockaddr_storage in_sto; @@ -2977,7 +3168,7 @@ init_socket (const struct sockaddr *addr, sto_len = in_len; } - addr = (struct sockaddr *) &in_sto; + //addr = (struct sockaddr *) &in_sto; in_len = sto_len; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Bound to `%s'\n", @@ -3034,6 +3225,7 @@ init_socket (const struct sockaddr *addr, return GNUNET_SYSERR; } + add_addr (addr, in_len); return GNUNET_OK; } @@ -3050,6 +3242,10 @@ nat_register () int i; struct Addresses *pos; + + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "starting nat register!\n"); + i = 0; saddrs = GNUNET_malloc ((addrs_lens + 1) * sizeof(struct sockaddr *)); @@ -3058,9 +3254,12 @@ nat_register () for (pos = addrs_head; NULL != pos; pos = pos->next) { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "registering address %s\n", + GNUNET_a2s (addrs_head->addr, addrs_head->addr_len)); + saddr_lens[i] = addrs_head->addr_len; - saddrs[i] = GNUNET_malloc (saddr_lens[i]); - saddrs[i] = addrs_head->addr; + saddrs[i] = GNUNET_memdup (addrs_head->addr, saddr_lens[i]); i++; @@ -3078,8 +3277,8 @@ nat_register () i = 0; - /*for (i = addrs_lens - 1; i >= 0; i--) - GNUNET_free (saddrs[i]);*/ + for (i = addrs_lens - 1; i >= 0; i--) + GNUNET_free (saddrs[i]); GNUNET_free (saddrs); GNUNET_free (saddr_lens); @@ -3093,22 +3292,6 @@ nat_register () } /** - * This method adds addresses to the DLL, that are later register at the NAT service. - */ -static void -add_addr (struct sockaddr *in, socklen_t in_len) -{ - - struct Addresses *saddrs; - - saddrs = GNUNET_new (struct Addresses); - saddrs->addr = in; - saddrs->addr_len = in_len; - GNUNET_CONTAINER_DLL_insert (addrs_head, addrs_tail, saddrs); - addrs_lens++; -} - -/** * This method is the callback called by the resolver API, and wraps method init_socket. * * @param cls The port we will bind to. @@ -3123,22 +3306,19 @@ init_socket_resolv (void *cls, struct sockaddr_in *v4; struct sockaddr_in6 *v6; struct sockaddr *in; - unsigned int *port; - port = cls; + (void) cls; if (NULL != addr) { if (AF_INET == addr->sa_family) { v4 = (struct sockaddr_in *) addr; - in = tcp_address_to_sockaddr_numeric_v4 (&in_len, *v4, *port);// _global); - add_addr (in, in_len); + in = tcp_address_to_sockaddr_numeric_v4 (&in_len, *v4, bind_port);// _global); } else if (AF_INET6 == addr->sa_family) { v6 = (struct sockaddr_in6 *) addr; - in = tcp_address_to_sockaddr_numeric_v6 (&in_len, *v6, *port);// _global); - add_addr (in, in_len); + in = tcp_address_to_sockaddr_numeric_v6 (&in_len, *v6, bind_port);// _global); } else { @@ -3149,13 +3329,17 @@ init_socket_resolv (void *cls, AF_INET6); return; } - init_socket (in, - in_len); + init_socket (in, in_len); } else { GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Address is NULL. This might be an error or the resolver finished resolving.\n"); + if (NULL == addrs_head){ + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "Resolver finished resolving, but we do not listen to an address!.\n"); + return; + } nat_register (); } } @@ -3221,12 +3405,9 @@ run (void *cls, return; } - // cp = GNUNET_strdup (bindto); - start = extract_address (bindto); - - if (1 == sscanf (bindto, "%u%1s", &port, dummy)) + if (1 == sscanf (bindto, "%u%1s", &bind_port, dummy)) { - po = tcp_address_to_sockaddr_port_only (bindto, &port); + po = tcp_address_to_sockaddr_port_only (bindto, &bind_port); addr_len_ipv4 = po->addr_len_ipv4; @@ -3238,46 +3419,53 @@ run (void *cls, if (NULL != po->addr_ipv4) { init_socket (po->addr_ipv4, addr_len_ipv4); - add_addr (po->addr_ipv4, addr_len_ipv4); } if (NULL != po->addr_ipv6) { addr_len_ipv6 = po->addr_len_ipv6; init_socket (po->addr_ipv6, addr_len_ipv6); - add_addr (po->addr_ipv6, addr_len_ipv6); } + GNUNET_free (po); nat_register (); + GNUNET_free (bindto); + + return; } - else if (1 == inet_pton (AF_INET, start, &v4.sin_addr)) + + start = extract_address (bindto); + + if (1 == inet_pton (AF_INET, start, &v4.sin_addr)) { - port = extract_port (bindto); + bind_port = extract_port (bindto); - in = tcp_address_to_sockaddr_numeric_v4 (&in_len, v4, port); + in = tcp_address_to_sockaddr_numeric_v4 (&in_len, v4, bind_port); init_socket (in, in_len); - add_addr (in, in_len); nat_register (); + GNUNET_free (bindto); + return; } - else if (1 == inet_pton (AF_INET6, start, &v6.sin6_addr)) + + if (1 == inet_pton (AF_INET6, start, &v6.sin6_addr)) { - port = extract_port (bindto); - in = tcp_address_to_sockaddr_numeric_v6 (&in_len, v6, port); + bind_port = extract_port (bindto); + in = tcp_address_to_sockaddr_numeric_v6 (&in_len, v6, bind_port); init_socket (in, in_len); - add_addr (in, in_len); nat_register (); + GNUNET_free (bindto); + return; } - else - { - port = extract_port (bindto); - resolve_request_handle = GNUNET_RESOLVER_ip_get (strtok_r (bindto, ":", - &rest), - AF_UNSPEC, - GNUNET_TIME_UNIT_MINUTES, - &init_socket_resolv, - &port); - } + + bind_port = extract_port (bindto); + + resolve_request_handle = GNUNET_RESOLVER_ip_get (strtok_r (bindto, ":", + &rest), + AF_UNSPEC, + GNUNET_TIME_UNIT_MINUTES, + &init_socket_resolv, + &port); GNUNET_free (bindto); } diff --git a/src/transport/test_communicator_tcp_rekey_peer2.conf b/src/transport/test_communicator_tcp_rekey_peer2.conf index 138650a3b..643b037b2 100644 --- a/src/transport/test_communicator_tcp_rekey_peer2.conf +++ b/src/transport/test_communicator_tcp_rekey_peer2.conf @@ -31,10 +31,10 @@ UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-resolver_test_2.sock UNIXPATH = $GNUNET_RUNTIME_DIR/test_gnunet-communicator-unix_2.sock [communicator-tcp] -#PREFIX = xterm -geometry 100x85 -T peer1 -e gdb --args +#PREFIX = xterm -geometry 100x85 -T peer2 -e gdb --args #PREFIX = valgrind --leak-check=full --track-origins=yes BINDTO = 60003 -DISABLE_V6 = YES +DISABLE_V6 = NO REKEY_INTERVAL = 100ms [communicator-udp] diff --git a/src/transport/transport-testing2.c b/src/transport/transport-testing2.c index 13944e9f0..e194b0159 100644 --- a/src/transport/transport-testing2.c +++ b/src/transport/transport-testing2.c @@ -897,7 +897,6 @@ shutdown_process (struct GNUNET_OS_Process *proc) GNUNET_OS_process_destroy (proc); } - static void shutdown_peerstore (void *cls) { @@ -905,7 +904,6 @@ shutdown_peerstore (void *cls) shutdown_process (proc); } - static void shutdown_communicator (void *cls) { @@ -941,8 +939,7 @@ communicator_start ( binary = GNUNET_OS_get_libexec_binary_path (binary_name); - tc_h->c_proc = GNUNET_OS_start_process_s (GNUNET_OS_USE_PIPE_CONTROL - | GNUNET_OS_INHERIT_STD_OUT_AND_ERR, + tc_h->c_proc = GNUNET_OS_start_process_s (GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, loprefix, binary, @@ -1026,10 +1023,8 @@ peerstore_start ( { char *binary; - LOG (GNUNET_ERROR_TYPE_DEBUG, "peerstore_start\n"); binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-peerstore"); - tc_h->ps_proc = GNUNET_OS_start_process (GNUNET_OS_USE_PIPE_CONTROL - | GNUNET_OS_INHERIT_STD_OUT_AND_ERR, + tc_h->ps_proc = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, NULL, @@ -1047,7 +1042,6 @@ peerstore_start ( GNUNET_free (binary); } - /** * @brief Start NAT * diff --git a/src/transport/transport_api2_communication.c b/src/transport/transport_api2_communication.c index d1e28cc36..b048ad851 100644 --- a/src/transport/transport_api2_communication.c +++ b/src/transport/transport_api2_communication.c @@ -1081,7 +1081,6 @@ GNUNET_TRANSPORT_communicator_address_add ( return ai; } - /** * Notify transport service about an address that this communicator no * longer provides for this peer. @@ -1100,6 +1099,20 @@ GNUNET_TRANSPORT_communicator_address_remove ( GNUNET_free (ai); } +/** + * Notify transport service that this communicator no longer provides all its addresses for this peer. + * + * @param ch The communicator handle. + */ +void +GNUNET_TRANSPORT_communicator_address_remove_all ( + struct GNUNET_TRANSPORT_CommunicatorHandle *ch) +{ + for (struct GNUNET_TRANSPORT_AddressIdentifier *ai = ch->ai_head; NULL != ai; + ai = ai->next) + GNUNET_TRANSPORT_communicator_address_remove (ai); +} + /* ************************* Backchannel *************************** */ diff --git a/src/util/gnunet-qr.c b/src/util/gnunet-qr.c index 83b2af2fc..451d61d40 100644 --- a/src/util/gnunet-qr.c +++ b/src/util/gnunet-qr.c @@ -36,7 +36,7 @@ /** * Video device to capture from. Sane default for GNU/Linux systems. */ -static char *device = "/dev/video0"; +static char *device; /** * --verbose option @@ -51,7 +51,7 @@ static int silent = false; /** * Handler exit code */ -static long unsigned int exit_code = 1; +static long unsigned int exit_code = 0; /** * Helper process we started. @@ -228,6 +228,8 @@ get_symbol (zbar_processor_t *proc) } /* initialize the Processor */ + if (NULL == device) + device = GNUNET_strdup ("/dev/video0"); if (0 != (rc = zbar_processor_init (proc, device, 1))) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -306,6 +308,7 @@ run_zbar () ret = GNUNET_strdup (data); /* clean up */ zbar_processor_destroy (proc); + GNUNET_free (device); return ret; } diff --git a/src/util/gnunet-uri.c b/src/util/gnunet-uri.c index 9443c9120..de0ff1f92 100644 --- a/src/util/gnunet-uri.c +++ b/src/util/gnunet-uri.c @@ -29,7 +29,7 @@ /** * Handler exit code */ -static long unsigned int exit_code = 1; +static long unsigned int exit_code = 0; /** * Helper process we started. |