diff options
-rw-r--r-- | src/core/Makefile.am | 1 | ||||
-rw-r--r-- | src/core/gnunet-service-core.c | 32 | ||||
-rw-r--r-- | src/hostlist/hostlist-client.c | 31 | ||||
-rw-r--r-- | src/hostlist/hostlist-server.c | 2 |
4 files changed, 59 insertions, 7 deletions
diff --git a/src/core/Makefile.am b/src/core/Makefile.am index 605b8d2ce..894721874 100644 --- a/src/core/Makefile.am +++ b/src/core/Makefile.am | |||
@@ -34,6 +34,7 @@ gnunet_service_core_SOURCES = \ | |||
34 | gnunet_service_core_LDADD = \ | 34 | gnunet_service_core_LDADD = \ |
35 | $(top_builddir)/src/hello/libgnunethello.la \ | 35 | $(top_builddir)/src/hello/libgnunethello.la \ |
36 | $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \ | 36 | $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \ |
37 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | ||
37 | $(top_builddir)/src/transport/libgnunettransport.la \ | 38 | $(top_builddir)/src/transport/libgnunettransport.la \ |
38 | $(top_builddir)/src/util/libgnunetutil.la \ | 39 | $(top_builddir)/src/util/libgnunetutil.la \ |
39 | $(GN_LIBINTL) | 40 | $(GN_LIBINTL) |
diff --git a/src/core/gnunet-service-core.c b/src/core/gnunet-service-core.c index 8f22313e6..eabb2d946 100644 --- a/src/core/gnunet-service-core.c +++ b/src/core/gnunet-service-core.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #include "gnunet_peerinfo_service.h" | 37 | #include "gnunet_peerinfo_service.h" |
38 | #include "gnunet_protocols.h" | 38 | #include "gnunet_protocols.h" |
39 | #include "gnunet_signatures.h" | 39 | #include "gnunet_signatures.h" |
40 | #include "gnunet_statistics_service.h" | ||
40 | #include "gnunet_transport_service.h" | 41 | #include "gnunet_transport_service.h" |
41 | #include "core.h" | 42 | #include "core.h" |
42 | 43 | ||
@@ -690,6 +691,11 @@ static struct GNUNET_SERVER_NotificationContext *notifier; | |||
690 | static struct Neighbour *neighbours; | 691 | static struct Neighbour *neighbours; |
691 | 692 | ||
692 | /** | 693 | /** |
694 | * For creating statistics. | ||
695 | */ | ||
696 | static struct GNUNET_STATISTICS_Handle *stats; | ||
697 | |||
698 | /** | ||
693 | * Sum of all preferences among all neighbours. | 699 | * Sum of all preferences among all neighbours. |
694 | */ | 700 | */ |
695 | static unsigned long long preference_sum; | 701 | static unsigned long long preference_sum; |
@@ -737,6 +743,7 @@ update_preference_sum (unsigned long long inc) | |||
737 | preference_sum += n->current_preference; | 743 | preference_sum += n->current_preference; |
738 | n = n->next; | 744 | n = n->next; |
739 | } | 745 | } |
746 | GNUNET_STATISTICS_set (stats, gettext_noop ("# total peer preference"), preference_sum, GNUNET_NO); | ||
740 | } | 747 | } |
741 | 748 | ||
742 | 749 | ||
@@ -1094,8 +1101,10 @@ free_neighbour (struct Neighbour *n) | |||
1094 | GNUNET_SCHEDULER_cancel (sched, n->quota_update_task); | 1101 | GNUNET_SCHEDULER_cancel (sched, n->quota_update_task); |
1095 | if (n->dead_clean_task != GNUNET_SCHEDULER_NO_TASK) | 1102 | if (n->dead_clean_task != GNUNET_SCHEDULER_NO_TASK) |
1096 | GNUNET_SCHEDULER_cancel (sched, n->dead_clean_task); | 1103 | GNUNET_SCHEDULER_cancel (sched, n->dead_clean_task); |
1097 | if (n->keep_alive_task != GNUNET_SCHEDULER_NO_TASK) | 1104 | if (n->keep_alive_task != GNUNET_SCHEDULER_NO_TASK) |
1098 | GNUNET_SCHEDULER_cancel (sched, n->keep_alive_task); | 1105 | GNUNET_SCHEDULER_cancel (sched, n->keep_alive_task); |
1106 | if (n->status == PEER_STATE_KEY_CONFIRMED) | ||
1107 | GNUNET_STATISTICS_update (stats, gettext_noop ("# peers connected"), -1, GNUNET_NO); | ||
1099 | GNUNET_free_non_null (n->public_key); | 1108 | GNUNET_free_non_null (n->public_key); |
1100 | GNUNET_free_non_null (n->pending_ping); | 1109 | GNUNET_free_non_null (n->pending_ping); |
1101 | GNUNET_free_non_null (n->pending_pong); | 1110 | GNUNET_free_non_null (n->pending_pong); |
@@ -1141,6 +1150,7 @@ do_encrypt (struct Neighbour *n, | |||
1141 | (const struct | 1150 | (const struct |
1142 | GNUNET_CRYPTO_AesInitializationVector | 1151 | GNUNET_CRYPTO_AesInitializationVector |
1143 | *) iv, out)); | 1152 | *) iv, out)); |
1153 | GNUNET_STATISTICS_update (stats, gettext_noop ("# bytes encrypted"), size, GNUNET_NO); | ||
1144 | #if DEBUG_CORE | 1154 | #if DEBUG_CORE |
1145 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1155 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1146 | "Encrypted %u bytes for `%4s' using key %u\n", size, | 1156 | "Encrypted %u bytes for `%4s' using key %u\n", size, |
@@ -1286,6 +1296,7 @@ consider_free_neighbour (struct Neighbour *n) | |||
1286 | prev->next = n->next; | 1296 | prev->next = n->next; |
1287 | GNUNET_assert (neighbour_count > 0); | 1297 | GNUNET_assert (neighbour_count > 0); |
1288 | neighbour_count--; | 1298 | neighbour_count--; |
1299 | GNUNET_STATISTICS_set (stats, gettext_noop ("# active neighbours"), neighbour_count, GNUNET_NO); | ||
1289 | free_neighbour (n); | 1300 | free_neighbour (n); |
1290 | } | 1301 | } |
1291 | 1302 | ||
@@ -1444,6 +1455,7 @@ do_decrypt (struct Neighbour *n, | |||
1444 | GNUNET_break (0); | 1455 | GNUNET_break (0); |
1445 | return GNUNET_SYSERR; | 1456 | return GNUNET_SYSERR; |
1446 | } | 1457 | } |
1458 | GNUNET_STATISTICS_update (stats, gettext_noop ("# bytes decrypted"), size, GNUNET_NO); | ||
1447 | #if DEBUG_CORE | 1459 | #if DEBUG_CORE |
1448 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1460 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1449 | "Decrypted %u bytes from `%4s' using key %u\n", | 1461 | "Decrypted %u bytes from `%4s' using key %u\n", |
@@ -2050,6 +2062,7 @@ create_neighbour (const struct GNUNET_PeerIdentity *pid) | |||
2050 | n->next = neighbours; | 2062 | n->next = neighbours; |
2051 | neighbours = n; | 2063 | neighbours = n; |
2052 | neighbour_count++; | 2064 | neighbour_count++; |
2065 | GNUNET_STATISTICS_set (stats, gettext_noop ("# active neighbours"), neighbour_count, GNUNET_NO); | ||
2053 | n->peer = *pid; | 2066 | n->peer = *pid; |
2054 | GNUNET_CRYPTO_aes_create_session_key (&n->encrypt_key); | 2067 | GNUNET_CRYPTO_aes_create_session_key (&n->encrypt_key); |
2055 | now = GNUNET_TIME_absolute_get (); | 2068 | now = GNUNET_TIME_absolute_get (); |
@@ -2250,6 +2263,7 @@ handle_client_request_connect (void *cls, | |||
2250 | if ( (n->is_connected) || | 2263 | if ( (n->is_connected) || |
2251 | (n->th != NULL) ) | 2264 | (n->th != NULL) ) |
2252 | return; /* already connected, or at least trying */ | 2265 | return; /* already connected, or at least trying */ |
2266 | GNUNET_STATISTICS_update (stats, gettext_noop ("# connection requests received"), 1, GNUNET_NO); | ||
2253 | #if DEBUG_CORE | 2267 | #if DEBUG_CORE |
2254 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2268 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2255 | "Core received `%s' request for `%4s', will try to establish connection\n", | 2269 | "Core received `%s' request for `%4s', will try to establish connection\n", |
@@ -2721,7 +2735,7 @@ handle_pong (struct Neighbour *n, | |||
2721 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2735 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2722 | "Confirmed key via `%s' message for peer `%4s'\n", | 2736 | "Confirmed key via `%s' message for peer `%4s'\n", |
2723 | "PONG", GNUNET_i2s (&n->peer)); | 2737 | "PONG", GNUNET_i2s (&n->peer)); |
2724 | #endif | 2738 | #endif |
2725 | if (n->retry_set_key_task != GNUNET_SCHEDULER_NO_TASK) | 2739 | if (n->retry_set_key_task != GNUNET_SCHEDULER_NO_TASK) |
2726 | { | 2740 | { |
2727 | GNUNET_SCHEDULER_cancel (sched, n->retry_set_key_task); | 2741 | GNUNET_SCHEDULER_cancel (sched, n->retry_set_key_task); |
@@ -3267,6 +3281,7 @@ handle_transport_receive (void *cls, | |||
3267 | GNUNET_break_op (0); | 3281 | GNUNET_break_op (0); |
3268 | return; | 3282 | return; |
3269 | } | 3283 | } |
3284 | GNUNET_STATISTICS_update (stats, gettext_noop ("# session keys received"), 1, GNUNET_NO); | ||
3270 | handle_set_key (n, (const struct SetKeyMessage *) message); | 3285 | handle_set_key (n, (const struct SetKeyMessage *) message); |
3271 | break; | 3286 | break; |
3272 | case GNUNET_MESSAGE_TYPE_CORE_ENCRYPTED_MESSAGE: | 3287 | case GNUNET_MESSAGE_TYPE_CORE_ENCRYPTED_MESSAGE: |
@@ -3290,6 +3305,7 @@ handle_transport_receive (void *cls, | |||
3290 | GNUNET_break_op (0); | 3305 | GNUNET_break_op (0); |
3291 | return; | 3306 | return; |
3292 | } | 3307 | } |
3308 | GNUNET_STATISTICS_update (stats, gettext_noop ("# ping messages received"), 1, GNUNET_NO); | ||
3293 | if ((n->status != PEER_STATE_KEY_RECEIVED) && | 3309 | if ((n->status != PEER_STATE_KEY_RECEIVED) && |
3294 | (n->status != PEER_STATE_KEY_CONFIRMED)) | 3310 | (n->status != PEER_STATE_KEY_CONFIRMED)) |
3295 | { | 3311 | { |
@@ -3311,6 +3327,7 @@ handle_transport_receive (void *cls, | |||
3311 | GNUNET_break_op (0); | 3327 | GNUNET_break_op (0); |
3312 | return; | 3328 | return; |
3313 | } | 3329 | } |
3330 | GNUNET_STATISTICS_update (stats, gettext_noop ("# pong messages received"), 1, GNUNET_NO); | ||
3314 | if ( (n->status != PEER_STATE_KEY_RECEIVED) && | 3331 | if ( (n->status != PEER_STATE_KEY_RECEIVED) && |
3315 | (n->status != PEER_STATE_KEY_CONFIRMED) ) | 3332 | (n->status != PEER_STATE_KEY_CONFIRMED) ) |
3316 | { | 3333 | { |
@@ -3336,7 +3353,10 @@ handle_transport_receive (void *cls, | |||
3336 | now = GNUNET_TIME_absolute_get (); | 3353 | now = GNUNET_TIME_absolute_get (); |
3337 | n->last_activity = now; | 3354 | n->last_activity = now; |
3338 | if (!up) | 3355 | if (!up) |
3339 | n->time_established = now; | 3356 | { |
3357 | GNUNET_STATISTICS_update (stats, gettext_noop ("# peers connected"), 1, GNUNET_NO); | ||
3358 | n->time_established = now; | ||
3359 | } | ||
3340 | if (n->keep_alive_task != GNUNET_SCHEDULER_NO_TASK) | 3360 | if (n->keep_alive_task != GNUNET_SCHEDULER_NO_TASK) |
3341 | GNUNET_SCHEDULER_cancel (sched, n->keep_alive_task); | 3361 | GNUNET_SCHEDULER_cancel (sched, n->keep_alive_task); |
3342 | n->keep_alive_task | 3362 | n->keep_alive_task |
@@ -3545,12 +3565,15 @@ cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
3545 | neighbour_count--; | 3565 | neighbour_count--; |
3546 | free_neighbour (n); | 3566 | free_neighbour (n); |
3547 | } | 3567 | } |
3568 | GNUNET_STATISTICS_set (stats, gettext_noop ("# active neighbours"), neighbour_count, GNUNET_NO); | ||
3548 | GNUNET_SERVER_notification_context_destroy (notifier); | 3569 | GNUNET_SERVER_notification_context_destroy (notifier); |
3549 | notifier = NULL; | 3570 | notifier = NULL; |
3550 | while (NULL != (c = clients)) | 3571 | while (NULL != (c = clients)) |
3551 | handle_client_disconnect (NULL, c->client_handle); | 3572 | handle_client_disconnect (NULL, c->client_handle); |
3552 | if (my_private_key != NULL) | 3573 | if (my_private_key != NULL) |
3553 | GNUNET_CRYPTO_rsa_key_free (my_private_key); | 3574 | GNUNET_CRYPTO_rsa_key_free (my_private_key); |
3575 | if (stats != NULL) | ||
3576 | GNUNET_STATISTICS_destroy (stats, GNUNET_YES); | ||
3554 | } | 3577 | } |
3555 | 3578 | ||
3556 | 3579 | ||
@@ -3620,6 +3643,7 @@ run (void *cls, | |||
3620 | &handle_transport_notify_connect, | 3643 | &handle_transport_notify_connect, |
3621 | &handle_transport_notify_disconnect); | 3644 | &handle_transport_notify_disconnect); |
3622 | GNUNET_assert (NULL != transport); | 3645 | GNUNET_assert (NULL != transport); |
3646 | stats = GNUNET_STATISTICS_create (sched, "core", cfg); | ||
3623 | GNUNET_SCHEDULER_add_delayed (sched, | 3647 | GNUNET_SCHEDULER_add_delayed (sched, |
3624 | GNUNET_TIME_UNIT_FOREVER_REL, | 3648 | GNUNET_TIME_UNIT_FOREVER_REL, |
3625 | &cleaning_task, NULL); | 3649 | &cleaning_task, NULL); |
diff --git a/src/hostlist/hostlist-client.c b/src/hostlist/hostlist-client.c index feef6230b..381638554 100644 --- a/src/hostlist/hostlist-client.c +++ b/src/hostlist/hostlist-client.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include "hostlist-client.h" | 28 | #include "hostlist-client.h" |
29 | #include "gnunet_core_service.h" | 29 | #include "gnunet_core_service.h" |
30 | #include "gnunet_hello_lib.h" | 30 | #include "gnunet_hello_lib.h" |
31 | #include "gnunet_statistics_service.h" | ||
31 | #include "gnunet_transport_service.h" | 32 | #include "gnunet_transport_service.h" |
32 | #include <curl/curl.h> | 33 | #include <curl/curl.h> |
33 | 34 | ||
@@ -142,6 +143,10 @@ download_hostlist_processor (void *ptr, | |||
142 | { | 143 | { |
143 | return total; /* ok, no data or bogus data */ | 144 | return total; /* ok, no data or bogus data */ |
144 | } | 145 | } |
146 | GNUNET_STATISTICS_update (stats, | ||
147 | gettext_noop ("# bytes downloaded from hostlist servers"), | ||
148 | (int64_t) total, | ||
149 | GNUNET_NO); | ||
145 | left = total; | 150 | left = total; |
146 | while (left > 0) | 151 | while (left > 0) |
147 | { | 152 | { |
@@ -159,6 +164,10 @@ download_hostlist_processor (void *ptr, | |||
159 | msize = ntohs(msg->size); | 164 | msize = ntohs(msg->size); |
160 | if (msize < sizeof(struct GNUNET_MessageHeader)) | 165 | if (msize < sizeof(struct GNUNET_MessageHeader)) |
161 | { | 166 | { |
167 | GNUNET_STATISTICS_update (stats, | ||
168 | gettext_noop ("# invalid HELLOs downloaded from hostlist servers"), | ||
169 | 1, | ||
170 | GNUNET_NO); | ||
162 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 171 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
163 | _("Invalid `%s' message received from hostlist at `%s'\n"), | 172 | _("Invalid `%s' message received from hostlist at `%s'\n"), |
164 | "HELLO", | 173 | "HELLO", |
@@ -175,10 +184,18 @@ download_hostlist_processor (void *ptr, | |||
175 | "Received valid `%s' message from hostlist server.\n", | 184 | "Received valid `%s' message from hostlist server.\n", |
176 | "HELLO"); | 185 | "HELLO"); |
177 | #endif | 186 | #endif |
187 | GNUNET_STATISTICS_update (stats, | ||
188 | gettext_noop ("# valid HELLOs downloaded from hostlist servers"), | ||
189 | 1, | ||
190 | GNUNET_NO); | ||
178 | GNUNET_TRANSPORT_offer_hello (transport, msg); | 191 | GNUNET_TRANSPORT_offer_hello (transport, msg); |
179 | } | 192 | } |
180 | else | 193 | else |
181 | { | 194 | { |
195 | GNUNET_STATISTICS_update (stats, | ||
196 | gettext_noop ("# invalid HELLOs downloaded from hostlist servers"), | ||
197 | 1, | ||
198 | GNUNET_NO); | ||
182 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 199 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
183 | _("Invalid `%s' message received from hostlist at `%s'\n"), | 200 | _("Invalid `%s' message received from hostlist at `%s'\n"), |
184 | "HELLO", | 201 | "HELLO", |
@@ -495,7 +512,10 @@ download_hostlist () | |||
495 | GNUNET_log (GNUNET_ERROR_TYPE_INFO | GNUNET_ERROR_TYPE_BULK, | 512 | GNUNET_log (GNUNET_ERROR_TYPE_INFO | GNUNET_ERROR_TYPE_BULK, |
496 | _("Bootstrapping using hostlist at `%s'.\n"), | 513 | _("Bootstrapping using hostlist at `%s'.\n"), |
497 | current_url); | 514 | current_url); |
498 | 515 | GNUNET_STATISTICS_update (stats, | |
516 | gettext_noop ("# hostlist downloads initiated"), | ||
517 | 1, | ||
518 | GNUNET_NO); | ||
499 | if (proxy != NULL) | 519 | if (proxy != NULL) |
500 | CURL_EASY_SETOPT (curl, CURLOPT_PROXY, proxy); | 520 | CURL_EASY_SETOPT (curl, CURLOPT_PROXY, proxy); |
501 | download_pos = 0; | 521 | download_pos = 0; |
@@ -660,6 +680,10 @@ connect_handler (void *cls, | |||
660 | uint32_t distance) | 680 | uint32_t distance) |
661 | { | 681 | { |
662 | connection_count++; | 682 | connection_count++; |
683 | GNUNET_STATISTICS_update (stats, | ||
684 | gettext_noop ("# active connections"), | ||
685 | 1, | ||
686 | GNUNET_NO); | ||
663 | } | 687 | } |
664 | 688 | ||
665 | 689 | ||
@@ -675,6 +699,10 @@ disconnect_handler (void *cls, | |||
675 | GNUNET_PeerIdentity * peer) | 699 | GNUNET_PeerIdentity * peer) |
676 | { | 700 | { |
677 | connection_count--; | 701 | connection_count--; |
702 | GNUNET_STATISTICS_update (stats, | ||
703 | gettext_noop ("# active connections"), | ||
704 | -1, | ||
705 | GNUNET_NO); | ||
678 | } | 706 | } |
679 | 707 | ||
680 | 708 | ||
@@ -783,7 +811,6 @@ GNUNET_HOSTLIST_client_stop () | |||
783 | proxy = NULL; | 811 | proxy = NULL; |
784 | cfg = NULL; | 812 | cfg = NULL; |
785 | sched = NULL; | 813 | sched = NULL; |
786 | stats = NULL; | ||
787 | } | 814 | } |
788 | 815 | ||
789 | /* end of hostlist-client.c */ | 816 | /* end of hostlist-client.c */ |
diff --git a/src/hostlist/hostlist-server.c b/src/hostlist/hostlist-server.c index 11cd8b906..0982889d7 100644 --- a/src/hostlist/hostlist-server.c +++ b/src/hostlist/hostlist-server.c | |||
@@ -92,7 +92,7 @@ static struct GNUNET_PEERINFO_IteratorContext *pitr; | |||
92 | */ | 92 | */ |
93 | struct HostSet | 93 | struct HostSet |
94 | { | 94 | { |
95 | size_t size; | 95 | unsigned int size; |
96 | 96 | ||
97 | char *data; | 97 | char *data; |
98 | }; | 98 | }; |