mod
authorMatthias Wachs <wachs@net.in.tum.de>
Fri, 7 Dec 2012 15:32:46 +0000 (15:32 +0000)
committerMatthias Wachs <wachs@net.in.tum.de>
Fri, 7 Dec 2012 15:32:46 +0000 (15:32 +0000)
src/ats/gnunet-service-ats_addresses.c
src/ats/gnunet-service-ats_addresses.h
src/ats/gnunet-service-ats_addresses_simplistic.c
src/ats/gnunet-service-ats_addresses_simplistic.h

index 70869192ee71d8dc9f036b7096046b39b8a26109..ddaa8a36779a5cde4b0d5110c391ec6fe6784907 100644 (file)
@@ -314,11 +314,6 @@ compare_address_it (void *cls, const struct GNUNET_HashCode * key, void *value)
   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:
@@ -400,12 +395,6 @@ find_address (const struct GNUNET_PeerIdentity *peer,
   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;
@@ -444,48 +433,6 @@ lookup_address (const struct GNUNET_PeerIdentity *peer,
 }
 
 
-#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,
index 80c89afbac1934be23e9cfacd59089e712e73b51..5600d48e2055a0454969d5c4fc276403a2c24b17 100644 (file)
@@ -147,12 +147,33 @@ struct ATS_Address
 };
 
 
+/**
+ * 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
index baab09e900a1c269c8e1f536f26819b3d30743e2..1e7b468d5398ea7099006706a5245b299f22b7a3 100644 (file)
  */
 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));
@@ -64,10 +100,12 @@ GAS_simplistic_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
   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;
 }
@@ -86,6 +124,7 @@ GAS_simplistic_done (void *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);
 }
 
@@ -212,8 +251,6 @@ update_bw_simple_it (void *cls, const struct GNUNET_HashCode * key, void *value)
   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;
 }
 
@@ -284,7 +321,7 @@ GAS_simplistic_address_change_preference (void *solver,
                                    enum GNUNET_ATS_PreferenceKind kind,
                                    float score)
 {
-
+  /* FIXME : implement this */
 }
 
 /* end of gnunet-service-ats_addresses_simplistic.c */
index 6f45f819bbf521c7316e4b5438888246abcf13a1..7c99b74ca680261856dd4278924746c4a8c3b40d 100644 (file)
 /**
  * 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