- fix memleak complaints from valgrind
[oweals/gnunet.git] / src / testbed / gnunet-service-testbed_links.h
1 /*
2   This file is part of GNUnet.
3   (C) 2008--2013 Christian Grothoff (and other contributing authors)
4
5   GNUnet is free software; you can redistribute it and/or modify
6   it under the terms of the GNU General Public License as published
7   by the Free Software Foundation; either version 2, or (at your
8   option) any later version.
9
10   GNUnet is distributed in the hope that it will be useful, but
11   WITHOUT ANY WARRANTY; without even the implied warranty of
12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13   General Public License for more details.
14
15   You should have received a copy of the GNU General Public License
16   along with GNUnet; see the file COPYING.  If not, write to the
17   Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18   Boston, MA 02111-1307, USA.
19 */
20
21 /**
22  * @file testbed/gnunet-service-testbed_links.h
23  * @brief TESTBED service components that deals with starting slave controllers
24  *          and establishing lateral links between controllers
25  * @author Sree Harsha Totakura
26  */
27
28 struct Neighbour;
29
30
31 /**
32  * Structure representing a connected(directly-linked) controller
33  */
34 struct Slave
35 {
36   /**
37    * The controller process handle if we had started the controller
38    */
39   struct GNUNET_TESTBED_ControllerProc *controller_proc;
40
41   /**
42    * The controller handle
43    */
44   struct GNUNET_TESTBED_Controller *controller;
45
46   /**
47    * handle to lcc which is associated with this slave startup. Should be set to
48    * NULL when the slave has successfully started up
49    */
50   struct LinkControllersContext *lcc;
51
52   /**
53    * Head of the host registration DLL
54    */
55   struct HostRegistration *hr_dll_head;
56
57   /**
58    * Tail of the host registration DLL
59    */
60   struct HostRegistration *hr_dll_tail;
61
62   /**
63    * The current host registration handle
64    */
65   struct GNUNET_TESTBED_HostRegistrationHandle *rhandle;
66
67   /**
68    * Hashmap to hold Registered host contexts
69    */
70   struct GNUNET_CONTAINER_MultiHashMap *reghost_map;
71
72   /**
73    * Operation handle for opening a lateral connection to another controller.
74    * Will be NULL if the slave controller is started by this controller
75    */
76   struct GNUNET_TESTBED_Operation *conn_op;
77
78   /**
79    * The id of the host this controller is running on
80    */
81   uint32_t host_id;
82
83 };
84
85 /**
86  * A list of directly linked neighbours
87  */
88 extern struct Slave **GST_slave_list;
89
90 /**
91  * The size of directly linked neighbours list
92  */
93 extern unsigned int GST_slave_list_size;
94
95 void
96 GST_neighbour_list_clean();
97
98 struct Neighbour *
99 GST_get_neighbour (uint32_t id);
100
101 void
102 GST_free_nccq ();
103
104 struct NeighbourConnectNotification;
105
106 typedef void (*GST_NeigbourConnectNotifyCallback) (void *cls,
107                                                    struct
108                                                    GNUNET_TESTBED_Controller
109                                                    *controller);
110
111 struct NeighbourConnectNotification *
112 GST_neighbour_get_connection (struct Neighbour *n,
113                               GST_NeigbourConnectNotifyCallback cb,
114                               void *cb_cls);
115
116 void
117 GST_neighbour_get_connection_cancel (struct NeighbourConnectNotification *h);
118
119 void
120 GST_neighbour_release_connection (struct Neighbour *n);
121
122 /**
123  * Message handler for GNUNET_MESSAGE_TYPE_TESTBED_LCONTROLLERS message
124  *
125  * @param cls NULL
126  * @param client identification of the client
127  * @param message the actual message
128  */
129 void
130 GST_handle_link_controllers (void *cls, struct GNUNET_SERVER_Client *client,
131                              const struct GNUNET_MessageHeader *message);
132
133
134 /**
135  * Cleans up the slave list
136  */
137 void
138 GST_slave_list_clear ();