-improve UDP logging
[oweals/gnunet.git] / src / ats / gnunet-service-ats_connectivity.c
index 56d7abbebab2e39ac94bb60f908c91c3c395e7a2..e9f1e5398ba7442e9ef414bcb1562f514df73b0f 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2011-2015 Christian Grothoff (and other contributing authors)
+     Copyright (C) 2011-2015 Christian Grothoff (and other contributing authors)
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -41,6 +41,8 @@ struct ConnectionRequest
    * Client that made the request.
    */
   struct GNUNET_SERVER_Client *client;
+
+  /* TODO: allow client to express a 'strength' for this request */
 };
 
 
@@ -50,6 +52,26 @@ struct ConnectionRequest
 static struct GNUNET_CONTAINER_MultiPeerMap *connection_requests;
 
 
+/**
+ * Is the given peer in the list of peers for which we
+ * have an address request?
+ *
+ * @param cls unused, NULL
+ * @param peer peer to query for
+ * @return #GNUNET_YES if so, #GNUNET_NO if not
+ */
+unsigned int
+GAS_connectivity_has_peer (void *cls,
+                           const struct GNUNET_PeerIdentity *peer)
+{
+  if (NULL == connection_requests)
+    return 0;
+  /* TODO: return sum of 'strength's of connectivity requests */
+  return GNUNET_CONTAINER_multipeermap_contains (connection_requests,
+                                                 peer);
+}
+
+
 /**
  * Handle 'request address' messages from clients.
  *
@@ -198,6 +220,7 @@ GAS_connectivity_done ()
                                          &free_request,
                                          NULL);
   GNUNET_CONTAINER_multipeermap_destroy (connection_requests);
+  connection_requests = NULL;
 }