summaryrefslogtreecommitdiff
path: root/toxcore/TCP_server.c
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2018-02-27 01:07:46 +0000
committeriphydf <iphydf@users.noreply.github.com>2018-05-20 19:35:28 +0000
commit21675ce0d2581597b0e0a727ab4cf6cfb796a037 (patch)
treee1ac4ca63c5cc2b2dc78fcd5b20a8202eab98d9d /toxcore/TCP_server.c
parent4f6ab0708c85f3e3da7726f6caecc381c6d21370 (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_server.c')
-rw-r--r--toxcore/TCP_server.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/toxcore/TCP_server.c b/toxcore/TCP_server.c
index 28a441ad..65dc81c3 100644
--- a/toxcore/TCP_server.c
+++ b/toxcore/TCP_server.c
@@ -889,7 +889,7 @@ static int handle_TCP_packet(TCP_Server *TCP_server, uint32_t con_id, const uint
889 889
890 IP_Port source; 890 IP_Port source;
891 source.port = 0; // dummy initialise 891 source.port = 0; // dummy initialise
892 source.ip.family = TCP_ONION_FAMILY; 892 source.ip.family = net_family_tcp_onion;
893 source.ip.ip.v6.uint32[0] = con_id; 893 source.ip.ip.v6.uint32[0] = con_id;
894 source.ip.ip.v6.uint32[1] = 0; 894 source.ip.ip.v6.uint32[1] = 0;
895 source.ip.ip.v6.uint64[1] = con->identifier; 895 source.ip.ip.v6.uint64[1] = con->identifier;
@@ -1007,7 +1007,7 @@ static Socket new_listening_TCP_socket(Family family, uint16_t port)
1007 1007
1008 int ok = set_socket_nonblock(sock); 1008 int ok = set_socket_nonblock(sock);
1009 1009
1010 if (ok && family == TOX_AF_INET6) { 1010 if (ok && net_family_is_ipv6(family)) {
1011 ok = set_socket_dualstack(sock); 1011 ok = set_socket_dualstack(sock);
1012 } 1012 }
1013 1013
@@ -1060,13 +1060,7 @@ TCP_Server *new_TCP_server(uint8_t ipv6_enabled, uint16_t num_sockets, const uin
1060 1060
1061#endif 1061#endif
1062 1062
1063 uint8_t family; 1063 const Family family = ipv6_enabled ? net_family_ipv6 : net_family_ipv4;
1064
1065 if (ipv6_enabled) {
1066 family = TOX_AF_INET6;
1067 } else {
1068 family = TOX_AF_INET;
1069 }
1070 1064
1071 uint32_t i; 1065 uint32_t i;
1072#ifdef TCP_SERVER_USE_EPOLL 1066#ifdef TCP_SERVER_USE_EPOLL