From 307e4d2e3edba4c1c297199a9785efcf628d7ee9 Mon Sep 17 00:00:00 2001 From: rlt3 Date: Thu, 1 Aug 2013 15:58:19 -0400 Subject: Trying to make Lossless UDP more readable with style changes --- core/Lossless_UDP.h | 96 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 58 insertions(+), 38 deletions(-) (limited to 'core/Lossless_UDP.h') 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" { /* maximum length of the data in the data packets */ #define MAX_DATA_SIZE 1024 -/* Functions */ - -/* initialize a new connection to ip_port - returns an integer corresponding to the connection id. - return -1 if it could not initialize the connection. - if there already was an existing connection to that ip_port return its number. */ +/* + * Initialize a new connection to ip_port + * Returns an integer corresponding to the connection id. + * Return -1 if it could not initialize the connection. + * Return number if there already was an existing connection to that ip_port. + */ int new_connection(IP_Port ip_port); -/* get connection id from IP_Port - return -1 if there are no connections like we are looking for - return id if it found it */ +/* + * Get connection id from IP_Port. + * Return -1 if there are no connections like we are looking for. + * Return id if it found it . + */ int getconnection_id(IP_Port ip_port); -/* returns an integer corresponding to the next connection in our imcoming connection list - return -1 if there are no new incoming connections in the list. */ +/* + * Returns an int corresponding to the next connection in our imcoming connection list + * Return -1 if there are no new incoming connections in the list. + */ int incoming_connection(); -/* return -1 if it could not kill the connection. - return 0 if killed successfully */ +/* + * Return -1 if it could not kill the connection. + * Return 0 if killed successfully + */ int kill_connection(int connection_id); -/* kill connection in seconds seconds. - return -1 if it can not kill the connection. - return 0 if it will kill it */ +/* + * Kill connection in seconds seconds. + * Return -1 if it can not kill the connection. + * Return 0 if it will kill it + */ int kill_connection_in(int connection_id, uint32_t seconds); -/* returns the ip_port of the corresponding connection. - return 0 if there is no such connection. */ +/* + * Returns the ip_port of the corresponding connection. + * Return 0 if there is no such connection. + */ IP_Port connection_ip(int connection_id); -/* returns the id of the next packet in the queue - return -1 if no packet in queue */ +/* + * Returns the id of the next packet in the queue + * Return -1 if no packet in queue + */ char id_packet(int connection_id); -/* return 0 if there is no received data in the buffer. - return length of received packet if successful */ +/* + * Return 0 if there is no received data in the buffer. + * Return length of received packet if successful + */ int read_packet(int connection_id, uint8_t *data); -/* return 0 if data could not be put in packet queue - return 1 if data was put into the queue */ +/* + * Return 0 if data could not be put in packet queue + * Return 1 if data was put into the queue + */ int write_packet(int connection_id, uint8_t *data, uint32_t length); -/* returns the number of packets in the queue waiting to be successfully sent. */ +/* Returns the number of packets in the queue waiting to be successfully sent. */ uint32_t sendqueue(int connection_id); -/* returns the number of packets in the queue waiting to be successfully read with read_packet(...) */ +/* + * returns the number of packets in the queue waiting to be successfully + * read with read_packet(...) + */ uint32_t recvqueue(int connection_id); -/* check if connection is connected - return 0 no. - return 1 if attempting handshake - return 2 if handshake is done - return 3 if fully connected - return 4 if timed out and wating to be killed */ +/* Check if connection is connected: + * Return 0 no. + * Return 1 if attempting handshake. + * Return 2 if handshake is done. + * Return 3 if fully connected. + * Return 4 if timed out and wating to be killed. + */ int is_connected(int connection_id); -/* Call this function a couple times per second - It's the main loop. */ +/* Call this function a couple times per second It's the main loop. */ void doLossless_UDP(); - -/* if we receive a Lossless_UDP packet we call this function so it can be handled. - return 0 if packet is handled correctly. - return 1 if it didn't handle the packet or if the packet was shit. */ +/* + * If we receive a Lossless_UDP packet, call this function so it can be handled. + * Return 0 if packet is handled correctly. + * Return 1 if it didn't handle the packet or if the packet was shit. + */ int LosslessUDP_handlepacket(uint8_t *packet, uint32_t length, IP_Port source); #ifdef __cplusplus -- cgit v1.2.3