-void
-GAS_normalization_normalize_preference (void *src,
- const struct GNUNET_PeerIdentity *peer,
- enum GNUNET_ATS_PreferenceKind kind,
- float score_abs)
-{
- struct PreferenceClient *c_cur;
- struct PreferencePeer *p_cur;
- struct PeerRelative *r_cur;
- int i;
-
- GNUNET_assert(NULL != src);
- GNUNET_assert(NULL != peer);
-
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
- "Client %p changes preference for peer `%s' for `%s' to %.2f\n", src,
- GNUNET_i2s (peer), GNUNET_ATS_print_preference_type (kind), score_abs);
-
- if (kind >= GNUNET_ATS_PreferenceCount)
- {
- GNUNET_break(0);
- return;
- }
-
- /* Find preference client */
- for (c_cur = pc_head; NULL != c_cur; c_cur = c_cur->next)
- {
- if (src == c_cur->client)
- break;
- }
- /* Not found: create new preference client */
- if (NULL == c_cur)
- {
- c_cur = GNUNET_malloc (sizeof (struct PreferenceClient));
- c_cur->client = src;
- GNUNET_CONTAINER_DLL_insert (pc_head, pc_tail, c_cur);
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
- "Adding new client %p \n", c_cur);
- }
-
- /* Find entry for peer */
- for (p_cur = c_cur->p_head; NULL != p_cur; p_cur = p_cur->next)
- if (0 == memcmp (&p_cur->id, peer, sizeof(p_cur->id)))
- break;
-
- /* Not found: create new peer entry */
- if (NULL == p_cur)
- {
- p_cur = GNUNET_malloc (sizeof (struct PreferencePeer));
- p_cur->client = c_cur;
- p_cur->id = (*peer);
- for (i = 0; i < GNUNET_ATS_PreferenceCount; i++)
- {
- /* Default value per peer absolut preference for a quality:
- * No value set, so absolute preference 0 */
- p_cur->f_abs[i] = DEFAULT_ABS_PREFERENCE;
- /* Default value per peer relative preference for a quality: 1.0 */
- p_cur->f_rel[i] = DEFAULT_REL_PREFERENCE;
- p_cur->next_aging[i] = GNUNET_TIME_UNIT_FOREVER_ABS;
- }
- GNUNET_CONTAINER_DLL_insert(c_cur->p_head, c_cur->p_tail, p_cur);
- }
-
- if (NULL == GNUNET_CONTAINER_multipeermap_get (preference_peers,
- peer))
- {
- r_cur = GNUNET_malloc (sizeof (struct PeerRelative));
- r_cur->id = (*peer);
- for (i = 0; i < GNUNET_ATS_PreferenceCount; i++)
- r_cur->f_rel[i] = DEFAULT_REL_PREFERENCE;
- GNUNET_CONTAINER_multipeermap_put (preference_peers, &r_cur->id,
- r_cur, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
- }
-
- if (GNUNET_SCHEDULER_NO_TASK == aging_task)
- aging_task = GNUNET_SCHEDULER_add_delayed (PREF_AGING_INTERVAL,
- &preference_aging, NULL);
-
- update_preference (c_cur, p_cur, kind, score_abs);
-}
-
-/**
- * Get the normalized preference values for a specific peer or
- * the default values if
- *
- * @param id the peer
- * @return pointer to the values, can be indexed with GNUNET_ATS_PreferenceKind,
- * default preferences if peer does not exist
- */
-const double *
-GAS_normalization_get_preferences_by_peer (const struct GNUNET_PeerIdentity *id)