- struct Property *p = cls;
- struct ATS_Address *address = k;
- double delta;
- double backup;
- uint32_t avg_value;
-
- backup = address->atsin[p->prop_type].norm;
- avg_value = address->atsin[p->prop_type].avg;
- delta = p->max - p->min;
- /* max - 2 * min + avg_value / max - min */
- if (0 != delta)
- address->atsin[p->prop_type].norm = (delta + (avg_value - p->min)) / (delta);
- else
- address->atsin[p->prop_type].norm = DEFAULT_REL_QUALITY;
-
- if (backup == address->atsin[p->prop_type].norm)
- return GNUNET_OK;
-
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Normalize `%s' address %p's '%s' with value %u to range [%u..%u] = %.3f\n",
- GNUNET_i2s (&address->peer),
- address,
- GNUNET_ATS_print_property_type (p->atsi_type),
- address->atsin[p->prop_type].avg,
- p->min,
- p->max,
- address->atsin[p->prop_type].norm);
- GAS_normalized_property_changed (address,
- p->atsi_type,
- address->atsin[p->prop_type].norm);
+ struct ATS_Address *address = value;
+
+ update_norm (property_range.min.delay.rel_value_us,
+ property_range.max.delay.rel_value_us,
+ &address->norm_delay);
+ update_norm (property_range.min.distance,
+ property_range.max.distance,
+ &address->norm_distance);
+ update_norm (property_range.min.utilization_in,
+ property_range.max.utilization_in,
+ &address->norm_utilization_in);
+ update_norm (property_range.min.utilization_out,
+ property_range.max.utilization_out,
+ &address->norm_utilization_out);