summaryrefslogtreecommitdiff
path: root/toxcore/TCP_connection.c
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2018-01-13 19:19:20 +0000
committeriphydf <iphydf@users.noreply.github.com>2018-01-14 19:13:32 +0000
commitbacd74c4dd1fc6edaaacf580b20a9292f3322532 (patch)
tree546a9fe5d7eca634410236038db1e7995974d7c5 /toxcore/TCP_connection.c
parent7aca413e3231dfcfa7bc484bc44319c6780a4fc7 (diff)
Make TCP_Client_Connection a module-private type.
Diffstat (limited to 'toxcore/TCP_connection.c')
-rw-r--r--toxcore/TCP_connection.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/toxcore/TCP_connection.c b/toxcore/TCP_connection.c
index fd7e073c..a43069da 100644
--- a/toxcore/TCP_connection.c
+++ b/toxcore/TCP_connection.c
@@ -477,7 +477,7 @@ static int find_tcp_connection_relay(TCP_Connections *tcp_c, const uint8_t *rela
477 return i; 477 return i;
478 } 478 }
479 } else { 479 } else {
480 if (public_key_cmp(tcp_con->connection->public_key, relay_pk) == 0) { 480 if (public_key_cmp(tcp_con_public_key(tcp_con->connection), relay_pk) == 0) {
481 return i; 481 return i;
482 } 482 }
483 } 483 }
@@ -768,9 +768,9 @@ static int reconnect_tcp_relay_connection(TCP_Connections *tcp_c, int tcp_connec
768 return -1; 768 return -1;
769 } 769 }
770 770
771 IP_Port ip_port = tcp_con->connection->ip_port; 771 IP_Port ip_port = tcp_con_ip_port(tcp_con->connection);
772 uint8_t relay_pk[CRYPTO_PUBLIC_KEY_SIZE]; 772 uint8_t relay_pk[CRYPTO_PUBLIC_KEY_SIZE];
773 memcpy(relay_pk, tcp_con->connection->public_key, CRYPTO_PUBLIC_KEY_SIZE); 773 memcpy(relay_pk, tcp_con_public_key(tcp_con->connection), CRYPTO_PUBLIC_KEY_SIZE);
774 kill_TCP_connection(tcp_con->connection); 774 kill_TCP_connection(tcp_con->connection);
775 tcp_con->connection = new_TCP_connection(ip_port, relay_pk, tcp_c->self_public_key, tcp_c->self_secret_key, 775 tcp_con->connection = new_TCP_connection(ip_port, relay_pk, tcp_c->self_public_key, tcp_c->self_secret_key,
776 &tcp_c->proxy_info); 776 &tcp_c->proxy_info);
@@ -820,8 +820,8 @@ static int sleep_tcp_relay_connection(TCP_Connections *tcp_c, int tcp_connection
820 return -1; 820 return -1;
821 } 821 }
822 822
823 tcp_con->ip_port = tcp_con->connection->ip_port; 823 tcp_con->ip_port = tcp_con_ip_port(tcp_con->connection);
824 memcpy(tcp_con->relay_pk, tcp_con->connection->public_key, CRYPTO_PUBLIC_KEY_SIZE); 824 memcpy(tcp_con->relay_pk, tcp_con_public_key(tcp_con->connection), CRYPTO_PUBLIC_KEY_SIZE);
825 825
826 kill_TCP_connection(tcp_con->connection); 826 kill_TCP_connection(tcp_con->connection);
827 tcp_con->connection = NULL; 827 tcp_con->connection = NULL;
@@ -905,9 +905,9 @@ static int send_tcp_relay_routing_request(TCP_Connections *tcp_c, int tcp_connec
905static int tcp_response_callback(void *object, uint8_t connection_id, const uint8_t *public_key) 905static int tcp_response_callback(void *object, uint8_t connection_id, const uint8_t *public_key)
906{ 906{
907 TCP_Client_Connection *TCP_client_con = (TCP_Client_Connection *)object; 907 TCP_Client_Connection *TCP_client_con = (TCP_Client_Connection *)object;
908 TCP_Connections *tcp_c = (TCP_Connections *)TCP_client_con->custom_object; 908 TCP_Connections *tcp_c = (TCP_Connections *)tcp_con_custom_object(TCP_client_con);
909 909
910 unsigned int tcp_connections_number = TCP_client_con->custom_uint; 910 unsigned int tcp_connections_number = tcp_con_custom_uint(TCP_client_con);
911 TCP_con *tcp_con = get_tcp_connection(tcp_c, tcp_connections_number); 911 TCP_con *tcp_con = get_tcp_connection(tcp_c, tcp_connections_number);
912 912
913 if (!tcp_con) { 913 if (!tcp_con) {
@@ -938,9 +938,9 @@ static int tcp_response_callback(void *object, uint8_t connection_id, const uint
938static int tcp_status_callback(void *object, uint32_t number, uint8_t connection_id, uint8_t status) 938static int tcp_status_callback(void *object, uint32_t number, uint8_t connection_id, uint8_t status)
939{ 939{
940 TCP_Client_Connection *TCP_client_con = (TCP_Client_Connection *)object; 940 TCP_Client_Connection *TCP_client_con = (TCP_Client_Connection *)object;
941 TCP_Connections *tcp_c = (TCP_Connections *)TCP_client_con->custom_object; 941 TCP_Connections *tcp_c = (TCP_Connections *)tcp_con_custom_object(TCP_client_con);
942 942
943 unsigned int tcp_connections_number = TCP_client_con->custom_uint; 943 unsigned int tcp_connections_number = tcp_con_custom_uint(TCP_client_con);
944 TCP_con *tcp_con = get_tcp_connection(tcp_c, tcp_connections_number); 944 TCP_con *tcp_con = get_tcp_connection(tcp_c, tcp_connections_number);
945 TCP_Connection_to *con_to = get_connection(tcp_c, number); 945 TCP_Connection_to *con_to = get_connection(tcp_c, number);
946 946
@@ -981,9 +981,9 @@ static int tcp_conn_data_callback(void *object, uint32_t number, uint8_t connect
981 } 981 }
982 982
983 TCP_Client_Connection *TCP_client_con = (TCP_Client_Connection *)object; 983 TCP_Client_Connection *TCP_client_con = (TCP_Client_Connection *)object;
984 TCP_Connections *tcp_c = (TCP_Connections *)TCP_client_con->custom_object; 984 TCP_Connections *tcp_c = (TCP_Connections *)tcp_con_custom_object(TCP_client_con);
985 985
986 unsigned int tcp_connections_number = TCP_client_con->custom_uint; 986 unsigned int tcp_connections_number = tcp_con_custom_uint(TCP_client_con);
987 TCP_con *tcp_con = get_tcp_connection(tcp_c, tcp_connections_number); 987 TCP_con *tcp_con = get_tcp_connection(tcp_c, tcp_connections_number);
988 988
989 if (!tcp_con) { 989 if (!tcp_con) {
@@ -1011,9 +1011,9 @@ static int tcp_conn_oob_callback(void *object, const uint8_t *public_key, const
1011 } 1011 }
1012 1012
1013 TCP_Client_Connection *TCP_client_con = (TCP_Client_Connection *)object; 1013 TCP_Client_Connection *TCP_client_con = (TCP_Client_Connection *)object;
1014 TCP_Connections *tcp_c = (TCP_Connections *)TCP_client_con->custom_object; 1014 TCP_Connections *tcp_c = (TCP_Connections *)tcp_con_custom_object(TCP_client_con);
1015 1015
1016 unsigned int tcp_connections_number = TCP_client_con->custom_uint; 1016 unsigned int tcp_connections_number = tcp_con_custom_uint(TCP_client_con);
1017 TCP_con *tcp_con = get_tcp_connection(tcp_c, tcp_connections_number); 1017 TCP_con *tcp_con = get_tcp_connection(tcp_c, tcp_connections_number);
1018 1018
1019 if (!tcp_con) { 1019 if (!tcp_con) {
@@ -1062,8 +1062,8 @@ static int tcp_relay_set_callbacks(TCP_Connections *tcp_c, int tcp_connections_n
1062 1062
1063 TCP_Client_Connection *con = tcp_con->connection; 1063 TCP_Client_Connection *con = tcp_con->connection;
1064 1064
1065 con->custom_object = tcp_c; 1065 tcp_con_set_custom_object(con, tcp_c);
1066 con->custom_uint = tcp_connections_number; 1066 tcp_con_set_custom_uint(con, tcp_connections_number);
1067 onion_response_handler(con, &tcp_onion_callback, tcp_c); 1067 onion_response_handler(con, &tcp_onion_callback, tcp_c);
1068 routing_response_handler(con, &tcp_response_callback, con); 1068 routing_response_handler(con, &tcp_response_callback, con);
1069 routing_status_handler(con, &tcp_status_callback, con); 1069 routing_status_handler(con, &tcp_status_callback, con);
@@ -1273,8 +1273,8 @@ unsigned int tcp_copy_connected_relays(TCP_Connections *tcp_c, Node_format *tcp_
1273 } 1273 }
1274 1274
1275 if (tcp_con->status == TCP_CONN_CONNECTED) { 1275 if (tcp_con->status == TCP_CONN_CONNECTED) {
1276 memcpy(tcp_relays[copied].public_key, tcp_con->connection->public_key, CRYPTO_PUBLIC_KEY_SIZE); 1276 memcpy(tcp_relays[copied].public_key, tcp_con_public_key(tcp_con->connection), CRYPTO_PUBLIC_KEY_SIZE);
1277 tcp_relays[copied].ip_port = tcp_con->connection->ip_port; 1277 tcp_relays[copied].ip_port = tcp_con_ip_port(tcp_con->connection);
1278 1278
1279 if (tcp_relays[copied].ip_port.ip.family == TOX_AF_INET) { 1279 if (tcp_relays[copied].ip_port.ip.family == TOX_AF_INET) {
1280 tcp_relays[copied].ip_port.ip.family = TCP_INET; 1280 tcp_relays[copied].ip_port.ip.family = TCP_INET;
@@ -1402,7 +1402,7 @@ static void do_tcp_conns(TCP_Connections *tcp_c, void *userdata)
1402 // Make sure the TCP connection wasn't dropped in any of the callbacks. 1402 // Make sure the TCP connection wasn't dropped in any of the callbacks.
1403 assert(tcp_con != NULL); 1403 assert(tcp_con != NULL);
1404 1404
1405 if (tcp_con->connection->status == TCP_CLIENT_DISCONNECTED) { 1405 if (tcp_con_status(tcp_con->connection) == TCP_CLIENT_DISCONNECTED) {
1406 if (tcp_con->status == TCP_CONN_CONNECTED) { 1406 if (tcp_con->status == TCP_CONN_CONNECTED) {
1407 reconnect_tcp_relay_connection(tcp_c, i); 1407 reconnect_tcp_relay_connection(tcp_c, i);
1408 } else { 1408 } else {
@@ -1412,7 +1412,7 @@ static void do_tcp_conns(TCP_Connections *tcp_c, void *userdata)
1412 continue; 1412 continue;
1413 } 1413 }
1414 1414
1415 if (tcp_con->status == TCP_CONN_VALID && tcp_con->connection->status == TCP_CLIENT_CONFIRMED) { 1415 if (tcp_con->status == TCP_CONN_VALID && tcp_con_status(tcp_con->connection) == TCP_CLIENT_CONFIRMED) {
1416 tcp_relay_on_online(tcp_c, i); 1416 tcp_relay_on_online(tcp_c, i);
1417 } 1417 }
1418 1418