diff options
author | iphydf <iphydf@users.noreply.github.com> | 2018-02-27 01:07:46 +0000 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2018-05-20 19:35:28 +0000 |
commit | 21675ce0d2581597b0e0a727ab4cf6cfb796a037 (patch) | |
tree | e1ac4ca63c5cc2b2dc78fcd5b20a8202eab98d9d /toxcore/TCP_connection.c | |
parent | 4f6ab0708c85f3e3da7726f6caecc381c6d21370 (diff) |
Finish @Diadlo's network Family abstraction.
The Family stuff in toxcore is a big mess. I'm sure I saw a bunch of bugs
on the way, but I'm not verifying that code now, so the bugs stay.
Diffstat (limited to 'toxcore/TCP_connection.c')
-rw-r--r-- | toxcore/TCP_connection.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/toxcore/TCP_connection.c b/toxcore/TCP_connection.c index 72642264..06cb6e34 100644 --- a/toxcore/TCP_connection.c +++ b/toxcore/TCP_connection.c | |||
@@ -1125,13 +1125,13 @@ static int tcp_relay_on_online(TCP_Connections *tcp_c, int tcp_connections_numbe | |||
1125 | 1125 | ||
1126 | static int add_tcp_relay_instance(TCP_Connections *tcp_c, IP_Port ip_port, const uint8_t *relay_pk) | 1126 | static int add_tcp_relay_instance(TCP_Connections *tcp_c, IP_Port ip_port, const uint8_t *relay_pk) |
1127 | { | 1127 | { |
1128 | if (ip_port.ip.family == TCP_INET) { | 1128 | if (net_family_is_tcp_ipv4(ip_port.ip.family)) { |
1129 | ip_port.ip.family = TOX_AF_INET; | 1129 | ip_port.ip.family = net_family_ipv4; |
1130 | } else if (ip_port.ip.family == TCP_INET6) { | 1130 | } else if (net_family_is_tcp_ipv6(ip_port.ip.family)) { |
1131 | ip_port.ip.family = TOX_AF_INET6; | 1131 | ip_port.ip.family = net_family_ipv6; |
1132 | } | 1132 | } |
1133 | 1133 | ||
1134 | if (ip_port.ip.family != TOX_AF_INET && ip_port.ip.family != TOX_AF_INET6) { | 1134 | if (!net_family_is_ipv4(ip_port.ip.family) && !net_family_is_ipv6(ip_port.ip.family)) { |
1135 | return -1; | 1135 | return -1; |
1136 | } | 1136 | } |
1137 | 1137 | ||
@@ -1286,10 +1286,12 @@ unsigned int tcp_copy_connected_relays(TCP_Connections *tcp_c, Node_format *tcp_ | |||
1286 | memcpy(tcp_relays[copied].public_key, tcp_con_public_key(tcp_con->connection), CRYPTO_PUBLIC_KEY_SIZE); | 1286 | memcpy(tcp_relays[copied].public_key, tcp_con_public_key(tcp_con->connection), CRYPTO_PUBLIC_KEY_SIZE); |
1287 | tcp_relays[copied].ip_port = tcp_con_ip_port(tcp_con->connection); | 1287 | tcp_relays[copied].ip_port = tcp_con_ip_port(tcp_con->connection); |
1288 | 1288 | ||
1289 | if (tcp_relays[copied].ip_port.ip.family == TOX_AF_INET) { | 1289 | Family *const family = &tcp_relays[copied].ip_port.ip.family; |
1290 | tcp_relays[copied].ip_port.ip.family = TCP_INET; | 1290 | |
1291 | } else if (tcp_relays[copied].ip_port.ip.family == TOX_AF_INET6) { | 1291 | if (net_family_is_ipv4(*family)) { |
1292 | tcp_relays[copied].ip_port.ip.family = TCP_INET6; | 1292 | *family = net_family_tcp_ipv4; |
1293 | } else if (net_family_is_ipv6(*family)) { | ||
1294 | *family = net_family_tcp_ipv6; | ||
1293 | } | 1295 | } |
1294 | 1296 | ||
1295 | ++copied; | 1297 | ++copied; |