MODE_MLP
};
-
-
-
-
-
+/**
+ * Handle for ATS address component
+ */
struct GAS_Addresses_Handle
{
+ /**
+ * A multihashmap to store all addresses
+ */
struct GNUNET_CONTAINER_MultiHashMap *addresses;
+ /**
+ * Configure WAN quota in
+ */
unsigned long long wan_quota_in;
+ /**
+ * Configure WAN quota out
+ */
unsigned long long wan_quota_out;
+ /**
+ * Number of active addresses
+ */
unsigned int active_addr_count;
+ /**
+ * Is ATS addresses running
+ */
int running;
-
+ /**
+ * Configured ATS solver
+ */
int ats_mode;
- /* Solver handle */
+
+ /**
+ * Solver handle
+ */
void *solver;
/* Solver functions */
+
+ /**
+ * Initialize solver
+ */
GAS_solver_init s_init;
- GAS_solver_done s_done;
+
+ /**
+ * Update address in solver
+ */
+ GAS_solver_address_update s_update;
+
+ /**
+ * Get address from solver
+ */
+ GAS_solver_get_preferred_address s_get;
+
+ /**
+ * Delete address in solver
+ */
GAS_solver_address_delete s_del;
+
+ /**
+ * Change preference for quality in solver
+ */
GAS_solver_address_change_preference s_pref;
+
+ /**
+ * Shutdown solver
+ */
+ GAS_solver_done s_done;
};
+
+/**
+ * Temporary handle
+ */
struct GAS_Addresses_Handle *handle;
+
static unsigned int
assemble_ats_information (struct ATS_Address *aa, struct GNUNET_ATS_Information **dest)
{
}
+#if 0
static int
compare_address_session_it (void *cls, const struct GNUNET_HashCode * key, void *value)
{
&compare_address_session_it, &cac);
return cac.exact_address;
}
-
+#endif
void
GAS_addresses_add (const struct GNUNET_PeerIdentity *peer,
}
/* Tell solver about update */
- switch (handle->ats_mode)
- {
- case MODE_MLP:
- GAS_mlp_address_update (handle->solver, handle->addresses, old);
- break;
- case MODE_SIMPLISTIC:
- GAS_simplistic_address_update (handle->solver, handle->addresses, old);
- break;
- default:
- GNUNET_break (0);
- break;
- }
+ handle->s_update (handle->solver, handle->addresses, old);
}
old->used = in_use;
/* Tell solver about update */
- switch (handle->ats_mode)
- {
- case MODE_MLP:
- GAS_mlp_address_update (handle->solver, handle->addresses, old);
- break;
- case MODE_SIMPLISTIC:
- GAS_simplistic_address_update (handle->solver, handle->addresses, old);
- break;
- default:
- GNUNET_break (0);
- break;
- }
+ handle->s_update (handle->solver, handle->addresses, old);
+
return GNUNET_OK;
}
}
-
-// FIXME: this function should likely end up in the LP-subsystem and
-// not with 'addresses' in the future...
void
GAS_addresses_change_preference (const struct GNUNET_PeerIdentity *peer,
enum GNUNET_ATS_PreferenceKind kind,
if (GNUNET_NO == handle->running)
return;
-
/* Tell solver about update */
- switch (handle->ats_mode)
- {
- case MODE_MLP:
- GAS_mlp_address_change_preference (handle->solver, peer, kind, score);
- break;
- case MODE_SIMPLISTIC:
- GAS_simplistic_address_change_preference (handle->solver, peer, kind, score);
- break;
- default:
- GNUNET_break (0);
- break;
- }
+ handle->s_pref (handle->solver, peer, kind, score);
}
#if HAVE_LIBGLPK
ah->ats_mode = MODE_MLP;
ah->s_init = &GAS_mlp_init;
+ ah->s_update = &GAS_mlp_address_update;
+ ah->s_get = &GAS_mlp_get_preferred_address;
ah->s_pref = &GAS_mlp_address_change_preference;
ah->s_del = &GAS_mlp_address_delete;
ah->s_done = &GAS_mlp_done;
/* Init the simplistic solver with default values */
ah->ats_mode = MODE_SIMPLISTIC;
ah->s_init = &GAS_simplistic_init;
+ ah->s_update = &GAS_simplistic_address_update;
+ ah->s_get = &GAS_simplistic_get_preferred_address;
ah->s_pref = &GAS_simplistic_address_change_preference;
ah->s_del = &GAS_simplistic_address_delete;
ah->s_done = &GAS_simplistic_done;
}
GNUNET_assert (NULL != ah->s_init);
+ GNUNET_assert (NULL != ah->s_update);
+ GNUNET_assert (NULL != ah->s_get);
GNUNET_assert (NULL != ah->s_pref);
GNUNET_assert (NULL != ah->s_del);
GNUNET_assert (NULL != ah->s_done);