diff options
author | t3sserakt <t3ss@posteo.de> | 2021-01-05 13:35:49 +0100 |
---|---|---|
committer | t3sserakt <t3ss@posteo.de> | 2021-01-05 13:35:49 +0100 |
commit | fac97cea47df432d6418e0399e799e47057e89d7 (patch) | |
tree | 33412732a2e78342a07649d70c9eff0b706709d2 /src/transport | |
parent | 5affc9ad078e8d90c47a2972d67cd9d65529792d (diff) | |
parent | fd30e4bf7ebd4d628f04e0158c527607870759d4 (diff) | |
download | gnunet-fac97cea47df432d6418e0399e799e47057e89d7.tar.gz gnunet-fac97cea47df432d6418e0399e799e47057e89d7.zip |
Merge branch 'master' of ssh://gnunet.org/gnunet
Diffstat (limited to 'src/transport')
-rw-r--r-- | src/transport/Makefile.am | 6 | ||||
-rw-r--r-- | src/transport/gnunet-communicator-udp.c | 89 | ||||
-rw-r--r-- | src/transport/test_communicator_basic.c | 149 |
3 files changed, 145 insertions, 99 deletions
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am index 0f9d40e13..a2fc3811e 100644 --- a/src/transport/Makefile.am +++ b/src/transport/Makefile.am | |||
@@ -131,8 +131,9 @@ noinst_PROGRAMS = \ | |||
131 | $(WLAN_BIN_RECEIVER) | 131 | $(WLAN_BIN_RECEIVER) |
132 | 132 | ||
133 | if HAVE_TESTING | 133 | if HAVE_TESTING |
134 | TESTING_LIBS = libgnunettransporttesting.la \ | 134 | TESTING_LIBS = \ |
135 | libgnunettransporttesting2.la | 135 | libgnunettransporttesting.la \ |
136 | libgnunettransporttesting2.la | ||
136 | endif | 137 | endif |
137 | 138 | ||
138 | lib_LTLIBRARIES = \ | 139 | lib_LTLIBRARIES = \ |
@@ -174,6 +175,7 @@ libgnunettransporttesting2_la_LIBADD = \ | |||
174 | libgnunettransport.la \ | 175 | libgnunettransport.la \ |
175 | libgnunettransportapplication.la \ | 176 | libgnunettransportapplication.la \ |
176 | libgnunettransportcore.la \ | 177 | libgnunettransportcore.la \ |
178 | $(top_builddir)/src/arm/libgnunetarm.la \ | ||
177 | $(top_builddir)/src/testing/libgnunettesting.la \ | 179 | $(top_builddir)/src/testing/libgnunettesting.la \ |
178 | $(top_builddir)/src/ats/libgnunetats.la \ | 180 | $(top_builddir)/src/ats/libgnunetats.la \ |
179 | $(top_builddir)/src/hello/libgnunethello.la \ | 181 | $(top_builddir)/src/hello/libgnunethello.la \ |
diff --git a/src/transport/gnunet-communicator-udp.c b/src/transport/gnunet-communicator-udp.c index 1f87ba6d4..018da8f0e 100644 --- a/src/transport/gnunet-communicator-udp.c +++ b/src/transport/gnunet-communicator-udp.c | |||
@@ -1464,7 +1464,7 @@ destroy_all_secrets (struct SharedSecret *ss, int withoutKce) | |||
1464 | } | 1464 | } |
1465 | 1465 | ||
1466 | pos = ss_start; | 1466 | pos = ss_start; |
1467 | while ( NULL != pos) | 1467 | while (NULL != pos) |
1468 | { | 1468 | { |
1469 | ss_to_destroy = pos; | 1469 | ss_to_destroy = pos; |
1470 | pos = pos->next; | 1470 | pos = pos->next; |
@@ -1484,6 +1484,7 @@ destroy_all_secrets (struct SharedSecret *ss, int withoutKce) | |||
1484 | "Finished destroy all.\n"); | 1484 | "Finished destroy all.\n"); |
1485 | } | 1485 | } |
1486 | 1486 | ||
1487 | |||
1487 | static void | 1488 | static void |
1488 | add_acks (struct SharedSecret *ss, int acks_to_add) | 1489 | add_acks (struct SharedSecret *ss, int acks_to_add) |
1489 | { | 1490 | { |
@@ -1520,6 +1521,7 @@ add_acks (struct SharedSecret *ss, int acks_to_add) | |||
1520 | destroy_all_secrets (ss, GNUNET_YES); | 1521 | destroy_all_secrets (ss, GNUNET_YES); |
1521 | } | 1522 | } |
1522 | 1523 | ||
1524 | |||
1523 | static uint32_t | 1525 | static uint32_t |
1524 | reset_rekey_kces (struct ReceiverAddress *receiver, | 1526 | reset_rekey_kces (struct ReceiverAddress *receiver, |
1525 | uint32_t acks_to_add) | 1527 | uint32_t acks_to_add) |
@@ -1550,6 +1552,7 @@ reset_rekey_kces (struct ReceiverAddress *receiver, | |||
1550 | return acks_to_add; | 1552 | return acks_to_add; |
1551 | } | 1553 | } |
1552 | 1554 | ||
1555 | |||
1553 | static void | 1556 | static void |
1554 | add_acks_rekey (struct ReceiverAddress *receiver) | 1557 | add_acks_rekey (struct ReceiverAddress *receiver) |
1555 | { | 1558 | { |
@@ -1575,6 +1578,7 @@ add_acks_rekey (struct ReceiverAddress *receiver) | |||
1575 | GNUNET_NO); | 1578 | GNUNET_NO); |
1576 | } | 1579 | } |
1577 | 1580 | ||
1581 | |||
1578 | /** | 1582 | /** |
1579 | * We received an ACK for @a pid. Check if it is for | 1583 | * We received an ACK for @a pid. Check if it is for |
1580 | * the receiver in @a value and if so, handle it and | 1584 | * the receiver in @a value and if so, handle it and |
@@ -1736,7 +1740,6 @@ try_handle_plaintext (struct SenderAddress *sender, | |||
1736 | } | 1740 | } |
1737 | 1741 | ||
1738 | 1742 | ||
1739 | |||
1740 | static void | 1743 | static void |
1741 | kce_generate_cb (void *cls) | 1744 | kce_generate_cb (void *cls) |
1742 | { | 1745 | { |
@@ -1771,6 +1774,7 @@ kce_generate_cb (void *cls) | |||
1771 | 1774 | ||
1772 | } | 1775 | } |
1773 | 1776 | ||
1777 | |||
1774 | static void | 1778 | static void |
1775 | kce_generate_rekey_cb (void *cls) | 1779 | kce_generate_rekey_cb (void *cls) |
1776 | { | 1780 | { |
@@ -1870,7 +1874,8 @@ consider_ss_ack (struct SharedSecret *ss, int initial) | |||
1870 | kce_task_finished = GNUNET_NO; | 1874 | kce_task_finished = GNUNET_NO; |
1871 | } | 1875 | } |
1872 | } | 1876 | } |
1873 | else if ((NULL == kce_task) && ((KCN_THRESHOLD > ss->sender->acks_available)|| | 1877 | else if ((NULL == kce_task) && ((KCN_THRESHOLD > |
1878 | ss->sender->acks_available) || | ||
1874 | (GNUNET_YES == ss->sender->rekeying) || | 1879 | (GNUNET_YES == ss->sender->rekeying) || |
1875 | (ss->sender->num_secrets > MAX_SECRETS) )) | 1880 | (ss->sender->num_secrets > MAX_SECRETS) )) |
1876 | { | 1881 | { |
@@ -1945,13 +1950,15 @@ decrypt_box (const struct UDPBox *box, | |||
1945 | } | 1950 | } |
1946 | else if (GNUNET_NO == box->rekeying) | 1951 | else if (GNUNET_NO == box->rekeying) |
1947 | consider_ss_ack (ss, GNUNET_NO); | 1952 | consider_ss_ack (ss, GNUNET_NO); |
1948 | else{ | 1953 | else |
1954 | { | ||
1949 | ss->sender->rekeying = GNUNET_YES; | 1955 | ss->sender->rekeying = GNUNET_YES; |
1950 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1956 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1951 | "Got Box: Receiver doing rekeying.\n"); | 1957 | "Got Box: Receiver doing rekeying.\n"); |
1952 | } | 1958 | } |
1953 | } | 1959 | } |
1954 | 1960 | ||
1961 | |||
1955 | /** | 1962 | /** |
1956 | * We received a @a rekey with matching @a kce. Decrypt and process it. | 1963 | * We received a @a rekey with matching @a kce. Decrypt and process it. |
1957 | * | 1964 | * |
@@ -2039,6 +2046,7 @@ decrypt_rekey (const struct UDPRekey *rekey, | |||
2039 | 2046 | ||
2040 | } | 2047 | } |
2041 | 2048 | ||
2049 | |||
2042 | /** | 2050 | /** |
2043 | * Closure for #find_sender_by_address() | 2051 | * Closure for #find_sender_by_address() |
2044 | */ | 2052 | */ |
@@ -2249,15 +2257,16 @@ sock_read (void *cls) | |||
2249 | box = (const struct UDPBox *) buf; | 2257 | box = (const struct UDPBox *) buf; |
2250 | kce = GNUNET_CONTAINER_multishortmap_get (key_cache, &rekey->kid); | 2258 | kce = GNUNET_CONTAINER_multishortmap_get (key_cache, &rekey->kid); |
2251 | 2259 | ||
2252 | if ((GNUNET_YES == box->rekeying)||(GNUNET_NO == box->rekeying)) | 2260 | if ((GNUNET_YES == box->rekeying) || (GNUNET_NO == box->rekeying)) |
2253 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2261 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2254 | "UDPRekey has rekeying %u\n", | 2262 | "UDPRekey has rekeying %u\n", |
2255 | box->rekeying); | 2263 | box->rekeying); |
2256 | else | 2264 | else |
2257 | do_decrypt = GNUNET_YES; | 2265 | do_decrypt = GNUNET_YES; |
2258 | 2266 | ||
2259 | if ((GNUNET_YES == do_decrypt)&& (NULL != kce) && (GNUNET_YES == | 2267 | if ((GNUNET_YES == do_decrypt) && (NULL != kce) && (GNUNET_YES == |
2260 | kce->ss->sender->rekeying)) | 2268 | kce->ss->sender-> |
2269 | rekeying)) | ||
2261 | { | 2270 | { |
2262 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2271 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2263 | "UDPRekey with kid %s\n", | 2272 | "UDPRekey with kid %s\n", |
@@ -2400,7 +2409,8 @@ sock_read (void *cls) | |||
2400 | } | 2409 | } |
2401 | else if (GNUNET_NO == kx->rekeying) | 2410 | else if (GNUNET_NO == kx->rekeying) |
2402 | consider_ss_ack (ss, GNUNET_YES); | 2411 | consider_ss_ack (ss, GNUNET_YES); |
2403 | else{ | 2412 | else |
2413 | { | ||
2404 | ss->sender->rekeying = GNUNET_YES; | 2414 | ss->sender->rekeying = GNUNET_YES; |
2405 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2415 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2406 | "Got KX: Receiver doing rekeying.\n"); | 2416 | "Got KX: Receiver doing rekeying.\n"); |
@@ -2664,6 +2674,7 @@ mq_send_kx (struct GNUNET_MQ_Handle *mq, | |||
2664 | GNUNET_MQ_impl_send_continue (mq); | 2674 | GNUNET_MQ_impl_send_continue (mq); |
2665 | } | 2675 | } |
2666 | 2676 | ||
2677 | |||
2667 | static void | 2678 | static void |
2668 | check_for_rekeying (struct ReceiverAddress *receiver, struct UDPBox *box) | 2679 | check_for_rekeying (struct ReceiverAddress *receiver, struct UDPBox *box) |
2669 | { | 2680 | { |
@@ -2687,8 +2698,8 @@ check_for_rekeying (struct ReceiverAddress *receiver, struct UDPBox *box) | |||
2687 | rt.rel_value_us, | 2698 | rt.rel_value_us, |
2688 | receiver->rekey_timeout.abs_value_us); | 2699 | receiver->rekey_timeout.abs_value_us); |
2689 | 2700 | ||
2690 | if ((0 == rt.rel_value_us)||(receiver->rekey_send_bytes > | 2701 | if ((0 == rt.rel_value_us) || (receiver->rekey_send_bytes > |
2691 | rekey_max_bytes) ) | 2702 | rekey_max_bytes) ) |
2692 | { | 2703 | { |
2693 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2704 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2694 | "Bytes send %lu greater than %llu max bytes\n.", | 2705 | "Bytes send %lu greater than %llu max bytes\n.", |
@@ -2716,6 +2727,7 @@ check_for_rekeying (struct ReceiverAddress *receiver, struct UDPBox *box) | |||
2716 | } | 2727 | } |
2717 | } | 2728 | } |
2718 | 2729 | ||
2730 | |||
2719 | static void | 2731 | static void |
2720 | send_UDPRekey (struct ReceiverAddress *receiver, struct SharedSecret *ss) | 2732 | send_UDPRekey (struct ReceiverAddress *receiver, struct SharedSecret *ss) |
2721 | { | 2733 | { |
@@ -3283,14 +3295,17 @@ do_shutdown (void *cls) | |||
3283 | } | 3295 | } |
3284 | if (NULL != udp_sock) | 3296 | if (NULL != udp_sock) |
3285 | { | 3297 | { |
3286 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (udp_sock)); | 3298 | GNUNET_break (GNUNET_OK == |
3299 | GNUNET_NETWORK_socket_close (udp_sock)); | ||
3287 | udp_sock = NULL; | 3300 | udp_sock = NULL; |
3288 | } | 3301 | } |
3289 | GNUNET_CONTAINER_multipeermap_iterate (receivers, | 3302 | GNUNET_CONTAINER_multipeermap_iterate (receivers, |
3290 | &get_receiver_delete_it, | 3303 | &get_receiver_delete_it, |
3291 | NULL); | 3304 | NULL); |
3292 | GNUNET_CONTAINER_multipeermap_destroy (receivers); | 3305 | GNUNET_CONTAINER_multipeermap_destroy (receivers); |
3293 | GNUNET_CONTAINER_multipeermap_iterate (senders, &get_sender_delete_it, NULL); | 3306 | GNUNET_CONTAINER_multipeermap_iterate (senders, |
3307 | &get_sender_delete_it, | ||
3308 | NULL); | ||
3294 | GNUNET_CONTAINER_multipeermap_destroy (senders); | 3309 | GNUNET_CONTAINER_multipeermap_destroy (senders); |
3295 | GNUNET_CONTAINER_multishortmap_destroy (key_cache); | 3310 | GNUNET_CONTAINER_multishortmap_destroy (key_cache); |
3296 | GNUNET_CONTAINER_heap_destroy (senders_heap); | 3311 | GNUNET_CONTAINER_heap_destroy (senders_heap); |
@@ -3438,25 +3453,29 @@ ifc_broadcast (void *cls) | |||
3438 | static int no = 0; | 3453 | static int no = 0; |
3439 | ssize_t sent; | 3454 | ssize_t sent; |
3440 | 3455 | ||
3441 | if (GNUNET_OK != GNUNET_NETWORK_socket_setsockopt (udp_sock, | 3456 | if (GNUNET_OK != |
3442 | SOL_SOCKET, | 3457 | GNUNET_NETWORK_socket_setsockopt (udp_sock, |
3443 | SO_BROADCAST, | 3458 | SOL_SOCKET, |
3444 | &yes, | 3459 | SO_BROADCAST, |
3445 | sizeof(int))) | 3460 | &yes, |
3446 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "setsockopt"); | 3461 | sizeof(int))) |
3462 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, | ||
3463 | "setsockopt"); | ||
3447 | sent = GNUNET_NETWORK_socket_sendto (udp_sock, | 3464 | sent = GNUNET_NETWORK_socket_sendto (udp_sock, |
3448 | &bi->bcm, | 3465 | &bi->bcm, |
3449 | sizeof(bi->bcm), | 3466 | sizeof(bi->bcm), |
3450 | bi->ba, | 3467 | bi->ba, |
3451 | bi->salen); | 3468 | bi->salen); |
3452 | if (-1 == sent) | 3469 | if (-1 == sent) |
3453 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "sendto"); | 3470 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, |
3471 | "sendto"); | ||
3454 | if (GNUNET_OK != GNUNET_NETWORK_socket_setsockopt (udp_sock, | 3472 | if (GNUNET_OK != GNUNET_NETWORK_socket_setsockopt (udp_sock, |
3455 | SOL_SOCKET, | 3473 | SOL_SOCKET, |
3456 | SO_BROADCAST, | 3474 | SO_BROADCAST, |
3457 | &no, | 3475 | &no, |
3458 | sizeof(int))) | 3476 | sizeof(int))) |
3459 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "setsockopt"); | 3477 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, |
3478 | "setsockopt"); | ||
3460 | break; | 3479 | break; |
3461 | } | 3480 | } |
3462 | 3481 | ||
@@ -3538,9 +3557,18 @@ iface_proc (void *cls, | |||
3538 | return GNUNET_OK; /* not using IPv6 */ | 3557 | return GNUNET_OK; /* not using IPv6 */ |
3539 | 3558 | ||
3540 | bi = GNUNET_new (struct BroadcastInterface); | 3559 | bi = GNUNET_new (struct BroadcastInterface); |
3541 | bi->sa = GNUNET_memdup (addr, addrlen); | 3560 | bi->sa = GNUNET_memdup (addr, |
3542 | if (NULL != broadcast_addr) | 3561 | addrlen); |
3543 | bi->ba = GNUNET_memdup (broadcast_addr, addrlen); | 3562 | if ( (NULL != broadcast_addr) && |
3563 | (addrlen == sizeof (struct sockaddr_in)) ) | ||
3564 | { | ||
3565 | struct sockaddr_in *ba; | ||
3566 | |||
3567 | ba = GNUNET_memdup (broadcast_addr, | ||
3568 | addrlen); | ||
3569 | ba->sin_port = htons (2086); /* always GNUnet port, ignore configuration! */ | ||
3570 | bi->ba = (struct sockaddr *) ba; | ||
3571 | } | ||
3544 | bi->salen = addrlen; | 3572 | bi->salen = addrlen; |
3545 | bi->found = GNUNET_YES; | 3573 | bi->found = GNUNET_YES; |
3546 | bi->bcm.sender = my_identity; | 3574 | bi->bcm.sender = my_identity; |
@@ -3551,7 +3579,7 @@ iface_proc (void *cls, | |||
3551 | GNUNET_CRYPTO_eddsa_sign (my_private_key, | 3579 | GNUNET_CRYPTO_eddsa_sign (my_private_key, |
3552 | &ubs, | 3580 | &ubs, |
3553 | &bi->bcm.sender_sig); | 3581 | &bi->bcm.sender_sig); |
3554 | if (NULL != broadcast_addr) | 3582 | if (NULL != bi->ba) |
3555 | { | 3583 | { |
3556 | bi->broadcast_task = GNUNET_SCHEDULER_add_now (&ifc_broadcast, bi); | 3584 | bi->broadcast_task = GNUNET_SCHEDULER_add_now (&ifc_broadcast, bi); |
3557 | GNUNET_CONTAINER_DLL_insert (bi_head, bi_tail, bi); | 3585 | GNUNET_CONTAINER_DLL_insert (bi_head, bi_tail, bi); |
@@ -3675,7 +3703,9 @@ run (void *cls, | |||
3675 | return; | 3703 | return; |
3676 | } | 3704 | } |
3677 | udp_sock = | 3705 | udp_sock = |
3678 | GNUNET_NETWORK_socket_create (in->sa_family, SOCK_DGRAM, IPPROTO_UDP); | 3706 | GNUNET_NETWORK_socket_create (in->sa_family, |
3707 | SOCK_DGRAM, | ||
3708 | IPPROTO_UDP); | ||
3679 | if (NULL == udp_sock) | 3709 | if (NULL == udp_sock) |
3680 | { | 3710 | { |
3681 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "socket"); | 3711 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "socket"); |
@@ -3685,9 +3715,14 @@ run (void *cls, | |||
3685 | } | 3715 | } |
3686 | if (AF_INET6 == in->sa_family) | 3716 | if (AF_INET6 == in->sa_family) |
3687 | have_v6_socket = GNUNET_YES; | 3717 | have_v6_socket = GNUNET_YES; |
3688 | if (GNUNET_OK != GNUNET_NETWORK_socket_bind (udp_sock, in, in_len)) | 3718 | if (GNUNET_OK != |
3719 | GNUNET_NETWORK_socket_bind (udp_sock, | ||
3720 | in, | ||
3721 | in_len)) | ||
3689 | { | 3722 | { |
3690 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "bind", bindto); | 3723 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, |
3724 | "bind", | ||
3725 | bindto); | ||
3691 | GNUNET_NETWORK_socket_close (udp_sock); | 3726 | GNUNET_NETWORK_socket_close (udp_sock); |
3692 | udp_sock = NULL; | 3727 | udp_sock = NULL; |
3693 | GNUNET_free (in); | 3728 | GNUNET_free (in); |
diff --git a/src/transport/test_communicator_basic.c b/src/transport/test_communicator_basic.c index 0eeaecb6c..1f85a9895 100644 --- a/src/transport/test_communicator_basic.c +++ b/src/transport/test_communicator_basic.c | |||
@@ -137,12 +137,12 @@ static struct GNUNET_TIME_Relative duration; | |||
137 | 137 | ||
138 | 138 | ||
139 | static void | 139 | static void |
140 | communicator_available_cb (void *cls, | 140 | communicator_available_cb ( |
141 | struct | 141 | void *cls, |
142 | GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle | 142 | struct |
143 | *tc_h, | 143 | GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h, |
144 | enum GNUNET_TRANSPORT_CommunicatorCharacteristics cc, | 144 | enum GNUNET_TRANSPORT_CommunicatorCharacteristics cc, |
145 | char *address_prefix) | 145 | char *address_prefix) |
146 | { | 146 | { |
147 | LOG (GNUNET_ERROR_TYPE_INFO, | 147 | LOG (GNUNET_ERROR_TYPE_INFO, |
148 | "Communicator available. (cc: %u, prefix: %s)\n", | 148 | "Communicator available. (cc: %u, prefix: %s)\n", |
@@ -150,10 +150,11 @@ communicator_available_cb (void *cls, | |||
150 | address_prefix); | 150 | address_prefix); |
151 | } | 151 | } |
152 | 152 | ||
153 | |||
153 | static void | 154 | static void |
154 | open_queue (void *cls) | 155 | open_queue (void *cls) |
155 | { | 156 | { |
156 | char *address = cls; | 157 | const char *address = cls; |
157 | 158 | ||
158 | if (NULL != tc_hs[PEER_A]->c_mq) | 159 | if (NULL != tc_hs[PEER_A]->c_mq) |
159 | { | 160 | { |
@@ -166,30 +167,32 @@ open_queue (void *cls) | |||
166 | { | 167 | { |
167 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, | 168 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, |
168 | &open_queue, | 169 | &open_queue, |
169 | address); | 170 | (void *) address); |
170 | } | 171 | } |
171 | } | 172 | } |
172 | 173 | ||
174 | |||
173 | static void | 175 | static void |
174 | add_address_cb (void *cls, | 176 | add_address_cb ( |
175 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle * | 177 | void *cls, |
176 | tc_h, | 178 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h, |
177 | const char *address, | 179 | const char *address, |
178 | struct GNUNET_TIME_Relative expiration, | 180 | struct GNUNET_TIME_Relative expiration, |
179 | uint32_t aid, | 181 | uint32_t aid, |
180 | enum GNUNET_NetworkType nt) | 182 | enum GNUNET_NetworkType nt) |
181 | { | 183 | { |
182 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 184 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
183 | "New address. (addr: %s, expir: %" PRIu32 ", ID: %" PRIu32 ", nt: %u\n", | 185 | "New address. (addr: %s, expir: %s, ID: %" PRIu32 ", nt: %u\n", |
184 | address, | 186 | address, |
185 | expiration.rel_value_us, | 187 | GNUNET_STRINGS_relative_time_to_string (expiration, |
188 | GNUNET_NO), | ||
186 | aid, | 189 | aid, |
187 | nt); | 190 | (int) nt); |
188 | // addresses[1] = GNUNET_strdup (address); | 191 | // addresses[1] = GNUNET_strdup (address); |
189 | if ((0 == strcmp ((char*) cls, cfg_peers_name[PEER_B])) && | 192 | if ((0 == strcmp ((char*) cls, cfg_peers_name[PEER_B])) && |
190 | (GNUNET_NO == queue_est)) | 193 | (GNUNET_NO == queue_est)) |
191 | { | 194 | { |
192 | open_queue (address); | 195 | open_queue ((void *) address); |
193 | } | 196 | } |
194 | } | 197 | } |
195 | 198 | ||
@@ -206,12 +209,13 @@ add_address_cb (void *cls, | |||
206 | * #GNUNET_NO if queue will not be established (bogous address) | 209 | * #GNUNET_NO if queue will not be established (bogous address) |
207 | */ | 210 | */ |
208 | static void | 211 | static void |
209 | queue_create_reply_cb (void *cls, | 212 | queue_create_reply_cb ( |
210 | struct | 213 | void *cls, |
211 | GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle * | 214 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h, |
212 | tc_h, | 215 | int will_try) |
213 | int will_try) | ||
214 | { | 216 | { |
217 | (void) cls; | ||
218 | (void) tc_h; | ||
215 | if (GNUNET_YES == will_try) | 219 | if (GNUNET_YES == will_try) |
216 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 220 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
217 | "Queue will be established!\n"); | 221 | "Queue will be established!\n"); |
@@ -227,6 +231,9 @@ handle_backchannel_cb (void *cls, | |||
227 | struct GNUNET_PeerIdentity *pid) | 231 | struct GNUNET_PeerIdentity *pid) |
228 | { | 232 | { |
229 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls; | 233 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls; |
234 | |||
235 | (void) tc_h; | ||
236 | (void) msg; | ||
230 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Handling BC message...\n"); | 237 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Handling BC message...\n"); |
231 | if (0 == memcmp (&peer_id[PEER_A], pid, sizeof (*pid))) | 238 | if (0 == memcmp (&peer_id[PEER_A], pid, sizeof (*pid))) |
232 | return tc_hs[PEER_A]; | 239 | return tc_hs[PEER_A]; |
@@ -268,9 +275,11 @@ latency_timeout (void *cls) | |||
268 | NULL); | 275 | NULL); |
269 | return; | 276 | return; |
270 | } | 277 | } |
271 | |||
272 | switch (phase) | 278 | switch (phase) |
273 | { | 279 | { |
280 | case TP_INIT: | ||
281 | GNUNET_assert (0); | ||
282 | break; | ||
274 | case TP_BURST_SHORT: | 283 | case TP_BURST_SHORT: |
275 | num_sent = num_sent_short; | 284 | num_sent = num_sent_short; |
276 | num_received = num_received_short; | 285 | num_received = num_received_short; |
@@ -291,6 +300,7 @@ latency_timeout (void *cls) | |||
291 | GNUNET_SCHEDULER_shutdown (); | 300 | GNUNET_SCHEDULER_shutdown (); |
292 | } | 301 | } |
293 | 302 | ||
303 | |||
294 | /*static void | 304 | /*static void |
295 | size_test (void *cls);*/ | 305 | size_test (void *cls);*/ |
296 | 306 | ||
@@ -302,7 +312,7 @@ size_test (void *cls) | |||
302 | 312 | ||
303 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 313 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
304 | "size_test_cb %u\n", | 314 | "size_test_cb %u\n", |
305 | num_sent_size); | 315 | (unsigned int) num_sent_size); |
306 | GNUNET_assert (TP_SIZE_CHECK == phase); | 316 | GNUNET_assert (TP_SIZE_CHECK == phase); |
307 | if (LONG_MESSAGE_SIZE != long_message_size) | 317 | if (LONG_MESSAGE_SIZE != long_message_size) |
308 | max_size = long_message_size; | 318 | max_size = long_message_size; |
@@ -324,13 +334,6 @@ size_test (void *cls) | |||
324 | TIMEOUT_MULTIPLIER)); | 334 | TIMEOUT_MULTIPLIER)); |
325 | } | 335 | } |
326 | 336 | ||
327 | /*static void | ||
328 | size_test (void *cls) | ||
329 | { | ||
330 | GNUNET_SCHEDULER_add_delayed (DELAY, | ||
331 | &size_test_cb, | ||
332 | NULL); | ||
333 | }*/ | ||
334 | 337 | ||
335 | static void | 338 | static void |
336 | long_test (void *cls); | 339 | long_test (void *cls); |
@@ -342,8 +345,8 @@ long_test_cb (void *cls) | |||
342 | 345 | ||
343 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 346 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
344 | "long_test_cb %u/%u\n", | 347 | "long_test_cb %u/%u\n", |
345 | num_sent_long, | 348 | (unsigned int) num_sent_long, |
346 | num_received_long); | 349 | (unsigned int) num_received_long); |
347 | payload = make_payload (long_message_size); | 350 | payload = make_payload (long_message_size); |
348 | num_sent_long++; | 351 | num_sent_long++; |
349 | GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc, | 352 | GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc, |
@@ -355,11 +358,13 @@ long_test_cb (void *cls) | |||
355 | payload, | 358 | payload, |
356 | long_message_size); | 359 | long_message_size); |
357 | GNUNET_free (payload); | 360 | GNUNET_free (payload); |
358 | timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply ( | 361 | timeout = GNUNET_TIME_relative_to_absolute ( |
359 | GNUNET_TIME_UNIT_SECONDS, | 362 | GNUNET_TIME_relative_multiply ( |
360 | TIMEOUT_MULTIPLIER)); | 363 | GNUNET_TIME_UNIT_SECONDS, |
364 | TIMEOUT_MULTIPLIER)); | ||
361 | } | 365 | } |
362 | 366 | ||
367 | |||
363 | static void | 368 | static void |
364 | long_test (void *cls) | 369 | long_test (void *cls) |
365 | { | 370 | { |
@@ -371,9 +376,11 @@ long_test (void *cls) | |||
371 | NULL); | 376 | NULL); |
372 | } | 377 | } |
373 | 378 | ||
379 | |||
374 | static void | 380 | static void |
375 | short_test (void *cls); | 381 | short_test (void *cls); |
376 | 382 | ||
383 | |||
377 | static void | 384 | static void |
378 | short_test_cb (void *cls) | 385 | short_test_cb (void *cls) |
379 | { | 386 | { |
@@ -381,8 +388,8 @@ short_test_cb (void *cls) | |||
381 | 388 | ||
382 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 389 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
383 | "short_test_cb %u/%u\n", | 390 | "short_test_cb %u/%u\n", |
384 | num_sent_short, | 391 | (unsigned int) num_sent_short, |
385 | num_received_short); | 392 | (unsigned int) num_received_short); |
386 | payload = make_payload (SHORT_MESSAGE_SIZE); | 393 | payload = make_payload (SHORT_MESSAGE_SIZE); |
387 | num_sent_short++; | 394 | num_sent_short++; |
388 | GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc, | 395 | GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc, |
@@ -399,6 +406,7 @@ short_test_cb (void *cls) | |||
399 | TIMEOUT_MULTIPLIER)); | 406 | TIMEOUT_MULTIPLIER)); |
400 | } | 407 | } |
401 | 408 | ||
409 | |||
402 | static void | 410 | static void |
403 | short_test (void *cls) | 411 | short_test (void *cls) |
404 | { | 412 | { |
@@ -494,10 +502,14 @@ update_avg_latency (const char*payload) | |||
494 | ts = GNUNET_TIME_absolute_ntoh (*ts_n); | 502 | ts = GNUNET_TIME_absolute_ntoh (*ts_n); |
495 | latency = GNUNET_TIME_absolute_get_duration (ts); | 503 | latency = GNUNET_TIME_absolute_get_duration (ts); |
496 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 504 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
497 | "Latency of received packet: %u\n", | 505 | "Latency of received packet: %s\n", |
498 | latency); | 506 | GNUNET_STRINGS_relative_time_to_string (latency, |
507 | GNUNET_YES)); | ||
499 | switch (phase) | 508 | switch (phase) |
500 | { | 509 | { |
510 | case TP_INIT: | ||
511 | GNUNET_assert (0); | ||
512 | break; | ||
501 | case TP_BURST_SHORT: | 513 | case TP_BURST_SHORT: |
502 | num_received = num_received_short; | 514 | num_received = num_received_short; |
503 | break; | 515 | break; |
@@ -516,6 +528,8 @@ update_avg_latency (const char*payload) | |||
516 | 528 | ||
517 | } | 529 | } |
518 | 530 | ||
531 | |||
532 | static void | ||
519 | process_statistics_box_done (void *cls, int success) | 533 | process_statistics_box_done (void *cls, int success) |
520 | { | 534 | { |
521 | if (NULL != box_stats) | 535 | if (NULL != box_stats) |
@@ -528,6 +542,8 @@ process_statistics_box_done (void *cls, int success) | |||
528 | } | 542 | } |
529 | } | 543 | } |
530 | 544 | ||
545 | |||
546 | static void | ||
531 | process_statistics_rekey_done (void *cls, int success) | 547 | process_statistics_rekey_done (void *cls, int success) |
532 | { | 548 | { |
533 | if (NULL != rekey_stats) | 549 | if (NULL != rekey_stats) |
@@ -540,6 +556,7 @@ process_statistics_rekey_done (void *cls, int success) | |||
540 | } | 556 | } |
541 | } | 557 | } |
542 | 558 | ||
559 | |||
543 | static int | 560 | static int |
544 | process_statistics (void *cls, | 561 | process_statistics (void *cls, |
545 | const char *subsystem, | 562 | const char *subsystem, |
@@ -560,7 +577,7 @@ process_statistics (void *cls, | |||
560 | "No successful rekeying!\n"); | 577 | "No successful rekeying!\n"); |
561 | GNUNET_SCHEDULER_shutdown (); | 578 | GNUNET_SCHEDULER_shutdown (); |
562 | } | 579 | } |
563 | if ((0 == strcmp ("backchannel", test_name)) && | 580 | if ((0 == strcmp ("backchannel", test_name)) && |
564 | (0 == strcmp ( | 581 | (0 == strcmp ( |
565 | "# messages decrypted with BOX", | 582 | "# messages decrypted with BOX", |
566 | name)) | 583 | name)) |
@@ -571,7 +588,7 @@ process_statistics (void *cls, | |||
571 | "Not enough BOX messages!\n"); | 588 | "Not enough BOX messages!\n"); |
572 | GNUNET_SCHEDULER_shutdown (); | 589 | GNUNET_SCHEDULER_shutdown (); |
573 | } | 590 | } |
574 | if ((0 == strcmp ("rekey", test_name)) && | 591 | if ((0 == strcmp ("rekey", test_name)) && |
575 | (0 == strcmp ( | 592 | (0 == strcmp ( |
576 | "# messages decrypted with BOX", | 593 | "# messages decrypted with BOX", |
577 | name)) | 594 | name)) |
@@ -585,6 +602,7 @@ process_statistics (void *cls, | |||
585 | return GNUNET_OK; | 602 | return GNUNET_OK; |
586 | } | 603 | } |
587 | 604 | ||
605 | |||
588 | /** | 606 | /** |
589 | * @brief Handle an incoming message | 607 | * @brief Handle an incoming message |
590 | * | 608 | * |
@@ -595,14 +613,14 @@ process_statistics (void *cls, | |||
595 | * @param msg Received message | 613 | * @param msg Received message |
596 | */ | 614 | */ |
597 | static void | 615 | static void |
598 | incoming_message_cb (void *cls, | 616 | incoming_message_cb ( |
599 | struct | 617 | void *cls, |
600 | GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle | 618 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h, |
601 | *tc_h, | 619 | const char *payload, |
602 | const char*payload, | 620 | size_t payload_len) |
603 | size_t payload_len) | ||
604 | { | 621 | { |
605 | if (0 != strcmp ((char*) cls, cfg_peers_name[NUM_PEERS - 1])) | 622 | if (0 != strcmp ((char*) cls, |
623 | cfg_peers_name[NUM_PEERS - 1])) | ||
606 | { | 624 | { |
607 | LOG (GNUNET_ERROR_TYPE_WARNING, | 625 | LOG (GNUNET_ERROR_TYPE_WARNING, |
608 | "unexpected receiver...\n"); | 626 | "unexpected receiver...\n"); |
@@ -628,11 +646,9 @@ incoming_message_cb (void *cls, | |||
628 | { | 646 | { |
629 | LOG (GNUNET_ERROR_TYPE_MESSAGE, | 647 | LOG (GNUNET_ERROR_TYPE_MESSAGE, |
630 | "Short size packet test done.\n"); | 648 | "Short size packet test done.\n"); |
631 | char *goodput = GNUNET_STRINGS_byte_size_fancy ((SHORT_MESSAGE_SIZE | 649 | char *goodput = GNUNET_STRINGS_byte_size_fancy ( |
632 | * num_received_short | 650 | (SHORT_MESSAGE_SIZE * num_received_short * 1000 * 1000) |
633 | * 1000 | 651 | / duration.rel_value_us); |
634 | * 1000) | ||
635 | / duration.rel_value_us); | ||
636 | LOG (GNUNET_ERROR_TYPE_MESSAGE, | 652 | LOG (GNUNET_ERROR_TYPE_MESSAGE, |
637 | "%lu/%lu packets in %llu us (%s/s) -- avg latency: %llu us\n", | 653 | "%lu/%lu packets in %llu us (%s/s) -- avg latency: %llu us\n", |
638 | (unsigned long) num_received_short, | 654 | (unsigned long) num_received_short, |
@@ -646,9 +662,6 @@ incoming_message_cb (void *cls, | |||
646 | // num_sent_short = 0; | 662 | // num_sent_short = 0; |
647 | avg_latency = 0; | 663 | avg_latency = 0; |
648 | // num_received = 0; | 664 | // num_received = 0; |
649 | /*LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
650 | "Finished\n"); | ||
651 | GNUNET_SCHEDULER_shutdown ();*/ | ||
652 | long_test (NULL); | 665 | long_test (NULL); |
653 | } | 666 | } |
654 | break; | 667 | break; |
@@ -669,12 +682,10 @@ incoming_message_cb (void *cls, | |||
669 | { | 682 | { |
670 | LOG (GNUNET_ERROR_TYPE_MESSAGE, | 683 | LOG (GNUNET_ERROR_TYPE_MESSAGE, |
671 | "Long size packet test done.\n"); | 684 | "Long size packet test done.\n"); |
672 | char *goodput = GNUNET_STRINGS_byte_size_fancy ((long_message_size | 685 | char *goodput = GNUNET_STRINGS_byte_size_fancy ( |
673 | * num_received_long | 686 | (long_message_size * num_received_long * 1000 * 1000) |
674 | * 1000 | 687 | / duration. |
675 | * 1000) | 688 | rel_value_us); |
676 | / duration. | ||
677 | rel_value_us); | ||
678 | 689 | ||
679 | LOG (GNUNET_ERROR_TYPE_MESSAGE, | 690 | LOG (GNUNET_ERROR_TYPE_MESSAGE, |
680 | "%lu/%lu packets in %llu us (%s/s) -- avg latency: %llu us\n", | 691 | "%lu/%lu packets in %llu us (%s/s) -- avg latency: %llu us\n", |
@@ -749,7 +760,8 @@ incoming_message_cb (void *cls, | |||
749 | &process_statistics, | 760 | &process_statistics, |
750 | NULL); | 761 | NULL); |
751 | } | 762 | } |
752 | else{ | 763 | else |
764 | { | ||
753 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 765 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
754 | "Finished\n"); | 766 | "Finished\n"); |
755 | GNUNET_SCHEDULER_shutdown (); | 767 | GNUNET_SCHEDULER_shutdown (); |
@@ -765,7 +777,7 @@ static void | |||
765 | do_shutdown (void *cls) | 777 | do_shutdown (void *cls) |
766 | { | 778 | { |
767 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 779 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
768 | "shuting down test.\”"); | 780 | "shuting down test.\n"); |
769 | 781 | ||
770 | if (NULL != box_stats) | 782 | if (NULL != box_stats) |
771 | { | 783 | { |
@@ -919,15 +931,12 @@ main (int argc, | |||
919 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 931 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
920 | "test_name: %s\n", | 932 | "test_name: %s\n", |
921 | test_name); | 933 | test_name); |
922 | |||
923 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 934 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
924 | "communicator_name: %s\n", | 935 | "communicator_name: %s\n", |
925 | communicator_name); | 936 | communicator_name); |
926 | |||
927 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 937 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
928 | "communicator_binary: %s\n", | 938 | "communicator_binary: %s\n", |
929 | communicator_binary); | 939 | communicator_binary); |
930 | |||
931 | GNUNET_SCHEDULER_run (&run, | 940 | GNUNET_SCHEDULER_run (&run, |
932 | NULL); | 941 | NULL); |
933 | return ret; | 942 | return ret; |