From 3d2a951fa12546c09809f0a4d7e789ef8e971b03 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 4 May 2019 16:53:00 +0200 Subject: [PATCH] only use mono time in TNG HELLOs --- src/hello/hello-ng.c | 99 +++++++-------- src/include/gnunet_hello_lib.h | 67 +++++------ .../gnunet_transport_application_service.h | 20 ++-- src/transport/gnunet-communicator-udp.c | 10 +- src/transport/gnunet-service-tng.c | 36 +++--- src/transport/transport.h | 5 - src/transport/transport_api2_application.c | 113 ++++++++---------- 7 files changed, 152 insertions(+), 198 deletions(-) diff --git a/src/hello/hello-ng.c b/src/hello/hello-ng.c index 2d60b04f3..29ab17f9b 100644 --- a/src/hello/hello-ng.c +++ b/src/hello/hello-ng.c @@ -41,9 +41,9 @@ struct SignedAddress struct GNUNET_CRYPTO_EccSignaturePurpose purpose; /** - * When does the address expire. + * When was the address generated. */ - struct GNUNET_TIME_AbsoluteNBO expiration; + struct GNUNET_TIME_AbsoluteNBO mono_time; /** * Hash of the address. @@ -57,18 +57,19 @@ struct SignedAddress * * @param address text address at @a communicator to sign * @param nt network type of @a address - * @param expiration how long is @a address valid + * @param mono_time monotonic time at which @a address was valid * @param private_key signing key to use * @param result[out] where to write address record (allocated) * @param result_size[out] set to size of @a result */ void -GNUNET_HELLO_sign_address (const char *address, - enum GNUNET_NetworkType nt, - struct GNUNET_TIME_Absolute expiration, - const struct GNUNET_CRYPTO_EddsaPrivateKey *private_key, - void **result, - size_t *result_size) +GNUNET_HELLO_sign_address ( + const char *address, + enum GNUNET_NetworkType nt, + struct GNUNET_TIME_Absolute mono_time, + const struct GNUNET_CRYPTO_EddsaPrivateKey *private_key, + void **result, + size_t *result_size) { struct SignedAddress sa; struct GNUNET_CRYPTO_EddsaSignature sig; @@ -76,24 +77,19 @@ GNUNET_HELLO_sign_address (const char *address, sa.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_ADDRESS); sa.purpose.size = htonl (sizeof (sa)); - sa.expiration = GNUNET_TIME_absolute_hton (expiration); - GNUNET_CRYPTO_hash (address, - strlen (address), - &sa.h_addr); + sa.mono_time = GNUNET_TIME_absolute_hton (mono_time); + GNUNET_CRYPTO_hash (address, strlen (address), &sa.h_addr); GNUNET_assert (GNUNET_YES == - GNUNET_CRYPTO_eddsa_sign (private_key, - &sa.purpose, - &sig)); + GNUNET_CRYPTO_eddsa_sign (private_key, &sa.purpose, &sig)); sig_str = NULL; - (void) GNUNET_STRINGS_base64_encode (&sig, - sizeof (sig), - &sig_str); - *result_size = 1 + GNUNET_asprintf ((char **) result, - "%s;%llu;%u;%s", - sig_str, - (unsigned long long) expiration.abs_value_us, - (unsigned int) nt, - address); + (void) GNUNET_STRINGS_base64_encode (&sig, sizeof (sig), &sig_str); + *result_size = + 1 + GNUNET_asprintf ((char **) result, + "%s;%llu;%u;%s", + sig_str, + (unsigned long long) mono_time.abs_value_us, + (unsigned int) nt, + address); GNUNET_free (sig_str); } @@ -105,15 +101,15 @@ GNUNET_HELLO_sign_address (const char *address, * @param raw_size size of @a raw * @param pid public key to use for signature verification * @param nt[out] set to network type - * @param expiration[out] how long is the address valid + * @param mono_time[out] when was the address generated * @return NULL on error, otherwise the address */ char * GNUNET_HELLO_extract_address (const void *raw, - size_t raw_size, - const struct GNUNET_PeerIdentity *pid, - enum GNUNET_NetworkType *nt, - struct GNUNET_TIME_Absolute *expiration) + size_t raw_size, + const struct GNUNET_PeerIdentity *pid, + enum GNUNET_NetworkType *nt, + struct GNUNET_TIME_Absolute *mono_time) { const struct GNUNET_CRYPTO_EddsaPublicKey *public_key = &pid->public_key; const char *raws = raw; @@ -123,7 +119,7 @@ GNUNET_HELLO_extract_address (const void *raw, const char *sc2; const char *sc3; const char *raw_addr; - struct GNUNET_TIME_Absolute raw_expiration; + struct GNUNET_TIME_Absolute raw_mono_time; struct SignedAddress sa; struct GNUNET_CRYPTO_EddsaSignature *sig; @@ -132,40 +128,30 @@ GNUNET_HELLO_extract_address (const void *raw, GNUNET_break_op (0); return NULL; } - if (NULL == (sc = strchr (raws, - ';'))) + if (NULL == (sc = strchr (raws, ';'))) { GNUNET_break_op (0); return NULL; } - if (NULL == (sc2 = strchr (sc + 1, - ';'))) + if (NULL == (sc2 = strchr (sc + 1, ';'))) { GNUNET_break_op (0); return NULL; } - if (NULL == (sc3 = strchr (sc2 + 1, - ';'))) + if (NULL == (sc3 = strchr (sc2 + 1, ';'))) { GNUNET_break_op (0); return NULL; } - if (1 != sscanf (sc + 1, - "%llu;%u;", - &raw_us, - &raw_nt)) + if (1 != sscanf (sc + 1, "%llu;%u;", &raw_us, &raw_nt)) { GNUNET_break_op (0); return NULL; } - raw_expiration.abs_value_us = raw_us; - if (0 == GNUNET_TIME_absolute_get_remaining (raw_expiration).rel_value_us) - return NULL; /* expired */ + raw_mono_time.abs_value_us = raw_us; sig = NULL; if (sizeof (struct GNUNET_CRYPTO_EddsaSignature) != - GNUNET_STRINGS_base64_decode (raws, - sc - raws, - (void **) &sig)) + GNUNET_STRINGS_base64_decode (raws, sc - raws, (void **) &sig)) { GNUNET_break_op (0); GNUNET_free_non_null (sig); @@ -175,22 +161,20 @@ GNUNET_HELLO_extract_address (const void *raw, sa.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_ADDRESS); sa.purpose.size = htonl (sizeof (sa)); - sa.expiration = GNUNET_TIME_absolute_hton (raw_expiration); - GNUNET_CRYPTO_hash (raw_addr, - strlen (raw_addr), - &sa.h_addr); + sa.mono_time = GNUNET_TIME_absolute_hton (raw_mono_time); + GNUNET_CRYPTO_hash (raw_addr, strlen (raw_addr), &sa.h_addr); if (GNUNET_YES != GNUNET_CRYPTO_eddsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_ADDRESS, - &sa.purpose, - sig, - public_key)) + &sa.purpose, + sig, + public_key)) { GNUNET_break_op (0); GNUNET_free (sig); return NULL; } GNUNET_free (sig); - *expiration = raw_expiration; + *mono_time = raw_mono_time; *nt = (enum GNUNET_NetworkType) raw_nt; return GNUNET_strdup (raw_addr); } @@ -202,7 +186,7 @@ GNUNET_HELLO_extract_address (const void *raw, * * @param address a peer's address * @return NULL if the address is mal-formed, otherwise the prefix - */ + */ char * GNUNET_HELLO_address_to_prefix (const char *address) { @@ -211,6 +195,5 @@ GNUNET_HELLO_address_to_prefix (const char *address) dash = strchr (address, '-'); if (NULL == dash) return NULL; - return GNUNET_strndup (address, - dash - address); + return GNUNET_strndup (address, dash - address); } diff --git a/src/include/gnunet_hello_lib.h b/src/include/gnunet_hello_lib.h index c46e847f1..3b494f0a2 100644 --- a/src/include/gnunet_hello_lib.h +++ b/src/include/gnunet_hello_lib.h @@ -35,9 +35,8 @@ #define GNUNET_HELLO_LIB_H #ifdef __cplusplus -extern "C" -{ -#if 0 /* keep Emacsens' auto-indent happy */ +extern "C" { +#if 0 /* keep Emacsens' auto-indent happy */ } #endif #endif @@ -122,7 +121,6 @@ struct GNUNET_HELLO_Address * when a #GNUNET_HELLO_Message is created */ enum GNUNET_HELLO_AddressInfo local_info; - }; @@ -194,7 +192,7 @@ GNUNET_HELLO_address_check_option (const struct GNUNET_HELLO_Address *address, * * @param addr address to free */ -#define GNUNET_HELLO_address_free(addr) GNUNET_free(addr) +#define GNUNET_HELLO_address_free(addr) GNUNET_free (addr) GNUNET_NETWORK_STRUCT_BEGIN @@ -228,12 +226,10 @@ struct GNUNET_HELLO_Message * The public key of the peer. */ struct GNUNET_CRYPTO_EddsaPublicKey publicKey; - }; GNUNET_NETWORK_STRUCT_END - /** * Return HELLO type * @@ -273,10 +269,9 @@ GNUNET_HELLO_add_address (const struct GNUNET_HELLO_Address *address, * @return number of bytes written or 0, #GNUNET_SYSERR to signal the * end of the iteration. */ -typedef ssize_t -(*GNUNET_HELLO_GenerateAddressListCallback) (void *cls, - size_t max, - void *buf); +typedef ssize_t (*GNUNET_HELLO_GenerateAddressListCallback) (void *cls, + size_t max, + void *buf); /** @@ -356,10 +351,10 @@ GNUNET_HELLO_equals (const struct GNUNET_HELLO_Message *h1, * #GNUNET_NO to delete it from the HELLO * #GNUNET_SYSERR to stop iterating (but keep current address) */ -typedef int -(*GNUNET_HELLO_AddressIterator) (void *cls, - const struct GNUNET_HELLO_Address *address, - struct GNUNET_TIME_Absolute expiration); +typedef int (*GNUNET_HELLO_AddressIterator) ( + void *cls, + const struct GNUNET_HELLO_Address *address, + struct GNUNET_TIME_Absolute expiration); /** @@ -387,7 +382,8 @@ GNUNET_HELLO_get_last_expiration (const struct GNUNET_HELLO_Message *msg); struct GNUNET_HELLO_Message * GNUNET_HELLO_iterate_addresses (const struct GNUNET_HELLO_Message *msg, int return_modified, - GNUNET_HELLO_AddressIterator it, void *it_cls); + GNUNET_HELLO_AddressIterator it, + void *it_cls); /** @@ -404,11 +400,12 @@ GNUNET_HELLO_iterate_addresses (const struct GNUNET_HELLO_Message *msg, * @param it_cls closure for @a it */ void -GNUNET_HELLO_iterate_new_addresses (const struct GNUNET_HELLO_Message *new_hello, - const struct GNUNET_HELLO_Message *old_hello, - struct GNUNET_TIME_Absolute expiration_limit, - GNUNET_HELLO_AddressIterator it, - void *it_cls); +GNUNET_HELLO_iterate_new_addresses ( + const struct GNUNET_HELLO_Message *new_hello, + const struct GNUNET_HELLO_Message *old_hello, + struct GNUNET_TIME_Absolute expiration_limit, + GNUNET_HELLO_AddressIterator it, + void *it_cls); /** @@ -442,8 +439,8 @@ GNUNET_HELLO_get_header (struct GNUNET_HELLO_Message *hello); * @param name name of the transport plugin to load * @return NULL if a plugin with name @a name is not known/loadable */ -typedef struct GNUNET_TRANSPORT_PluginFunctions * -(*GNUNET_HELLO_TransportPluginsFind) (const char *name); +typedef struct GNUNET_TRANSPORT_PluginFunctions *( + *GNUNET_HELLO_TransportPluginsFind) (const char *name); /** @@ -474,7 +471,6 @@ GNUNET_HELLO_parse_uri (const char *uri, GNUNET_HELLO_TransportPluginsFind plugins_find); - /* NG API */ #include "gnunet_nt_lib.h" @@ -484,18 +480,19 @@ GNUNET_HELLO_parse_uri (const char *uri, * * @param address text address to sign * @param nt network type of @a address - * @param expiration how long is @a address valid + * @param mono_time when was @a address valid * @param private_key signing key to use * @param result[out] where to write address record (allocated) * @param result_size[out] set to size of @a result */ void -GNUNET_HELLO_sign_address (const char *address, - enum GNUNET_NetworkType nt, - struct GNUNET_TIME_Absolute expiration, - const struct GNUNET_CRYPTO_EddsaPrivateKey *private_key, - void **result, - size_t *result_size); +GNUNET_HELLO_sign_address ( + const char *address, + enum GNUNET_NetworkType nt, + struct GNUNET_TIME_Absolute mono_time, + const struct GNUNET_CRYPTO_EddsaPrivateKey *private_key, + void **result, + size_t *result_size); /** @@ -505,7 +502,7 @@ GNUNET_HELLO_sign_address (const char *address, * @param raw_size size of @a raw * @param pid public key to use for signature verification * @param nt[out] set to network type - * @param expiration[out] how long is the address valid + * @param mono_time[out] when was the address generated * @return NULL on error, otherwise the address */ char * @@ -513,7 +510,7 @@ GNUNET_HELLO_extract_address (const void *raw, size_t raw_size, const struct GNUNET_PeerIdentity *pid, enum GNUNET_NetworkType *nt, - struct GNUNET_TIME_Absolute *expiration); + struct GNUNET_TIME_Absolute *mono_time); /** @@ -527,7 +524,7 @@ char * GNUNET_HELLO_address_to_prefix (const char *address); -#if 0 /* keep Emacsens' auto-indent happy */ +#if 0 /* keep Emacsens' auto-indent happy */ { #endif #ifdef __cplusplus @@ -537,6 +534,6 @@ GNUNET_HELLO_address_to_prefix (const char *address); /* ifndef GNUNET_HELLO_LIB_H */ #endif -/** @} */ /* end of group */ +/** @} */ /* end of group */ /* end of gnunet_hello_lib.h */ diff --git a/src/include/gnunet_transport_application_service.h b/src/include/gnunet_transport_application_service.h index bbd4e3ddf..8c63a8234 100644 --- a/src/include/gnunet_transport_application_service.h +++ b/src/include/gnunet_transport_application_service.h @@ -50,7 +50,8 @@ struct GNUNET_TRANSPORT_ApplicationHandle; * @return ats application handle, NULL on error */ struct GNUNET_TRANSPORT_ApplicationHandle * -GNUNET_TRANSPORT_application_init (const struct GNUNET_CONFIGURATION_Handle *cfg); +GNUNET_TRANSPORT_application_init ( + const struct GNUNET_CONFIGURATION_Handle *cfg); /** @@ -59,7 +60,8 @@ GNUNET_TRANSPORT_application_init (const struct GNUNET_CONFIGURATION_Handle *cfg * @param ch handle to destroy */ void -GNUNET_TRANSPORT_application_done (struct GNUNET_TRANSPORT_ApplicationHandle *ch); +GNUNET_TRANSPORT_application_done ( + struct GNUNET_TRANSPORT_ApplicationHandle *ch); /** @@ -72,21 +74,19 @@ GNUNET_TRANSPORT_application_done (struct GNUNET_TRANSPORT_ApplicationHandle *ch * * @param ch handle * @param peer identity of the peer we have an address for - * @param expiration when does @a addr expire; used by TRANSPORT to know when - * to definitively give up attempting to validate * @param nt network type of @a addr (as claimed by the other peer); * used by TRANSPORT to avoid trying @a addr's that really cannot work * due to network type missmatches * @param addr address to validate */ void -GNUNET_TRANSPORT_application_validate (struct GNUNET_TRANSPORT_ApplicationHandle *ch, - const struct GNUNET_PeerIdentity *peer, - struct GNUNET_TIME_Absolute expiration, - enum GNUNET_NetworkType nt, - const char *addr); +GNUNET_TRANSPORT_application_validate ( + struct GNUNET_TRANSPORT_ApplicationHandle *ch, + const struct GNUNET_PeerIdentity *peer, + enum GNUNET_NetworkType nt, + const char *addr); -/** @} */ /* end of group */ +/** @} */ /* end of group */ #endif /* end of file gnunet_ats_application_service.h */ diff --git a/src/transport/gnunet-communicator-udp.c b/src/transport/gnunet-communicator-udp.c index 9420b9b5c..1c2063d58 100644 --- a/src/transport/gnunet-communicator-udp.c +++ b/src/transport/gnunet-communicator-udp.c @@ -1630,23 +1630,15 @@ sock_read (void *cls) &ub->sender.public_key)) { char *addr_s; - struct GNUNET_TIME_Absolute expiration; enum GNUNET_NetworkType nt; addr_s = sockaddr_to_udpaddr_string ((const struct sockaddr *) &sa, salen); GNUNET_STATISTICS_update (stats, "# broadcasts received", 1, GNUNET_NO); - /* expire at the broadcast frequency, as then we'll get the next one - * anyway */ - expiration = GNUNET_TIME_relative_to_absolute (BROADCAST_FREQUENCY); /* use our own mechanism to determine network type */ nt = GNUNET_NT_scanner_get_type (is, (const struct sockaddr *) &sa, salen); - GNUNET_TRANSPORT_application_validate (ah, - &ub->sender, - expiration, - nt, - addr_s); + GNUNET_TRANSPORT_application_validate (ah, &ub->sender, nt, addr_s); GNUNET_free (addr_s); return; } diff --git a/src/transport/gnunet-service-tng.c b/src/transport/gnunet-service-tng.c index a8f70986b..95ea102df 100644 --- a/src/transport/gnunet-service-tng.c +++ b/src/transport/gnunet-service-tng.c @@ -2546,6 +2546,16 @@ static struct PendingAcknowledgement *pa_tail; */ static unsigned int pa_count; +/** + * Monotonic time we use for HELLOs generated at this time. TODO: we + * should increase this value from time to time (i.e. whenever a + * `struct AddressListEntry` actually expires), but IF we do this, we + * must also update *all* (remaining) addresses in the PEERSTORE at + * that time! (So for now only increased when the peer is restarted, + * which hopefully roughly matches whenever our addresses change.) + */ +static struct GNUNET_TIME_Absolute hello_mono_time; + /** * Get an offset into the transmission history buffer for `struct @@ -4657,7 +4667,7 @@ store_pi (void *cls) expiration = GNUNET_TIME_relative_to_absolute (ale->expiration); GNUNET_HELLO_sign_address (ale->address, ale->nt, - expiration, + hello_mono_time, GST_my_private_key, &addr, &addr_len); @@ -8442,19 +8452,15 @@ check_known_address (void *cls, * * @param pid peer the @a address is for * @param address an address to reach @a pid (presumably) - * @param expiration when did @a pid claim @a address will become invalid */ static void start_address_validation (const struct GNUNET_PeerIdentity *pid, - const char *address, - struct GNUNET_TIME_Absolute expiration) + const char *address) { struct GNUNET_TIME_Absolute now; struct ValidationState *vs; struct CheckKnownAddressContext ckac = {.address = address, .vs = NULL}; - if (0 == GNUNET_TIME_absolute_get_remaining (expiration).rel_value_us) - return; /* expired */ (void) GNUNET_CONTAINER_multipeermap_get_multiple (validation_map, pid, &check_known_address, @@ -8479,7 +8485,8 @@ start_address_validation (const struct GNUNET_PeerIdentity *pid, now = GNUNET_TIME_absolute_get (); vs = GNUNET_new (struct ValidationState); vs->pid = *pid; - vs->valid_until = expiration; + vs->valid_until = + GNUNET_TIME_relative_to_absolute (ADDRESS_VALIDATION_LIFETIME); vs->first_challenge_use = now; vs->validation_rtt = GNUNET_TIME_UNIT_FOREVER_REL; GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE, @@ -8524,9 +8531,7 @@ handle_hello (void *cls, GNUNET_break (0); return; } - start_address_validation (&pr->pid, - (const char *) record->value, - record->expiry); + start_address_validation (&pr->pid, (const char *) record->value); } @@ -8602,7 +8607,7 @@ handle_address_consider_verify ( struct TransportClient *tc = cls; char *address; enum GNUNET_NetworkType nt; - struct GNUNET_TIME_Absolute expiration; + struct GNUNET_TIME_Absolute mono_time; (void) cls; // OPTIMIZE-FIXME: checking that we know this address already should @@ -8614,13 +8619,13 @@ handle_address_consider_verify ( ntohs (hdr->header.size) - sizeof (*hdr), &hdr->peer, &nt, - &expiration); + &mono_time); if (NULL == address) { GNUNET_break_op (0); return; } - start_address_validation (&hdr->peer, address, expiration); + start_address_validation (&hdr->peer, address); GNUNET_free (address); GNUNET_SERVICE_client_continue (tc->client); } @@ -8657,9 +8662,7 @@ handle_request_hello_validation (void *cls, { struct TransportClient *tc = cls; - start_address_validation (&m->peer, - (const char *) &m[1], - GNUNET_TIME_absolute_ntoh (m->expiration)); + start_address_validation (&m->peer, (const char *) &m[1]); GNUNET_SERVICE_client_continue (tc->client); } @@ -8895,6 +8898,7 @@ run (void *cls, (void) cls; (void) service; /* setup globals */ + hello_mono_time = GNUNET_TIME_absolute_get_monotonic (c); GST_cfg = c; backtalkers = GNUNET_CONTAINER_multipeermap_create (16, GNUNET_YES); pending_acks = GNUNET_CONTAINER_multishortmap_create (32768, GNUNET_YES); diff --git a/src/transport/transport.h b/src/transport/transport.h index ed89940cc..4ba628112 100644 --- a/src/transport/transport.h +++ b/src/transport/transport.h @@ -1203,11 +1203,6 @@ struct RequestHelloValidationMessage */ struct GNUNET_PeerIdentity peer; - /** - * When does the address expire? - */ - struct GNUNET_TIME_AbsoluteNBO expiration; - /* followed by 0-terminated address to validate */ }; diff --git a/src/transport/transport_api2_application.c b/src/transport/transport_api2_application.c index 414a21fe4..49f0f36c7 100644 --- a/src/transport/transport_api2_application.c +++ b/src/transport/transport_api2_application.c @@ -29,7 +29,8 @@ #include "transport.h" -#define LOG(kind,...) GNUNET_log_from(kind, "transport-application-api", __VA_ARGS__) +#define LOG(kind, ...) \ + GNUNET_log_from (kind, "transport-application-api", __VA_ARGS__) /** @@ -132,9 +133,7 @@ force_reconnect (struct GNUNET_TRANSPORT_ApplicationHandle *ch) ch->mq = NULL; } ch->backoff = GNUNET_TIME_STD_BACKOFF (ch->backoff); - ch->task = GNUNET_SCHEDULER_add_delayed (ch->backoff, - &reconnect_task, - ch); + ch->task = GNUNET_SCHEDULER_add_delayed (ch->backoff, &reconnect_task, ch); } @@ -146,8 +145,7 @@ force_reconnect (struct GNUNET_TRANSPORT_ApplicationHandle *ch) * @param error details about the error */ static void -error_handler (void *cls, - enum GNUNET_MQ_Error error) +error_handler (void *cls, enum GNUNET_MQ_Error error) { struct GNUNET_TRANSPORT_ApplicationHandle *ch = cls; @@ -179,8 +177,7 @@ transmit_suggestion (void *cls, if (NULL == ch->mq) return GNUNET_SYSERR; - ev = GNUNET_MQ_msg (m, - GNUNET_MESSAGE_TYPE_TRANSPORT_SUGGEST); + ev = GNUNET_MQ_msg (m, GNUNET_MESSAGE_TYPE_TRANSPORT_SUGGEST); m->pk = htonl ((uint32_t) sh->pk); m->bw = sh->bw; m->peer = *peer; @@ -197,16 +194,11 @@ transmit_suggestion (void *cls, static void reconnect (struct GNUNET_TRANSPORT_ApplicationHandle *ch) { - static const struct GNUNET_MQ_MessageHandler handlers[] = { - { NULL, 0, 0 } - }; + static const struct GNUNET_MQ_MessageHandler handlers[] = {{NULL, 0, 0}}; GNUNET_assert (NULL == ch->mq); - ch->mq = GNUNET_CLIENT_connect (ch->cfg, - "transport", - handlers, - &error_handler, - ch); + ch->mq = + GNUNET_CLIENT_connect (ch->cfg, "transport", handlers, &error_handler, ch); if (NULL == ch->mq) { force_reconnect (ch); @@ -225,14 +217,14 @@ reconnect (struct GNUNET_TRANSPORT_ApplicationHandle *ch) * @return transport application handle, NULL on error */ struct GNUNET_TRANSPORT_ApplicationHandle * -GNUNET_TRANSPORT_application_init (const struct GNUNET_CONFIGURATION_Handle *cfg) +GNUNET_TRANSPORT_application_init ( + const struct GNUNET_CONFIGURATION_Handle *cfg) { struct GNUNET_TRANSPORT_ApplicationHandle *ch; ch = GNUNET_new (struct GNUNET_TRANSPORT_ApplicationHandle); ch->cfg = cfg; - ch->sug_requests = GNUNET_CONTAINER_multipeermap_create (32, - GNUNET_YES); + ch->sug_requests = GNUNET_CONTAINER_multipeermap_create (32, GNUNET_YES); reconnect (ch); return ch; } @@ -248,9 +240,7 @@ GNUNET_TRANSPORT_application_init (const struct GNUNET_CONFIGURATION_Handle *cfg * @return #GNUNET_OK (continue to iterate) */ static int -free_sug_handle (void *cls, - const struct GNUNET_PeerIdentity *key, - void *value) +free_sug_handle (void *cls, const struct GNUNET_PeerIdentity *key, void *value) { struct GNUNET_TRANSPORT_ApplicationSuggestHandle *cur = value; @@ -265,7 +255,8 @@ free_sug_handle (void *cls, * @param ch handle to release */ void -GNUNET_TRANSPORT_application_done (struct GNUNET_TRANSPORT_ApplicationHandle *ch) +GNUNET_TRANSPORT_application_done ( + struct GNUNET_TRANSPORT_ApplicationHandle *ch) { if (NULL != ch->mq) { @@ -299,10 +290,11 @@ GNUNET_TRANSPORT_application_done (struct GNUNET_TRANSPORT_ApplicationHandle *ch * @return suggest handle, NULL if a request is already pending */ struct GNUNET_TRANSPORT_ApplicationSuggestHandle * -GNUNET_TRANSPORT_application_suggest (struct GNUNET_TRANSPORT_ApplicationHandle *ch, - const struct GNUNET_PeerIdentity *peer, - enum GNUNET_MQ_PreferenceKind pk, - struct GNUNET_BANDWIDTH_Value32NBO bw) +GNUNET_TRANSPORT_application_suggest ( + struct GNUNET_TRANSPORT_ApplicationHandle *ch, + const struct GNUNET_PeerIdentity *peer, + enum GNUNET_MQ_PreferenceKind pk, + struct GNUNET_BANDWIDTH_Value32NBO bw) { struct GNUNET_TRANSPORT_ApplicationSuggestHandle *s; @@ -311,19 +303,17 @@ GNUNET_TRANSPORT_application_suggest (struct GNUNET_TRANSPORT_ApplicationHandle s->id = *peer; s->pk = pk; s->bw = bw; - (void) GNUNET_CONTAINER_multipeermap_put (ch->sug_requests, - &s->id, - s, - GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); + (void) GNUNET_CONTAINER_multipeermap_put ( + ch->sug_requests, + &s->id, + s, + GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); LOG (GNUNET_ERROR_TYPE_DEBUG, "Requesting TRANSPORT to suggest address for `%s'\n", GNUNET_i2s (peer)); if (NULL == ch->mq) return s; - GNUNET_assert (GNUNET_OK == - transmit_suggestion (ch, - &s->id, - s)); + GNUNET_assert (GNUNET_OK == transmit_suggestion (ch, &s->id, s)); return s; } @@ -334,7 +324,8 @@ GNUNET_TRANSPORT_application_suggest (struct GNUNET_TRANSPORT_ApplicationHandle * @param sh handle to stop */ void -GNUNET_TRANSPORT_application_suggest_cancel (struct GNUNET_TRANSPORT_ApplicationSuggestHandle *sh) +GNUNET_TRANSPORT_application_suggest_cancel ( + struct GNUNET_TRANSPORT_ApplicationSuggestHandle *sh) { struct GNUNET_TRANSPORT_ApplicationHandle *ch = sh->ch; struct GNUNET_MQ_Envelope *ev; @@ -343,27 +334,23 @@ GNUNET_TRANSPORT_application_suggest_cancel (struct GNUNET_TRANSPORT_Application LOG (GNUNET_ERROR_TYPE_DEBUG, "Telling TRANSPORT we no longer care for an address for `%s'\n", GNUNET_i2s (&sh->id)); - GNUNET_assert (GNUNET_OK == - GNUNET_CONTAINER_multipeermap_remove (ch->sug_requests, - &sh->id, - sh)); + GNUNET_assert ( + GNUNET_OK == + GNUNET_CONTAINER_multipeermap_remove (ch->sug_requests, &sh->id, sh)); if (NULL == ch->mq) { GNUNET_free (sh); return; } - ev = GNUNET_MQ_msg (m, - GNUNET_MESSAGE_TYPE_TRANSPORT_SUGGEST_CANCEL); + ev = GNUNET_MQ_msg (m, GNUNET_MESSAGE_TYPE_TRANSPORT_SUGGEST_CANCEL); m->pk = htonl ((uint32_t) sh->pk); m->bw = sh->bw; m->peer = sh->id; - GNUNET_MQ_send (ch->mq, - ev); + GNUNET_MQ_send (ch->mq, ev); GNUNET_free (sh); } - /** * An application (or a communicator) has received a HELLO (or other address * data of another peer) and wants TRANSPORT to validate that the address is @@ -374,19 +361,17 @@ GNUNET_TRANSPORT_application_suggest_cancel (struct GNUNET_TRANSPORT_Application * * @param ch handle * @param peer identity of the peer we have an address for - * @param expiration when does @a addr expire; used by TRANSPORT to know when - * to definitively give up attempting to validate * @param nt network type of @a addr (as claimed by the other peer); * used by TRANSPORT to avoid trying @a addr's that really cannot work * due to network type missmatches * @param addr address to validate */ void -GNUNET_TRANSPORT_application_validate (struct GNUNET_TRANSPORT_ApplicationHandle *ch, - const struct GNUNET_PeerIdentity *peer, - struct GNUNET_TIME_Absolute expiration, - enum GNUNET_NetworkType nt, - const char *addr) +GNUNET_TRANSPORT_application_validate ( + struct GNUNET_TRANSPORT_ApplicationHandle *ch, + const struct GNUNET_PeerIdentity *peer, + enum GNUNET_NetworkType nt, + const char *addr) { struct GNUNET_MQ_Envelope *ev; struct RequestHelloValidationMessage *m; @@ -394,24 +379,22 @@ GNUNET_TRANSPORT_application_validate (struct GNUNET_TRANSPORT_ApplicationHandle if (NULL == ch->mq) { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Address validation for %s:%s skipped as transport is not connected\n", - GNUNET_i2s (peer), - addr); + GNUNET_log ( + GNUNET_ERROR_TYPE_WARNING, + "Address validation for %s:%s skipped as transport is not connected\n", + GNUNET_i2s (peer), + addr); return; } alen = strlen (addr) + 1; - ev = GNUNET_MQ_msg_extra (m, - alen, - GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_HELLO_VALIDATION); + ev = + GNUNET_MQ_msg_extra (m, + alen, + GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_HELLO_VALIDATION); m->peer = *peer; - m->expiration = GNUNET_TIME_absolute_hton (expiration); m->nt = htonl ((uint32_t) nt); - memcpy (&m[1], - addr, - alen); - GNUNET_MQ_send (ch->mq, - ev); + memcpy (&m[1], addr, alen); + GNUNET_MQ_send (ch->mq, ev); } -- 2.25.1