guix-env: some update.
[oweals/gnunet.git] / src / testbed / gnunet-service-testbed_links.h
index 65741c21c0fe1ff1e599ba90e77631acf639f2bc..09764b99aca6ca4cb6e033854ed7155084677936 100644 (file)
@@ -1,10 +1,10 @@
 /*
   This file is part of GNUnet.
-  (C) 2008--2013 Christian Grothoff (and other contributing authors)
+  Copyright (C) 2008--2013 GNUnet e.V.
 
   GNUnet is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published
-  by the Free Software Foundation; either version 2, or (at your
+  by the Free Software Foundation; either version 3, or (at your
   option) any later version.
 
   GNUnet is distributed in the hope that it will be useful, but
@@ -14,8 +14,8 @@
 
   You should have received a copy of the GNU General Public License
   along with GNUnet; see the file COPYING.  If not, write to the
-  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-  Boston, MA 02111-1307, USA.
+  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+  Boston, MA 02110-1301, USA.
 */
 
 /**
  * @author Sree Harsha Totakura
  */
 
+
+/**
+ * A connected controller which is not our child
+ */
 struct Neighbour;
 
 
@@ -69,17 +73,10 @@ struct Slave
    */
   struct GNUNET_CONTAINER_MultiHashMap *reghost_map;
 
-  /**
-   * Operation handle for opening a lateral connection to another controller.
-   * Will be NULL if the slave controller is started by this controller
-   */
-  struct GNUNET_TESTBED_Operation *conn_op;
-
   /**
    * The id of the host this controller is running on
    */
   uint32_t host_id;
-
 };
 
 /**
@@ -92,50 +89,119 @@ extern struct Slave **GST_slave_list;
  */
 extern unsigned int GST_slave_list_size;
 
+
+/**
+ * Cleans up the neighbour list
+ */
 void
-GST_neighbour_list_clean();
+GST_neighbour_list_clean (void);
+
 
+/**
+ * Get a neighbour from the neighbour list
+ *
+ * @param id the index of the neighbour in the neighbour list
+ * @return the Neighbour; NULL if the given index in invalid (index greater than
+ *           the list size or neighbour at that index is NULL)
+ */
 struct Neighbour *
 GST_get_neighbour (uint32_t id);
 
+
+/**
+ * Function to cleanup the neighbour connect contexts
+ */
 void
-GST_free_nccq ();
+GST_free_nccq (void);
+
 
+/**
+ * Notification context to be used to notify when connection to the neighbour's
+ * controller is opened
+ */
 struct NeighbourConnectNotification;
 
-typedef void (*GST_NeigbourConnectNotifyCallback) (void *cls,
-                                                   struct
-                                                   GNUNET_TESTBED_Controller
-                                                   *controller);
 
+/**
+ * The notification callback to call when we are connect to neighbour
+ *
+ * @param cls the closure given to GST_neighbour_get_connection()
+ * @param controller the controller handle to the neighbour
+ */
+typedef void
+(*GST_NeigbourConnectNotifyCallback) (void *cls,
+                                      struct GNUNET_TESTBED_Controller *controller);
+
+
+/**
+ * Try to open a connection to the given neigbour.  If the connection is open
+ * already, then it is re-used.  If not, the request is queued in the operation
+ * queues responsible for bounding the total number of file descriptors.  The
+ * actual connection will happen when the operation queue marks the
+ * corresponding operation as active.
+ *
+ * @param n the neighbour to open a connection to
+ * @param cb the notification callback to call when the connection is opened
+ * @param cb_cls the closure for the above callback
+ */
 struct NeighbourConnectNotification *
 GST_neighbour_get_connection (struct Neighbour *n,
                               GST_NeigbourConnectNotifyCallback cb,
                               void *cb_cls);
 
+
+/**
+ * Cancel the request for opening a connection to the neighbour
+ *
+ * @param h the notification handle
+ */
 void
 GST_neighbour_get_connection_cancel (struct NeighbourConnectNotification *h);
 
+
+/**
+ * Release the connection to the neighbour.  The actual connection will be
+ * closed if connections to other neighbour are waiting (to maintain a bound on
+ * the total number of connections that are open).
+ *
+ * @param n the neighbour whose connection can be closed
+ */
 void
 GST_neighbour_release_connection (struct Neighbour *n);
 
+
+/**
+ * Function to create a neigbour and add it into the neighbour list
+ *
+ * @param host the host of the neighbour
+ */
 struct Neighbour *
 GST_create_neighbour (struct GNUNET_TESTBED_Host *host);
 
+
+/**
+ * Message handler for #GNUNET_MESSAGE_TYPE_TESTBED_LCONTROLLERS message
+ *
+ * @param cls identification of the client
+ * @param msg the actual message
+ */
+void
+handle_link_controllers (void *cls,
+                         const struct GNUNET_TESTBED_ControllerLinkRequest *msg);
+
+
 /**
- * Message handler for GNUNET_MESSAGE_TYPE_TESTBED_LCONTROLLERS message
+ * Clean up @a client handle if we stored any via #handle_link_controllers(),
+ * the given client disconnected.
  *
- * @param cls NULL
- * @param client identification of the client
- * @param message the actual message
+ * @param client the client that is history
  */
 void
-GST_handle_link_controllers (void *cls, struct GNUNET_SERVER_Client *client,
-                             const struct GNUNET_MessageHeader *message);
+GST_link_notify_disconnect (struct GNUNET_SERVICE_Client *client);
 
 
 /**
  * Cleans up the slave list
  */
 void
-GST_slave_list_clear ();
+GST_slave_list_clear (void);