diff options
author | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2019-12-27 04:48:12 +0900 |
---|---|---|
committer | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2019-12-27 04:48:12 +0900 |
commit | 852b6710fb70b3943e2b2f02252bfa58bca3ce45 (patch) | |
tree | d50fd98d94f2acbf487b792e6bff1b5ffce83d63 | |
parent | 705ef31579622b7ad033ae4a22ddc30fa7040148 (diff) | |
download | gnunet-852b6710fb70b3943e2b2f02252bfa58bca3ce45.tar.gz gnunet-852b6710fb70b3943e2b2f02252bfa58bca3ce45.zip |
fix communicator IP parsing, debug udp communicator
-rw-r--r-- | src/transport/gnunet-communicator-tcp.c | 10 | ||||
-rw-r--r-- | src/transport/gnunet-communicator-udp.c | 50 | ||||
-rw-r--r-- | src/transport/test_communicator_udp_peer1.conf | 1 | ||||
-rw-r--r-- | src/transport/test_communicator_udp_peer2.conf | 1 |
4 files changed, 46 insertions, 16 deletions
diff --git a/src/transport/gnunet-communicator-tcp.c b/src/transport/gnunet-communicator-tcp.c index e902e2316..107a37838 100644 --- a/src/transport/gnunet-communicator-tcp.c +++ b/src/transport/gnunet-communicator-tcp.c | |||
@@ -1183,10 +1183,13 @@ tcp_address_to_sockaddr (const char *bindto, socklen_t *sock_len) | |||
1183 | /* try IPv4 */ | 1183 | /* try IPv4 */ |
1184 | struct sockaddr_in v4; | 1184 | struct sockaddr_in v4; |
1185 | 1185 | ||
1186 | if (1 == inet_pton (AF_INET, cp, &v4)) | 1186 | if (1 == inet_pton (AF_INET, cp, &v4.sin_addr)) |
1187 | { | 1187 | { |
1188 | v4.sin_family = AF_INET; | 1188 | v4.sin_family = AF_INET; |
1189 | v4.sin_port = htons ((uint16_t) port); | 1189 | v4.sin_port = htons ((uint16_t) port); |
1190 | #if HAVE_SOCKADDR_IN_SIN_LEN | ||
1191 | v4.sin_len = sizeof(struct sockaddr_in); | ||
1192 | #endif | ||
1190 | in = GNUNET_memdup (&v4, sizeof(v4)); | 1193 | in = GNUNET_memdup (&v4, sizeof(v4)); |
1191 | *sock_len = sizeof(v4); | 1194 | *sock_len = sizeof(v4); |
1192 | GNUNET_free (cp); | 1195 | GNUNET_free (cp); |
@@ -1204,10 +1207,13 @@ tcp_address_to_sockaddr (const char *bindto, socklen_t *sock_len) | |||
1204 | start++; /* skip over '[' */ | 1207 | start++; /* skip over '[' */ |
1205 | cp[strlen (cp) - 1] = '\0'; /* eat ']' */ | 1208 | cp[strlen (cp) - 1] = '\0'; /* eat ']' */ |
1206 | } | 1209 | } |
1207 | if (1 == inet_pton (AF_INET6, start, &v6)) | 1210 | if (1 == inet_pton (AF_INET6, start, &v6.sin6_addr)) |
1208 | { | 1211 | { |
1209 | v6.sin6_family = AF_INET6; | 1212 | v6.sin6_family = AF_INET6; |
1210 | v6.sin6_port = htons ((uint16_t) port); | 1213 | v6.sin6_port = htons ((uint16_t) port); |
1214 | #if HAVE_SOCKADDR_IN_SIN_LEN | ||
1215 | v6.sin6_len = sizeof(sizeof(struct sockaddr_in6)); | ||
1216 | #endif | ||
1211 | in = GNUNET_memdup (&v6, sizeof(v6)); | 1217 | in = GNUNET_memdup (&v6, sizeof(v6)); |
1212 | *sock_len = sizeof(v6); | 1218 | *sock_len = sizeof(v6); |
1213 | GNUNET_free (cp); | 1219 | GNUNET_free (cp); |
diff --git a/src/transport/gnunet-communicator-udp.c b/src/transport/gnunet-communicator-udp.c index 80fc4142b..6a4fea315 100644 --- a/src/transport/gnunet-communicator-udp.c +++ b/src/transport/gnunet-communicator-udp.c | |||
@@ -1593,7 +1593,8 @@ sock_read (void *cls) | |||
1593 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_DEBUG, "recv"); | 1593 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_DEBUG, "recv"); |
1594 | return; | 1594 | return; |
1595 | } | 1595 | } |
1596 | 1596 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | |
1597 | "Read %lu bytes\n", rcvd); | ||
1597 | /* first, see if it is a UDPBox */ | 1598 | /* first, see if it is a UDPBox */ |
1598 | if (rcvd > sizeof(struct UDPBox)) | 1599 | if (rcvd > sizeof(struct UDPBox)) |
1599 | { | 1600 | { |
@@ -1652,7 +1653,8 @@ sock_read (void *cls) | |||
1652 | GNUNET_NO); | 1653 | GNUNET_NO); |
1653 | return; | 1654 | return; |
1654 | } | 1655 | } |
1655 | 1656 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | |
1657 | "Got KX\n"); | ||
1656 | { | 1658 | { |
1657 | const struct InitialKX *kx; | 1659 | const struct InitialKX *kx; |
1658 | struct SharedSecret *ss; | 1660 | struct SharedSecret *ss; |
@@ -1669,6 +1671,8 @@ sock_read (void *cls) | |||
1669 | sizeof(pbuf), | 1671 | sizeof(pbuf), |
1670 | pbuf)) | 1672 | pbuf)) |
1671 | { | 1673 | { |
1674 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1675 | "Unable to decrypt tag, dropping...\n"); | ||
1672 | GNUNET_free (ss); | 1676 | GNUNET_free (ss); |
1673 | GNUNET_STATISTICS_update ( | 1677 | GNUNET_STATISTICS_update ( |
1674 | stats, | 1678 | stats, |
@@ -1795,12 +1799,15 @@ udp_address_to_sockaddr (const char *bindto, socklen_t *sock_len) | |||
1795 | { | 1799 | { |
1796 | /* try IPv4 */ | 1800 | /* try IPv4 */ |
1797 | struct sockaddr_in v4; | 1801 | struct sockaddr_in v4; |
1798 | 1802 | if (1 == inet_pton (AF_INET, cp, &v4.sin_addr)) | |
1799 | if (1 == inet_pton (AF_INET, cp, &v4)) | ||
1800 | { | 1803 | { |
1804 | v4.sin_family = AF_INET; | ||
1801 | v4.sin_port = htons ((uint16_t) port); | 1805 | v4.sin_port = htons ((uint16_t) port); |
1802 | in = GNUNET_memdup (&v4, sizeof(v4)); | 1806 | #if HAVE_SOCKADDR_IN_SIN_LEN |
1803 | *sock_len = sizeof(v4); | 1807 | v4.sin_len = sizeof(struct sockaddr_in); |
1808 | #endif | ||
1809 | in = GNUNET_memdup (&v4, sizeof(struct sockaddr_in)); | ||
1810 | *sock_len = sizeof(struct sockaddr_in); | ||
1804 | GNUNET_free (cp); | 1811 | GNUNET_free (cp); |
1805 | return in; | 1812 | return in; |
1806 | } | 1813 | } |
@@ -1816,9 +1823,13 @@ udp_address_to_sockaddr (const char *bindto, socklen_t *sock_len) | |||
1816 | start++; /* skip over '[' */ | 1823 | start++; /* skip over '[' */ |
1817 | cp[strlen (cp) - 1] = '\0'; /* eat ']' */ | 1824 | cp[strlen (cp) - 1] = '\0'; /* eat ']' */ |
1818 | } | 1825 | } |
1819 | if (1 == inet_pton (AF_INET6, start, &v6)) | 1826 | if (1 == inet_pton (AF_INET6, start, &v6.sin6_addr)) |
1820 | { | 1827 | { |
1828 | v6.sin6_family = AF_INET6; | ||
1821 | v6.sin6_port = htons ((uint16_t) port); | 1829 | v6.sin6_port = htons ((uint16_t) port); |
1830 | #if HAVE_SOCKADDR_IN_SIN_LEN | ||
1831 | v6.sin6_len = sizeof(sizeof(struct sockaddr_in6)); | ||
1832 | #endif | ||
1822 | in = GNUNET_memdup (&v6, sizeof(v6)); | 1833 | in = GNUNET_memdup (&v6, sizeof(v6)); |
1823 | *sock_len = sizeof(v6); | 1834 | *sock_len = sizeof(v6); |
1824 | GNUNET_free (cp); | 1835 | GNUNET_free (cp); |
@@ -1914,7 +1925,7 @@ mq_send (struct GNUNET_MQ_Handle *mq, | |||
1914 | &uhs.purpose, | 1925 | &uhs.purpose, |
1915 | &uc.sender_sig)); | 1926 | &uc.sender_sig)); |
1916 | /* Leave space for kx */ | 1927 | /* Leave space for kx */ |
1917 | dpos = sizeof(struct GNUNET_CRYPTO_EcdhePublicKey); | 1928 | dpos = sizeof(kx); |
1918 | /* Append encrypted uc to dgram */ | 1929 | /* Append encrypted uc to dgram */ |
1919 | GNUNET_assert (0 == gcry_cipher_encrypt (out_cipher, | 1930 | GNUNET_assert (0 == gcry_cipher_encrypt (out_cipher, |
1920 | &dgram[dpos], | 1931 | &dgram[dpos], |
@@ -1939,6 +1950,8 @@ mq_send (struct GNUNET_MQ_Handle *mq, | |||
1939 | receiver->address, | 1950 | receiver->address, |
1940 | receiver->address_len)) | 1951 | receiver->address_len)) |
1941 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "send"); | 1952 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "send"); |
1953 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1954 | "Sending KX to %s\n", GNUNET_a2s (receiver->address, receiver->address_len)); | ||
1942 | GNUNET_MQ_impl_send_continue (mq); | 1955 | GNUNET_MQ_impl_send_continue (mq); |
1943 | return; | 1956 | return; |
1944 | } /* End of KX encryption method */ | 1957 | } /* End of KX encryption method */ |
@@ -1973,12 +1986,17 @@ mq_send (struct GNUNET_MQ_Handle *mq, | |||
1973 | receiver->address, | 1986 | receiver->address, |
1974 | receiver->address_len)) | 1987 | receiver->address_len)) |
1975 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "send"); | 1988 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "send"); |
1989 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1990 | "Sending data\n"); | ||
1991 | |||
1976 | GNUNET_MQ_impl_send_continue (mq); | 1992 | GNUNET_MQ_impl_send_continue (mq); |
1977 | receiver->acks_available--; | 1993 | receiver->acks_available--; |
1978 | if (0 == receiver->acks_available) | 1994 | if (0 == receiver->acks_available) |
1979 | { | 1995 | { |
1980 | /* We have no more ACKs => MTU change! */ | 1996 | /* We have no more ACKs => MTU change! */ |
1981 | setup_receiver_mq (receiver); | 1997 | setup_receiver_mq (receiver); |
1998 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1999 | "No more acks, MTU changed\n"); | ||
1982 | } | 2000 | } |
1983 | return; | 2001 | return; |
1984 | } | 2002 | } |
@@ -2505,8 +2523,11 @@ iface_proc (void *cls, | |||
2505 | GNUNET_assert (GNUNET_OK == GNUNET_CRYPTO_eddsa_sign (my_private_key, | 2523 | GNUNET_assert (GNUNET_OK == GNUNET_CRYPTO_eddsa_sign (my_private_key, |
2506 | &ubs.purpose, | 2524 | &ubs.purpose, |
2507 | &bi->bcm.sender_sig)); | 2525 | &bi->bcm.sender_sig)); |
2508 | bi->broadcast_task = GNUNET_SCHEDULER_add_now (&ifc_broadcast, bi); | 2526 | if (NULL != broadcast_addr) |
2509 | GNUNET_CONTAINER_DLL_insert (bi_head, bi_tail, bi); | 2527 | { |
2528 | bi->broadcast_task = GNUNET_SCHEDULER_add_now (&ifc_broadcast, bi); | ||
2529 | GNUNET_CONTAINER_DLL_insert (bi_head, bi_tail, bi); | ||
2530 | } | ||
2510 | if ((AF_INET6 == addr->sa_family) && (NULL != broadcast_addr)) | 2531 | if ((AF_INET6 == addr->sa_family) && (NULL != broadcast_addr)) |
2511 | { | 2532 | { |
2512 | /* Create IPv6 multicast request */ | 2533 | /* Create IPv6 multicast request */ |
@@ -2591,10 +2612,10 @@ run (void *cls, | |||
2591 | (void) cls; | 2612 | (void) cls; |
2592 | cfg = c; | 2613 | cfg = c; |
2593 | if (GNUNET_OK != | 2614 | if (GNUNET_OK != |
2594 | GNUNET_CONFIGURATION_get_value_filename (cfg, | 2615 | GNUNET_CONFIGURATION_get_value_string (cfg, |
2595 | COMMUNICATOR_CONFIG_SECTION, | 2616 | COMMUNICATOR_CONFIG_SECTION, |
2596 | "BINDTO", | 2617 | "BINDTO", |
2597 | &bindto)) | 2618 | &bindto)) |
2598 | { | 2619 | { |
2599 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, | 2620 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, |
2600 | COMMUNICATOR_CONFIG_SECTION, | 2621 | COMMUNICATOR_CONFIG_SECTION, |
@@ -2631,6 +2652,7 @@ run (void *cls, | |||
2631 | GNUNET_free (bindto); | 2652 | GNUNET_free (bindto); |
2632 | return; | 2653 | return; |
2633 | } | 2654 | } |
2655 | |||
2634 | /* We might have bound to port 0, allowing the OS to figure it out; | 2656 | /* We might have bound to port 0, allowing the OS to figure it out; |
2635 | thus, get the real IN-address from the socket */ | 2657 | thus, get the real IN-address from the socket */ |
2636 | sto_len = sizeof(in_sto); | 2658 | sto_len = sizeof(in_sto); |
diff --git a/src/transport/test_communicator_udp_peer1.conf b/src/transport/test_communicator_udp_peer1.conf index fc08af1ee..417e92ab5 100644 --- a/src/transport/test_communicator_udp_peer1.conf +++ b/src/transport/test_communicator_udp_peer1.conf | |||
@@ -29,3 +29,4 @@ DISABLE_V6 = YES | |||
29 | 29 | ||
30 | [communicator-udp] | 30 | [communicator-udp] |
31 | BINDTO = 60002 | 31 | BINDTO = 60002 |
32 | DISABLE_V6 = YES | ||
diff --git a/src/transport/test_communicator_udp_peer2.conf b/src/transport/test_communicator_udp_peer2.conf index 4197df00d..a063a545a 100644 --- a/src/transport/test_communicator_udp_peer2.conf +++ b/src/transport/test_communicator_udp_peer2.conf | |||
@@ -29,3 +29,4 @@ DISABLE_V6 = YES | |||
29 | 29 | ||
30 | [communicator-udp] | 30 | [communicator-udp] |
31 | BINDTO = 60003 | 31 | BINDTO = 60003 |
32 | DISABLE_V6 = YES | ||