summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBahkuh <philip_hq@hotmail.com>2013-10-21 08:00:27 +0200
committerBahkuh <philip_hq@hotmail.com>2013-10-22 20:24:48 +0200
commitf581e20233d2f67a1b0afc974900e258113bb230 (patch)
tree0af2bb69cf1940c3b98b8c8b06b4c50b61981e4b
parente9d92606d94837ac24e2583cdfd8d313a0fd9338 (diff)
This squash should work now.
-rw-r--r--.gitignore27
-rw-r--r--toxcore/Lossless_UDP.c14
-rw-r--r--toxcore/Lossless_UDP.h10
-rw-r--r--toxcore/net_crypto.c4
-rw-r--r--toxcore/net_crypto.h4
5 files changed, 27 insertions, 32 deletions
diff --git a/.gitignore b/.gitignore
index aa7d8f50..e903e3ca 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,31 +3,28 @@
3.DS_Store? 3.DS_Store?
4._* 4._*
5.Spotlight-V100 5.Spotlight-V100
6.Trashes 6.Trash*
7Icon?
7ethumbs.db 8ethumbs.db
8Thumbs.db 9Thumbs.db
10*.tmp
9 11
10//nacl build 12# Make
11nacl/build/
12build/
13!build/Makefile.am
14sodium
15
16CMakeCache.txt 13CMakeCache.txt
17CMakeFiles 14CMakeFiles
18Makefile 15Makefile
19cmake_install.cmake 16cmake_install.cmake
20install_manifest.txt 17install_manifest.txt
18tags
19Makefile.in
21 20
21# Testing
22testing/data 22testing/data
23*~ 23*~
24 24
25# Vim 25# Vim
26*.swp 26*.swp
27 27
28# Ctags
29tags
30
31# Object files 28# Object files
32*.o 29*.o
33*.lo 30*.lo
@@ -37,14 +34,13 @@ tags
37*.exe 34*.exe
38*.out 35*.out
39*.app 36*.app
40*.swp
41*.la 37*.la
42 38
39# Misc (?)
43m4/* 40m4/*
44!m4/pkg.m4
45configure 41configure
46configure_aux 42configure_aux
47Makefile.in 43!m4/pkg.m4
48aclocal.m4 44aclocal.m4
49config.h* 45config.h*
50config.log 46config.log
@@ -53,13 +49,12 @@ stamp-h1
53autom4te.cache 49autom4te.cache
54libtoxcore.pc 50libtoxcore.pc
55libtool 51libtool
56
57.deps 52.deps
58.libs 53.libs
59.dirstamp 54.dirstamp
60 55
61#netbeans 56# Netbeans
62nbproject 57nbproject
63 58
64#astyle 59# astyle
65*.orig 60*.orig
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 */
852static void adjust_datasendspeed(Connection *connection, uint32_t req_packets) 852static 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. */
1148void do_lossless_udp(Lossless_UDP *ludp) 1148void 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 */
250int is_connected(Lossless_UDP *ludp, int connection_id); 250int 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. */
253void do_lossless_udp(Lossless_UDP *ludp); 253void 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)
152static uint8_t base_nonce[crypto_box_NONCEBYTES]; 152static uint8_t base_nonce[crypto_box_NONCEBYTES];
153static uint8_t nonce_set = 0; 153static 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.*/
156void new_nonce(uint8_t *nonce) 156void 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
33typedef struct { 33typedef 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 */