summaryrefslogtreecommitdiff
path: root/toxcore/net_crypto.c
diff options
context:
space:
mode:
authorirungentoo <irungentoo@gmail.com>2014-05-03 11:58:45 -0400
committerirungentoo <irungentoo@gmail.com>2014-05-03 11:58:45 -0400
commit4dc0af61c6ea5b1581aca0d15cfd9ffc0f525b10 (patch)
treebcb812983340e7d128626805564afe3ef2ed2b79 /toxcore/net_crypto.c
parent20e9d9c079e9b330296625dcfa5bfacd376d9ff0 (diff)
All time in core is now monotonic.
Diffstat (limited to 'toxcore/net_crypto.c')
-rw-r--r--toxcore/net_crypto.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/toxcore/net_crypto.c b/toxcore/net_crypto.c
index 9425afba..d4922380 100644
--- a/toxcore/net_crypto.c
+++ b/toxcore/net_crypto.c
@@ -379,7 +379,7 @@ static int send_data_packet(Net_Crypto *c, int crypt_connection_id, uint8_t *dat
379 return -1; 379 return -1;
380 380
381 increment_nonce(conn->sent_nonce); 381 increment_nonce(conn->sent_nonce);
382 conn->last_data_packet_sent = current_time(); //TODO remove this. 382 conn->last_data_packet_sent = current_time_monotonic(); //TODO remove this.
383 return send_packet_to(c, crypt_connection_id, packet, sizeof(packet)); 383 return send_packet_to(c, crypt_connection_id, packet, sizeof(packet));
384} 384}
385 385
@@ -505,7 +505,7 @@ static int send_temp_packet(Net_Crypto *c, int crypt_connection_id)
505 if (send_packet_to(c, crypt_connection_id, conn->temp_packet, conn->temp_packet_length) != 0) 505 if (send_packet_to(c, crypt_connection_id, conn->temp_packet, conn->temp_packet_length) != 0)
506 return -1; 506 return -1;
507 507
508 conn->temp_packet_sent_time = current_time(); 508 conn->temp_packet_sent_time = current_time_monotonic();
509 ++conn->temp_packet_num_sent; 509 ++conn->temp_packet_num_sent;
510 return 0; 510 return 0;
511} 511}
@@ -738,7 +738,7 @@ static int crypto_connection_add_source(Net_Crypto *c, int crypt_connection_id,
738 738
739 if (source.ip.family == AF_INET || source.ip.family == AF_INET6) { 739 if (source.ip.family == AF_INET || source.ip.family == AF_INET6) {
740 conn->ip_port = source; 740 conn->ip_port = source;
741 conn->direct_lastrecv_time = current_time(); 741 conn->direct_lastrecv_time = current_time_monotonic();
742 return 0; 742 return 0;
743 } 743 }
744 744
@@ -1032,14 +1032,14 @@ static int udp_handle_packet(void *object, IP_Port source, uint8_t *packet, uint
1032 if (conn == 0) 1032 if (conn == 0)
1033 return -1; 1033 return -1;
1034 1034
1035 conn->direct_lastrecv_time = current_time(); 1035 conn->direct_lastrecv_time = current_time_monotonic();
1036 return 0; 1036 return 0;
1037} 1037}
1038 1038
1039static void send_crypto_packets(Net_Crypto *c) 1039static void send_crypto_packets(Net_Crypto *c)
1040{ 1040{
1041 uint32_t i; 1041 uint32_t i;
1042 uint64_t temp_time = current_time(); 1042 uint64_t temp_time = current_time_monotonic();
1043 1043
1044 for (i = 0; i < c->crypto_connections_length; ++i) { 1044 for (i = 0; i < c->crypto_connections_length; ++i) {
1045 Crypto_Connection *conn = get_crypto_connection(c, i); 1045 Crypto_Connection *conn = get_crypto_connection(c, i);
@@ -1047,12 +1047,12 @@ static void send_crypto_packets(Net_Crypto *c)
1047 if (conn == 0) 1047 if (conn == 0)
1048 return; 1048 return;
1049 1049
1050 if ((CRYPTO_SEND_PACKET_INTERVAL * 1000ULL) + conn->temp_packet_sent_time < temp_time) { 1050 if (CRYPTO_SEND_PACKET_INTERVAL + conn->temp_packet_sent_time < temp_time) {
1051 send_temp_packet(c, i); 1051 send_temp_packet(c, i);
1052 } 1052 }
1053 1053
1054 if (conn->status >= CRYPTO_CONN_NOT_CONFIRMED 1054 if (conn->status >= CRYPTO_CONN_NOT_CONFIRMED
1055 && (500ULL * 1000ULL) + conn->last_data_packet_sent < temp_time) {//TODO remove this. 1055 && (500ULL + conn->last_data_packet_sent) < temp_time) {//TODO remove this.
1056 uint8_t data[4] = {}; 1056 uint8_t data[4] = {};
1057 send_data_packet(c, i, data, 4); 1057 send_data_packet(c, i, data, 4);
1058 } 1058 }
@@ -1159,7 +1159,7 @@ Net_Crypto *new_net_crypto(DHT *dht)
1159static void kill_timedout(Net_Crypto *c) 1159static void kill_timedout(Net_Crypto *c)
1160{ 1160{
1161 uint32_t i; 1161 uint32_t i;
1162 uint64_t temp_time = current_time(); 1162 //uint64_t temp_time = current_time_monotonic();
1163 1163
1164 for (i = 0; i < c->crypto_connections_length; ++i) { 1164 for (i = 0; i < c->crypto_connections_length; ++i) {
1165 Crypto_Connection *conn = get_crypto_connection(c, i); 1165 Crypto_Connection *conn = get_crypto_connection(c, i);