gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r27732 - gnunet/src/ats


From: gnunet
Subject: [GNUnet-SVN] r27732 - gnunet/src/ats
Date: Wed, 3 Jul 2013 13:55:28 +0200

Author: wachs
Date: 2013-07-03 13:55:28 +0200 (Wed, 03 Jul 2013)
New Revision: 27732

Modified:
   gnunet/src/ats/gnunet-service-ats_addresses.c
   gnunet/src/ats/gnunet-service-ats_normalization.c
   gnunet/src/ats/gnunet-service-ats_normalization.h
Log:
function to get normalized properties in solver


Modified: gnunet/src/ats/gnunet-service-ats_addresses.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses.c       2013-07-03 11:55:03 UTC 
(rev 27731)
+++ gnunet/src/ats/gnunet-service-ats_addresses.c       2013-07-03 11:55:28 UTC 
(rev 27732)
@@ -1379,12 +1379,34 @@
               prop_rel);
 }
 
+
+/**
+ * Function allowing the solver to obtain normalized preference
+ * values from solver
+ *
+ * @param cls unused
+ * @param id the peer to return the normalized properties for
+ * @return array of double values with |GNUNET_ATS_PreferenceCount| elements
+ */
 const double *
 get_preferences_cb (void *cls, const struct GNUNET_PeerIdentity *id)
 {
        return GAS_normalization_get_preferences (id);
 }
 
+/**
+ * Function allowing the solver to obtain normalized property
+ * values for an address from solver
+ *
+ * @param cls unused
+ * @param id the peer to return the normalized properties for
+ * @return array of double values with |GNUNET_ATS_QualityPropertiesCount| 
elements
+ */
+const double *
+get_property_cb (void *cls, struct ATS_Address *address)
+{
+       return GAS_normalization_get_properties (address);
+}
 
 /**
  * Change the preference for a peer

Modified: gnunet/src/ats/gnunet-service-ats_normalization.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_normalization.c   2013-07-03 11:55:03 UTC 
(rev 27731)
+++ gnunet/src/ats/gnunet-service-ats_normalization.c   2013-07-03 11:55:28 UTC 
(rev 27732)
@@ -509,7 +509,36 @@
        return rp->f_rel;
 }
 
+
 /**
+ * Get the normalized properties values for a specific peer or
+ * the default values if
+ *
+ * @param address the address
+ * @return pointer to the values, can be indexed with 
GNUNET_ATS_PreferenceKind,
+ * default preferences if peer does not exist
+ */
+const double *
+GAS_normalization_get_properties (struct ATS_Address *address)
+{
+       static double norm_values[GNUNET_ATS_QualityPropertiesCount];
+       int i;
+
+       GNUNET_assert (NULL != address);
+
+       for (i = 0; i < GNUNET_ATS_QualityPropertiesCount; i++)
+       {
+               if ((address->atsin[i].norm >= 1.0) &&
+                               (address->atsin[i].norm <= 2.0))
+                       norm_values[i] = address->atsin[i].norm;
+               else
+                       norm_values[i] = DEFAULT_REL_QUALITY;
+       }
+       return norm_values;
+}
+
+
+/**
  * Quality Normalization
  */
 

Modified: gnunet/src/ats/gnunet-service-ats_normalization.h
===================================================================
--- gnunet/src/ats/gnunet-service-ats_normalization.h   2013-07-03 11:55:03 UTC 
(rev 27731)
+++ gnunet/src/ats/gnunet-service-ats_normalization.h   2013-07-03 11:55:28 UTC 
(rev 27732)
@@ -58,6 +58,17 @@
 
 
 /**
+ * Get the normalized properties values for a specific peer or
+ * the default values if
+ *
+ * @param address the address
+ * @return pointer to the values, can be indexed with 
GNUNET_ATS_PreferenceKind,
+ * default preferences if peer does not exist
+ */
+const double *
+GAS_normalization_get_properties (struct ATS_Address *address);
+
+/**
  * Normalize an updated preference value
  *
  * @param src the client with this preference




reply via email to

[Prev in Thread] Current Thread [Next in Thread]