struct CompareAddressContext *cac = cls;
struct ATS_Address *aa = value;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Comparing peer %4s: address length %u session %u <-> address length %u session %u\n",
- GNUNET_h2s (key),
- aa->addr_len, aa->session_id,
- cac->search->addr_len, cac->search->session_id);
-
/* Find an matching exact address:
*
* Compare by:
GNUNET_CONTAINER_multihashmap_get_multiple (handle->addresses, &peer->hashPubKey,
&compare_address_it, &cac);
-#if 0
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Found exact address: %s base address: %s\n",
- (cac.exact_address != NULL) ? "YES" : "NO",
- (cac.base_address != NULL) ? "YES" : "NO");
-#endif
if (cac.exact_address == NULL)
return cac.base_address;
return cac.exact_address;
}
-#if 0
-static int
-compare_address_session_it (void *cls, const struct GNUNET_HashCode * key, void *value)
-{
- struct CompareAddressContext *cac = cls;
- struct ATS_Address *aa = value;
-
- if ((aa->addr_len == cac->search->addr_len) && (0 == strcmp (aa->plugin, cac->search->plugin)))
- {
- if ((0 == memcmp (aa->addr, cac->search->addr, aa->addr_len)) && (aa->session_id == cac->search->session_id))
- {
- cac->exact_address = aa;
- return GNUNET_NO;
- }
- }
- return GNUNET_YES;
-}
-
-
-/**
- * Find an existing equivalent address record.
- * Compares by peer identity and network address AND by session ID
- * (one of the two must match).
- *
- * @param peer peer to lookup addresses for
- * @param addr existing address record
- * @return existing address record, NULL for none
- */
-static struct ATS_Address *
-find_exact_address (const struct GNUNET_PeerIdentity *peer,
- const struct ATS_Address *addr)
-{
- struct CompareAddressContext cac;
-
- cac.exact_address = NULL;
- cac.search = addr;
- GNUNET_CONTAINER_multihashmap_get_multiple (handle->addresses, &peer->hashPubKey,
- &compare_address_session_it, &cac);
- return cac.exact_address;
-}
-#endif
-
void
GAS_addresses_add (const struct GNUNET_PeerIdentity *peer,
const char *plugin_name, const void *plugin_addr,
};
+/**
+ * Init the simplistic problem solving component
+ *
+ * Quotas:
+ * network[i] contains the network type as type GNUNET_ATS_NetworkType[i]
+ * out_quota[i] contains outbound quota for network type i
+ * in_quota[i] contains inbound quota for network type i
+ *
+ * Example
+ * network = {GNUNET_ATS_NET_UNSPECIFIED, GNUNET_ATS_NET_LOOPBACK, GNUNET_ATS_NET_LAN, GNUNET_ATS_NET_WAN, GNUNET_ATS_NET_WLAN}
+ * network[2] == GNUNET_ATS_NET_LAN
+ * out_quota[2] == 65353
+ * in_quota[2] == 65353
+ *
+ * @param cfg configuration handle
+ * @param stats the GNUNET_STATISTICS handle
+ * @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
+ * @return handle for the solver on success, NULL on fail
+ */
typedef void *
(*GAS_solver_init) (const struct GNUNET_CONFIGURATION_Handle *cfg,
const struct GNUNET_STATISTICS_Handle *stats,
int *network,
- unsigned long long *out_dest,
- unsigned long long *in_dest,
+ unsigned long long *out_quota,
+ unsigned long long *in_quota,
int dest_length);
typedef void
*/
struct GAS_SIMPLISTIC_Handle
{
+
unsigned int active_addresses;
+
+ /**
+ * Network type array
+ *
+ * quotas[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkType;
+ *
+ */
int *quota_net;
+
+ /**
+ * Array of inbound quotas
+ *
+ */
unsigned long long *quota_in;
+
+ /**
+ * Array of outbound quotas
+ *
+ */
unsigned long long *quota_out;
-};
+ /**
+ * Active addresses per network type
+ */
+ unsigned int *active_addresses_per_net;
+};
/**
* Init the simplistic problem solving component
*
+ * Quotas:
+ * network[i] contains the network type as type GNUNET_ATS_NetworkType[i]
+ * out_quota[i] contains outbound quota for network type i
+ * in_quota[i] contains inbound quota for network type i
+ *
+ * Example
+ * network = {GNUNET_ATS_NET_UNSPECIFIED, GNUNET_ATS_NET_LOOPBACK, GNUNET_ATS_NET_LAN, GNUNET_ATS_NET_WAN, GNUNET_ATS_NET_WLAN}
+ * network[2] == GNUNET_ATS_NET_LAN
+ * out_quota[2] == 65353
+ * in_quota[2] == 65353
+ *
* @param cfg configuration handle
* @param stats the GNUNET_STATISTICS handle
+ * @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
* @return handle for the solver on success, NULL on fail
*/
void *
GAS_simplistic_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
const struct GNUNET_STATISTICS_Handle *stats,
int *network,
- unsigned long long *out_dest,
- unsigned long long *in_dest,
+ unsigned long long *out_quota,
+ unsigned long long *in_quota,
int dest_length)
{
struct GAS_SIMPLISTIC_Handle *solver = GNUNET_malloc (sizeof (struct GAS_SIMPLISTIC_Handle));
memcpy (solver->quota_net, network, dest_length * sizeof (int));
solver->quota_in = GNUNET_malloc (dest_length * sizeof (unsigned long long));
- memcpy (solver->quota_in, out_dest, dest_length * sizeof (int));
+ memcpy (solver->quota_in, in_quota, dest_length * sizeof (int));
solver->quota_out = GNUNET_malloc (dest_length * sizeof (unsigned long long));
- memcpy (solver->quota_out, out_dest, dest_length * sizeof (unsigned long long));
+ memcpy (solver->quota_out, out_quota, dest_length * sizeof (unsigned long long));
+
+ solver->active_addresses_per_net = GNUNET_malloc (dest_length * sizeof (unsigned int));
return solver;
}
GNUNET_free (s->quota_net);
GNUNET_free (s->quota_in);
GNUNET_free (s->quota_out);
+ GNUNET_free (s->active_addresses_per_net);
GNUNET_free (s);
}
aa->assigned_bw_in.value__ = htonl (UINT32_MAX / s->active_addresses);
aa->assigned_bw_out.value__ = htonl (UINT32_MAX / s->active_addresses);
- //send_bw_notification (aa);
-
return GNUNET_OK;
}
enum GNUNET_ATS_PreferenceKind kind,
float score)
{
-
+ /* FIXME : implement this */
}
/* end of gnunet-service-ats_addresses_simplistic.c */
/**
* Init the simplistic problem solving component
*
+ * Quotas:
+ * network[i] contains the network type as type GNUNET_ATS_NetworkType[i]
+ * out_quota[i] contains outbound quota for network type i
+ * in_quota[i] contains inbound quota for network type i
+ *
+ * Example
+ * network = {GNUNET_ATS_NET_UNSPECIFIED, GNUNET_ATS_NET_LOOPBACK, GNUNET_ATS_NET_LAN, GNUNET_ATS_NET_WAN, GNUNET_ATS_NET_WLAN}
+ * network[2] == GNUNET_ATS_NET_LAN
+ * out_quota[2] == 65353
+ * in_quota[2] == 65353
+ *
* @param cfg configuration handle
* @param stats the GNUNET_STATISTICS handle
+ * @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
* @return handle for the solver on success, NULL on fail
*/
void *
GAS_simplistic_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
- const struct GNUNET_STATISTICS_Handle *stats,
- int *network,
- unsigned long long *out_dest, unsigned long long *in_dest, int dest_length);
+ const struct GNUNET_STATISTICS_Handle *stats,
+ int *network,
+ unsigned long long *out_quota,
+ unsigned long long *in_quota,
+ int dest_length);
/**
* Shutdown the simplistic problem solving component