From: Nathan S. Evans Date: Tue, 19 Jan 2010 14:20:54 +0000 (+0000) Subject: pre-commit X-Git-Tag: initial-import-from-subversion-38251~22928 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=b6dbf7e98bb79907562bf67d423b67a030b503e7;p=oweals%2Fgnunet.git pre-commit --- diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index 6b8e0e7dd..acdac052c 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c @@ -223,7 +223,7 @@ struct MessageQueue * How important is the message? */ unsigned int priority; - + }; @@ -672,7 +672,7 @@ transmit_to_client_callback (void *cls, size_t size, void *buf) if (buf == NULL) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Transmission to client failed, closing connection.\n"); + "Transmission to client failed, closing connection.\n"); /* fatal error with client, free message queue! */ while (NULL != (q = client->message_queue_head)) { @@ -693,8 +693,8 @@ transmit_to_client_callback (void *cls, size_t size, void *buf) break; #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Transmitting message of type %u to client.\n", - ntohs (msg->type)); + "Transmitting message of type %u to client.\n", + ntohs (msg->type)); #endif client->message_queue_head = q->next; if (q->next == NULL) @@ -815,9 +815,7 @@ try_alternative_plugins (struct NeighbourList *neighbour) * disconnected or must we ask all plugins to * disconnect? */ -static void -disconnect_neighbour (struct NeighbourList *n, - int check); +static void disconnect_neighbour (struct NeighbourList *n, int check); /** @@ -827,8 +825,7 @@ disconnect_neighbour (struct NeighbourList *n, * * @param neighbour target peer for which to check the plugins */ -static void -try_transmission_to_peer (struct NeighbourList *neighbour); +static void try_transmission_to_peer (struct NeighbourList *neighbour); /** @@ -867,13 +864,15 @@ transmit_send_continuation (void *cls, GNUNET_assert (rl != NULL); if (result == GNUNET_OK) { - rl->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); + rl->timeout = + GNUNET_TIME_relative_to_absolute + (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); } else { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Transmission to peer `%s' failed, marking connection as down.\n", - GNUNET_i2s(target)); + "Transmission to peer `%s' failed, marking connection as down.\n", + GNUNET_i2s (target)); rl->connected = GNUNET_NO; } if (!mq->internal_msg) @@ -881,9 +880,8 @@ transmit_send_continuation (void *cls, if (mq->client != NULL) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Notifying client %p about failed transission to peer `%4s'.\n", - mq->client, - GNUNET_i2s(target)); + "Notifying client %p about failed transission to peer `%4s'.\n", + mq->client, GNUNET_i2s (target)); send_ok_msg.header.size = htons (sizeof (send_ok_msg)); send_ok_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK); send_ok_msg.success = htonl (result); @@ -896,8 +894,8 @@ transmit_send_continuation (void *cls, another message (if available) */ if (result == GNUNET_OK) try_transmission_to_peer (n); - else - disconnect_neighbour (n, GNUNET_YES); + else + disconnect_neighbour (n, GNUNET_YES); } @@ -958,9 +956,9 @@ try_transmission_to_peer (struct NeighbourList *neighbour) rl->connect_attempts++; rl->connected = GNUNET_YES; #if DEBUG_TRANSPORT - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Establishing fresh connection with `%4s' via plugin `%s'\n", - GNUNET_i2s (&neighbour->id), rl->plugin->short_name); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Establishing fresh connection with `%4s' via plugin `%s'\n", + GNUNET_i2s (&neighbour->id), rl->plugin->short_name); #endif } neighbour->messages = mq->next; @@ -974,11 +972,11 @@ try_transmission_to_peer (struct NeighbourList *neighbour) GNUNET_i2s (&neighbour->id), rl->plugin->short_name); #endif rl->plugin->api->send (rl->plugin->api->cls, - &neighbour->id, - mq->priority, - mq->message, - GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, - &transmit_send_continuation, mq); + &neighbour->id, + mq->priority, + mq->message, + GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, + &transmit_send_continuation, mq); } @@ -993,7 +991,7 @@ try_transmission_to_peer (struct NeighbourList *neighbour) */ static void transmit_to_peer (struct TransportClient *client, - unsigned int priority, + unsigned int priority, const struct GNUNET_MessageHeader *msg, int is_internal, struct NeighbourList *neighbour) { @@ -1100,8 +1098,7 @@ refresh_hello () #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, - "Refreshing my `%s'\n", - "HELLO"); + "Refreshing my `%s'\n", "HELLO"); #endif gc.plug_pos = plugins; gc.addr_pos = plugins != NULL ? plugins->addresses : NULL; @@ -1125,9 +1122,8 @@ refresh_hello () { #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, - "Transmitting updated `%s' to neighbour `%4s'\n", - "HELLO", - GNUNET_i2s(&npos->id)); + "Transmitting updated `%s' to neighbour `%4s'\n", + "HELLO", GNUNET_i2s (&npos->id)); #endif transmit_to_peer (NULL, 0, (const struct GNUNET_MessageHeader *) our_hello, @@ -1264,7 +1260,7 @@ plugin_env_notify_address (void *cls, #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Plugin `%s' informs us about a new address `%s'\n", name, - GNUNET_a2s(addr, addrlen)); + GNUNET_a2s (addr, addrlen)); #endif al = GNUNET_malloc (sizeof (struct AddressList) + addrlen); al->addr = &al[1]; @@ -1294,7 +1290,7 @@ notify_clients_connect (const struct GNUNET_PeerIdentity *peer, #endif cim.header.size = htons (sizeof (struct ConnectInfoMessage)); cim.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT); - cim.quota_out = htonl (GNUNET_CONSTANTS_DEFAULT_BPM_IN_OUT / (60*1000)); + cim.quota_out = htonl (GNUNET_CONSTANTS_DEFAULT_BPM_IN_OUT / (60 * 1000)); cim.latency = GNUNET_TIME_relative_hton (latency); memcpy (&cim.id, peer, sizeof (struct GNUNET_PeerIdentity)); cpos = clients; @@ -1400,9 +1396,9 @@ cleanup_validation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) "HELLO", GNUNET_i2s (&pid)); #endif GNUNET_PEERINFO_add_peer (cfg, sched, &pid, hello); - n = find_neighbour (&pid); - if (NULL != n) - try_transmission_to_peer (n); + n = find_neighbour (&pid); + if (NULL != n) + try_transmission_to_peer (n); GNUNET_free (hello); while (NULL != (va = pos->addresses)) { @@ -1416,7 +1412,7 @@ cleanup_validation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) else pos = prev->next; continue; - } + } prev = pos; pos = pos->next; } @@ -1427,14 +1423,14 @@ cleanup_validation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { first = pending_validations->timeout; pos = pending_validations; - while (pos != NULL) - { - first = GNUNET_TIME_absolute_min (first, pos->timeout); - pos = pos->next; - } + while (pos != NULL) + { + first = GNUNET_TIME_absolute_min (first, pos->timeout); + pos = pos->next; + } GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_absolute_get_remaining (first), - &cleanup_validation, NULL); + GNUNET_TIME_absolute_get_remaining + (first), &cleanup_validation, NULL); } } @@ -1458,10 +1454,9 @@ cleanup_validation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) */ static void plugin_env_notify_validation (void *cls, - const char *name, - const struct GNUNET_PeerIdentity *peer, - uint32_t challenge, - const char *sender_addr) + const char *name, + const struct GNUNET_PeerIdentity *peer, + uint32_t challenge, const char *sender_addr) { unsigned int not_done; int matched; @@ -1476,8 +1471,7 @@ plugin_env_notify_validation (void *cls, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &id.hashPubKey); - if (0 == - memcmp (peer, &id, sizeof (struct GNUNET_PeerIdentity))) + if (0 == memcmp (peer, &id, sizeof (struct GNUNET_PeerIdentity))) break; pos = pos->next; } @@ -1487,7 +1481,7 @@ plugin_env_notify_validation (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_INFO, _ ("Received validation response but have no record of any validation request for `%4s'. Ignoring.\n"), - GNUNET_i2s(peer)); + GNUNET_i2s (peer)); return; } not_done = 0; @@ -1496,23 +1490,23 @@ plugin_env_notify_validation (void *cls, while (va != NULL) { if (va->challenge == challenge) - { + { #if DEBUG_TRANSPORT - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Confirmed validity of address, peer `%4s' has address `%s'.\n", - GNUNET_i2s (peer), - GNUNET_a2s ((const struct sockaddr*) &va[1], - va->addr_len)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Confirmed validity of address, peer `%4s' has address `%s'.\n", + GNUNET_i2s (peer), + GNUNET_a2s ((const struct sockaddr *) &va[1], + va->addr_len)); #endif - GNUNET_log (GNUNET_ERROR_TYPE_INFO | GNUNET_ERROR_TYPE_BULK, - _("Another peer saw us using the address `%s' via `%s'. If this is not plausible, this address should be listed in the configuration as implausible to avoid MiM attacks.\n"), - sender_addr, - name); - va->ok = GNUNET_YES; - va->expiration = - GNUNET_TIME_relative_to_absolute (HELLO_ADDRESS_EXPIRATION); - matched = GNUNET_YES; - } + GNUNET_log (GNUNET_ERROR_TYPE_INFO | GNUNET_ERROR_TYPE_BULK, + _ + ("Another peer saw us using the address `%s' via `%s'. If this is not plausible, this address should be listed in the configuration as implausible to avoid MiM attacks.\n"), + sender_addr, name); + va->ok = GNUNET_YES; + va->expiration = + GNUNET_TIME_relative_to_absolute (HELLO_ADDRESS_EXPIRATION); + matched = GNUNET_YES; + } if (va->ok != GNUNET_YES) not_done++; va = va->next; @@ -1529,24 +1523,20 @@ plugin_env_notify_validation (void *cls, { #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "All addresses validated, will now construct `%s' for `%4s'.\n", - "HELLO", - GNUNET_i2s (peer)); + "All addresses validated, will now construct `%s' for `%4s'.\n", + "HELLO", GNUNET_i2s (peer)); #endif pos->timeout.value = 0; GNUNET_SCHEDULER_add_with_priority (sched, - GNUNET_SCHEDULER_PRIORITY_IDLE, - &cleanup_validation, NULL); + GNUNET_SCHEDULER_PRIORITY_IDLE, + &cleanup_validation, NULL); } else { #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Still waiting for %u additional `%s' messages before constructing `%s' for `%4s'.\n", - not_done, - "PONG", - "HELLO", - GNUNET_i2s (peer)); + "Still waiting for %u additional `%s' messages before constructing `%s' for `%4s'.\n", + not_done, "PONG", "HELLO", GNUNET_i2s (peer)); #endif } } @@ -1604,14 +1594,12 @@ run_validation (void *cls, return GNUNET_OK; } GNUNET_CRYPTO_hash (&e->publicKey, - sizeof (struct - GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), - &id.hashPubKey); + sizeof (struct + GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), + &id.hashPubKey); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Scheduling validation of address `%s' via `%s' for `%4s'\n", - GNUNET_a2s(addr, addrlen), - tname, - GNUNET_i2s(&id)); + "Scheduling validation of address `%s' via `%s' for `%4s'\n", + GNUNET_a2s (addr, addrlen), tname, GNUNET_i2s (&id)); va = GNUNET_malloc (sizeof (struct ValidationAddress) + addrlen); va->next = e->addresses; @@ -1619,7 +1607,7 @@ run_validation (void *cls, va->transport_name = GNUNET_strdup (tname); va->addr_len = addrlen; va->challenge = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, - (unsigned int) -1); + (unsigned int) -1); memcpy (&va[1], addr, addrlen); return GNUNET_OK; } @@ -1633,8 +1621,7 @@ run_validation (void *cls, static void check_hello_validated (void *cls, const struct GNUNET_PeerIdentity *peer, - const struct GNUNET_HELLO_Message *h, - uint32_t trust) + const struct GNUNET_HELLO_Message *h, uint32_t trust) { struct CheckHelloValidatedContext *chvc = cls; struct ValidationAddress *va; @@ -1672,13 +1659,11 @@ check_hello_validated (void *cls, if (h != NULL) return; /* wait for next call */ /* finally, transmit validation attempts */ - GNUNET_assert (GNUNET_OK == - GNUNET_HELLO_get_id (chvc->hello, - &apeer)); + GNUNET_assert (GNUNET_OK == GNUNET_HELLO_get_id (chvc->hello, &apeer)); #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Ready to validate addresses from `%s' message for peer `%4s'\n", - "HELLO", GNUNET_i2s (&apeer)); + "Ready to validate addresses from `%s' message for peer `%4s'\n", + "HELLO", GNUNET_i2s (&apeer)); #endif va = chvc->e->addresses; while (va != NULL) @@ -1688,25 +1673,24 @@ check_hello_validated (void *cls, "Establishing `%s' connection to validate `%s' address `%s' of `%4s'\n", va->transport_name, "HELLO", - GNUNET_a2s ((const struct sockaddr*) &va[1], - va->addr_len), - GNUNET_i2s (&apeer)); + GNUNET_a2s ((const struct sockaddr *) &va[1], + va->addr_len), GNUNET_i2s (&apeer)); #endif tp = find_transport (va->transport_name); GNUNET_assert (tp != NULL); if (GNUNET_OK != tp->api->validate (tp->api->cls, - &apeer, - va->challenge, - HELLO_VERIFICATION_TIMEOUT, - &va[1], - va->addr_len)) + &apeer, + va->challenge, + HELLO_VERIFICATION_TIMEOUT, + &va[1], va->addr_len)) va->ok = GNUNET_SYSERR; va = va->next; } GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_absolute_get_remaining (chvc->e->timeout), - &cleanup_validation, NULL); + GNUNET_TIME_absolute_get_remaining (chvc->e-> + timeout), + &cleanup_validation, NULL); GNUNET_free (chvc); } @@ -1767,10 +1751,10 @@ process_hello (struct TransportPlugin *plugin, { /* TODO: call to stats? */ #if DEBUG_TRANSPORT - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "`%s' message for peer `%4s' is already pending; ignoring new message\n", - "HELLO", GNUNET_i2s (&target)); -#endif + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "`%s' message for peer `%4s' is already pending; ignoring new message\n", + "HELLO", GNUNET_i2s (&target)); +#endif return GNUNET_OK; } e = e->next; @@ -1782,11 +1766,11 @@ process_hello (struct TransportPlugin *plugin, /* finally, check if HELLO was previously validated (continuation will then schedule actual validation) */ chvc->piter = GNUNET_PEERINFO_iterate (cfg, - sched, - &target, - 0, - HELLO_VERIFICATION_TIMEOUT, - &check_hello_validated, chvc); + sched, + &target, + 0, + HELLO_VERIFICATION_TIMEOUT, + &check_hello_validated, chvc); return GNUNET_OK; } @@ -1805,29 +1789,27 @@ process_hello (struct TransportPlugin *plugin, * disconnect? */ static void -disconnect_neighbour (struct NeighbourList *n, - int check) +disconnect_neighbour (struct NeighbourList *n, int check) { struct ReadyList *rpos; struct NeighbourList *npos; struct NeighbourList *nprev; struct MessageQueue *mq; - + if (GNUNET_YES == check) { rpos = n->plugins; while (NULL != rpos) - { - if (GNUNET_YES == rpos->connected) - return; /* still connected */ - rpos = rpos->next; - } + { + if (GNUNET_YES == rpos->connected) + return; /* still connected */ + rpos = rpos->next; + } } #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, - "Disconnecting from `%4s'\n", - GNUNET_i2s(&n->id)); + "Disconnecting from `%4s'\n", GNUNET_i2s (&n->id)); #endif /* remove n from neighbours list */ nprev = NULL; @@ -1852,8 +1834,7 @@ disconnect_neighbour (struct NeighbourList *n, n->plugins = rpos->next; GNUNET_assert (rpos->neighbour == n); if (GNUNET_YES == rpos->connected) - rpos->plugin->api->disconnect (rpos->plugin->api->cls, - &n->id); + rpos->plugin->api->disconnect (rpos->plugin->api->cls, &n->id); GNUNET_free (rpos); } @@ -1865,8 +1846,7 @@ disconnect_neighbour (struct NeighbourList *n, GNUNET_free (mq); } if (n->timeout_task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel (sched, - n->timeout_task); + GNUNET_SCHEDULER_cancel (sched, n->timeout_task); /* finally, free n itself */ GNUNET_free (n); } @@ -1912,8 +1892,7 @@ neighbour_timeout_task (void *cls, #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, - "Neighbour `%4s' has timed out!\n", - GNUNET_i2s(&n->id)); + "Neighbour `%4s' has timed out!\n", GNUNET_i2s (&n->id)); #endif n->timeout_task = GNUNET_SCHEDULER_NO_TASK; disconnect_neighbour (n, GNUNET_NO); @@ -1945,7 +1924,8 @@ setup_new_neighbour (const struct GNUNET_PeerIdentity *peer) n->id = *peer; n->last_quota_update = GNUNET_TIME_absolute_get (); n->peer_timeout = - GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); + GNUNET_TIME_relative_to_absolute + (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); n->quota_in = (GNUNET_CONSTANTS_DEFAULT_BPM_IN_OUT + 59999) / (60 * 1000); add_plugins (n); n->timeout_task = GNUNET_SCHEDULER_add_delayed (sched, @@ -1995,25 +1975,23 @@ plugin_env_receive (void *cls, if (n == NULL) { if (message == NULL) - return; /* disconnect of peer already marked down */ + return; /* disconnect of peer already marked down */ n = setup_new_neighbour (peer); } service_context = n->plugins; - while ( (service_context != NULL) && - (plugin != service_context->plugin) ) + while ((service_context != NULL) && (plugin != service_context->plugin)) service_context = service_context->next; - GNUNET_assert ((plugin->api->send == NULL) || - (service_context != NULL)); + GNUNET_assert ((plugin->api->send == NULL) || (service_context != NULL)); if (message == NULL) { #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, - "Receive failed from `%4s', triggering disconnect\n", - GNUNET_i2s(&n->id)); + "Receive failed from `%4s', triggering disconnect\n", + GNUNET_i2s (&n->id)); #endif /* TODO: call stats */ - if (service_context != NULL) - service_context->connected = GNUNET_NO; + if (service_context != NULL) + service_context->connected = GNUNET_NO; disconnect_neighbour (n, GNUNET_YES); return; } @@ -2031,7 +2009,9 @@ plugin_env_receive (void *cls, service_context->connect_attempts++; } service_context->timeout - = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); + = + GNUNET_TIME_relative_to_absolute + (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); service_context->latency = latency; } /* update traffic received amount ... */ @@ -2039,9 +2019,10 @@ plugin_env_receive (void *cls, n->last_received += msize; GNUNET_SCHEDULER_cancel (sched, n->timeout_task); n->peer_timeout = - GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); + GNUNET_TIME_relative_to_absolute + (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); n->timeout_task = - GNUNET_SCHEDULER_add_delayed (sched, + GNUNET_SCHEDULER_add_delayed (sched, GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, &neighbour_timeout_task, n); update_quota (n); @@ -2053,8 +2034,8 @@ plugin_env_receive (void *cls, _ ("Dropping incoming message due to repeated bandwidth quota violations.\n")); /* TODO: call stats */ - GNUNET_assert ( (service_context == NULL) || - (NULL != service_context->neighbour) ); + GNUNET_assert ((service_context == NULL) || + (NULL != service_context->neighbour)); return; } switch (ntohs (message->type)) @@ -2063,13 +2044,13 @@ plugin_env_receive (void *cls, #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receiving `%s' message from `%4s'.\n", "HELLO", - GNUNET_i2s(peer)); + GNUNET_i2s (peer)); #endif process_hello (plugin, message); #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message to connecting peer `%4s'.\n", "ACK", - GNUNET_i2s(peer)); + GNUNET_i2s (peer)); #endif transmit_to_peer (NULL, 0, &ack, GNUNET_YES, n); break; @@ -2080,8 +2061,7 @@ plugin_env_receive (void *cls, #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received message of type %u from `%4s', sending to all clients.\n", - ntohs (message->type), - GNUNET_i2s(peer)); + ntohs (message->type), GNUNET_i2s (peer)); #endif /* transmit message to all clients */ im = GNUNET_malloc (sizeof (struct InboundMessage) + msize); @@ -2099,8 +2079,8 @@ plugin_env_receive (void *cls, } GNUNET_free (im); } - GNUNET_assert ( (service_context == NULL) || - (NULL != service_context->neighbour) ); + GNUNET_assert ((service_context == NULL) || + (NULL != service_context->neighbour)); } @@ -2147,8 +2127,7 @@ handle_start (void *cls, { #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Sending our own `%s' to new client\n", - "HELLO"); + "Sending our own `%s' to new client\n", "HELLO"); #endif transmit_to_client (c, (const struct GNUNET_MessageHeader *) our_hello, @@ -2156,7 +2135,8 @@ handle_start (void *cls, /* tell new client about all existing connections */ cim.header.size = htons (sizeof (struct ConnectInfoMessage)); cim.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT); - cim.quota_out = htonl (GNUNET_CONSTANTS_DEFAULT_BPM_IN_OUT / (60 * 1000)); + cim.quota_out = + htonl (GNUNET_CONSTANTS_DEFAULT_BPM_IN_OUT / (60 * 1000)); cim.latency = GNUNET_TIME_relative_hton (GNUNET_TIME_UNIT_ZERO); /* FIXME? */ im = GNUNET_malloc (sizeof (struct InboundMessage) + sizeof (struct GNUNET_MessageHeader)); @@ -2260,7 +2240,7 @@ handle_send (void *cls, ntohs (obmm->size), ntohs (obmm->type), GNUNET_i2s (&obm->peer)); #endif - transmit_to_peer (tc, ntohl(obm->priority), obmm, GNUNET_NO, n); + transmit_to_peer (tc, ntohl (obm->priority), obmm, GNUNET_NO, n); GNUNET_SERVER_receive_done (client, GNUNET_OK); } @@ -2328,36 +2308,33 @@ handle_try_connect (void *cls, #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' request from client %p asking to connect to `%4s'\n", - "TRY_CONNECT", - client, - GNUNET_i2s (&tcm->peer)); + "TRY_CONNECT", client, GNUNET_i2s (&tcm->peer)); #endif if (NULL == find_neighbour (&tcm->peer)) setup_new_neighbour (&tcm->peer); #if DEBUG_TRANSPORT else GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Client asked to connect to `%4s', but connection already exists\n", - "TRY_CONNECT", - GNUNET_i2s (&tcm->peer)); -#endif + "Client asked to connect to `%4s', but connection already exists\n", + "TRY_CONNECT", GNUNET_i2s (&tcm->peer)); +#endif GNUNET_SERVER_receive_done (client, GNUNET_OK); } static void transmit_address_to_client (void *cls, const char *address) { - struct GNUNET_SERVER_TransmitContext *tc = cls; - size_t slen; - - if (NULL == address) - slen = 0; - else - slen = strlen (address) + 1; - GNUNET_SERVER_transmit_context_append (tc, address, slen, - GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_REPLY); - if (NULL == address) - GNUNET_SERVER_transmit_context_run (tc, GNUNET_TIME_UNIT_FOREVER_REL); + struct GNUNET_SERVER_TransmitContext *tc = cls; + size_t slen; + + if (NULL == address) + slen = 0; + else + slen = strlen (address) + 1; + GNUNET_SERVER_transmit_context_append (tc, address, slen, + GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_REPLY); + if (NULL == address) + GNUNET_SERVER_transmit_context_run (tc, GNUNET_TIME_UNIT_FOREVER_REL); } /** @@ -2369,52 +2346,58 @@ transmit_address_to_client (void *cls, const char *address) */ static void handle_address_lookup (void *cls, - struct GNUNET_SERVER_Client *client, - const struct GNUNET_MessageHeader *message) + struct GNUNET_SERVER_Client *client, + const struct GNUNET_MessageHeader *message) { - const struct AddressLookupMessage *alum; - struct TransportPlugin *lsPlugin; - const char *nameTransport; - const char *address; - uint16_t size; - struct GNUNET_SERVER_TransmitContext *tc; - - size = ntohs (message->size); - if (size < sizeof(struct AddressLookupMessage)) - { - GNUNET_break_op (0); - GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); - return; - } - alum = (const struct AddressLookupMessage *) message; - uint32_t addressLen = ntohl(alum->addrlen); - if (size <= sizeof(struct AddressLookupMessage) + addressLen) - { - GNUNET_break_op (0); - GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); - return; - } - address = (const char *)&alum[1]; - nameTransport = (const char*)&address[addressLen]; - if (nameTransport [size - sizeof (struct AddressLookupMessage) - addressLen -1] != '\0') - { - GNUNET_break_op (0); - GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); - return; - } - struct GNUNET_TIME_Absolute timeout= GNUNET_TIME_absolute_ntoh(alum->timeout); - struct GNUNET_TIME_Relative rtimeout = GNUNET_TIME_absolute_get_remaining(timeout); - lsPlugin = find_transport(nameTransport); - if (NULL == lsPlugin) - { - tc = GNUNET_SERVER_transmit_context_create (client); - GNUNET_SERVER_transmit_context_append (tc, NULL, 0, GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_REPLY); - GNUNET_SERVER_transmit_context_run (tc, rtimeout); - return; - } - tc = GNUNET_SERVER_transmit_context_create (client); - lsPlugin->api->address_pretty_printer(cls, nameTransport, - address, addressLen, GNUNET_YES, rtimeout, &transmit_address_to_client, tc); + const struct AddressLookupMessage *alum; + struct TransportPlugin *lsPlugin; + const char *nameTransport; + const char *address; + uint16_t size; + struct GNUNET_SERVER_TransmitContext *tc; + + size = ntohs (message->size); + if (size < sizeof (struct AddressLookupMessage)) + { + GNUNET_break_op (0); + GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); + return; + } + alum = (const struct AddressLookupMessage *) message; + uint32_t addressLen = ntohl (alum->addrlen); + if (size <= sizeof (struct AddressLookupMessage) + addressLen) + { + GNUNET_break_op (0); + GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); + return; + } + address = (const char *) &alum[1]; + nameTransport = (const char *) &address[addressLen]; + if (nameTransport + [size - sizeof (struct AddressLookupMessage) - addressLen - 1] != '\0') + { + GNUNET_break_op (0); + GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); + return; + } + struct GNUNET_TIME_Absolute timeout = + GNUNET_TIME_absolute_ntoh (alum->timeout); + struct GNUNET_TIME_Relative rtimeout = + GNUNET_TIME_absolute_get_remaining (timeout); + lsPlugin = find_transport (nameTransport); + if (NULL == lsPlugin) + { + tc = GNUNET_SERVER_transmit_context_create (client); + GNUNET_SERVER_transmit_context_append (tc, NULL, 0, + GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_REPLY); + GNUNET_SERVER_transmit_context_run (tc, rtimeout); + return; + } + tc = GNUNET_SERVER_transmit_context_create (client); + lsPlugin->api->address_pretty_printer (cls, nameTransport, + address, addressLen, GNUNET_YES, + rtimeout, + &transmit_address_to_client, tc); } /** @@ -2435,7 +2418,7 @@ static struct GNUNET_SERVER_MessageHandler handlers[] = { sizeof (struct TryConnectMessage)}, {&handle_address_lookup, NULL, GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_LOOKUP, - 0 }, + 0}, {NULL, NULL, 0, 0} }; @@ -2455,7 +2438,8 @@ create_environment (struct TransportPlugin *plug) plug->env.receive = &plugin_env_receive; plug->env.notify_address = &plugin_env_notify_address; plug->env.notify_validation = &plugin_env_notify_validation; - plug->env.default_quota_in = (GNUNET_CONSTANTS_DEFAULT_BPM_IN_OUT + 59999) / (60 * 1000); + plug->env.default_quota_in = + (GNUNET_CONSTANTS_DEFAULT_BPM_IN_OUT + 59999) / (60 * 1000); plug->env.max_connections = max_connect_per_transport; } @@ -2545,8 +2529,7 @@ client_disconnect_notification (void *cls, * @param tc task context (unused) */ static void -unload_plugins (void *cls, - const struct GNUNET_SCHEDULER_TaskContext *tc) +unload_plugins (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { struct TransportPlugin *plug; struct AddressList *al; @@ -2585,7 +2568,7 @@ unload_plugins (void *cls, static void run (void *cls, struct GNUNET_SCHEDULER_Handle *s, - struct GNUNET_SERVER_Handle *serv, + struct GNUNET_SERVER_Handle *serv, const struct GNUNET_CONFIGURATION_Handle *c) { char *plugs; @@ -2654,8 +2637,7 @@ run (void *cls, if (no_transports) refresh_hello (); #if DEBUG_TRANSPORT - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Transport service ready.\n")); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Transport service ready.\n")); #endif /* process client requests */ GNUNET_SERVER_add_handlers (server, handlers); @@ -2673,11 +2655,11 @@ int main (int argc, char *const *argv) { return (GNUNET_OK == - GNUNET_SERVICE_run (argc, - argv, - "transport", - GNUNET_SERVICE_OPTION_NONE, - &run, NULL)) ? 0 : 1; + GNUNET_SERVICE_run (argc, + argv, + "transport", + GNUNET_SERVICE_OPTION_NONE, + &run, NULL)) ? 0 : 1; } /* end of gnunet-service-transport.c */ diff --git a/src/transport/plugin_transport.h b/src/transport/plugin_transport.h index 4cbf5e2e6..795d4ed25 100644 --- a/src/transport/plugin_transport.h +++ b/src/transport/plugin_transport.h @@ -60,12 +60,15 @@ * @param message the message, NULL if peer was disconnected */ typedef void (*GNUNET_TRANSPORT_PluginReceiveCallback) (void *cls, - struct GNUNET_TIME_Relative - latency, - const struct GNUNET_PeerIdentity - * peer, - const struct GNUNET_MessageHeader - * message); + struct + GNUNET_TIME_Relative + latency, + const struct + GNUNET_PeerIdentity * + peer, + const struct + GNUNET_MessageHeader * + message); /** @@ -84,10 +87,13 @@ typedef void (*GNUNET_TRANSPORT_PluginReceiveCallback) (void *cls, * by the other peer in human-readable format) */ typedef void (*GNUNET_TRANSPORT_ValidationNotification) (void *cls, - const char *name, - const struct GNUNET_PeerIdentity *peer, - uint32_t challenge, - const char *sender_addr); + const char *name, + const struct + GNUNET_PeerIdentity * + peer, + uint32_t challenge, + const char + *sender_addr); @@ -217,12 +223,12 @@ struct GNUNET_TRANSPORT_PluginEnvironment */ typedef int (*GNUNET_TRANSPORT_ValidationFunction) (void *cls, - const struct - GNUNET_PeerIdentity * target, - uint32_t challenge, - struct GNUNET_TIME_Relative - timeout, const void *addr, - size_t addrlen); + const struct + GNUNET_PeerIdentity * target, + uint32_t challenge, + struct GNUNET_TIME_Relative + timeout, const void *addr, + size_t addrlen); /** * Function called by the GNUNET_TRANSPORT_TransmitFunction @@ -260,11 +266,11 @@ typedef void * peer disconnected...); can be NULL * @param cont_cls closure for cont */ -typedef void +typedef void (*GNUNET_TRANSPORT_TransmitFunction) (void *cls, const struct GNUNET_PeerIdentity * target, - unsigned int priority, + unsigned int priority, const struct GNUNET_MessageHeader * msg, struct GNUNET_TIME_Relative timeout, @@ -290,8 +296,8 @@ typedef void */ typedef void (*GNUNET_TRANSPORT_DisconnectFunction) (void *cls, - const struct GNUNET_PeerIdentity * - target); + const struct GNUNET_PeerIdentity * + target); /** diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c index 5fd875623..e5f1361ac 100644 --- a/src/transport/plugin_transport_http.c +++ b/src/transport/plugin_transport_http.c @@ -1006,9 +1006,8 @@ receiveContentCallback (void *ptr, size_t size, size_t nmemb, void *ctx) cpy = sizeof (GNUNET_MessageHeader) - httpSession->cs.client.rpos1; if (cpy > have) cpy = have; - memcpy (&httpSession->cs. - client.rbuff1[httpSession->cs.client.rpos1], &inbuf[poff], - cpy); + memcpy (&httpSession->cs.client. + rbuff1[httpSession->cs.client.rpos1], &inbuf[poff], cpy); httpSession->cs.client.rpos1 += cpy; have -= cpy; poff += cpy; @@ -1028,9 +1027,8 @@ receiveContentCallback (void *ptr, size_t size, size_t nmemb, void *ctx) httpSession->cs.client.rpos2; if (cpy > have) cpy = have; - memcpy (&httpSession->cs. - client.rbuff2[httpSession->cs.client.rpos2], &inbuf[poff], - cpy); + memcpy (&httpSession->cs.client. + rbuff2[httpSession->cs.client.rpos2], &inbuf[poff], cpy); have -= cpy; poff += cpy; httpSession->cs.client.rpos2 += cpy; @@ -1810,11 +1808,14 @@ curl_runner (void *unused) GNUNET_net_fdset_copy_native (hrs, rs); GNUNET_net_fdset_copy_native (hes, es); - GNUNET_net_fdset_handle_set (signal_pipe[0], hrs); + GNUNET_net_fdset_handle_set (signal_pipe[0], hrs); if (stats != NULL) stats->change (stat_select_calls, 1); ret = - GNUNET_net_select (hrs, hws, hes, (have_tv == MHD_YES) ? timeout : GNUNET_TIME_UNIT_FOREVER_REL); + GNUNET_net_select (hrs, hws, hes, + (have_tv == + MHD_YES) ? timeout : + GNUNET_TIME_UNIT_FOREVER_REL); if (ret == GNUNET_SYSERR) { GNUNET_GE_LOG_STRERROR (coreAPI->ectx, diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c index 2694b3f1e..d877a7f5b 100644 --- a/src/transport/plugin_transport_tcp.c +++ b/src/transport/plugin_transport_tcp.c @@ -421,9 +421,9 @@ find_session_by_target (struct Plugin *plugin, ret = plugin->sessions; while ((ret != NULL) && - ( (GNUNET_SYSERR == ret->expecting_welcome) || - (0 != memcmp (target, - &ret->target, sizeof (struct GNUNET_PeerIdentity))))) + ((GNUNET_SYSERR == ret->expecting_welcome) || + (0 != memcmp (target, + &ret->target, sizeof (struct GNUNET_PeerIdentity))))) ret = ret->next; return ret; } @@ -538,24 +538,24 @@ do_transmit (void *cls, size_t size, void *buf) { #if DEBUG_TCP GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "tcp", - "Timeout trying to transmit to peer `%4s', discarding message queue.\n", - GNUNET_i2s(&session->target)); + "tcp", + "Timeout trying to transmit to peer `%4s', discarding message queue.\n", + GNUNET_i2s (&session->target)); #endif /* timeout */ while (NULL != (pm = session->pending_messages)) { session->pending_messages = pm->next; #if DEBUG_TCP - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "tcp", - "Failed to transmit message of type %u to `%4s'.\n", - ntohs(pm->msg->type), - GNUNET_i2s(&session->target)); + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, + "tcp", + "Failed to transmit message of type %u to `%4s'.\n", + ntohs (pm->msg->type), + GNUNET_i2s (&session->target)); #endif if (pm->transmit_cont != NULL) - pm->transmit_cont (pm->transmit_cont_cls, - &session->target, GNUNET_SYSERR); + pm->transmit_cont (pm->transmit_cont_cls, + &session->target, GNUNET_SYSERR); GNUNET_free (pm); } return 0; @@ -618,22 +618,20 @@ static void process_pending_messages (struct Session *session) { GNUNET_assert (session->client != NULL); - if (session->pending_messages == NULL) - return; + if (session->pending_messages == NULL) + return; if (session->transmit_handle != NULL) return; session->transmit_handle = GNUNET_SERVER_notify_transmit_ready (session->client, - ntohs (session-> - pending_messages->msg-> - size) + - (session-> - pending_messages->is_welcome ? 0 : - sizeof (struct DataMessage)), + ntohs (session->pending_messages-> + msg->size) + + (session->pending_messages-> + is_welcome ? 0 : sizeof (struct + DataMessage)), GNUNET_TIME_absolute_get_remaining - (session-> - pending_messages[0].timeout), - &do_transmit, session); + (session->pending_messages[0]. + timeout), &do_transmit, session); } @@ -652,8 +650,9 @@ process_pending_messages (struct Session *session) */ static struct Session * connect_and_create_validation_session (struct Plugin *plugin, - const struct GNUNET_PeerIdentity *target, - const void *addr, size_t addrlen) + const struct GNUNET_PeerIdentity + *target, const void *addr, + size_t addrlen) { struct GNUNET_SERVER_Client *client; struct GNUNET_CONNECTION_Handle *conn; @@ -663,24 +662,24 @@ connect_and_create_validation_session (struct Plugin *plugin, if (addrlen == sizeof (struct sockaddr_in)) af = AF_INET; else if (addrlen == sizeof (struct sockaddr_in6)) - af = AF_INET6; + af = AF_INET6; else { GNUNET_break_op (0); return NULL; /* invalid address */ } conn = GNUNET_CONNECTION_create_from_sockaddr (plugin->env->sched, - af, - addr, - addrlen, - GNUNET_SERVER_MAX_MESSAGE_SIZE); + af, + addr, + addrlen, + GNUNET_SERVER_MAX_MESSAGE_SIZE); if (conn == NULL) { #if DEBUG_TCP GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", "Failed to create connection to peer at `%s'.\n", - GNUNET_a2s(addr, addrlen)); + GNUNET_a2s (addr, addrlen)); #endif return NULL; } @@ -692,16 +691,15 @@ connect_and_create_validation_session (struct Plugin *plugin, session->pending_messages = NULL; session->connect_alen = addrlen; session->connect_addr = GNUNET_malloc (addrlen); - session->expecting_welcome = GNUNET_SYSERR; + session->expecting_welcome = GNUNET_SYSERR; memcpy (session->connect_addr, addr, addrlen); #if DEBUG_TCP GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", "Creating new session %p with `%s' for `%4s' based on `%s' request.\n", - session, - GNUNET_a2s (addr, addrlen), - GNUNET_i2s (&session->target), - "VALIDATE"); + session, + GNUNET_a2s (addr, addrlen), + GNUNET_i2s (&session->target), "VALIDATE"); #endif return session; } @@ -723,17 +721,18 @@ connect_and_create_validation_session (struct Plugin *plugin, */ static int tcp_plugin_validate (void *cls, - const struct GNUNET_PeerIdentity *target, - uint32_t challenge, - struct GNUNET_TIME_Relative timeout, - const void *addr, size_t addrlen) + const struct GNUNET_PeerIdentity *target, + uint32_t challenge, + struct GNUNET_TIME_Relative timeout, + const void *addr, size_t addrlen) { struct Plugin *plugin = cls; struct Session *session; struct PendingMessage *pm; struct ValidationChallengeMessage *vcm; - session = connect_and_create_validation_session (plugin, target, addr, addrlen); + session = + connect_and_create_validation_session (plugin, target, addr, addrlen); if (session == NULL) { #if DEBUG_TCP @@ -743,15 +742,15 @@ tcp_plugin_validate (void *cls, return GNUNET_SYSERR; } pm = GNUNET_malloc (sizeof (struct PendingMessage) + - sizeof (struct ValidationChallengeMessage) + addrlen); + sizeof (struct ValidationChallengeMessage) + addrlen); pm->msg = (struct GNUNET_MessageHeader *) &pm[1]; pm->timeout = GNUNET_TIME_relative_to_absolute (timeout); pm->is_welcome = GNUNET_YES; - vcm = (struct ValidationChallengeMessage*) &pm[1]; + vcm = (struct ValidationChallengeMessage *) &pm[1]; vcm->header.size = htons (sizeof (struct ValidationChallengeMessage) + addrlen); vcm->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_TCP_PING); - vcm->challenge = htonl(challenge); + vcm->challenge = htonl (challenge); vcm->target = *target; memcpy (&vcm[1], addr, addrlen); GNUNET_assert (session->pending_messages == NULL); @@ -778,12 +777,11 @@ disconnect_session (struct Session *session) #if DEBUG_TCP GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", - "Disconnecting from `%4s' at %s (session %p).\n", - GNUNET_i2s(&session->target), - (session->connect_addr != NULL) ? - GNUNET_a2s(session->connect_addr, - session->connect_alen) : "*", - session); + "Disconnecting from `%4s' at %s (session %p).\n", + GNUNET_i2s (&session->target), + (session->connect_addr != NULL) ? + GNUNET_a2s (session->connect_addr, + session->connect_alen) : "*", session); #endif /* remove from session list */ prev = NULL; @@ -805,19 +803,20 @@ disconnect_session (struct Session *session) } if (session->transmit_handle != NULL) { - GNUNET_CONNECTION_notify_transmit_ready_cancel (session->transmit_handle); + GNUNET_CONNECTION_notify_transmit_ready_cancel (session-> + transmit_handle); session->transmit_handle = NULL; } while (NULL != (pm = session->pending_messages)) { #if DEBUG_TCP GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "tcp", - pm->transmit_cont != NULL - ? "Could not deliver message of type %u to `%4s'.\n" - : "Could not deliver message of type %u to `%4s', notifying.\n", - ntohs(pm->msg->type), - GNUNET_i2s(&session->target)); + "tcp", + pm->transmit_cont != NULL + ? "Could not deliver message of type %u to `%4s'.\n" + : + "Could not deliver message of type %u to `%4s', notifying.\n", + ntohs (pm->msg->type), GNUNET_i2s (&session->target)); #endif session->pending_messages = pm->next; if (NULL != pm->transmit_cont) @@ -829,17 +828,17 @@ disconnect_session (struct Session *session) { #if DEBUG_TCP GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "tcp", - "Notifying transport service about loss of data connection with `%4s'.\n", - GNUNET_i2s(&session->target)); + "tcp", + "Notifying transport service about loss of data connection with `%4s'.\n", + GNUNET_i2s (&session->target)); #endif /* Data session that actually went past the - initial handshake; transport service may - know about this one, so we need to - notify transport service about disconnect */ + initial handshake; transport service may + know about this one, so we need to + notify transport service about disconnect */ session->plugin->env->receive (session->plugin->env->cls, - GNUNET_TIME_UNIT_ZERO, - &session->target, NULL); + GNUNET_TIME_UNIT_ZERO, + &session->target, NULL); } if (session->client != NULL) { @@ -930,13 +929,13 @@ try_connect_to_address (void *cls, cc->welcome = create_welcome (addrlen, addr, cc->plugin); cc->sa = GNUNET_CONNECTION_create_from_sockaddr (cc->plugin->env->sched, - af, addr, addrlen, - GNUNET_SERVER_MAX_MESSAGE_SIZE); + af, addr, addrlen, + GNUNET_SERVER_MAX_MESSAGE_SIZE); #if DEBUG_TCP GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "tcp", - "Connecting using address %s.\n", - GNUNET_a2s(addr, addrlen)); + "tcp", + "Connecting using address %s.\n", + GNUNET_a2s (addr, addrlen)); #endif return GNUNET_SYSERR; } @@ -974,7 +973,7 @@ session_try_connect (void *cls, GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", "Now connected to `%4s', now processing messages.\n", - GNUNET_i2s(&session->target)); + GNUNET_i2s (&session->target)); #endif process_pending_messages (session); } @@ -984,8 +983,7 @@ session_try_connect (void *cls, GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", "Failed to connect to `%4s' (no working `%s'), closing session.\n", - GNUNET_i2s(&session->target), - "HELLO"); + GNUNET_i2s (&session->target), "HELLO"); #endif disconnect_session (session); } @@ -1005,7 +1003,7 @@ session_try_connect (void *cls, GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", "Asked to connect to `%4s', but have no addresses to try.\n", - GNUNET_i2s(&session->target)); + GNUNET_i2s (&session->target)); #endif return; } @@ -1030,8 +1028,7 @@ session_try_connect (void *cls, #if DEBUG_TCP GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connected to `%4s' for session %p\n", - GNUNET_i2s(&session->target), - session->client); + GNUNET_i2s (&session->target), session->client); #endif if (session->client == NULL) { @@ -1047,8 +1044,7 @@ session_try_connect (void *cls, GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", "Connected to `%4s', now sending `%s' message.\n", - GNUNET_i2s(&session->target), - "WELCOME"); + GNUNET_i2s (&session->target), "WELCOME"); #endif } @@ -1070,9 +1066,9 @@ session_try_connect (void *cls, * peer disconnected...) * @param cont_cls closure for cont */ -static void +static void tcp_plugin_send (void *cls, - const struct GNUNET_PeerIdentity *target, + const struct GNUNET_PeerIdentity *target, unsigned int priority, const struct GNUNET_MessageHeader *msg, struct GNUNET_TIME_Relative timeout, @@ -1083,7 +1079,7 @@ tcp_plugin_send (void *cls, struct PendingMessage *pm; struct PendingMessage *pme; - session = find_session_by_target (plugin, target); + session = find_session_by_target (plugin, target); pm = GNUNET_malloc (sizeof (struct PendingMessage) + ntohs (msg->size)); pm->msg = (struct GNUNET_MessageHeader *) &pm[1]; memcpy (pm->msg, msg, ntohs (msg->size)); @@ -1108,9 +1104,10 @@ tcp_plugin_send (void *cls, session->expecting_welcome = GNUNET_YES; session->pending_messages = pm; session->ic = GNUNET_PEERINFO_iterate (plugin->env->cfg, - plugin->env->sched, - target, - 0, timeout, &session_try_connect, session); + plugin->env->sched, + target, + 0, timeout, &session_try_connect, + session); return; } GNUNET_assert (session != NULL); @@ -1153,13 +1150,12 @@ tcp_plugin_send (void *cls, * to be cancelled */ static void -tcp_plugin_disconnect (void *cls, - const struct GNUNET_PeerIdentity *target) +tcp_plugin_disconnect (void *cls, const struct GNUNET_PeerIdentity *target) { struct Plugin *plugin = cls; struct Session *session; struct PendingMessage *pm; - + session = find_session_by_target (plugin, target); if (session == NULL) { @@ -1168,9 +1164,9 @@ tcp_plugin_disconnect (void *cls, } #if DEBUG_TCP GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "tcp", - "Asked to cancel session with `%4s'\n", - GNUNET_i2s(target)); + "tcp", + "Asked to cancel session with `%4s'\n", + GNUNET_i2s (target)); #endif pm = session->pending_messages; while (pm != NULL) @@ -1338,7 +1334,7 @@ tcp_plugin_set_receive_quota (void *cls, session = find_session_by_target (plugin, target); if (session == NULL) - return; /* peer must have disconnected, ignore */ + return; /* peer must have disconnected, ignore */ if (session->quota_in != quota_in) { update_quota (session, GNUNET_YES); @@ -1408,7 +1404,7 @@ tcp_plugin_address_suggested (void *cls, const void *addr, size_t addrlen) GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", "Informing transport service about my address `%s'.\n", - GNUNET_a2s(addr, addrlen)); + GNUNET_a2s (addr, addrlen)); #endif plugin->env->notify_address (plugin->env->cls, "tcp", @@ -1421,9 +1417,7 @@ tcp_plugin_address_suggested (void *cls, const void *addr, size_t addrlen) * Send a validation challenge response. */ static size_t -send_vcr (void *cls, - size_t size, - void *buf) +send_vcr (void *cls, size_t size, void *buf) { struct ValidationChallengeResponse *vcr = cls; uint16_t msize; @@ -1433,7 +1427,7 @@ send_vcr (void *cls, GNUNET_free (vcr); return 0; } - msize = ntohs(vcr->header.size); + msize = ntohs (vcr->header.size); GNUNET_assert (size >= msize); memcpy (buf, vcr, msize); GNUNET_free (vcr); @@ -1451,8 +1445,8 @@ send_vcr (void *cls, */ static void handle_tcp_ping (void *cls, - struct GNUNET_SERVER_Client *client, - const struct GNUNET_MessageHeader *message) + struct GNUNET_SERVER_Client *client, + const struct GNUNET_MessageHeader *message) { struct Plugin *plugin = cls; const struct ValidationChallengeMessage *vcm; @@ -1463,14 +1457,11 @@ handle_tcp_ping (void *cls, #if DEBUG_TRANSPORT if (GNUNET_OK == - GNUNET_SERVER_client_get_address (client, - (void **) &addr, - &addrlen)) + GNUNET_SERVER_client_get_address (client, (void **) &addr, &addrlen)) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, - "Processing `%s' from `%s'\n", - "PING", - GNUNET_a2s (addr, addrlen)); + "Processing `%s' from `%s'\n", + "PING", GNUNET_a2s (addr, addrlen)); GNUNET_free (addr); } #endif @@ -1478,75 +1469,69 @@ handle_tcp_ping (void *cls, if (msize < sizeof (struct ValidationChallengeMessage)) { GNUNET_break_op (0); - GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); + GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); return; } vcm = (const struct ValidationChallengeMessage *) message; if (0 != memcmp (&vcm->target, - plugin->env->my_identity, sizeof (struct GNUNET_PeerIdentity))) + plugin->env->my_identity, + sizeof (struct GNUNET_PeerIdentity))) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Received `%s' message not destined for me!\n"), "PING"); /* TODO: call statistics */ - GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); + GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); return; } msize -= sizeof (struct ValidationChallengeMessage); - if (GNUNET_OK != - tcp_plugin_address_suggested (plugin, &vcm[1], msize)) + if (GNUNET_OK != tcp_plugin_address_suggested (plugin, &vcm[1], msize)) { GNUNET_break_op (0); - GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); + GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); return; } - if (GNUNET_OK != - GNUNET_SERVER_client_get_address (client, - &addr, - &addrlen)) + if (GNUNET_OK != GNUNET_SERVER_client_get_address (client, &addr, &addrlen)) { GNUNET_break (0); - GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); + GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); return; } vcr = GNUNET_malloc (sizeof (struct ValidationChallengeResponse) + addrlen); - vcr->header.size = htons (sizeof (struct ValidationChallengeResponse) + addrlen); + vcr->header.size = + htons (sizeof (struct ValidationChallengeResponse) + addrlen); vcr->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_TCP_PONG); vcr->purpose.size = htonl (sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) + - sizeof (uint32_t) + - sizeof ( struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded) + - addrlen); + sizeof (uint32_t) + + sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded) + addrlen); vcr->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_TCP_PING); vcr->challenge = vcm->challenge; vcr->signer = *plugin->env->my_public_key; - memcpy (&vcr[1], - addr, - addrlen); + memcpy (&vcr[1], addr, addrlen); GNUNET_assert (GNUNET_OK == GNUNET_CRYPTO_rsa_sign (plugin->env->my_private_key, - &vcr->purpose, - &vcr->signature)); + &vcr->purpose, &vcr->signature)); #if EXTRA_CHECKS GNUNET_assert (GNUNET_OK == GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_TCP_PING, - &vcr->purpose, - &vcr->signature, - plugin->env->my_public_key)); + &vcr->purpose, + &vcr->signature, plugin->env->my_public_key)); #endif GNUNET_free (addr); if (NULL == GNUNET_SERVER_notify_transmit_ready (client, - sizeof (struct ValidationChallengeResponse) + addrlen, - GNUNET_TIME_UNIT_SECONDS, - &send_vcr, - vcr)) + sizeof (struct + ValidationChallengeResponse) + + addrlen, + GNUNET_TIME_UNIT_SECONDS, + &send_vcr, vcr)) { GNUNET_break (0); GNUNET_free (vcr); } /* after a PING, we always close the connection */ - GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); + GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); } @@ -1559,8 +1544,8 @@ handle_tcp_ping (void *cls, */ static void handle_tcp_pong (void *cls, - struct GNUNET_SERVER_Client *client, - const struct GNUNET_MessageHeader *message) + struct GNUNET_SERVER_Client *client, + const struct GNUNET_MessageHeader *message) { struct Plugin *plugin = cls; const struct ValidationChallengeResponse *vcr; @@ -1575,78 +1560,71 @@ handle_tcp_pong (void *cls, struct sockaddr *claddr; if (GNUNET_OK == - GNUNET_SERVER_client_get_address (client, - (void**) &claddr, - &addrlen)) + GNUNET_SERVER_client_get_address (client, (void **) &claddr, &addrlen)) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, - "Processing `%s' from `%s'\n", - "PONG", - GNUNET_a2s (claddr, addrlen)); + "Processing `%s' from `%s'\n", + "PONG", GNUNET_a2s (claddr, addrlen)); GNUNET_free (claddr); } #endif - if (ntohs(message->size) < sizeof(struct ValidationChallengeResponse)) + if (ntohs (message->size) < sizeof (struct ValidationChallengeResponse)) { GNUNET_break_op (0); - GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); + GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); return; } - addrlen = ntohs(message->size) - sizeof(struct ValidationChallengeResponse); + addrlen = + ntohs (message->size) - sizeof (struct ValidationChallengeResponse); vcr = (const struct ValidationChallengeResponse *) message; - if ( (ntohl(vcr->purpose.size) != - sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) + - sizeof (uint32_t) + - sizeof ( struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded) + - addrlen)) + if ((ntohl (vcr->purpose.size) != + sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) + + sizeof (uint32_t) + + sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded) + addrlen)) { GNUNET_break_op (0); - GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); + GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); return; } if (GNUNET_OK != GNUNET_CRYPTO_rsa_verify - (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_TCP_PING, - &vcr->purpose, - &vcr->signature, - &vcr->signer)) + (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_TCP_PING, + &vcr->purpose, &vcr->signature, &vcr->signer)) { GNUNET_break_op (0); - GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); + GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); return; } GNUNET_CRYPTO_hash (&vcr->signer, - sizeof( struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), - &peer.hashPubKey); - addr = (const struct sockaddr*) &vcr[1]; + sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), + &peer.hashPubKey); + addr = (const struct sockaddr *) &vcr[1]; if (addrlen == sizeof (struct sockaddr_in)) { memcpy (&v4, addr, sizeof (struct sockaddr_in)); - v4.sin_port = htons(check_port (plugin, ntohs (v4.sin_port))); - sender_addr = GNUNET_strdup (GNUNET_a2s((const struct sockaddr*) &v4, - addrlen)); + v4.sin_port = htons (check_port (plugin, ntohs (v4.sin_port))); + sender_addr = GNUNET_strdup (GNUNET_a2s ((const struct sockaddr *) &v4, + addrlen)); } else if (addrlen == sizeof (struct sockaddr_in6)) { memcpy (&v6, addr, sizeof (struct sockaddr_in6)); - v6.sin6_port = htons(check_port (plugin, ntohs (v6.sin6_port))); - sender_addr = GNUNET_strdup (GNUNET_a2s((const struct sockaddr*) &v6, - addrlen)); + v6.sin6_port = htons (check_port (plugin, ntohs (v6.sin6_port))); + sender_addr = GNUNET_strdup (GNUNET_a2s ((const struct sockaddr *) &v6, + addrlen)); } else { - GNUNET_break_op (0); - GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); + GNUNET_break_op (0); + GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); return; } plugin->env->notify_validation (plugin->env->cls, - "tcp", - &peer, - ntohl(vcr->challenge), - sender_addr); + "tcp", + &peer, ntohl (vcr->challenge), sender_addr); GNUNET_free (sender_addr); /* after a PONG, we always close the connection */ - GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); + GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); } @@ -1685,8 +1663,7 @@ handle_tcp_welcome (void *cls, GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", "Received `%s' message from `%4s/%p'.\n", "WELCOME", - GNUNET_i2s(&wm->clientIdentity), - client); + GNUNET_i2s (&wm->clientIdentity), client); #endif session_c = find_session_by_client (plugin, client); if (session_c == NULL) @@ -1809,8 +1786,7 @@ handle_tcp_data (void *cls, #if DEBUG_TCP GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", "Receiving %u bytes from `%4s'.\n", - msize, - GNUNET_i2s(&session->target)); + msize, GNUNET_i2s (&session->target)); #endif dm = (const struct DataMessage *) message; session->max_in_msg_counter = GNUNET_MAX (session->max_in_msg_counter, @@ -1848,8 +1824,7 @@ handle_tcp_data (void *cls, "Forwarding data of type %u to transport service.\n", ntohs (msg->type)); #endif - plugin->env->receive (plugin->env->cls, - latency, &session->target, msg); + plugin->env->receive (plugin->env->cls, latency, &session->target, msg); /* update bandwidth used */ session->last_received += msize; update_quota (session, GNUNET_NO); @@ -1910,11 +1885,10 @@ disconnect_notify (void *cls, struct GNUNET_SERVER_Client *client) GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", "Destroying session of `%4s' with %s (%p) due to network-level disconnect.\n", - GNUNET_i2s(&session->target), - (session->connect_addr != NULL) ? - GNUNET_a2s(session->connect_addr, - session->connect_alen) : "*", - client); + GNUNET_i2s (&session->target), + (session->connect_addr != NULL) ? + GNUNET_a2s (session->connect_addr, + session->connect_alen) : "*", client); #endif disconnect_session (session); } @@ -1949,8 +1923,8 @@ process_interfaces (void *cls, } GNUNET_log_from (GNUNET_ERROR_TYPE_INFO | GNUNET_ERROR_TYPE_BULK, - "tcp", _("Found address `%s' (%s)\n"), - GNUNET_a2s(addr, addrlen), name); + "tcp", _("Found address `%s' (%s)\n"), + GNUNET_a2s (addr, addrlen), name); plugin->env->notify_address (plugin->env->cls, "tcp", addr, addrlen, GNUNET_TIME_UNIT_FOREVER_REL); @@ -1978,11 +1952,7 @@ process_hostname_ips (void *cls, plugin->hostname_dns = NULL; return; } - process_interfaces (plugin, - "", - GNUNET_YES, - addr, - addrlen); + process_interfaces (plugin, "", GNUNET_YES, addr, addrlen); } @@ -2062,10 +2032,11 @@ libgnunet_plugin_transport_tcp_init (void *cls) plugin); GNUNET_OS_network_interfaces_list (&process_interfaces, plugin); plugin->hostname_dns = GNUNET_RESOLVER_hostname_resolve (env->sched, - env->cfg, - AF_UNSPEC, - HOSTNAME_RESOLVE_TIMEOUT, - &process_hostname_ips, plugin); + env->cfg, + AF_UNSPEC, + HOSTNAME_RESOLVE_TIMEOUT, + &process_hostname_ips, + plugin); return api; } @@ -2081,7 +2052,7 @@ libgnunet_plugin_transport_tcp_done (void *cls) struct Session *session; while (NULL != (session = plugin->sessions)) - disconnect_session (session); + disconnect_session (session); if (NULL != plugin->hostname_dns) { GNUNET_RESOLVER_request_cancel (plugin->hostname_dns); diff --git a/src/transport/plugin_transport_template.c b/src/transport/plugin_transport_template.c index 69c27b923..69610283b 100644 --- a/src/transport/plugin_transport_template.c +++ b/src/transport/plugin_transport_template.c @@ -147,11 +147,10 @@ struct Plugin */ static int template_plugin_validate (void *cls, - const struct GNUNET_PeerIdentity *target, - uint32_t challenge, - struct GNUNET_TIME_Relative timeout, - const void *addr, - size_t addrlen) + const struct GNUNET_PeerIdentity *target, + uint32_t challenge, + struct GNUNET_TIME_Relative timeout, + const void *addr, size_t addrlen) { // FIXME return GNUNET_SYSERR; @@ -173,10 +172,10 @@ template_plugin_validate (void *cls, * peer disconnected...) * @param cont_cls closure for cont */ -static void +static void template_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target, - unsigned int priority, + unsigned int priority, const struct GNUNET_MessageHeader *msg, struct GNUNET_TIME_Relative timeout, GNUNET_TRANSPORT_TransmitContinuation cont, @@ -197,7 +196,7 @@ template_plugin_send (void *cls, */ static void template_plugin_disconnect (void *cls, - const struct GNUNET_PeerIdentity *target) + const struct GNUNET_PeerIdentity *target) { // struct Plugin *plugin = cls; // FIXME diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index f20cd19df..345a98bec 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c @@ -1,6 +1,6 @@ /* This file is part of GNUnet - (C) 2001, 2002, 2003, 2004, 2005, 2008 Christian Grothoff (and other contributing authors) + (C) 2010 Christian Grothoff (and other contributing authors) GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -166,7 +166,7 @@ struct Plugin /* * FD Read set */ - struct GNUNET_NETWORK_FDSet * rs; + struct GNUNET_NETWORK_FDSet *rs; }; @@ -242,7 +242,7 @@ static struct GNUNET_NETWORK_Handle *udp_sock; * GNUNET_SYSERR if not. */ int -udp_associate (struct Session * session) +udp_associate (struct Session *session) { return GNUNET_SYSERR; /* UDP connections can never be associated */ } @@ -254,9 +254,7 @@ udp_associate (struct Session * session) * @return GNUNET_OK on success, GNUNET_SYSERR if the operation failed */ void -udp_disconnect (void *cls, - const struct GNUNET_PeerIdentity * - target) +udp_disconnect (void *cls, const struct GNUNET_PeerIdentity *target) { return; } @@ -282,18 +280,20 @@ udp_transport_server_stop (void *cls) } static struct Session * -find_session(void *cls, struct Session * session_list, const struct GNUNET_PeerIdentity *peer) +find_session (void *cls, struct Session *session_list, + const struct GNUNET_PeerIdentity *peer) { struct Plugin *plugin = cls; struct Session *pos; pos = session_list; while (pos != NULL) - { - if (memcmp(peer, &pos->target, sizeof(struct GNUNET_PeerIdentity)) == 0) - return pos; - pos = pos->next; - } + { + if (memcmp (peer, &pos->target, sizeof (struct GNUNET_PeerIdentity)) == + 0) + return pos; + pos = pos->next; + } return NULL; } @@ -329,34 +329,37 @@ udp_plugin_send (void *cls, int ssize; size_t sent; - session = find_session(plugin, plugin->sessions, target); + session = find_session (plugin, plugin->sessions, target); if ((session == NULL) || (udp_sock == NULL)) return; /* Build the message to be sent */ - message = GNUNET_malloc(sizeof(struct UDPMessage) + ntohs(msg->size)); - ssize = sizeof(struct UDPMessage) + ntohs(msg->size); + message = GNUNET_malloc (sizeof (struct UDPMessage) + ntohs (msg->size)); + ssize = sizeof (struct UDPMessage) + ntohs (msg->size); #if DEBUG_UDP - GNUNET_log_from(GNUNET_ERROR_TYPE_INFO, "udp", _ - ("In udp_send, ssize is %d\n"), ssize); + GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, "udp", _ + ("In udp_send, ssize is %d\n"), ssize); #endif - message->header.size = htons(ssize); - message->header.type = htons(0); - memcpy (&message->sender, plugin->env->my_identity, sizeof(struct GNUNET_PeerIdentity)); + message->header.size = htons (ssize); + message->header.type = htons (0); + memcpy (&message->sender, plugin->env->my_identity, + sizeof (struct GNUNET_PeerIdentity)); memcpy (&message[1], msg, ntohs (msg->size)); /* Actually send the message */ - sent = GNUNET_NETWORK_socket_sendto (udp_sock, message, ssize, session->connect_addr, - session->connect_alen); + sent = + GNUNET_NETWORK_socket_sendto (udp_sock, message, ssize, + session->connect_addr, + session->connect_alen); if (cont != NULL) { if (sent == GNUNET_SYSERR) - cont(cont_cls, target, GNUNET_SYSERR); + cont (cont_cls, target, GNUNET_SYSERR); else - cont(cont_cls, target, GNUNET_OK); + cont (cont_cls, target, GNUNET_OK); } return; @@ -372,30 +375,35 @@ udp_plugin_send (void *cls, */ static void handle_udp_ping (void *cls, - struct GNUNET_PeerIdentity *sender, struct sockaddr_storage * addr, size_t addrlen, + struct GNUNET_PeerIdentity *sender, + struct sockaddr_storage *addr, size_t addrlen, const struct GNUNET_MessageHeader *message) { struct Plugin *plugin = cls; struct Session *head = plugin->sessions; - const struct UDPPingMessage *ping = (const struct UDPPingMessage *)message; + const struct UDPPingMessage *ping = (const struct UDPPingMessage *) message; struct UDPPongMessage *pong; struct Session *found; #if DEBUG_UDP - GNUNET_log_from(GNUNET_ERROR_TYPE_INFO, "udp", _ - ("handling ping, challenge is %d\n"), ntohs(ping->challenge)); + GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, "udp", _ + ("handling ping, challenge is %d\n"), + ntohs (ping->challenge)); #endif - found = find_session(plugin, head, sender); + found = find_session (plugin, head, sender); if (found != NULL) { - pong = GNUNET_malloc(sizeof(struct UDPPongMessage) + addrlen); - pong->header.type = htons(GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_PONG); - pong->header.size = htons(sizeof(struct UDPPongMessage) + addrlen); + pong = GNUNET_malloc (sizeof (struct UDPPongMessage) + addrlen); + pong->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_PONG); + pong->header.size = htons (sizeof (struct UDPPongMessage) + addrlen); pong->challenge = ping->challenge; - memcpy(&pong[1], addr, addrlen); - pong->addrlen = htons(addrlen); + memcpy (&pong[1], addr, addrlen); + pong->addrlen = htons (addrlen); - udp_plugin_send(plugin, sender, GNUNET_SCHEDULER_PRIORITY_DEFAULT, &pong->header, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30), NULL, NULL); + udp_plugin_send (plugin, sender, GNUNET_SCHEDULER_PRIORITY_DEFAULT, + &pong->header, + GNUNET_TIME_relative_multiply + (GNUNET_TIME_UNIT_SECONDS, 30), NULL, NULL); } return; @@ -417,49 +425,52 @@ handle_udp_pong (void *cls, const struct GNUNET_MessageHeader *message) { struct Plugin *plugin = cls; - const struct UDPPongMessage *pong = (struct UDPPongMessage *)message; + const struct UDPPongMessage *pong = (struct UDPPongMessage *) message; struct Session *found; unsigned int addr_len; struct sockaddr_storage addr; #if DEBUG_UDP - GNUNET_log_from(GNUNET_ERROR_TYPE_INFO, "udp", _ - ("handling pong\n")); + GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, "udp", _("handling pong\n")); #endif - found = find_session(plugin, plugin->sessions, sender); + found = find_session (plugin, plugin->sessions, sender); #if DEBUG_UDP - GNUNET_log_from(GNUNET_ERROR_TYPE_INFO, "udp", _ - ("found->challenge %d, pong->challenge %d\n"), found->challenge, ntohs(pong->challenge)); + GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, "udp", _ + ("found->challenge %d, pong->challenge %d\n"), + found->challenge, ntohs (pong->challenge)); #endif - if ((found != NULL) && (found->challenge == ntohs(pong->challenge))) + if ((found != NULL) && (found->challenge == ntohs (pong->challenge))) { found->validated = GNUNET_YES; - addr_len = ntohs(pong->addrlen); + addr_len = ntohs (pong->addrlen); #if DEBUG_UDP - GNUNET_log_from(GNUNET_ERROR_TYPE_INFO, "udp", _ - ("found associated ping, addr is %u bytes\n"), addr_len); + GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, "udp", _ + ("found associated ping, addr is %u bytes\n"), + addr_len); #endif - memcpy(&addr, &pong[1], addr_len); - plugin->env->notify_validation(plugin->env->cls, "udp", sender, ntohs(pong->challenge), (char *)&addr); + memcpy (&addr, &pong[1], addr_len); + plugin->env->notify_validation (plugin->env->cls, "udp", sender, + ntohs (pong->challenge), + (char *) &addr); } else { #if DEBUG_UDP - GNUNET_log_from(GNUNET_ERROR_TYPE_INFO, "udp", _ - ("Session not found!\n")); + GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, "udp", _ + ("Session not found!\n")); #endif } return; } static void -udp_plugin_select (void *cls, - const struct GNUNET_SCHEDULER_TaskContext *tc) +udp_plugin_select (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { struct Plugin *plugin = cls; - struct GNUNET_TIME_Relative timeout = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 500); - char * buf; + struct GNUNET_TIME_Relative timeout = + GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 500); + char *buf; struct UDPMessage *msg; const struct GNUNET_MessageHeader *hdr; struct GNUNET_PeerIdentity *sender; @@ -468,88 +479,100 @@ udp_plugin_select (void *cls, struct sockaddr_storage addr; ssize_t ret; - do + do { - buflen = GNUNET_NETWORK_socket_recvfrom_amount(udp_sock); + buflen = GNUNET_NETWORK_socket_recvfrom_amount (udp_sock); #if DEBUG_UDP - GNUNET_log_from(GNUNET_ERROR_TYPE_INFO, "udp", _ - ("we expect to read %u bytes\n"), buflen); + GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, "udp", _ + ("we expect to read %u bytes\n"), buflen); #endif if (buflen == GNUNET_NO) return; - buf = GNUNET_malloc(buflen); - fromlen = sizeof(addr); + buf = GNUNET_malloc (buflen); + fromlen = sizeof (addr); #if DEBUG_UDP - GNUNET_log_from(GNUNET_ERROR_TYPE_INFO, "udp", _ - ("src_addr_len is %u\n"), fromlen); + GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, "udp", _ + ("src_addr_len is %u\n"), fromlen); #endif - memset(&addr, 0, fromlen); - ret = GNUNET_NETWORK_socket_recvfrom(udp_sock, buf, buflen, (struct sockaddr *)&addr, &fromlen); + memset (&addr, 0, fromlen); + ret = + GNUNET_NETWORK_socket_recvfrom (udp_sock, buf, buflen, + (struct sockaddr *) &addr, &fromlen); #if DEBUG_UDP - GNUNET_log_from(GNUNET_ERROR_TYPE_INFO, "udp", _ - ("socket_recv returned %u, src_addr_len is %u\n"), ret, fromlen); + GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, "udp", _ + ("socket_recv returned %u, src_addr_len is %u\n"), ret, + fromlen); #endif if (ret <= 0) { - GNUNET_free(buf); + GNUNET_free (buf); return; } - msg = (struct UDPMessage *)buf; + msg = (struct UDPMessage *) buf; #if DEBUG_UDP - GNUNET_log_from(GNUNET_ERROR_TYPE_INFO, "udp", _ - ("header reports message size of %d\n"), ntohs(msg->header.size)); + GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, "udp", _ + ("header reports message size of %d\n"), + ntohs (msg->header.size)); - GNUNET_log_from(GNUNET_ERROR_TYPE_INFO, "udp", _ - ("header reports message type of %d\n"), ntohs(msg->header.type)); + GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, "udp", _ + ("header reports message type of %d\n"), + ntohs (msg->header.type)); #endif /*if (ntohs(hdr->size) < sizeof(struct UDPMessage)) - { - GNUNET_free(buf); - GNUNET_NETWORK_fdset_zero(plugin->rs); - GNUNET_NETWORK_fdset_set(plugin->rs, udp_sock); - break; - }*/ - hdr = (const struct GNUNET_MessageHeader *)&msg[1]; - sender = GNUNET_malloc(sizeof(struct GNUNET_PeerIdentity)); - memcpy(sender, &msg->sender, sizeof(struct GNUNET_PeerIdentity)); + { + GNUNET_free(buf); + GNUNET_NETWORK_fdset_zero(plugin->rs); + GNUNET_NETWORK_fdset_set(plugin->rs, udp_sock); + break; + } */ + hdr = (const struct GNUNET_MessageHeader *) &msg[1]; + sender = GNUNET_malloc (sizeof (struct GNUNET_PeerIdentity)); + memcpy (sender, &msg->sender, sizeof (struct GNUNET_PeerIdentity)); #if DEBUG_UDP - GNUNET_log_from(GNUNET_ERROR_TYPE_INFO, "udp", _ - ("msg reports message size of %d\n"), ntohs(hdr->size)); + GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, "udp", _ + ("msg reports message size of %d\n"), + ntohs (hdr->size)); - GNUNET_log_from(GNUNET_ERROR_TYPE_INFO, "udp", _ - ("msg reports message type of %d\n"), ntohs(hdr->type)); + GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, "udp", _ + ("msg reports message type of %d\n"), + ntohs (hdr->type)); #endif - if (ntohs(hdr->type) == GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_PING) + if (ntohs (hdr->type) == GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_PING) { - handle_udp_ping(plugin, sender, &addr, fromlen, hdr); + handle_udp_ping (plugin, sender, &addr, fromlen, hdr); } - if (ntohs(hdr->type) == GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_PONG) + if (ntohs (hdr->type) == GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_PONG) { - handle_udp_pong(plugin, sender, hdr); + handle_udp_pong (plugin, sender, hdr); } - GNUNET_free(buf); + GNUNET_free (buf); } - while (GNUNET_NETWORK_socket_select (plugin->rs, - NULL, - NULL, - timeout) > 0 && GNUNET_NETWORK_fdset_isset(plugin->rs, udp_sock)); - - plugin->select_task = GNUNET_SCHEDULER_add_select(plugin->env->sched, GNUNET_SCHEDULER_PRIORITY_DEFAULT, GNUNET_SCHEDULER_NO_TASK, - GNUNET_TIME_UNIT_FOREVER_REL, plugin->rs, NULL, &udp_plugin_select, plugin); + while (GNUNET_NETWORK_socket_select (plugin->rs, + NULL, + NULL, + timeout) > 0 + && GNUNET_NETWORK_fdset_isset (plugin->rs, udp_sock)); + + plugin->select_task = + GNUNET_SCHEDULER_add_select (plugin->env->sched, + GNUNET_SCHEDULER_PRIORITY_DEFAULT, + GNUNET_SCHEDULER_NO_TASK, + GNUNET_TIME_UNIT_FOREVER_REL, plugin->rs, + NULL, &udp_plugin_select, plugin); } @@ -569,15 +592,16 @@ udp_transport_server_start (void *cls) desc = NULL; if (GNUNET_YES != - GNUNET_CONFIGURATION_get_value_yesno (plugin->env->cfg, "GNUNETD", "DISABLE-IPV6")) + GNUNET_CONFIGURATION_get_value_yesno (plugin->env->cfg, "GNUNETD", + "DISABLE-IPV6")) { desc = GNUNET_NETWORK_socket_create (PF_INET6, SOCK_DGRAM, 17); if (desc != NULL) { memset (&serverAddrv6, 0, sizeof (serverAddrv6)); - #if HAVE_SOCKADDR_IN_SIN_LEN +#if HAVE_SOCKADDR_IN_SIN_LEN serverAddrv6.sin6_len = sizeof (serverAddrv6); - #endif +#endif serverAddrv6.sin6_family = AF_INET6; serverAddrv6.sin6_addr = in6addr_any; serverAddrv6.sin6_port = htons (plugin->open_port); @@ -590,17 +614,15 @@ udp_transport_server_start (void *cls) desc = GNUNET_NETWORK_socket_create (PF_INET, SOCK_DGRAM, 17); if (NULL == desc) { - GNUNET_log_from(GNUNET_ERROR_TYPE_DEBUG, - "udp", - "socket"); + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "udp", "socket"); return NULL; } else { memset (&serverAddrv4, 0, sizeof (serverAddrv4)); - #if HAVE_SOCKADDR_IN_SIN_LEN +#if HAVE_SOCKADDR_IN_SIN_LEN serverAddrv4.sin_len = sizeof (serverAddrv4); - #endif +#endif serverAddrv4.sin_family = AF_INET; serverAddrv4.sin_addr.s_addr = INADDR_ANY; serverAddrv4.sin_port = htons (plugin->open_port); @@ -611,16 +633,21 @@ udp_transport_server_start (void *cls) if (desc != NULL) { - GNUNET_assert(GNUNET_NETWORK_socket_bind(desc, serverAddr, addrlen) == GNUNET_OK); + GNUNET_assert (GNUNET_NETWORK_socket_bind (desc, serverAddr, addrlen) == + GNUNET_OK); } plugin->rs = GNUNET_NETWORK_fdset_create (); - GNUNET_NETWORK_fdset_zero(plugin->rs); - GNUNET_NETWORK_fdset_set(plugin->rs, desc); + GNUNET_NETWORK_fdset_zero (plugin->rs); + GNUNET_NETWORK_fdset_set (plugin->rs, desc); - plugin->select_task = GNUNET_SCHEDULER_add_select(plugin->env->sched, GNUNET_SCHEDULER_PRIORITY_DEFAULT, GNUNET_SCHEDULER_NO_TASK, - GNUNET_TIME_UNIT_FOREVER_REL, plugin->rs, NULL, &udp_plugin_select, plugin); + plugin->select_task = + GNUNET_SCHEDULER_add_select (plugin->env->sched, + GNUNET_SCHEDULER_PRIORITY_DEFAULT, + GNUNET_SCHEDULER_NO_TASK, + GNUNET_TIME_UNIT_FOREVER_REL, plugin->rs, + NULL, &udp_plugin_select, plugin); return desc; } @@ -641,10 +668,10 @@ udp_transport_server_start (void *cls) */ static int udp_plugin_validate (void *cls, - const struct GNUNET_PeerIdentity *target, - uint32_t challenge, - struct GNUNET_TIME_Relative timeout, - const void *addr, size_t addrlen) + const struct GNUNET_PeerIdentity *target, + uint32_t challenge, + struct GNUNET_TIME_Relative timeout, + const void *addr, size_t addrlen) { struct Plugin *plugin = cls; struct Session *new_session; @@ -653,32 +680,37 @@ udp_plugin_validate (void *cls, if (addrlen <= 0) return GNUNET_SYSERR; - new_session = GNUNET_malloc(sizeof(struct Session)); - new_session->connect_addr = GNUNET_malloc(addrlen); - memcpy(new_session->connect_addr, addr, addrlen); + new_session = GNUNET_malloc (sizeof (struct Session)); + new_session->connect_addr = GNUNET_malloc (addrlen); + memcpy (new_session->connect_addr, addr, addrlen); new_session->connect_alen = addrlen; #if DEBUG_UDP - if (memcmp(target, plugin->env->my_identity, sizeof(struct GNUNET_PeerIdentity)) == 0) + if (memcmp + (target, plugin->env->my_identity, + sizeof (struct GNUNET_PeerIdentity)) == 0) { - GNUNET_log_from(GNUNET_ERROR_TYPE_INFO, "udp", _ - ("definitely adding self to session list... hmmm\n")); + GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, "udp", _ + ("definitely adding self to session list... hmmm\n")); } #endif - memcpy(&new_session->target, target, sizeof(struct GNUNET_PeerIdentity)); + memcpy (&new_session->target, target, sizeof (struct GNUNET_PeerIdentity)); new_session->challenge = challenge; new_session->validated = GNUNET_NO; new_session->next = plugin->sessions; plugin->sessions = new_session; msg = GNUNET_malloc (sizeof (struct UDPPongMessage)); - msg->header.size = htons(sizeof(struct UDPPongMessage)); - msg->header.type = htons(GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_PING); - msg->challenge = htons(challenge); + msg->header.size = htons (sizeof (struct UDPPongMessage)); + msg->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_PING); + msg->challenge = htons (challenge); #if DEBUG_UDP - GNUNET_log_from(GNUNET_ERROR_TYPE_INFO, "udp", _ - ("In validate, header size is %d, type %d, challenge %u\n"), ntohs(msg->header.size), ntohs(msg->header.type), ntohl(msg->challenge)); + GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, "udp", _ + ("In validate, header size is %d, type %d, challenge %u\n"), + ntohs (msg->header.size), ntohs (msg->header.type), + ntohl (msg->challenge)); #endif - udp_plugin_send(plugin, target, GNUNET_SCHEDULER_PRIORITY_DEFAULT, &msg->header, timeout, NULL, NULL); + udp_plugin_send (plugin, target, GNUNET_SCHEDULER_PRIORITY_DEFAULT, + &msg->header, timeout, NULL, NULL); return GNUNET_OK; } @@ -766,39 +798,41 @@ libgnunet_plugin_transport_udp_init (void *cls) service = GNUNET_SERVICE_start ("transport-udp", env->sched, env->cfg); if (service == NULL) { - GNUNET_log_from(GNUNET_ERROR_TYPE_WARNING, "udp", _ - ("Failed to start service for `%s' transport plugin.\n"), "udp"); + GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, "udp", _ + ("Failed to start service for `%s' transport plugin.\n"), + "udp"); return NULL; } - aport = 0; - if ((GNUNET_OK != - GNUNET_CONFIGURATION_get_value_number (env->cfg, - "transport-udp", - "PORT", - &bport)) || - (bport > 65535) || - ((GNUNET_OK == - GNUNET_CONFIGURATION_get_value_number (env->cfg, - "transport-udp", - "ADVERTISED-PORT", - &aport)) && (aport > 65535))) - { - GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, - "udp", - _ - ("Require valid port number for service `%s' in configuration!\n"), - "transport-udp"); - GNUNET_SERVICE_stop (service); - return NULL; - } - if (aport == 0) - aport = bport; + aport = 0; + if ((GNUNET_OK != + GNUNET_CONFIGURATION_get_value_number (env->cfg, + "transport-udp", + "PORT", + &bport)) || + (bport > 65535) || + ((GNUNET_OK == + GNUNET_CONFIGURATION_get_value_number (env->cfg, + "transport-udp", + "ADVERTISED-PORT", + &aport)) && (aport > 65535))) + { + GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, + "udp", + _ + ("Require valid port number for service `%s' in configuration!\n"), + "transport-udp"); + GNUNET_SERVICE_stop (service); + return NULL; + } + if (aport == 0) + aport = bport; mtu = 1240; if (mtu < 1200) - GNUNET_log_from(GNUNET_ERROR_TYPE_INFO, - "udp", - _("MTU %llu for `%s' is probably too low!\n"), mtu, "UDP"); + GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, + "udp", + _("MTU %llu for `%s' is probably too low!\n"), mtu, + "UDP"); plugin = GNUNET_malloc (sizeof (struct Plugin)); plugin->open_port = bport; @@ -818,9 +852,9 @@ libgnunet_plugin_transport_udp_init (void *cls) api->cost_estimate = 17; /* TODO: ATS */ plugin->service = service; - udp_sock = udp_transport_server_start(plugin); + udp_sock = udp_transport_server_start (plugin); - GNUNET_assert(udp_sock != NULL); + GNUNET_assert (udp_sock != NULL); return api; } @@ -831,7 +865,7 @@ libgnunet_plugin_transport_udp_done (void *cls) struct GNUNET_TRANSPORT_PluginFunctions *api = cls; struct Plugin *plugin = api->cls; - udp_transport_server_stop(plugin); + udp_transport_server_stop (plugin); if (NULL != hostname_dns) { GNUNET_RESOLVER_request_cancel (hostname_dns); diff --git a/src/transport/test_plugin_transport.c b/src/transport/test_plugin_transport.c index d4183fc27..407150d3a 100644 --- a/src/transport/test_plugin_transport.c +++ b/src/transport/test_plugin_transport.c @@ -93,24 +93,20 @@ static int ok; * Initialize Environment for this plugin */ static void -receive(void *cls, - struct GNUNET_TIME_Relative - latency, - const struct GNUNET_PeerIdentity - * peer, - const struct GNUNET_MessageHeader - * message) +receive (void *cls, + struct GNUNET_TIME_Relative + latency, + const struct GNUNET_PeerIdentity + *peer, const struct GNUNET_MessageHeader *message) { /* do nothing */ } -void notify_address(void *cls, - const char *name, - const void *addr, - size_t addrlen, - struct - GNUNET_TIME_Relative - expires) +void +notify_address (void *cls, + const char *name, + const void *addr, + size_t addrlen, struct GNUNET_TIME_Relative expires) { } @@ -122,19 +118,19 @@ void notify_address(void *cls, * @param cfg configuration to use */ static void -unload_plugins (void *cls, - const struct GNUNET_CONFIGURATION_Handle *cfg) -{ - GNUNET_assert (NULL == GNUNET_PLUGIN_unload ("libgnunet_plugin_transport_tcp",api)); +unload_plugins (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg) +{ + GNUNET_assert (NULL == + GNUNET_PLUGIN_unload ("libgnunet_plugin_transport_tcp", + api)); if (my_private_key != NULL) GNUNET_CRYPTO_rsa_key_free (my_private_key); - + } static void -unload_task (void *cls, - const struct GNUNET_SCHEDULER_TaskContext *tc) +unload_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { struct GNUNET_CONFIGURATION_Handle *cfg = cls; unload_plugins (NULL, cfg); @@ -144,12 +140,11 @@ unload_task (void *cls, static GNUNET_SCHEDULER_TaskIdentifier validation_timeout_task; -static void +static void validation_notification (void *cls, - const char *name, - const struct GNUNET_PeerIdentity *peer, - uint32_t challenge, - const char *sender_addr) + const char *name, + const struct GNUNET_PeerIdentity *peer, + uint32_t challenge, const char *sender_addr) { if (validation_timeout_task != GNUNET_SCHEDULER_NO_TASK) { @@ -158,24 +153,23 @@ validation_notification (void *cls, } GNUNET_assert (challenge == 42); - - ok = 0; /* if the last test succeeded, report success */ + + ok = 0; /* if the last test succeeded, report success */ GNUNET_SCHEDULER_add_continuation (sched, - &unload_task, - (void*) cfg, - GNUNET_SCHEDULER_REASON_PREREQ_DONE); + &unload_task, + (void *) cfg, + GNUNET_SCHEDULER_REASON_PREREQ_DONE); } static void -validation_failed (void *cls, - const struct GNUNET_SCHEDULER_TaskContext *tc) +validation_failed (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { validation_timeout_task = GNUNET_SCHEDULER_NO_TASK; - GNUNET_break (0); /* output error */ + GNUNET_break (0); /* output error */ /* the "validation_notification" was not called in a timely fashion; we should set an error - code for main and shut down */ + code for main and shut down */ unload_plugins (NULL, cfg); } @@ -198,42 +192,36 @@ static void test_validation () { struct sockaddr_in soaddr; - - memset (&soaddr, 0, sizeof(soaddr)); + + memset (&soaddr, 0, sizeof (soaddr)); #if HAVE_SOCKADDR_IN_SIN_LEN soaddr.sin_len = sizeof (soaddr); #endif soaddr.sin_family = AF_INET; - soaddr.sin_port = htons(2368 /* FIXME: get from config! */); + soaddr.sin_port = htons (2368 /* FIXME: get from config! */ ); soaddr.sin_addr.s_addr = htonl (INADDR_LOOPBACK); api->validate (api->cls, - &my_identity, - 42, - TIMEOUT, - &soaddr, - sizeof(soaddr)); + &my_identity, 42, TIMEOUT, &soaddr, sizeof (soaddr)); /* add job to catch failure (timeout) */ validation_timeout_task = - GNUNET_SCHEDULER_add_delayed (sched, - TIMEOUT, - &validation_failed, - NULL); + GNUNET_SCHEDULER_add_delayed (sched, TIMEOUT, &validation_failed, NULL); } -static void setup_plugin_environment() +static void +setup_plugin_environment () { - env.cfg = cfg; + env.cfg = cfg; env.sched = sched; env.my_public_key = &my_public_key; env.my_private_key = my_private_key; env.my_identity = &my_identity; - env.cls=&env; - env.receive=&receive; - env.notify_address=¬ify_address; + env.cls = &env; + env.receive = &receive; + env.notify_address = ¬ify_address; env.notify_validation = &validation_notification; - env.max_connections = max_connect_per_transport; -} + env.max_connections = max_connect_per_transport; +} /** @@ -247,9 +235,8 @@ static void run (void *cls, struct GNUNET_SCHEDULER_Handle *s, char *const *args, - const char *cfgfile, - const struct GNUNET_CONFIGURATION_Handle *c) -{ + const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) +{ unsigned long long tneigh; char *keyfile; char *libname; @@ -268,7 +255,8 @@ run (void *cls, "HOSTKEY", &keyfile))) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Transport service is lacking key configuration settings. Exiting.\n")); + _ + ("Transport service is lacking key configuration settings. Exiting.\n")); GNUNET_SCHEDULER_shutdown (s); return; } @@ -278,25 +266,23 @@ run (void *cls, if (my_private_key == NULL) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Transport service could not access hostkey. Exiting.\n")); + _ + ("Transport service could not access hostkey. Exiting.\n")); GNUNET_SCHEDULER_shutdown (s); return; } - GNUNET_CRYPTO_rsa_key_get_public (my_private_key, - &my_public_key); + GNUNET_CRYPTO_rsa_key_get_public (my_private_key, &my_public_key); GNUNET_CRYPTO_hash (&my_public_key, - sizeof (my_public_key), - &my_identity.hashPubKey); - - - - /* load plugins... */ - setup_plugin_environment(); - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Loading tcp transport plugin\n")); + sizeof (my_public_key), &my_identity.hashPubKey); + + + + /* load plugins... */ + setup_plugin_environment (); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Loading tcp transport plugin\n")); GNUNET_asprintf (&libname, "libgnunet_plugin_transport_tcp"); - api = GNUNET_PLUGIN_load(libname, &env); + api = GNUNET_PLUGIN_load (libname, &env); GNUNET_free (libname); if (api == NULL) { @@ -304,7 +290,7 @@ run (void *cls, _("Failed to load transport plugin for tcp\n")); /* FIXME: set some error code for main */ return; - } + } test_validation (); } @@ -334,22 +320,20 @@ main (int argc, char *const *argv) "WARNING", #endif NULL - }; + }; GNUNET_log_setup ("test-plugin-transport", #if VERBOSE "DEBUG", #else "WARNING", #endif - NULL); - ok = 1; /* set to fail */ + NULL); + ok = 1; /* set to fail */ ret = (GNUNET_OK == - GNUNET_PROGRAM_run (5, - argv_prog, - "test-plugin-transport", - "testcase", - options, - &run, NULL)) ? ok : 1; + GNUNET_PROGRAM_run (5, + argv_prog, + "test-plugin-transport", + "testcase", options, &run, NULL)) ? ok : 1; GNUNET_DISK_directory_remove ("/tmp/test-gnunetd-plugin-transport"); return ret; } diff --git a/src/transport/test_plugin_transport_udp.c b/src/transport/test_plugin_transport_udp.c index 27140a311..62e12e1cd 100644 --- a/src/transport/test_plugin_transport_udp.c +++ b/src/transport/test_plugin_transport_udp.c @@ -94,24 +94,20 @@ static int ok; * Initialize Environment for this plugin */ static void -receive(void *cls, - struct GNUNET_TIME_Relative - latency, - const struct GNUNET_PeerIdentity - * peer, - const struct GNUNET_MessageHeader - * message) +receive (void *cls, + struct GNUNET_TIME_Relative + latency, + const struct GNUNET_PeerIdentity + *peer, const struct GNUNET_MessageHeader *message) { /* do nothing */ } -void notify_address(void *cls, - const char *name, - const void *addr, - size_t addrlen, - struct - GNUNET_TIME_Relative - expires) +void +notify_address (void *cls, + const char *name, + const void *addr, + size_t addrlen, struct GNUNET_TIME_Relative expires) { } @@ -123,10 +119,11 @@ void notify_address(void *cls, * @param cfg configuration to use */ static void -unload_plugins (void *cls, - const struct GNUNET_CONFIGURATION_Handle *cfg) +unload_plugins (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg) { - GNUNET_assert (NULL == GNUNET_PLUGIN_unload ("libgnunet_plugin_transport_udp",api)); + GNUNET_assert (NULL == + GNUNET_PLUGIN_unload ("libgnunet_plugin_transport_udp", + api)); if (my_private_key != NULL) GNUNET_CRYPTO_rsa_key_free (my_private_key); @@ -134,8 +131,7 @@ unload_plugins (void *cls, static void -unload_task (void *cls, - const struct GNUNET_SCHEDULER_TaskContext *tc) +unload_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { struct GNUNET_CONFIGURATION_Handle *cfg = cls; unload_plugins (NULL, cfg); @@ -149,8 +145,7 @@ static void validation_notification (void *cls, const char *name, const struct GNUNET_PeerIdentity *peer, - uint32_t challenge, - const char *sender_addr) + uint32_t challenge, const char *sender_addr) { if (validation_timeout_task != GNUNET_SCHEDULER_NO_TASK) { @@ -160,21 +155,20 @@ validation_notification (void *cls, GNUNET_assert (challenge == 42); - ok = 0; /* if the last test succeeded, report success */ + ok = 0; /* if the last test succeeded, report success */ GNUNET_SCHEDULER_add_continuation (sched, &unload_task, - (void*) cfg, + (void *) cfg, GNUNET_SCHEDULER_REASON_PREREQ_DONE); } static void -validation_failed (void *cls, - const struct GNUNET_SCHEDULER_TaskContext *tc) +validation_failed (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { validation_timeout_task = GNUNET_SCHEDULER_NO_TASK; - GNUNET_break (0); /* output error */ + GNUNET_break (0); /* output error */ /* the "validation_notification" was not called in a timely fashion; we should set an error code for main and shut down */ @@ -201,43 +195,38 @@ test_validation () { struct sockaddr_in soaddr; - memset (&soaddr, 0, sizeof(soaddr)); + memset (&soaddr, 0, sizeof (soaddr)); #if HAVE_SOCKADDR_IN_SIN_LEN soaddr.sin_len = sizeof (soaddr); #endif soaddr.sin_family = AF_INET; - soaddr.sin_port = htons(2368 /* FIXME: get from config! */); + soaddr.sin_port = htons (2368 /* FIXME: get from config! */ ); soaddr.sin_addr.s_addr = htonl (INADDR_LOOPBACK); /* add job to catch failure (timeout) */ validation_timeout_task = - GNUNET_SCHEDULER_add_delayed (sched, - TIMEOUT, - &validation_failed, - NULL); + GNUNET_SCHEDULER_add_delayed (sched, TIMEOUT, &validation_failed, NULL); api->validate (api->cls, - &my_identity, - 42, - TIMEOUT, - &soaddr, - sizeof(soaddr)); + &my_identity, 42, TIMEOUT, &soaddr, sizeof (soaddr)); } -static void setup_plugin_environment() +static void +setup_plugin_environment () { - env.cfg = cfg; + env.cfg = cfg; env.sched = sched; env.my_public_key = &my_public_key; env.my_private_key = my_private_key; env.my_identity = &my_identity; - env.cls=&env; - env.receive=&receive; - env.notify_address=¬ify_address; + env.cls = &env; + env.receive = &receive; + env.notify_address = ¬ify_address; env.notify_validation = &validation_notification; env.max_connections = max_connect_per_transport; } + static int retx; /** @@ -251,8 +240,7 @@ static void run (void *cls, struct GNUNET_SCHEDULER_Handle *s, char *const *args, - const char *cfgfile, - const struct GNUNET_CONFIGURATION_Handle *c) + const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) { unsigned long long tneigh; char *keyfile; @@ -272,7 +260,8 @@ run (void *cls, "HOSTKEY", &keyfile))) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Transport service is lacking key configuration settings. Exiting.\n")); + _ + ("Transport service is lacking key configuration settings. Exiting.\n")); GNUNET_SCHEDULER_shutdown (s); return; } @@ -282,23 +271,21 @@ run (void *cls, if (my_private_key == NULL) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Transport service could not access hostkey. Exiting.\n")); + _ + ("Transport service could not access hostkey. Exiting.\n")); GNUNET_SCHEDULER_shutdown (s); return; } - GNUNET_CRYPTO_rsa_key_get_public (my_private_key, - &my_public_key); + GNUNET_CRYPTO_rsa_key_get_public (my_private_key, &my_public_key); GNUNET_CRYPTO_hash (&my_public_key, - sizeof (my_public_key), - &my_identity.hashPubKey); + sizeof (my_public_key), &my_identity.hashPubKey); /* load plugins... */ - setup_plugin_environment(); - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Loading udp transport plugin\n")); + setup_plugin_environment (); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Loading udp transport plugin\n")); GNUNET_asprintf (&libname, "libgnunet_plugin_transport_udp"); - api = GNUNET_PLUGIN_load(libname, &env); + api = GNUNET_PLUGIN_load (libname, &env); GNUNET_free (libname); if (api == NULL) { @@ -344,14 +331,12 @@ main (int argc, char *const *argv) "WARNING", #endif NULL); - ok = 1; /* set to fail */ + ok = 1; /* set to fail */ ret = (GNUNET_OK == - GNUNET_PROGRAM_run (5, - argv_prog, - "test-plugin-transport", - "testcase", - options, - &run, NULL)) ? ok : 1; + GNUNET_PROGRAM_run (5, + argv_prog, + "test-plugin-transport", + "testcase", options, &run, NULL)) ? ok : 1; GNUNET_DISK_directory_remove ("/tmp/test-gnunetd-plugin-transport"); return ret; } diff --git a/src/transport/test_transport_api.c b/src/transport/test_transport_api.c index 90e12d75b..a5afc5fe4 100644 --- a/src/transport/test_transport_api.c +++ b/src/transport/test_transport_api.c @@ -120,10 +120,8 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_TIME_Relative latency) { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Peer `%4s' connected to us (%p)!\n", - GNUNET_i2s(peer), - cls); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Peer `%4s' connected to us (%p)!\n", GNUNET_i2s (peer), cls); GNUNET_assert ((ok >= 1) && (ok <= 6)); OKPP; } @@ -197,14 +195,15 @@ exchange_hello_last (void *cls, GNUNET_assert (message != NULL); GNUNET_assert (GNUNET_OK == GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) - message, &me->id)); + message, &me->id)); GNUNET_TRANSPORT_offer_hello (p1.th, message); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Finished exchanging HELLOs, now waiting for transmission!\n"); /* both HELLOs exchanged, get ready to test transmission! */ GNUNET_TRANSPORT_notify_transmit_ready (p1.th, &p2.id, - 256, 0, TIMEOUT, ¬ify_ready, &p1); + 256, 0, TIMEOUT, ¬ify_ready, + &p1); } @@ -223,10 +222,8 @@ exchange_hello (void *cls, GNUNET_assert (message != NULL); GNUNET_assert (GNUNET_OK == GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) - message, &me->id)); - GNUNET_TRANSPORT_get_hello (p2.th, - TIMEOUT, - &exchange_hello_last, &p2); + message, &me->id)); + GNUNET_TRANSPORT_get_hello (p2.th, TIMEOUT, &exchange_hello_last, &p2); } @@ -234,16 +231,14 @@ static void run (void *cls, struct GNUNET_SCHEDULER_Handle *s, char *const *args, - const char *cfgfile, - const struct GNUNET_CONFIGURATION_Handle *cfg) + const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) { GNUNET_assert (ok == 1); OKPP; sched = s; setup_peer (&p1, "test_transport_api_peer1.conf"); setup_peer (&p2, "test_transport_api_peer2.conf"); - GNUNET_TRANSPORT_get_hello (p1.th, - TIMEOUT, &exchange_hello, &p1); + GNUNET_TRANSPORT_get_hello (p1.th, TIMEOUT, &exchange_hello, &p1); } @@ -253,7 +248,7 @@ stop_arm (struct PeerContext *p) #if START_ARM if (0 != PLIBC_KILL (p->arm_pid, SIGTERM)) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); - GNUNET_OS_process_wait(p->arm_pid); + GNUNET_OS_process_wait (p->arm_pid); #endif GNUNET_CONFIGURATION_destroy (p->cfg); } @@ -296,7 +291,7 @@ main (int argc, char *argv[]) #endif NULL); ret = check (); - GNUNET_DISK_directory_remove ("/tmp/test-gnunetd-transport-peer-1"); + GNUNET_DISK_directory_remove ("/tmp/test-gnunetd-transport-peer-1"); GNUNET_DISK_directory_remove ("/tmp/test-gnunetd-transport-peer-2"); return ret; } diff --git a/src/transport/transport_api.c b/src/transport/transport_api.c index 7adec78c9..155347bf0 100644 --- a/src/transport/transport_api.c +++ b/src/transport/transport_api.c @@ -379,7 +379,7 @@ transport_notify_ready (void *cls, size_t size, void *buf) { #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Could not transmit to transport service, cancelling pending requests\n"); + "Could not transmit to transport service, cancelling pending requests\n"); #endif th = h->connect_ready_head; if (th->next != NULL) @@ -391,17 +391,16 @@ transport_notify_ready (void *cls, size_t size, void *buf) n->transmit_handle = NULL; } if (th->notify_delay_task != GNUNET_SCHEDULER_NO_TASK) - { - GNUNET_SCHEDULER_cancel (h->sched, - th->notify_delay_task); - th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; - } + { + GNUNET_SCHEDULER_cancel (h->sched, th->notify_delay_task); + th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; + } GNUNET_assert (0 == th->notify (th->notify_cls, 0, NULL)); GNUNET_free (th); - if (h->connect_ready_head != NULL) - schedule_transmission (h); /* FIXME: is this ok? */ + if (h->connect_ready_head != NULL) + schedule_transmission (h); /* FIXME: is this ok? */ return 0; - } + } #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ready to transmit %u bytes to transport service\n", size); @@ -415,11 +414,10 @@ transport_notify_ready (void *cls, size_t size, void *buf) { th = h->connect_ready_head; if (th->notify_delay_task != GNUNET_SCHEDULER_NO_TASK) - { - GNUNET_SCHEDULER_cancel (h->sched, - th->notify_delay_task); - th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; - } + { + GNUNET_SCHEDULER_cancel (h->sched, th->notify_delay_task); + th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; + } GNUNET_assert (th->notify_size <= size); if (th->next != NULL) th->next->prev = NULL; @@ -458,18 +456,17 @@ schedule_transmission (struct GNUNET_TRANSPORT_Handle *h) if (h->client == NULL) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Could not yet schedule transmission: we are not yet connected to the transport service!\n"); - return; /* not yet connected */ + "Could not yet schedule transmission: we are not yet connected to the transport service!\n"); + return; /* not yet connected */ } th = h->connect_ready_head; if (th == NULL) - return; /* no request pending */ + return; /* no request pending */ if (th->notify_delay_task != GNUNET_SCHEDULER_NO_TASK) { /* remove existing time out task, will be integrated - with transmit_ready notification! */ - GNUNET_SCHEDULER_cancel (h->sched, - th->notify_delay_task); + with transmit_ready notification! */ + GNUNET_SCHEDULER_cancel (h->sched, th->notify_delay_task); th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; } h->transmission_scheduled = GNUNET_YES; @@ -477,7 +474,7 @@ schedule_transmission (struct GNUNET_TRANSPORT_Handle *h) th->notify_size, GNUNET_TIME_absolute_get_remaining (th->timeout), - GNUNET_NO, + GNUNET_NO, &transport_notify_ready, h); GNUNET_assert (NULL != h->network_handle); @@ -564,8 +561,7 @@ remove_from_any_list (struct GNUNET_TRANSPORT_TransmitHandle *th) * @param th handle for a request to transmit once we * have connected */ -static void -try_connect (struct GNUNET_TRANSPORT_TransmitHandle *th); +static void try_connect (struct GNUNET_TRANSPORT_TransmitHandle *th); /** @@ -575,7 +571,8 @@ try_connect (struct GNUNET_TRANSPORT_TransmitHandle *th); * TransmitHandle. */ static void -peer_transmit_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) +peer_transmit_timeout (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc) { struct GNUNET_TRANSPORT_TransmitHandle *th = cls; @@ -583,9 +580,9 @@ peer_transmit_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (th->neighbour != NULL) th->neighbour->transmit_handle = NULL; #if DEBUG_TRANSPORT - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Request for transmission to peer `%s' timed out.\n", - GNUNET_i2s(&th->target)); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Request for transmission to peer `%s' timed out.\n", + GNUNET_i2s (&th->target)); #endif remove_from_any_list (th); th->notify (th->notify_cls, 0, NULL); @@ -619,9 +616,8 @@ schedule_control_transmit (struct GNUNET_TRANSPORT_Handle *h, #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Control transmit of %u bytes within %llums requested\n", - size, - (unsigned long long) timeout.value); + "Control transmit of %u bytes within %llums requested\n", + size, (unsigned long long) timeout.value); #endif th = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_TransmitHandle)); th->handle = h; @@ -629,10 +625,9 @@ schedule_control_transmit (struct GNUNET_TRANSPORT_Handle *h, th->notify_cls = notify_cls; th->timeout = GNUNET_TIME_relative_to_absolute (timeout); th->notify_size = size; - th->notify_delay_task + th->notify_delay_task = GNUNET_SCHEDULER_add_delayed (h->sched, - timeout, - &peer_transmit_timeout, th); + timeout, &peer_transmit_timeout, th); if (at_head) { th->next = h->connect_ready_head; @@ -798,14 +793,16 @@ hello_wait_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("First attempt to obtain `%s' from transport service failed, will try again for %llums.\n"), - "HELLO", - GNUNET_TIME_absolute_get_remaining (hwl->timeout).value); + _ + ("First attempt to obtain `%s' from transport service failed, will try again for %llums.\n"), + "HELLO", + GNUNET_TIME_absolute_get_remaining (hwl->timeout).value); #endif hwl->task = GNUNET_SCHEDULER_add_delayed (hwl->handle->sched, - GNUNET_TIME_absolute_get_remaining (hwl->timeout), + GNUNET_TIME_absolute_get_remaining + (hwl->timeout), &hello_wait_timeout, hwl); - return; + return; } /* signal timeout */ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, @@ -988,14 +985,13 @@ request_connect (void *cls, size_t size, void *buf) #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Failed to transmit `%s' request for `%4s' to service.\n", - "TRY_CONNECT", - GNUNET_i2s(&th->target)); + "TRY_CONNECT", GNUNET_i2s (&th->target)); #endif if (th->notify_delay_task != GNUNET_SCHEDULER_NO_TASK) - { - GNUNET_SCHEDULER_cancel (h->sched, th->notify_delay_task); - th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; - } + { + GNUNET_SCHEDULER_cancel (h->sched, th->notify_delay_task); + th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; + } th->notify (th->notify_cls, 0, NULL); GNUNET_free (th); return 0; @@ -1004,7 +1000,7 @@ request_connect (void *cls, size_t size, void *buf) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transmitting `%s' message for `%4s' (need connection in %llu ms).\n", "TRY_CONNECT", GNUNET_i2s (&th->target), - GNUNET_TIME_absolute_get_remaining (th->timeout).value); + GNUNET_TIME_absolute_get_remaining (th->timeout).value); #endif GNUNET_assert (size >= sizeof (struct TryConnectMessage)); tcm = buf; @@ -1014,9 +1010,9 @@ request_connect (void *cls, size_t size, void *buf) memcpy (&tcm->peer, &th->target, sizeof (struct GNUNET_PeerIdentity)); th->notify_delay_task = GNUNET_SCHEDULER_add_delayed (h->sched, - GNUNET_TIME_absolute_get_remaining - (th->timeout), - &peer_transmit_timeout, th); + GNUNET_TIME_absolute_get_remaining + (th->timeout), + &peer_transmit_timeout, th); insert_transmit_handle (&h->connect_wait_head, th); return sizeof (struct TryConnectMessage); } @@ -1033,7 +1029,7 @@ request_connect (void *cls, size_t size, void *buf) static void try_connect (struct GNUNET_TRANSPORT_TransmitHandle *th) { - GNUNET_assert (th->notify_delay_task == GNUNET_SCHEDULER_NO_TASK); + GNUNET_assert (th->notify_delay_task == GNUNET_SCHEDULER_NO_TASK); schedule_control_transmit (th->handle, sizeof (struct TryConnectMessage), GNUNET_NO, @@ -1050,10 +1046,9 @@ try_connect (struct GNUNET_TRANSPORT_TransmitHandle *th) * @param tc scheduler information about why we were triggered (not used) */ static void -try_connect_task (void *cls, - const struct GNUNET_SCHEDULER_TaskContext *tc) +try_connect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { - struct GNUNET_TRANSPORT_TransmitHandle *th = cls; + struct GNUNET_TRANSPORT_TransmitHandle *th = cls; th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; try_connect (th); @@ -1079,14 +1074,12 @@ remove_neighbour (struct GNUNET_TRANSPORT_Handle *h, #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Removing neighbour `%s' from list of connected peers.\n", - GNUNET_i2s (peer)); + GNUNET_i2s (peer)); #endif prev = NULL; pos = h->neighbours; while ((pos != NULL) && - (0 != memcmp (peer, - &pos->id, - sizeof (struct GNUNET_PeerIdentity)))) + (0 != memcmp (peer, &pos->id, sizeof (struct GNUNET_PeerIdentity)))) { prev = pos; pos = pos->next; @@ -1105,29 +1098,31 @@ remove_neighbour (struct GNUNET_TRANSPORT_Handle *h, pos->transmit_handle = NULL; th->neighbour = NULL; remove_from_any_list (th); - if (GNUNET_TIME_absolute_get_remaining (th->timeout).value <= CONNECT_RETRY_TIMEOUT.value) - { - /* signal error */ - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Connection with `%4s' failed and timeout was in the past, giving up on message delivery.\n"), - GNUNET_i2s (peer)); - GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == th->notify_delay_task); - peer_transmit_timeout (th, NULL); - } + if (GNUNET_TIME_absolute_get_remaining (th->timeout).value <= + CONNECT_RETRY_TIMEOUT.value) + { + /* signal error */ + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + _ + ("Connection with `%4s' failed and timeout was in the past, giving up on message delivery.\n"), + GNUNET_i2s (peer)); + GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == th->notify_delay_task); + peer_transmit_timeout (th, NULL); + } else - { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Connection with `%4s' failed, will keep trying for %llu ms to deliver message\n"), - GNUNET_i2s (peer), - GNUNET_TIME_absolute_get_remaining (th->timeout).value); - /* try again in a bit */ - GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == th->notify_delay_task); - th->notify_delay_task - = GNUNET_SCHEDULER_add_delayed (h->sched, - CONNECT_RETRY_TIMEOUT, - &try_connect_task, - th); - } + { + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + _ + ("Connection with `%4s' failed, will keep trying for %llu ms to deliver message\n"), + GNUNET_i2s (peer), + GNUNET_TIME_absolute_get_remaining (th->timeout).value); + /* try again in a bit */ + GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == th->notify_delay_task); + th->notify_delay_task + = GNUNET_SCHEDULER_add_delayed (h->sched, + CONNECT_RETRY_TIMEOUT, + &try_connect_task, th); + } } if (h->nc_cb != NULL) h->nd_cb (h->cls, peer); @@ -1170,12 +1165,11 @@ reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (pos->next != NULL) pos->next->prev = pos->prev; GNUNET_assert (pos->neighbour == NULL); - if (GNUNET_SCHEDULER_NO_TASK != pos->notify_delay_task) - { - GNUNET_SCHEDULER_cancel (h->sched, - pos->notify_delay_task); - pos->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; - } + if (GNUNET_SCHEDULER_NO_TASK != pos->notify_delay_task) + { + GNUNET_SCHEDULER_cancel (h->sched, pos->notify_delay_task); + pos->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; + } GNUNET_free (pos); break; } @@ -1184,8 +1178,7 @@ reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) schedule_control_transmit (h, sizeof (struct GNUNET_MessageHeader), GNUNET_YES, - GNUNET_TIME_UNIT_FOREVER_REL, - &send_start, NULL); + GNUNET_TIME_UNIT_FOREVER_REL, &send_start, NULL); GNUNET_CLIENT_receive (h->client, &demultiplexer, h, GNUNET_TIME_UNIT_FOREVER_REL); } @@ -1292,8 +1285,7 @@ schedule_request (struct GNUNET_TRANSPORT_TransmitHandle *th) #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Would need %llu ms before bandwidth is available for delivery to `%4s', that is too long. Signaling timeout.\n", - duration.value, - GNUNET_i2s(&th->target)); + duration.value, GNUNET_i2s (&th->target)); #endif remove_from_wait_list (th); th->notify (th->notify_cls, 0, NULL); @@ -1303,8 +1295,7 @@ schedule_request (struct GNUNET_TRANSPORT_TransmitHandle *th) #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Need more bandwidth, delaying delivery to `%4s' by %llu ms\n", - GNUNET_i2s(&th->target), - duration.value); + GNUNET_i2s (&th->target), duration.value); #endif th->notify_delay_task = GNUNET_SCHEDULER_add_delayed (h->sched, @@ -1328,14 +1319,16 @@ schedule_request (struct GNUNET_TRANSPORT_TransmitHandle *th) th->notify_delay_task = GNUNET_SCHEDULER_add_delayed (h->sched, GNUNET_TIME_absolute_get_remaining - (th->timeout), &peer_transmit_timeout, th); + (th->timeout), &peer_transmit_timeout, + th); return; } n->transmit_ok = GNUNET_NO; remove_from_wait_list (th); #if DEBUG_TRANSPORT - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Moving message for `%4s' to ready list\n", - GNUNET_i2s(&n->id)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Moving message for `%4s' to ready list\n", + GNUNET_i2s (&n->id)); #endif insert_transmit_handle (&h->connect_ready_head, th); if (GNUNET_NO == h->transmission_scheduled) @@ -1394,24 +1387,23 @@ add_neighbour (struct GNUNET_TRANSPORT_Handle *h, if (GNUNET_YES == n->received_ack) { #if DEBUG_TRANSPORT - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Found pending request for `%4s' will trigger it now.\n", - GNUNET_i2s (&pos->target)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Found pending request for `%4s' will trigger it now.\n", + GNUNET_i2s (&pos->target)); #endif - if (pos->notify_delay_task != GNUNET_SCHEDULER_NO_TASK) - { - GNUNET_SCHEDULER_cancel (h->sched, pos->notify_delay_task); - pos->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; - } + if (pos->notify_delay_task != GNUNET_SCHEDULER_NO_TASK) + { + GNUNET_SCHEDULER_cancel (h->sched, pos->notify_delay_task); + pos->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; + } schedule_request (pos); } else { #if DEBUG_TRANSPORT - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Found pending request for `%4s' but still need `%s' before proceeding.\n", - GNUNET_i2s (&pos->target), - "ACK"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Found pending request for `%4s' but still need `%s' before proceeding.\n", + GNUNET_i2s (&pos->target), "ACK"); #endif } break; @@ -1470,8 +1462,7 @@ GNUNET_TRANSPORT_disconnect (struct GNUNET_TRANSPORT_Handle *handle) struct GNUNET_CLIENT_Connection *client; #if DEBUG_TRANSPORT - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Transport disconnect called!\n"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transport disconnect called!\n"); #endif while (NULL != (th = handle->connect_ready_head)) { @@ -1499,15 +1490,15 @@ GNUNET_TRANSPORT_disconnect (struct GNUNET_TRANSPORT_Handle *handle) { handle->neighbours = n->next; if (NULL != (th = n->transmit_handle)) - { - if (th->notify_delay_task != GNUNET_SCHEDULER_NO_TASK) - { - GNUNET_SCHEDULER_cancel (handle->sched, th->notify_delay_task); - th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; - } - th->notify (th->notify_cls, 0, NULL); - GNUNET_free (th); - } + { + if (th->notify_delay_task != GNUNET_SCHEDULER_NO_TASK) + { + GNUNET_SCHEDULER_cancel (handle->sched, th->notify_delay_task); + th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; + } + th->notify (th->notify_cls, 0, NULL); + GNUNET_free (th); + } GNUNET_free (n); } while (NULL != (hwl = handle->hwl_head)) @@ -1515,8 +1506,9 @@ GNUNET_TRANSPORT_disconnect (struct GNUNET_TRANSPORT_Handle *handle) handle->hwl_head = hwl->next; GNUNET_SCHEDULER_cancel (handle->sched, hwl->task); GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - _("Disconnect while trying to obtain `%s' from transport service.\n"), - "HELLO"); + _ + ("Disconnect while trying to obtain `%s' from transport service.\n"), + "HELLO"); if (hwl->rec != NULL) hwl->rec (hwl->rec_cls, GNUNET_TIME_UNIT_ZERO, NULL, NULL); GNUNET_free (hwl); @@ -1528,7 +1520,8 @@ GNUNET_TRANSPORT_disconnect (struct GNUNET_TRANSPORT_Handle *handle) } GNUNET_free_non_null (handle->my_hello); handle->my_hello = NULL; - GNUNET_ARM_stop_services (handle->cfg, handle->sched, "transport", "peerinfo", NULL); + GNUNET_ARM_stop_services (handle->cfg, handle->sched, "transport", + "peerinfo", NULL); if (NULL != handle->network_handle) { GNUNET_CLIENT_notify_transmit_ready_cancel (handle->network_handle); @@ -1582,14 +1575,15 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg) GNUNET_CLIENT_notify_transmit_ready_cancel (h->network_handle); h->network_handle = NULL; h->transmission_scheduled = GNUNET_NO; - th = h->connect_ready_head; - /* add timeout again, we cancelled the transmit_ready task! */ - GNUNET_assert (th->notify_delay_task == GNUNET_SCHEDULER_NO_TASK); - th->notify_delay_task - = GNUNET_SCHEDULER_add_delayed (h->sched, - GNUNET_TIME_absolute_get_remaining(th->timeout), - &peer_transmit_timeout, - th); + th = h->connect_ready_head; + /* add timeout again, we cancelled the transmit_ready task! */ + GNUNET_assert (th->notify_delay_task == + GNUNET_SCHEDULER_NO_TASK); + th->notify_delay_task = + GNUNET_SCHEDULER_add_delayed (h->sched, + GNUNET_TIME_absolute_get_remaining + (th->timeout), + &peer_transmit_timeout, th); } GNUNET_CLIENT_disconnect (h->client); h->client = NULL; @@ -1611,7 +1605,7 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg) case GNUNET_MESSAGE_TYPE_HELLO: if (GNUNET_OK != GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) msg, - &me)) + &me)) { GNUNET_break (0); break; @@ -1680,7 +1674,7 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg) #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receiving `%s' message, transmission %s.\n", "SEND_OK", - ntohl(okm->success) == GNUNET_OK ? "succeeded" : "failed"); + ntohl (okm->success) == GNUNET_OK ? "succeeded" : "failed"); #endif n = find_neighbour (h, &okm->peer); GNUNET_assert (n != NULL); @@ -1690,12 +1684,11 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg) #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing pending message for `%4s'\n", - GNUNET_i2s(&n->id)); + GNUNET_i2s (&n->id)); #endif GNUNET_SCHEDULER_cancel (h->sched, n->transmit_handle->notify_delay_task); - n->transmit_handle->notify_delay_task = - GNUNET_SCHEDULER_NO_TASK; + n->transmit_handle->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; GNUNET_assert (GNUNET_YES == n->received_ack); schedule_request (n->transmit_handle); } @@ -1857,7 +1850,7 @@ GNUNET_TRANSPORT_notify_transmit_ready (struct GNUNET_TRANSPORT_Handle *handle, const struct GNUNET_PeerIdentity *target, size_t size, - unsigned int priority, + unsigned int priority, struct GNUNET_TIME_Relative timeout, GNUNET_CONNECTION_TransmitReadyNotify notify, void *notify_cls) @@ -1879,9 +1872,8 @@ GNUNET_TRANSPORT_notify_transmit_ready (struct GNUNET_TRANSPORT_Handle size, GNUNET_i2s (target)); #endif n = find_neighbour (handle, target); - if ( (n != NULL) && - (n->transmit_handle != NULL) ) - return NULL; /* already have a request pending for this peer! */ + if ((n != NULL) && (n->transmit_handle != NULL)) + return NULL; /* already have a request pending for this peer! */ ctw = GNUNET_malloc (sizeof (struct ClientTransmitWrapper)); th = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_TransmitHandle)); ctw->notify = notify; @@ -1915,7 +1907,7 @@ GNUNET_TRANSPORT_notify_transmit_ready (struct GNUNET_TRANSPORT_Handle #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Transmission request queued for transmission to transport service.\n"); + "Transmission request queued for transmission to transport service.\n"); #endif GNUNET_assert (NULL == n->transmit_handle); n->transmit_handle = th; @@ -1923,23 +1915,22 @@ GNUNET_TRANSPORT_notify_transmit_ready (struct GNUNET_TRANSPORT_Handle { #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Connection to `%4s' is not yet confirmed connected, scheduling timeout (%llu ms) only.\n", - GNUNET_i2s (target), timeout.value); + "Connection to `%4s' is not yet confirmed connected, scheduling timeout (%llu ms) only.\n", + GNUNET_i2s (target), timeout.value); #endif th->notify_delay_task - = GNUNET_SCHEDULER_add_delayed (handle->sched, - timeout, &peer_transmit_timeout, th); + = GNUNET_SCHEDULER_add_delayed (handle->sched, + timeout, &peer_transmit_timeout, th); return th; } - + #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Peer `%4s' is ready to receive, scheduling message for delivery now.\n", - GNUNET_i2s (target)); + "Peer `%4s' is ready to receive, scheduling message for delivery now.\n", + GNUNET_i2s (target)); #endif th->notify_delay_task - = GNUNET_SCHEDULER_add_now (handle->sched, - &transmit_ready, th); + = GNUNET_SCHEDULER_add_now (handle->sched, &transmit_ready, th); return th; } @@ -1956,9 +1947,9 @@ GNUNET_TRANSPORT_notify_transmit_ready_cancel (struct #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Transmission request of %u bytes to `%4s' was cancelled.\n", - th->notify_size - sizeof(struct OutboundMessage), - GNUNET_i2s (&th->target)); + "Transmission request of %u bytes to `%4s' was cancelled.\n", + th->notify_size - sizeof (struct OutboundMessage), + GNUNET_i2s (&th->target)); #endif GNUNET_assert (th->notify == &client_notify_wrapper); remove_from_any_list (th); diff --git a/src/transport/transport_api_address_lookup.c b/src/transport/transport_api_address_lookup.c index 1c0cf7340..961ee0713 100644 --- a/src/transport/transport_api_address_lookup.c +++ b/src/transport/transport_api_address_lookup.c @@ -9,108 +9,114 @@ #include "transport.h" // FIXME: document -struct AddressLookUpCB { - GNUNET_TRANSPORT_AddressLookUpCallback cb; - void *cls; - struct GNUNET_TIME_Absolute timeout; - struct GNUNET_CLIENT_Connection *client; +struct AddressLookUpCB +{ + GNUNET_TRANSPORT_AddressLookUpCallback cb; + void *cls; + struct GNUNET_TIME_Absolute timeout; + struct GNUNET_CLIENT_Connection *client; }; // FIXME: document static void -address_response_processor(void *cls, const struct - GNUNET_MessageHeader * msg) +address_response_processor (void *cls, const struct GNUNET_MessageHeader *msg) { - struct AddressLookUpCB *alucb = cls; - const char *address; - uint16_t size; + struct AddressLookUpCB *alucb = cls; + const char *address; + uint16_t size; - if (msg == NULL) - { - /* timeout */ - alucb->cb (alucb->cls, NULL); - GNUNET_CLIENT_disconnect (alucb->client); - GNUNET_free (alucb); - return; - } - size = ntohs(msg->size); - if (size == sizeof(struct GNUNET_MessageHeader)) - { - /* last reply */ - address = NULL; - } - else - { - address = (const char*) &msg[1]; - if (address[size - sizeof(struct GNUNET_MessageHeader) - 1] != '\0') - { - /* invalid reply */ - GNUNET_break_op (0); - alucb->cb (alucb->cls, NULL); - GNUNET_CLIENT_disconnect (alucb->client); - GNUNET_free (alucb); - return; - } - else - { - /* expect more replies */ - GNUNET_CLIENT_receive (alucb->client, &address_response_processor, alucb, - GNUNET_TIME_absolute_get_remaining (alucb->timeout)); - } - } - alucb->cb (alucb->cls, address); - if (address == NULL) - { - /* done! */ - GNUNET_CLIENT_disconnect (alucb->client); - GNUNET_free (alucb); - } + if (msg == NULL) + { + /* timeout */ + alucb->cb (alucb->cls, NULL); + GNUNET_CLIENT_disconnect (alucb->client); + GNUNET_free (alucb); + return; + } + size = ntohs (msg->size); + if (size == sizeof (struct GNUNET_MessageHeader)) + { + /* last reply */ + address = NULL; + } + else + { + address = (const char *) &msg[1]; + if (address[size - sizeof (struct GNUNET_MessageHeader) - 1] != '\0') + { + /* invalid reply */ + GNUNET_break_op (0); + alucb->cb (alucb->cls, NULL); + GNUNET_CLIENT_disconnect (alucb->client); + GNUNET_free (alucb); + return; + } + else + { + /* expect more replies */ + GNUNET_CLIENT_receive (alucb->client, &address_response_processor, + alucb, + GNUNET_TIME_absolute_get_remaining (alucb-> + timeout)); + } + } + alucb->cb (alucb->cls, address); + if (address == NULL) + { + /* done! */ + GNUNET_CLIENT_disconnect (alucb->client); + GNUNET_free (alucb); + } } void GNUNET_TRANSPORT_address_lookup (struct GNUNET_SCHEDULER_Handle *sched, - const struct GNUNET_CONFIGURATION_Handle *cfg, - const char * address, - size_t addressLen, - const char * nameTrans, - struct GNUNET_TIME_Relative timeout, - GNUNET_TRANSPORT_AddressLookUpCallback aluc, - void *aluc_cls) + const struct GNUNET_CONFIGURATION_Handle + *cfg, const char *address, size_t addressLen, + const char *nameTrans, + struct GNUNET_TIME_Relative timeout, + GNUNET_TRANSPORT_AddressLookUpCallback aluc, + void *aluc_cls) { - size_t len = sizeof (struct AddressLookupMessage) + addressLen + strlen (nameTrans) + 1; - struct AddressLookupMessage *msg; - struct GNUNET_TIME_Absolute abs_timeout; - struct AddressLookUpCB *aluCB; - struct GNUNET_CLIENT_Connection *client; + size_t len = + sizeof (struct AddressLookupMessage) + addressLen + strlen (nameTrans) + + 1; + struct AddressLookupMessage *msg; + struct GNUNET_TIME_Absolute abs_timeout; + struct AddressLookUpCB *aluCB; + struct GNUNET_CLIENT_Connection *client; - if (len >= GNUNET_SERVER_MAX_MESSAGE_SIZE) - { - GNUNET_break (0); - aluc (aluc_cls, NULL); - return; - } - client = GNUNET_CLIENT_connect (sched, "transport", cfg); - if (client == NULL) - { - aluc (aluc_cls, NULL); - return; - } - abs_timeout = GNUNET_TIME_relative_to_absolute(timeout); - msg = GNUNET_malloc (len); - msg->header->size = htons (len); - msg->header->type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_LOOKUP); - msg->timeout = GNUNET_TIME_absolute_hton(abs_timeout); - msg->addrlen = htonl (addressLen); - char *addrbuf = (char*) &msg[1]; - memcpy (addrbuf, address, addressLen); - char *tbuf = &addrbuf[addressLen]; - memcpy (tbuf, nameTrans, strlen(nameTrans) + 1); - aluCB = GNUNET_malloc (sizeof (struct AddressLookUpCB)); - aluCB->cb = aluc; - aluCB->cb_cls = aluc_cls; - aluCB->timeout = abs_timeout; - aluCB->client = client; - GNUNET_CLIENT_transmit_and_get_response(client, msg->header, timeout, GNUNET_YES, &address_response_processor, aluCB); - GNUNET_free(msg); + if (len >= GNUNET_SERVER_MAX_MESSAGE_SIZE) + { + GNUNET_break (0); + aluc (aluc_cls, NULL); + return; + } + client = GNUNET_CLIENT_connect (sched, "transport", cfg); + if (client == NULL) + { + aluc (aluc_cls, NULL); + return; + } + abs_timeout = GNUNET_TIME_relative_to_absolute (timeout); + msg = GNUNET_malloc (len); + msg->header->size = htons (len); + msg->header->type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_LOOKUP); + msg->timeout = GNUNET_TIME_absolute_hton (abs_timeout); + msg->addrlen = htonl (addressLen); + char *addrbuf = (char *) &msg[1]; + memcpy (addrbuf, address, addressLen); + char *tbuf = &addrbuf[addressLen]; + memcpy (tbuf, nameTrans, strlen (nameTrans) + 1); + aluCB = GNUNET_malloc (sizeof (struct AddressLookUpCB)); + aluCB->cb = aluc; + aluCB->cb_cls = aluc_cls; + aluCB->timeout = abs_timeout; + aluCB->client = client; + GNUNET_CLIENT_transmit_and_get_response (client, msg->header, timeout, + GNUNET_YES, + &address_response_processor, + aluCB); + GNUNET_free (msg); }