From 7b944e9c656f5bc9e0165db666db0a89963247c8 Mon Sep 17 00:00:00 2001 From: JamoBox Date: Mon, 2 Sep 2013 17:12:02 +0100 Subject: comment updates --- toxcore/net_crypto.c | 65 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 28 deletions(-) (limited to 'toxcore/net_crypto.c') diff --git a/toxcore/net_crypto.c b/toxcore/net_crypto.c index 87c98089..739003a4 100644 --- a/toxcore/net_crypto.c +++ b/toxcore/net_crypto.c @@ -144,9 +144,9 @@ void random_nonce(uint8_t *nonce) } } -/* return 0 if there is no received data in the buffer. - * return -1 if the packet was discarded. - * return length of received data if successful. +/* return 0 if there is no received data in the buffer. + * return -1 if the packet was discarded. + * return length of received data if successful. */ int read_cryptpacket(Net_Crypto *c, int crypt_connection_id, uint8_t *data) { @@ -177,8 +177,8 @@ int read_cryptpacket(Net_Crypto *c, int crypt_connection_id, uint8_t *data) return -1; } -/* 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_cryptpacket(Net_Crypto *c, int crypt_connection_id, uint8_t *data, uint32_t length) { @@ -215,8 +215,8 @@ int write_cryptpacket(Net_Crypto *c, int crypt_connection_id, uint8_t *data, uin * Data represents the data we send with the request with length being the length of the data. * request_id is the id of the request (32 = friend request, 254 = ping request). * - * returns -1 on failure. - * returns the length of the created packet on success. + * return -1 on failure. + * return the length of the created packet on success. */ int create_request(uint8_t *send_public_key, uint8_t *send_secret_key, uint8_t *packet, uint8_t *recv_public_key, uint8_t *data, uint32_t length, uint8_t request_id) @@ -246,7 +246,8 @@ int create_request(uint8_t *send_public_key, uint8_t *send_secret_key, uint8_t * /* Puts the senders public key in the request in public_key, the data from the request * in data if a friend or ping request was sent to us and returns the length of the data. * packet is the request packet and length is its length. - * return -1 if not valid request. + * + * return -1 if not valid request. */ static int handle_request(Net_Crypto *c, uint8_t *public_key, uint8_t *data, uint8_t *request_id, uint8_t *packet, uint16_t length) @@ -341,8 +342,9 @@ static int send_cryptohandshake(Net_Crypto *c, int connection_id, uint8_t *publi } /* Extract secret nonce, session public key and public_key from a packet(data) with length length. - * return 1 if successful. - * return 0 if failure. + * + * return 1 if successful. + * return 0 if failure. */ static int handle_cryptohandshake(Net_Crypto *c, uint8_t *public_key, uint8_t *secret_nonce, uint8_t *session_key, uint8_t *data, uint16_t length) @@ -374,8 +376,9 @@ static int handle_cryptohandshake(Net_Crypto *c, uint8_t *public_key, uint8_t *s } /* Get crypto connection id from public key of peer. - * return -1 if there are no connections like we are looking for. - * return id if it found it. + * + * return -1 if there are no connections like we are looking for. + * return id if it found it. */ static int getcryptconnection_id(Net_Crypto *c, uint8_t *public_key) { @@ -391,7 +394,8 @@ static int getcryptconnection_id(Net_Crypto *c, uint8_t *public_key) } /* Set the size of the friend list to numfriends. - * return -1 if realloc fails. + * + * return -1 if realloc fails. */ int realloc_cryptoconnection(Net_Crypto *c, uint32_t num) { @@ -411,8 +415,9 @@ int realloc_cryptoconnection(Net_Crypto *c, uint32_t num) } /* Start a secure connection with other peer who has public_key and ip_port. - * returns -1 if failure. - * returns crypt_connection_id of the initialized connection if everything went well. + * + * return -1 if failure. + * return crypt_connection_id of the initialized connection if everything went well. */ int crypto_connect(Net_Crypto *c, uint8_t *public_key, IP_Port ip_port) { @@ -462,8 +467,9 @@ int crypto_connect(Net_Crypto *c, uint8_t *public_key, IP_Port ip_port) } /* Handle an incoming connection. - * return -1 if no crypto inbound connection. - * return incoming connection id (Lossless_UDP one) if there is an incoming crypto connection. + * + * return -1 if no crypto inbound connection. + * return incoming connection id (Lossless_UDP one) if there is an incoming crypto connection. * * Put the public key of the peer in public_key, the secret_nonce from the handshake into secret_nonce * and the session public key for the connection in session_key. @@ -500,8 +506,9 @@ int crypto_inbound(Net_Crypto *c, uint8_t *public_key, uint8_t *secret_nonce, ui } /* Kill a crypto connection. - * return 0 if killed successfully. - * return 1 if there was a problem. + * + * return 0 if killed successfully. + * return 1 if there was a problem. */ int crypto_kill(Net_Crypto *c, int crypt_connection_id) { @@ -529,8 +536,9 @@ int crypto_kill(Net_Crypto *c, int crypt_connection_id) } /* Accept an incoming connection using the parameters provided by crypto_inbound. - * return -1 if not successful. - * returns the crypt_connection_id if successful. + * + * return -1 if not successful. + * return the crypt_connection_id if successful. */ int accept_crypto_inbound(Net_Crypto *c, int connection_id, uint8_t *public_key, uint8_t *secret_nonce, uint8_t *session_key) @@ -588,11 +596,11 @@ int accept_crypto_inbound(Net_Crypto *c, int connection_id, uint8_t *public_key, return -1; } -/* return 0 if no connection. - * return 1 we have sent a handshake. - * return 2 if connection is not confirmed yet (we have received a handshake but no empty data packet). - * return 3 if the connection is established. - * return 4 if the connection is timed out and waiting to be killed. +/* return 0 if no connection. + * return 1 we have sent a handshake. + * return 2 if connection is not confirmed yet (we have received a handshake but no empty data packet). + * return 3 if the connection is established. + * return 4 if the connection is timed out and waiting to be killed. */ int is_cryptoconnected(Net_Crypto *c, int crypt_connection_id) { @@ -626,9 +634,10 @@ void load_keys(Net_Crypto *c, uint8_t *keys) } /* Adds an incoming connection to the incoming_connection list. - * returns 0 if successful - * returns 1 if failure. * TODO: Optimize this. + * + * returns 0 if successful + * returns 1 if failure. */ static int new_incoming(Net_Crypto *c, int id) { -- cgit v1.2.3