aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-12-20 11:51:11 +0100
committerChristian Grothoff <christian@grothoff.org>2020-12-20 11:51:11 +0100
commite60f76eab3447fba5982d30f0e4e7ebecf4edc0b (patch)
tree1baf70b171535f7f789bc33bd59a3f7e4deb2051 /src/transport
parent0876272a77b7fbcf8e662dccf463e5fca9ea9acf (diff)
downloadgnunet-e60f76eab3447fba5982d30f0e4e7ebecf4edc0b.tar.gz
gnunet-e60f76eab3447fba5982d30f0e4e7ebecf4edc0b.zip
-fix misc compiler warnings
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/test_communicator_basic.c124
1 files changed, 74 insertions, 50 deletions
diff --git a/src/transport/test_communicator_basic.c b/src/transport/test_communicator_basic.c
index 10c942daa..fcdbb4b0e 100644
--- a/src/transport/test_communicator_basic.c
+++ b/src/transport/test_communicator_basic.c
@@ -133,12 +133,12 @@ static struct GNUNET_TIME_Relative duration;
133 133
134 134
135static void 135static void
136communicator_available_cb (void *cls, 136communicator_available_cb (
137 struct 137 void *cls,
138 GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle 138 struct
139 *tc_h, 139 GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h,
140 enum GNUNET_TRANSPORT_CommunicatorCharacteristics cc, 140 enum GNUNET_TRANSPORT_CommunicatorCharacteristics cc,
141 char *address_prefix) 141 char *address_prefix)
142{ 142{
143 LOG (GNUNET_ERROR_TYPE_INFO, 143 LOG (GNUNET_ERROR_TYPE_INFO,
144 "Communicator available. (cc: %u, prefix: %s)\n", 144 "Communicator available. (cc: %u, prefix: %s)\n",
@@ -146,10 +146,11 @@ communicator_available_cb (void *cls,
146 address_prefix); 146 address_prefix);
147} 147}
148 148
149
149static void 150static void
150open_queue (void *cls) 151open_queue (void *cls)
151{ 152{
152 char *address = cls; 153 const char *address = cls;
153 154
154 if (NULL != tc_hs[PEER_A]->c_mq) 155 if (NULL != tc_hs[PEER_A]->c_mq)
155 { 156 {
@@ -162,30 +163,32 @@ open_queue (void *cls)
162 { 163 {
163 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, 164 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
164 &open_queue, 165 &open_queue,
165 address); 166 (void *) address);
166 } 167 }
167} 168}
168 169
170
169static void 171static void
170add_address_cb (void *cls, 172add_address_cb (
171 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle * 173 void *cls,
172 tc_h, 174 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h,
173 const char *address, 175 const char *address,
174 struct GNUNET_TIME_Relative expiration, 176 struct GNUNET_TIME_Relative expiration,
175 uint32_t aid, 177 uint32_t aid,
176 enum GNUNET_NetworkType nt) 178 enum GNUNET_NetworkType nt)
177{ 179{
178 LOG (GNUNET_ERROR_TYPE_DEBUG, 180 LOG (GNUNET_ERROR_TYPE_DEBUG,
179 "New address. (addr: %s, expir: %" PRIu32 ", ID: %" PRIu32 ", nt: %u\n", 181 "New address. (addr: %s, expir: %s, ID: %" PRIu32 ", nt: %u\n",
180 address, 182 address,
181 expiration.rel_value_us, 183 GNUNET_STRINGS_relative_time_to_string (expiration,
184 GNUNET_NO),
182 aid, 185 aid,
183 nt); 186 (int) nt);
184 // addresses[1] = GNUNET_strdup (address); 187 // addresses[1] = GNUNET_strdup (address);
185 if ((0 == strcmp ((char*) cls, cfg_peers_name[PEER_B])) && 188 if ((0 == strcmp ((char*) cls, cfg_peers_name[PEER_B])) &&
186 (GNUNET_NO == queue_est)) 189 (GNUNET_NO == queue_est))
187 { 190 {
188 open_queue (address); 191 open_queue ((void *) address);
189 } 192 }
190} 193}
191 194
@@ -202,12 +205,13 @@ add_address_cb (void *cls,
202 * #GNUNET_NO if queue will not be established (bogous address) 205 * #GNUNET_NO if queue will not be established (bogous address)
203 */ 206 */
204static void 207static void
205queue_create_reply_cb (void *cls, 208queue_create_reply_cb (
206 struct 209 void *cls,
207 GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle * 210 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h,
208 tc_h, 211 int will_try)
209 int will_try)
210{ 212{
213 (void) cls;
214 (void) tc_h;
211 if (GNUNET_YES == will_try) 215 if (GNUNET_YES == will_try)
212 LOG (GNUNET_ERROR_TYPE_DEBUG, 216 LOG (GNUNET_ERROR_TYPE_DEBUG,
213 "Queue will be established!\n"); 217 "Queue will be established!\n");
@@ -223,6 +227,9 @@ handle_backchannel_cb (void *cls,
223 struct GNUNET_PeerIdentity *pid) 227 struct GNUNET_PeerIdentity *pid)
224{ 228{
225 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls; 229 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls;
230
231 (void) tc_h;
232 (void) msg;
226 LOG (GNUNET_ERROR_TYPE_DEBUG, "Handling BC message...\n"); 233 LOG (GNUNET_ERROR_TYPE_DEBUG, "Handling BC message...\n");
227 if (0 == memcmp (&peer_id[PEER_A], pid, sizeof (*pid))) 234 if (0 == memcmp (&peer_id[PEER_A], pid, sizeof (*pid)))
228 return tc_hs[PEER_A]; 235 return tc_hs[PEER_A];
@@ -267,6 +274,9 @@ latency_timeout (void *cls)
267 274
268 switch (phase) 275 switch (phase)
269 { 276 {
277 case TP_INIT:
278 GNUNET_assert (0);
279 break;
270 case TP_BURST_SHORT: 280 case TP_BURST_SHORT:
271 num_sent = num_sent_short; 281 num_sent = num_sent_short;
272 num_received = num_received_short; 282 num_received = num_received_short;
@@ -287,6 +297,7 @@ latency_timeout (void *cls)
287 GNUNET_SCHEDULER_shutdown (); 297 GNUNET_SCHEDULER_shutdown ();
288} 298}
289 299
300
290/*static void 301/*static void
291 size_test (void *cls);*/ 302 size_test (void *cls);*/
292 303
@@ -298,7 +309,7 @@ size_test (void *cls)
298 309
299 LOG (GNUNET_ERROR_TYPE_DEBUG, 310 LOG (GNUNET_ERROR_TYPE_DEBUG,
300 "size_test_cb %u\n", 311 "size_test_cb %u\n",
301 num_sent_size); 312 (unsigned int) num_sent_size);
302 GNUNET_assert (TP_SIZE_CHECK == phase); 313 GNUNET_assert (TP_SIZE_CHECK == phase);
303 if (LONG_MESSAGE_SIZE != long_message_size) 314 if (LONG_MESSAGE_SIZE != long_message_size)
304 max_size = long_message_size; 315 max_size = long_message_size;
@@ -320,6 +331,7 @@ size_test (void *cls)
320 TIMEOUT_MULTIPLIER)); 331 TIMEOUT_MULTIPLIER));
321} 332}
322 333
334
323/*static void 335/*static void
324size_test (void *cls) 336size_test (void *cls)
325{ 337{
@@ -338,8 +350,8 @@ long_test_cb (void *cls)
338 350
339 LOG (GNUNET_ERROR_TYPE_DEBUG, 351 LOG (GNUNET_ERROR_TYPE_DEBUG,
340 "long_test_cb %u/%u\n", 352 "long_test_cb %u/%u\n",
341 num_sent_long, 353 (unsigned int) num_sent_long,
342 num_received_long); 354 (unsigned int) num_received_long);
343 payload = make_payload (long_message_size); 355 payload = make_payload (long_message_size);
344 num_sent_long++; 356 num_sent_long++;
345 GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc, 357 GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc,
@@ -359,6 +371,7 @@ long_test_cb (void *cls)
359 TIMEOUT_MULTIPLIER)); 371 TIMEOUT_MULTIPLIER));
360} 372}
361 373
374
362static void 375static void
363long_test (void *cls) 376long_test (void *cls)
364{ 377{
@@ -370,6 +383,7 @@ long_test (void *cls)
370 NULL); 383 NULL);
371} 384}
372 385
386
373static void 387static void
374short_test (void *cls); 388short_test (void *cls);
375 389
@@ -380,27 +394,26 @@ short_test_cb (void *cls)
380 394
381 LOG (GNUNET_ERROR_TYPE_DEBUG, 395 LOG (GNUNET_ERROR_TYPE_DEBUG,
382 "short_test_cb %u/%u\n", 396 "short_test_cb %u/%u\n",
383 num_sent_short, 397 (unsigned int) num_sent_short,
384 num_received_short); 398 (unsigned int) num_received_short);
385 payload = make_payload (SHORT_MESSAGE_SIZE); 399 payload = make_payload (SHORT_MESSAGE_SIZE);
386 num_sent_short++; 400 num_sent_short++;
387 GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc, 401 GNUNET_TRANSPORT_TESTING_transport_communicator_send (
388 ((BURST_PACKETS 402 my_tc,
389 * 0.91 == 403 ( (BURST_PACKETS * 0.91 == num_received_short) ||
390 num_received_short) || 404 (BURST_PACKETS == num_sent_short) )
391 (BURST_PACKETS == 405 ? NULL
392 num_sent_short)) 406 : &short_test,
393 ? NULL 407 NULL,
394 : &short_test, 408 payload,
395 NULL, 409 SHORT_MESSAGE_SIZE);
396 payload,
397 SHORT_MESSAGE_SIZE);
398 GNUNET_free (payload); 410 GNUNET_free (payload);
399 timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply ( 411 timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply (
400 GNUNET_TIME_UNIT_SECONDS, 412 GNUNET_TIME_UNIT_SECONDS,
401 TIMEOUT_MULTIPLIER)); 413 TIMEOUT_MULTIPLIER));
402} 414}
403 415
416
404static void 417static void
405short_test (void *cls) 418short_test (void *cls)
406{ 419{
@@ -496,10 +509,14 @@ update_avg_latency (const char*payload)
496 ts = GNUNET_TIME_absolute_ntoh (*ts_n); 509 ts = GNUNET_TIME_absolute_ntoh (*ts_n);
497 latency = GNUNET_TIME_absolute_get_duration (ts); 510 latency = GNUNET_TIME_absolute_get_duration (ts);
498 LOG (GNUNET_ERROR_TYPE_DEBUG, 511 LOG (GNUNET_ERROR_TYPE_DEBUG,
499 "Latency of received packet: %u\n", 512 "Latency of received packet: %s\n",
500 latency); 513 GNUNET_STRINGS_relative_time_to_string (latency,
514 GNUNET_YES));
501 switch (phase) 515 switch (phase)
502 { 516 {
517 case TP_INIT:
518 GNUNET_assert (0);
519 break;
503 case TP_BURST_SHORT: 520 case TP_BURST_SHORT:
504 num_received = num_received_short; 521 num_received = num_received_short;
505 break; 522 break;
@@ -518,6 +535,8 @@ update_avg_latency (const char*payload)
518 535
519} 536}
520 537
538
539static void
521process_statistics_box_done (void *cls, int success) 540process_statistics_box_done (void *cls, int success)
522{ 541{
523 if (NULL != box_stats) 542 if (NULL != box_stats)
@@ -530,6 +549,8 @@ process_statistics_box_done (void *cls, int success)
530 } 549 }
531} 550}
532 551
552
553static void
533process_statistics_rekey_done (void *cls, int success) 554process_statistics_rekey_done (void *cls, int success)
534{ 555{
535 if (NULL != rekey_stats) 556 if (NULL != rekey_stats)
@@ -542,6 +563,7 @@ process_statistics_rekey_done (void *cls, int success)
542 } 563 }
543} 564}
544 565
566
545static int 567static int
546process_statistics (void *cls, 568process_statistics (void *cls,
547 const char *subsystem, 569 const char *subsystem,
@@ -562,7 +584,7 @@ process_statistics (void *cls,
562 "No successful rekeying!\n"); 584 "No successful rekeying!\n");
563 GNUNET_SCHEDULER_shutdown (); 585 GNUNET_SCHEDULER_shutdown ();
564 } 586 }
565 if ((0 == strcmp ("backchannel", test_name)) && 587 if ((0 == strcmp ("backchannel", test_name)) &&
566 (0 == strcmp ( 588 (0 == strcmp (
567 "# messages decrypted with BOX", 589 "# messages decrypted with BOX",
568 name)) 590 name))
@@ -573,7 +595,7 @@ process_statistics (void *cls,
573 "Not enough BOX messages!\n"); 595 "Not enough BOX messages!\n");
574 GNUNET_SCHEDULER_shutdown (); 596 GNUNET_SCHEDULER_shutdown ();
575 } 597 }
576 if ((0 == strcmp ("rekey", test_name)) && 598 if ((0 == strcmp ("rekey", test_name)) &&
577 (0 == strcmp ( 599 (0 == strcmp (
578 "# messages decrypted with BOX", 600 "# messages decrypted with BOX",
579 name)) 601 name))
@@ -587,6 +609,7 @@ process_statistics (void *cls,
587 return GNUNET_OK; 609 return GNUNET_OK;
588} 610}
589 611
612
590/** 613/**
591 * @brief Handle an incoming message 614 * @brief Handle an incoming message
592 * 615 *
@@ -723,8 +746,8 @@ incoming_message_cb (void *cls,
723 short_test (NULL); 746 short_test (NULL);
724 break; 747 break;
725 } 748 }
726 if ((0 == strcmp ("rekey", test_name))||(0 == strcmp ("backchannel", 749 if ((0 == strcmp ("rekey", test_name)) || (0 == strcmp ("backchannel",
727 test_name)) ) 750 test_name)) )
728 { 751 {
729 if (NULL != box_stats) 752 if (NULL != box_stats)
730 GNUNET_STATISTICS_get_cancel (box_stats); 753 GNUNET_STATISTICS_get_cancel (box_stats);
@@ -743,7 +766,8 @@ incoming_message_cb (void *cls,
743 &process_statistics, 766 &process_statistics,
744 NULL); 767 NULL);
745 } 768 }
746 else{ 769 else
770 {
747 LOG (GNUNET_ERROR_TYPE_DEBUG, 771 LOG (GNUNET_ERROR_TYPE_DEBUG,
748 "Finished\n"); 772 "Finished\n");
749 GNUNET_SCHEDULER_shutdown (); 773 GNUNET_SCHEDULER_shutdown ();
@@ -759,7 +783,7 @@ static void
759do_shutdown (void *cls) 783do_shutdown (void *cls)
760{ 784{
761 LOG (GNUNET_ERROR_TYPE_DEBUG, 785 LOG (GNUNET_ERROR_TYPE_DEBUG,
762 "shuting down test.\"); 786 "shuting down test.\n");
763 787
764 if (NULL != box_stats) 788 if (NULL != box_stats)
765 { 789 {
@@ -810,8 +834,8 @@ run (void *cls)
810 &handle_backchannel_cb, 834 &handle_backchannel_cb,
811 cfg_peers_name[i]); /* cls */ 835 cfg_peers_name[i]); /* cls */
812 836
813 if ((0 == strcmp ("rekey", test_name))||(0 == strcmp ("backchannel", 837 if ((0 == strcmp ("rekey", test_name)) || (0 == strcmp ("backchannel",
814 test_name)) ) 838 test_name)) )
815 { 839 {
816 stats[i] = GNUNET_STATISTICS_create ("C-UDP", 840 stats[i] = GNUNET_STATISTICS_create ("C-UDP",
817 cfg_peers[i]); 841 cfg_peers[i]);