diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2013-07-03 11:55:28 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2013-07-03 11:55:28 +0000 |
commit | bfa3b153493bc4d15f0be2d3dfa0b77e45065a61 (patch) | |
tree | 4f6a027084e16261046b89ed65f59972ab03fde0 /src/ats | |
parent | 3625013da298f13830847c33d04c3ce5ff430705 (diff) | |
download | gnunet-bfa3b153493bc4d15f0be2d3dfa0b77e45065a61.tar.gz gnunet-bfa3b153493bc4d15f0be2d3dfa0b77e45065a61.zip |
function to get normalized properties in solver
Diffstat (limited to 'src/ats')
-rw-r--r-- | src/ats/gnunet-service-ats_addresses.c | 22 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_normalization.c | 29 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_normalization.h | 11 |
3 files changed, 62 insertions, 0 deletions
diff --git a/src/ats/gnunet-service-ats_addresses.c b/src/ats/gnunet-service-ats_addresses.c index 4574383ab..317cfa07c 100644 --- a/src/ats/gnunet-service-ats_addresses.c +++ b/src/ats/gnunet-service-ats_addresses.c | |||
@@ -1379,12 +1379,34 @@ normalized_property_changed_cb (void *cls, | |||
1379 | prop_rel); | 1379 | prop_rel); |
1380 | } | 1380 | } |
1381 | 1381 | ||
1382 | |||
1383 | /** | ||
1384 | * Function allowing the solver to obtain normalized preference | ||
1385 | * values from solver | ||
1386 | * | ||
1387 | * @param cls unused | ||
1388 | * @param id the peer to return the normalized properties for | ||
1389 | * @return array of double values with |GNUNET_ATS_PreferenceCount| elements | ||
1390 | */ | ||
1382 | const double * | 1391 | const double * |
1383 | get_preferences_cb (void *cls, const struct GNUNET_PeerIdentity *id) | 1392 | get_preferences_cb (void *cls, const struct GNUNET_PeerIdentity *id) |
1384 | { | 1393 | { |
1385 | return GAS_normalization_get_preferences (id); | 1394 | return GAS_normalization_get_preferences (id); |
1386 | } | 1395 | } |
1387 | 1396 | ||
1397 | /** | ||
1398 | * Function allowing the solver to obtain normalized property | ||
1399 | * values for an address from solver | ||
1400 | * | ||
1401 | * @param cls unused | ||
1402 | * @param id the peer to return the normalized properties for | ||
1403 | * @return array of double values with |GNUNET_ATS_QualityPropertiesCount| elements | ||
1404 | */ | ||
1405 | const double * | ||
1406 | get_property_cb (void *cls, struct ATS_Address *address) | ||
1407 | { | ||
1408 | return GAS_normalization_get_properties (address); | ||
1409 | } | ||
1388 | 1410 | ||
1389 | /** | 1411 | /** |
1390 | * Change the preference for a peer | 1412 | * Change the preference for a peer |
diff --git a/src/ats/gnunet-service-ats_normalization.c b/src/ats/gnunet-service-ats_normalization.c index 86e6f1700..6ced1b49e 100644 --- a/src/ats/gnunet-service-ats_normalization.c +++ b/src/ats/gnunet-service-ats_normalization.c | |||
@@ -509,6 +509,35 @@ GAS_normalization_get_preferences (const struct GNUNET_PeerIdentity *id) | |||
509 | return rp->f_rel; | 509 | return rp->f_rel; |
510 | } | 510 | } |
511 | 511 | ||
512 | |||
513 | /** | ||
514 | * Get the normalized properties values for a specific peer or | ||
515 | * the default values if | ||
516 | * | ||
517 | * @param address the address | ||
518 | * @return pointer to the values, can be indexed with GNUNET_ATS_PreferenceKind, | ||
519 | * default preferences if peer does not exist | ||
520 | */ | ||
521 | const double * | ||
522 | GAS_normalization_get_properties (struct ATS_Address *address) | ||
523 | { | ||
524 | static double norm_values[GNUNET_ATS_QualityPropertiesCount]; | ||
525 | int i; | ||
526 | |||
527 | GNUNET_assert (NULL != address); | ||
528 | |||
529 | for (i = 0; i < GNUNET_ATS_QualityPropertiesCount; i++) | ||
530 | { | ||
531 | if ((address->atsin[i].norm >= 1.0) && | ||
532 | (address->atsin[i].norm <= 2.0)) | ||
533 | norm_values[i] = address->atsin[i].norm; | ||
534 | else | ||
535 | norm_values[i] = DEFAULT_REL_QUALITY; | ||
536 | } | ||
537 | return norm_values; | ||
538 | } | ||
539 | |||
540 | |||
512 | /** | 541 | /** |
513 | * Quality Normalization | 542 | * Quality Normalization |
514 | */ | 543 | */ |
diff --git a/src/ats/gnunet-service-ats_normalization.h b/src/ats/gnunet-service-ats_normalization.h index 3637766f5..551c47cd3 100644 --- a/src/ats/gnunet-service-ats_normalization.h +++ b/src/ats/gnunet-service-ats_normalization.h | |||
@@ -58,6 +58,17 @@ GAS_normalization_get_preferences (const struct GNUNET_PeerIdentity *id); | |||
58 | 58 | ||
59 | 59 | ||
60 | /** | 60 | /** |
61 | * Get the normalized properties values for a specific peer or | ||
62 | * the default values if | ||
63 | * | ||
64 | * @param address the address | ||
65 | * @return pointer to the values, can be indexed with GNUNET_ATS_PreferenceKind, | ||
66 | * default preferences if peer does not exist | ||
67 | */ | ||
68 | const double * | ||
69 | GAS_normalization_get_properties (struct ATS_Address *address); | ||
70 | |||
71 | /** | ||
61 | * Normalize an updated preference value | 72 | * Normalize an updated preference value |
62 | * | 73 | * |
63 | * @param src the client with this preference | 74 | * @param src the client with this preference |