diff options
author | mannol <eniz_vukovic@hotmail.com> | 2014-07-03 17:08:38 +0200 |
---|---|---|
committer | mannol <eniz_vukovic@hotmail.com> | 2014-07-03 17:08:38 +0200 |
commit | f8a2a865dc32bfa626cc150a509d30d897e1181b (patch) | |
tree | 5bb6b234149cdf2a79422815dc59a0c53cb3cb0e /toxcore/TCP_client.c | |
parent | a9a7f6a5952d0385904ec9df078ac065a3f5887f (diff) | |
parent | c4f0650ae33e1669bfc994ef4f76c6c31e4d63c0 (diff) |
Resolved conflicts when merging upstream
Diffstat (limited to 'toxcore/TCP_client.c')
-rw-r--r-- | toxcore/TCP_client.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/toxcore/TCP_client.c b/toxcore/TCP_client.c index e4845852..087188f7 100644 --- a/toxcore/TCP_client.c +++ b/toxcore/TCP_client.c | |||
@@ -65,7 +65,8 @@ static int connect_sock_to(sock_t sock, IP_Port ip_port) | |||
65 | /* return 0 on success. | 65 | /* return 0 on success. |
66 | * return -1 on failure. | 66 | * return -1 on failure. |
67 | */ | 67 | */ |
68 | static int generate_handshake(TCP_Client_Connection *TCP_conn, uint8_t *self_public_key, uint8_t *self_secret_key) | 68 | static int generate_handshake(TCP_Client_Connection *TCP_conn, const uint8_t *self_public_key, |
69 | const uint8_t *self_secret_key) | ||
69 | { | 70 | { |
70 | uint8_t plain[crypto_box_PUBLICKEYBYTES + crypto_box_NONCEBYTES]; | 71 | uint8_t plain[crypto_box_PUBLICKEYBYTES + crypto_box_NONCEBYTES]; |
71 | crypto_box_keypair(plain, TCP_conn->temp_secret_key); | 72 | crypto_box_keypair(plain, TCP_conn->temp_secret_key); |
@@ -90,7 +91,7 @@ static int generate_handshake(TCP_Client_Connection *TCP_conn, uint8_t *self_pub | |||
90 | * return 0 on success. | 91 | * return 0 on success. |
91 | * return -1 on failure. | 92 | * return -1 on failure. |
92 | */ | 93 | */ |
93 | static int handle_handshake(TCP_Client_Connection *TCP_conn, uint8_t *data) | 94 | static int handle_handshake(TCP_Client_Connection *TCP_conn, const uint8_t *data) |
94 | { | 95 | { |
95 | uint8_t plain[crypto_box_PUBLICKEYBYTES + crypto_box_NONCEBYTES]; | 96 | uint8_t plain[crypto_box_PUBLICKEYBYTES + crypto_box_NONCEBYTES]; |
96 | int len = decrypt_data_symmetric(TCP_conn->shared_key, data, data + crypto_box_NONCEBYTES, | 97 | int len = decrypt_data_symmetric(TCP_conn->shared_key, data, data + crypto_box_NONCEBYTES, |
@@ -137,7 +138,7 @@ static int send_pending_data(TCP_Client_Connection *con) | |||
137 | * return 0 if could not send packet. | 138 | * return 0 if could not send packet. |
138 | * return -1 on failure (connection must be killed). | 139 | * return -1 on failure (connection must be killed). |
139 | */ | 140 | */ |
140 | static int write_packet_TCP_secure_connection(TCP_Client_Connection *con, uint8_t *data, uint16_t length) | 141 | static int write_packet_TCP_secure_connection(TCP_Client_Connection *con, const uint8_t *data, uint16_t length) |
141 | { | 142 | { |
142 | if (length + crypto_box_MACBYTES > MAX_PACKET_SIZE) | 143 | if (length + crypto_box_MACBYTES > MAX_PACKET_SIZE) |
143 | return -1; | 144 | return -1; |
@@ -183,7 +184,7 @@ int send_routing_request(TCP_Client_Connection *con, uint8_t *public_key) | |||
183 | } | 184 | } |
184 | 185 | ||
185 | void routing_response_handler(TCP_Client_Connection *con, int (*response_callback)(void *object, uint8_t connection_id, | 186 | void routing_response_handler(TCP_Client_Connection *con, int (*response_callback)(void *object, uint8_t connection_id, |
186 | uint8_t *public_key), void *object) | 187 | const uint8_t *public_key), void *object) |
187 | { | 188 | { |
188 | con->response_callback = response_callback; | 189 | con->response_callback = response_callback; |
189 | con->response_callback_object = object; | 190 | con->response_callback_object = object; |
@@ -200,7 +201,7 @@ void routing_status_handler(TCP_Client_Connection *con, int (*status_callback)(v | |||
200 | * return 0 if could not send packet. | 201 | * return 0 if could not send packet. |
201 | * return -1 on failure. | 202 | * return -1 on failure. |
202 | */ | 203 | */ |
203 | int send_data(TCP_Client_Connection *con, uint8_t con_id, uint8_t *data, uint16_t length) | 204 | int send_data(TCP_Client_Connection *con, uint8_t con_id, const uint8_t *data, uint16_t length) |
204 | { | 205 | { |
205 | if (con_id >= NUM_CLIENT_CONNECTIONS) | 206 | if (con_id >= NUM_CLIENT_CONNECTIONS) |
206 | return -1; | 207 | return -1; |
@@ -218,7 +219,7 @@ int send_data(TCP_Client_Connection *con, uint8_t con_id, uint8_t *data, uint16_ | |||
218 | * return 0 if could not send packet. | 219 | * return 0 if could not send packet. |
219 | * return -1 on failure. | 220 | * return -1 on failure. |
220 | */ | 221 | */ |
221 | int send_oob_packet(TCP_Client_Connection *con, uint8_t *public_key, uint8_t *data, uint16_t length) | 222 | int send_oob_packet(TCP_Client_Connection *con, const uint8_t *public_key, const uint8_t *data, uint16_t length) |
222 | { | 223 | { |
223 | if (length == 0 || length > TCP_MAX_OOB_DATA_LENGTH) | 224 | if (length == 0 || length > TCP_MAX_OOB_DATA_LENGTH) |
224 | return -1; | 225 | return -1; |
@@ -251,14 +252,14 @@ int set_tcp_connection_number(TCP_Client_Connection *con, uint8_t con_id, uint32 | |||
251 | } | 252 | } |
252 | 253 | ||
253 | void routing_data_handler(TCP_Client_Connection *con, int (*data_callback)(void *object, uint32_t number, | 254 | void routing_data_handler(TCP_Client_Connection *con, int (*data_callback)(void *object, uint32_t number, |
254 | uint8_t connection_id, uint8_t *data, uint16_t length), void *object) | 255 | uint8_t connection_id, const uint8_t *data, uint16_t length), void *object) |
255 | { | 256 | { |
256 | con->data_callback = data_callback; | 257 | con->data_callback = data_callback; |
257 | con->data_callback_object = object; | 258 | con->data_callback_object = object; |
258 | } | 259 | } |
259 | 260 | ||
260 | void oob_data_handler(TCP_Client_Connection *con, int (*oob_data_callback)(void *object, uint8_t *public_key, | 261 | void oob_data_handler(TCP_Client_Connection *con, int (*oob_data_callback)(void *object, const uint8_t *public_key, |
261 | uint8_t *data, uint16_t length), void *object) | 262 | const uint8_t *data, uint16_t length), void *object) |
262 | { | 263 | { |
263 | con->oob_data_callback = oob_data_callback; | 264 | con->oob_data_callback = oob_data_callback; |
264 | con->oob_data_callback_object = object; | 265 | con->oob_data_callback_object = object; |
@@ -318,7 +319,7 @@ int send_disconnect_request(TCP_Client_Connection *con, uint8_t con_id) | |||
318 | * return 0 if could not send packet. | 319 | * return 0 if could not send packet. |
319 | * return -1 on failure (connection must be killed). | 320 | * return -1 on failure (connection must be killed). |
320 | */ | 321 | */ |
321 | int send_onion_request(TCP_Client_Connection *con, uint8_t *data, uint16_t length) | 322 | int send_onion_request(TCP_Client_Connection *con, const uint8_t *data, uint16_t length) |
322 | { | 323 | { |
323 | uint8_t packet[1 + length]; | 324 | uint8_t packet[1 + length]; |
324 | packet[0] = TCP_PACKET_ONION_REQUEST; | 325 | packet[0] = TCP_PACKET_ONION_REQUEST; |
@@ -326,7 +327,7 @@ int send_onion_request(TCP_Client_Connection *con, uint8_t *data, uint16_t lengt | |||
326 | return write_packet_TCP_secure_connection(con, packet, sizeof(packet)); | 327 | return write_packet_TCP_secure_connection(con, packet, sizeof(packet)); |
327 | } | 328 | } |
328 | 329 | ||
329 | void onion_response_handler(TCP_Client_Connection *con, int (*onion_callback)(void *object, uint8_t *data, | 330 | void onion_response_handler(TCP_Client_Connection *con, int (*onion_callback)(void *object, const uint8_t *data, |
330 | uint16_t length), void *object) | 331 | uint16_t length), void *object) |
331 | { | 332 | { |
332 | con->onion_callback = onion_callback; | 333 | con->onion_callback = onion_callback; |
@@ -335,8 +336,8 @@ void onion_response_handler(TCP_Client_Connection *con, int (*onion_callback)(vo | |||
335 | 336 | ||
336 | /* Create new TCP connection to ip_port/public_key | 337 | /* Create new TCP connection to ip_port/public_key |
337 | */ | 338 | */ |
338 | TCP_Client_Connection *new_TCP_connection(IP_Port ip_port, uint8_t *public_key, uint8_t *self_public_key, | 339 | TCP_Client_Connection *new_TCP_connection(IP_Port ip_port, const uint8_t *public_key, const uint8_t *self_public_key, |
339 | uint8_t *self_secret_key) | 340 | const uint8_t *self_secret_key) |
340 | { | 341 | { |
341 | if (networking_at_startup() != 0) { | 342 | if (networking_at_startup() != 0) { |
342 | return NULL; | 343 | return NULL; |
@@ -388,7 +389,7 @@ TCP_Client_Connection *new_TCP_connection(IP_Port ip_port, uint8_t *public_key, | |||
388 | /* return 0 on success | 389 | /* return 0 on success |
389 | * return -1 on failure | 390 | * return -1 on failure |
390 | */ | 391 | */ |
391 | static int handle_TCP_packet(TCP_Client_Connection *conn, uint8_t *data, uint16_t length) | 392 | static int handle_TCP_packet(TCP_Client_Connection *conn, const uint8_t *data, uint16_t length) |
392 | { | 393 | { |
393 | if (length <= 1) | 394 | if (length <= 1) |
394 | return -1; | 395 | return -1; |