Added function to check if packet sent with net_crypto was received.

This commit is contained in:
irungentoo 2014-08-27 14:37:28 -04:00
parent bbfa9efff6
commit 33b4268f7e
No known key found for this signature in database
GPG Key ID: 10349DC9BED89E98
2 changed files with 33 additions and 0 deletions

View File

@ -2472,6 +2472,30 @@ int64_t write_cryptpacket(Net_Crypto *c, int crypt_connection_id, const uint8_t
return ret;
}
/* Check if packet_number was received by the other side.
*
* packet_number must be a valid packet number of a packet sent on this connection.
*
* return -1 on failure.
* return 0 on success.
*/
int cryptpacket_received(Net_Crypto *c, int crypt_connection_id, uint32_t packet_number)
{
Crypto_Connection *conn = get_crypto_connection(c, crypt_connection_id);
if (conn == 0)
return -1;
uint32_t num = conn->send_array.buffer_end - conn->send_array.buffer_start;
uint32_t num1 = packet_number - conn->send_array.buffer_start;
if (num < num1) {
return 0;
} else {
return -1;
}
}
/* return -1 on failure.
* return 0 on success.
*

View File

@ -308,6 +308,15 @@ uint32_t crypto_num_free_sendqueue_slots(const Net_Crypto *c, int crypt_connecti
*/
int64_t write_cryptpacket(Net_Crypto *c, int crypt_connection_id, const uint8_t *data, uint32_t length);
/* Check if packet_number was received by the other side.
*
* packet_number must be a valid packet number of a packet sent on this connection.
*
* return -1 on failure.
* return 0 on success.
*/
int cryptpacket_received(Net_Crypto *c, int crypt_connection_id, uint32_t packet_number);
/* return -1 on failure.
* return 0 on success.
*