diff options
Diffstat (limited to 'src/transport/gnunet-service-transport_plugins.c')
-rw-r--r-- | src/transport/gnunet-service-transport_plugins.c | 486 |
1 files changed, 242 insertions, 244 deletions
diff --git a/src/transport/gnunet-service-transport_plugins.c b/src/transport/gnunet-service-transport_plugins.c index c6c5e0444..b9203f9f4 100644 --- a/src/transport/gnunet-service-transport_plugins.c +++ b/src/transport/gnunet-service-transport_plugins.c | |||
@@ -1,22 +1,22 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2010-2014 GNUnet e.V. | 3 | Copyright (C) 2010-2014 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
7 | by the Free Software Foundation, either version 3 of the License, | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | or (at your option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file transport/gnunet-service-transport_plugins.c | 22 | * @file transport/gnunet-service-transport_plugins.c |
@@ -32,8 +32,7 @@ | |||
32 | /** | 32 | /** |
33 | * Entry in doubly-linked list of all of our plugins. | 33 | * Entry in doubly-linked list of all of our plugins. |
34 | */ | 34 | */ |
35 | struct TransportPlugin | 35 | struct TransportPlugin { |
36 | { | ||
37 | /** | 36 | /** |
38 | * This is a doubly-linked list. | 37 | * This is a doubly-linked list. |
39 | */ | 38 | */ |
@@ -65,7 +64,6 @@ struct TransportPlugin | |||
65 | * for this plugin. | 64 | * for this plugin. |
66 | */ | 65 | */ |
67 | struct GNUNET_TRANSPORT_PluginEnvironment env; | 66 | struct GNUNET_TRANSPORT_PluginEnvironment env; |
68 | |||
69 | }; | 67 | }; |
70 | 68 | ||
71 | /** | 69 | /** |
@@ -88,12 +86,12 @@ static struct TransportPlugin *plugins_tail; | |||
88 | * @param distance new distance | 86 | * @param distance new distance |
89 | */ | 87 | */ |
90 | static void | 88 | static void |
91 | plugin_env_update_distance (void *cls, | 89 | plugin_env_update_distance(void *cls, |
92 | const struct GNUNET_HELLO_Address *address, | 90 | const struct GNUNET_HELLO_Address *address, |
93 | uint32_t distance) | 91 | uint32_t distance) |
94 | { | 92 | { |
95 | GST_ats_update_distance (address, | 93 | GST_ats_update_distance(address, |
96 | distance); | 94 | distance); |
97 | } | 95 | } |
98 | 96 | ||
99 | 97 | ||
@@ -107,18 +105,18 @@ plugin_env_update_distance (void *cls, | |||
107 | * @return type of the network @a addr belongs to | 105 | * @return type of the network @a addr belongs to |
108 | */ | 106 | */ |
109 | static enum GNUNET_NetworkType | 107 | static enum GNUNET_NetworkType |
110 | plugin_env_address_to_type (void *cls, | 108 | plugin_env_address_to_type(void *cls, |
111 | const struct sockaddr *addr, | 109 | const struct sockaddr *addr, |
112 | size_t addrlen) | 110 | size_t addrlen) |
113 | { | 111 | { |
114 | if (NULL == GST_is) | 112 | if (NULL == GST_is) |
115 | { | 113 | { |
116 | GNUNET_break(0); | 114 | GNUNET_break(0); |
117 | return GNUNET_NT_UNSPECIFIED; | 115 | return GNUNET_NT_UNSPECIFIED; |
118 | } | 116 | } |
119 | return GNUNET_NT_scanner_get_type (GST_is, | 117 | return GNUNET_NT_scanner_get_type(GST_is, |
120 | addr, | 118 | addr, |
121 | addrlen); | 119 | addrlen); |
122 | } | 120 | } |
123 | 121 | ||
124 | 122 | ||
@@ -135,10 +133,10 @@ plugin_env_address_to_type (void *cls, | |||
135 | * @param address_type_cb function to call when a address type is requested | 133 | * @param address_type_cb function to call when a address type is requested |
136 | */ | 134 | */ |
137 | void | 135 | void |
138 | GST_plugins_load (GNUNET_TRANSPORT_PluginReceiveCallback recv_cb, | 136 | GST_plugins_load(GNUNET_TRANSPORT_PluginReceiveCallback recv_cb, |
139 | GNUNET_TRANSPORT_AddressNotification address_cb, | 137 | GNUNET_TRANSPORT_AddressNotification address_cb, |
140 | GNUNET_TRANSPORT_SessionStart session_start_cb, | 138 | GNUNET_TRANSPORT_SessionStart session_start_cb, |
141 | GNUNET_TRANSPORT_SessionEnd session_end_cb) | 139 | GNUNET_TRANSPORT_SessionEnd session_end_cb) |
142 | { | 140 | { |
143 | struct TransportPlugin *plug; | 141 | struct TransportPlugin *plug; |
144 | struct TransportPlugin *next; | 142 | struct TransportPlugin *next; |
@@ -149,175 +147,175 @@ GST_plugins_load (GNUNET_TRANSPORT_PluginReceiveCallback recv_cb, | |||
149 | int fail; | 147 | int fail; |
150 | 148 | ||
151 | if (GNUNET_OK != | 149 | if (GNUNET_OK != |
152 | GNUNET_CONFIGURATION_get_value_number (GST_cfg, | 150 | GNUNET_CONFIGURATION_get_value_number(GST_cfg, |
153 | "TRANSPORT", | 151 | "TRANSPORT", |
154 | "NEIGHBOUR_LIMIT", | 152 | "NEIGHBOUR_LIMIT", |
155 | &tneigh)) | 153 | &tneigh)) |
156 | { | ||
157 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
158 | _("Transport service is lacking NEIGHBOUR_LIMIT option.\n")); | ||
159 | return; | ||
160 | } | ||
161 | if (GNUNET_OK != | ||
162 | GNUNET_CONFIGURATION_get_value_string (GST_cfg, | ||
163 | "TRANSPORT", | ||
164 | "PLUGINS", | ||
165 | &plugs)) | ||
166 | return; | ||
167 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
168 | _("Starting transport plugins `%s'\n"), | ||
169 | plugs); | ||
170 | for (pos = strtok (plugs, " "); pos != NULL; pos = strtok (NULL, " ")) | ||
171 | { | ||
172 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
173 | _("Loading `%s' transport plugin\n"), | ||
174 | pos); | ||
175 | GNUNET_asprintf (&libname, | ||
176 | "libgnunet_plugin_transport_%s", | ||
177 | pos); | ||
178 | plug = GNUNET_new (struct TransportPlugin); | ||
179 | plug->short_name = GNUNET_strdup (pos); | ||
180 | plug->lib_name = libname; | ||
181 | plug->env.cfg = GST_cfg; | ||
182 | plug->env.my_identity = &GST_my_identity; | ||
183 | plug->env.get_our_hello = &GST_hello_get; | ||
184 | plug->env.cls = plug->short_name; | ||
185 | plug->env.receive = recv_cb; | ||
186 | plug->env.notify_address = address_cb; | ||
187 | plug->env.session_start = session_start_cb; | ||
188 | plug->env.session_end = session_end_cb; | ||
189 | plug->env.get_address_type = &plugin_env_address_to_type; | ||
190 | plug->env.update_address_distance = &plugin_env_update_distance; | ||
191 | plug->env.max_connections = tneigh; | ||
192 | plug->env.stats = GST_stats; | ||
193 | GNUNET_CONTAINER_DLL_insert (plugins_head, | ||
194 | plugins_tail, | ||
195 | plug); | ||
196 | } | ||
197 | GNUNET_free (plugs); | ||
198 | next = plugins_head; | ||
199 | while (NULL != next) | ||
200 | { | ||
201 | plug = next; | ||
202 | next = plug->next; | ||
203 | plug->api = GNUNET_PLUGIN_load (plug->lib_name, | ||
204 | &plug->env); | ||
205 | if (NULL == plug->api) | ||
206 | { | ||
207 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
208 | _("Failed to load transport plugin for `%s'\n"), | ||
209 | plug->lib_name); | ||
210 | GNUNET_CONTAINER_DLL_remove (plugins_head, | ||
211 | plugins_tail, | ||
212 | plug); | ||
213 | GNUNET_free (plug->short_name); | ||
214 | GNUNET_free (plug->lib_name); | ||
215 | GNUNET_free (plug); | ||
216 | continue; | ||
217 | } | ||
218 | fail = GNUNET_NO; | ||
219 | if (NULL == plug->api->address_pretty_printer) | ||
220 | { | ||
221 | fail = GNUNET_YES; | ||
222 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
223 | _("Missing function `%s' in transport plugin for `%s'\n"), | ||
224 | "address_pretty_printer", | ||
225 | plug->lib_name); | ||
226 | } | ||
227 | if (NULL == plug->api->address_to_string) | ||
228 | { | ||
229 | fail = GNUNET_YES; | ||
230 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
231 | _("Missing function `%s' in transport plugin for `%s'\n"), | ||
232 | "address_to_string", | ||
233 | plug->lib_name); | ||
234 | } | ||
235 | if (NULL == plug->api->string_to_address) | ||
236 | { | ||
237 | fail = GNUNET_YES; | ||
238 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
239 | _("Missing function `%s' in transport plugin for `%s'\n"), | ||
240 | "string_to_address", | ||
241 | plug->lib_name); | ||
242 | } | ||
243 | if (NULL == plug->api->check_address) | ||
244 | { | ||
245 | fail = GNUNET_YES; | ||
246 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
247 | _("Missing function `%s' in transport plugin for `%s'\n"), | ||
248 | "check_address", | ||
249 | plug->lib_name); | ||
250 | } | ||
251 | if (NULL == plug->api->get_session) | ||
252 | { | ||
253 | fail = GNUNET_YES; | ||
254 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
255 | _("Missing function `%s' in transport plugin for `%s'\n"), | ||
256 | "get_session", | ||
257 | plug->lib_name); | ||
258 | } | ||
259 | if (NULL == plug->api->get_network) | ||
260 | { | ||
261 | fail = GNUNET_YES; | ||
262 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
263 | _("Missing function `%s' in transport plugin for `%s'\n"), | ||
264 | "get_network", | ||
265 | plug->lib_name); | ||
266 | } | ||
267 | if (NULL == plug->api->send) | ||
268 | { | ||
269 | fail = GNUNET_YES; | ||
270 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
271 | _("Missing function `%s' in transport plugin for `%s'\n"), | ||
272 | "send", | ||
273 | plug->lib_name); | ||
274 | } | ||
275 | if (NULL == plug->api->disconnect_peer) | ||
276 | { | ||
277 | fail = GNUNET_YES; | ||
278 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
279 | _("Missing function `%s' in transport plugin for `%s'\n"), | ||
280 | "disconnect_peer", | ||
281 | plug->lib_name); | ||
282 | } | ||
283 | if (NULL == plug->api->disconnect_session) | ||
284 | { | ||
285 | fail = GNUNET_YES; | ||
286 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
287 | _("Missing function `%s' in transport plugin for `%s'\n"), | ||
288 | "disconnect_session", | ||
289 | plug->lib_name); | ||
290 | } | ||
291 | if (NULL == plug->api->query_keepalive_factor) | ||
292 | { | 154 | { |
293 | fail = GNUNET_YES; | 155 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
294 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 156 | _("Transport service is lacking NEIGHBOUR_LIMIT option.\n")); |
295 | _("Missing function `%s' in transport plugin for `%s'\n"), | 157 | return; |
296 | "query_keepalive_factor", | ||
297 | plug->lib_name); | ||
298 | } | 158 | } |
299 | if (NULL == plug->api->update_session_timeout) | 159 | if (GNUNET_OK != |
160 | GNUNET_CONFIGURATION_get_value_string(GST_cfg, | ||
161 | "TRANSPORT", | ||
162 | "PLUGINS", | ||
163 | &plugs)) | ||
164 | return; | ||
165 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | ||
166 | _("Starting transport plugins `%s'\n"), | ||
167 | plugs); | ||
168 | for (pos = strtok(plugs, " "); pos != NULL; pos = strtok(NULL, " ")) | ||
300 | { | 169 | { |
301 | fail = GNUNET_YES; | 170 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
302 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 171 | _("Loading `%s' transport plugin\n"), |
303 | _("Missing function `%s' in transport plugin for `%s'\n"), | 172 | pos); |
304 | "update_session_timeout", | 173 | GNUNET_asprintf(&libname, |
305 | plug->lib_name); | 174 | "libgnunet_plugin_transport_%s", |
175 | pos); | ||
176 | plug = GNUNET_new(struct TransportPlugin); | ||
177 | plug->short_name = GNUNET_strdup(pos); | ||
178 | plug->lib_name = libname; | ||
179 | plug->env.cfg = GST_cfg; | ||
180 | plug->env.my_identity = &GST_my_identity; | ||
181 | plug->env.get_our_hello = &GST_hello_get; | ||
182 | plug->env.cls = plug->short_name; | ||
183 | plug->env.receive = recv_cb; | ||
184 | plug->env.notify_address = address_cb; | ||
185 | plug->env.session_start = session_start_cb; | ||
186 | plug->env.session_end = session_end_cb; | ||
187 | plug->env.get_address_type = &plugin_env_address_to_type; | ||
188 | plug->env.update_address_distance = &plugin_env_update_distance; | ||
189 | plug->env.max_connections = tneigh; | ||
190 | plug->env.stats = GST_stats; | ||
191 | GNUNET_CONTAINER_DLL_insert(plugins_head, | ||
192 | plugins_tail, | ||
193 | plug); | ||
306 | } | 194 | } |
307 | if (GNUNET_YES == fail) | 195 | GNUNET_free(plugs); |
196 | next = plugins_head; | ||
197 | while (NULL != next) | ||
308 | { | 198 | { |
309 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 199 | plug = next; |
310 | _("Did not load plugin `%s' due to missing functions\n"), | 200 | next = plug->next; |
311 | plug->lib_name); | 201 | plug->api = GNUNET_PLUGIN_load(plug->lib_name, |
312 | GNUNET_break (NULL == GNUNET_PLUGIN_unload (plug->lib_name, plug->api)); | 202 | &plug->env); |
313 | GNUNET_CONTAINER_DLL_remove (plugins_head, | 203 | if (NULL == plug->api) |
314 | plugins_tail, | 204 | { |
315 | plug); | 205 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
316 | GNUNET_free (plug->short_name); | 206 | _("Failed to load transport plugin for `%s'\n"), |
317 | GNUNET_free (plug->lib_name); | 207 | plug->lib_name); |
318 | GNUNET_free (plug); | 208 | GNUNET_CONTAINER_DLL_remove(plugins_head, |
209 | plugins_tail, | ||
210 | plug); | ||
211 | GNUNET_free(plug->short_name); | ||
212 | GNUNET_free(plug->lib_name); | ||
213 | GNUNET_free(plug); | ||
214 | continue; | ||
215 | } | ||
216 | fail = GNUNET_NO; | ||
217 | if (NULL == plug->api->address_pretty_printer) | ||
218 | { | ||
219 | fail = GNUNET_YES; | ||
220 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | ||
221 | _("Missing function `%s' in transport plugin for `%s'\n"), | ||
222 | "address_pretty_printer", | ||
223 | plug->lib_name); | ||
224 | } | ||
225 | if (NULL == plug->api->address_to_string) | ||
226 | { | ||
227 | fail = GNUNET_YES; | ||
228 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | ||
229 | _("Missing function `%s' in transport plugin for `%s'\n"), | ||
230 | "address_to_string", | ||
231 | plug->lib_name); | ||
232 | } | ||
233 | if (NULL == plug->api->string_to_address) | ||
234 | { | ||
235 | fail = GNUNET_YES; | ||
236 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | ||
237 | _("Missing function `%s' in transport plugin for `%s'\n"), | ||
238 | "string_to_address", | ||
239 | plug->lib_name); | ||
240 | } | ||
241 | if (NULL == plug->api->check_address) | ||
242 | { | ||
243 | fail = GNUNET_YES; | ||
244 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | ||
245 | _("Missing function `%s' in transport plugin for `%s'\n"), | ||
246 | "check_address", | ||
247 | plug->lib_name); | ||
248 | } | ||
249 | if (NULL == plug->api->get_session) | ||
250 | { | ||
251 | fail = GNUNET_YES; | ||
252 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | ||
253 | _("Missing function `%s' in transport plugin for `%s'\n"), | ||
254 | "get_session", | ||
255 | plug->lib_name); | ||
256 | } | ||
257 | if (NULL == plug->api->get_network) | ||
258 | { | ||
259 | fail = GNUNET_YES; | ||
260 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | ||
261 | _("Missing function `%s' in transport plugin for `%s'\n"), | ||
262 | "get_network", | ||
263 | plug->lib_name); | ||
264 | } | ||
265 | if (NULL == plug->api->send) | ||
266 | { | ||
267 | fail = GNUNET_YES; | ||
268 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | ||
269 | _("Missing function `%s' in transport plugin for `%s'\n"), | ||
270 | "send", | ||
271 | plug->lib_name); | ||
272 | } | ||
273 | if (NULL == plug->api->disconnect_peer) | ||
274 | { | ||
275 | fail = GNUNET_YES; | ||
276 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | ||
277 | _("Missing function `%s' in transport plugin for `%s'\n"), | ||
278 | "disconnect_peer", | ||
279 | plug->lib_name); | ||
280 | } | ||
281 | if (NULL == plug->api->disconnect_session) | ||
282 | { | ||
283 | fail = GNUNET_YES; | ||
284 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | ||
285 | _("Missing function `%s' in transport plugin for `%s'\n"), | ||
286 | "disconnect_session", | ||
287 | plug->lib_name); | ||
288 | } | ||
289 | if (NULL == plug->api->query_keepalive_factor) | ||
290 | { | ||
291 | fail = GNUNET_YES; | ||
292 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | ||
293 | _("Missing function `%s' in transport plugin for `%s'\n"), | ||
294 | "query_keepalive_factor", | ||
295 | plug->lib_name); | ||
296 | } | ||
297 | if (NULL == plug->api->update_session_timeout) | ||
298 | { | ||
299 | fail = GNUNET_YES; | ||
300 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | ||
301 | _("Missing function `%s' in transport plugin for `%s'\n"), | ||
302 | "update_session_timeout", | ||
303 | plug->lib_name); | ||
304 | } | ||
305 | if (GNUNET_YES == fail) | ||
306 | { | ||
307 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | ||
308 | _("Did not load plugin `%s' due to missing functions\n"), | ||
309 | plug->lib_name); | ||
310 | GNUNET_break(NULL == GNUNET_PLUGIN_unload(plug->lib_name, plug->api)); | ||
311 | GNUNET_CONTAINER_DLL_remove(plugins_head, | ||
312 | plugins_tail, | ||
313 | plug); | ||
314 | GNUNET_free(plug->short_name); | ||
315 | GNUNET_free(plug->lib_name); | ||
316 | GNUNET_free(plug); | ||
317 | } | ||
319 | } | 318 | } |
320 | } | ||
321 | } | 319 | } |
322 | 320 | ||
323 | 321 | ||
@@ -325,18 +323,18 @@ GST_plugins_load (GNUNET_TRANSPORT_PluginReceiveCallback recv_cb, | |||
325 | * Unload all plugins | 323 | * Unload all plugins |
326 | */ | 324 | */ |
327 | void | 325 | void |
328 | GST_plugins_unload () | 326 | GST_plugins_unload() |
329 | { | 327 | { |
330 | struct TransportPlugin *plug; | 328 | struct TransportPlugin *plug; |
331 | 329 | ||
332 | while (NULL != (plug = plugins_head)) | 330 | while (NULL != (plug = plugins_head)) |
333 | { | 331 | { |
334 | GNUNET_break (NULL == GNUNET_PLUGIN_unload (plug->lib_name, plug->api)); | 332 | GNUNET_break(NULL == GNUNET_PLUGIN_unload(plug->lib_name, plug->api)); |
335 | GNUNET_free (plug->lib_name); | 333 | GNUNET_free(plug->lib_name); |
336 | GNUNET_free (plug->short_name); | 334 | GNUNET_free(plug->short_name); |
337 | GNUNET_CONTAINER_DLL_remove (plugins_head, plugins_tail, plug); | 335 | GNUNET_CONTAINER_DLL_remove(plugins_head, plugins_tail, plug); |
338 | GNUNET_free (plug); | 336 | GNUNET_free(plug); |
339 | } | 337 | } |
340 | } | 338 | } |
341 | 339 | ||
342 | 340 | ||
@@ -347,12 +345,12 @@ GST_plugins_unload () | |||
347 | * @return the plugin's API, NULL if the plugin is not loaded | 345 | * @return the plugin's API, NULL if the plugin is not loaded |
348 | */ | 346 | */ |
349 | struct GNUNET_TRANSPORT_PluginFunctions * | 347 | struct GNUNET_TRANSPORT_PluginFunctions * |
350 | GST_plugins_find (const char *name) | 348 | GST_plugins_find(const char *name) |
351 | { | 349 | { |
352 | struct TransportPlugin *pos; | 350 | struct TransportPlugin *pos; |
353 | 351 | ||
354 | for (pos = plugins_head; NULL != pos; pos = pos->next) | 352 | for (pos = plugins_head; NULL != pos; pos = pos->next) |
355 | if (0 == strcmp (name, pos->short_name)) | 353 | if (0 == strcmp(name, pos->short_name)) |
356 | break; | 354 | break; |
357 | if (NULL == pos) | 355 | if (NULL == pos) |
358 | return NULL; | 356 | return NULL; |
@@ -371,18 +369,18 @@ GST_plugins_find (const char *name) | |||
371 | * @return the plugin's API, NULL if the plugin is not loaded | 369 | * @return the plugin's API, NULL if the plugin is not loaded |
372 | */ | 370 | */ |
373 | struct GNUNET_TRANSPORT_PluginFunctions * | 371 | struct GNUNET_TRANSPORT_PluginFunctions * |
374 | GST_plugins_printer_find (const char *name) | 372 | GST_plugins_printer_find(const char *name) |
375 | { | 373 | { |
376 | struct TransportPlugin *pos; | 374 | struct TransportPlugin *pos; |
377 | char *stripped = GNUNET_strdup (name); | 375 | char *stripped = GNUNET_strdup(name); |
378 | char *sep = strchr (stripped, '_'); | 376 | char *sep = strchr(stripped, '_'); |
379 | 377 | ||
380 | if (NULL != sep) | 378 | if (NULL != sep) |
381 | sep[0] = '\0'; | 379 | sep[0] = '\0'; |
382 | for (pos = plugins_head; NULL != pos; pos = pos->next) | 380 | for (pos = plugins_head; NULL != pos; pos = pos->next) |
383 | if (pos->short_name == strstr (pos->short_name, stripped)) | 381 | if (pos->short_name == strstr(pos->short_name, stripped)) |
384 | break; | 382 | break; |
385 | GNUNET_free (stripped); | 383 | GNUNET_free(stripped); |
386 | if (NULL == pos) | 384 | if (NULL == pos) |
387 | return NULL; | 385 | return NULL; |
388 | return pos->api; | 386 | return pos->api; |
@@ -397,7 +395,7 @@ GST_plugins_printer_find (const char *name) | |||
397 | * @return statically allocated (!) human-readable address | 395 | * @return statically allocated (!) human-readable address |
398 | */ | 396 | */ |
399 | const char * | 397 | const char * |
400 | GST_plugins_a2s (const struct GNUNET_HELLO_Address *address) | 398 | GST_plugins_a2s(const struct GNUNET_HELLO_Address *address) |
401 | { | 399 | { |
402 | struct GNUNET_TRANSPORT_PluginFunctions *api; | 400 | struct GNUNET_TRANSPORT_PluginFunctions *api; |
403 | static char unable_to_show[1024]; | 401 | static char unable_to_show[1024]; |
@@ -407,28 +405,28 @@ GST_plugins_a2s (const struct GNUNET_HELLO_Address *address) | |||
407 | return "<NULL>"; | 405 | return "<NULL>"; |
408 | if (0 == address->address_length) | 406 | if (0 == address->address_length) |
409 | return TRANSPORT_SESSION_INBOUND_STRING; /* Addresse with length 0 are inbound, address->address itself may be NULL */ | 407 | return TRANSPORT_SESSION_INBOUND_STRING; /* Addresse with length 0 are inbound, address->address itself may be NULL */ |
410 | api = GST_plugins_printer_find (address->transport_name); | 408 | api = GST_plugins_printer_find(address->transport_name); |
411 | if (NULL == api) | 409 | if (NULL == api) |
412 | { | 410 | { |
413 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 411 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
414 | "Failed to find transport plugin `%s'\n", | 412 | "Failed to find transport plugin `%s'\n", |
415 | address->transport_name); | 413 | address->transport_name); |
416 | return "<plugin unknown>"; | 414 | return "<plugin unknown>"; |
417 | } | 415 | } |
418 | if (0 == address->address_length) | 416 | if (0 == address->address_length) |
419 | { | 417 | { |
420 | GNUNET_snprintf (unable_to_show, | 418 | GNUNET_snprintf(unable_to_show, |
421 | sizeof (unable_to_show), | 419 | sizeof(unable_to_show), |
422 | "<unable to stringify %u-byte long address of %s transport>", | 420 | "<unable to stringify %u-byte long address of %s transport>", |
423 | (unsigned int) address->address_length, | 421 | (unsigned int)address->address_length, |
424 | address->transport_name); | 422 | address->transport_name); |
425 | return unable_to_show; | 423 | return unable_to_show; |
426 | } | 424 | } |
427 | return (NULL != (s = api->address_to_string (NULL, | 425 | return(NULL != (s = api->address_to_string(NULL, |
428 | address->address, | 426 | address->address, |
429 | address->address_length)) | 427 | address->address_length)) |
430 | ? s | 428 | ? s |
431 | : "<invalid>"); | 429 | : "<invalid>"); |
432 | } | 430 | } |
433 | 431 | ||
434 | 432 | ||
@@ -439,18 +437,18 @@ GST_plugins_a2s (const struct GNUNET_HELLO_Address *address) | |||
439 | * @param cb_cls closure for @a cb | 437 | * @param cb_cls closure for @a cb |
440 | */ | 438 | */ |
441 | void | 439 | void |
442 | GST_plugins_monitor_subscribe (GNUNET_TRANSPORT_SessionInfoCallback cb, | 440 | GST_plugins_monitor_subscribe(GNUNET_TRANSPORT_SessionInfoCallback cb, |
443 | void *cb_cls) | 441 | void *cb_cls) |
444 | { | 442 | { |
445 | struct TransportPlugin *pos; | 443 | struct TransportPlugin *pos; |
446 | 444 | ||
447 | for (pos = plugins_head; NULL != pos; pos = pos->next) | 445 | for (pos = plugins_head; NULL != pos; pos = pos->next) |
448 | if (NULL == pos->api->setup_monitor) | 446 | if (NULL == pos->api->setup_monitor) |
449 | GNUNET_break (0); | 447 | GNUNET_break(0); |
450 | else | 448 | else |
451 | pos->api->setup_monitor (pos->api->cls, | 449 | pos->api->setup_monitor(pos->api->cls, |
452 | cb, | 450 | cb, |
453 | cb_cls); | 451 | cb_cls); |
454 | } | 452 | } |
455 | 453 | ||
456 | 454 | ||