diff options
author | irungentoo <irungentoo@gmail.com> | 2014-05-08 18:26:01 -0400 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2014-05-08 18:26:01 -0400 |
commit | a26ced5fcb7a9a8bf6b4795c95b04277c14b84f2 (patch) | |
tree | 8a659c2dc15414ff227cf43c793f20ee2a91cbe1 /toxcore | |
parent | 98f20c76de801d042c695b3034056b2cfbfeaab5 (diff) | |
parent | 89022326d3742defd9c7b1111ddcda53688d85be (diff) |
Merge branch 'master' into TCP
Diffstat (limited to 'toxcore')
-rw-r--r-- | toxcore/DHT.c | 18 | ||||
-rw-r--r-- | toxcore/DHT.h | 2 | ||||
-rw-r--r-- | toxcore/Messenger.c | 6 | ||||
-rw-r--r-- | toxcore/Messenger.h | 4 | ||||
-rw-r--r-- | toxcore/TCP_server.c | 2 | ||||
-rw-r--r-- | toxcore/TCP_server.h | 2 | ||||
-rw-r--r-- | toxcore/assoc.c | 2 | ||||
-rw-r--r-- | toxcore/network.c | 5 | ||||
-rw-r--r-- | toxcore/onion_client.c | 6 | ||||
-rw-r--r-- | toxcore/onion_client.h | 4 | ||||
-rw-r--r-- | toxcore/tox.c | 4 | ||||
-rw-r--r-- | toxcore/tox.h | 10 |
12 files changed, 34 insertions, 31 deletions
diff --git a/toxcore/DHT.c b/toxcore/DHT.c index c23bad5d..7678ae7f 100644 --- a/toxcore/DHT.c +++ b/toxcore/DHT.c | |||
@@ -164,7 +164,7 @@ void get_shared_key(Shared_Keys *shared_keys, uint8_t *shared_key, uint8_t *secr | |||
164 | } | 164 | } |
165 | 165 | ||
166 | /* Copy shared_key to encrypt/decrypt DHT packet from client_id into shared_key | 166 | /* Copy shared_key to encrypt/decrypt DHT packet from client_id into shared_key |
167 | * for packets that we recieve. | 167 | * for packets that we receive. |
168 | */ | 168 | */ |
169 | void DHT_get_shared_key_recv(DHT *dht, uint8_t *shared_key, uint8_t *client_id) | 169 | void DHT_get_shared_key_recv(DHT *dht, uint8_t *shared_key, uint8_t *client_id) |
170 | { | 170 | { |
@@ -688,7 +688,7 @@ static int replace_possible_bad( Client_data *list, | |||
688 | 688 | ||
689 | sort_list(list, length, comp_client_id); | 689 | sort_list(list, length, comp_client_id); |
690 | 690 | ||
691 | /* TODO: decide if the folowing lines should stay commented or not. | 691 | /* TODO: decide if the following lines should stay commented or not. |
692 | if (id_closest(comp_client_id, list[0].client_id, client_id) == 1) | 692 | if (id_closest(comp_client_id, list[0].client_id, client_id) == 1) |
693 | return 0;*/ | 693 | return 0;*/ |
694 | 694 | ||
@@ -949,20 +949,20 @@ static int getnodes(DHT *dht, IP_Port ip_port, uint8_t *public_key, uint8_t *cli | |||
949 | 949 | ||
950 | uint64_t temp_time = unix_time(); | 950 | uint64_t temp_time = unix_time(); |
951 | memcpy(plain_message, &temp_time, sizeof(temp_time)); | 951 | memcpy(plain_message, &temp_time, sizeof(temp_time)); |
952 | Node_format reciever; | 952 | Node_format receiver; |
953 | memcpy(reciever.client_id, public_key, CLIENT_ID_SIZE); | 953 | memcpy(receiver.client_id, public_key, CLIENT_ID_SIZE); |
954 | reciever.ip_port = ip_port; | 954 | receiver.ip_port = ip_port; |
955 | memcpy(plain_message + sizeof(temp_time), &reciever, sizeof(reciever)); | 955 | memcpy(plain_message + sizeof(temp_time), &receiver, sizeof(receiver)); |
956 | 956 | ||
957 | if (sendback_node != NULL) | 957 | if (sendback_node != NULL) |
958 | memcpy(plain_message + sizeof(temp_time) + sizeof(reciever), sendback_node, sizeof(Node_format)); | 958 | memcpy(plain_message + sizeof(temp_time) + sizeof(receiver), sendback_node, sizeof(Node_format)); |
959 | else | 959 | else |
960 | memset(plain_message + sizeof(temp_time) + sizeof(reciever), 0, sizeof(Node_format)); | 960 | memset(plain_message + sizeof(temp_time) + sizeof(receiver), 0, sizeof(Node_format)); |
961 | 961 | ||
962 | int len_m = encrypt_data_symmetric(dht->secret_symmetric_key, | 962 | int len_m = encrypt_data_symmetric(dht->secret_symmetric_key, |
963 | nonce, | 963 | nonce, |
964 | plain_message, | 964 | plain_message, |
965 | sizeof(temp_time) + sizeof(reciever) + sizeof(Node_format), | 965 | sizeof(temp_time) + sizeof(receiver) + sizeof(Node_format), |
966 | encrypted_message + crypto_box_NONCEBYTES); | 966 | encrypted_message + crypto_box_NONCEBYTES); |
967 | 967 | ||
968 | if (len_m != NODES_ENCRYPTED_MESSAGE_LENGTH - crypto_box_NONCEBYTES) | 968 | if (len_m != NODES_ENCRYPTED_MESSAGE_LENGTH - crypto_box_NONCEBYTES) |
diff --git a/toxcore/DHT.h b/toxcore/DHT.h index 52aad266..d6514ee9 100644 --- a/toxcore/DHT.h +++ b/toxcore/DHT.h | |||
@@ -217,7 +217,7 @@ typedef struct { | |||
217 | void get_shared_key(Shared_Keys *shared_keys, uint8_t *shared_key, uint8_t *secret_key, uint8_t *client_id); | 217 | void get_shared_key(Shared_Keys *shared_keys, uint8_t *shared_key, uint8_t *secret_key, uint8_t *client_id); |
218 | 218 | ||
219 | /* Copy shared_key to encrypt/decrypt DHT packet from client_id into shared_key | 219 | /* Copy shared_key to encrypt/decrypt DHT packet from client_id into shared_key |
220 | * for packets that we recieve. | 220 | * for packets that we receive. |
221 | */ | 221 | */ |
222 | void DHT_get_shared_key_recv(DHT *dht, uint8_t *shared_key, uint8_t *client_id); | 222 | void DHT_get_shared_key_recv(DHT *dht, uint8_t *shared_key, uint8_t *client_id); |
223 | 223 | ||
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index a84c391b..fc8bd9bb 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c | |||
@@ -1835,6 +1835,10 @@ void kill_messenger(Messenger *m) | |||
1835 | kill_net_crypto(m->net_crypto); | 1835 | kill_net_crypto(m->net_crypto); |
1836 | kill_DHT(m->dht); | 1836 | kill_DHT(m->dht); |
1837 | kill_networking(m->net); | 1837 | kill_networking(m->net); |
1838 | for (i = 0; i < m->numfriends; ++i) { | ||
1839 | if (m->friendlist[i].statusmessage) | ||
1840 | free(m->friendlist[i].statusmessage); | ||
1841 | } | ||
1838 | free(m->friendlist); | 1842 | free(m->friendlist); |
1839 | free(m); | 1843 | free(m); |
1840 | } | 1844 | } |
@@ -2228,7 +2232,7 @@ void do_friends(Messenger *m) | |||
2228 | } | 2232 | } |
2229 | 2233 | ||
2230 | if (m->friendlist[i].ping_lastrecv + FRIEND_CONNECTION_TIMEOUT < temp_time) { | 2234 | if (m->friendlist[i].ping_lastrecv + FRIEND_CONNECTION_TIMEOUT < temp_time) { |
2231 | /* If we stopped recieving ping packets, kill it. */ | 2235 | /* If we stopped receiving ping packets, kill it. */ |
2232 | crypto_kill(m->net_crypto, m->friendlist[i].crypt_connection_id); | 2236 | crypto_kill(m->net_crypto, m->friendlist[i].crypt_connection_id); |
2233 | m->friendlist[i].crypt_connection_id = -1; | 2237 | m->friendlist[i].crypt_connection_id = -1; |
2234 | set_friend_status(m, i, FRIEND_CONFIRMED); | 2238 | set_friend_status(m, i, FRIEND_CONFIRMED); |
diff --git a/toxcore/Messenger.h b/toxcore/Messenger.h index 66ef39e5..b72a0831 100644 --- a/toxcore/Messenger.h +++ b/toxcore/Messenger.h | |||
@@ -88,7 +88,7 @@ enum { | |||
88 | /* Interval between the sending of ping packets. */ | 88 | /* Interval between the sending of ping packets. */ |
89 | #define FRIEND_PING_INTERVAL 5 | 89 | #define FRIEND_PING_INTERVAL 5 |
90 | 90 | ||
91 | /* If no packets are recieved from friend in this time interval, kill the connection. */ | 91 | /* If no packets are received from friend in this time interval, kill the connection. */ |
92 | #define FRIEND_CONNECTION_TIMEOUT (FRIEND_PING_INTERVAL * 2) | 92 | #define FRIEND_CONNECTION_TIMEOUT (FRIEND_PING_INTERVAL * 2) |
93 | 93 | ||
94 | /* USERSTATUS - | 94 | /* USERSTATUS - |
@@ -352,7 +352,7 @@ int setname(Messenger *m, uint8_t *name, uint16_t length); | |||
352 | 352 | ||
353 | /* | 353 | /* |
354 | * Get your nickname. | 354 | * Get your nickname. |
355 | * m - The messanger context to use. | 355 | * m - The messenger context to use. |
356 | * name needs to be a valid memory location with a size of at least MAX_NAME_LENGTH bytes. | 356 | * name needs to be a valid memory location with a size of at least MAX_NAME_LENGTH bytes. |
357 | * | 357 | * |
358 | * return length of the name. | 358 | * return length of the name. |
diff --git a/toxcore/TCP_server.c b/toxcore/TCP_server.c index fa49274a..79a420d3 100644 --- a/toxcore/TCP_server.c +++ b/toxcore/TCP_server.c | |||
@@ -228,7 +228,7 @@ int read_TCP_packet(sock_t sock, uint8_t *data, uint16_t length) | |||
228 | return -1; | 228 | return -1; |
229 | } | 229 | } |
230 | 230 | ||
231 | /* return length of recieved packet on success. | 231 | /* return length of received packet on success. |
232 | * return 0 if could not read any packet. | 232 | * return 0 if could not read any packet. |
233 | * return -1 on failure (connection must be killed). | 233 | * return -1 on failure (connection must be killed). |
234 | */ | 234 | */ |
diff --git a/toxcore/TCP_server.h b/toxcore/TCP_server.h index 26cfa493..2a6b8276 100644 --- a/toxcore/TCP_server.h +++ b/toxcore/TCP_server.h | |||
@@ -138,7 +138,7 @@ uint16_t read_TCP_length(sock_t sock); | |||
138 | */ | 138 | */ |
139 | int read_TCP_packet(sock_t sock, uint8_t *data, uint16_t length); | 139 | int read_TCP_packet(sock_t sock, uint8_t *data, uint16_t length); |
140 | 140 | ||
141 | /* return length of recieved packet on success. | 141 | /* return length of received packet on success. |
142 | * return 0 if could not read any packet. | 142 | * return 0 if could not read any packet. |
143 | * return -1 on failure (connection must be killed). | 143 | * return -1 on failure (connection must be killed). |
144 | */ | 144 | */ |
diff --git a/toxcore/assoc.c b/toxcore/assoc.c index 2c1f0bad..50bc3a3e 100644 --- a/toxcore/assoc.c +++ b/toxcore/assoc.c | |||
@@ -28,7 +28,7 @@ | |||
28 | * Candidates are kept in buckets of hash tables. The hash | 28 | * Candidates are kept in buckets of hash tables. The hash |
29 | * function is calculated from the client_id. Up to | 29 | * function is calculated from the client_id. Up to |
30 | * HASH_COLLIDE_COUNT alternative positions are tried if | 30 | * HASH_COLLIDE_COUNT alternative positions are tried if |
31 | * the inital position is already used by a different entry. | 31 | * the initial position is already used by a different entry. |
32 | * The collision function is multiplicative, not additive. | 32 | * The collision function is multiplicative, not additive. |
33 | * | 33 | * |
34 | * A new candidate can bump an existing candidate, if it is | 34 | * A new candidate can bump an existing candidate, if it is |
diff --git a/toxcore/network.c b/toxcore/network.c index 69874189..0505091d 100644 --- a/toxcore/network.c +++ b/toxcore/network.c | |||
@@ -314,7 +314,6 @@ int sendpacket(Networking_Core *net, IP_Port ip_port, uint8_t *data, uint32_t le | |||
314 | * ip and port of sender is put into ip_port. | 314 | * ip and port of sender is put into ip_port. |
315 | * Packet data is put into data. | 315 | * Packet data is put into data. |
316 | * Packet length is put into length. | 316 | * Packet length is put into length. |
317 | * Dump all empty packets. | ||
318 | */ | 317 | */ |
319 | static int receivepacket(sock_t sock, IP_Port *ip_port, uint8_t *data, uint32_t *length) | 318 | static int receivepacket(sock_t sock, IP_Port *ip_port, uint8_t *data, uint32_t *length) |
320 | { | 319 | { |
@@ -328,7 +327,7 @@ static int receivepacket(sock_t sock, IP_Port *ip_port, uint8_t *data, uint32_t | |||
328 | *length = 0; | 327 | *length = 0; |
329 | int fail_or_len = recvfrom(sock, (char *) data, MAX_UDP_PACKET_SIZE, 0, (struct sockaddr *)&addr, &addrlen); | 328 | int fail_or_len = recvfrom(sock, (char *) data, MAX_UDP_PACKET_SIZE, 0, (struct sockaddr *)&addr, &addrlen); |
330 | 329 | ||
331 | if (fail_or_len <= 0) { | 330 | if (fail_or_len < 0) { |
332 | #ifdef LOGGING | 331 | #ifdef LOGGING |
333 | 332 | ||
334 | if ((fail_or_len < 0) && (errno != EWOULDBLOCK)) { | 333 | if ((fail_or_len < 0) && (errno != EWOULDBLOCK)) { |
@@ -337,7 +336,7 @@ static int receivepacket(sock_t sock, IP_Port *ip_port, uint8_t *data, uint32_t | |||
337 | } | 336 | } |
338 | 337 | ||
339 | #endif | 338 | #endif |
340 | return -1; /* Nothing received or empty packet. */ | 339 | return -1; /* Nothing received. */ |
341 | } | 340 | } |
342 | 341 | ||
343 | *length = (uint32_t)fail_or_len; | 342 | *length = (uint32_t)fail_or_len; |
diff --git a/toxcore/onion_client.c b/toxcore/onion_client.c index 52fdfeaf..0a238b5f 100644 --- a/toxcore/onion_client.c +++ b/toxcore/onion_client.c | |||
@@ -509,9 +509,9 @@ static int handle_fakeid_announce(void *object, uint8_t *source_pubkey, uint8_t | |||
509 | return 0; | 509 | return 0; |
510 | } | 510 | } |
511 | /* Send data of length length to friendnum. | 511 | /* Send data of length length to friendnum. |
512 | * This data will be recieved by the friend using the Onion_Data_Handlers callbacks. | 512 | * This data will be received by the friend using the Onion_Data_Handlers callbacks. |
513 | * | 513 | * |
514 | * Even if this function succeeds, the friend might not recieve any data. | 514 | * Even if this function succeeds, the friend might not receive any data. |
515 | * | 515 | * |
516 | * return the number of packets sent on success | 516 | * return the number of packets sent on success |
517 | * return -1 on failure. | 517 | * return -1 on failure. |
@@ -574,7 +574,7 @@ int send_onion_data(Onion_Client *onion_c, int friend_num, uint8_t *data, uint32 | |||
574 | 574 | ||
575 | /* Try to send the fakeid via the DHT instead of onion | 575 | /* Try to send the fakeid via the DHT instead of onion |
576 | * | 576 | * |
577 | * Even if this function succeeds, the friend might not recieve any data. | 577 | * Even if this function succeeds, the friend might not receive any data. |
578 | * | 578 | * |
579 | * return the number of packets sent on success | 579 | * return the number of packets sent on success |
580 | * return -1 on failure. | 580 | * return -1 on failure. |
diff --git a/toxcore/onion_client.h b/toxcore/onion_client.h index 4affcc6a..32d2989f 100644 --- a/toxcore/onion_client.h +++ b/toxcore/onion_client.h | |||
@@ -184,9 +184,9 @@ int onion_getfriend_DHT_pubkey(Onion_Client *onion_c, int friend_num, uint8_t *d | |||
184 | 184 | ||
185 | /* Send data of length length to friendnum. | 185 | /* Send data of length length to friendnum. |
186 | * Maximum length of data is ONION_CLIENT_MAX_DATA_SIZE. | 186 | * Maximum length of data is ONION_CLIENT_MAX_DATA_SIZE. |
187 | * This data will be recieved by the friend using the Onion_Data_Handlers callbacks. | 187 | * This data will be received by the friend using the Onion_Data_Handlers callbacks. |
188 | * | 188 | * |
189 | * Even if this function succeeds, the friend might not recieve any data. | 189 | * Even if this function succeeds, the friend might not receive any data. |
190 | * | 190 | * |
191 | * return the number of packets sent on success | 191 | * return the number of packets sent on success |
192 | * return -1 on failure. | 192 | * return -1 on failure. |
diff --git a/toxcore/tox.c b/toxcore/tox.c index 037cb7f5..d49e2241 100644 --- a/toxcore/tox.c +++ b/toxcore/tox.c | |||
@@ -186,7 +186,7 @@ int tox_set_name(Tox *tox, uint8_t *name, uint16_t length) | |||
186 | } | 186 | } |
187 | 187 | ||
188 | /* Get your nickname. | 188 | /* Get your nickname. |
189 | * m - The messanger context to use. | 189 | * m - The messenger context to use. |
190 | * name - Pointer to a string for the name. (must be at least MAX_NAME_LENGTH) | 190 | * name - Pointer to a string for the name. (must be at least MAX_NAME_LENGTH) |
191 | * | 191 | * |
192 | * return length of the name. | 192 | * return length of the name. |
@@ -828,4 +828,4 @@ int tox_load(Tox *tox, uint8_t *data, uint32_t length) | |||
828 | { | 828 | { |
829 | Messenger *m = tox; | 829 | Messenger *m = tox; |
830 | return messenger_load(m, data, length); | 830 | return messenger_load(m, data, length); |
831 | } \ No newline at end of file | 831 | } |
diff --git a/toxcore/tox.h b/toxcore/tox.h index 8edf0499..111b2634 100644 --- a/toxcore/tox.h +++ b/toxcore/tox.h | |||
@@ -210,7 +210,7 @@ int tox_set_name(Tox *tox, uint8_t *name, uint16_t length); | |||
210 | 210 | ||
211 | /* | 211 | /* |
212 | * Get your nickname. | 212 | * Get your nickname. |
213 | * m - The messanger context to use. | 213 | * m - The messenger context to use. |
214 | * name - needs to be a valid memory location with a size of at least MAX_NAME_LENGTH (128) bytes. | 214 | * name - needs to be a valid memory location with a size of at least MAX_NAME_LENGTH (128) bytes. |
215 | * | 215 | * |
216 | * return length of name. | 216 | * return length of name. |
@@ -515,11 +515,11 @@ uint32_t tox_get_chatlist(Tox *tox, int *out_list, uint32_t list_size); | |||
515 | * tox_file_data_remaining(...) can be used to know how many bytes are left to send/receive. | 515 | * tox_file_data_remaining(...) can be used to know how many bytes are left to send/receive. |
516 | * | 516 | * |
517 | * If the connection breaks during file sending (The other person goes offline without pausing the sending and then comes back) | 517 | * If the connection breaks during file sending (The other person goes offline without pausing the sending and then comes back) |
518 | * the reciever must send a control packet with receive_send == 0 message_id = TOX_FILECONTROL_RESUME_BROKEN and the data being | 518 | * the receiver must send a control packet with receive_send == 0 message_id = TOX_FILECONTROL_RESUME_BROKEN and the data being |
519 | * a uint64_t (in host byte order) containing the number of bytes recieved. | 519 | * a uint64_t (in host byte order) containing the number of bytes received. |
520 | * | 520 | * |
521 | * If the sender recieves this packet, he must send a control packet with receive_send == 1 and control_type == TOX_FILECONTROL_ACCEPT | 521 | * If the sender receives this packet, he must send a control packet with receive_send == 1 and control_type == TOX_FILECONTROL_ACCEPT |
522 | * then he must start sending file data from the position (data , uint64_t in host byte order) recieved in the TOX_FILECONTROL_RESUME_BROKEN packet. | 522 | * then he must start sending file data from the position (data , uint64_t in host byte order) received in the TOX_FILECONTROL_RESUME_BROKEN packet. |
523 | * | 523 | * |
524 | * More to come... | 524 | * More to come... |
525 | */ | 525 | */ |