diff options
Diffstat (limited to 'src/transport')
3 files changed, 175 insertions, 154 deletions
diff --git a/src/transport/gnunet-communicator-tcp.c b/src/transport/gnunet-communicator-tcp.c index db2aea552..e2f1e4507 100644 --- a/src/transport/gnunet-communicator-tcp.c +++ b/src/transport/gnunet-communicator-tcp.c | |||
@@ -1513,13 +1513,13 @@ handshake_ack_monotime_cb (void *cls, | |||
1513 | */ | 1513 | */ |
1514 | static void | 1514 | static void |
1515 | send_challenge (struct GNUNET_CRYPTO_ChallengeNonceP challenge, | 1515 | send_challenge (struct GNUNET_CRYPTO_ChallengeNonceP challenge, |
1516 | struct Queue *queue) | 1516 | struct Queue *queue) |
1517 | { | 1517 | { |
1518 | struct TCPConfirmationAck tca; | 1518 | struct TCPConfirmationAck tca; |
1519 | struct TcpHandshakeAckSignature thas; | 1519 | struct TcpHandshakeAckSignature thas; |
1520 | 1520 | ||
1521 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1521 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1522 | "sending challenge\n"); | 1522 | "sending challenge\n"); |
1523 | 1523 | ||
1524 | tca.header.type = ntohs ( | 1524 | tca.header.type = ntohs ( |
1525 | GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_CONFIRMATION_ACK); | 1525 | GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_CONFIRMATION_ACK); |
@@ -1546,7 +1546,7 @@ send_challenge (struct GNUNET_CRYPTO_ChallengeNonceP challenge, | |||
1546 | sizeof(tca))); | 1546 | sizeof(tca))); |
1547 | queue->cwrite_off += sizeof(tca); | 1547 | queue->cwrite_off += sizeof(tca); |
1548 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1548 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1549 | "sending challenge done\n"); | 1549 | "sending challenge done\n"); |
1550 | } | 1550 | } |
1551 | 1551 | ||
1552 | 1552 | ||
@@ -1632,8 +1632,8 @@ inject_rekey (struct Queue *queue) | |||
1632 | 1632 | ||
1633 | static int | 1633 | static int |
1634 | pending_reversals_delete_it (void *cls, | 1634 | pending_reversals_delete_it (void *cls, |
1635 | const struct GNUNET_HashCode *key, | 1635 | const struct GNUNET_HashCode *key, |
1636 | void *value) | 1636 | void *value) |
1637 | { | 1637 | { |
1638 | (void) cls; | 1638 | (void) cls; |
1639 | struct PendingReversal *pending_reversal = value; | 1639 | struct PendingReversal *pending_reversal = value; |
@@ -1643,9 +1643,10 @@ pending_reversals_delete_it (void *cls, | |||
1643 | GNUNET_SCHEDULER_cancel (pending_reversal->timeout_task); | 1643 | GNUNET_SCHEDULER_cancel (pending_reversal->timeout_task); |
1644 | pending_reversal->timeout_task = NULL; | 1644 | pending_reversal->timeout_task = NULL; |
1645 | } | 1645 | } |
1646 | GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove (pending_reversals, | 1646 | GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove ( |
1647 | key, | 1647 | pending_reversals, |
1648 | pending_reversal)); | 1648 | key, |
1649 | pending_reversal)); | ||
1649 | GNUNET_free (pending_reversal->in); | 1650 | GNUNET_free (pending_reversal->in); |
1650 | GNUNET_free (pending_reversal); | 1651 | GNUNET_free (pending_reversal); |
1651 | return GNUNET_OK; | 1652 | return GNUNET_OK; |
@@ -1653,33 +1654,37 @@ pending_reversals_delete_it (void *cls, | |||
1653 | 1654 | ||
1654 | 1655 | ||
1655 | static void | 1656 | static void |
1656 | check_and_remove_pending_reversal (struct sockaddr *in, sa_family_t sa_family, struct GNUNET_PeerIdentity *sender) | 1657 | check_and_remove_pending_reversal (struct sockaddr *in, sa_family_t sa_family, |
1658 | struct GNUNET_PeerIdentity *sender) | ||
1657 | { | 1659 | { |
1658 | if (AF_INET == sa_family) | 1660 | if (AF_INET == sa_family) |
1659 | { | 1661 | { |
1660 | struct PendingReversal *pending_reversal; | 1662 | struct PendingReversal *pending_reversal; |
1661 | struct GNUNET_HashCode key; | 1663 | struct GNUNET_HashCode key; |
1662 | struct sockaddr_in *natted_address; | 1664 | struct sockaddr_in *natted_address; |
1663 | 1665 | ||
1664 | natted_address = GNUNET_memdup (in, sizeof (struct sockaddr)); | 1666 | natted_address = GNUNET_memdup (in, sizeof (struct sockaddr)); |
1665 | natted_address->sin_port = 0; | 1667 | natted_address->sin_port = 0; |
1666 | GNUNET_CRYPTO_hash (natted_address, | 1668 | GNUNET_CRYPTO_hash (natted_address, |
1667 | sizeof(struct sockaddr), | 1669 | sizeof(struct sockaddr), |
1668 | &key); | 1670 | &key); |
1669 | 1671 | ||
1670 | pending_reversal = GNUNET_CONTAINER_multihashmap_get (pending_reversals, | 1672 | pending_reversal = GNUNET_CONTAINER_multihashmap_get (pending_reversals, |
1671 | &key); | 1673 | &key); |
1672 | if (NULL != pending_reversal && (NULL == sender || | 1674 | if (NULL != pending_reversal && (NULL == sender || |
1673 | 0 != memcmp (sender, &pending_reversal->target, sizeof(struct GNUNET_PeerIdentity)))) | 1675 | 0 != memcmp (sender, |
1674 | { | 1676 | &pending_reversal->target, |
1675 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1677 | sizeof(struct |
1676 | "Removing invalid pending reversal for `%s'at `%s'\n", | 1678 | GNUNET_PeerIdentity)))) |
1677 | GNUNET_i2s (&pending_reversal->target), | 1679 | { |
1678 | GNUNET_a2s (in, sizeof (struct sockaddr))); | 1680 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1679 | pending_reversals_delete_it (NULL, &key, pending_reversal); | 1681 | "Removing invalid pending reversal for `%s'at `%s'\n", |
1680 | } | 1682 | GNUNET_i2s (&pending_reversal->target), |
1681 | GNUNET_free (natted_address); | 1683 | GNUNET_a2s (in, sizeof (struct sockaddr))); |
1682 | } | 1684 | pending_reversals_delete_it (NULL, &key, pending_reversal); |
1685 | } | ||
1686 | GNUNET_free (natted_address); | ||
1687 | } | ||
1683 | } | 1688 | } |
1684 | 1689 | ||
1685 | 1690 | ||
@@ -1971,7 +1976,8 @@ try_handle_plaintext (struct Queue *queue) | |||
1971 | } | 1976 | } |
1972 | else if (GNUNET_TRANSPORT_CS_OUTBOUND == queue->cs) | 1977 | else if (GNUNET_TRANSPORT_CS_OUTBOUND == queue->cs) |
1973 | { | 1978 | { |
1974 | check_and_remove_pending_reversal (queue->address, queue->address->sa_family, NULL); | 1979 | check_and_remove_pending_reversal (queue->address, |
1980 | queue->address->sa_family, NULL); | ||
1975 | } | 1981 | } |
1976 | 1982 | ||
1977 | unverified_size = -1; | 1983 | unverified_size = -1; |
@@ -2691,7 +2697,7 @@ transmit_kx (struct Queue *queue, | |||
2691 | queue->cwrite_off += sizeof(tc); | 2697 | queue->cwrite_off += sizeof(tc); |
2692 | 2698 | ||
2693 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2699 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2694 | "handshake written\n"); | 2700 | "handshake written\n"); |
2695 | } | 2701 | } |
2696 | 2702 | ||
2697 | 2703 | ||
@@ -2987,7 +2993,8 @@ proto_read_kx (void *cls) | |||
2987 | { | 2993 | { |
2988 | struct TCPNATProbeMessage *pm = (struct TCPNATProbeMessage *) pq->ibuf; | 2994 | struct TCPNATProbeMessage *pm = (struct TCPNATProbeMessage *) pq->ibuf; |
2989 | 2995 | ||
2990 | check_and_remove_pending_reversal (pq->address, pq->address->sa_family, &pm->clientIdentity); | 2996 | check_and_remove_pending_reversal (pq->address, pq->address->sa_family, |
2997 | &pm->clientIdentity); | ||
2991 | 2998 | ||
2992 | queue = GNUNET_new (struct Queue); | 2999 | queue = GNUNET_new (struct Queue); |
2993 | queue->target = pm->clientIdentity; | 3000 | queue->target = pm->clientIdentity; |
@@ -3009,13 +3016,13 @@ proto_read_kx (void *cls) | |||
3009 | queue); | 3016 | queue); |
3010 | if (GNUNET_OK != decrypt_and_check_tc (queue, &tc, pq->ibuf)) | 3017 | if (GNUNET_OK != decrypt_and_check_tc (queue, &tc, pq->ibuf)) |
3011 | { | 3018 | { |
3012 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 3019 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
3013 | "Invalid TCP KX received from %s\n", | 3020 | "Invalid TCP KX received from %s\n", |
3014 | GNUNET_a2s (pq->address, pq->address_len)); | 3021 | GNUNET_a2s (pq->address, pq->address_len)); |
3015 | gcry_cipher_close (queue->in_cipher); | 3022 | gcry_cipher_close (queue->in_cipher); |
3016 | GNUNET_free (queue); | 3023 | GNUNET_free (queue); |
3017 | free_proto_queue (pq); | 3024 | free_proto_queue (pq); |
3018 | return; | 3025 | return; |
3019 | } | 3026 | } |
3020 | queue->target = tc.sender; | 3027 | queue->target = tc.sender; |
3021 | queue->cs = GNUNET_TRANSPORT_CS_INBOUND; | 3028 | queue->cs = GNUNET_TRANSPORT_CS_INBOUND; |
@@ -3062,29 +3069,29 @@ create_proto_queue (struct GNUNET_NETWORK_Handle *sock, | |||
3062 | 3069 | ||
3063 | if (NULL == sock) | 3070 | if (NULL == sock) |
3064 | { | 3071 | { |
3065 | //sock = GNUNET_CONNECTION_create_from_sockaddr (AF_INET, addr, addrlen); | 3072 | // sock = GNUNET_CONNECTION_create_from_sockaddr (AF_INET, addr, addrlen); |
3066 | sock = GNUNET_NETWORK_socket_create (in->sa_family, SOCK_STREAM, 0); | 3073 | sock = GNUNET_NETWORK_socket_create (in->sa_family, SOCK_STREAM, 0); |
3067 | if (NULL == sock) | 3074 | if (NULL == sock) |
3068 | { | 3075 | { |
3069 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 3076 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
3070 | "socket(%d) failed: %s", | 3077 | "socket(%d) failed: %s", |
3071 | in->sa_family, | 3078 | in->sa_family, |
3072 | strerror (errno)); | 3079 | strerror (errno)); |
3073 | GNUNET_free (in); | 3080 | GNUNET_free (in); |
3074 | GNUNET_free (pq); | 3081 | GNUNET_free (pq); |
3075 | return NULL; | 3082 | return NULL; |
3076 | } | 3083 | } |
3077 | if ((GNUNET_OK != GNUNET_NETWORK_socket_connect (sock, in, addrlen)) && | 3084 | if ((GNUNET_OK != GNUNET_NETWORK_socket_connect (sock, in, addrlen)) && |
3078 | (errno != EINPROGRESS)) | 3085 | (errno != EINPROGRESS)) |
3079 | { | 3086 | { |
3080 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 3087 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
3081 | "connect to `%s' failed: %s", | 3088 | "connect to `%s' failed: %s", |
3082 | GNUNET_a2s (in, addrlen), | 3089 | GNUNET_a2s (in, addrlen), |
3083 | strerror (errno)); | 3090 | strerror (errno)); |
3084 | GNUNET_NETWORK_socket_close (sock); | 3091 | GNUNET_NETWORK_socket_close (sock); |
3085 | GNUNET_free (in); | 3092 | GNUNET_free (in); |
3086 | return NULL; | 3093 | return NULL; |
3087 | } | 3094 | } |
3088 | } | 3095 | } |
3089 | pq->address_len = addrlen; | 3096 | pq->address_len = addrlen; |
3090 | pq->address = in; | 3097 | pq->address = in; |
@@ -3158,31 +3165,31 @@ try_connection_reversal (void *cls, | |||
3158 | struct sockaddr *in_addr; | 3165 | struct sockaddr *in_addr; |
3159 | 3166 | ||
3160 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3167 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3161 | "addr->sa_family %d\n", | 3168 | "addr->sa_family %d\n", |
3162 | addr->sa_family); | 3169 | addr->sa_family); |
3163 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3170 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3164 | "Try to connect back\n"); | 3171 | "Try to connect back\n"); |
3165 | in_addr = GNUNET_memdup (addr, addrlen); | 3172 | in_addr = GNUNET_memdup (addr, addrlen); |
3166 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3173 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3167 | "in_addr->sa_family %d\n", | 3174 | "in_addr->sa_family %d\n", |
3168 | in_addr->sa_family); | 3175 | in_addr->sa_family); |
3169 | pq = create_proto_queue (NULL, in_addr, addrlen); | 3176 | pq = create_proto_queue (NULL, in_addr, addrlen); |
3170 | if (NULL != pq) | 3177 | if (NULL != pq) |
3171 | { | 3178 | { |
3172 | pm.header.size = htons (sizeof(struct TCPNATProbeMessage)); | 3179 | pm.header.size = htons (sizeof(struct TCPNATProbeMessage)); |
3173 | pm.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_TCP_NAT_PROBE); | 3180 | pm.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_TCP_NAT_PROBE); |
3174 | pm.clientIdentity = my_identity; | 3181 | pm.clientIdentity = my_identity; |
3175 | memcpy (pq->write_buf, &pm, sizeof(struct TCPNATProbeMessage)); | 3182 | memcpy (pq->write_buf, &pm, sizeof(struct TCPNATProbeMessage)); |
3176 | pq->write_off = sizeof(struct TCPNATProbeMessage); | 3183 | pq->write_off = sizeof(struct TCPNATProbeMessage); |
3177 | pq->write_task = GNUNET_SCHEDULER_add_write_net (PROTO_QUEUE_TIMEOUT, | 3184 | pq->write_task = GNUNET_SCHEDULER_add_write_net (PROTO_QUEUE_TIMEOUT, |
3178 | pq->sock, | 3185 | pq->sock, |
3179 | &proto_queue_write, | 3186 | &proto_queue_write, |
3180 | pq); | 3187 | pq); |
3181 | } | 3188 | } |
3182 | else | 3189 | else |
3183 | { | 3190 | { |
3184 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 3191 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
3185 | "Couldn't create ProtoQueue for sending TCPNATProbeMessage\n"); | 3192 | "Couldn't create ProtoQueue for sending TCPNATProbeMessage\n"); |
3186 | } | 3193 | } |
3187 | } | 3194 | } |
3188 | 3195 | ||
@@ -3268,43 +3275,45 @@ mq_init (void *cls, const struct GNUNET_PeerIdentity *peer, const char *address) | |||
3268 | GNUNET_a2s (in, in_len)); | 3275 | GNUNET_a2s (in, in_len)); |
3269 | 3276 | ||
3270 | switch (in->sa_family) | 3277 | switch (in->sa_family) |
3278 | { | ||
3279 | case AF_INET: | ||
3280 | v4 = (struct sockaddr_in *) in; | ||
3281 | if (0 == v4->sin_port) | ||
3271 | { | 3282 | { |
3272 | case AF_INET: | 3283 | is_natd = GNUNET_YES; |
3273 | v4 = (struct sockaddr_in *) in; | 3284 | GNUNET_CRYPTO_hash (in, |
3274 | if (0 == v4->sin_port){ | 3285 | sizeof(struct sockaddr), |
3275 | is_natd = GNUNET_YES; | 3286 | &key); |
3276 | GNUNET_CRYPTO_hash (in, | 3287 | if (GNUNET_YES == GNUNET_CONTAINER_multihashmap_contains ( |
3277 | sizeof(struct sockaddr), | 3288 | pending_reversals, |
3278 | &key); | 3289 | &key)) |
3279 | if (GNUNET_YES == GNUNET_CONTAINER_multihashmap_contains (pending_reversals, | ||
3280 | &key)) | ||
3281 | { | ||
3282 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
3283 | "There is already a request reversal for `%s'at `%s'\n", | ||
3284 | GNUNET_i2s (peer), | ||
3285 | address); | ||
3286 | GNUNET_free (in); | ||
3287 | return GNUNET_SYSERR; | ||
3288 | } | ||
3289 | } | ||
3290 | break; | ||
3291 | |||
3292 | case AF_INET6: | ||
3293 | v6 = (struct sockaddr_in6 *) in; | ||
3294 | if (0 == v6->sin6_port) | ||
3295 | { | 3290 | { |
3296 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 3291 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
3297 | "Request reversal for `%s' at `%s' not possible for an IPv6 address\n", | 3292 | "There is already a request reversal for `%s'at `%s'\n", |
3298 | GNUNET_i2s (peer), | 3293 | GNUNET_i2s (peer), |
3299 | address); | 3294 | address); |
3300 | GNUNET_free (in); | 3295 | GNUNET_free (in); |
3301 | return GNUNET_SYSERR; | 3296 | return GNUNET_SYSERR; |
3302 | } | 3297 | } |
3303 | break; | 3298 | } |
3299 | break; | ||
3304 | 3300 | ||
3305 | default: | 3301 | case AF_INET6: |
3306 | GNUNET_assert (0); | 3302 | v6 = (struct sockaddr_in6 *) in; |
3303 | if (0 == v6->sin6_port) | ||
3304 | { | ||
3305 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
3306 | "Request reversal for `%s' at `%s' not possible for an IPv6 address\n", | ||
3307 | GNUNET_i2s (peer), | ||
3308 | address); | ||
3309 | GNUNET_free (in); | ||
3310 | return GNUNET_SYSERR; | ||
3307 | } | 3311 | } |
3312 | break; | ||
3313 | |||
3314 | default: | ||
3315 | GNUNET_assert (0); | ||
3316 | } | ||
3308 | 3317 | ||
3309 | if (GNUNET_YES == is_natd) | 3318 | if (GNUNET_YES == is_natd) |
3310 | { | 3319 | { |
@@ -3320,9 +3329,9 @@ mq_init (void *cls, const struct GNUNET_PeerIdentity *peer, const char *address) | |||
3320 | if (GNUNET_OK != GNUNET_NAT_request_reversal (nat, &local_sa, v4)) | 3329 | if (GNUNET_OK != GNUNET_NAT_request_reversal (nat, &local_sa, v4)) |
3321 | { | 3330 | { |
3322 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 3331 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
3323 | "request reversal for `%s' at `%s' failed\n", | 3332 | "request reversal for `%s' at `%s' failed\n", |
3324 | GNUNET_i2s (peer), | 3333 | GNUNET_i2s (peer), |
3325 | address); | 3334 | address); |
3326 | GNUNET_free (in); | 3335 | GNUNET_free (in); |
3327 | return GNUNET_SYSERR; | 3336 | return GNUNET_SYSERR; |
3328 | } | 3337 | } |
@@ -3334,18 +3343,22 @@ mq_init (void *cls, const struct GNUNET_PeerIdentity *peer, const char *address) | |||
3334 | pending_reversal, | 3343 | pending_reversal, |
3335 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 3344 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
3336 | pending_reversal->target = *peer; | 3345 | pending_reversal->target = *peer; |
3337 | pending_reversal->timeout_task = GNUNET_SCHEDULER_add_delayed (NAT_TIMEOUT, &pending_reversal_timeout, in); | 3346 | pending_reversal->timeout_task = GNUNET_SCHEDULER_add_delayed (NAT_TIMEOUT, |
3347 | & | ||
3348 | pending_reversal_timeout, | ||
3349 | in); | ||
3338 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3350 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3339 | "Created NAT WAIT connection to `%s' at `%s'\n", | 3351 | "Created NAT WAIT connection to `%s' at `%s'\n", |
3340 | GNUNET_i2s (peer), | 3352 | GNUNET_i2s (peer), |
3341 | GNUNET_a2s (in, sizeof (struct sockaddr))); | 3353 | GNUNET_a2s (in, sizeof (struct sockaddr))); |
3342 | } | 3354 | } |
3343 | else | 3355 | else |
3344 | { | 3356 | { |
3345 | struct GNUNET_NETWORK_Handle *sock; | 3357 | struct GNUNET_NETWORK_Handle *sock; |
3346 | struct Queue *queue; | 3358 | struct Queue *queue; |
3347 | 3359 | ||
3348 | sock = GNUNET_NETWORK_socket_create (in->sa_family, SOCK_STREAM, IPPROTO_TCP); | 3360 | sock = GNUNET_NETWORK_socket_create (in->sa_family, SOCK_STREAM, |
3361 | IPPROTO_TCP); | ||
3349 | if (NULL == sock) | 3362 | if (NULL == sock) |
3350 | { | 3363 | { |
3351 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 3364 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
@@ -3478,7 +3491,8 @@ do_shutdown (void *cls) | |||
3478 | GNUNET_NAT_unregister (nat); | 3491 | GNUNET_NAT_unregister (nat); |
3479 | nat = NULL; | 3492 | nat = NULL; |
3480 | } | 3493 | } |
3481 | GNUNET_CONTAINER_multihashmap_iterate (pending_reversals, &pending_reversals_delete_it, NULL); | 3494 | GNUNET_CONTAINER_multihashmap_iterate (pending_reversals, |
3495 | &pending_reversals_delete_it, NULL); | ||
3482 | GNUNET_CONTAINER_multihashmap_destroy (pending_reversals); | 3496 | GNUNET_CONTAINER_multihashmap_destroy (pending_reversals); |
3483 | GNUNET_CONTAINER_multihashmap_iterate (lt_map, &get_lt_delete_it, NULL); | 3497 | GNUNET_CONTAINER_multihashmap_iterate (lt_map, &get_lt_delete_it, NULL); |
3484 | GNUNET_CONTAINER_multihashmap_destroy (lt_map); | 3498 | GNUNET_CONTAINER_multihashmap_destroy (lt_map); |
@@ -4040,7 +4054,7 @@ main (int argc, char *const *argv) | |||
4040 | int ret; | 4054 | int ret; |
4041 | 4055 | ||
4042 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 4056 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
4043 | "Starting tcp communicator\n"); | 4057 | "Starting tcp communicator\n"); |
4044 | if (GNUNET_OK != | 4058 | if (GNUNET_OK != |
4045 | GNUNET_STRINGS_get_utf8_args (argc, argv, | 4059 | GNUNET_STRINGS_get_utf8_args (argc, argv, |
4046 | &argc, &argv)) | 4060 | &argc, &argv)) |
diff --git a/src/transport/test_transport_plugin_cmd_simple_send_performance.c b/src/transport/test_transport_plugin_cmd_simple_send_performance.c index 9cd780705..2251f9849 100644 --- a/src/transport/test_transport_plugin_cmd_simple_send_performance.c +++ b/src/transport/test_transport_plugin_cmd_simple_send_performance.c | |||
@@ -86,7 +86,8 @@ struct Sender | |||
86 | */ | 86 | */ |
87 | static int | 87 | static int |
88 | check_test (void *cls, | 88 | check_test (void *cls, |
89 | const struct GNUNET_TRANSPORT_TESTING_PerformanceTestMessage *message) | 89 | const struct |
90 | GNUNET_TRANSPORT_TESTING_PerformanceTestMessage *message) | ||
90 | { | 91 | { |
91 | return GNUNET_OK; | 92 | return GNUNET_OK; |
92 | } | 93 | } |
@@ -99,7 +100,8 @@ check_test (void *cls, | |||
99 | */ | 100 | */ |
100 | static void | 101 | static void |
101 | handle_test (void *cls, | 102 | handle_test (void *cls, |
102 | const struct GNUNET_TRANSPORT_TESTING_PerformanceTestMessage *message) | 103 | const struct |
104 | GNUNET_TRANSPORT_TESTING_PerformanceTestMessage *message) | ||
103 | { | 105 | { |
104 | struct GNUNET_PeerIdentity *peer = cls; | 106 | struct GNUNET_PeerIdentity *peer = cls; |
105 | const struct GNUNET_TESTING_AsyncContext *ac; | 107 | const struct GNUNET_TESTING_AsyncContext *ac; |
@@ -131,11 +133,13 @@ handle_test (void *cls, | |||
131 | { | 133 | { |
132 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 134 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
133 | "time traveled init %s\n", | 135 | "time traveled init %s\n", |
134 | GNUNET_i2s(peer)); | 136 | GNUNET_i2s (peer)); |
135 | sender = GNUNET_new (struct Sender); | 137 | sender = GNUNET_new (struct Sender); |
136 | sender->time_first = time_send; | 138 | sender->time_first = time_send; |
137 | sender->mean_time = GNUNET_TIME_UNIT_ZERO; | 139 | sender->mean_time = GNUNET_TIME_UNIT_ZERO; |
138 | GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_multipeermap_put (senders, peer, sender, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 140 | GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_multipeermap_put (senders, |
141 | peer, sender, | ||
142 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | ||
139 | } | 143 | } |
140 | 144 | ||
141 | if (GNUNET_TIME_UNIT_ZERO.rel_value_us == sender->mean_time.rel_value_us) | 145 | if (GNUNET_TIME_UNIT_ZERO.rel_value_us == sender->mean_time.rel_value_us) |
@@ -146,7 +150,8 @@ handle_test (void *cls, | |||
146 | } | 150 | } |
147 | else | 151 | else |
148 | { | 152 | { |
149 | double factor = (double) sender->num_received/((double) sender->num_received + 1.0); | 153 | double factor = (double) sender->num_received |
154 | / ((double) sender->num_received + 1.0); | ||
150 | struct GNUNET_TIME_Relative s1; | 155 | struct GNUNET_TIME_Relative s1; |
151 | struct GNUNET_TIME_Relative s2; | 156 | struct GNUNET_TIME_Relative s2; |
152 | 157 | ||
@@ -188,7 +193,7 @@ handle_test (void *cls, | |||
188 | struct GNUNET_TESTING_BarrierList* | 193 | struct GNUNET_TESTING_BarrierList* |
189 | get_waiting_for_barriers () | 194 | get_waiting_for_barriers () |
190 | { | 195 | { |
191 | struct GNUNET_TESTING_BarrierList* barriers; | 196 | struct GNUNET_TESTING_BarrierList*barriers; |
192 | struct GNUNET_TESTING_BarrierListEntry *ble; | 197 | struct GNUNET_TESTING_BarrierListEntry *ble; |
193 | 198 | ||
194 | barriers = GNUNET_new (struct GNUNET_TESTING_BarrierList); | 199 | barriers = GNUNET_new (struct GNUNET_TESTING_BarrierList); |
@@ -307,7 +312,7 @@ all_local_tests_prepared () | |||
307 | * the topology configuration. | 312 | * the topology configuration. |
308 | * @param read_file If read_file is GNUNET_YES this string is the filename for the topology configuration, | 313 | * @param read_file If read_file is GNUNET_YES this string is the filename for the topology configuration, |
309 | * if read_file is GNUNET_NO the string contains the topology configuration. | 314 | * if read_file is GNUNET_NO the string contains the topology configuration. |
310 | * @param finish_cb Callback function which writes a message from the helper process running on a netjail | 315 | * @param finish_cb Callback function which writes a message from the helper process running on a netjail |
311 | * node to the master process * signaling that the test case running on the netjail node finished. | 316 | * node to the master process * signaling that the test case running on the netjail node finished. |
312 | * @return Returns the struct GNUNET_TESTING_Interpreter of the command loop running on this netjail node. | 317 | * @return Returns the struct GNUNET_TESTING_Interpreter of the command loop running on this netjail node. |
313 | */ | 318 | */ |
@@ -411,19 +416,20 @@ start_testcase (GNUNET_TESTING_cmd_helper_write_cb write_message, | |||
411 | struct GNUNET_MQ_MessageHandler handlers[] = { | 416 | struct GNUNET_MQ_MessageHandler handlers[] = { |
412 | GNUNET_MQ_hd_var_size (test, | 417 | GNUNET_MQ_hd_var_size (test, |
413 | GNUNET_TRANSPORT_TESTING_SIMPLE_PERFORMANCE_MTYPE, | 418 | GNUNET_TRANSPORT_TESTING_SIMPLE_PERFORMANCE_MTYPE, |
414 | struct GNUNET_TRANSPORT_TESTING_PerformanceTestMessage, | 419 | struct |
420 | GNUNET_TRANSPORT_TESTING_PerformanceTestMessage, | ||
415 | ts), | 421 | ts), |
416 | GNUNET_MQ_handler_end () | 422 | GNUNET_MQ_handler_end () |
417 | }; | 423 | }; |
418 | 424 | ||
419 | start_peer = GNUNET_TRANSPORT_cmd_start_peer ("start-peer", | 425 | start_peer = GNUNET_TRANSPORT_cmd_start_peer ("start-peer", |
420 | "system-create", | 426 | "system-create", |
421 | num, | 427 | num, |
422 | node_ip, | 428 | node_ip, |
423 | handlers, | 429 | handlers, |
424 | ts->cfgname, | 430 | ts->cfgname, |
425 | notify_connect, | 431 | notify_connect, |
426 | GNUNET_NO); | 432 | GNUNET_NO); |
427 | 433 | ||
428 | struct GNUNET_TESTING_Command commands[] = { | 434 | struct GNUNET_TESTING_Command commands[] = { |
429 | GNUNET_TESTING_cmd_system_create ("system-create", | 435 | GNUNET_TESTING_cmd_system_create ("system-create", |
@@ -437,12 +443,12 @@ start_testcase (GNUNET_TESTING_cmd_helper_write_cb write_message, | |||
437 | write_message), | 443 | write_message), |
438 | connect_peers, | 444 | connect_peers, |
439 | GNUNET_TRANSPORT_cmd_send_simple_performance ("send-simple", | 445 | GNUNET_TRANSPORT_cmd_send_simple_performance ("send-simple", |
440 | "start-peer", | 446 | "start-peer", |
441 | "system-create", | 447 | "system-create", |
442 | num, | 448 | num, |
443 | MESSAGE_SIZE, | 449 | MESSAGE_SIZE, |
444 | MAX_RECEIVED, | 450 | MAX_RECEIVED, |
445 | topology), | 451 | topology), |
446 | block_receive, | 452 | block_receive, |
447 | GNUNET_TESTING_cmd_barrier_reached ("test-case-finished-reached", | 453 | GNUNET_TESTING_cmd_barrier_reached ("test-case-finished-reached", |
448 | "test-case-finished", | 454 | "test-case-finished", |
@@ -460,9 +466,9 @@ start_testcase (GNUNET_TESTING_cmd_helper_write_cb write_message, | |||
460 | ts->write_message = write_message; | 466 | ts->write_message = write_message; |
461 | 467 | ||
462 | is = GNUNET_TESTING_run (commands, | 468 | is = GNUNET_TESTING_run (commands, |
463 | TIMEOUT, | 469 | TIMEOUT, |
464 | &handle_result, | 470 | &handle_result, |
465 | ts); | 471 | ts); |
466 | return is; | 472 | return is; |
467 | } | 473 | } |
468 | 474 | ||
diff --git a/src/transport/transport_api_cmd_send_simple_performance.c b/src/transport/transport_api_cmd_send_simple_performance.c index d7850e007..5fe8d4de8 100644 --- a/src/transport/transport_api_cmd_send_simple_performance.c +++ b/src/transport/transport_api_cmd_send_simple_performance.c | |||
@@ -80,7 +80,7 @@ struct MQWrapper | |||
80 | * State of the command. | 80 | * State of the command. |
81 | */ | 81 | */ |
82 | struct SendSimplePerfState *sss; | 82 | struct SendSimplePerfState *sss; |
83 | 83 | ||
84 | /** | 84 | /** |
85 | * Message queue for a peer. | 85 | * Message queue for a peer. |
86 | */ | 86 | */ |
@@ -169,7 +169,7 @@ send_simple_run (void *cls, | |||
169 | const struct GNUNET_TESTING_Command *peer1_cmd; | 169 | const struct GNUNET_TESTING_Command *peer1_cmd; |
170 | const struct GNUNET_TESTING_Command *system_cmd; | 170 | const struct GNUNET_TESTING_Command *system_cmd; |
171 | const struct GNUNET_TESTING_System *tl_system; | 171 | const struct GNUNET_TESTING_System *tl_system; |
172 | 172 | ||
173 | 173 | ||
174 | peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (is, | 174 | peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (is, |
175 | sss->start_peer_label); | 175 | sss->start_peer_label); |
@@ -190,13 +190,14 @@ send_simple_run (void *cls, | |||
190 | 190 | ||
191 | struct GNUNET_TESTING_Command | 191 | struct GNUNET_TESTING_Command |
192 | GNUNET_TRANSPORT_cmd_send_simple_performance (const char *label, | 192 | GNUNET_TRANSPORT_cmd_send_simple_performance (const char *label, |
193 | const char *start_peer_label, | 193 | const char *start_peer_label, |
194 | const char *create_label, | 194 | const char *create_label, |
195 | uint32_t num, | 195 | uint32_t num, |
196 | int size, | 196 | int size, |
197 | int max_send, | 197 | int max_send, |
198 | struct GNUNET_TESTING_NetjailTopology * | 198 | struct |
199 | topology) | 199 | GNUNET_TESTING_NetjailTopology * |
200 | topology) | ||
200 | { | 201 | { |
201 | struct SendSimplePerfState *sss; | 202 | struct SendSimplePerfState *sss; |
202 | struct GNUNET_TESTING_Command cmd; | 203 | struct GNUNET_TESTING_Command cmd; |
@@ -209,11 +210,11 @@ GNUNET_TRANSPORT_cmd_send_simple_performance (const char *label, | |||
209 | sss->max_send = max_send; | 210 | sss->max_send = max_send; |
210 | 211 | ||
211 | cmd = GNUNET_TESTING_command_new (sss, | 212 | cmd = GNUNET_TESTING_command_new (sss, |
212 | label, | 213 | label, |
213 | &send_simple_run, | 214 | &send_simple_run, |
214 | &send_simple_cleanup, | 215 | &send_simple_cleanup, |
215 | NULL, | 216 | NULL, |
216 | &sss->ac); | 217 | &sss->ac); |
217 | cmd.asynchronous_finish = GNUNET_YES; | 218 | cmd.asynchronous_finish = GNUNET_YES; |
218 | return cmd; | 219 | return cmd; |
219 | } | 220 | } |