diff options
author | Florian Hahn <flo@fhahn.com> | 2013-08-04 22:47:16 +0200 |
---|---|---|
committer | Florian Hahn <flo@fhahn.com> | 2013-08-04 23:05:27 +0200 |
commit | 2a9fedc08f4ebaa210f94041a99eb6d11c0ce45c (patch) | |
tree | a3a72b58403fe5121f2b9c21f2c69cb87fa5f18a /core/Lossless_UDP.c | |
parent | 8680cf76bfee0fe21529d6f4747801d246be177f (diff) |
Make private functions in core/Lossless_UDP.c static
Diffstat (limited to 'core/Lossless_UDP.c')
-rw-r--r-- | core/Lossless_UDP.c | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/core/Lossless_UDP.c b/core/Lossless_UDP.c index a753e5ff..8538f76c 100644 --- a/core/Lossless_UDP.c +++ b/core/Lossless_UDP.c | |||
@@ -149,7 +149,7 @@ static uint32_t randtable[6][256]; | |||
149 | * | 149 | * |
150 | * TODO: make this better | 150 | * TODO: make this better |
151 | */ | 151 | */ |
152 | uint32_t handshake_id(IP_Port source) | 152 | static uint32_t handshake_id(IP_Port source) |
153 | { | 153 | { |
154 | uint32_t id = 0, i; | 154 | uint32_t id = 0, i; |
155 | for (i = 0; i < 6; ++i) { | 155 | for (i = 0; i < 6; ++i) { |
@@ -168,7 +168,7 @@ uint32_t handshake_id(IP_Port source) | |||
168 | * | 168 | * |
169 | * TODO: make this better | 169 | * TODO: make this better |
170 | */ | 170 | */ |
171 | void change_handshake(IP_Port source) | 171 | static void change_handshake(IP_Port source) |
172 | { | 172 | { |
173 | uint8_t rand = random_int() % 4; | 173 | uint8_t rand = random_int() % 4; |
174 | randtable[rand][((uint8_t *)&source)[rand]] = random_int(); | 174 | randtable[rand][((uint8_t *)&source)[rand]] = random_int(); |
@@ -234,7 +234,7 @@ int new_connection(IP_Port ip_port) | |||
234 | * Returns an integer corresponding to the connection id. | 234 | * Returns an integer corresponding to the connection id. |
235 | * Return -1 if it could not initialize the connection. | 235 | * Return -1 if it could not initialize the connection. |
236 | */ | 236 | */ |
237 | int new_inconnection(IP_Port ip_port) | 237 | static int new_inconnection(IP_Port ip_port) |
238 | { | 238 | { |
239 | if (getconnection_id(ip_port) != -1) | 239 | if (getconnection_id(ip_port) != -1) |
240 | return -1; | 240 | return -1; |
@@ -470,7 +470,7 @@ uint32_t missing_packets(int connection_id, uint32_t * requested) | |||
470 | * see http://wiki.tox.im/index.php/Lossless_UDP for more information. | 470 | * see http://wiki.tox.im/index.php/Lossless_UDP for more information. |
471 | */ | 471 | */ |
472 | 472 | ||
473 | int send_handshake(IP_Port ip_port, uint32_t handshake_id1, uint32_t handshake_id2) | 473 | static int send_handshake(IP_Port ip_port, uint32_t handshake_id1, uint32_t handshake_id2) |
474 | { | 474 | { |
475 | uint8_t packet[1 + 4 + 4]; | 475 | uint8_t packet[1 + 4 + 4]; |
476 | uint32_t temp; | 476 | uint32_t temp; |
@@ -484,7 +484,7 @@ int send_handshake(IP_Port ip_port, uint32_t handshake_id1, uint32_t handshake_i | |||
484 | return sendpacket(ip_port, packet, sizeof(packet)); | 484 | return sendpacket(ip_port, packet, sizeof(packet)); |
485 | } | 485 | } |
486 | 486 | ||
487 | int send_SYNC(uint32_t connection_id) | 487 | static int send_SYNC(uint32_t connection_id) |
488 | { | 488 | { |
489 | uint8_t packet[(BUFFER_PACKET_NUM*4 + 4 + 4 + 2)]; | 489 | uint8_t packet[(BUFFER_PACKET_NUM*4 + 4 + 4 + 2)]; |
490 | uint16_t index = 0; | 490 | uint16_t index = 0; |
@@ -511,7 +511,7 @@ int send_SYNC(uint32_t connection_id) | |||
511 | 511 | ||
512 | } | 512 | } |
513 | 513 | ||
514 | int send_data_packet(uint32_t connection_id, uint32_t packet_num) | 514 | static int send_data_packet(uint32_t connection_id, uint32_t packet_num) |
515 | { | 515 | { |
516 | uint32_t index = packet_num % MAX_QUEUE_NUM; | 516 | uint32_t index = packet_num % MAX_QUEUE_NUM; |
517 | uint32_t temp; | 517 | uint32_t temp; |
@@ -526,7 +526,7 @@ int send_data_packet(uint32_t connection_id, uint32_t packet_num) | |||
526 | } | 526 | } |
527 | 527 | ||
528 | /* sends 1 data packet */ | 528 | /* sends 1 data packet */ |
529 | int send_DATA(uint32_t connection_id) | 529 | static int send_DATA(uint32_t connection_id) |
530 | { | 530 | { |
531 | int ret; | 531 | int ret; |
532 | uint32_t buffer[BUFFER_PACKET_NUM]; | 532 | uint32_t buffer[BUFFER_PACKET_NUM]; |
@@ -555,7 +555,7 @@ int send_DATA(uint32_t connection_id) | |||
555 | 555 | ||
556 | 556 | ||
557 | /* Return 0 if handled correctly, 1 if packet is bad. */ | 557 | /* Return 0 if handled correctly, 1 if packet is bad. */ |
558 | int handle_handshake(uint8_t * packet, uint32_t length, IP_Port source) | 558 | static int handle_handshake(uint8_t * packet, uint32_t length, IP_Port source) |
559 | { | 559 | { |
560 | if (length != (1 + 4 + 4)) | 560 | if (length != (1 + 4 + 4)) |
561 | return 1; | 561 | return 1; |
@@ -591,7 +591,7 @@ int handle_handshake(uint8_t * packet, uint32_t length, IP_Port source) | |||
591 | } | 591 | } |
592 | 592 | ||
593 | /* returns 1 if sync packet is valid 0 if not. */ | 593 | /* returns 1 if sync packet is valid 0 if not. */ |
594 | int SYNC_valid(uint32_t length) | 594 | static int SYNC_valid(uint32_t length) |
595 | { | 595 | { |
596 | if (length < 4 + 4 + 2) | 596 | if (length < 4 + 4 + 2) |
597 | return 0; | 597 | return 0; |
@@ -602,7 +602,7 @@ int SYNC_valid(uint32_t length) | |||
602 | } | 602 | } |
603 | 603 | ||
604 | /* case 1 in handle_SYNC: */ | 604 | /* case 1 in handle_SYNC: */ |
605 | int handle_SYNC1(IP_Port source, uint32_t recv_packetnum, uint32_t sent_packetnum) | 605 | static int handle_SYNC1(IP_Port source, uint32_t recv_packetnum, uint32_t sent_packetnum) |
606 | { | 606 | { |
607 | if (handshake_id(source) == recv_packetnum) { | 607 | if (handshake_id(source) == recv_packetnum) { |
608 | int x = new_inconnection(source); | 608 | int x = new_inconnection(source); |
@@ -622,7 +622,7 @@ int handle_SYNC1(IP_Port source, uint32_t recv_packetnum, uint32_t sent_packetnu | |||
622 | } | 622 | } |
623 | 623 | ||
624 | /* case 2 in handle_SYNC: */ | 624 | /* case 2 in handle_SYNC: */ |
625 | int handle_SYNC2(int connection_id, uint8_t counter, uint32_t recv_packetnum, uint32_t sent_packetnum) | 625 | static int handle_SYNC2(int connection_id, uint8_t counter, uint32_t recv_packetnum, uint32_t sent_packetnum) |
626 | { | 626 | { |
627 | if (recv_packetnum == connections[connection_id].orecv_packetnum) { | 627 | if (recv_packetnum == connections[connection_id].orecv_packetnum) { |
628 | /* && sent_packetnum == connections[connection_id].osent_packetnum) */ | 628 | /* && sent_packetnum == connections[connection_id].osent_packetnum) */ |
@@ -635,7 +635,7 @@ int handle_SYNC2(int connection_id, uint8_t counter, uint32_t recv_packetnum, ui | |||
635 | return 1; | 635 | return 1; |
636 | } | 636 | } |
637 | /* case 3 in handle_SYNC: */ | 637 | /* case 3 in handle_SYNC: */ |
638 | int handle_SYNC3(int connection_id, uint8_t counter, uint32_t recv_packetnum, uint32_t sent_packetnum, uint32_t * req_packets, | 638 | static int handle_SYNC3(int connection_id, uint8_t counter, uint32_t recv_packetnum, uint32_t sent_packetnum, uint32_t * req_packets, |
639 | uint16_t number) | 639 | uint16_t number) |
640 | { | 640 | { |
641 | uint8_t comp_counter = (counter - connections[connection_id].recv_counter ); | 641 | uint8_t comp_counter = (counter - connections[connection_id].recv_counter ); |
@@ -669,7 +669,7 @@ int handle_SYNC3(int connection_id, uint8_t counter, uint32_t recv_packetnum, ui | |||
669 | return 1; | 669 | return 1; |
670 | } | 670 | } |
671 | 671 | ||
672 | int handle_SYNC(uint8_t *packet, uint32_t length, IP_Port source) | 672 | static int handle_SYNC(uint8_t *packet, uint32_t length, IP_Port source) |
673 | { | 673 | { |
674 | 674 | ||
675 | if (!SYNC_valid(length)) | 675 | if (!SYNC_valid(length)) |
@@ -708,7 +708,7 @@ int handle_SYNC(uint8_t *packet, uint32_t length, IP_Port source) | |||
708 | * Add a packet to the received buffer and set the recv_packetnum of the | 708 | * Add a packet to the received buffer and set the recv_packetnum of the |
709 | * connection to its proper value. Return 1 if data was too big, 0 if not. | 709 | * connection to its proper value. Return 1 if data was too big, 0 if not. |
710 | */ | 710 | */ |
711 | int add_recv(int connection_id, uint32_t data_num, uint8_t *data, uint16_t size) | 711 | static int add_recv(int connection_id, uint32_t data_num, uint8_t *data, uint16_t size) |
712 | { | 712 | { |
713 | if (size > MAX_DATA_SIZE) | 713 | if (size > MAX_DATA_SIZE) |
714 | return 1; | 714 | return 1; |
@@ -742,7 +742,7 @@ int add_recv(int connection_id, uint32_t data_num, uint8_t *data, uint16_t size) | |||
742 | return 0; | 742 | return 0; |
743 | } | 743 | } |
744 | 744 | ||
745 | int handle_data(uint8_t *packet, uint32_t length, IP_Port source) | 745 | static int handle_data(uint8_t *packet, uint32_t length, IP_Port source) |
746 | { | 746 | { |
747 | int connection = getconnection_id(source); | 747 | int connection = getconnection_id(source); |
748 | 748 | ||
@@ -793,7 +793,7 @@ int LosslessUDP_handlepacket(uint8_t *packet, uint32_t length, IP_Port source) | |||
793 | * Send handshake requests | 793 | * Send handshake requests |
794 | * handshake packets are sent at the same rate as SYNC packets | 794 | * handshake packets are sent at the same rate as SYNC packets |
795 | */ | 795 | */ |
796 | void doNew() | 796 | static void doNew() |
797 | { | 797 | { |
798 | uint32_t i; | 798 | uint32_t i; |
799 | uint64_t temp_time = current_time(); | 799 | uint64_t temp_time = current_time(); |
@@ -817,7 +817,7 @@ void doNew() | |||
817 | } | 817 | } |
818 | } | 818 | } |
819 | 819 | ||
820 | void doSYNC() | 820 | static void doSYNC() |
821 | { | 821 | { |
822 | uint32_t i; | 822 | uint32_t i; |
823 | uint64_t temp_time = current_time(); | 823 | uint64_t temp_time = current_time(); |
@@ -830,7 +830,7 @@ void doSYNC() | |||
830 | } | 830 | } |
831 | } | 831 | } |
832 | 832 | ||
833 | void doData() | 833 | static void doData() |
834 | { | 834 | { |
835 | uint32_t i; | 835 | uint32_t i; |
836 | uint64_t j; | 836 | uint64_t j; |
@@ -851,7 +851,7 @@ void doData() | |||
851 | * | 851 | * |
852 | * TODO: flow control. | 852 | * TODO: flow control. |
853 | */ | 853 | */ |
854 | void adjustRates() | 854 | static void adjustRates() |
855 | { | 855 | { |
856 | uint32_t i; | 856 | uint32_t i; |
857 | uint64_t temp_time = current_time(); | 857 | uint64_t temp_time = current_time(); |