indent
[oweals/gnunet.git] / src / ats / gnunet-service-ats_addresses.h
index 4eddd5290e6de3791803b3cb1bd9eb48e7fabe08..4f17fd9123aa0b7dd644f6750966d8e9ea4969d5 100644 (file)
  *    it as a value_number. If no configuration value is found it will assign
  *    GNUNET_ATS_DefaultBandwidth. The most important step is to load the
  *    configured solver using configuration "[ats]:MODE". Current solvers are
- *    MODE_SIMPLISTIC, MODE_MLP. Interaction is done using a solver API
+ *    MODE_PROPORTIONAL, MODE_MLP. Interaction is done using a solver API
  *
  *     1.4 Solver API
  *
  */
 #define ATS_BLOCKING_DELTA GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100)
 
-struct GAS_Addresses_Handle;
 
 /**
  * Information provided by ATS normalization
@@ -259,6 +258,7 @@ struct GAS_NormalizationInfo
                double norm;
 };
 
+
 /**
  * Address with additional information
  */
@@ -314,32 +314,6 @@ struct ATS_Address
    */
   uint32_t atsi_count;
 
-#if 0
-  /* CHECK USAGE */
-  struct GNUNET_TIME_Relative atsp_latency;
-
-  /* CHECK USAGE */
-  struct GNUNET_BANDWIDTH_Value32NBO atsp_utilization_in;
-
-  /* CHECK USAGE */
-  struct GNUNET_BANDWIDTH_Value32NBO atsp_utilization_out;
-
-
-  /* CHECK USAGE */
-  uint32_t atsp_distance;
-
-  /* CHECK USAGE */
-  uint32_t atsp_cost_wan;
-
-  /* CHECK USAGE */
-  uint32_t atsp_cost_lan;
-
-  /* CHECK USAGE */
-  uint32_t atsp_cost_wlan;
-
-  /* CHECK USAGE */
-  uint32_t atsp_network_type;
-#endif
   /**
    * Inbound bandwidth assigned by solver in NBO
    */
@@ -383,21 +357,44 @@ struct ATS_Address
  *
  * @param address the with changed bandwidth assigned
  */
-
 typedef void
  (*GAS_bandwidth_changed_cb) (void *cls, struct ATS_Address *address);
 
+
+/**
+ * Callback to call from solver to obtain application preference values for a
+ * peer
+ *
+ * @param cls the cls
+ * @param id the peer id
+ * @return carry of double values containing the preferences with
+ *     GNUNET_ATS_PreferenceCount elements
+ */
 typedef const double *
  (*GAS_get_preferences) (void *cls, const struct GNUNET_PeerIdentity *id);
 
 
+/**
+ * Callback to call from solver to obtain transport properties for an
+ * address
+ *
+ * @param cls the cls
+ * @param address the address
+ * @return carry of double values containing the preferences with
+ *     GNUNET_ATS_PreferenceCount elements
+ */
+typedef const double *
+ (*GAS_get_properties) (void *cls, const struct ATS_Address *address);
+
+
+
 /*
  * Solver API
  * ----------
  */
 
 /**
- * Init the simplistic problem solving component
+ * Init the problem solving component
  *
  * Quotas:
  * network[i] contains the network type as type GNUNET_ATS_NetworkType[i]
@@ -412,6 +409,7 @@ typedef const double *
  *
  * @param cfg configuration handle
  * @param stats the GNUNET_STATISTICS handle
+ * @param addresses hashmap containing all addresses
  * @param network array of GNUNET_ATS_NetworkType with length dest_length
  * @param out_quota array of outbound quotas
  * @param in_quota array of outbound quota
@@ -421,6 +419,7 @@ typedef const double *
 typedef void *
  (*GAS_solver_init) (const struct GNUNET_CONFIGURATION_Handle *cfg,
                      const struct GNUNET_STATISTICS_Handle *stats,
+                     const struct GNUNET_CONTAINER_MultiHashMap *addresses,
                      int *network,
                      unsigned long long *out_quota,
                      unsigned long long *in_quota,
@@ -428,7 +427,9 @@ typedef void *
                      GAS_bandwidth_changed_cb bw_changed_cb,
                      void *bw_changed_cb_cls,
                      GAS_get_preferences get_preference,
-                     void *get_preference_cls);
+                     void *get_preference_cls,
+                     GAS_get_properties get_properties,
+                     void *get_properties_cls);
 
 
 /**
@@ -443,11 +444,49 @@ typedef void *
  */
 typedef void
 (*GAS_solver_address_change_preference) (void *solver,
-                                                                                                                                                                struct GNUNET_CONTAINER_MultiHashMap *addresses,
                                                                                                                                                                 const struct GNUNET_PeerIdentity *peer,
                                                                                                                                                                 enum GNUNET_ATS_PreferenceKind kind,
                                                                                                                                                                 double pref_rel);
 
