diff options
Diffstat (limited to 'src/transport/gnunet-communicator-udp.c')
-rw-r--r-- | src/transport/gnunet-communicator-udp.c | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/src/transport/gnunet-communicator-udp.c b/src/transport/gnunet-communicator-udp.c index 659fd7d26..b7a3b4082 100644 --- a/src/transport/gnunet-communicator-udp.c +++ b/src/transport/gnunet-communicator-udp.c | |||
@@ -2262,6 +2262,7 @@ static void | |||
2262 | sock_read (void *cls) | 2262 | sock_read (void *cls) |
2263 | { | 2263 | { |
2264 | struct sockaddr_storage sa; | 2264 | struct sockaddr_storage sa; |
2265 | struct sockaddr_in *addr_verify; | ||
2265 | socklen_t salen = sizeof(sa); | 2266 | socklen_t salen = sizeof(sa); |
2266 | char buf[UINT16_MAX]; | 2267 | char buf[UINT16_MAX]; |
2267 | ssize_t rcvd; | 2268 | ssize_t rcvd; |
@@ -2341,12 +2342,22 @@ sock_read (void *cls) | |||
2341 | { | 2342 | { |
2342 | const struct UDPBroadcast *ub; | 2343 | const struct UDPBroadcast *ub; |
2343 | struct UdpBroadcastSignature uhs; | 2344 | struct UdpBroadcastSignature uhs; |
2345 | struct GNUNET_PeerIdentity sender; | ||
2344 | 2346 | ||
2347 | addr_verify = GNUNET_memdup (&sa, salen); | ||
2348 | addr_verify->sin_port = 0; | ||
2349 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2350 | "received UDPBroadcast from %s\n", | ||
2351 | GNUNET_a2s ((const struct sockaddr *) addr_verify, salen)); | ||
2345 | ub = (const struct UDPBroadcast *) buf; | 2352 | ub = (const struct UDPBroadcast *) buf; |
2346 | uhs.purpose.purpose = htonl (GNUNET_SIGNATURE_COMMUNICATOR_UDP_BROADCAST); | 2353 | uhs.purpose.purpose = htonl (GNUNET_SIGNATURE_COMMUNICATOR_UDP_BROADCAST); |
2347 | uhs.purpose.size = htonl (sizeof(uhs)); | 2354 | uhs.purpose.size = htonl (sizeof(uhs)); |
2348 | uhs.sender = ub->sender; | 2355 | uhs.sender = ub->sender; |
2349 | GNUNET_CRYPTO_hash (&sa, salen, &uhs.h_address); | 2356 | sender = ub->sender; |
2357 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2358 | "checking UDPBroadcastSignature for %s\n", | ||
2359 | GNUNET_i2s (&sender)); | ||
2360 | GNUNET_CRYPTO_hash ((struct sockaddr *) addr_verify, salen, &uhs.h_address); | ||
2350 | if (GNUNET_OK == | 2361 | if (GNUNET_OK == |
2351 | GNUNET_CRYPTO_eddsa_verify (GNUNET_SIGNATURE_COMMUNICATOR_UDP_BROADCAST, | 2362 | GNUNET_CRYPTO_eddsa_verify (GNUNET_SIGNATURE_COMMUNICATOR_UDP_BROADCAST, |
2352 | &uhs, | 2363 | &uhs, |
@@ -2362,10 +2373,23 @@ sock_read (void *cls) | |||
2362 | /* use our own mechanism to determine network type */ | 2373 | /* use our own mechanism to determine network type */ |
2363 | nt = | 2374 | nt = |
2364 | GNUNET_NT_scanner_get_type (is, (const struct sockaddr *) &sa, salen); | 2375 | GNUNET_NT_scanner_get_type (is, (const struct sockaddr *) &sa, salen); |
2365 | GNUNET_TRANSPORT_application_validate (ah, &ub->sender, nt, addr_s); | 2376 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2377 | "validating address %s received from UDPBroadcast\n", | ||
2378 | GNUNET_i2s (&sender)); | ||
2379 | GNUNET_TRANSPORT_application_validate (ah, &sender, nt, addr_s); | ||
2366 | GNUNET_free (addr_s); | 2380 | GNUNET_free (addr_s); |
2367 | return; | 2381 | return; |
2368 | } | 2382 | } |
2383 | else | ||
2384 | { | ||
2385 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
2386 | "VerifyingPeer %s is verifying UDPBroadcast\n", | ||
2387 | GNUNET_i2s (&my_identity)); | ||
2388 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
2389 | "Verifying UDPBroadcast from %s failed\n", | ||
2390 | GNUNET_i2s (&ub->sender)); | ||
2391 | } | ||
2392 | GNUNET_free (addr_verify); | ||
2369 | /* continue with KX, mostly for statistics... */ | 2393 | /* continue with KX, mostly for statistics... */ |
2370 | } | 2394 | } |
2371 | 2395 | ||
@@ -3477,7 +3501,7 @@ ifc_broadcast (void *cls) | |||
3477 | delay.rel_value_us = | 3501 | delay.rel_value_us = |
3478 | GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, delay.rel_value_us); | 3502 | GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, delay.rel_value_us); |
3479 | bi->broadcast_task = | 3503 | bi->broadcast_task = |
3480 | GNUNET_SCHEDULER_add_delayed (INTERFACE_SCAN_FREQUENCY, &ifc_broadcast, bi); | 3504 | GNUNET_SCHEDULER_add_delayed (delay, &ifc_broadcast, bi); |
3481 | 3505 | ||
3482 | switch (bi->sa->sa_family) | 3506 | switch (bi->sa->sa_family) |
3483 | { | 3507 | { |
@@ -3494,6 +3518,12 @@ ifc_broadcast (void *cls) | |||
3494 | sizeof(int))) | 3518 | sizeof(int))) |
3495 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, | 3519 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, |
3496 | "setsockopt"); | 3520 | "setsockopt"); |
3521 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3522 | "creating UDPBroadcast from %s\n", | ||
3523 | GNUNET_i2s (&(bi->bcm.sender))); | ||
3524 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3525 | "sending UDPBroadcast to add %s\n", | ||
3526 | GNUNET_a2s (bi->ba, bi->salen)); | ||
3497 | sent = GNUNET_NETWORK_socket_sendto (udp_sock, | 3527 | sent = GNUNET_NETWORK_socket_sendto (udp_sock, |
3498 | &bi->bcm, | 3528 | &bi->bcm, |
3499 | sizeof(bi->bcm), | 3529 | sizeof(bi->bcm), |
@@ -3521,6 +3551,8 @@ ifc_broadcast (void *cls) | |||
3521 | dst.sin6_addr = bi->mcreq.ipv6mr_multiaddr; | 3551 | dst.sin6_addr = bi->mcreq.ipv6mr_multiaddr; |
3522 | dst.sin6_scope_id = ((struct sockaddr_in6 *) bi->ba)->sin6_scope_id; | 3552 | dst.sin6_scope_id = ((struct sockaddr_in6 *) bi->ba)->sin6_scope_id; |
3523 | 3553 | ||
3554 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3555 | "sending UDPBroadcast\n"); | ||
3524 | sent = GNUNET_NETWORK_socket_sendto (udp_sock, | 3556 | sent = GNUNET_NETWORK_socket_sendto (udp_sock, |
3525 | &bi->bcm, | 3557 | &bi->bcm, |
3526 | sizeof(bi->bcm), | 3558 | sizeof(bi->bcm), |
@@ -3608,6 +3640,9 @@ iface_proc (void *cls, | |||
3608 | ubs.purpose.purpose = htonl (GNUNET_SIGNATURE_COMMUNICATOR_UDP_BROADCAST); | 3640 | ubs.purpose.purpose = htonl (GNUNET_SIGNATURE_COMMUNICATOR_UDP_BROADCAST); |
3609 | ubs.purpose.size = htonl (sizeof(ubs)); | 3641 | ubs.purpose.size = htonl (sizeof(ubs)); |
3610 | ubs.sender = my_identity; | 3642 | ubs.sender = my_identity; |
3643 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3644 | "creating UDPBroadcastSignature for %s\n", | ||
3645 | GNUNET_a2s (addr, addrlen)); | ||
3611 | GNUNET_CRYPTO_hash (addr, addrlen, &ubs.h_address); | 3646 | GNUNET_CRYPTO_hash (addr, addrlen, &ubs.h_address); |
3612 | GNUNET_CRYPTO_eddsa_sign (my_private_key, | 3647 | GNUNET_CRYPTO_eddsa_sign (my_private_key, |
3613 | &ubs, | 3648 | &ubs, |