diff options
author | irungentoo <irungentoo@gmail.com> | 2014-05-15 20:57:55 -0400 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2014-05-15 20:57:55 -0400 |
commit | a5141679527b10de8cc6e0aa211873706abac149 (patch) | |
tree | 4f165634167a7c24ecc36d009467db33e670fece /toxcore | |
parent | 1e7164fcee879a4392ccb45c80607bd5b5c71352 (diff) |
Exposed and tested disconnect notification TCP packets.
Diffstat (limited to 'toxcore')
-rw-r--r-- | toxcore/TCP_client.c | 15 | ||||
-rw-r--r-- | toxcore/TCP_client.h | 6 |
2 files changed, 21 insertions, 0 deletions
diff --git a/toxcore/TCP_client.c b/toxcore/TCP_client.c index 4652b4a6..209c1775 100644 --- a/toxcore/TCP_client.c +++ b/toxcore/TCP_client.c | |||
@@ -304,6 +304,20 @@ static int send_ping_response(TCP_Client_Connection *con, uint64_t ping_id) | |||
304 | * return 0 if could not send packet. | 304 | * return 0 if could not send packet. |
305 | * return -1 on failure (connection must be killed). | 305 | * return -1 on failure (connection must be killed). |
306 | */ | 306 | */ |
307 | int send_disconnect_request(TCP_Client_Connection *con, uint8_t con_id) | ||
308 | { | ||
309 | if (con_id >= NUM_CLIENT_CONNECTIONS) | ||
310 | return -1; | ||
311 | |||
312 | con->connections[con_id].status = 0; | ||
313 | con->connections[con_id].number = 0; | ||
314 | return send_disconnect_notification(con, con_id + NUM_RESERVED_PORTS); | ||
315 | } | ||
316 | |||
317 | /* return 1 on success. | ||
318 | * return 0 if could not send packet. | ||
319 | * return -1 on failure (connection must be killed). | ||
320 | */ | ||
307 | int send_onion_request(TCP_Client_Connection *con, uint8_t *data, uint16_t length) | 321 | int send_onion_request(TCP_Client_Connection *con, uint8_t *data, uint16_t length) |
308 | { | 322 | { |
309 | uint8_t packet[1 + length]; | 323 | uint8_t packet[1 + length]; |
@@ -564,6 +578,7 @@ void do_TCP_connection(TCP_Client_Connection *TCP_connection) | |||
564 | 578 | ||
565 | if (sizeof(data) == len) { | 579 | if (sizeof(data) == len) { |
566 | if (handle_handshake(TCP_connection, data) == 0) { | 580 | if (handle_handshake(TCP_connection, data) == 0) { |
581 | TCP_connection->kill_at = ~0; | ||
567 | TCP_connection->status = TCP_CLIENT_CONFIRMED; | 582 | TCP_connection->status = TCP_CLIENT_CONFIRMED; |
568 | } else { | 583 | } else { |
569 | TCP_connection->kill_at = 0; | 584 | TCP_connection->kill_at = 0; |
diff --git a/toxcore/TCP_client.h b/toxcore/TCP_client.h index 277378b9..768ef9d2 100644 --- a/toxcore/TCP_client.h +++ b/toxcore/TCP_client.h | |||
@@ -105,6 +105,12 @@ void routing_response_handler(TCP_Client_Connection *con, int (*response_callbac | |||
105 | void routing_status_handler(TCP_Client_Connection *con, int (*status_callback)(void *object, uint32_t number, | 105 | void routing_status_handler(TCP_Client_Connection *con, int (*status_callback)(void *object, uint32_t number, |
106 | uint8_t connection_id, uint8_t status), void *object); | 106 | uint8_t connection_id, uint8_t status), void *object); |
107 | 107 | ||
108 | /* return 1 on success. | ||
109 | * return 0 if could not send packet. | ||
110 | * return -1 on failure (connection must be killed). | ||
111 | */ | ||
112 | int send_disconnect_request(TCP_Client_Connection *con, uint8_t con_id); | ||
113 | |||
108 | /* Set the number that will be used as an argument in the callbacks related to con_id. | 114 | /* Set the number that will be used as an argument in the callbacks related to con_id. |
109 | * | 115 | * |
110 | * When not set by this function, the number is ~0. | 116 | * When not set by this function, the number is ~0. |