summaryrefslogtreecommitdiff
path: root/toxcore/net_crypto.c
diff options
context:
space:
mode:
Diffstat (limited to 'toxcore/net_crypto.c')
-rw-r--r--toxcore/net_crypto.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/toxcore/net_crypto.c b/toxcore/net_crypto.c
index a354c36b..2da8de61 100644
--- a/toxcore/net_crypto.c
+++ b/toxcore/net_crypto.c
@@ -505,7 +505,7 @@ static IP_Port return_ip_port_connection(Net_Crypto *c, int crypt_connection_id)
505 */ 505 */
506static int send_packet_to(Net_Crypto *c, int crypt_connection_id, const uint8_t *data, uint16_t length) 506static int send_packet_to(Net_Crypto *c, int crypt_connection_id, const uint8_t *data, uint16_t length)
507{ 507{
508//TODO TCP, etc... 508// TODO(irungentoo): TCP, etc...
509 Crypto_Connection *conn = get_crypto_connection(c, crypt_connection_id); 509 Crypto_Connection *conn = get_crypto_connection(c, crypt_connection_id);
510 510
511 if (conn == 0) { 511 if (conn == 0) {
@@ -517,7 +517,7 @@ static int send_packet_to(Net_Crypto *c, int crypt_connection_id, const uint8_t
517 pthread_mutex_lock(&conn->mutex); 517 pthread_mutex_lock(&conn->mutex);
518 IP_Port ip_port = return_ip_port_connection(c, crypt_connection_id); 518 IP_Port ip_port = return_ip_port_connection(c, crypt_connection_id);
519 519
520 //TODO: on bad networks, direct connections might not last indefinitely. 520 // TODO(irungentoo): on bad networks, direct connections might not last indefinitely.
521 if (ip_port.ip.family != 0) { 521 if (ip_port.ip.family != 0) {
522 bool direct_connected = 0; 522 bool direct_connected = 0;
523 crypto_connection_status(c, crypt_connection_id, &direct_connected, NULL); 523 crypto_connection_status(c, crypt_connection_id, &direct_connected, NULL);
@@ -532,7 +532,7 @@ static int send_packet_to(Net_Crypto *c, int crypt_connection_id, const uint8_t
532 return -1; 532 return -1;
533 } 533 }
534 534
535 //TODO: a better way of sending packets directly to confirm the others ip. 535 // TODO(irungentoo): a better way of sending packets directly to confirm the others ip.
536 uint64_t current_time = unix_time(); 536 uint64_t current_time = unix_time();
537 537
538 if ((((UDP_DIRECT_TIMEOUT / 2) + conn->direct_send_attempt_time) > current_time && length < 96) 538 if ((((UDP_DIRECT_TIMEOUT / 2) + conn->direct_send_attempt_time) > current_time && length < 96)
@@ -1403,7 +1403,7 @@ static int handle_data_packet_helper(Net_Crypto *c, int crypt_connection_id, con
1403 return -1; 1403 return -1;
1404 } 1404 }
1405 1405
1406 // else { /* TODO? */ } 1406 // else { /* TODO(irungentoo): ? */ }
1407 1407
1408 set_buffer_end(&conn->recv_array, num); 1408 set_buffer_end(&conn->recv_array, num);
1409 } else if (real_data[0] >= CRYPTO_RESERVED_PACKETS && real_data[0] < PACKET_ID_LOSSY_RANGE_START) { 1409 } else if (real_data[0] >= CRYPTO_RESERVED_PACKETS && real_data[0] < PACKET_ID_LOSSY_RANGE_START) {
@@ -1595,7 +1595,7 @@ static int create_crypto_connection(Net_Crypto *c)
1595 } 1595 }
1596 } 1596 }
1597 1597
1598 while (1) { /* TODO: is this really the best way to do this? */ 1598 while (1) { /* TODO(irungentoo): is this really the best way to do this? */
1599 pthread_mutex_lock(&c->connections_mutex); 1599 pthread_mutex_lock(&c->connections_mutex);
1600 1600
1601 if (!c->connection_use_counter) { 1601 if (!c->connection_use_counter) {
@@ -1967,7 +1967,7 @@ static int tcp_data_callback(void *object, int id, const uint8_t *data, uint16_t
1967 return -1; 1967 return -1;
1968 } 1968 }
1969 1969
1970 //TODO detect and kill bad TCP connections. 1970 // TODO(irungentoo): detect and kill bad TCP connections.
1971 return 0; 1971 return 0;
1972} 1972}
1973 1973
@@ -2034,7 +2034,7 @@ int add_tcp_relay(Net_Crypto *c, IP_Port ip_port, const uint8_t *public_key)
2034 2034
2035/* Return a random TCP connection number for use in send_tcp_onion_request. 2035/* Return a random TCP connection number for use in send_tcp_onion_request.
2036 * 2036 *
2037 * TODO: This number is just the index of an array that the elements can 2037 * TODO(irungentoo): This number is just the index of an array that the elements can
2038 * change without warning. 2038 * change without warning.
2039 * 2039 *
2040 * return TCP connection number on success. 2040 * return TCP connection number on success.
@@ -2388,7 +2388,7 @@ static void send_crypto_packets(Net_Crypto *c)
2388 } else { 2388 } else {
2389 long signed int total_sent = 0, total_resent = 0; 2389 long signed int total_sent = 0, total_resent = 0;
2390 2390
2391 //TODO use real delay 2391 // TODO(irungentoo): use real delay
2392 unsigned int delay = (unsigned int)((conn->rtt_time / PACKET_COUNTER_AVERAGE_INTERVAL) + 0.5); 2392 unsigned int delay = (unsigned int)((conn->rtt_time / PACKET_COUNTER_AVERAGE_INTERVAL) + 0.5);
2393 unsigned int packets_set_rem_array = (CONGESTION_LAST_SENT_ARRAY_SIZE - CONGESTION_QUEUE_ARRAY_SIZE); 2393 unsigned int packets_set_rem_array = (CONGESTION_LAST_SENT_ARRAY_SIZE - CONGESTION_QUEUE_ARRAY_SIZE);
2394 2394
@@ -2424,7 +2424,7 @@ static void send_crypto_packets(Net_Crypto *c)
2424 2424
2425 double send_array_ratio = (((double)npackets) / min_speed); 2425 double send_array_ratio = (((double)npackets) / min_speed);
2426 2426
2427 //TODO: Improve formula? 2427 // TODO(irungentoo): Improve formula?
2428 if (send_array_ratio > SEND_QUEUE_RATIO && CRYPTO_MIN_QUEUE_LENGTH < npackets) { 2428 if (send_array_ratio > SEND_QUEUE_RATIO && CRYPTO_MIN_QUEUE_LENGTH < npackets) {
2429 conn->packet_send_rate = min_speed * (1.0 / (send_array_ratio / SEND_QUEUE_RATIO)); 2429 conn->packet_send_rate = min_speed * (1.0 / (send_array_ratio / SEND_QUEUE_RATIO));
2430 } else if (conn->last_congestion_event + CONGESTION_EVENT_TIMEOUT < temp_time) { 2430 } else if (conn->last_congestion_event + CONGESTION_EVENT_TIMEOUT < temp_time) {
@@ -2680,7 +2680,7 @@ int send_lossy_cryptpacket(Net_Crypto *c, int crypt_connection_id, const uint8_t
2680 */ 2680 */
2681int crypto_kill(Net_Crypto *c, int crypt_connection_id) 2681int crypto_kill(Net_Crypto *c, int crypt_connection_id)
2682{ 2682{
2683 while (1) { /* TODO: is this really the best way to do this? */ 2683 while (1) { /* TODO(irungentoo): is this really the best way to do this? */
2684 pthread_mutex_lock(&c->connections_mutex); 2684 pthread_mutex_lock(&c->connections_mutex);
2685 2685
2686 if (!c->connection_use_counter) { 2686 if (!c->connection_use_counter) {
@@ -2759,7 +2759,7 @@ void new_keys(Net_Crypto *c)
2759/* Save the public and private keys to the keys array. 2759/* Save the public and private keys to the keys array.
2760 * Length must be crypto_box_PUBLICKEYBYTES + crypto_box_SECRETKEYBYTES. 2760 * Length must be crypto_box_PUBLICKEYBYTES + crypto_box_SECRETKEYBYTES.
2761 * 2761 *
2762 * TODO: Save only secret key. 2762 * TODO(irungentoo): Save only secret key.
2763 */ 2763 */
2764void save_keys(const Net_Crypto *c, uint8_t *keys) 2764void save_keys(const Net_Crypto *c, uint8_t *keys)
2765{ 2765{
@@ -2857,7 +2857,7 @@ static void kill_timedout(Net_Crypto *c, void *userdata)
2857#if 0 2857#if 0
2858 2858
2859 if (conn->status == CRYPTO_CONN_ESTABLISHED) { 2859 if (conn->status == CRYPTO_CONN_ESTABLISHED) {
2860 //TODO: add a timeout here? 2860 // TODO(irungentoo): add a timeout here?
2861 } 2861 }
2862 2862
2863#endif 2863#endif