+
+/**
+ * Give feedback about the current assignment
+ *
+ * @param handle the solver handle
+ * @param application the application sending this request
+ * @param peer the peer id
+ * @param scope the time interval for this feedback: [now - scope .. now]
+ * @param kind the preference kind for this feedback
+ * @param score the feedback score
+ */
+typedef void
+(*GAS_solver_address_feedback_preference) (void *solver,
+                                                                                                                                                                void *application,
+                                                                                                                                                                const struct GNUNET_PeerIdentity *peer,
+                                                                                                                                                                const struct GNUNET_TIME_Relative scope,
+                                                                                                                                                                enum GNUNET_ATS_PreferenceKind kind,
+                                                                                                                                                                double score);
+
+/**
+ * Notify the solver about a bulk operation changing possibly a lot of values
+ * Solver will not resolve until all bulk operations are marked as done
+ *
+ * @param solver the solver
+ */
+typedef void
+(*GAS_solver_bulk_start) (void *solver);
+
+
+/**
+ * Mark a bulk operation as done
+ * Solver will resolve if values have changed
+ *
+ * @param solver the solver
+ */
+typedef void
+(*GAS_solver_bulk_stop) (void *solver);
+
+
 /**
  * Add a single address within a network to the solver
  *
@@ -458,9 +497,8 @@ typedef void
  */
 typedef void
 (*GAS_solver_address_add) (void *solver,
-                                                                                                               struct GNUNET_CONTAINER_MultiHashMap *addresses,
-                                                                                                               struct ATS_Address *address,
-                                                                                                               uint32_t network);
+                                                                                                        struct ATS_Address *address,
+                                                                                                        uint32_t network);
 
 
 /**
@@ -473,30 +511,72 @@ typedef void
  */
 typedef void
  (*GAS_solver_address_delete) (void *solver,
-                               struct GNUNET_CONTAINER_MultiHashMap *addresses,
                                struct ATS_Address *address,
                                int session_only);
 
+
 /**
- * Notify the solver about an update for an address
+ * Transport properties for this address have changed
  *
- * @param solver the solver to use
- * @param addresses the address hashmap containing all addresses
+ * @param solver solver handle
+ * @param address the address
+ * @param type the ATSI type in HBO
+ * @param abs_value the absolute value of the property
+ * @param rel_value the normalized value
+ */
+typedef void
+(*GAS_solver_address_property_changed) (void *solver,
+                                                                                                                                                               struct ATS_Address *address,
+                                                                                                                                                               uint32_t type,
+                                                                                                                                                               uint32_t abs_value,
+                                                                                                                                                               double rel_value);
+
+
+/**
+ * Transport session for this address has changed
+ *
+ * NOTE: values in addresses are already updated
+ *
+ * @param solver solver handle
+ * @param address the address
+ * @param cur_session the current session
+ * @param new_session the new session
+ */
+typedef void
+(*GAS_solver_address_session_changed) (void *solver,
+                                                                                                                                                       struct ATS_Address *address,
+                                                                                                                                                       uint32_t cur_session,
+                                                                                                                                                       uint32_t new_session);
+
+/**
+ * Transport session for this address has changed
+ *
+ * NOTE: values in addresses are already updated
+ *
+ * @param solver solver handle
  * @param address the address
- * @param session the previous session
- * @param in_use previous address used state: yes or no
- * @param atsi ats previous performance information
- * @param atsi_count previous number of ats performance information
+ * @param in_use usage state
+ */
+typedef void
+(*GAS_solver_address_inuse_changed) (void *solver,
+                                                                                                                                          struct ATS_Address *address,
+                                                                                                                                          int in_use);
+
+/**
+ * Network scope for this address has changed
+ *
+ * NOTE: values in addresses are already updated
  *
+ * @param solver solver handle
+ * @param address the address
+ * @param current_network the current network
+ * @param new_network the new network
  */
 typedef void
-(*GAS_solver_address_update) (void *solver,
-                              struct GNUNET_CONTAINER_MultiHashMap *addresses,
-                              struct ATS_Address *address,
-                              uint32_t prev_session,
-                              int in_use,
-                              const struct GNUNET_ATS_Information *prev_atsi,
-                              uint32_t prev_atsi_count);
+(*GAS_solver_address_network_changed) (void *solver,
+                                                                                                                                          struct ATS_Address *address,
+                                                                                                                                          uint32_t current_network,
+                                                                                                                                          uint32_t new_network);
 
 
 /**
@@ -508,7 +588,6 @@ typedef void
  */
 typedef const struct ATS_Address *
 (*GAS_solver_get_preferred_address) (void *solver,
-                                     struct GNUNET_CONTAINER_MultiHashMap *addresses,
                                      const struct GNUNET_PeerIdentity *peer);
 
 
@@ -521,7 +600,6 @@ typedef const struct ATS_Address *
  */
 typedef void
 (*GAS_solver_stop_get_preferred_address) (void *solver,
-                                     struct GNUNET_CONTAINER_MultiHashMap *addresses,
                                      const struct GNUNET_PeerIdentity *peer);
 
 /**
@@ -716,6 +794,25 @@ GAS_addresses_change_preference (struct GAS_Addresses_Handle *handle,
                                  float score_abs);
 
 
+/**
+ * Change the preference for a peer
+ *
+ * @param handle the address handle
+ * @param application the client sending this request
+ * @param peer the peer id
+ * @param scope the time interval this valid for: [now - scope .. now]
+ * @param kind the preference kind to change
+ * @param score_abs the new preference score
+ */
+void
+GAS_addresses_preference_feedback (struct GAS_Addresses_Handle *handle,
+                                                                                                                                               void *application,
+                                                                                                                                               const struct GNUNET_PeerIdentity *peer,
+                                                                                                                                               const struct GNUNET_TIME_Relative scope,
+                                                                                                                                               enum GNUNET_ATS_PreferenceKind kind,
+                                                                                                                                               float score_abs);
+
+
 /**
  * Iterator for GAS_addresses_iterate_peers
  *