diff options
author | rlt3 <leroy@bythehilt.com> | 2013-08-01 15:58:19 -0400 |
---|---|---|
committer | rlt3 <leroy@bythehilt.com> | 2013-08-01 15:58:19 -0400 |
commit | 307e4d2e3edba4c1c297199a9785efcf628d7ee9 (patch) | |
tree | c9f9c3256588a2d02119715020a173a1c2e6d53a /core/Lossless_UDP.h | |
parent | 75daa1aec9c908205ebc8e085b4c5cdb048b6017 (diff) |
Trying to make Lossless UDP more readable with style changes
Diffstat (limited to 'core/Lossless_UDP.h')
-rw-r--r-- | core/Lossless_UDP.h | 96 |
1 files changed, 58 insertions, 38 deletions
diff --git a/core/Lossless_UDP.h b/core/Lossless_UDP.h index 033bc480..573e1ab9 100644 --- a/core/Lossless_UDP.h +++ b/core/Lossless_UDP.h | |||
@@ -33,70 +33,90 @@ extern "C" { | |||
33 | /* maximum length of the data in the data packets */ | 33 | /* maximum length of the data in the data packets */ |
34 | #define MAX_DATA_SIZE 1024 | 34 | #define MAX_DATA_SIZE 1024 |
35 | 35 | ||
36 | /* Functions */ | 36 | /* |
37 | 37 | * Initialize a new connection to ip_port | |
38 | /* initialize a new connection to ip_port | 38 | * Returns an integer corresponding to the connection id. |
39 | returns an integer corresponding to the connection id. | 39 | * Return -1 if it could not initialize the connection. |
40 | return -1 if it could not initialize the connection. | 40 | * Return number if there already was an existing connection to that ip_port. |
41 | if there already was an existing connection to that ip_port return its number. */ | 41 | */ |
42 | int new_connection(IP_Port ip_port); | 42 | int new_connection(IP_Port ip_port); |
43 | 43 | ||
44 | /* get connection id from IP_Port | 44 | /* |
45 | return -1 if there are no connections like we are looking for | 45 | * Get connection id from IP_Port. |
46 | return id if it found it */ | 46 | * Return -1 if there are no connections like we are looking for. |
47 | * Return id if it found it . | ||
48 | */ | ||
47 | int getconnection_id(IP_Port ip_port); | 49 | int getconnection_id(IP_Port ip_port); |
48 | 50 | ||
49 | /* returns an integer corresponding to the next connection in our imcoming connection list | 51 | /* |
50 | return -1 if there are no new incoming connections in the list. */ | 52 | * Returns an int corresponding to the next connection in our imcoming connection list |
53 | * Return -1 if there are no new incoming connections in the list. | ||
54 | */ | ||
51 | int incoming_connection(); | 55 | int incoming_connection(); |
52 | 56 | ||
53 | /* return -1 if it could not kill the connection. | 57 | /* |
54 | return 0 if killed successfully */ | 58 | * Return -1 if it could not kill the connection. |
59 | * Return 0 if killed successfully | ||
60 | */ | ||
55 | int kill_connection(int connection_id); | 61 | int kill_connection(int connection_id); |
56 | 62 | ||
57 | /* kill connection in seconds seconds. | 63 | /* |
58 | return -1 if it can not kill the connection. | 64 | * Kill connection in seconds seconds. |
59 | return 0 if it will kill it */ | 65 | * Return -1 if it can not kill the connection. |
66 | * Return 0 if it will kill it | ||
67 | */ | ||
60 | int kill_connection_in(int connection_id, uint32_t seconds); | 68 | int kill_connection_in(int connection_id, uint32_t seconds); |
61 | 69 | ||
62 | /* returns the ip_port of the corresponding connection. | 70 | /* |
63 | return 0 if there is no such connection. */ | 71 | * Returns the ip_port of the corresponding connection. |
72 | * Return 0 if there is no such connection. | ||
73 | */ | ||
64 | IP_Port connection_ip(int connection_id); | 74 | IP_Port connection_ip(int connection_id); |
65 | 75 | ||
66 | /* returns the id of the next packet in the queue | 76 | /* |
67 | return -1 if no packet in queue */ | 77 | * Returns the id of the next packet in the queue |
78 | * Return -1 if no packet in queue | ||
79 | */ | ||
68 | char id_packet(int connection_id); | 80 | char id_packet(int connection_id); |
69 | 81 | ||
70 | /* return 0 if there is no received data in the buffer. | 82 | /* |
71 | return length of received packet if successful */ | 83 | * Return 0 if there is no received data in the buffer. |
84 | * Return length of received packet if successful | ||
85 | */ | ||
72 | int read_packet(int connection_id, uint8_t *data); | 86 | int read_packet(int connection_id, uint8_t *data); |
73 | 87 | ||
74 | /* return 0 if data could not be put in packet queue | 88 | /* |
75 | return 1 if data was put into the queue */ | 89 | * Return 0 if data could not be put in packet queue |
90 | * Return 1 if data was put into the queue | ||
91 | */ | ||
76 | int write_packet(int connection_id, uint8_t *data, uint32_t length); | 92 | int write_packet(int connection_id, uint8_t *data, uint32_t length); |
77 | 93 | ||
78 | /* returns the number of packets in the queue waiting to be successfully sent. */ | 94 | /* Returns the number of packets in the queue waiting to be successfully sent. */ |
79 | uint32_t sendqueue(int connection_id); | 95 | uint32_t sendqueue(int connection_id); |
80 | 96 | ||
81 | /* returns the number of packets in the queue waiting to be successfully read with read_packet(...) */ | 97 | /* |
98 | * returns the number of packets in the queue waiting to be successfully | ||
99 | * read with read_packet(...) | ||
100 | */ | ||
82 | uint32_t recvqueue(int connection_id); | 101 | uint32_t recvqueue(int connection_id); |
83 | 102 | ||
84 | /* check if connection is connected | 103 | /* Check if connection is connected: |
85 | return 0 no. | 104 | * Return 0 no. |
86 | return 1 if attempting handshake | 105 | * Return 1 if attempting handshake. |
87 | return 2 if handshake is done | 106 | * Return 2 if handshake is done. |
88 | return 3 if fully connected | 107 | * Return 3 if fully connected. |
89 | return 4 if timed out and wating to be killed */ | 108 | * Return 4 if timed out and wating to be killed. |
109 | */ | ||
90 | int is_connected(int connection_id); | 110 | int is_connected(int connection_id); |
91 | 111 | ||
92 | /* Call this function a couple times per second | 112 | /* Call this function a couple times per second It's the main loop. */ |
93 | It's the main loop. */ | ||
94 | void doLossless_UDP(); | 113 | void doLossless_UDP(); |
95 | 114 | ||
96 | 115 | /* | |
97 | /* if we receive a Lossless_UDP packet we call this function so it can be handled. | 116 | * If we receive a Lossless_UDP packet, call this function so it can be handled. |
98 | return 0 if packet is handled correctly. | 117 | * Return 0 if packet is handled correctly. |
99 | return 1 if it didn't handle the packet or if the packet was shit. */ | 118 | * Return 1 if it didn't handle the packet or if the packet was shit. |
119 | */ | ||
100 | int LosslessUDP_handlepacket(uint8_t *packet, uint32_t length, IP_Port source); | 120 | int LosslessUDP_handlepacket(uint8_t *packet, uint32_t length, IP_Port source); |
101 | 121 | ||
102 | #ifdef __cplusplus | 122 | #ifdef __cplusplus |