From ca2c35b387a67eed4d5242a0da9533be26ed0bb2 Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Thu, 21 Mar 2013 13:30:51 +0000 Subject: ats related changes in transport --- src/transport/gnunet-service-transport.c | 29 ++++++++--------- .../gnunet-service-transport_manipulation.c | 1 + .../gnunet-service-transport_neighbours.c | 37 ++++++++-------------- .../gnunet-service-transport_neighbours.h | 22 +++---------- src/transport/gnunet-transport.c | 5 +-- src/transport/transport-testing.c | 5 ++- src/transport/transport.h | 6 ---- src/transport/transport_api.c | 9 ++---- 8 files changed, 37 insertions(+), 77 deletions(-) (limited to 'src/transport') diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index cbe1f7b19..a0568c855 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c @@ -154,18 +154,15 @@ static struct GNUNET_TIME_Relative process_payload (const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Address *address, struct Session *session, - const struct GNUNET_MessageHeader *message, - const struct GNUNET_ATS_Information *ats, uint32_t ats_count) + const struct GNUNET_MessageHeader *message) { struct GNUNET_TIME_Relative ret; int do_forward; struct InboundMessage *im; size_t msg_size = ntohs (message->size); size_t size = - sizeof (struct InboundMessage) + msg_size + - sizeof (struct GNUNET_ATS_Information) * (ats_count + 1); + sizeof (struct InboundMessage) + msg_size; char buf[size] GNUNET_ALIGN; - struct GNUNET_ATS_Information *ap; ret = GNUNET_TIME_UNIT_ZERO; do_forward = GNUNET_SYSERR; @@ -190,17 +187,17 @@ process_payload (const struct GNUNET_PeerIdentity *peer, im = (struct InboundMessage *) buf; im->header.size = htons (size); im->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_RECV); - im->ats_count = htonl (ats_count + 1); im->peer = *peer; - ap = (struct GNUNET_ATS_Information *) &im[1]; - memcpy (ap, ats, ats_count * sizeof (struct GNUNET_ATS_Information)); + + fprintf (stderr, "FIX THIS: %s:%u \n", __FILE__, __LINE__); + /* ap[ats_count].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY); ap[ats_count].value = - htonl ((uint32_t) GST_neighbour_get_latency (peer).rel_value); - memcpy (&ap[ats_count + 1], message, ntohs (message->size)); + htonl ((uint32_t) GST_neighbour_get_latency (peer).rel_value);*/ + memcpy (&im[1], message, ntohs (message->size)); - GNUNET_ATS_address_add (GST_ats, address, session, ap, ats_count + 1); - GNUNET_ATS_address_update (GST_ats, address, session, ap, ats_count + 1); + GNUNET_ATS_address_add (GST_ats, address, session, NULL, 0); + GNUNET_ATS_address_update (GST_ats, address, session, NULL, 0); GST_clients_broadcast (&im->header, GNUNET_YES); return ret; @@ -280,10 +277,10 @@ GST_receive_callback (void *cls, const struct GNUNET_PeerIdentity *peer, GST_neighbours_handle_connect (message, peer, &address, session); break; case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT_ACK: - GST_neighbours_handle_connect_ack (message, peer, &address, session, NULL, 0); + GST_neighbours_handle_connect_ack (message, peer, &address, session); break; case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_ACK: - GST_neighbours_handle_session_ack (message, peer, &address, session, NULL, 0); + GST_neighbours_handle_session_ack (message, peer, &address, session); break; case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT: GST_neighbours_handle_disconnect_message (peer, message); @@ -292,7 +289,7 @@ GST_receive_callback (void *cls, const struct GNUNET_PeerIdentity *peer, GST_neighbours_keepalive (peer); break; case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE_RESPONSE: - GST_neighbours_keepalive_response (peer, NULL, 0); + GST_neighbours_keepalive_response (peer); break; default: /* should be payload */ @@ -300,7 +297,7 @@ GST_receive_callback (void *cls, const struct GNUNET_PeerIdentity *peer, gettext_noop ("# bytes payload received"), ntohs (message->size), GNUNET_NO); - ret = process_payload (peer, &address, session, message, NULL, 0); + ret = process_payload (peer, &address, session, message); break; } end: diff --git a/src/transport/gnunet-service-transport_manipulation.c b/src/transport/gnunet-service-transport_manipulation.c index 203a67771..c01c9d4dc 100644 --- a/src/transport/gnunet-service-transport_manipulation.c +++ b/src/transport/gnunet-service-transport_manipulation.c @@ -370,6 +370,7 @@ GST_manipulation_metrics_recv (void *cls, uint32_t m_distance; int d; + m_distance = 0; if (NULL != (tmp = GNUNET_CONTAINER_multihashmap_get (man_handle.peers, &peer->hashPubKey))) { diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index 21b5d06d6..2b010732d 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c @@ -1505,17 +1505,13 @@ GST_neighbours_keepalive (const struct GNUNET_PeerIdentity *neighbour) * plus calculated latency) to ATS. * * @param neighbour neighbour to keep alive - * @param ats performance data - * @param ats_count number of entries in ats */ void -GST_neighbours_keepalive_response (const struct GNUNET_PeerIdentity *neighbour, - const struct GNUNET_ATS_Information *ats, - uint32_t ats_count) +GST_neighbours_keepalive_response (const struct GNUNET_PeerIdentity *neighbour) { struct NeighbourMapEntry *n; uint32_t latency; - struct GNUNET_ATS_Information ats_new[ats_count + 1]; + struct GNUNET_ATS_Information ats; if (NULL == (n = lookup_neighbour (neighbour))) { @@ -1540,18 +1536,17 @@ GST_neighbours_keepalive_response (const struct GNUNET_PeerIdentity *neighbour, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Latency for peer `%s' is %llu ms\n", GNUNET_i2s (&n->id), n->latency.rel_value); - memcpy (ats_new, ats, sizeof (struct GNUNET_ATS_Information) * ats_count); /* append latency */ - ats_new[ats_count].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY); + ats.type = htonl (GNUNET_ATS_QUALITY_NET_DELAY); if (n->latency.rel_value > UINT32_MAX) latency = UINT32_MAX; else latency = n->latency.rel_value; - ats_new[ats_count].value = htonl (latency); + ats.value = htonl (latency); + fprintf (stderr, "FIX THIS: %s %u \n", __FILE__, __LINE__); GNUNET_ATS_address_update (GST_ats, n->primary_address.address, - n->primary_address.session, ats_new, - ats_count + 1); + n->primary_address.session, &ats, 1); } @@ -2757,9 +2752,7 @@ void GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Address *address, - struct Session *session, - const struct GNUNET_ATS_Information *ats, - uint32_t ats_count) + struct Session *session) { const struct SessionConnectMessage *scm; struct GNUNET_TIME_Absolute ts; @@ -2807,14 +2800,14 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message, gettext_noop ("# peers connected"), ++neighbours_connected, GNUNET_NO); - connect_notify_cb (callback_cls, &n->id, ats, ats_count, + connect_notify_cb (callback_cls, &n->id, NULL, 0, n->primary_address.bandwidth_in, n->primary_address.bandwidth_out); /* Tell ATS that the outbound session we created to send CONNECT was successfull */ GNUNET_ATS_address_add (GST_ats, n->primary_address.address, n->primary_address.session, - ats, ats_count); + NULL, 0); set_address (&n->primary_address, n->primary_address.address, n->primary_address.session, @@ -2862,7 +2855,7 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message, GNUNET_ATS_address_add(GST_ats, n->alternative_address.address, n->alternative_address.session, - ats, ats_count); + NULL, 0); set_address (&n->primary_address, n->alternative_address.address, n->alternative_address.session, @@ -3030,16 +3023,12 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer, * @param address address of the other peer, NULL if other peer * connected to us * @param session session to use (or NULL) - * @param ats performance data - * @param ats_count number of entries in ats */ void GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Address *address, - struct Session *session, - const struct GNUNET_ATS_Information *ats, - uint32_t ats_count) + struct Session *session) { struct NeighbourMapEntry *n; @@ -3070,13 +3059,13 @@ GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message, gettext_noop ("# peers connected"), ++neighbours_connected, GNUNET_NO); - connect_notify_cb (callback_cls, &n->id, ats, ats_count, + connect_notify_cb (callback_cls, &n->id, NULL, 0, n->primary_address.bandwidth_in, n->primary_address.bandwidth_out); GNUNET_ATS_address_add(GST_ats, n->primary_address.address, n->primary_address.session, - ats, ats_count); + NULL, 0); set_address (&n->primary_address, n->primary_address.address, n->primary_address.session, diff --git a/src/transport/gnunet-service-transport_neighbours.h b/src/transport/gnunet-service-transport_neighbours.h index bb3d4d2d3..70b6d1096 100644 --- a/src/transport/gnunet-service-transport_neighbours.h +++ b/src/transport/gnunet-service-transport_neighbours.h @@ -138,13 +138,9 @@ GST_neighbours_keepalive (const struct GNUNET_PeerIdentity *neighbour); * to this peer * * @param neighbour neighbour to keep alive - * @param ats performance data - * @param ats_count number of entries in ats */ void -GST_neighbours_keepalive_response (const struct GNUNET_PeerIdentity *neighbour, - const struct GNUNET_ATS_Information *ats, - uint32_t ats_count); +GST_neighbours_keepalive_response (const struct GNUNET_PeerIdentity *neighbour); /** @@ -244,9 +240,7 @@ GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer, * @param address address of the other peer, NULL if other peer * connected to us * @param session session to use (or NULL) - * @param ats performance data - * @param ats_count number of entries in ats (excluding 0-termination) - */ + */ void GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message, const struct GNUNET_PeerIdentity *peer, @@ -263,16 +257,12 @@ GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message, * @param address address of the other peer, NULL if other peer * connected to us * @param session session to use (or NULL) - * @param ats performance data - * @param ats_count number of entries in ats */ void GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Address *address, - struct Session *session, - const struct GNUNET_ATS_Information *ats, - uint32_t ats_count); + struct Session *session); /** @@ -284,16 +274,12 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message, * @param address address of the other peer, NULL if other peer * connected to us * @param session session to use (or NULL) - * @param ats performance data - * @param ats_count number of entries in ats */ void GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Address *address, - struct Session *session, - const struct GNUNET_ATS_Information *ats, - uint32_t ats_count); + struct Session *session); /** diff --git a/src/transport/gnunet-transport.c b/src/transport/gnunet-transport.c index 5dea54887..d606f05b9 100644 --- a/src/transport/gnunet-transport.c +++ b/src/transport/gnunet-transport.c @@ -648,13 +648,10 @@ monitor_notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) * @param cls closure * @param peer (claimed) identity of the other peer * @param message the message - * @param ats performance data - * @param ats_count number of entries in ats */ static void notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, - const struct GNUNET_MessageHeader *message, - const struct GNUNET_ATS_Information *ats, uint32_t ats_count) + const struct GNUNET_MessageHeader *message) { if (benchmark_receive) { diff --git a/src/transport/transport-testing.c b/src/transport/transport-testing.c index 32331d9d9..bb0b86077 100644 --- a/src/transport/transport-testing.c +++ b/src/transport/transport-testing.c @@ -145,15 +145,14 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) static void notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, - const struct GNUNET_MessageHeader *message, - const struct GNUNET_ATS_Information *ats, uint32_t ats_count) + const struct GNUNET_MessageHeader *message) { struct PeerContext *p = cls; if (p == NULL) return; if (p->rec != NULL) - p->rec (p->cb_cls, peer, message, ats, ats_count); + p->rec (p->cb_cls, peer, message); } diff --git a/src/transport/transport.h b/src/transport/transport.h index be31f0ad6..d5413f779 100644 --- a/src/transport/transport.h +++ b/src/transport/transport.h @@ -234,12 +234,6 @@ struct InboundMessage */ struct GNUNET_MessageHeader header; - /** - * Number of ATS key-value pairs that follow this struct - * (excluding the 0-terminator). - */ - uint32_t ats_count GNUNET_PACKED; - /** * Which peer sent the message? */ diff --git a/src/transport/transport_api.c b/src/transport/transport_api.c index 3b72ead5f..8b66fb986 100644 --- a/src/transport/transport_api.c +++ b/src/transport/transport_api.c @@ -619,11 +619,8 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg) break; } im = (const struct InboundMessage *) msg; - ats_count = ntohl (im->ats_count); - ats = (const struct GNUNET_ATS_Information *) &im[1]; - imm = (const struct GNUNET_MessageHeader *) &ats[ats_count]; - if (ntohs (imm->size) + sizeof (struct InboundMessage) + - ats_count * sizeof (struct GNUNET_ATS_Information) != size) + imm = (const struct GNUNET_MessageHeader *) &im[1]; + if (ntohs (imm->size) + sizeof (struct InboundMessage) != size) { GNUNET_break (0); break; @@ -637,7 +634,7 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg) break; } if (h->rec != NULL) - h->rec (h->cls, &im->peer, imm, ats, ats_count); + h->rec (h->cls, &im->peer, imm); break; case GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA: LOG (GNUNET_ERROR_TYPE_DEBUG, "Receiving `%s' message.\n", "SET_QUOTA"); -- cgit v1.2.3