aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--contrib/Makefile.am2
-rw-r--r--doc/man/gnunet-statistics.17
-rw-r--r--src/arm/gnunet-service-arm.c148
-rw-r--r--src/dns/gnunet-service-dns.c17
-rw-r--r--src/gns/gns.conf.in2
-rw-r--r--src/gns/gnunet-gns-proxy.c38
-rw-r--r--src/gns/gnunet-service-gns_resolver.c4
-rw-r--r--src/psyc/Makefile.am14
-rw-r--r--src/statistics/gnunet-statistics.c514
9 files changed, 629 insertions, 117 deletions
diff --git a/contrib/Makefile.am b/contrib/Makefile.am
index 1e348233d..158e43998 100644
--- a/contrib/Makefile.am
+++ b/contrib/Makefile.am
@@ -87,8 +87,6 @@ do_subst = $(SED) -e 's,[@]PYTHON[@],$(PYTHON),g'
87# chmod +x $@ 87# chmod +x $@
88# 88#
89# instead of this: 89# instead of this:
90
91SUFFIXES =
92SUFFIXES = .py.in .py 90SUFFIXES = .py.in .py
93 91
94.py.in.py: 92.py.in.py:
diff --git a/doc/man/gnunet-statistics.1 b/doc/man/gnunet-statistics.1
index 36f445a09..2aa889382 100644
--- a/doc/man/gnunet-statistics.1
+++ b/doc/man/gnunet-statistics.1
@@ -41,6 +41,13 @@ non\-persistent.
41Statistics are kept for various subsystems. With this option, the 41Statistics are kept for various subsystems. With this option, the
42output can be restricted to a particular subsystem only. 42output can be restricted to a particular subsystem only.
43.B 43.B
44.IP "\-S SEPARATOR, \-\-csv-separator=SEPARATOR"
45Specify a separator for generating csv-output.
46.B
47.IP "\-t TESTBED_PATH, \-\-subsystem=TESTBED_PATH"
48When running testbed, you can get statistics of all peers with specefying the
49folder containing the data of all testbed nodes like \fBgnunet\-statistics -t /tmp/testbedARtmQv\fP.
50.B
44.IP "\-v, \-\-version" 51.IP "\-v, \-\-version"
45Print GNUnet version number. 52Print GNUnet version number.
46 53
diff --git a/src/arm/gnunet-service-arm.c b/src/arm/gnunet-service-arm.c
index 6924ca676..b56c9c0a8 100644
--- a/src/arm/gnunet-service-arm.c
+++ b/src/arm/gnunet-service-arm.c
@@ -346,11 +346,15 @@ get_server_addresses (const char *service_name,
346 *addrs = NULL; 346 *addrs = NULL;
347 *addr_lens = NULL; 347 *addr_lens = NULL;
348 desc = NULL; 348 desc = NULL;
349 if (GNUNET_CONFIGURATION_have_value (cfg, service_name, "DISABLEV6")) 349 if (GNUNET_CONFIGURATION_have_value (cfg,
350 service_name,
351 "DISABLEV6"))
350 { 352 {
351 if (GNUNET_SYSERR == 353 if (GNUNET_SYSERR ==
352 (disablev6 = 354 (disablev6 =
353 GNUNET_CONFIGURATION_get_value_yesno (cfg, service_name, "DISABLEV6"))) 355 GNUNET_CONFIGURATION_get_value_yesno (cfg,
356 service_name,
357 "DISABLEV6")))
354 return GNUNET_SYSERR; 358 return GNUNET_SYSERR;
355 } 359 }
356 else 360 else
@@ -359,18 +363,24 @@ get_server_addresses (const char *service_name,
359 if (! disablev6) 363 if (! disablev6)
360 { 364 {
361 /* probe IPv6 support */ 365 /* probe IPv6 support */
362 desc = GNUNET_NETWORK_socket_create (PF_INET6, SOCK_STREAM, 0); 366 desc = GNUNET_NETWORK_socket_create (PF_INET6,
367 SOCK_STREAM,
368 0);
363 if (NULL == desc) 369 if (NULL == desc)
364 { 370 {
365 if ((ENOBUFS == errno) || (ENOMEM == errno) || (ENFILE == errno) || 371 if ( (ENOBUFS == errno) ||
366 (EACCES == errno)) 372 (ENOMEM == errno) ||
373 (ENFILE == errno) ||
374 (EACCES == errno) )
367 { 375 {
368 LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "socket"); 376 LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR,
377 "socket");
369 return GNUNET_SYSERR; 378 return GNUNET_SYSERR;
370 } 379 }
371 LOG (GNUNET_ERROR_TYPE_INFO, 380 LOG (GNUNET_ERROR_TYPE_INFO,
372 _("Disabling IPv6 support for service `%s', failed to create IPv6 socket: %s\n"), 381 _("Disabling IPv6 support for service `%s', failed to create IPv6 socket: %s\n"),
373 service_name, STRERROR (errno)); 382 service_name,
383 STRERROR (errno));
374 disablev6 = GNUNET_YES; 384 disablev6 = GNUNET_YES;
375 } 385 }
376 else 386 else
@@ -381,11 +391,15 @@ get_server_addresses (const char *service_name,
381 } 391 }
382 392
383 port = 0; 393 port = 0;
384 if (GNUNET_CONFIGURATION_have_value (cfg, service_name, "PORT")) 394 if (GNUNET_CONFIGURATION_have_value (cfg,
395 service_name,
396 "PORT"))
385 { 397 {
386 if (GNUNET_OK != 398 if (GNUNET_OK !=
387 GNUNET_CONFIGURATION_get_value_number (cfg, service_name, 399 GNUNET_CONFIGURATION_get_value_number (cfg,
388 "PORT", &port)) 400 service_name,
401 "PORT",
402 &port))
389 { 403 {
390 LOG (GNUNET_ERROR_TYPE_ERROR, 404 LOG (GNUNET_ERROR_TYPE_ERROR,
391 _("Require valid port number for service `%s' in configuration!\n"), 405 _("Require valid port number for service `%s' in configuration!\n"),
@@ -400,11 +414,15 @@ get_server_addresses (const char *service_name,
400 } 414 }
401 } 415 }
402 416
403 if (GNUNET_CONFIGURATION_have_value (cfg, service_name, "BINDTO")) 417 if (GNUNET_CONFIGURATION_have_value (cfg,
418 service_name,
419 "BINDTO"))
404 { 420 {
405 GNUNET_break (GNUNET_OK == 421 GNUNET_break (GNUNET_OK ==
406 GNUNET_CONFIGURATION_get_value_string (cfg, service_name, 422 GNUNET_CONFIGURATION_get_value_string (cfg,
407 "BINDTO", &hostname)); 423 service_name,
424 "BINDTO",
425 &hostname));
408 } 426 }
409 else 427 else
410 hostname = NULL; 428 hostname = NULL;
@@ -413,10 +431,14 @@ get_server_addresses (const char *service_name,
413 abstract = GNUNET_NO; 431 abstract = GNUNET_NO;
414#ifdef AF_UNIX 432#ifdef AF_UNIX
415 if ((GNUNET_YES == 433 if ((GNUNET_YES ==
416 GNUNET_CONFIGURATION_have_value (cfg, service_name, "UNIXPATH")) && 434 GNUNET_CONFIGURATION_have_value (cfg,
435 service_name,
436 "UNIXPATH")) &&
417 (GNUNET_OK == 437 (GNUNET_OK ==
418 GNUNET_CONFIGURATION_get_value_filename (cfg, service_name, "UNIXPATH", 438 GNUNET_CONFIGURATION_get_value_filename (cfg,
419 &unixpath)) && 439 service_name,
440 "UNIXPATH",
441 &unixpath)) &&
420 (0 < strlen (unixpath))) 442 (0 < strlen (unixpath)))
421 { 443 {
422 /* probe UNIX support */ 444 /* probe UNIX support */
@@ -425,7 +447,8 @@ get_server_addresses (const char *service_name,
425 if (strlen (unixpath) >= sizeof (s_un.sun_path)) 447 if (strlen (unixpath) >= sizeof (s_un.sun_path))
426 { 448 {
427 LOG (GNUNET_ERROR_TYPE_WARNING, 449 LOG (GNUNET_ERROR_TYPE_WARNING,
428 _("UNIXPATH `%s' too long, maximum length is %llu\n"), unixpath, 450 _("UNIXPATH `%s' too long, maximum length is %llu\n"),
451 unixpath,
429 (unsigned long long) sizeof (s_un.sun_path)); 452 (unsigned long long) sizeof (s_un.sun_path));
430 unixpath = GNUNET_NETWORK_shorten_unixpath (unixpath); 453 unixpath = GNUNET_NETWORK_shorten_unixpath (unixpath);
431 LOG (GNUNET_ERROR_TYPE_INFO, 454 LOG (GNUNET_ERROR_TYPE_INFO,
@@ -439,9 +462,9 @@ get_server_addresses (const char *service_name,
439 if (GNUNET_SYSERR == abstract) 462 if (GNUNET_SYSERR == abstract)
440 abstract = GNUNET_NO; 463 abstract = GNUNET_NO;
441#endif 464#endif
442 if ((GNUNET_YES != abstract) 465 if ( (GNUNET_YES != abstract) &&
443 && (GNUNET_OK != 466 (GNUNET_OK !=
444 GNUNET_DISK_directory_create_for_file (unixpath))) 467 GNUNET_DISK_directory_create_for_file (unixpath)) )
445 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, 468 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
446 "mkdir", 469 "mkdir",
447 unixpath); 470 unixpath);
@@ -451,8 +474,10 @@ get_server_addresses (const char *service_name,
451 desc = GNUNET_NETWORK_socket_create (AF_UNIX, SOCK_STREAM, 0); 474 desc = GNUNET_NETWORK_socket_create (AF_UNIX, SOCK_STREAM, 0);
452 if (NULL == desc) 475 if (NULL == desc)
453 { 476 {
454 if ((ENOBUFS == errno) || (ENOMEM == errno) || (ENFILE == errno) || 477 if ( (ENOBUFS == errno) ||
455 (EACCES == errno)) 478 (ENOMEM == errno) ||
479 (ENFILE == errno) ||
480 (EACCES == errno) )
456 { 481 {
457 LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "socket"); 482 LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "socket");
458 GNUNET_free_non_null (hostname); 483 GNUNET_free_non_null (hostname);
@@ -474,19 +499,29 @@ get_server_addresses (const char *service_name,
474 } 499 }
475#endif 500#endif
476 501
477 if ((0 == port) && (NULL == unixpath)) 502 if ( (0 == port) &&
503 (NULL == unixpath) )
478 { 504 {
479 LOG (GNUNET_ERROR_TYPE_ERROR, 505 if (GNUNET_YES ==
480 _("Have neither PORT nor UNIXPATH for service `%s', but one is required\n"), 506 GNUNET_CONFIGURATION_get_value_yesno (cfg,
481 service_name); 507 service_name,
508 "AUTOSTART"))
509 LOG (GNUNET_ERROR_TYPE_ERROR,
510 _("Have neither PORT nor UNIXPATH for service `%s', but one is required\n"),
511 service_name);
482 GNUNET_free_non_null (hostname); 512 GNUNET_free_non_null (hostname);
483 return GNUNET_SYSERR; 513 return GNUNET_SYSERR;
484 } 514 }
485 if (0 == port) 515 if (0 == port)
486 { 516 {
487 saddrs = GNUNET_malloc (2 * sizeof (struct sockaddr *)); 517 saddrs = GNUNET_new_array (2,
488 saddrlens = GNUNET_malloc (2 * sizeof (socklen_t)); 518 struct sockaddr *);
489 add_unixpath (saddrs, saddrlens, unixpath, abstract); 519 saddrlens = GNUNET_new_array (2,
520 socklen_t);
521 add_unixpath (saddrs,
522 saddrlens,
523 unixpath,
524 abstract);
490 GNUNET_free_non_null (unixpath); 525 GNUNET_free_non_null (unixpath);
491 GNUNET_free_non_null (hostname); 526 GNUNET_free_non_null (hostname);
492 *addrs = saddrs; 527 *addrs = saddrs;
@@ -504,7 +539,10 @@ get_server_addresses (const char *service_name,
504 if (disablev6) 539 if (disablev6)
505 hints.ai_family = AF_INET; 540 hints.ai_family = AF_INET;
506 hints.ai_protocol = IPPROTO_TCP; 541 hints.ai_protocol = IPPROTO_TCP;
507 if ((0 != (ret = getaddrinfo (hostname, NULL, &hints, &res))) || 542 if ((0 != (ret = getaddrinfo (hostname,
543 NULL,
544 &hints,
545 &res))) ||
508 (NULL == res)) 546 (NULL == res))
509 { 547 {
510 LOG (GNUNET_ERROR_TYPE_ERROR, 548 LOG (GNUNET_ERROR_TYPE_ERROR,
@@ -538,8 +576,10 @@ get_server_addresses (const char *service_name,
538 resi = i; 576 resi = i;
539 if (NULL != unixpath) 577 if (NULL != unixpath)
540 resi++; 578 resi++;
541 saddrs = GNUNET_malloc ((resi + 1) * sizeof (struct sockaddr *)); 579 saddrs = GNUNET_new_array (resi + 1,
542 saddrlens = GNUNET_malloc ((resi + 1) * sizeof (socklen_t)); 580 struct sockaddr *);
581 saddrlens = GNUNET_new_array (resi + 1,
582 socklen_t);
543 i = 0; 583 i = 0;
544 if (NULL != unixpath) 584 if (NULL != unixpath)
545 { 585 {
@@ -591,8 +631,10 @@ get_server_addresses (const char *service_name,
591 if (NULL != unixpath) 631 if (NULL != unixpath)
592 resi++; 632 resi++;
593 i = 0; 633 i = 0;
594 saddrs = GNUNET_malloc ((resi + 1) * sizeof (struct sockaddr *)); 634 saddrs = GNUNET_new_array (resi + 1,
595 saddrlens = GNUNET_malloc ((resi + 1) * sizeof (socklen_t)); 635 struct sockaddr *);
636 saddrlens = GNUNET_new_array (resi + 1,
637 socklen_t);
596 if (NULL != unixpath) 638 if (NULL != unixpath)
597 { 639 {
598 add_unixpath (saddrs, saddrlens, unixpath, abstract); 640 add_unixpath (saddrs, saddrlens, unixpath, abstract);
@@ -612,12 +654,17 @@ get_server_addresses (const char *service_name,
612 resi = 2; 654 resi = 2;
613 if (NULL != unixpath) 655 if (NULL != unixpath)
614 resi++; 656 resi++;
615 saddrs = GNUNET_malloc ((resi + 1) * sizeof (struct sockaddr *)); 657 saddrs = GNUNET_new_array (resi + 1,
616 saddrlens = GNUNET_malloc ((resi + 1) * sizeof (socklen_t)); 658 struct sockaddr *);
659 saddrlens = GNUNET_new_array (resi + 1,
660 socklen_t);
617 i = 0; 661 i = 0;
618 if (NULL != unixpath) 662 if (NULL != unixpath)
619 { 663 {
620 add_unixpath (saddrs, saddrlens, unixpath, abstract); 664 add_unixpath (saddrs,
665 saddrlens,
666 unixpath,
667 abstract);
621 i++; 668 i++;
622 } 669 }
623 saddrlens[i] = sizeof (struct sockaddr_in6); 670 saddrlens[i] = sizeof (struct sockaddr_in6);
@@ -663,6 +710,7 @@ signal_result (struct GNUNET_SERVICE_Client *client,
663 struct GNUNET_MQ_Envelope *env; 710 struct GNUNET_MQ_Envelope *env;
664 struct GNUNET_ARM_ResultMessage *msg; 711 struct GNUNET_ARM_ResultMessage *msg;
665 712
713 (void) name;
666 env = GNUNET_MQ_msg (msg, 714 env = GNUNET_MQ_msg (msg,
667 GNUNET_MESSAGE_TYPE_ARM_RESULT); 715 GNUNET_MESSAGE_TYPE_ARM_RESULT);
668 msg->result = htonl (result); 716 msg->result = htonl (result);
@@ -1184,6 +1232,7 @@ check_start (void *cls,
1184 uint16_t size; 1232 uint16_t size;
1185 const char *servicename; 1233 const char *servicename;
1186 1234
1235 (void) cls;
1187 size = ntohs (amsg->header.size) - sizeof (struct GNUNET_ARM_Message); 1236 size = ntohs (amsg->header.size) - sizeof (struct GNUNET_ARM_Message);
1188 servicename = (const char *) &amsg[1]; 1237 servicename = (const char *) &amsg[1];
1189 if ( (0 == size) || 1238 if ( (0 == size) ||
@@ -1254,6 +1303,7 @@ handle_start (void *cls,
1254static void 1303static void
1255trigger_shutdown (void *cls) 1304trigger_shutdown (void *cls)
1256{ 1305{
1306 (void) cls;
1257 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1307 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1258 "Triggering shutdown\n"); 1308 "Triggering shutdown\n");
1259 GNUNET_SCHEDULER_shutdown (); 1309 GNUNET_SCHEDULER_shutdown ();
@@ -1275,6 +1325,7 @@ check_stop (void *cls,
1275 uint16_t size; 1325 uint16_t size;
1276 const char *servicename; 1326 const char *servicename;
1277 1327
1328 (void) cls;
1278 size = ntohs (amsg->header.size) - sizeof (struct GNUNET_ARM_Message); 1329 size = ntohs (amsg->header.size) - sizeof (struct GNUNET_ARM_Message);
1279 servicename = (const char *) &amsg[1]; 1330 servicename = (const char *) &amsg[1];
1280 if ( (0 == size) || 1331 if ( (0 == size) ||
@@ -1451,6 +1502,7 @@ handle_test (void *cls,
1451 struct GNUNET_MQ_Envelope *env; 1502 struct GNUNET_MQ_Envelope *env;
1452 struct GNUNET_MessageHeader *msg; 1503 struct GNUNET_MessageHeader *msg;
1453 1504
1505 (void) message;
1454 env = GNUNET_MQ_msg (msg, 1506 env = GNUNET_MQ_msg (msg,
1455 GNUNET_MESSAGE_TYPE_ARM_TEST); 1507 GNUNET_MESSAGE_TYPE_ARM_TEST);
1456 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), 1508 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client),
@@ -1498,7 +1550,7 @@ list_count (struct ServiceList *running_head)
1498 struct ServiceList *i; 1550 struct ServiceList *i;
1499 unsigned int res; 1551 unsigned int res;
1500 1552
1501 for (res = 0, i = running_head; i; i = i->next, res++) 1553 for (res = 0, i = running_head; NULL != i; i = i->next, res++)
1502 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1554 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1503 "%s\n", 1555 "%s\n",
1504 i->name); 1556 i->name);
@@ -1518,6 +1570,7 @@ shutdown_task (void *cls)
1518 struct ServiceList *nxt; 1570 struct ServiceList *nxt;
1519 struct ServiceListeningInfo *sli; 1571 struct ServiceListeningInfo *sli;
1520 1572
1573 (void) cls;
1521 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1574 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1522 "First shutdown phase\n"); 1575 "First shutdown phase\n");
1523 if (NULL != child_restart_task) 1576 if (NULL != child_restart_task)
@@ -1589,6 +1642,7 @@ delayed_restart_task (void *cls)
1589 struct GNUNET_TIME_Relative lowestRestartDelay; 1642 struct GNUNET_TIME_Relative lowestRestartDelay;
1590 struct ServiceListeningInfo *sli; 1643 struct ServiceListeningInfo *sli;
1591 1644
1645 (void) cls;
1592 child_restart_task = NULL; 1646 child_restart_task = NULL;
1593 GNUNET_assert (GNUNET_NO == in_shutdown); 1647 GNUNET_assert (GNUNET_NO == in_shutdown);
1594 lowestRestartDelay = GNUNET_TIME_UNIT_FOREVER_REL; 1648 lowestRestartDelay = GNUNET_TIME_UNIT_FOREVER_REL;
@@ -1656,7 +1710,7 @@ delayed_restart_task (void *cls)
1656 * Task triggered whenever we receive a SIGCHLD (child 1710 * Task triggered whenever we receive a SIGCHLD (child
1657 * process died). 1711 * process died).
1658 * 1712 *
1659 * @param cls closure, NULL if we need to self-restart 1713 * @param cls closure, NULL
1660 */ 1714 */
1661static void 1715static void
1662maint_child_death (void *cls) 1716maint_child_death (void *cls)
@@ -1672,6 +1726,7 @@ maint_child_death (void *cls)
1672 unsigned long statusCode; 1726 unsigned long statusCode;
1673 const struct GNUNET_DISK_FileHandle *pr; 1727 const struct GNUNET_DISK_FileHandle *pr;
1674 1728
1729 (void) cls;
1675 pr = GNUNET_DISK_pipe_handle (sigpipe, 1730 pr = GNUNET_DISK_pipe_handle (sigpipe,
1676 GNUNET_DISK_PIPE_END_READ); 1731 GNUNET_DISK_PIPE_END_READ);
1677 child_death_task = NULL; 1732 child_death_task = NULL;
@@ -1914,6 +1969,7 @@ setup_service (void *cls,
1914 socklen_t *addr_lens; 1969 socklen_t *addr_lens;
1915 int ret; 1970 int ret;
1916 1971
1972 (void) cls;
1917 if (0 == strcasecmp (section, 1973 if (0 == strcasecmp (section,
1918 "arm")) 1974 "arm"))
1919 return; 1975 return;
@@ -2024,7 +2080,7 @@ setup_service (void *cls,
2024 &addr_lens))) 2080 &addr_lens)))
2025 return; 2081 return;
2026 /* this will free (or capture) addrs[i] */ 2082 /* this will free (or capture) addrs[i] */
2027 for (unsigned int i = 0; i < ret; i++) 2083 for (unsigned int i = 0; i < (unsigned int) ret; i++)
2028 create_listen_socket (addrs[i], 2084 create_listen_socket (addrs[i],
2029 addr_lens[i], 2085 addr_lens[i],
2030 sl); 2086 sl);
@@ -2049,6 +2105,8 @@ client_connect_cb (void *cls,
2049 /* All clients are considered to be of the "monitor" kind 2105 /* All clients are considered to be of the "monitor" kind
2050 * (that is, they don't affect ARM shutdown). 2106 * (that is, they don't affect ARM shutdown).
2051 */ 2107 */
2108 (void) cls;
2109 (void) mq;
2052 GNUNET_SERVICE_client_mark_monitor (client); 2110 GNUNET_SERVICE_client_mark_monitor (client);
2053 return client; 2111 return client;
2054} 2112}
@@ -2066,11 +2124,9 @@ client_disconnect_cb (void *cls,
2066 struct GNUNET_SERVICE_Client *client, 2124 struct GNUNET_SERVICE_Client *client,
2067 void *app_ctx) 2125 void *app_ctx)
2068{ 2126{
2069 struct ServiceList *sl; 2127 (void) cls;
2070
2071 GNUNET_assert (client == app_ctx); 2128 GNUNET_assert (client == app_ctx);
2072 2129 for (struct ServiceList *sl = running_head; NULL != sl; sl = sl->next)
2073 for (sl = running_head; NULL != sl; sl = sl->next)
2074 if (sl->killing_client == client) 2130 if (sl->killing_client == client)
2075 sl->killing_client = NULL; 2131 sl->killing_client = NULL;
2076} 2132}
@@ -2090,6 +2146,7 @@ handle_monitor (void *cls,
2090{ 2146{
2091 struct GNUNET_SERVICE_Client *client = cls; 2147 struct GNUNET_SERVICE_Client *client = cls;
2092 2148
2149 (void) message;
2093 /* FIXME: might want to start by letting monitor know about 2150 /* FIXME: might want to start by letting monitor know about
2094 services that are already running */ 2151 services that are already running */
2095 /* Removal is handled by the server implementation, internally. */ 2152 /* Removal is handled by the server implementation, internally. */
@@ -2105,7 +2162,7 @@ handle_monitor (void *cls,
2105/** 2162/**
2106 * Process arm requests. 2163 * Process arm requests.
2107 * 2164 *
2108 * @param cls closure 2165 * @param cls closure, NULL
2109 * @param serv the initialized service 2166 * @param serv the initialized service
2110 * @param c configuration to use 2167 * @param c configuration to use
2111 */ 2168 */
@@ -2116,6 +2173,7 @@ run (void *cls,
2116{ 2173{
2117 struct ServiceList *sl; 2174 struct ServiceList *sl;
2118 2175
2176 (void) cls;
2119 cfg = c; 2177 cfg = c;
2120 service = serv; 2178 service = serv;
2121 GNUNET_SCHEDULER_add_shutdown (&shutdown_task, 2179 GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
diff --git a/src/dns/gnunet-service-dns.c b/src/dns/gnunet-service-dns.c
index c191f0531..6b75fd0f4 100644
--- a/src/dns/gnunet-service-dns.c
+++ b/src/dns/gnunet-service-dns.c
@@ -1097,7 +1097,10 @@ run (void *cls,
1097 1097
1098 helper_argv[0] = GNUNET_strdup ("gnunet-dns"); 1098 helper_argv[0] = GNUNET_strdup ("gnunet-dns");
1099 if (GNUNET_SYSERR == 1099 if (GNUNET_SYSERR ==
1100 GNUNET_CONFIGURATION_get_value_string (cfg, "dns", "IFNAME", &ifc_name)) 1100 GNUNET_CONFIGURATION_get_value_string (cfg,
1101 "dns",
1102 "IFNAME",
1103 &ifc_name))
1101 { 1104 {
1102 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1105 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1103 "No entry 'IFNAME' in configuration!\n"); 1106 "No entry 'IFNAME' in configuration!\n");
@@ -1106,7 +1109,9 @@ run (void *cls,
1106 } 1109 }
1107 helper_argv[1] = ifc_name; 1110 helper_argv[1] = ifc_name;
1108 if ( (GNUNET_SYSERR == 1111 if ( (GNUNET_SYSERR ==
1109 GNUNET_CONFIGURATION_get_value_string (cfg, "dns", "IPV6ADDR", 1112 GNUNET_CONFIGURATION_get_value_string (cfg,
1113 "dns",
1114 "IPV6ADDR",
1110 &ipv6addr)) ) 1115 &ipv6addr)) )
1111 { 1116 {
1112 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1117 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -1116,7 +1121,9 @@ run (void *cls,
1116 } 1121 }
1117 helper_argv[2] = ipv6addr; 1122 helper_argv[2] = ipv6addr;
1118 if (GNUNET_SYSERR == 1123 if (GNUNET_SYSERR ==
1119 GNUNET_CONFIGURATION_get_value_string (cfg, "dns", "IPV6PREFIX", 1124 GNUNET_CONFIGURATION_get_value_string (cfg,
1125 "dns",
1126 "IPV6PREFIX",
1120 &ipv6prefix)) 1127 &ipv6prefix))
1121 { 1128 {
1122 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1129 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -1127,7 +1134,9 @@ run (void *cls,
1127 helper_argv[3] = ipv6prefix; 1134 helper_argv[3] = ipv6prefix;
1128 1135
1129 if (GNUNET_SYSERR == 1136 if (GNUNET_SYSERR ==
1130 GNUNET_CONFIGURATION_get_value_string (cfg, "dns", "IPV4ADDR", 1137 GNUNET_CONFIGURATION_get_value_string (cfg,
1138 "dns",
1139 "IPV4ADDR",
1131 &ipv4addr)) 1140 &ipv4addr))
1132 { 1141 {
1133 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1142 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
diff --git a/src/gns/gns.conf.in b/src/gns/gns.conf.in
index f7682cda7..de50d1047 100644
--- a/src/gns/gns.conf.in
+++ b/src/gns/gns.conf.in
@@ -20,7 +20,7 @@ MAX_PARALLEL_BACKGROUND_QUERIES = 1000
20# we will ask gnunet-service-dns to pass DNS queries to us. Otherwise, 20# we will ask gnunet-service-dns to pass DNS queries to us. Otherwise,
21# we only answer GNS queries via the API (which itself may be 21# we only answer GNS queries via the API (which itself may be
22# called via NSS or other mechanisms). 22# called via NSS or other mechanisms).
23INTERCEPT_DNS = YES 23INTERCEPT_DNS = NO
24 24
25# PREFIX = valgrind --leak-check=full --track-origins=yes 25# PREFIX = valgrind --leak-check=full --track-origins=yes
26 26
diff --git a/src/gns/gnunet-gns-proxy.c b/src/gns/gnunet-gns-proxy.c
index 9a405c49b..9c3c78b76 100644
--- a/src/gns/gnunet-gns-proxy.c
+++ b/src/gns/gnunet-gns-proxy.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2012-2014 GNUnet e.V. 3 Copyright (C) 2012-2018 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
@@ -46,14 +46,6 @@
46#include "gns.h" 46#include "gns.h"
47 47
48 48
49/**
50 * FIXME: GnuTLS right now sometimes rejects valid certs, so as a
51 * VERY temporary workaround we just WARN the user instead of
52 * dropping the page. THIS SHOULD NOT BE USED IN PRODUCTION,
53 * set to 1 in production!!! FIXME!!!
54 */
55#define FIXED_CERT_VALIDATION_BUG 0
56
57 49
58/** 50/**
59 * Default Socks5 listen port. 51 * Default Socks5 listen port.
@@ -1079,10 +1071,8 @@ check_ssl_certificate (struct Socks5Request *s5r)
1079 certdn, 1071 certdn,
1080 name, 1072 name,
1081 rc); 1073 rc);
1082#if FIXED_CERT_VALIDATION_BUG
1083 gnutls_x509_crt_deinit (x509_cert); 1074 gnutls_x509_crt_deinit (x509_cert);
1084 return GNUNET_SYSERR; 1075 return GNUNET_SYSERR;
1085#endif
1086 } 1076 }
1087 } 1077 }
1088 else 1078 else
@@ -1197,6 +1187,15 @@ curl_check_hdr (void *buffer,
1197 s5r->domain); 1187 s5r->domain);
1198 continue; 1188 continue;
1199 } 1189 }
1190 else if ( ('.' == cookie_domain[0]) &&
1191 (0 == strcmp (&cookie_domain[1],
1192 s5r->leho)) )
1193 {
1194 offset += sprintf (new_cookie_hdr + offset,
1195 " domain=.%s;",
1196 s5r->domain);
1197 continue;
1198 }
1200 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1199 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1201 _("Cookie domain `%s' supplied by server is invalid\n"), 1200 _("Cookie domain `%s' supplied by server is invalid\n"),
1202 tok); 1201 tok);
@@ -1996,7 +1995,8 @@ create_response (void *cls,
1996 us = MHD_lookup_connection_value (con, 1995 us = MHD_lookup_connection_value (con,
1997 MHD_HEADER_KIND, 1996 MHD_HEADER_KIND,
1998 MHD_HTTP_HEADER_CONTENT_LENGTH); 1997 MHD_HTTP_HEADER_CONTENT_LENGTH);
1999 if ( (NULL != us) && (1 == sscanf (us, 1998 if ( (NULL != us) &&
1999 (1 == sscanf (us,
2000 "%ld", 2000 "%ld",
2001 &upload_size)) && 2001 &upload_size)) &&
2002 (upload_size >= 0) ) 2002 (upload_size >= 0) )
@@ -2041,6 +2041,20 @@ create_response (void *cls,
2041 CURLOPT_WRITEDATA, 2041 CURLOPT_WRITEDATA,
2042 s5r); 2042 s5r);
2043 } 2043 }
2044 else if (0 == strcasecmp (meth,
2045 MHD_HTTP_METHOD_DELETE))
2046 {
2047 s5r->state = SOCKS5_SOCKET_DOWNLOAD_STARTED;
2048 curl_easy_setopt (s5r->curl,
2049 CURLOPT_CUSTOMREQUEST,
2050 "DELETE");
2051 curl_easy_setopt (s5r->curl,
2052 CURLOPT_WRITEFUNCTION,
2053 &curl_download_cb);
2054 curl_easy_setopt (s5r->curl,
2055 CURLOPT_WRITEDATA,
2056 s5r);
2057 }
2044 else 2058 else
2045 { 2059 {
2046 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 2060 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c
index 54c3cba23..67960ef97 100644
--- a/src/gns/gnunet-service-gns_resolver.c
+++ b/src/gns/gnunet-service-gns_resolver.c
@@ -2397,6 +2397,8 @@ handle_dht_response (void *cls,
2397 "Received expired block from the DHT, will not cache it.\n"); 2397 "Received expired block from the DHT, will not cache it.\n");
2398 return; 2398 return;
2399 } 2399 }
2400 if (GNUNET_YES == disable_cache)
2401 return;
2400 /* Cache well-formed blocks */ 2402 /* Cache well-formed blocks */
2401 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2403 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2402 "Caching response from the DHT in namecache\n"); 2404 "Caching response from the DHT in namecache\n");
@@ -2407,7 +2409,7 @@ handle_dht_response (void *cls,
2407 co); 2409 co);
2408 GNUNET_CONTAINER_DLL_insert (co_head, 2410 GNUNET_CONTAINER_DLL_insert (co_head,
2409 co_tail, 2411 co_tail,
2410 co); 2412 co);
2411} 2413}
2412 2414
2413 2415
diff --git a/src/psyc/Makefile.am b/src/psyc/Makefile.am
index 61618d176..26db608f3 100644
--- a/src/psyc/Makefile.am
+++ b/src/psyc/Makefile.am
@@ -58,13 +58,13 @@ AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PAT
58TESTS = $(check_PROGRAMS) 58TESTS = $(check_PROGRAMS)
59endif 59endif
60 60
61test_psyc_SOURCES = \ 61#test_psyc_SOURCES = \
62 test_psyc.c 62# test_psyc.c
63test_psyc_LDADD = \ 63#test_psyc_LDADD = \
64 libgnunetpsyc.la \ 64# libgnunetpsyc.la \
65 $(top_builddir)/src/psycutil/libgnunetpsycutil.la \ 65# $(top_builddir)/src/psycutil/libgnunetpsycutil.la \
66 $(top_builddir)/src/testing/libgnunettesting.la \ 66# $(top_builddir)/src/testing/libgnunettesting.la \
67 $(top_builddir)/src/util/libgnunetutil.la 67# $(top_builddir)/src/util/libgnunetutil.la
68test_psyc2_SOURCES = \ 68test_psyc2_SOURCES = \
69 test_psyc2.c 69 test_psyc2.c
70test_psyc2_LDADD = \ 70test_psyc2_LDADD = \
diff --git a/src/statistics/gnunet-statistics.c b/src/statistics/gnunet-statistics.c
index 648fc89bb..9093336e1 100644
--- a/src/statistics/gnunet-statistics.c
+++ b/src/statistics/gnunet-statistics.c
@@ -39,6 +39,11 @@ static int ret;
39static char *subsystem; 39static char *subsystem;
40 40
41/** 41/**
42 * The path of the testbed data.
43 */
44static char *path_testbed;
45
46/**
42 * Set to the specific stat value that we are after (or NULL for all). 47 * Set to the specific stat value that we are after (or NULL for all).
43 */ 48 */
44static char *name; 49static char *name;
@@ -59,6 +64,11 @@ static int watch;
59static int quiet; 64static int quiet;
60 65
61/** 66/**
67 * @brief Separator string for csv.
68 */
69static char *csv_separator;
70
71/**
62 * Remote host 72 * Remote host
63 */ 73 */
64static char *remote_host; 74static char *remote_host;
@@ -79,10 +89,200 @@ static unsigned long long set_val;
79static int set_value; 89static int set_value;
80 90
81/** 91/**
82 * Handle for pending GET operation. 92 * @brief Representation of all (testbed) nodes.
93 */
94static struct Node {
95 /**
96 * @brief Index of the node in this array.
97 */
98 unsigned index_node;
99
100 /**
101 * @brief Configuration handle for this node
102 */
103 struct GNUNET_CONFIGURATION_Handle *conf;
104
105 /**
106 * Handle for pending GET operation.
107 */
108 struct GNUNET_STATISTICS_GetHandle *gh;
109
110 /**
111 * @brief Statistics handle nodes.
112 */
113 struct GNUNET_STATISTICS_Handle *handle;
114 /**
115 * @brief Identifier for shutdown task for this node.
116 */
117 struct GNUNET_SCHEDULER_Task *shutdown_task;
118} *nodes;
119
120/**
121 * @brief Number of configurations of all (testbed) nodes.
122 */
123static unsigned num_nodes;
124
125/**
126 * @brief Set of values for a combination of subsystem and name.
127 */
128struct ValueSet
129{
130 /**
131 * @brief Subsystem of the valueset.
132 */
133 char *subsystem;
134
135 /**
136 * @brief Name of the valueset.
137 */
138 char *name;
139
140 /**
141 * @brief The values.
142 */
143 uint64_t *values;
144
145 /**
146 * @brief Persistence of the values.
147 */
148 int is_persistent;
149};
150
151/**
152 * @brief Collection of all values (represented with #ValueSet).
153 */
154static struct GNUNET_CONTAINER_MultiHashMap *values;
155
156/**
157 * @brief Number of nodes that have their values ready.
158 */
159static int num_nodes_ready;
160
161/**
162 * @brief Create a new #ValueSet
163 *
164 * @param subsystem Subsystem of the valueset.
165 * @param name Name of the valueset.
166 * @param num_values Number of values in valueset - number of peers.
167 * @param is_persistent Persistence status of values.
168 *
169 * @return Newly allocated #ValueSet.
170 */
171static struct ValueSet *
172new_value_set (const char *subsystem,
173 const char *name,
174 unsigned num_values,
175 int is_persistent)
176{
177 struct ValueSet *value_set;
178
179 value_set = GNUNET_new (struct ValueSet);
180 value_set->subsystem = GNUNET_strdup (subsystem);
181 value_set->name = GNUNET_strdup (name);
182 value_set->values = GNUNET_new_array (num_values, uint64_t);
183 value_set->is_persistent = persistent;
184 return value_set;
185}
186
187/**
188 * @brief Print the (collected) values.
189 *
190 * Implements #GNUNET_CONTAINER_HashMapIterator.
191 *
192 * @param cls Closure - unused
193 * @param key #GNUNET_HashCode key of #GNUNET_CONTAINER_MultiHashMap iterator -
194 * unused
195 * @param value Values represented as #ValueSet.
196 *
197 * @return GNUNET_YES - continue iteration.
198 */
199static int
200printer (void *cls,
201 const struct GNUNET_HashCode *key,
202 void *value)
203{
204 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get();
205 const char *now_str;
206 struct ValueSet *value_set = value;
207
208 if (quiet == GNUNET_NO)
209 {
210 if (GNUNET_YES == watch)
211 {
212 now_str = GNUNET_STRINGS_absolute_time_to_string (now);
213 FPRINTF (stdout,
214 "%24s%s %s%s%12s%s %50s%s ",
215 now_str,
216 csv_separator,
217 value_set->is_persistent ? "!" : " ",
218 csv_separator,
219 value_set->subsystem,
220 csv_separator,
221 _(value_set->name),
222 (0 == strlen (csv_separator) ? ":": csv_separator));
223 }
224 else
225 {
226 FPRINTF (stdout,
227 "%s%s%12s%s %50s%s ",
228 value_set->is_persistent ? "!" : " ",
229 csv_separator,
230 value_set->subsystem,
231 csv_separator,
232 _(value_set->name),
233 (0 == strlen (csv_separator) ? ":": csv_separator));
234 }
235 }
236 for (unsigned i = 0; i < num_nodes; i++)
237 {
238 FPRINTF (stdout,
239 "%16llu%s",
240 (unsigned long long) value_set->values[i],
241 csv_separator);
242 }
243 FPRINTF (stdout, "\n");
244 GNUNET_free (value_set->subsystem);
245 GNUNET_free (value_set->name);
246 GNUNET_free (value_set->values);
247 GNUNET_free (value_set);
248 return GNUNET_YES;
249}
250
251/**
252 * @brief Called once all statistic values are available.
253 *
254 * Implements #GNUNET_STATISTICS_Callback
255 *
256 * @param cls Closure - The index of the node.
257 * @param succes Whether statistics were obtained successfully.
83 */ 258 */
84static struct GNUNET_STATISTICS_GetHandle *gh; 259static void
260continuation_print (void *cls,
261 int success)
262{
263 const unsigned index_node = *(unsigned *) cls;
85 264
265 nodes[index_node].gh = NULL;
266 if (GNUNET_OK != success)
267 {
268 if (NULL == remote_host)
269 FPRINTF (stderr,
270 "%s",
271 _("Failed to obtain statistics.\n"));
272 else
273 FPRINTF (stderr,
274 _("Failed to obtain statistics from host `%s:%llu'\n"),
275 remote_host,
276 remote_port);
277 ret = 1;
278 }
279 num_nodes_ready++;
280 if (num_nodes_ready == num_nodes)
281 {
282 GNUNET_CONTAINER_multihashmap_iterate (values, printer, NULL);
283 GNUNET_SCHEDULER_shutdown();
284 }
285}
86 286
87/** 287/**
88 * Callback function to process statistic values. 288 * Callback function to process statistic values.
@@ -95,11 +295,11 @@ static struct GNUNET_STATISTICS_GetHandle *gh;
95 * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration 295 * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration
96 */ 296 */
97static int 297static int
98printer (void *cls, 298printer_watch (void *cls,
99 const char *subsystem, 299 const char *subsystem,
100 const char *name, 300 const char *name,
101 uint64_t value, 301 uint64_t value,
102 int is_persistent) 302 int is_persistent)
103{ 303{
104 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get(); 304 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get();
105 const char *now_str; 305 const char *now_str;
@@ -110,21 +310,28 @@ printer (void *cls,
110 { 310 {
111 now_str = GNUNET_STRINGS_absolute_time_to_string (now); 311 now_str = GNUNET_STRINGS_absolute_time_to_string (now);
112 FPRINTF (stdout, 312 FPRINTF (stdout,
113 "%24s %s%12s %50s: %16llu\n", 313 "%24s%s %s%s%12s%s %50s%s %16llu\n",
114 now_str, 314 now_str,
315 csv_separator,
115 is_persistent ? "!" : " ", 316 is_persistent ? "!" : " ",
317 csv_separator,
116 subsystem, 318 subsystem,
117 _(name), 319 csv_separator,
118 (unsigned long long) value); 320 _(name),
321 (0 == strlen (csv_separator) ? ":": csv_separator),
322 (unsigned long long) value);
119 } 323 }
120 else 324 else
121 { 325 {
122 FPRINTF (stdout, 326 FPRINTF (stdout,
123 "%s%12s %50s: %16llu\n", 327 "%s%s%12s%s %50s%s %16llu\n",
124 is_persistent ? "!" : " ", 328 is_persistent ? "!" : " ",
329 csv_separator,
125 subsystem, 330 subsystem,
126 _(name), 331 csv_separator,
127 (unsigned long long) value); 332 _(name),
333 (0 == strlen (csv_separator) ? ":": csv_separator),
334 (unsigned long long) value);
128 } 335 }
129 } 336 }
130 else 337 else
@@ -135,7 +342,6 @@ printer (void *cls,
135 return GNUNET_OK; 342 return GNUNET_OK;
136} 343}
137 344
138
139/** 345/**
140 * Function called last by the statistics code. 346 * Function called last by the statistics code.
141 * 347 *
@@ -147,7 +353,10 @@ static void
147cleanup (void *cls, 353cleanup (void *cls,
148 int success) 354 int success)
149{ 355{
150 gh = NULL; 356 for (unsigned i = 0; i < num_nodes; i++)
357 {
358 nodes[i].gh = NULL;
359 }
151 if (GNUNET_OK != success) 360 if (GNUNET_OK != success)
152 { 361 {
153 if (NULL == remote_host) 362 if (NULL == remote_host)
@@ -164,6 +373,55 @@ cleanup (void *cls,
164 GNUNET_SCHEDULER_shutdown (); 373 GNUNET_SCHEDULER_shutdown ();
165} 374}
166 375
376/**
377 * @brief Iterate over statistics values and store them in #values.
378 * They will be printed once all are available.
379 *
380 * @param cls Cosure - Node index.
381 * @param subsystem Subsystem of the value.
382 * @param name Name of the value.
383 * @param value Value itself.
384 * @param is_persistent Persistence.
385 *
386 * @return GNUNET_OK - continue.
387 */
388static int
389collector (void *cls,
390 const char *subsystem,
391 const char *name,
392 uint64_t value,
393 int is_persistent)
394{
395 const unsigned index_node = *(unsigned *) cls;
396 struct GNUNET_HashCode *key;
397 struct GNUNET_HashCode hc;
398 char *subsys_name;
399 unsigned len_subsys_name;
400 struct ValueSet *value_set;
401
402 len_subsys_name = strlen (subsystem) + 3 + strlen (name) + 1;
403 subsys_name = GNUNET_malloc (len_subsys_name);
404 SPRINTF (subsys_name, "%s---%s", subsystem, name);
405 key = &hc;
406 GNUNET_CRYPTO_hash (subsys_name, len_subsys_name, key);
407 GNUNET_free (subsys_name);
408 if (GNUNET_YES == GNUNET_CONTAINER_multihashmap_contains (values, key))
409 {
410 // get
411 value_set = GNUNET_CONTAINER_multihashmap_get (values, key);
412 }
413 else
414 {
415 // new
416 value_set = new_value_set (subsystem, name, num_nodes, is_persistent);
417 }
418 // write
419 value_set->values[index_node] = value;
420 // put
421 GNUNET_CONTAINER_multihashmap_put (values, key, value_set,
422 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
423 return GNUNET_OK;
424}
167 425
168/** 426/**
169 * Function run on shutdown to clean up. 427 * Function run on shutdown to clean up.
@@ -173,10 +431,30 @@ cleanup (void *cls,
173static void 431static void
174shutdown_task (void *cls) 432shutdown_task (void *cls)
175{ 433{
176 struct GNUNET_STATISTICS_Handle *h = cls; 434 const unsigned index_node = *(unsigned *) cls;
435 struct GNUNET_STATISTICS_Handle *h;
436 struct GNUNET_STATISTICS_GetHandle *gh;
177 437
438 nodes[index_node].shutdown_task = NULL;
439 if ( (NULL != path_testbed) &&
440 (NULL != nodes[index_node].conf) )
441 {
442 GNUNET_CONFIGURATION_destroy (nodes[index_node].conf);
443 nodes[index_node].conf = NULL;
444 }
445
446 h = nodes[index_node].handle;
447 gh = nodes[index_node].gh;
178 if (NULL == h) 448 if (NULL == h)
449 {
450 num_nodes_ready--;
451 if (0 == num_nodes_ready)
452 {
453 GNUNET_array_grow (nodes, num_nodes, 0);
454 GNUNET_CONTAINER_multihashmap_destroy (values);
455 }
179 return; 456 return;
457 }
180 if (NULL != gh) 458 if (NULL != gh)
181 { 459 {
182 GNUNET_STATISTICS_get_cancel (gh); 460 GNUNET_STATISTICS_get_cancel (gh);
@@ -186,14 +464,21 @@ shutdown_task (void *cls)
186 (NULL != subsystem) && 464 (NULL != subsystem) &&
187 (NULL != name) ) 465 (NULL != name) )
188 GNUNET_assert (GNUNET_OK == 466 GNUNET_assert (GNUNET_OK ==
189 GNUNET_STATISTICS_watch_cancel (h, 467 GNUNET_STATISTICS_watch_cancel (h,
190 subsystem, 468 subsystem,
191 name, 469 name,
192 &printer, 470 &printer_watch,
193 h)); 471 &nodes[index_node].index_node));
194 GNUNET_STATISTICS_destroy (h, 472 GNUNET_STATISTICS_destroy (h,
195 GNUNET_NO); 473 GNUNET_NO);
196 h = NULL; 474 h = NULL;
475
476 num_nodes_ready--;
477 if (0 == num_nodes_ready)
478 {
479 GNUNET_array_grow (nodes, num_nodes, 0);
480 GNUNET_CONTAINER_multihashmap_destroy (values);
481 }
197} 482}
198 483
199 484
@@ -205,8 +490,8 @@ shutdown_task (void *cls)
205static void 490static void
206main_task (void *cls) 491main_task (void *cls)
207{ 492{
208 const struct GNUNET_CONFIGURATION_Handle *cfg = cls; 493 unsigned index_node = *(unsigned *) cls;
209 struct GNUNET_STATISTICS_Handle *h; 494 const struct GNUNET_CONFIGURATION_Handle *cfg = nodes[index_node].conf;
210 495
211 if (set_value) 496 if (set_value)
212 { 497 {
@@ -226,23 +511,23 @@ main_task (void *cls)
226 ret = 1; 511 ret = 1;
227 return; 512 return;
228 } 513 }
229 h = GNUNET_STATISTICS_create (subsystem, 514 nodes[index_node].handle = GNUNET_STATISTICS_create (subsystem,
230 cfg); 515 cfg);
231 if (NULL == h) 516 if (NULL == nodes[index_node].handle)
232 { 517 {
233 ret = 1; 518 ret = 1;
234 return; 519 return;
235 } 520 }
236 GNUNET_STATISTICS_set (h, 521 GNUNET_STATISTICS_set (nodes[index_node].handle,
237 name, 522 name,
238 (uint64_t) set_val, 523 (uint64_t) set_val,
239 persistent); 524 persistent);
240 GNUNET_STATISTICS_destroy (h, 525 GNUNET_STATISTICS_destroy (nodes[index_node].handle,
241 GNUNET_YES); 526 GNUNET_YES);
242 h = NULL; 527 nodes[index_node].handle = NULL;
243 return; 528 return;
244 } 529 }
245 if (NULL == (h = GNUNET_STATISTICS_create ("gnunet-statistics", 530 if (NULL == (nodes[index_node].handle = GNUNET_STATISTICS_create ("gnunet-statistics",
246 cfg))) 531 cfg)))
247 { 532 {
248 ret = 1; 533 ret = 1;
@@ -251,13 +536,13 @@ main_task (void *cls)
251 if (GNUNET_NO == watch) 536 if (GNUNET_NO == watch)
252 { 537 {
253 if (NULL == 538 if (NULL ==
254 (gh = GNUNET_STATISTICS_get (h, 539 (nodes[index_node].gh = GNUNET_STATISTICS_get (nodes[index_node].handle,
255 subsystem, 540 subsystem,
256 name, 541 name,
257 &cleanup, 542 &continuation_print,
258 &printer, 543 &collector,
259 h)) ) 544 &nodes[index_node].index_node)) )
260 cleanup (h, 545 cleanup (nodes[index_node].handle,
261 GNUNET_SYSERR); 546 GNUNET_SYSERR);
262 } 547 }
263 else 548 else
@@ -266,30 +551,128 @@ main_task (void *cls)
266 (NULL == name) ) 551 (NULL == name) )
267 { 552 {
268 printf (_("No subsystem or name given\n")); 553 printf (_("No subsystem or name given\n"));
269 GNUNET_STATISTICS_destroy (h, 554 GNUNET_STATISTICS_destroy (nodes[index_node].handle,
270 GNUNET_NO); 555 GNUNET_NO);
271 h = NULL; 556 nodes[index_node].handle = NULL;
272 ret = 1; 557 ret = 1;
273 return; 558 return;
274 } 559 }
275 if (GNUNET_OK != 560 if (GNUNET_OK !=
276 GNUNET_STATISTICS_watch (h, 561 GNUNET_STATISTICS_watch (nodes[index_node].handle,
277 subsystem, 562 subsystem,
278 name, 563 name,
279 &printer, 564 &printer_watch,
280 h)) 565 &nodes[index_node].index_node))
281 { 566 {
282 fprintf (stderr, 567 fprintf (stderr,
283 _("Failed to initialize watch routine\n")); 568 _("Failed to initialize watch routine\n"));
284 GNUNET_SCHEDULER_add_now (&shutdown_task, 569 nodes[index_node].shutdown_task =
285 h); 570 GNUNET_SCHEDULER_add_now (&shutdown_task,
571 &nodes[index_node].index_node);
286 return; 572 return;
287 } 573 }
288 } 574 }
289 GNUNET_SCHEDULER_add_shutdown (&shutdown_task, 575 nodes[index_node].shutdown_task =
290 h); 576 GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
577 &nodes[index_node].index_node);
578}
579
580/**
581 * @brief Iter over content of a node's directory to check for existence of a
582 * config file.
583 *
584 * Implements #GNUNET_FileNameCallback
585 *
586 * @param cls pointer to indicate success
587 * @param filename filename inside the directory of the potential node
588 *
589 * @return to continue iteration or not to
590 */
591static int
592iter_check_config (void *cls,
593 const char *filename)
594{
595 if (0 == strncmp (GNUNET_STRINGS_get_short_name (filename), "config", 6))
596 {
597 /* Found the config - stop iteration successfully */
598 GNUNET_array_grow (nodes, num_nodes, num_nodes+1);
599 nodes[num_nodes-1].conf = GNUNET_CONFIGURATION_create();
600 nodes[num_nodes-1].index_node = num_nodes-1;
601 if (GNUNET_OK != GNUNET_CONFIGURATION_load (nodes[num_nodes-1].conf, filename))
602 {
603 FPRINTF (stderr, "Failed loading config `%s'\n", filename);
604 return GNUNET_SYSERR;
605 }
606 return GNUNET_NO;
607 }
608 else
609 {
610 /* Continue iteration */
611 return GNUNET_OK;
612 }
613}
614
615/**
616 * @brief Iterates over filenames in testbed directory.
617 *
618 * Implements #GNUNET_FileNameCallback
619 *
620 * Checks if the file is a directory for a testbed node
621 * and counts the nodes.
622 *
623 * @param cls counter of nodes
624 * @param filename full path of the file in testbed
625 *
626 * @return status whether to continue iteration
627 */
628static int
629iter_testbed_path (void *cls,
630 const char *filename)
631{
632 unsigned index_node;
633
634 GNUNET_assert (NULL != filename);
635 if (1 == SSCANF (GNUNET_STRINGS_get_short_name (filename),
636 "%u",
637 &index_node))
638 {
639 if (-1 == GNUNET_DISK_directory_scan (filename,
640 iter_check_config,
641 NULL))
642 {
643 /* This is probably no directory for a testbed node
644 * Go on with iteration */
645 return GNUNET_OK;
646 }
647 return GNUNET_OK;
648 }
649 return GNUNET_OK;
291} 650}
292 651
652/**
653 * @brief Count the number of nodes running in the testbed
654 *
655 * @param path_testbed path to the testbed data
656 *
657 * @return number of running nodes
658 */
659static int
660discover_testbed_nodes (const char *path_testbed)
661{
662 int num_dir_entries;
663
664 num_dir_entries = GNUNET_DISK_directory_scan (path_testbed,
665 iter_testbed_path,
666 NULL);
667 if (-1 == num_dir_entries)
668 {
669 FPRINTF (stderr,
670 "Failure during scanning directory `%s'\n",
671 path_testbed);
672 return -1;
673 }
674 return 0;
675}
293 676
294/** 677/**
295 * Main function that will be run by the scheduler. 678 * Main function that will be run by the scheduler.
@@ -309,6 +692,7 @@ run (void *cls,
309 692
310 c = (struct GNUNET_CONFIGURATION_Handle *) cfg; 693 c = (struct GNUNET_CONFIGURATION_Handle *) cfg;
311 set_value = GNUNET_NO; 694 set_value = GNUNET_NO;
695 if (NULL == csv_separator) csv_separator = "";
312 if (NULL != args[0]) 696 if (NULL != args[0])
313 { 697 {
314 if (1 != SSCANF (args[0], 698 if (1 != SSCANF (args[0],
@@ -361,8 +745,34 @@ run (void *cls,
361 "PORT", 745 "PORT",
362 remote_port); 746 remote_port);
363 } 747 }
364 GNUNET_SCHEDULER_add_now (&main_task, 748 if (NULL == path_testbed)
365 c); 749 {
750 values = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO);
751 GNUNET_array_grow (nodes, num_nodes, 1);
752 nodes[0].index_node = 0;
753 nodes[0].conf = c;
754 GNUNET_SCHEDULER_add_now (&main_task, &nodes[0].index_node);
755 }
756 else
757 {
758 if (GNUNET_YES == watch)
759 {
760 printf (_("Not able to watch testbed nodes (yet - feel free to implement)\n"));
761 ret = 1;
762 return;
763 }
764 values = GNUNET_CONTAINER_multihashmap_create (4, GNUNET_NO);
765 if (-1 == discover_testbed_nodes (path_testbed))
766 {
767 return;
768 }
769 /* For each config/node collect statistics */
770 for (unsigned i = 0; i < num_nodes; i++)
771 {
772 GNUNET_SCHEDULER_add_now (&main_task,
773 &nodes[i].index_node);
774 }
775 }
366} 776}
367 777
368 778
@@ -394,6 +804,18 @@ main (int argc, char *const *argv)
394 gettext_noop ("limit output to the given SUBSYSTEM"), 804 gettext_noop ("limit output to the given SUBSYSTEM"),
395 &subsystem), 805 &subsystem),
396 806
807 GNUNET_GETOPT_option_string ('S',
808 "csv-separator",
809 "CSV_SEPARATOR",
810 gettext_noop ("use as csv separator"),
811 &csv_separator),
812
813 GNUNET_GETOPT_option_filename ('t',
814 "testbed",
815 "TESTBED",
816 gettext_noop ("path to the folder containing the testbed data"),
817 &path_testbed),
818
397 GNUNET_GETOPT_option_flag ('q', 819 GNUNET_GETOPT_option_flag ('q',
398 "quiet", 820 "quiet",
399 gettext_noop ("just print the statistics value"), 821 gettext_noop ("just print the statistics value"),
@@ -409,11 +831,13 @@ main (int argc, char *const *argv)
409 "REMOTE", 831 "REMOTE",
410 gettext_noop ("connect to remote host"), 832 gettext_noop ("connect to remote host"),
411 &remote_host), 833 &remote_host),
834
412 GNUNET_GETOPT_option_ulong ('o', 835 GNUNET_GETOPT_option_ulong ('o',
413 "port", 836 "port",
414 "PORT", 837 "PORT",
415 gettext_noop ("port for remote host"), 838 gettext_noop ("port for remote host"),
416 &remote_port), 839 &remote_port),
840
417 GNUNET_GETOPT_OPTION_END 841 GNUNET_GETOPT_OPTION_END
418 }; 842 };
419 remote_port = 0; 843 remote_port = 0;