diff options
author | irungentoo <irungentoo@gmail.com> | 2013-10-23 14:32:09 -0400 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2013-10-23 14:32:09 -0400 |
commit | a67b4f8c6d85b5d77cbd8b04a1f7a90a4470947b (patch) | |
tree | c3cac91476290c4400d65d0eae0d510966ae5939 /toxcore | |
parent | b515eac0a3bec4d111e759922fd206236b56b4b1 (diff) |
Code cleanups.
Diffstat (limited to 'toxcore')
-rw-r--r-- | toxcore/Messenger.c | 10 | ||||
-rw-r--r-- | toxcore/net_crypto.c | 60 | ||||
-rw-r--r-- | toxcore/net_crypto.h | 6 | ||||
-rw-r--r-- | toxcore/ping.c | 18 | ||||
-rw-r--r-- | toxcore/ping.h | 17 | ||||
-rw-r--r-- | toxcore/util.c | 17 | ||||
-rw-r--r-- | toxcore/util.h | 17 |
7 files changed, 107 insertions, 38 deletions
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index 2e8efeac..eb379c4c 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c | |||
@@ -714,7 +714,7 @@ IP_Port get_friend_ipport(Messenger *m, int friendnumber) | |||
714 | 714 | ||
715 | int crypt_id = m->friendlist[friendnumber].crypt_connection_id; | 715 | int crypt_id = m->friendlist[friendnumber].crypt_connection_id; |
716 | 716 | ||
717 | if (is_cryptoconnected(m->net_crypto, crypt_id) != 3) | 717 | if (is_cryptoconnected(m->net_crypto, crypt_id) != CRYPTO_CONN_ESTABLISHED) |
718 | return zero; | 718 | return zero; |
719 | 719 | ||
720 | return connection_ip(m->net_crypto->lossless_udp, m->net_crypto->crypto_connections[crypt_id].number); | 720 | return connection_ip(m->net_crypto->lossless_udp, m->net_crypto->crypto_connections[crypt_id].number); |
@@ -1454,13 +1454,13 @@ void doFriends(Messenger *m) | |||
1454 | int friendok = DHT_getfriendip(m->dht, m->friendlist[i].client_id, &friendip); | 1454 | int friendok = DHT_getfriendip(m->dht, m->friendlist[i].client_id, &friendip); |
1455 | 1455 | ||
1456 | switch (is_cryptoconnected(m->net_crypto, m->friendlist[i].crypt_connection_id)) { | 1456 | switch (is_cryptoconnected(m->net_crypto, m->friendlist[i].crypt_connection_id)) { |
1457 | case 0: | 1457 | case CRYPTO_CONN_NO_CONNECTION: |
1458 | if (friendok == 1) | 1458 | if (friendok == 1) |
1459 | m->friendlist[i].crypt_connection_id = crypto_connect(m->net_crypto, m->friendlist[i].client_id, friendip); | 1459 | m->friendlist[i].crypt_connection_id = crypto_connect(m->net_crypto, m->friendlist[i].client_id, friendip); |
1460 | 1460 | ||
1461 | break; | 1461 | break; |
1462 | 1462 | ||
1463 | case 3: /* Connection is established. */ | 1463 | case CRYPTO_CONN_ESTABLISHED: /* Connection is established. */ |
1464 | set_friend_status(m, i, FRIEND_ONLINE); | 1464 | set_friend_status(m, i, FRIEND_ONLINE); |
1465 | m->friendlist[i].name_sent = 0; | 1465 | m->friendlist[i].name_sent = 0; |
1466 | m->friendlist[i].userstatus_sent = 0; | 1466 | m->friendlist[i].userstatus_sent = 0; |
@@ -1468,7 +1468,7 @@ void doFriends(Messenger *m) | |||
1468 | m->friendlist[i].ping_lastrecv = temp_time; | 1468 | m->friendlist[i].ping_lastrecv = temp_time; |
1469 | break; | 1469 | break; |
1470 | 1470 | ||
1471 | case 4: | 1471 | case CRYPTO_CONN_TIMED_OUT: |
1472 | crypto_kill(m->net_crypto, m->friendlist[i].crypt_connection_id); | 1472 | crypto_kill(m->net_crypto, m->friendlist[i].crypt_connection_id); |
1473 | m->friendlist[i].crypt_connection_id = -1; | 1473 | m->friendlist[i].crypt_connection_id = -1; |
1474 | break; | 1474 | break; |
@@ -1706,7 +1706,7 @@ void doFriends(Messenger *m) | |||
1706 | } | 1706 | } |
1707 | } else { | 1707 | } else { |
1708 | if (is_cryptoconnected(m->net_crypto, | 1708 | if (is_cryptoconnected(m->net_crypto, |
1709 | m->friendlist[i].crypt_connection_id) == 4) { /* If the connection timed out, kill it. */ | 1709 | m->friendlist[i].crypt_connection_id) == CRYPTO_CONN_TIMED_OUT) { /* If the connection timed out, kill it. */ |
1710 | crypto_kill(m->net_crypto, m->friendlist[i].crypt_connection_id); | 1710 | crypto_kill(m->net_crypto, m->friendlist[i].crypt_connection_id); |
1711 | m->friendlist[i].crypt_connection_id = -1; | 1711 | m->friendlist[i].crypt_connection_id = -1; |
1712 | set_friend_status(m, i, FRIEND_CONFIRMED); | 1712 | set_friend_status(m, i, FRIEND_CONFIRMED); |
diff --git a/toxcore/net_crypto.c b/toxcore/net_crypto.c index 14831868..a9aa77f9 100644 --- a/toxcore/net_crypto.c +++ b/toxcore/net_crypto.c | |||
@@ -30,12 +30,6 @@ | |||
30 | 30 | ||
31 | #include "net_crypto.h" | 31 | #include "net_crypto.h" |
32 | 32 | ||
33 | #define CONN_NO_CONNECTION 0 | ||
34 | #define CONN_HANDSHAKE_SENT 1 | ||
35 | #define CONN_NOT_CONFIRMED 2 | ||
36 | #define CONN_ESTABLISHED 3 | ||
37 | #define CONN_TIMED_OUT 4 | ||
38 | |||
39 | static uint8_t crypt_connection_id_not_valid(Net_Crypto *c, int crypt_connection_id) | 33 | static uint8_t crypt_connection_id_not_valid(Net_Crypto *c, int crypt_connection_id) |
40 | { | 34 | { |
41 | return (uint32_t)crypt_connection_id >= c->crypto_connections_length; | 35 | return (uint32_t)crypt_connection_id >= c->crypto_connections_length; |
@@ -174,7 +168,7 @@ int read_cryptpacket(Net_Crypto *c, int crypt_connection_id, uint8_t *data) | |||
174 | if (crypt_connection_id_not_valid(c, crypt_connection_id)) | 168 | if (crypt_connection_id_not_valid(c, crypt_connection_id)) |
175 | return 0; | 169 | return 0; |
176 | 170 | ||
177 | if (c->crypto_connections[crypt_connection_id].status != CONN_ESTABLISHED) | 171 | if (c->crypto_connections[crypt_connection_id].status != CRYPTO_CONN_ESTABLISHED) |
178 | return 0; | 172 | return 0; |
179 | 173 | ||
180 | uint8_t temp_data[MAX_DATA_SIZE]; | 174 | uint8_t temp_data[MAX_DATA_SIZE]; |
@@ -220,7 +214,7 @@ int write_cryptpacket(Net_Crypto *c, int crypt_connection_id, uint8_t *data, uin | |||
220 | if (length - crypto_box_BOXZEROBYTES + crypto_box_ZEROBYTES > MAX_DATA_SIZE - 1) | 214 | if (length - crypto_box_BOXZEROBYTES + crypto_box_ZEROBYTES > MAX_DATA_SIZE - 1) |
221 | return 0; | 215 | return 0; |
222 | 216 | ||
223 | if (c->crypto_connections[crypt_connection_id].status != CONN_ESTABLISHED) | 217 | if (c->crypto_connections[crypt_connection_id].status != CRYPTO_CONN_ESTABLISHED) |
224 | return 0; | 218 | return 0; |
225 | 219 | ||
226 | uint8_t temp_data[MAX_DATA_SIZE]; | 220 | uint8_t temp_data[MAX_DATA_SIZE]; |
@@ -420,7 +414,7 @@ static int getcryptconnection_id(Net_Crypto *c, uint8_t *public_key) | |||
420 | uint32_t i; | 414 | uint32_t i; |
421 | 415 | ||
422 | for (i = 0; i < c->crypto_connections_length; ++i) { | 416 | for (i = 0; i < c->crypto_connections_length; ++i) { |
423 | if (c->crypto_connections[i].status != CONN_NO_CONNECTION) | 417 | if (c->crypto_connections[i].status != CRYPTO_CONN_NO_CONNECTION) |
424 | if (memcmp(public_key, c->crypto_connections[i].public_key, crypto_box_PUBLICKEYBYTES) == 0) | 418 | if (memcmp(public_key, c->crypto_connections[i].public_key, crypto_box_PUBLICKEYBYTES) == 0) |
425 | return i; | 419 | return i; |
426 | } | 420 | } |
@@ -474,14 +468,14 @@ int crypto_connect(Net_Crypto *c, uint8_t *public_key, IP_Port ip_port) | |||
474 | c->crypto_connections[c->crypto_connections_length].number = ~0; | 468 | c->crypto_connections[c->crypto_connections_length].number = ~0; |
475 | 469 | ||
476 | for (i = 0; i <= c->crypto_connections_length; ++i) { | 470 | for (i = 0; i <= c->crypto_connections_length; ++i) { |
477 | if (c->crypto_connections[i].status == CONN_NO_CONNECTION) { | 471 | if (c->crypto_connections[i].status == CRYPTO_CONN_NO_CONNECTION) { |
478 | int id_new = new_connection(c->lossless_udp, ip_port); | 472 | int id_new = new_connection(c->lossless_udp, ip_port); |
479 | 473 | ||
480 | if (id_new == -1) | 474 | if (id_new == -1) |
481 | return -1; | 475 | return -1; |
482 | 476 | ||
483 | c->crypto_connections[i].number = id_new; | 477 | c->crypto_connections[i].number = id_new; |
484 | c->crypto_connections[i].status = CONN_HANDSHAKE_SENT; | 478 | c->crypto_connections[i].status = CRYPTO_CONN_HANDSHAKE_SENT; |
485 | random_nonce(c->crypto_connections[i].recv_nonce); | 479 | random_nonce(c->crypto_connections[i].recv_nonce); |
486 | memcpy(c->crypto_connections[i].public_key, public_key, crypto_box_PUBLICKEYBYTES); | 480 | memcpy(c->crypto_connections[i].public_key, public_key, crypto_box_PUBLICKEYBYTES); |
487 | crypto_box_keypair(c->crypto_connections[i].sessionpublic_key, c->crypto_connections[i].sessionsecret_key); | 481 | crypto_box_keypair(c->crypto_connections[i].sessionpublic_key, c->crypto_connections[i].sessionsecret_key); |
@@ -550,15 +544,15 @@ int crypto_kill(Net_Crypto *c, int crypt_connection_id) | |||
550 | if (crypt_connection_id_not_valid(c, crypt_connection_id)) | 544 | if (crypt_connection_id_not_valid(c, crypt_connection_id)) |
551 | return 1; | 545 | return 1; |
552 | 546 | ||
553 | if (c->crypto_connections[crypt_connection_id].status != CONN_NO_CONNECTION) { | 547 | if (c->crypto_connections[crypt_connection_id].status != CRYPTO_CONN_NO_CONNECTION) { |
554 | c->crypto_connections[crypt_connection_id].status = CONN_NO_CONNECTION; | 548 | c->crypto_connections[crypt_connection_id].status = CRYPTO_CONN_NO_CONNECTION; |
555 | kill_connection(c->lossless_udp, c->crypto_connections[crypt_connection_id].number); | 549 | kill_connection(c->lossless_udp, c->crypto_connections[crypt_connection_id].number); |
556 | memset(&(c->crypto_connections[crypt_connection_id]), 0 , sizeof(Crypto_Connection)); | 550 | memset(&(c->crypto_connections[crypt_connection_id]), 0 , sizeof(Crypto_Connection)); |
557 | c->crypto_connections[crypt_connection_id].number = ~0; | 551 | c->crypto_connections[crypt_connection_id].number = ~0; |
558 | uint32_t i; | 552 | uint32_t i; |
559 | 553 | ||
560 | for (i = c->crypto_connections_length; i != 0; --i) { | 554 | for (i = c->crypto_connections_length; i != 0; --i) { |
561 | if (c->crypto_connections[i - 1].status != CONN_NO_CONNECTION) | 555 | if (c->crypto_connections[i - 1].status != CRYPTO_CONN_NO_CONNECTION) |
562 | break; | 556 | break; |
563 | } | 557 | } |
564 | 558 | ||
@@ -598,9 +592,9 @@ int accept_crypto_inbound(Net_Crypto *c, int connection_id, uint8_t *public_key, | |||
598 | c->crypto_connections[c->crypto_connections_length].number = ~0; | 592 | c->crypto_connections[c->crypto_connections_length].number = ~0; |
599 | 593 | ||
600 | for (i = 0; i <= c->crypto_connections_length; ++i) { | 594 | for (i = 0; i <= c->crypto_connections_length; ++i) { |
601 | if (c->crypto_connections[i].status == CONN_NO_CONNECTION) { | 595 | if (c->crypto_connections[i].status == CRYPTO_CONN_NO_CONNECTION) { |
602 | c->crypto_connections[i].number = connection_id; | 596 | c->crypto_connections[i].number = connection_id; |
603 | c->crypto_connections[i].status = CONN_NOT_CONFIRMED; | 597 | c->crypto_connections[i].status = CRYPTO_CONN_NOT_CONFIRMED; |
604 | c->crypto_connections[i].timeout = unix_time() + CRYPTO_HANDSHAKE_TIMEOUT; | 598 | c->crypto_connections[i].timeout = unix_time() + CRYPTO_HANDSHAKE_TIMEOUT; |
605 | random_nonce(c->crypto_connections[i].recv_nonce); | 599 | random_nonce(c->crypto_connections[i].recv_nonce); |
606 | memcpy(c->crypto_connections[i].sent_nonce, secret_nonce, crypto_box_NONCEBYTES); | 600 | memcpy(c->crypto_connections[i].sent_nonce, secret_nonce, crypto_box_NONCEBYTES); |
@@ -621,9 +615,9 @@ int accept_crypto_inbound(Net_Crypto *c, int connection_id, uint8_t *public_key, | |||
621 | c->crypto_connections[i].sessionsecret_key, | 615 | c->crypto_connections[i].sessionsecret_key, |
622 | c->crypto_connections[i].shared_key); | 616 | c->crypto_connections[i].shared_key); |
623 | c->crypto_connections[i].status = | 617 | c->crypto_connections[i].status = |
624 | CONN_ESTABLISHED; /* Connection status needs to be 3 for write_cryptpacket() to work. */ | 618 | CRYPTO_CONN_ESTABLISHED; /* Connection status needs to be 3 for write_cryptpacket() to work. */ |
625 | write_cryptpacket(c, i, ((uint8_t *)&zero), sizeof(zero)); | 619 | write_cryptpacket(c, i, ((uint8_t *)&zero), sizeof(zero)); |
626 | c->crypto_connections[i].status = CONN_NOT_CONFIRMED; /* Set it to its proper value right after. */ | 620 | c->crypto_connections[i].status = CRYPTO_CONN_NOT_CONFIRMED; /* Set it to its proper value right after. */ |
627 | return i; | 621 | return i; |
628 | } | 622 | } |
629 | 623 | ||
@@ -645,7 +639,7 @@ int is_cryptoconnected(Net_Crypto *c, int crypt_connection_id) | |||
645 | if ((unsigned int)crypt_connection_id < c->crypto_connections_length) | 639 | if ((unsigned int)crypt_connection_id < c->crypto_connections_length) |
646 | return c->crypto_connections[crypt_connection_id].status; | 640 | return c->crypto_connections[crypt_connection_id].status; |
647 | 641 | ||
648 | return CONN_NO_CONNECTION; | 642 | return CRYPTO_CONN_NO_CONNECTION; |
649 | } | 643 | } |
650 | 644 | ||
651 | void new_keys(Net_Crypto *c) | 645 | void new_keys(Net_Crypto *c) |
@@ -678,10 +672,10 @@ static void receive_crypto(Net_Crypto *c) | |||
678 | uint64_t temp_time = unix_time(); | 672 | uint64_t temp_time = unix_time(); |
679 | 673 | ||
680 | for (i = 0; i < c->crypto_connections_length; ++i) { | 674 | for (i = 0; i < c->crypto_connections_length; ++i) { |
681 | if (c->crypto_connections[i].status == CONN_NO_CONNECTION) | 675 | if (c->crypto_connections[i].status == CRYPTO_CONN_NO_CONNECTION) |
682 | continue; | 676 | continue; |
683 | 677 | ||
684 | if (c->crypto_connections[i].status == CONN_HANDSHAKE_SENT) { | 678 | if (c->crypto_connections[i].status == CRYPTO_CONN_HANDSHAKE_SENT) { |
685 | uint8_t temp_data[MAX_DATA_SIZE]; | 679 | uint8_t temp_data[MAX_DATA_SIZE]; |
686 | uint8_t secret_nonce[crypto_box_NONCEBYTES]; | 680 | uint8_t secret_nonce[crypto_box_NONCEBYTES]; |
687 | uint8_t public_key[crypto_box_PUBLICKEYBYTES]; | 681 | uint8_t public_key[crypto_box_PUBLICKEYBYTES]; |
@@ -701,25 +695,25 @@ static void receive_crypto(Net_Crypto *c) | |||
701 | c->crypto_connections[i].sessionsecret_key, | 695 | c->crypto_connections[i].sessionsecret_key, |
702 | c->crypto_connections[i].shared_key); | 696 | c->crypto_connections[i].shared_key); |
703 | c->crypto_connections[i].status = | 697 | c->crypto_connections[i].status = |
704 | CONN_ESTABLISHED; /* Connection status needs to be 3 for write_cryptpacket() to work. */ | 698 | CRYPTO_CONN_ESTABLISHED; /* Connection status needs to be 3 for write_cryptpacket() to work. */ |
705 | write_cryptpacket(c, i, ((uint8_t *)&zero), sizeof(zero)); | 699 | write_cryptpacket(c, i, ((uint8_t *)&zero), sizeof(zero)); |
706 | c->crypto_connections[i].status = CONN_NOT_CONFIRMED; /* Set it to its proper value right after. */ | 700 | c->crypto_connections[i].status = CRYPTO_CONN_NOT_CONFIRMED; /* Set it to its proper value right after. */ |
707 | } else { | 701 | } else { |
708 | /* This should not happen, timeout the connection if it does. */ | 702 | /* This should not happen, timeout the connection if it does. */ |
709 | c->crypto_connections[i].status = CONN_TIMED_OUT; | 703 | c->crypto_connections[i].status = CRYPTO_CONN_TIMED_OUT; |
710 | } | 704 | } |
711 | } else { | 705 | } else { |
712 | /* This should not happen, timeout the connection if it does. */ | 706 | /* This should not happen, timeout the connection if it does. */ |
713 | c->crypto_connections[i].status = CONN_TIMED_OUT; | 707 | c->crypto_connections[i].status = CRYPTO_CONN_TIMED_OUT; |
714 | } | 708 | } |
715 | } else if (id_packet(c->lossless_udp, | 709 | } else if (id_packet(c->lossless_udp, |
716 | c->crypto_connections[i].number) != -1) { | 710 | c->crypto_connections[i].number) != -1) { |
717 | /* This should not happen, timeout the connection if it does. */ | 711 | /* This should not happen, timeout the connection if it does. */ |
718 | c->crypto_connections[i].status = CONN_TIMED_OUT; | 712 | c->crypto_connections[i].status = CRYPTO_CONN_TIMED_OUT; |
719 | } | 713 | } |
720 | } | 714 | } |
721 | 715 | ||
722 | if (c->crypto_connections[i].status == CONN_NOT_CONFIRMED) { | 716 | if (c->crypto_connections[i].status == CRYPTO_CONN_NOT_CONFIRMED) { |
723 | if (id_packet(c->lossless_udp, c->crypto_connections[i].number) == 3) { | 717 | if (id_packet(c->lossless_udp, c->crypto_connections[i].number) == 3) { |
724 | uint8_t temp_data[MAX_DATA_SIZE]; | 718 | uint8_t temp_data[MAX_DATA_SIZE]; |
725 | uint8_t data[MAX_DATA_SIZE]; | 719 | uint8_t data[MAX_DATA_SIZE]; |
@@ -734,22 +728,22 @@ static void receive_crypto(Net_Crypto *c) | |||
734 | encrypt_precompute(c->crypto_connections[i].peersessionpublic_key, | 728 | encrypt_precompute(c->crypto_connections[i].peersessionpublic_key, |
735 | c->crypto_connections[i].sessionsecret_key, | 729 | c->crypto_connections[i].sessionsecret_key, |
736 | c->crypto_connections[i].shared_key); | 730 | c->crypto_connections[i].shared_key); |
737 | c->crypto_connections[i].status = CONN_ESTABLISHED; | 731 | c->crypto_connections[i].status = CRYPTO_CONN_ESTABLISHED; |
738 | c->crypto_connections[i].timeout = ~0; | 732 | c->crypto_connections[i].timeout = ~0; |
739 | /* Connection is accepted. */ | 733 | /* Connection is accepted. */ |
740 | confirm_connection(c->lossless_udp, c->crypto_connections[i].number); | 734 | confirm_connection(c->lossless_udp, c->crypto_connections[i].number); |
741 | } else { | 735 | } else { |
742 | /* This should not happen, timeout the connection if it does. */ | 736 | /* This should not happen, timeout the connection if it does. */ |
743 | c->crypto_connections[i].status = CONN_TIMED_OUT; | 737 | c->crypto_connections[i].status = CRYPTO_CONN_TIMED_OUT; |
744 | } | 738 | } |
745 | } else if (id_packet(c->lossless_udp, c->crypto_connections[i].number) != -1) { | 739 | } else if (id_packet(c->lossless_udp, c->crypto_connections[i].number) != -1) { |
746 | /* This should not happen, timeout the connection if it does. */ | 740 | /* This should not happen, timeout the connection if it does. */ |
747 | c->crypto_connections[i].status = CONN_TIMED_OUT; | 741 | c->crypto_connections[i].status = CRYPTO_CONN_TIMED_OUT; |
748 | } | 742 | } |
749 | } | 743 | } |
750 | 744 | ||
751 | if (temp_time > c->crypto_connections[i].timeout) { | 745 | if (temp_time > c->crypto_connections[i].timeout) { |
752 | c->crypto_connections[i].status = CONN_TIMED_OUT; | 746 | c->crypto_connections[i].status = CRYPTO_CONN_TIMED_OUT; |
753 | } | 747 | } |
754 | } | 748 | } |
755 | } | 749 | } |
@@ -788,9 +782,9 @@ static void kill_timedout(Net_Crypto *c) | |||
788 | uint32_t i; | 782 | uint32_t i; |
789 | 783 | ||
790 | for (i = 0; i < c->crypto_connections_length; ++i) { | 784 | for (i = 0; i < c->crypto_connections_length; ++i) { |
791 | if (c->crypto_connections[i].status != CONN_NO_CONNECTION | 785 | if (c->crypto_connections[i].status != CRYPTO_CONN_NO_CONNECTION |
792 | && is_connected(c->lossless_udp, c->crypto_connections[i].number) == LUDP_TIMED_OUT) | 786 | && is_connected(c->lossless_udp, c->crypto_connections[i].number) == LUDP_TIMED_OUT) |
793 | c->crypto_connections[i].status = CONN_TIMED_OUT; | 787 | c->crypto_connections[i].status = CRYPTO_CONN_TIMED_OUT; |
794 | } | 788 | } |
795 | } | 789 | } |
796 | 790 | ||
diff --git a/toxcore/net_crypto.h b/toxcore/net_crypto.h index f0141f52..0de66e98 100644 --- a/toxcore/net_crypto.h +++ b/toxcore/net_crypto.h | |||
@@ -30,6 +30,12 @@ | |||
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 (CONNECTION_TIMEOUT * 2) | 31 | #define CRYPTO_HANDSHAKE_TIMEOUT (CONNECTION_TIMEOUT * 2) |
32 | 32 | ||
33 | #define CRYPTO_CONN_NO_CONNECTION 0 | ||
34 | #define CRYPTO_CONN_HANDSHAKE_SENT 1 | ||
35 | #define CRYPTO_CONN_NOT_CONFIRMED 2 | ||
36 | #define CRYPTO_CONN_ESTABLISHED 3 | ||
37 | #define CRYPTO_CONN_TIMED_OUT 4 | ||
38 | |||
33 | typedef struct { | 39 | typedef struct { |
34 | uint8_t public_key[crypto_box_PUBLICKEYBYTES]; /* The real public key of the peer. */ | 40 | uint8_t public_key[crypto_box_PUBLICKEYBYTES]; /* The real public key of the peer. */ |
35 | uint8_t recv_nonce[crypto_box_NONCEBYTES]; /* Nonce of received packets. */ | 41 | uint8_t recv_nonce[crypto_box_NONCEBYTES]; /* Nonce of received packets. */ |
diff --git a/toxcore/ping.c b/toxcore/ping.c index b9940ce1..2d0a4545 100644 --- a/toxcore/ping.c +++ b/toxcore/ping.c | |||
@@ -3,6 +3,24 @@ | |||
3 | * | 3 | * |
4 | * This file is donated to the Tox Project. | 4 | * This file is donated to the Tox Project. |
5 | * Copyright 2013 plutooo | 5 | * Copyright 2013 plutooo |
6 | * | ||
7 | * Copyright (C) 2013 Tox project All Rights Reserved. | ||
8 | * | ||
9 | * This file is part of Tox. | ||
10 | * | ||
11 | * Tox is free software: you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License as published by | ||
13 | * the Free Software Foundation, either version 3 of the License, or | ||
14 | * (at your option) any later version. | ||
15 | * | ||
16 | * Tox is distributed in the hope that it will be useful, | ||
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
19 | * GNU General Public License for more details. | ||
20 | * | ||
21 | * You should have received a copy of the GNU General Public License | ||
22 | * along with Tox. If not, see <http://www.gnu.org/licenses/>. | ||
23 | * | ||
6 | */ | 24 | */ |
7 | 25 | ||
8 | #ifdef HAVE_CONFIG_H | 26 | #ifdef HAVE_CONFIG_H |
diff --git a/toxcore/ping.h b/toxcore/ping.h index fabb1afd..32742401 100644 --- a/toxcore/ping.h +++ b/toxcore/ping.h | |||
@@ -3,6 +3,23 @@ | |||
3 | * | 3 | * |
4 | * This file is donated to the Tox Project. | 4 | * This file is donated to the Tox Project. |
5 | * Copyright 2013 plutooo | 5 | * Copyright 2013 plutooo |
6 | * | ||
7 | * Copyright (C) 2013 Tox project All Rights Reserved. | ||
8 | * | ||
9 | * This file is part of Tox. | ||
10 | * | ||
11 | * Tox is free software: you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License as published by | ||
13 | * the Free Software Foundation, either version 3 of the License, or | ||
14 | * (at your option) any later version. | ||
15 | * | ||
16 | * Tox is distributed in the hope that it will be useful, | ||
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
19 | * GNU General Public License for more details. | ||
20 | * | ||
21 | * You should have received a copy of the GNU General Public License | ||
22 | * along with Tox. If not, see <http://www.gnu.org/licenses/>. | ||
6 | */ | 23 | */ |
7 | #ifndef __PING_H__ | 24 | #ifndef __PING_H__ |
8 | #define __PING_H__ | 25 | #define __PING_H__ |
diff --git a/toxcore/util.c b/toxcore/util.c index a1de6392..576972b4 100644 --- a/toxcore/util.c +++ b/toxcore/util.c | |||
@@ -3,6 +3,23 @@ | |||
3 | * | 3 | * |
4 | * This file is donated to the Tox Project. | 4 | * This file is donated to the Tox Project. |
5 | * Copyright 2013 plutooo | 5 | * Copyright 2013 plutooo |
6 | * | ||
7 | * Copyright (C) 2013 Tox project All Rights Reserved. | ||
8 | * | ||
9 | * This file is part of Tox. | ||
10 | * | ||
11 | * Tox is free software: you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License as published by | ||
13 | * the Free Software Foundation, either version 3 of the License, or | ||
14 | * (at your option) any later version. | ||
15 | * | ||
16 | * Tox is distributed in the hope that it will be useful, | ||
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
19 | * GNU General Public License for more details. | ||
20 | * | ||
21 | * You should have received a copy of the GNU General Public License | ||
22 | * along with Tox. If not, see <http://www.gnu.org/licenses/>. | ||
6 | */ | 23 | */ |
7 | 24 | ||
8 | #ifdef HAVE_CONFIG_H | 25 | #ifdef HAVE_CONFIG_H |
diff --git a/toxcore/util.h b/toxcore/util.h index 13ab4792..f7b30693 100644 --- a/toxcore/util.h +++ b/toxcore/util.h | |||
@@ -3,6 +3,23 @@ | |||
3 | * | 3 | * |
4 | * This file is donated to the Tox Project. | 4 | * This file is donated to the Tox Project. |
5 | * Copyright 2013 plutooo | 5 | * Copyright 2013 plutooo |
6 | * | ||
7 | * Copyright (C) 2013 Tox project All Rights Reserved. | ||
8 | * | ||
9 | * This file is part of Tox. | ||
10 | * | ||
11 | * Tox is free software: you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License as published by | ||
13 | * the Free Software Foundation, either version 3 of the License, or | ||
14 | * (at your option) any later version. | ||
15 | * | ||
16 | * Tox is distributed in the hope that it will be useful, | ||
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
19 | * GNU General Public License for more details. | ||
20 | * | ||
21 | * You should have received a copy of the GNU General Public License | ||
22 | * along with Tox. If not, see <http://www.gnu.org/licenses/>. | ||
6 | */ | 23 | */ |
7 | 24 | ||
8 | #ifndef __UTIL_H__ | 25 | #ifndef __UTIL_H__ |