From f40b9f4d92412da3a1461f16069c8bbb425bd136 Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Thu, 13 Oct 2011 13:06:01 +0000 Subject: [PATCH] compile --- src/transport/gnunet-service-transport.c | 43 ++++++--- .../gnunet-service-transport_neighbours.c | 90 ++----------------- .../gnunet-service-transport_validation.c | 23 ++--- src/transport/plugin_transport_http.c | 10 +-- src/transport/plugin_transport_tcp.c | 15 ++-- src/transport/plugin_transport_udp.c | 10 +-- src/transport/plugin_transport_unix.c | 10 +-- src/transport/plugin_transport_wlan.c | 10 +-- 8 files changed, 67 insertions(+), 144 deletions(-) diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index ce4c240a7..e551cbf49 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c @@ -246,7 +246,6 @@ plugin_env_receive_callback (void *cls, const struct GNUNET_PeerIdentity *peer, break; } } - GNUNET_assert ((ats_count > 0) && (ats != NULL)); /* FIXME: this gives an address that might not have been validated to ATS for 'selection', which is probably not what we want; this @@ -254,9 +253,11 @@ plugin_env_receive_callback (void *cls, const struct GNUNET_PeerIdentity *peer, validation) as 'GNUNET_ATS_address_update' currently ignores the expiration given. */ - GNUNET_ATS_address_update (GST_ats, peer, GNUNET_TIME_absolute_get (), /* valid at least until right now... */ - plugin_name, session, sender_address, - sender_address_len, ats, ats_count); + if ((ats_count > 0) && (ats != NULL)) + GNUNET_ATS_address_update (GST_ats, peer, + plugin_name, sender_address, sender_address_len, + session, + ats, ats_count); return ret; } @@ -304,7 +305,7 @@ plugin_env_session_end (void *cls, const struct GNUNET_PeerIdentity *peer, "Session %X to peer `%s' ended \n", session, GNUNET_i2s (peer)); #endif - GNUNET_ATS_session_destroyed(GST_ats, peer, session); + GNUNET_ATS_address_destroyed(GST_ats, peer, NULL, NULL, 0, session); GST_neighbours_session_terminated (peer, session); } @@ -327,15 +328,32 @@ plugin_env_session_end (void *cls, const struct GNUNET_PeerIdentity *peer, */ static void ats_request_address_change (void *cls, const struct GNUNET_PeerIdentity *peer, - const char *plugin_name, struct Session *session, + const char *plugin_name, const void *plugin_addr, size_t plugin_addr_len, + struct Session *session, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in) { GST_neighbours_switch_to_address (peer, plugin_name, plugin_addr, plugin_addr_len, session, NULL, 0); GST_neighbours_set_incoming_quota (peer, bandwidth_in); - // FIXME: use 'bandwidth_out'! + +#if DEBUG_TRANSPORT + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending outbound quota of %u Bps for peer `%s' to all clients\n", + ntohl (bandwidth_out.value__), GNUNET_i2s (target)); +#endif + struct QuotaSetMessage msg; + msg.header.size = htons (sizeof (struct QuotaSetMessage)); + msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA); + msg.quota = bandwidth_out; + msg.peer = (*peer); + GST_clients_broadcast ((struct GNUNET_MessageHeader *) &msg, GNUNET_NO); + +#if DEBUG_TRANSPORT + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Setting inbound quota of %u for peer `%s' to \n", + ntohl (bandwidth_in.value__), GNUNET_i2s (target)); +#endif + GST_neighbours_set_incoming_quota (peer, bandwidth_in); } @@ -346,7 +364,7 @@ ats_request_address_change (void *cls, const struct GNUNET_PeerIdentity *peer, * @param cls closure * @param peer the peer that connected * @param ats performance data - * @param ats_count number of entries in ats (excluding 0-termination) + * @param ats_count number of entries in ats */ static void neighbours_connect_notification (void *cls, @@ -357,16 +375,13 @@ neighbours_connect_notification (void *cls, char buf[sizeof (struct ConnectInfoMessage) + ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information)]; struct ConnectInfoMessage *connect_msg = (struct ConnectInfoMessage *) buf; - struct GNUNET_TRANSPORT_ATS_Information *atsm = &connect_msg->ats; connect_msg->header.size = htons (sizeof (buf)); connect_msg->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT); connect_msg->ats_count = htonl (ats_count); connect_msg->id = *peer; - memcpy (&connect_msg->ats, ats, + memcpy (&connect_msg->ats, &connect_msg->ats, ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information)); - atsm[ats_count].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR); - atsm[ats_count].value = htonl (0); GST_clients_broadcast (&connect_msg->header, GNUNET_NO); } @@ -405,7 +420,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GST_validation_stop (); GST_plugins_unload (); GST_neighbours_stop (); - GNUNET_ATS_shutdown (GST_ats); + GNUNET_ATS_scheduling_done (GST_ats); GST_ats = NULL; GST_clients_stop (); GST_blacklist_stop (); @@ -484,7 +499,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, GST_plugins_load (&plugin_env_receive_callback, &plugin_env_address_change_notification, &plugin_env_session_end); - GST_ats = GNUNET_ATS_init (GST_cfg, &ats_request_address_change, NULL); + GST_ats = GNUNET_ATS_scheduling_init (GST_cfg, &ats_request_address_change, NULL); GST_neighbours_start (NULL, &neighbours_connect_notification, &neighbours_disconnect_notification); GST_clients_start (server); diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index cbcc50b42..5c17648a8 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c @@ -190,12 +190,6 @@ struct NeighbourMapEntry */ struct MessageQueue *messages_tail; - /** - * Context for address suggestion. - * NULL after we are connected. - */ - struct GNUNET_ATS_SuggestionContext *asc; - /** * Performance data for the peer. */ @@ -505,11 +499,6 @@ disconnect_neighbour (struct NeighbourMapEntry *n) GNUNET_SCHEDULER_cancel (n->transmission_task); n->transmission_task = GNUNET_SCHEDULER_NO_TASK; } - if (NULL != n->asc) - { - GNUNET_ATS_suggest_address_cancel (n->asc); - n->asc = NULL; - } GNUNET_array_grow (n->ats, n->ats_count, 0); if (NULL != n->plugin_name) { @@ -649,6 +638,7 @@ GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer, { struct NeighbourMapEntry *n; struct SessionConnectMessage connect_msg; + int was_connected; GNUNET_assert (neighbours != NULL); @@ -660,6 +650,8 @@ GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer, // GNUNET_break (0); return; } + was_connected = n->is_connected; + n->is_connected = GNUNET_YES; #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -693,76 +685,18 @@ GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer, GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ()); GST_neighbours_send (peer, &connect_msg, sizeof (connect_msg), GNUNET_TIME_UNIT_FOREVER_REL, NULL, NULL); -} - -/** - * Try to connect to the target peer using the given address - * - * @param cls the 'struct NeighbourMapEntry' of the target - * @param target identity of the target peer - * @param plugin_name name of the plugin - * @param plugin_address binary address - * @param plugin_address_len length of address - * @param session session to use - * @param bandwidth_out available outbound bandwidth - * @param bandwidth_in available inbound bandwidth - * @param ats performance data for the address (as far as known) - * @param ats_count number of performance records in 'ats' - */ -static void -try_connect_using_address (void *cls, const struct GNUNET_PeerIdentity *target, - const char *plugin_name, const void *plugin_address, - size_t plugin_address_len, struct Session *session, - struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, - struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, - const struct GNUNET_TRANSPORT_ATS_Information *ats, - uint32_t ats_count) -{ - struct NeighbourMapEntry *n = cls; - int was_connected; - - n->asc = NULL; - was_connected = n->is_connected; - n->is_connected = GNUNET_YES; - - GST_neighbours_switch_to_address (target, plugin_name, plugin_address, - plugin_address_len, session, ats, - ats_count); + n->keepalive_task = GNUNET_SCHEDULER_add_now (&neighbour_keepalive_task, + n); if (GNUNET_YES == was_connected) return; - n->keepalive_task = GNUNET_SCHEDULER_add_now (&neighbour_keepalive_task, - n); - - /* ATS told us inbound quota for this peer */ -#if DEBUG_TRANSPORT - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Setting inbound quota of %u for peer `%s' to \n", - ntohl (bandwidth_in.value__), GNUNET_i2s (target)); -#endif - GST_neighbours_set_incoming_quota (&n->id, bandwidth_in); - /* First tell clients about connected neighbours...*/ neighbours_connected++; GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# peers connected"), 1, GNUNET_NO); - connect_notify_cb (callback_cls, target, n->ats, n->ats_count); - - /* ... then send outbound quota for this peer to all clients */ -#if DEBUG_TRANSPORT - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending outbound quota of %u Bps for peer `%s' to all clients\n", - ntohl (bandwidth_out.value__), GNUNET_i2s (target)); -#endif - - struct QuotaSetMessage msg; - msg.header.size = htons (sizeof (struct QuotaSetMessage)); - msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA); - msg.quota = bandwidth_out; - msg.peer = (*target); - GST_clients_broadcast ((struct GNUNET_MessageHeader *) &msg, GNUNET_NO); - + connect_notify_cb (callback_cls, peer, n->ats, n->ats_count); } - /** * Try to create a connection to the given target (eventually). * @@ -795,9 +729,6 @@ GST_neighbours_try_connect (const struct GNUNET_PeerIdentity *target) #endif n = GNUNET_malloc (sizeof (struct NeighbourMapEntry)); n->id = *target; - GNUNET_array_grow (n->ats, n->ats_count, 1); - n->ats[0].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR);; - n->ats[0].value = htonl (0); GNUNET_BANDWIDTH_tracker_init (&n->in_tracker, GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT, MAX_BANDWIDTH_CARRY_S); @@ -809,16 +740,12 @@ GST_neighbours_try_connect (const struct GNUNET_PeerIdentity *target) &n->id.hashPubKey, n, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); } - if (n->asc != NULL) - return; /* already trying */ #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asking ATS for suggested address to connect to peer `%s'\n", GNUNET_i2s (target)); #endif - n->asc = - GNUNET_ATS_suggest_address (GST_ats, target, &try_connect_using_address, - n); + GNUNET_ATS_suggest_address (GST_ats, target); } @@ -891,8 +818,7 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer, //GNUNET_break (0); return; } - n->asc = - GNUNET_ATS_suggest_address (GST_ats, peer, &try_connect_using_address, n); + GNUNET_ATS_suggest_address (GST_ats, peer); } diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c index e16ccb56b..f0cc12e41 100644 --- a/src/transport/gnunet-service-transport_validation.c +++ b/src/transport/gnunet-service-transport_validation.c @@ -394,7 +394,6 @@ add_valid_address (void *cls, const char *tname, struct ValidationEntry *ve; struct GNUNET_PeerIdentity pid; struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key; - struct GNUNET_TRANSPORT_ATS_Information ats; if (GNUNET_TIME_absolute_get_remaining (expiration).rel_value == 0) return GNUNET_OK; /* expired */ @@ -406,10 +405,8 @@ add_valid_address (void *cls, const char *tname, } ve = find_validation_entry (&public_key, &pid, tname, addr, addrlen); ve->valid_until = GNUNET_TIME_absolute_max (ve->valid_until, expiration); - ats.type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR); - ats.value = htonl (0); - GNUNET_ATS_address_update (GST_ats, &pid, ve->valid_until, tname, NULL, addr, - addrlen, &ats, 1); + GNUNET_ATS_address_update (GST_ats, &pid, tname, addr, + addrlen, NULL, NULL, 0); return GNUNET_OK; } @@ -978,15 +975,13 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender, /* validity achieved, remember it! */ ve->valid_until = GNUNET_TIME_relative_to_absolute (HELLO_ADDRESS_EXPIRATION); { - struct GNUNET_TRANSPORT_ATS_Information ats[2]; - - ats[0].type = htonl (GNUNET_TRANSPORT_ATS_QUALITY_NET_DELAY); - ats[0].value = htonl ((uint32_t) GNUNET_TIME_absolute_get_duration (ve->send_time).rel_value); - ats[1].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR); - ats[1].value = htonl (0); - GNUNET_ATS_address_update (GST_ats, &ve->pid, ve->valid_until, - ve->transport_name, NULL, ve->addr, ve->addrlen, - ats, 2); + struct GNUNET_TRANSPORT_ATS_Information ats; + + ats.type = htonl (GNUNET_TRANSPORT_ATS_QUALITY_NET_DELAY); + ats.value = htonl ((uint32_t) GNUNET_TIME_absolute_get_duration (ve->send_time).rel_value); + GNUNET_ATS_address_update (GST_ats, &ve->pid, + ve->transport_name,ve->addr, ve->addrlen, NULL, + &ats, 1); } /* build HELLO to store in PEERINFO */ diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c index 3f7ff2a40..7e740293b 100644 --- a/src/transport/plugin_transport_http.c +++ b/src/transport/plugin_transport_http.c @@ -257,15 +257,13 @@ http_plugin_receive (void *cls, const struct GNUNET_PeerIdentity * peer, { struct Session *s = cls; struct Plugin *plugin = s->plugin; - struct GNUNET_TRANSPORT_ATS_Information distance[2]; + struct GNUNET_TRANSPORT_ATS_Information distance; struct GNUNET_TIME_Relative delay; - distance[0].type = htonl (GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE); - distance[0].value = htonl (1); - distance[1].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR); - distance[1].value = htonl (0); + distance.type = htonl (GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE); + distance.value = htonl (1); - delay = plugin->env->receive (plugin->env->cls, &s->target, message, (const struct GNUNET_TRANSPORT_ATS_Information*) &distance, 2, s, s->addr, s->addrlen); + delay = plugin->env->receive (plugin->env->cls, &s->target, message, (const struct GNUNET_TRANSPORT_ATS_Information*) &distance, 1, s, s->addr, s->addrlen); return delay; } diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c index 20e4bda50..d85d5fc82 100644 --- a/src/transport/plugin_transport_tcp.c +++ b/src/transport/plugin_transport_tcp.c @@ -1663,13 +1663,10 @@ delayed_done (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) struct GNUNET_TIME_Relative delay; struct GNUNET_TRANSPORT_ATS_Information ats; - ats.type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR); - ats.value = htonl (0); - session->receive_delay_task = GNUNET_SCHEDULER_NO_TASK; delay = session->plugin->env->receive (session->plugin->env->cls, - &session->target, NULL, &ats, 1, session, + &session->target, NULL, &ats, 0, session, NULL, 0); if (delay.rel_value == 0) GNUNET_SERVER_receive_done (session->client, GNUNET_OK); @@ -1721,16 +1718,14 @@ handle_tcp_data (void *cls, struct GNUNET_SERVER_Client *client, GNUNET_STATISTICS_update (plugin->env->stats, gettext_noop ("# bytes received via TCP"), ntohs (message->size), GNUNET_NO); - struct GNUNET_TRANSPORT_ATS_Information distance[2]; + struct GNUNET_TRANSPORT_ATS_Information distance; - distance[0].type = htonl (GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE); - distance[0].value = htonl (1); - distance[1].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR); - distance[1].value = htonl (0); + distance.type = htonl (GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE); + distance.value = htonl (1); delay = plugin->env->receive (plugin->env->cls, &session->target, message, (const struct GNUNET_TRANSPORT_ATS_Information *) - &distance, 2, session, + &distance, 1, session, (GNUNET_YES == session->inbound) ? NULL : session->connect_addr, (GNUNET_YES == diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index adb9277c4..0b37b9be4 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c @@ -759,17 +759,15 @@ process_inbound_tokenized_messages (void *cls, void *client, { struct Plugin *plugin = cls; struct SourceInformation *si = client; - struct GNUNET_TRANSPORT_ATS_Information distance[2]; + struct GNUNET_TRANSPORT_ATS_Information distance; /* setup ATS */ - distance[0].type = htonl (GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE); - distance[0].value = htonl (1); - distance[1].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR); - distance[1].value = htonl (0); + distance.type = htonl (GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE); + distance.value = htonl (1); LOG (GNUNET_ERROR_TYPE_DEBUG, "Giving Session %X %s to transport\n", si->session, GNUNET_i2s(&si->session->target)); - plugin->env->receive (plugin->env->cls, &si->sender, hdr, distance, 2, si->session, + plugin->env->receive (plugin->env->cls, &si->sender, hdr, &distance, 1, si->session, si->arg, si->args); } diff --git a/src/transport/plugin_transport_unix.c b/src/transport/plugin_transport_unix.c index da08c5a24..14034e683 100644 --- a/src/transport/plugin_transport_unix.c +++ b/src/transport/plugin_transport_unix.c @@ -719,12 +719,10 @@ unix_demultiplexer (struct Plugin *plugin, struct GNUNET_PeerIdentity *sender, const struct GNUNET_MessageHeader *currhdr, const struct sockaddr_un *un, size_t fromlen) { - struct GNUNET_TRANSPORT_ATS_Information distance[2]; + struct GNUNET_TRANSPORT_ATS_Information distance; - distance[0].type = htonl (GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE); - distance[0].value = htonl (UNIX_DIRECT_DISTANCE); - distance[1].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR); - distance[1].value = htonl (0); + distance.type = htonl (GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE); + distance.value = htonl (UNIX_DIRECT_DISTANCE); GNUNET_assert (fromlen >= sizeof (struct sockaddr_un)); @@ -734,7 +732,7 @@ unix_demultiplexer (struct Plugin *plugin, struct GNUNET_PeerIdentity *sender, #endif plugin->env->receive (plugin->env->cls, sender, currhdr, (const struct GNUNET_TRANSPORT_ATS_Information *) - &distance, 2, NULL, un->sun_path, + &distance, 1, NULL, un->sun_path, strlen (un->sun_path) + 1); } diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c index dbc3e5493..51da7ec32 100644 --- a/src/transport/plugin_transport_wlan.c +++ b/src/transport/plugin_transport_wlan.c @@ -2334,12 +2334,10 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr) struct Session *session = (struct Session *) client; struct Plugin *plugin = (struct Plugin *) cls; - struct GNUNET_TRANSPORT_ATS_Information distance[2]; + struct GNUNET_TRANSPORT_ATS_Information distance; - distance[0].type = htonl (GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE); - distance[0].value = htonl (1); - distance[1].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR); - distance[1].value = htonl (0); + distance.type = htonl (GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE); + distance.value = htonl (1); #if DEBUG_wlan GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, @@ -2352,7 +2350,7 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr) plugin->env->receive (plugin->env->cls, &(session->target), hdr, (const struct GNUNET_TRANSPORT_ATS_Information *) - &distance, 2, session, + &distance, 1, session, (const char *) &session->mac->addr, sizeof (session->mac->addr)); } -- 2.25.1