diff options
Diffstat (limited to 'toxcore')
-rw-r--r-- | toxcore/Lossless_UDP.c | 14 | ||||
-rw-r--r-- | toxcore/Lossless_UDP.h | 10 | ||||
-rw-r--r-- | toxcore/net_crypto.c | 4 | ||||
-rw-r--r-- | toxcore/net_crypto.h | 4 |
4 files changed, 16 insertions, 16 deletions
diff --git a/toxcore/Lossless_UDP.c b/toxcore/Lossless_UDP.c index 6d82b768..e291340d 100644 --- a/toxcore/Lossless_UDP.c +++ b/toxcore/Lossless_UDP.c | |||
@@ -198,8 +198,8 @@ int new_connection(Lossless_UDP *ludp, IP_Port ip_port) | |||
198 | memset(connection, 0, sizeof(Connection)); | 198 | memset(connection, 0, sizeof(Connection)); |
199 | 199 | ||
200 | uint32_t handshake_id1 = handshake_id(ludp, ip_port); | 200 | uint32_t handshake_id1 = handshake_id(ludp, ip_port); |
201 | /* add randomness to timeout to prevent connections getting stuck in a loop. */ | 201 | /* Add randomness to timeout to prevent connections getting stuck in a loop. */ |
202 | uint8_t timeout = CONNEXION_TIMEOUT + rand() % CONNEXION_TIMEOUT; | 202 | uint8_t timeout = CONNECTION_TIMEOUT + rand() % CONNECTION_TIMEOUT; |
203 | 203 | ||
204 | *connection = (Connection) { | 204 | *connection = (Connection) { |
205 | .ip_port = ip_port, | 205 | .ip_port = ip_port, |
@@ -260,7 +260,7 @@ static int new_inconnection(Lossless_UDP *ludp, IP_Port ip_port) | |||
260 | Connection *connection = &tox_array_get(&ludp->connections, connection_id, Connection); | 260 | Connection *connection = &tox_array_get(&ludp->connections, connection_id, Connection); |
261 | memset(connection, 0, sizeof(Connection)); | 261 | memset(connection, 0, sizeof(Connection)); |
262 | /* Add randomness to timeout to prevent connections getting stuck in a loop. */ | 262 | /* Add randomness to timeout to prevent connections getting stuck in a loop. */ |
263 | uint8_t timeout = CONNEXION_TIMEOUT + rand() % CONNEXION_TIMEOUT; | 263 | uint8_t timeout = CONNECTION_TIMEOUT + rand() % CONNECTION_TIMEOUT; |
264 | 264 | ||
265 | *connection = (Connection) { | 265 | *connection = (Connection) { |
266 | .ip_port = ip_port, | 266 | .ip_port = ip_port, |
@@ -403,7 +403,7 @@ int connection_confirmed(Lossless_UDP *ludp, int connection_id) | |||
403 | } | 403 | } |
404 | 404 | ||
405 | /* Confirm an incoming connection. | 405 | /* Confirm an incoming connection. |
406 | * Also disables the auto kill timeout on incomming connections. | 406 | * Also disable the auto kill timeout on incomming connections. |
407 | * | 407 | * |
408 | * return 0 on success | 408 | * return 0 on success |
409 | * return -1 on failure. | 409 | * return -1 on failure. |
@@ -777,7 +777,7 @@ static int handle_handshake(void *object, IP_Port source, uint8_t *packet, uint3 | |||
777 | /* if handshake_id2 is what we sent previously as handshake_id1 */ | 777 | /* if handshake_id2 is what we sent previously as handshake_id1 */ |
778 | if (handshake_id2 == connection->handshake_id1) { | 778 | if (handshake_id2 == connection->handshake_id1) { |
779 | connection->status = LUDP_NOT_CONFIRMED; | 779 | connection->status = LUDP_NOT_CONFIRMED; |
780 | /* NOTE: is this necessary? | 780 | /* NOTE: Is this necessary? |
781 | connection->handshake_id2 = handshake_id1; */ | 781 | connection->handshake_id2 = handshake_id1; */ |
782 | connection->orecv_packetnum = handshake_id2; | 782 | connection->orecv_packetnum = handshake_id2; |
783 | connection->osent_packetnum = handshake_id1; | 783 | connection->osent_packetnum = handshake_id1; |
@@ -847,7 +847,7 @@ static int handle_SYNC2(Lossless_UDP *ludp, int connection_id, uint8_t counter, | |||
847 | /* | 847 | /* |
848 | * Automatically adjusts send rates of data packets for optimal transmission. | 848 | * Automatically adjusts send rates of data packets for optimal transmission. |
849 | * | 849 | * |
850 | * TODO: Impove this. | 850 | * TODO: Improve this. |
851 | */ | 851 | */ |
852 | static void adjust_datasendspeed(Connection *connection, uint32_t req_packets) | 852 | static void adjust_datasendspeed(Connection *connection, uint32_t req_packets) |
853 | { | 853 | { |
@@ -1144,7 +1144,7 @@ static void adjust_rates(Lossless_UDP *ludp) | |||
1144 | } | 1144 | } |
1145 | } | 1145 | } |
1146 | 1146 | ||
1147 | /* Call this function a couple times per second It's the main loop. */ | 1147 | /* Call this function a couple times per second. It is the main loop. */ |
1148 | void do_lossless_udp(Lossless_UDP *ludp) | 1148 | void do_lossless_udp(Lossless_UDP *ludp) |
1149 | { | 1149 | { |
1150 | do_new(ludp); | 1150 | do_new(ludp); |
diff --git a/toxcore/Lossless_UDP.h b/toxcore/Lossless_UDP.h index d2f1986f..d4d6ec4e 100644 --- a/toxcore/Lossless_UDP.h +++ b/toxcore/Lossless_UDP.h | |||
@@ -38,10 +38,10 @@ | |||
38 | /* Maximum number of data packets in the buffer. */ | 38 | /* Maximum number of data packets in the buffer. */ |
39 | #define MAX_REQUESTED_PACKETS 256 | 39 | #define MAX_REQUESTED_PACKETS 256 |
40 | 40 | ||
41 | /* Timeout per connection is randomly set between CONNEXION_TIMEOUT and 2*CONNEXION_TIMEOUT. */ | 41 | /* Timeout per connection is randomly set between CONNECTION_TIMEOUT and 2*CONNECTION_TIMEOUT. */ |
42 | #define CONNEXION_TIMEOUT 5 | 42 | #define CONNECTION_TIMEOUT 5 |
43 | 43 | ||
44 | /* Initial amount of sync/hanshake packets to send per second. */ | 44 | /* Initial amount of sync/handshake packets to send per second. */ |
45 | #define SYNC_RATE 2 | 45 | #define SYNC_RATE 2 |
46 | 46 | ||
47 | /* Initial send rate of data. */ | 47 | /* Initial send rate of data. */ |
@@ -124,7 +124,7 @@ typedef struct { | |||
124 | uint8_t send_counter; | 124 | uint8_t send_counter; |
125 | uint8_t timeout; /* connection timeout in seconds. */ | 125 | uint8_t timeout; /* connection timeout in seconds. */ |
126 | 126 | ||
127 | /* is the connection confirmed or not 1 if yes, 0 if no */ | 127 | /* Is the connection confirmed or not? 1 if yes, 0 if no */ |
128 | uint8_t confirmed; | 128 | uint8_t confirmed; |
129 | } Connection; | 129 | } Connection; |
130 | 130 | ||
@@ -249,7 +249,7 @@ uint32_t recvqueue(Lossless_UDP *ludp, int connection_id); | |||
249 | */ | 249 | */ |
250 | int is_connected(Lossless_UDP *ludp, int connection_id); | 250 | int is_connected(Lossless_UDP *ludp, int connection_id); |
251 | 251 | ||
252 | /* Call this function a couple times per second It's the main loop. */ | 252 | /* Call this function a couple times per second. It is the main loop. */ |
253 | void do_lossless_udp(Lossless_UDP *ludp); | 253 | void do_lossless_udp(Lossless_UDP *ludp); |
254 | 254 | ||
255 | /* This function sets up LosslessUDP packet handling. */ | 255 | /* This function sets up LosslessUDP packet handling. */ |
diff --git a/toxcore/net_crypto.c b/toxcore/net_crypto.c index b7e3ced7..14831868 100644 --- a/toxcore/net_crypto.c +++ b/toxcore/net_crypto.c | |||
@@ -152,7 +152,7 @@ void random_nonce(uint8_t *nonce) | |||
152 | static uint8_t base_nonce[crypto_box_NONCEBYTES]; | 152 | static uint8_t base_nonce[crypto_box_NONCEBYTES]; |
153 | static uint8_t nonce_set = 0; | 153 | static uint8_t nonce_set = 0; |
154 | 154 | ||
155 | /*Gives a nonce guaranteed to be different from previous ones.*/ | 155 | /* Gives a nonce guaranteed to be different from previous ones.*/ |
156 | void new_nonce(uint8_t *nonce) | 156 | void new_nonce(uint8_t *nonce) |
157 | { | 157 | { |
158 | if (nonce_set == 0) { | 158 | if (nonce_set == 0) { |
@@ -240,7 +240,7 @@ int write_cryptpacket(Net_Crypto *c, int crypt_connection_id, uint8_t *data, uin | |||
240 | return 1; | 240 | return 1; |
241 | } | 241 | } |
242 | 242 | ||
243 | /* Ceate a request to peer. | 243 | /* Create a request to peer. |
244 | * send_public_key and send_secret_key are the pub/secret keys of the sender. | 244 | * send_public_key and send_secret_key are the pub/secret keys of the sender. |
245 | * recv_public_key is public key of reciever. | 245 | * recv_public_key is public key of reciever. |
246 | * packet must be an array of MAX_DATA_SIZE big. | 246 | * packet must be an array of MAX_DATA_SIZE big. |
diff --git a/toxcore/net_crypto.h b/toxcore/net_crypto.h index 0ddb711a..f0141f52 100644 --- a/toxcore/net_crypto.h +++ b/toxcore/net_crypto.h | |||
@@ -28,7 +28,7 @@ | |||
28 | 28 | ||
29 | #define CRYPTO_PACKET_FRIEND_REQ 32 /* Friend request crypto packet ID. */ | 29 | #define CRYPTO_PACKET_FRIEND_REQ 32 /* Friend request crypto packet ID. */ |
30 | #define CRYPTO_PACKET_NAT_PING 254 /* NAT ping crypto packet ID. */ | 30 | #define CRYPTO_PACKET_NAT_PING 254 /* NAT ping crypto packet ID. */ |
31 | #define CRYPTO_HANDSHAKE_TIMEOUT (CONNEXION_TIMEOUT * 2) | 31 | #define CRYPTO_HANDSHAKE_TIMEOUT (CONNECTION_TIMEOUT * 2) |
32 | 32 | ||
33 | typedef struct { | 33 | typedef struct { |
34 | uint8_t public_key[crypto_box_PUBLICKEYBYTES]; /* The real public key of the peer. */ | 34 | uint8_t public_key[crypto_box_PUBLICKEYBYTES]; /* The real public key of the peer. */ |
@@ -38,7 +38,7 @@ typedef struct { | |||
38 | uint8_t sessionsecret_key[crypto_box_SECRETKEYBYTES]; /* Our private key for this session. */ | 38 | uint8_t sessionsecret_key[crypto_box_SECRETKEYBYTES]; /* Our private key for this session. */ |
39 | uint8_t peersessionpublic_key[crypto_box_PUBLICKEYBYTES]; /* The public key of the peer. */ | 39 | uint8_t peersessionpublic_key[crypto_box_PUBLICKEYBYTES]; /* The public key of the peer. */ |
40 | uint8_t shared_key[crypto_box_BEFORENMBYTES]; /* The precomputed shared key from encrypt_precompute. */ | 40 | uint8_t shared_key[crypto_box_BEFORENMBYTES]; /* The precomputed shared key from encrypt_precompute. */ |
41 | uint8_t status; /* 0 if no connection, 1 we have sent a handshake, 2 if connexion is not confirmed yet | 41 | uint8_t status; /* 0 if no connection, 1 we have sent a handshake, 2 if connection is not confirmed yet |
42 | * (we have received a handshake but no empty data packet), 3 if the connection is established. | 42 | * (we have received a handshake but no empty data packet), 3 if the connection is established. |
43 | * 4 if the connection is timed out. | 43 | * 4 if the connection is timed out. |
44 | */ | 44 | */ |