diff options
-rw-r--r-- | src/ats/gnunet-service-ats_addresses.c | 12 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_addresses.h | 15 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_addresses_mlp.c | 14 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_addresses_mlp.h | 10 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_addresses_simplistic.c | 21 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_addresses_simplistic.h | 10 |
6 files changed, 80 insertions, 2 deletions
diff --git a/src/ats/gnunet-service-ats_addresses.c b/src/ats/gnunet-service-ats_addresses.c index ddaa8a3677..519be0484f 100644 --- a/src/ats/gnunet-service-ats_addresses.c +++ b/src/ats/gnunet-service-ats_addresses.c @@ -124,6 +124,11 @@ struct GAS_Addresses_Handle GAS_solver_init s_init; /** + * Add an address to the solver + */ + GAS_solver_address_add s_add; + + /** * Update address in solver */ GAS_solver_address_update s_update; @@ -478,7 +483,7 @@ GAS_addresses_add (const struct GNUNET_PeerIdentity *peer, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Added new address for peer `%s' session id %u, %p\n", GNUNET_i2s (peer), session_id, aa); /* Tell solver about update */ - handle->s_update (handle->solver, handle->addresses, aa); + handle->s_add (handle->solver, handle->addresses, aa); return; } @@ -505,7 +510,7 @@ GAS_addresses_add (const struct GNUNET_PeerIdentity *peer, } GNUNET_free (aa->plugin); GNUNET_free (aa); - handle->s_update (handle->solver, handle->addresses, old); + handle->s_add (handle->solver, handle->addresses, old); } @@ -997,6 +1002,7 @@ GAS_addresses_init (const struct GNUNET_CONFIGURATION_Handle *cfg, #if HAVE_LIBGLPK ah->ats_mode = MODE_MLP; ah->s_init = &GAS_mlp_init; + ah->s_add = &GAS_mlp_address_add; ah->s_update = &GAS_mlp_address_update; ah->s_get = &GAS_mlp_get_preferred_address; ah->s_pref = &GAS_mlp_address_change_preference; @@ -1011,6 +1017,7 @@ GAS_addresses_init (const struct GNUNET_CONFIGURATION_Handle *cfg, /* Init the simplistic solver with default values */ ah->ats_mode = MODE_SIMPLISTIC; ah->s_init = &GAS_simplistic_init; + ah->s_add = &GAS_simplistic_address_add; ah->s_update = &GAS_simplistic_address_update; ah->s_get = &GAS_simplistic_get_preferred_address; ah->s_pref = &GAS_simplistic_address_change_preference; @@ -1024,6 +1031,7 @@ GAS_addresses_init (const struct GNUNET_CONFIGURATION_Handle *cfg, } GNUNET_assert (NULL != ah->s_init); + GNUNET_assert (NULL != ah->s_add); GNUNET_assert (NULL != ah->s_update); GNUNET_assert (NULL != ah->s_get); GNUNET_assert (NULL != ah->s_pref); diff --git a/src/ats/gnunet-service-ats_addresses.h b/src/ats/gnunet-service-ats_addresses.h index 5600d48e20..ae1215954a 100644 --- a/src/ats/gnunet-service-ats_addresses.h +++ b/src/ats/gnunet-service-ats_addresses.h @@ -176,12 +176,27 @@ typedef void * unsigned long long *in_quota, int dest_length); + typedef void (*GAS_solver_address_change_preference) (void *solver, const struct GNUNET_PeerIdentity *peer, enum GNUNET_ATS_PreferenceKind kind, float score); +/** + * Add a single address to the solver + * + * @param solver the solver Handle + * @param addresses the address hashmap containing all addresses + * @param address the address to add + */ +typedef void +(*GAS_solver_address_add) (void *solver, + struct GNUNET_CONTAINER_MultiHashMap * addresses, + struct ATS_Address *address); + + + typedef void (*GAS_solver_address_delete) (void *solver, struct GNUNET_CONTAINER_MultiHashMap *addresses, diff --git a/src/ats/gnunet-service-ats_addresses_mlp.c b/src/ats/gnunet-service-ats_addresses_mlp.c index 7f20ab68e6..c493517a98 100644 --- a/src/ats/gnunet-service-ats_addresses_mlp.c +++ b/src/ats/gnunet-service-ats_addresses_mlp.c @@ -1517,6 +1517,20 @@ update_quality (struct GAS_MLP_Handle *mlp, struct ATS_Address * address) } } + +/** + * Add a single address to the solve + * + * @param solver the solver Handle + * @param addresses the address hashmap containing all addresses + * @param address the address to add + */ +void +GAS_mlp_address_add (void *solver, struct GNUNET_CONTAINER_MultiHashMap * addresses, struct ATS_Address *address) +{ + +} + /** * Updates a single address in the MLP problem * diff --git a/src/ats/gnunet-service-ats_addresses_mlp.h b/src/ats/gnunet-service-ats_addresses_mlp.h index f0af97dd6b..646b658247 100644 --- a/src/ats/gnunet-service-ats_addresses_mlp.h +++ b/src/ats/gnunet-service-ats_addresses_mlp.h @@ -326,6 +326,16 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg, /** + * Add a single address to the solve + * + * @param solver the solver Handle + * @param addresses the address hashmap containing all addresses + * @param address the address to add + */ +void +GAS_mlp_address_add (void *solver, struct GNUNET_CONTAINER_MultiHashMap * addresses, struct ATS_Address *address); + +/** * Updates a single address in the MLP problem * * If the address did not exist before in the problem: diff --git a/src/ats/gnunet-service-ats_addresses_simplistic.c b/src/ats/gnunet-service-ats_addresses_simplistic.c index 1e7b468d53..3ee446bb8e 100644 --- a/src/ats/gnunet-service-ats_addresses_simplistic.c +++ b/src/ats/gnunet-service-ats_addresses_simplistic.c @@ -39,6 +39,8 @@ struct GAS_SIMPLISTIC_Handle unsigned int active_addresses; + unsigned int networks; + /** * Network type array * @@ -96,6 +98,8 @@ GAS_simplistic_init (const struct GNUNET_CONFIGURATION_Handle *cfg, { struct GAS_SIMPLISTIC_Handle *solver = GNUNET_malloc (sizeof (struct GAS_SIMPLISTIC_Handle)); + solver->networks = dest_length; + solver->quota_net = GNUNET_malloc (dest_length * sizeof (int)); memcpy (solver->quota_net, network, dest_length * sizeof (int)); @@ -129,6 +133,22 @@ GAS_simplistic_done (void *solver) } /** + * Add a single address to the solve + * + * @param solver the solver Handle + * @param addresses the address hashmap containing all addresses + * @param address the address to add + */ +void +GAS_simplistic_address_add (void *solver, struct GNUNET_CONTAINER_MultiHashMap * addresses, struct ATS_Address *address) +{ + + +} + + + +/** * Updates a single address in the solve * * @param solver the solver Handle @@ -139,6 +159,7 @@ void GAS_simplistic_address_update (void *solver, struct GNUNET_CONTAINER_MultiHashMap * addresses, struct ATS_Address *address) { + } diff --git a/src/ats/gnunet-service-ats_addresses_simplistic.h b/src/ats/gnunet-service-ats_addresses_simplistic.h index 7c99b74ca6..da60f6edc2 100644 --- a/src/ats/gnunet-service-ats_addresses_simplistic.h +++ b/src/ats/gnunet-service-ats_addresses_simplistic.h @@ -67,6 +67,16 @@ GAS_simplistic_init (const struct GNUNET_CONFIGURATION_Handle *cfg, void GAS_simplistic_done (void * solver); +/** + * Add a single address to the solve + * + * @param solver the solver Handle + * @param addresses the address hashmap containing all addresses + * @param address the address to add + */ +void +GAS_simplistic_address_add (void *solver, struct GNUNET_CONTAINER_MultiHashMap * addresses, struct ATS_Address *address); + /** * Updates a single address in the solve |