blob: 36e6401806631abd8c5c92bd2a56487359c76c60 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
|
/*
This file is part of GNUnet.
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 Affero General Public License as published
by the Free Software Foundation, either version 3 of the License,
or (at your option) any later version.
GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file testbed/gnunet-service-testbed_links.h
* @brief TESTBED service components that deals with starting slave controllers
* and establishing lateral links between controllers
* @author Sree Harsha Totakura
*/
/**
* A connected controller which is not our child
*/
struct Neighbour;
/**
* Structure representing a connected(directly-linked) controller
*/
struct Slave
{
/**
* The controller process handle if we had started the controller
*/
struct GNUNET_TESTBED_ControllerProc *controller_proc;
/**
* The controller handle
*/
struct GNUNET_TESTBED_Controller *controller;
/**
* handle to lcc which is associated with this slave startup. Should be set to
* NULL when the slave has successfully started up
*/
struct LinkControllersContext *lcc;
/**
* Head of the host registration DLL
*/
struct HostRegistration *hr_dll_head;
/**
* Tail of the host registration DLL
*/
struct HostRegistration *hr_dll_tail;
/**
* The current host registration handle
*/
struct GNUNET_TESTBED_HostRegistrationHandle *rhandle;
/**
* Hashmap to hold Registered host contexts
*/
struct GNUNET_CONTAINER_MultiHashMap *reghost_map;
/**
* The id of the host this controller is running on
*/
uint32_t host_id;
};
/**
* A list of directly linked neighbours
*/
extern struct Slave **GST_slave_list;
/**
* The size of directly linked neighbours list
*/
extern unsigned int GST_slave_list_size;
/**
* Cleans up the neighbour list
*/
void
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 (void);
/**
* Notification context to be used to notify when connection to the neighbour's
* controller is opened
*/
struct NeighbourConnectNotification;
/**
* 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);
/**
* Clean up @a client handle if we stored any via #handle_link_controllers(),
* the given client disconnected.
*
* @param client the client that is history
*/
void
GST_link_notify_disconnect (struct GNUNET_SERVICE_Client *client);
/**
* Cleans up the slave list
*/
void
GST_slave_list_clear (void);
|