aboutsummaryrefslogtreecommitdiff
path: root/src/transport/gnunet-service-transport_plugins.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2014-10-23 10:59:15 +0000
committerChristian Grothoff <christian@grothoff.org>2014-10-23 10:59:15 +0000
commit1a45b968a48a82e57696ce618e1e77141b738182 (patch)
treec42bbd986f0df598621d88859362082549ce4fde /src/transport/gnunet-service-transport_plugins.c
parent1aa2d5f160da455dd68c3d8be6f6e9ebf5b46d98 (diff)
downloadgnunet-1a45b968a48a82e57696ce618e1e77141b738182.tar.gz
gnunet-1a45b968a48a82e57696ce618e1e77141b738182.zip
implementing monitoring functionality in transport service
Diffstat (limited to 'src/transport/gnunet-service-transport_plugins.c')
-rw-r--r--src/transport/gnunet-service-transport_plugins.c86
1 files changed, 52 insertions, 34 deletions
diff --git a/src/transport/gnunet-service-transport_plugins.c b/src/transport/gnunet-service-transport_plugins.c
index 846461a4c..e43b7057a 100644
--- a/src/transport/gnunet-service-transport_plugins.c
+++ b/src/transport/gnunet-service-transport_plugins.c
@@ -1,21 +1,21 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2010,2011 Christian Grothoff (and other contributing authors) 3 (C) 2010-2014 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 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 6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your 7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version. 8 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 General Public License for more details. 13 General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 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 16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/** 21/**
@@ -302,13 +302,14 @@ GST_plugins_unload ()
302struct GNUNET_TRANSPORT_PluginFunctions * 302struct GNUNET_TRANSPORT_PluginFunctions *
303GST_plugins_find (const char *name) 303GST_plugins_find (const char *name)
304{ 304{
305 struct TransportPlugin *head = plugins_head; 305 struct TransportPlugin *pos;
306 306
307 while ((head != NULL) && (0 != strcmp (name, head->short_name))) 307 for (pos = plugins_head; NULL != pos; pos = pos->next)
308 head = head->next; 308 if (0 == strcmp (name, pos->short_name))
309 if (NULL == head) 309 break;
310 if (NULL == pos)
310 return NULL; 311 return NULL;
311 return head->api; 312 return pos->api;
312} 313}
313 314
314 315
@@ -325,23 +326,19 @@ GST_plugins_find (const char *name)
325struct GNUNET_TRANSPORT_PluginFunctions * 326struct GNUNET_TRANSPORT_PluginFunctions *
326GST_plugins_printer_find (const char *name) 327GST_plugins_printer_find (const char *name)
327{ 328{
328 struct TransportPlugin *head = plugins_head; 329 struct TransportPlugin *pos;
329
330 char *stripped = GNUNET_strdup (name); 330 char *stripped = GNUNET_strdup (name);
331 char *sep = strchr (stripped, '_'); 331 char *sep = strchr (stripped, '_');
332
332 if (NULL != sep) 333 if (NULL != sep)
333 sep[0] = '\0'; 334 sep[0] = '\0';
334 335 for (pos = plugins_head; NULL != pos; pos = pos->next)
335 while (head != NULL) 336 if (pos->short_name == strstr (pos->short_name, stripped))
336 {
337 if (head->short_name == strstr (head->short_name, stripped))
338 break; 337 break;
339 head = head->next;
340 }
341 GNUNET_free (stripped); 338 GNUNET_free (stripped);
342 if (NULL == head) 339 if (NULL == pos)
343 return NULL; 340 return NULL;
344 return head->api; 341 return pos->api;
345} 342}
346 343
347 344
@@ -359,9 +356,9 @@ GST_plugins_a2s (const struct GNUNET_HELLO_Address *address)
359 static char unable_to_show[1024]; 356 static char unable_to_show[1024];
360 static const char *s; 357 static const char *s;
361 358
362 if (address == NULL) 359 if (NULL == address)
363 { 360 {
364 GNUNET_break (0); /* a HELLO address cannot be NULL */ 361 GNUNET_break (0); /* a HELLO address cannot be NULL */
365 return "<invalid>"; 362 return "<invalid>";
366 } 363 }
367 if (0 == address->address_length) 364 if (0 == address->address_length)
@@ -382,4 +379,25 @@ GST_plugins_a2s (const struct GNUNET_HELLO_Address *address)
382} 379}
383 380
384 381
382/**
383 * Register callback with all plugins to monitor their status.
384 *
385 * @param cb callback to register, NULL to unsubscribe
386 * @param cb_cls closure for @a cb
387 */
388void
389GST_plugins_monitor_subscribe (GNUNET_TRANSPORT_SessionInfoCallback cb,
390 void *cb_cls)
391{
392 struct TransportPlugin *pos;
393
394 for (pos = plugins_head; NULL != pos; pos = pos->next)
395 if (NULL == pos->api->setup_monitor)
396 GNUNET_break (0);
397 else
398 pos->api->setup_monitor (pos->api->cls,
399 cb, cb_cls);
400}
401
402
385/* end of file gnunet-service-transport_plugins.c */ 403/* end of file gnunet-service-transport_plugins.c */