diff options
Diffstat (limited to 'core/Lossless_UDP.c')
-rw-r--r-- | core/Lossless_UDP.c | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/core/Lossless_UDP.c b/core/Lossless_UDP.c index 47d63a71..83bb1785 100644 --- a/core/Lossless_UDP.c +++ b/core/Lossless_UDP.c | |||
@@ -25,8 +25,6 @@ | |||
25 | There are a couple of useless variables to get rid of. */ | 25 | There are a couple of useless variables to get rid of. */ |
26 | #include "Lossless_UDP.h" | 26 | #include "Lossless_UDP.h" |
27 | 27 | ||
28 | |||
29 | |||
30 | /* maximum data packets in sent and receive queues. */ | 28 | /* maximum data packets in sent and receive queues. */ |
31 | #define MAX_QUEUE_NUM 16 | 29 | #define MAX_QUEUE_NUM 16 |
32 | 30 | ||
@@ -88,7 +86,6 @@ typedef struct | |||
88 | uint8_t timeout; /* connection timeout in seconds. */ | 86 | uint8_t timeout; /* connection timeout in seconds. */ |
89 | }Connection; | 87 | }Connection; |
90 | 88 | ||
91 | |||
92 | #define MAX_CONNECTIONS 256 | 89 | #define MAX_CONNECTIONS 256 |
93 | 90 | ||
94 | static Connection connections[MAX_CONNECTIONS]; | 91 | static Connection connections[MAX_CONNECTIONS]; |
@@ -117,7 +114,6 @@ int getconnection_id(IP_Port ip_port) | |||
117 | /* table of random numbers used below. */ | 114 | /* table of random numbers used below. */ |
118 | static uint32_t randtable[6][256]; | 115 | static uint32_t randtable[6][256]; |
119 | 116 | ||
120 | |||
121 | /* generate a handshake_id which depends on the ip_port. | 117 | /* generate a handshake_id which depends on the ip_port. |
122 | this function will always give one unique handshake_id per ip_port. | 118 | this function will always give one unique handshake_id per ip_port. |
123 | TODO: make this better */ | 119 | TODO: make this better */ |
@@ -138,6 +134,7 @@ uint32_t handshake_id(IP_Port source) | |||
138 | } | 134 | } |
139 | return id; | 135 | return id; |
140 | } | 136 | } |
137 | |||
141 | /* change the hnshake id associated with that ip_port | 138 | /* change the hnshake id associated with that ip_port |
142 | TODO: make this better */ | 139 | TODO: make this better */ |
143 | void change_handshake(IP_Port source) | 140 | void change_handshake(IP_Port source) |
@@ -146,7 +143,6 @@ void change_handshake(IP_Port source) | |||
146 | randtable[rand][((uint8_t *)&source)[rand]] = random_int(); | 143 | randtable[rand][((uint8_t *)&source)[rand]] = random_int(); |
147 | } | 144 | } |
148 | 145 | ||
149 | |||
150 | /* initialize a new connection to ip_port | 146 | /* initialize a new connection to ip_port |
151 | returns an integer corresponding to the connection id. | 147 | returns an integer corresponding to the connection id. |
152 | return -1 if it could not initialize the connection. | 148 | return -1 if it could not initialize the connection. |
@@ -314,6 +310,7 @@ char id_packet(int connection_id) | |||
314 | } | 310 | } |
315 | return -1; | 311 | return -1; |
316 | } | 312 | } |
313 | |||
317 | /* return 0 if there is no received data in the buffer. | 314 | /* return 0 if there is no received data in the buffer. |
318 | return length of received packet if successful */ | 315 | return length of received packet if successful */ |
319 | int read_packet(int connection_id, uint8_t * data) | 316 | int read_packet(int connection_id, uint8_t * data) |
@@ -353,9 +350,6 @@ int write_packet(int connection_id, uint8_t * data, uint32_t length) | |||
353 | return 0; | 350 | return 0; |
354 | } | 351 | } |
355 | 352 | ||
356 | |||
357 | |||
358 | |||
359 | /* put the packet numbers the we are missing in requested and return the number */ | 353 | /* put the packet numbers the we are missing in requested and return the number */ |
360 | uint32_t missing_packets(int connection_id, uint32_t * requested) | 354 | uint32_t missing_packets(int connection_id, uint32_t * requested) |
361 | { | 355 | { |
@@ -386,8 +380,6 @@ uint32_t missing_packets(int connection_id, uint32_t * requested) | |||
386 | /* Packet sending functions | 380 | /* Packet sending functions |
387 | One per packet type. | 381 | One per packet type. |
388 | see docs/Lossless_UDP.txt for more information. */ | 382 | see docs/Lossless_UDP.txt for more information. */ |
389 | |||
390 | |||
391 | int send_handshake(IP_Port ip_port, uint32_t handshake_id1, uint32_t handshake_id2) | 383 | int send_handshake(IP_Port ip_port, uint32_t handshake_id1, uint32_t handshake_id2) |
392 | { | 384 | { |
393 | uint8_t packet[1 + 4 + 4]; | 385 | uint8_t packet[1 + 4 + 4]; |
@@ -402,7 +394,6 @@ int send_handshake(IP_Port ip_port, uint32_t handshake_id1, uint32_t handshake_i | |||
402 | 394 | ||
403 | } | 395 | } |
404 | 396 | ||
405 | |||
406 | int send_SYNC(uint32_t connection_id) | 397 | int send_SYNC(uint32_t connection_id) |
407 | { | 398 | { |
408 | 399 | ||
@@ -468,8 +459,6 @@ int send_DATA(uint32_t connection_id) | |||
468 | 459 | ||
469 | /* END of packet sending functions */ | 460 | /* END of packet sending functions */ |
470 | 461 | ||
471 | |||
472 | |||
473 | /* Packet handling functions | 462 | /* Packet handling functions |
474 | One to handle each type of packets we receive | 463 | One to handle each type of packets we receive |
475 | return 0 if handled correctly, 1 if packet is bad. */ | 464 | return 0 if handled correctly, 1 if packet is bad. */ |
@@ -700,7 +689,6 @@ int handle_data(uint8_t * packet, uint32_t length, IP_Port source) | |||
700 | 689 | ||
701 | /* END of packet handling functions */ | 690 | /* END of packet handling functions */ |
702 | 691 | ||
703 | |||
704 | int LosslessUDP_handlepacket(uint8_t * packet, uint32_t length, IP_Port source) | 692 | int LosslessUDP_handlepacket(uint8_t * packet, uint32_t length, IP_Port source) |
705 | { | 693 | { |
706 | 694 | ||
@@ -828,6 +816,7 @@ void adjustRates() | |||
828 | } | 816 | } |
829 | } | 817 | } |
830 | } | 818 | } |
819 | |||
831 | /* Call this function a couple times per second | 820 | /* Call this function a couple times per second |
832 | It's the main loop. */ | 821 | It's the main loop. */ |
833 | void doLossless_UDP() | 822 | void doLossless_UDP() |