summaryrefslogtreecommitdiff
path: root/toxcore/TCP_client.c
diff options
context:
space:
mode:
authorDiadlo <polsha3@gmail.com>2017-03-02 23:15:51 +0300
committerDiadlo <polsha3@gmail.com>2017-08-24 20:09:08 +0300
commit66b8a7685e8fdecd6104f01f840f5d792ce1e041 (patch)
tree7c65281aefeb21c55ba422ff7d9587675eeb7070 /toxcore/TCP_client.c
parent8f19c926c0d5231ede61a831050664103e54000e (diff)
AF_INET -> TOX_AF_INET
Diffstat (limited to 'toxcore/TCP_client.c')
-rw-r--r--toxcore/TCP_client.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/toxcore/TCP_client.c b/toxcore/TCP_client.c
index e584b265..f44fabb3 100644
--- a/toxcore/TCP_client.c
+++ b/toxcore/TCP_client.c
@@ -145,7 +145,7 @@ static void proxy_socks5_generate_connection_request(TCP_Client_Connection *TCP_
145 TCP_conn->last_packet[2] = 0; /* reserved, must be 0 */ 145 TCP_conn->last_packet[2] = 0; /* reserved, must be 0 */
146 uint16_t length = 3; 146 uint16_t length = 3;
147 147
148 if (TCP_conn->ip_port.ip.family == AF_INET) { 148 if (TCP_conn->ip_port.ip.family == TOX_AF_INET) {
149 TCP_conn->last_packet[3] = 1; /* IPv4 address */ 149 TCP_conn->last_packet[3] = 1; /* IPv4 address */
150 ++length; 150 ++length;
151 memcpy(TCP_conn->last_packet + length, TCP_conn->ip_port.ip.ip4.uint8, sizeof(IP4)); 151 memcpy(TCP_conn->last_packet + length, TCP_conn->ip_port.ip.ip4.uint8, sizeof(IP4));
@@ -170,7 +170,7 @@ static void proxy_socks5_generate_connection_request(TCP_Client_Connection *TCP_
170 */ 170 */
171static int proxy_socks5_read_connection_response(TCP_Client_Connection *TCP_conn) 171static int proxy_socks5_read_connection_response(TCP_Client_Connection *TCP_conn)
172{ 172{
173 if (TCP_conn->ip_port.ip.family == AF_INET) { 173 if (TCP_conn->ip_port.ip.family == TOX_AF_INET) {
174 uint8_t data[4 + sizeof(IP4) + sizeof(uint16_t)]; 174 uint8_t data[4 + sizeof(IP4) + sizeof(uint16_t)];
175 int ret = read_TCP_packet(TCP_conn->sock, data, sizeof(data)); 175 int ret = read_TCP_packet(TCP_conn->sock, data, sizeof(data));
176 176
@@ -251,7 +251,8 @@ static int client_send_pending_data_nonpriority(TCP_Client_Connection *con)
251 } 251 }
252 252
253 uint16_t left = con->last_packet_length - con->last_packet_sent; 253 uint16_t left = con->last_packet_length - con->last_packet_sent;
254 int len = send(con->sock, (const char *)(con->last_packet + con->last_packet_sent), left, MSG_NOSIGNAL); 254 const char *data = (const char *)(con->last_packet + con->last_packet_sent);
255 int len = send(con->sock, data, left, MSG_NOSIGNAL);
255 256
256 if (len <= 0) { 257 if (len <= 0) {
257 return -1; 258 return -1;
@@ -614,12 +615,10 @@ TCP_Client_Connection *new_TCP_connection(IP_Port ip_port, const uint8_t *public
614 return NULL; 615 return NULL;
615 } 616 }
616 617
617 if (ip_port.ip.family != AF_INET && ip_port.ip.family != AF_INET6) { 618 if (ip_port.ip.family != TOX_AF_INET && ip_port.ip.family != TOX_AF_INET6) {
618 return NULL; 619 return NULL;
619 } 620 }
620 621
621 uint8_t family = ip_port.ip.family;
622
623 TCP_Proxy_Info default_proxyinfo; 622 TCP_Proxy_Info default_proxyinfo;
624 623
625 if (proxy_info == NULL) { 624 if (proxy_info == NULL) {
@@ -627,6 +626,8 @@ TCP_Client_Connection *new_TCP_connection(IP_Port ip_port, const uint8_t *public
627 proxy_info = &default_proxyinfo; 626 proxy_info = &default_proxyinfo;
628 } 627 }
629 628
629 uint8_t family = ip_port.ip.family;
630
630 if (proxy_info->proxy_type != TCP_PROXY_NONE) { 631 if (proxy_info->proxy_type != TCP_PROXY_NONE) {
631 family = proxy_info->ip_port.ip.family; 632 family = proxy_info->ip_port.ip.family;
632 } 633 }