[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r27864 - gnunet/src/transport
From: |
gnunet |
Subject: |
[GNUnet-SVN] r27864 - gnunet/src/transport |
Date: |
Wed, 10 Jul 2013 10:53:22 +0200 |
Author: wachs
Date: 2013-07-10 10:53:22 +0200 (Wed, 10 Jul 2013)
New Revision: 27864
Modified:
gnunet/src/transport/gnunet-service-transport.c
gnunet/src/transport/gnunet-service-transport.h
gnunet/src/transport/gnunet-service-transport_neighbours.c
Log:
move add function directly to transport
Modified: gnunet/src/transport/gnunet-service-transport.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport.c 2013-07-10 08:24:33 UTC
(rev 27863)
+++ gnunet/src/transport/gnunet-service-transport.c 2013-07-10 08:53:22 UTC
(rev 27864)
@@ -393,8 +393,56 @@
}
+/**
+ * Notify ATS about the new address including the network this address is
+ * located in.
+ *
+ * @param address the address
+ * @param session the session
+ */
void
-GST_update_ats_metrics (const struct GNUNET_PeerIdentity *peer,
+GST_ats_add_address (struct GNUNET_HELLO_Address *address,
+ void *session)
+{
+ struct GNUNET_TRANSPORT_PluginFunctions *papi;
+ struct GNUNET_ATS_Information ats;
+ uint32_t net;
+
+ /* valid new address, let ATS know! */
+ if (NULL == address->transport_name)
+ {
+ GNUNET_break (0);
+ return;
+ }
+ if (NULL == (papi = GST_plugins_find (address->transport_name)))
+ {
+ /* we don't have the plugin for this address */
+ GNUNET_break (0);
+ return;
+ }
+
+ net = papi->get_network (NULL, session);
+ ats.type = htonl (GNUNET_ATS_NETWORK_TYPE);
+ ats.value = htonl(net);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Notifying ATS about new address
`%s' in network %s\n",
+ (0 == address->address_length) ? "<inbound>" :
GST_plugins_a2s (address),
+ GNUNET_ATS_print_network_type(net));
+ GNUNET_ATS_address_add (GST_ats,
+ address, session, &ats, 1);
+}
+
+
+/**
+ * Notify ATS about property changes to an address
+ *
+ * @param peer the peer
+ * @param address the address
+ * @param session the session
+ * @param ats performance information
+ * @param ats_count number of elements in ats
+ */
+void
+GST_ats_update_metrics (const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_HELLO_Address *address,
struct Session *session,
const struct GNUNET_ATS_Information *ats,
@@ -446,7 +494,7 @@
haddress.address_length = address_len;
haddress.transport_name = plugin_name;
- GST_update_ats_metrics (peer, &haddress, session, ats, ats_count);
+ GST_ats_update_metrics (peer, &haddress, session, ats, ats_count);
}
static void
@@ -484,7 +532,9 @@
addr = GNUNET_HELLO_address_allocate (peer, plugin, address,
address_len);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding peer `%s' address %s
session %p\n",
GNUNET_i2s (peer), GST_plugins_a2s(addr), session);
- GNUNET_ATS_address_add (GST_ats, addr, session, ats, ats_count);
+ GST_ats_add_address (addr, session);
+ if (0 < ats_count)
+ GST_ats_update_metrics (peer, addr, session, ats, ats_count);
GNUNET_free (addr);
}
Modified: gnunet/src/transport/gnunet-service-transport.h
===================================================================
--- gnunet/src/transport/gnunet-service-transport.h 2013-07-10 08:24:33 UTC
(rev 27863)
+++ gnunet/src/transport/gnunet-service-transport.h 2013-07-10 08:53:22 UTC
(rev 27864)
@@ -97,7 +97,27 @@
uint16_t sender_address_len);
+/**
+ * Notify ATS about the new address including the network this address is
+ * located in.
+ *
+ * @param address the address
+ * @param session the session
+ */
void
+GST_ats_add_address (struct GNUNET_HELLO_Address *address, void *session);
+
+/**
+ * Notify ATS about property changes to an address
+ *
+ * @param peer the peer
+ * @param address the address
+ * @param session the session
+ * @param ats performance information
+ * @param ats_count number of elements in ats
+ */
+
+void
GST_update_ats_metrics (const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_HELLO_Address *address,
struct Session *session,
Modified: gnunet/src/transport/gnunet-service-transport_neighbours.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_neighbours.c 2013-07-10
08:24:33 UTC (rev 27863)
+++ gnunet/src/transport/gnunet-service-transport_neighbours.c 2013-07-10
08:53:22 UTC (rev 27864)
@@ -934,44 +934,6 @@
/**
- * Notify ATS about the new address including the network this address is
- * located in.
- *
- * @param address the address
- * @param session the session*
- */
-static void
-add_address (struct GNUNET_HELLO_Address *address,
- void *session)
-{
- struct GNUNET_TRANSPORT_PluginFunctions *papi;
- struct GNUNET_ATS_Information ats;
- uint32_t net;
-
- /* valid new address, let ATS know! */
- if (NULL == address->transport_name)
- {
- GNUNET_break (0);
- return;
- }
- if (NULL == (papi = GST_plugins_find (address->transport_name)))
- {
- /* we don't have the plugin for this address */
- GNUNET_break (0);
- return;
- }
-
- net = papi->get_network (NULL, session);
- ats.type = htonl (GNUNET_ATS_NETWORK_TYPE);
- ats.value = htonl(net);
-// GNUNET_break (0);
-// fprintf (stderr, "NET: %u\n", ntohl(net));
- GNUNET_ATS_address_add (GST_ats,
- address, session, &ats, 1);
-}
-
-
-/**
* Initialize the 'struct NeighbourAddress'.
*
* @param na neighbour address to initialize
@@ -1581,7 +1543,7 @@
else
latency = n->latency.rel_value;
ats.value = htonl (latency);
- GST_update_ats_metrics (&n->id,
+ GST_ats_update_metrics (&n->id,
n->primary_address.address,
n->primary_address.session,
&ats, 1);
@@ -2026,7 +1988,7 @@
break;
case S_CONNECT_RECV_BLACKLIST_INBOUND:
if (GNUNET_OK == result)
- add_address (bcc->na.address, bcc->na.session);
+ GST_ats_add_address (bcc->na.address, bcc->na.session);
n->state = S_CONNECT_RECV_ATS;
n->timeout = GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT);
@@ -2835,7 +2797,7 @@
n->primary_address.bandwidth_in,
n->primary_address.bandwidth_out);
/* Tell ATS that the outbound session we created to send CONNECT was
successfull */
- add_address (n->primary_address.address, n->primary_address.session);
+ GST_ats_add_address (n->primary_address.address,
n->primary_address.session);
set_address (&n->primary_address,
n->primary_address.address,
n->primary_address.session,
@@ -2881,7 +2843,7 @@
n->timeout = GNUNET_TIME_relative_to_absolute
(GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
GNUNET_break (GNUNET_NO == n->alternative_address.ats_active);
- add_address (n->alternative_address.address,
n->alternative_address.session);
+ GST_ats_add_address (n->alternative_address.address,
n->alternative_address.session);
set_address (&n->primary_address,
n->alternative_address.address,
n->alternative_address.session,
@@ -3089,7 +3051,7 @@
n->primary_address.bandwidth_in,
n->primary_address.bandwidth_out);
- add_address (n->primary_address.address, n->primary_address.session);
+ GST_ats_add_address (n->primary_address.address, n->primary_address.session);
set_address (&n->primary_address,
n->primary_address.address,
n->primary_address.session,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r27864 - gnunet/src/transport,
gnunet <=