diff options
Diffstat (limited to 'src/nse')
-rw-r--r-- | src/nse/gnunet-nse.c | 38 | ||||
-rw-r--r-- | src/nse/gnunet-service-nse.c | 21 | ||||
-rw-r--r-- | src/nse/nse_api.c | 43 |
3 files changed, 55 insertions, 47 deletions
diff --git a/src/nse/gnunet-nse.c b/src/nse/gnunet-nse.c index bf2fe11c3..c8ffa152e 100644 --- a/src/nse/gnunet-nse.c +++ b/src/nse/gnunet-nse.c | |||
@@ -46,6 +46,7 @@ static int status; | |||
46 | static void | 46 | static void |
47 | do_shutdown (void *cls) | 47 | do_shutdown (void *cls) |
48 | { | 48 | { |
49 | (void) cls; | ||
49 | if (NULL != nse) | 50 | if (NULL != nse) |
50 | { | 51 | { |
51 | GNUNET_NSE_disconnect (nse); | 52 | GNUNET_NSE_disconnect (nse); |
@@ -65,12 +66,14 @@ do_shutdown (void *cls) | |||
65 | */ | 66 | */ |
66 | static void | 67 | static void |
67 | handle_estimate (void *cls, | 68 | handle_estimate (void *cls, |
68 | struct GNUNET_TIME_Absolute timestamp, | 69 | struct GNUNET_TIME_Absolute timestamp, |
69 | double estimate, | 70 | double estimate, |
70 | double std_dev) | 71 | double std_dev) |
71 | { | 72 | { |
73 | (void) cls; | ||
72 | status = 0; | 74 | status = 0; |
73 | FPRINTF (stdout, "%llu %f %f %f\n", | 75 | FPRINTF (stdout, |
76 | "%llu %f %f %f\n", | ||
74 | (unsigned long long) timestamp.abs_value_us, | 77 | (unsigned long long) timestamp.abs_value_us, |
75 | GNUNET_NSE_log_estimate_to_n (estimate), | 78 | GNUNET_NSE_log_estimate_to_n (estimate), |
76 | estimate, | 79 | estimate, |
@@ -92,11 +95,11 @@ run (void *cls, | |||
92 | const char *cfgfile, | 95 | const char *cfgfile, |
93 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 96 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
94 | { | 97 | { |
95 | nse = GNUNET_NSE_connect (cfg, | 98 | (void) cls; |
96 | &handle_estimate, | 99 | (void) args; |
97 | NULL); | 100 | (void) cfgfile; |
98 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, | 101 | nse = GNUNET_NSE_connect (cfg, &handle_estimate, NULL); |
99 | NULL); | 102 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); |
100 | } | 103 | } |
101 | 104 | ||
102 | 105 | ||
@@ -106,22 +109,21 @@ run (void *cls, | |||
106 | * @return 0 on success | 109 | * @return 0 on success |
107 | */ | 110 | */ |
108 | int | 111 | int |
109 | main (int argc, | 112 | main (int argc, char *const *argv) |
110 | char *const *argv) | ||
111 | { | 113 | { |
112 | static struct GNUNET_GETOPT_CommandLineOption options[] = { | 114 | static struct GNUNET_GETOPT_CommandLineOption options[] = { |
113 | GNUNET_GETOPT_OPTION_END | 115 | GNUNET_GETOPT_OPTION_END}; |
114 | }; | ||
115 | 116 | ||
116 | status = 1; | 117 | status = 1; |
117 | if (GNUNET_OK != | 118 | if (GNUNET_OK != |
118 | GNUNET_PROGRAM_run (argc, | 119 | GNUNET_PROGRAM_run (argc, |
119 | argv, | 120 | argv, |
120 | "gnunet-nse", | 121 | "gnunet-nse", |
121 | gettext_noop | 122 | gettext_noop ( |
122 | ("Show network size estimates from NSE service."), | 123 | "Show network size estimates from NSE service."), |
123 | options, | 124 | options, |
124 | &run, NULL)) | 125 | &run, |
126 | NULL)) | ||
125 | return 2; | 127 | return 2; |
126 | return status; | 128 | return status; |
127 | } | 129 | } |
diff --git a/src/nse/gnunet-service-nse.c b/src/nse/gnunet-service-nse.c index 09316dbcf..fd83d2b67 100644 --- a/src/nse/gnunet-service-nse.c +++ b/src/nse/gnunet-service-nse.c | |||
@@ -430,6 +430,7 @@ handle_start (void *cls, const struct GNUNET_MessageHeader *message) | |||
430 | struct GNUNET_NSE_ClientMessage em; | 430 | struct GNUNET_NSE_ClientMessage em; |
431 | struct GNUNET_MQ_Envelope *env; | 431 | struct GNUNET_MQ_Envelope *env; |
432 | 432 | ||
433 | (void) message; | ||
433 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received START message from client\n"); | 434 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received START message from client\n"); |
434 | mq = GNUNET_SERVICE_client_get_mq (client); | 435 | mq = GNUNET_SERVICE_client_get_mq (client); |
435 | GNUNET_notification_context_add (nc, mq); | 436 | GNUNET_notification_context_add (nc, mq); |
@@ -717,6 +718,8 @@ schedule_current_round (void *cls, | |||
717 | struct NSEPeerEntry *peer_entry = value; | 718 | struct NSEPeerEntry *peer_entry = value; |
718 | struct GNUNET_TIME_Relative delay; | 719 | struct GNUNET_TIME_Relative delay; |
719 | 720 | ||
721 | (void) cls; | ||
722 | (void) key; | ||
720 | if (NULL != peer_entry->transmit_task) | 723 | if (NULL != peer_entry->transmit_task) |
721 | { | 724 | { |
722 | GNUNET_SCHEDULER_cancel (peer_entry->transmit_task); | 725 | GNUNET_SCHEDULER_cancel (peer_entry->transmit_task); |
@@ -749,8 +752,8 @@ static void | |||
749 | update_flood_message (void *cls) | 752 | update_flood_message (void *cls) |
750 | { | 753 | { |
751 | struct GNUNET_TIME_Relative offset; | 754 | struct GNUNET_TIME_Relative offset; |
752 | unsigned int i; | ||
753 | 755 | ||
756 | (void) cls; | ||
754 | flood_task = NULL; | 757 | flood_task = NULL; |
755 | offset = GNUNET_TIME_absolute_get_remaining (next_timestamp); | 758 | offset = GNUNET_TIME_absolute_get_remaining (next_timestamp); |
756 | if (0 != offset.rel_value_us) | 759 | if (0 != offset.rel_value_us) |
@@ -780,7 +783,7 @@ update_flood_message (void *cls) | |||
780 | setup_flood_message (estimate_index, current_timestamp); | 783 | setup_flood_message (estimate_index, current_timestamp); |
781 | next_message.matching_bits = htonl (0); /* reset for 'next' round */ | 784 | next_message.matching_bits = htonl (0); /* reset for 'next' round */ |
782 | hop_count_max = 0; | 785 | hop_count_max = 0; |
783 | for (i = 0; i < HISTORY_SIZE; i++) | 786 | for (unsigned int i = 0; i < HISTORY_SIZE; i++) |
784 | hop_count_max = | 787 | hop_count_max = |
785 | GNUNET_MAX (ntohl (size_estimate_messages[i].hop_count), hop_count_max); | 788 | GNUNET_MAX (ntohl (size_estimate_messages[i].hop_count), hop_count_max); |
786 | GNUNET_CONTAINER_multipeermap_iterate (peers, &schedule_current_round, NULL); | 789 | GNUNET_CONTAINER_multipeermap_iterate (peers, &schedule_current_round, NULL); |
@@ -869,6 +872,7 @@ find_proof (void *cls) | |||
869 | struct GNUNET_HashCode result; | 872 | struct GNUNET_HashCode result; |
870 | unsigned int i; | 873 | unsigned int i; |
871 | 874 | ||
875 | (void) cls; | ||
872 | proof_task = NULL; | 876 | proof_task = NULL; |
873 | GNUNET_memcpy (&buf[sizeof (uint64_t)], | 877 | GNUNET_memcpy (&buf[sizeof (uint64_t)], |
874 | &my_identity, | 878 | &my_identity, |
@@ -967,6 +971,7 @@ update_flood_times (void *cls, | |||
967 | struct NSEPeerEntry *peer_entry = value; | 971 | struct NSEPeerEntry *peer_entry = value; |
968 | struct GNUNET_TIME_Relative delay; | 972 | struct GNUNET_TIME_Relative delay; |
969 | 973 | ||
974 | (void) key; | ||
970 | if (peer_entry == exclude) | 975 | if (peer_entry == exclude) |
971 | return GNUNET_OK; /* trigger of the update */ | 976 | return GNUNET_OK; /* trigger of the update */ |
972 | if (GNUNET_NO == peer_entry->previous_round) | 977 | if (GNUNET_NO == peer_entry->previous_round) |
@@ -1178,6 +1183,7 @@ handle_core_connect (void *cls, | |||
1178 | { | 1183 | { |
1179 | struct NSEPeerEntry *peer_entry; | 1184 | struct NSEPeerEntry *peer_entry; |
1180 | 1185 | ||
1186 | (void) cls; | ||
1181 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1187 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1182 | "Peer `%s' connected to us\n", | 1188 | "Peer `%s' connected to us\n", |
1183 | GNUNET_i2s (peer)); | 1189 | GNUNET_i2s (peer)); |
@@ -1217,6 +1223,7 @@ handle_core_disconnect (void *cls, | |||
1217 | { | 1223 | { |
1218 | struct NSEPeerEntry *pos = internal_cls; | 1224 | struct NSEPeerEntry *pos = internal_cls; |
1219 | 1225 | ||
1226 | (void) cls; | ||
1220 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1227 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1221 | "Peer `%s' disconnected from us\n", | 1228 | "Peer `%s' disconnected from us\n", |
1222 | GNUNET_i2s (peer)); | 1229 | GNUNET_i2s (peer)); |
@@ -1243,6 +1250,8 @@ handle_core_disconnect (void *cls, | |||
1243 | static void | 1250 | static void |
1244 | flush_comp_cb (void *cls, size_t size) | 1251 | flush_comp_cb (void *cls, size_t size) |
1245 | { | 1252 | { |
1253 | (void) cls; | ||
1254 | (void) size; | ||
1246 | GNUNET_TESTBED_LOGGER_disconnect (lh); | 1255 | GNUNET_TESTBED_LOGGER_disconnect (lh); |
1247 | lh = NULL; | 1256 | lh = NULL; |
1248 | } | 1257 | } |
@@ -1257,6 +1266,7 @@ flush_comp_cb (void *cls, size_t size) | |||
1257 | static void | 1266 | static void |
1258 | shutdown_task (void *cls) | 1267 | shutdown_task (void *cls) |
1259 | { | 1268 | { |
1269 | (void) cls; | ||
1260 | if (NULL != flood_task) | 1270 | if (NULL != flood_task) |
1261 | { | 1271 | { |
1262 | GNUNET_SCHEDULER_cancel (flood_task); | 1272 | GNUNET_SCHEDULER_cancel (flood_task); |
@@ -1324,6 +1334,7 @@ core_init (void *cls, const struct GNUNET_PeerIdentity *identity) | |||
1324 | struct GNUNET_TIME_Absolute now; | 1334 | struct GNUNET_TIME_Absolute now; |
1325 | struct GNUNET_TIME_Absolute prev_time; | 1335 | struct GNUNET_TIME_Absolute prev_time; |
1326 | 1336 | ||
1337 | (void) cls; | ||
1327 | if (NULL == identity) | 1338 | if (NULL == identity) |
1328 | { | 1339 | { |
1329 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Connection to core FAILED!\n"); | 1340 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Connection to core FAILED!\n"); |
@@ -1365,6 +1376,7 @@ core_init (void *cls, const struct GNUNET_PeerIdentity *identity) | |||
1365 | static void | 1376 | static void |
1366 | status_cb (void *cls, int status) | 1377 | status_cb (void *cls, int status) |
1367 | { | 1378 | { |
1379 | (void) cls; | ||
1368 | logger_test = NULL; | 1380 | logger_test = NULL; |
1369 | if (GNUNET_YES != status) | 1381 | if (GNUNET_YES != status) |
1370 | { | 1382 | { |
@@ -1402,6 +1414,8 @@ run (void *cls, | |||
1402 | char *proof; | 1414 | char *proof; |
1403 | struct GNUNET_CRYPTO_EddsaPrivateKey *pk; | 1415 | struct GNUNET_CRYPTO_EddsaPrivateKey *pk; |
1404 | 1416 | ||
1417 | (void) cls; | ||
1418 | (void) service; | ||
1405 | cfg = c; | 1419 | cfg = c; |
1406 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_time (cfg, | 1420 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_time (cfg, |
1407 | "NSE", | 1421 | "NSE", |
@@ -1524,6 +1538,8 @@ client_connect_cb (void *cls, | |||
1524 | struct GNUNET_SERVICE_Client *c, | 1538 | struct GNUNET_SERVICE_Client *c, |
1525 | struct GNUNET_MQ_Handle *mq) | 1539 | struct GNUNET_MQ_Handle *mq) |
1526 | { | 1540 | { |
1541 | (void) cls; | ||
1542 | (void) mq; | ||
1527 | return c; | 1543 | return c; |
1528 | } | 1544 | } |
1529 | 1545 | ||
@@ -1540,6 +1556,7 @@ client_disconnect_cb (void *cls, | |||
1540 | struct GNUNET_SERVICE_Client *c, | 1556 | struct GNUNET_SERVICE_Client *c, |
1541 | void *internal_cls) | 1557 | void *internal_cls) |
1542 | { | 1558 | { |
1559 | (void) cls; | ||
1543 | GNUNET_assert (c == internal_cls); | 1560 | GNUNET_assert (c == internal_cls); |
1544 | } | 1561 | } |
1545 | 1562 | ||
diff --git a/src/nse/nse_api.c b/src/nse/nse_api.c index e9eaada93..259be75ed 100644 --- a/src/nse/nse_api.c +++ b/src/nse/nse_api.c | |||
@@ -32,7 +32,7 @@ | |||
32 | #include "gnunet_nse_service.h" | 32 | #include "gnunet_nse_service.h" |
33 | #include "nse.h" | 33 | #include "nse.h" |
34 | 34 | ||
35 | #define LOG(kind,...) GNUNET_log_from (kind, "nse-api",__VA_ARGS__) | 35 | #define LOG(kind, ...) GNUNET_log_from (kind, "nse-api", __VA_ARGS__) |
36 | 36 | ||
37 | /** | 37 | /** |
38 | * Handle for talking with the NSE service. | 38 | * Handle for talking with the NSE service. |
@@ -68,7 +68,6 @@ struct GNUNET_NSE_Handle | |||
68 | * Closure to pass to @e recv_cb callback. | 68 | * Closure to pass to @e recv_cb callback. |
69 | */ | 69 | */ |
70 | void *recv_cb_cls; | 70 | void *recv_cb_cls; |
71 | |||
72 | }; | 71 | }; |
73 | 72 | ||
74 | 73 | ||
@@ -91,17 +90,15 @@ reconnect (void *cls); | |||
91 | * @param error error code | 90 | * @param error error code |
92 | */ | 91 | */ |
93 | static void | 92 | static void |
94 | mq_error_handler (void *cls, | 93 | mq_error_handler (void *cls, enum GNUNET_MQ_Error error) |
95 | enum GNUNET_MQ_Error error) | ||
96 | { | 94 | { |
97 | struct GNUNET_NSE_Handle *h = cls; | 95 | struct GNUNET_NSE_Handle *h = cls; |
98 | 96 | ||
97 | (void) error; | ||
99 | GNUNET_MQ_destroy (h->mq); | 98 | GNUNET_MQ_destroy (h->mq); |
100 | h->mq = NULL; | 99 | h->mq = NULL; |
101 | h->reconnect_task | 100 | h->reconnect_task = |
102 | = GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, | 101 | GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, &reconnect, h); |
103 | &reconnect, | ||
104 | h); | ||
105 | h->reconnect_delay = GNUNET_TIME_STD_BACKOFF (h->reconnect_delay); | 102 | h->reconnect_delay = GNUNET_TIME_STD_BACKOFF (h->reconnect_delay); |
106 | } | 103 | } |
107 | 104 | ||
@@ -114,8 +111,7 @@ mq_error_handler (void *cls, | |||
114 | * @param client_msg message received | 111 | * @param client_msg message received |
115 | */ | 112 | */ |
116 | static void | 113 | static void |
117 | handle_estimate (void *cls, | 114 | handle_estimate (void *cls, const struct GNUNET_NSE_ClientMessage *client_msg) |
118 | const struct GNUNET_NSE_ClientMessage *client_msg) | ||
119 | { | 115 | { |
120 | struct GNUNET_NSE_Handle *h = cls; | 116 | struct GNUNET_NSE_Handle *h = cls; |
121 | 117 | ||
@@ -123,7 +119,7 @@ handle_estimate (void *cls, | |||
123 | h->recv_cb (h->recv_cb_cls, | 119 | h->recv_cb (h->recv_cb_cls, |
124 | GNUNET_TIME_absolute_ntoh (client_msg->timestamp), | 120 | GNUNET_TIME_absolute_ntoh (client_msg->timestamp), |
125 | GNUNET_ntoh_double (client_msg->size_estimate), | 121 | GNUNET_ntoh_double (client_msg->size_estimate), |
126 | GNUNET_ntoh_double (client_msg->std_deviation)); | 122 | GNUNET_ntoh_double (client_msg->std_deviation)); |
127 | } | 123 | } |
128 | 124 | ||
129 | 125 | ||
@@ -136,13 +132,12 @@ static void | |||
136 | reconnect (void *cls) | 132 | reconnect (void *cls) |
137 | { | 133 | { |
138 | struct GNUNET_NSE_Handle *h = cls; | 134 | struct GNUNET_NSE_Handle *h = cls; |
139 | struct GNUNET_MQ_MessageHandler handlers[] = { | 135 | struct GNUNET_MQ_MessageHandler handlers[] = |
140 | GNUNET_MQ_hd_fixed_size (estimate, | 136 | {GNUNET_MQ_hd_fixed_size (estimate, |
141 | GNUNET_MESSAGE_TYPE_NSE_ESTIMATE, | 137 | GNUNET_MESSAGE_TYPE_NSE_ESTIMATE, |
142 | struct GNUNET_NSE_ClientMessage, | 138 | struct GNUNET_NSE_ClientMessage, |
143 | h), | 139 | h), |
144 | GNUNET_MQ_handler_end () | 140 | GNUNET_MQ_handler_end ()}; |
145 | }; | ||
146 | struct GNUNET_MessageHeader *msg; | 141 | struct GNUNET_MessageHeader *msg; |
147 | struct GNUNET_MQ_Envelope *env; | 142 | struct GNUNET_MQ_Envelope *env; |
148 | 143 | ||
@@ -150,17 +145,11 @@ reconnect (void *cls) | |||
150 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 145 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
151 | "Connecting to network size estimation service.\n"); | 146 | "Connecting to network size estimation service.\n"); |
152 | GNUNET_assert (NULL == h->mq); | 147 | GNUNET_assert (NULL == h->mq); |
153 | h->mq = GNUNET_CLIENT_connect (h->cfg, | 148 | h->mq = GNUNET_CLIENT_connect (h->cfg, "nse", handlers, &mq_error_handler, h); |
154 | "nse", | ||
155 | handlers, | ||
156 | &mq_error_handler, | ||
157 | h); | ||
158 | if (NULL == h->mq) | 149 | if (NULL == h->mq) |
159 | return; | 150 | return; |
160 | env = GNUNET_MQ_msg (msg, | 151 | env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_NSE_START); |
161 | GNUNET_MESSAGE_TYPE_NSE_START); | 152 | GNUNET_MQ_send (h->mq, env); |
162 | GNUNET_MQ_send (h->mq, | ||
163 | env); | ||
164 | } | 153 | } |
165 | 154 | ||
166 | 155 | ||