[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r25297 - gnunet/src/ats
From: |
gnunet |
Subject: |
[GNUnet-SVN] r25297 - gnunet/src/ats |
Date: |
Thu, 6 Dec 2012 15:00:56 +0100 |
Author: wachs
Date: 2012-12-06 15:00:56 +0100 (Thu, 06 Dec 2012)
New Revision: 25297
Modified:
gnunet/src/ats/gnunet-service-ats_addresses.c
gnunet/src/ats/gnunet-service-ats_addresses.h
gnunet/src/ats/gnunet-service-ats_addresses_mlp.c
gnunet/src/ats/test_ats_api_scheduling_update_address.c
Log:
changes
Modified: gnunet/src/ats/gnunet-service-ats_addresses.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses.c 2012-12-06 13:53:33 UTC
(rev 25296)
+++ gnunet/src/ats/gnunet-service-ats_addresses.c 2012-12-06 14:00:56 UTC
(rev 25297)
@@ -182,6 +182,59 @@
return ats_count;
}
+static unsigned int
+disassemble_ats_information (const struct GNUNET_ATS_Information *src,
+ uint32_t ats_count,
+ struct ATS_Address *dest)
+{
+ int i;
+ int res = 0;
+ for (i = 0; i < ats_count; i++)
+ switch (ntohl (src[i].type))
+ {
+ case GNUNET_ATS_UTILIZATION_UP:
+ dest->atsp_utilization_out.value__ = src[i].value;
+ res ++;
+ break;
+ case GNUNET_ATS_UTILIZATION_DOWN:
+ dest->atsp_utilization_in.value__ = src[i].value;
+ res ++;
+ break;
+ case GNUNET_ATS_QUALITY_NET_DELAY:
+ dest->atsp_latency.rel_value = ntohl (src[i].value);
+ res ++;
+ break;
+ case GNUNET_ATS_QUALITY_NET_DISTANCE:
+ dest->atsp_distance = ntohl (src[i].value);
+ res ++;
+ break;
+ case GNUNET_ATS_COST_WAN:
+ dest->atsp_cost_wan = ntohl (src[i].value);
+ res ++;
+ break;
+ case GNUNET_ATS_COST_LAN:
+ dest->atsp_cost_lan = ntohl (src[i].value);
+ res ++;
+ break;
+ case GNUNET_ATS_COST_WLAN:
+ dest->atsp_cost_wlan = ntohl (src[i].value);
+ res ++;
+ break;
+ case GNUNET_ATS_NETWORK_TYPE:
+ dest->atsp_network_type = ntohl (src[i].value);
+ res ++;
+ break;
+ case GNUNET_ATS_ARRAY_TERMINATOR:
+ break;
+ default:
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Received unsupported ATS type %u\n", ntohl (src[i].type));
+ GNUNET_break (0);
+ break;
+ }
+ return res;
+}
+
/**
* Free the given address
* @param addr address to destroy
@@ -189,7 +242,6 @@
static void
free_address (struct ATS_Address *addr)
{
- GNUNET_free_non_null (addr->ats);
GNUNET_free (addr->plugin);
GNUNET_free (addr);
}
@@ -376,9 +428,6 @@
session_id);
aa->mlp_information = NULL;
- aa->ats = GNUNET_malloc (atsi_count * sizeof (struct
GNUNET_ATS_Information));
- aa->ats_count = atsi_count;
- memcpy (aa->ats, atsi, atsi_count * sizeof (struct GNUNET_ATS_Information));
/* Get existing address or address with session == 0 */
old = find_address (peer, aa);
@@ -446,6 +495,7 @@
{
struct ATS_Address *aa;
struct ATS_Address *old;
+ unsigned int ats_res;
if (GNUNET_NO == handle->running)
return;
@@ -457,9 +507,12 @@
plugin_addr, plugin_addr_len,
session_id);
aa->mlp_information = NULL;
- aa->ats = GNUNET_malloc (atsi_count * sizeof (struct
GNUNET_ATS_Information));
- aa->ats_count = atsi_count;
- memcpy (aa->ats, atsi, atsi_count * sizeof (struct GNUNET_ATS_Information));
+ if (atsi_count != (ats_res = disassemble_ats_information(atsi, atsi_count,
aa)))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "While adding address: had %u ATS elements to add, could only
add %u\n",
+ atsi_count, ats_res);
+ }
/* Get existing address or address with session == 0 */
old = find_address (peer, aa);
@@ -491,12 +544,13 @@
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Updated existing address for peer `%s' %p with new session %u\n",
GNUNET_i2s (peer), old, session_id);
- GNUNET_free_non_null (old->ats);
old->session_id = session_id;
- old->ats = NULL;
- old->ats_count = 0;
- old->ats = aa->ats;
- old->ats_count = aa->ats_count;
+ if (atsi_count != (ats_res = disassemble_ats_information(atsi, atsi_count,
old)))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "While updating address: had %u ATS elements to add, could
only add %u\n",
+ atsi_count, ats_res);
+ }
GNUNET_free (aa->plugin);
GNUNET_free (aa);
handle->s_update (handle->solver, handle->addresses, old);
Modified: gnunet/src/ats/gnunet-service-ats_addresses.h
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses.h 2012-12-06 13:53:33 UTC
(rev 25296)
+++ gnunet/src/ats/gnunet-service-ats_addresses.h 2012-12-06 14:00:56 UTC
(rev 25297)
@@ -83,12 +83,12 @@
/**
* ATS information
*/
- struct GNUNET_ATS_Information *ats;
+ //struct GNUNET_ATS_Information *ats;
/**
* Number of ATS information
*/
- uint32_t ats_count;
+ //uint32_t ats_count;
/* CHECK USAGE */
struct GNUNET_TIME_Relative atsp_latency;
Modified: gnunet/src/ats/gnunet-service-ats_addresses_mlp.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses_mlp.c 2012-12-06 13:53:33 UTC
(rev 25296)
+++ gnunet/src/ats/gnunet-service-ats_addresses_mlp.c 2012-12-06 14:00:56 UTC
(rev 25297)
@@ -347,7 +347,7 @@
*
* @return the index on success, otherwise GNUNET_SYSERR
*/
-
+#if 0
static int
mlp_lookup_ats (struct ATS_Address *addr, int ats_index)
{
@@ -367,6 +367,7 @@
else
return GNUNET_SYSERR;
}
+#endif
/**
* Adds the problem constraints for all addresses
@@ -1363,28 +1364,32 @@
GNUNET_assert (NULL != address);
GNUNET_assert (NULL != address->mlp_information);
- GNUNET_assert (NULL != address->ats);
+// GNUNET_assert (NULL != address->ats);
struct MLP_information *mlpi = address->mlp_information;
- struct GNUNET_ATS_Information *ats = address->ats;
+ //struct GNUNET_ATS_Information *ats = address->ats;
GNUNET_assert (mlpi != NULL);
int c;
for (c = 0; c < GNUNET_ATS_QualityPropertiesCount; c++)
{
- int index = mlp_lookup_ats(address, mlp->q[c]);
+ /* FIXME int index = mlp_lookup_ats(address, mlp->q[c]); */
+ int index = GNUNET_SYSERR;
+
if (index == GNUNET_SYSERR)
continue;
-
+ /* FIXME
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating address for peer `%s' value
`%s': %f\n",
GNUNET_i2s (&address->peer),
mlp_ats_to_string(mlp->q[c]),
(double) ats[index].value);
- int i = mlpi->q_avg_i[c];
+ int i = mlpi->q_avg_i[c];*/
double * qp = mlpi->q[c];
+ /* FIXME
qp[i] = (double) ats[index].value;
+ */
int t;
for (t = 0; t < MLP_AVERAGING_QUEUE_LENGTH; t++)
Modified: gnunet/src/ats/test_ats_api_scheduling_update_address.c
===================================================================
--- gnunet/src/ats/test_ats_api_scheduling_update_address.c 2012-12-06
13:53:33 UTC (rev 25296)
+++ gnunet/src/ats/test_ats_api_scheduling_update_address.c 2012-12-06
14:00:56 UTC (rev 25297)
@@ -234,7 +234,15 @@
}
/* Update address */
+ /* Prepare ATS Information */
+ test_ats_info[0].type = htonl (GNUNET_ATS_NETWORK_TYPE);
+ test_ats_info[0].value = htonl(GNUNET_ATS_NET_LAN);
+ test_ats_info[1].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
+ test_ats_info[1].value = htonl(3);
+ test_ats_count = 2;
+ GNUNET_ATS_address_update (sched_ats, &test_hello_address, test_session,
test_ats_info, test_ats_count);
+
/* Request address */
GNUNET_ATS_suggest_address (sched_ats, &p.id);
stage ++;
@@ -255,6 +263,14 @@
ret = 1;
}
+ if (GNUNET_OK != compare_ats(atsi, ats_count, test_ats_info,
test_ats_count))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage 1: Callback with incorrect
ats info \n");
+ ret = 1;
+ GNUNET_SCHEDULER_add_now (&end, NULL);
+ return;
+ }
+
GNUNET_SCHEDULER_add_now (&end, NULL);
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r25297 - gnunet/src/ats,
gnunet <=