summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--toxav/audio.c8
-rw-r--r--toxav/msi.c2
-rw-r--r--toxav/msi.h2
-rw-r--r--toxav/rtp.c2
-rw-r--r--toxav/rtp.h2
-rw-r--r--toxav/toxav_old.c18
-rw-r--r--toxav/video.c17
-rw-r--r--toxcore/DHT.c4
-rw-r--r--toxcore/DHT.h2
-rw-r--r--toxcore/LAN_discovery.c22
-rw-r--r--toxcore/Messenger.c23
-rw-r--r--toxcore/Messenger.h51
-rw-r--r--toxcore/crypto_core.c2
-rw-r--r--toxcore/friend_requests.h2
-rw-r--r--toxcore/group.c22
-rw-r--r--toxcore/group.h22
-rw-r--r--toxcore/net_crypto.c12
-rw-r--r--toxcore/net_crypto.h6
-rw-r--r--toxcore/network.c14
-rw-r--r--toxcore/network.h14
-rw-r--r--toxcore/onion.c2
-rw-r--r--toxcore/onion.h2
-rw-r--r--toxcore/onion_client.c2
23 files changed, 109 insertions, 144 deletions
diff --git a/toxav/audio.c b/toxav/audio.c
index d4618aaf..b936f7a4 100644
--- a/toxav/audio.c
+++ b/toxav/audio.c
@@ -378,7 +378,7 @@ OpusEncoder *create_audio_encoder(const Logger *log, int32_t bit_rate, int32_t s
378 * controlling the rate by adjusting the output buffer size. 378 * controlling the rate by adjusting the output buffer size.
379 * 379 *
380 * Parameters: 380 * Parameters:
381 * [in] x opus_int32: bitrate in bits per second. 381 * `[in]` `x` `opus_int32`: bitrate in bits per second.
382 */ 382 */
383 status = opus_encoder_ctl(rc, OPUS_SET_BITRATE(bit_rate)); 383 status = opus_encoder_ctl(rc, OPUS_SET_BITRATE(bit_rate));
384 384
@@ -393,7 +393,7 @@ OpusEncoder *create_audio_encoder(const Logger *log, int32_t bit_rate, int32_t s
393 * Note: 393 * Note:
394 * This is only applicable to the LPC layer 394 * This is only applicable to the LPC layer
395 * Parameters: 395 * Parameters:
396 * [in] x int: FEC flag, 0 (disabled) is default 396 * `[in]` `x` `int`: FEC flag, 0 (disabled) is default
397 */ 397 */
398 /* Enable in-band forward error correction in codec */ 398 /* Enable in-band forward error correction in codec */
399 status = opus_encoder_ctl(rc, OPUS_SET_INBAND_FEC(1)); 399 status = opus_encoder_ctl(rc, OPUS_SET_INBAND_FEC(1));
@@ -410,7 +410,7 @@ OpusEncoder *create_audio_encoder(const Logger *log, int32_t bit_rate, int32_t s
410 * the encoder at the expense of quality at a given bitrate in the lossless case, 410 * the encoder at the expense of quality at a given bitrate in the lossless case,
411 * but greater quality under loss. 411 * but greater quality under loss.
412 * Parameters: 412 * Parameters:
413 * [in] x int: Loss percentage in the range 0-100, inclusive. 413 * `[in]` `x` `int`: Loss percentage in the range 0-100, inclusive.
414 */ 414 */
415 /* Make codec resistant to up to 10% packet loss 415 /* Make codec resistant to up to 10% packet loss
416 * NOTE This could also be adjusted on the fly, rather than hard-coded, 416 * NOTE This could also be adjusted on the fly, rather than hard-coded,
@@ -431,7 +431,7 @@ OpusEncoder *create_audio_encoder(const Logger *log, int32_t bit_rate, int32_t s
431 * The default value is 10. 431 * The default value is 10.
432 * 432 *
433 * Parameters: 433 * Parameters:
434 * [in] x int: 0-10, inclusive 434 * `[in]` `x` `int`: 0-10, inclusive
435 */ 435 */
436 /* Set algorithm to the highest complexity, maximizing compression */ 436 /* Set algorithm to the highest complexity, maximizing compression */
437 status = opus_encoder_ctl(rc, OPUS_SET_COMPLEXITY(AUDIO_OPUS_COMPLEXITY)); 437 status = opus_encoder_ctl(rc, OPUS_SET_COMPLEXITY(AUDIO_OPUS_COMPLEXITY));
diff --git a/toxav/msi.c b/toxav/msi.c
index 84a18f36..69046079 100644
--- a/toxav/msi.c
+++ b/toxav/msi.c
@@ -21,7 +21,7 @@
21/** 21/**
22 * Protocol: 22 * Protocol:
23 * 23 *
24 * |id [1 byte]| |size [1 byte]| |data [$size bytes]| |...{repeat}| |0 {end byte}| 24 * `|id [1 byte]| |size [1 byte]| |data [$size bytes]| |...{repeat}| |0 {end byte}|`
25 */ 25 */
26 26
27typedef enum MSIHeaderID { 27typedef enum MSIHeaderID {
diff --git a/toxav/msi.h b/toxav/msi.h
index e50171e5..5809228d 100644
--- a/toxav/msi.h
+++ b/toxav/msi.h
@@ -121,7 +121,7 @@ void msi_register_callback(MSISession *session, msi_action_cb *callback, MSICall
121 */ 121 */
122int msi_invite(MSISession *session, MSICall **call, uint32_t friend_number, uint8_t capabilities); 122int msi_invite(MSISession *session, MSICall **call, uint32_t friend_number, uint8_t capabilities);
123/** 123/**
124 * Hangup call. NOTE: 'call' will be freed 124 * Hangup call. NOTE: `call` will be freed
125 */ 125 */
126int msi_hangup(MSICall *call); 126int msi_hangup(MSICall *call);
127/** 127/**
diff --git a/toxav/rtp.c b/toxav/rtp.c
index 35898b68..aed9523b 100644
--- a/toxav/rtp.c
+++ b/toxav/rtp.c
@@ -319,9 +319,11 @@ static void update_bwc_values(const Logger *log, RTPSession *session, const stru
319 * find out and handle it appropriately. 319 * find out and handle it appropriately.
320 * 320 *
321 * @param session The current RTP session with: 321 * @param session The current RTP session with:
322 * <code>
322 * session->mcb == vc_queue_message() // this function is called from here 323 * session->mcb == vc_queue_message() // this function is called from here
323 * session->mp == struct RTPMessage * 324 * session->mp == struct RTPMessage *
324 * session->cs == call->video.second // == VCSession created by vc_new() call 325 * session->cs == call->video.second // == VCSession created by vc_new() call
326 * </code>
325 * @param header The RTP header deserialised from the packet. 327 * @param header The RTP header deserialised from the packet.
326 * @param incoming_data The packet data *not* header, i.e. this is the actual 328 * @param incoming_data The packet data *not* header, i.e. this is the actual
327 * payload. 329 * payload.
diff --git a/toxav/rtp.h b/toxav/rtp.h
index b6217d95..46cd6b86 100644
--- a/toxav/rtp.h
+++ b/toxav/rtp.h
@@ -122,7 +122,7 @@ struct RTPMessage {
122struct RTPWorkBuffer { 122struct RTPWorkBuffer {
123 /** 123 /**
124 * Whether this slot contains a key frame. This is true iff 124 * Whether this slot contains a key frame. This is true iff
125 * buf->header.flags & RTP_KEY_FRAME. 125 * `buf->header.flags & RTP_KEY_FRAME`.
126 */ 126 */
127 bool is_keyframe; 127 bool is_keyframe;
128 /** 128 /**
diff --git a/toxav/toxav_old.c b/toxav/toxav_old.c
index 9ecc7969..e5cfbadc 100644
--- a/toxav/toxav_old.c
+++ b/toxav/toxav_old.c
@@ -17,9 +17,9 @@
17 * return -1 on failure. 17 * return -1 on failure.
18 * 18 *
19 * Audio data callback format: 19 * Audio data callback format:
20 * audio_callback(Tox *tox, int groupnumber, int peernumber, const int16_t *pcm, unsigned int samples, uint8_t channels, unsigned int sample_rate, void *userdata) 20 * `audio_callback(Tox *tox, int groupnumber, int peernumber, const int16_t *pcm, unsigned int samples, uint8_t channels, unsigned int sample_rate, void *userdata)`
21 * 21 *
22 * Note that total size of pcm in bytes is equal to (samples * channels * sizeof(int16_t)). 22 * Note that total size of pcm in bytes is equal to `(samples * channels * sizeof(int16_t))`.
23 */ 23 */
24int toxav_add_av_groupchat(Tox *tox, audio_data_cb *audio_callback, void *userdata) 24int toxav_add_av_groupchat(Tox *tox, audio_data_cb *audio_callback, void *userdata)
25{ 25{
@@ -33,10 +33,10 @@ int toxav_add_av_groupchat(Tox *tox, audio_data_cb *audio_callback, void *userda
33 * returns group number on success 33 * returns group number on success
34 * returns -1 on failure. 34 * returns -1 on failure.
35 * 35 *
36 * Audio data callback format (same as the one for toxav_add_av_groupchat()): 36 * Audio data callback format (same as the one for `toxav_add_av_groupchat()`):
37 * audio_callback(Tox *tox, int groupnumber, int peernumber, const int16_t *pcm, unsigned int samples, uint8_t channels, unsigned int sample_rate, void *userdata) 37 * `audio_callback(Tox *tox, int groupnumber, int peernumber, const int16_t *pcm, unsigned int samples, uint8_t channels, unsigned int sample_rate, void *userdata)`
38 * 38 *
39 * Note that total size of pcm in bytes is equal to (samples * channels * sizeof(int16_t)). 39 * Note that total size of pcm in bytes is equal to `(samples * channels * sizeof(int16_t))`.
40 */ 40 */
41int toxav_join_av_groupchat(Tox *tox, uint32_t friendnumber, const uint8_t *data, uint16_t length, 41int toxav_join_av_groupchat(Tox *tox, uint32_t friendnumber, const uint8_t *data, uint16_t length,
42 audio_data_cb *audio_callback, void *userdata) 42 audio_data_cb *audio_callback, void *userdata)
@@ -51,9 +51,9 @@ int toxav_join_av_groupchat(Tox *tox, uint32_t friendnumber, const uint8_t *data
51 * return 0 on success. 51 * return 0 on success.
52 * return -1 on failure. 52 * return -1 on failure.
53 * 53 *
54 * Note that total size of pcm in bytes is equal to (samples * channels * sizeof(int16_t)). 54 * Note that total size of pcm in bytes is equal to `(samples * channels * sizeof(int16_t))`.
55 * 55 *
56 * Valid number of samples are ((sample rate) * (audio length (Valid ones are: 2.5, 5, 10, 20, 40 or 60 ms)) / 1000) 56 * Valid number of samples are `((sample rate) * (audio length) / 1000)` (Valid values for audio length: 2.5, 5, 10, 20, 40 or 60 ms)
57 * Valid number of channels are 1 or 2. 57 * Valid number of channels are 1 or 2.
58 * Valid sample rates are 8000, 12000, 16000, 24000, or 48000. 58 * Valid sample rates are 8000, 12000, 16000, 24000, or 48000.
59 * 59 *
@@ -81,9 +81,9 @@ int toxav_group_send_audio(Tox *tox, uint32_t groupnumber, const int16_t *pcm, u
81 * return -1 on failure. 81 * return -1 on failure.
82 * 82 *
83 * Audio data callback format (same as the one for toxav_add_av_groupchat()): 83 * Audio data callback format (same as the one for toxav_add_av_groupchat()):
84 * audio_callback(Tox *tox, uint32_t groupnumber, uint32_t peernumber, const int16_t *pcm, unsigned int samples, uint8_t channels, uint32_t sample_rate, void *userdata) 84 * `audio_callback(Tox *tox, uint32_t groupnumber, uint32_t peernumber, const int16_t *pcm, unsigned int samples, uint8_t channels, uint32_t sample_rate, void *userdata)`
85 * 85 *
86 * Note that total size of pcm in bytes is equal to (samples * channels * sizeof(int16_t)). 86 * Note that total size of pcm in bytes is equal to `(samples * channels * sizeof(int16_t))`.
87 */ 87 */
88int toxav_groupchat_enable_av(Tox *tox, uint32_t groupnumber, audio_data_cb *audio_callback, void *userdata) 88int toxav_groupchat_enable_av(Tox *tox, uint32_t groupnumber, audio_data_cb *audio_callback, void *userdata)
89{ 89{
diff --git a/toxav/video.c b/toxav/video.c
index c6206bbf..7855f142 100644
--- a/toxav/video.c
+++ b/toxav/video.c
@@ -241,15 +241,16 @@ VCSession *vc_new(Mono_Time *mono_time, const Logger *log, ToxAV *av, uint32_t f
241 control function to set noise sensitivity 241 control function to set noise sensitivity
242 0: off, 1: OnYOnly, 2: OnYUV, 3: OnYUVAggressive, 4: Adaptive 242 0: off, 1: OnYOnly, 2: OnYUV, 3: OnYUVAggressive, 4: Adaptive
243 */ 243 */
244 /* 244#if 0
245 rc = vpx_codec_control(vc->encoder, VP8E_SET_NOISE_SENSITIVITY, 2); 245 rc = vpx_codec_control(vc->encoder, VP8E_SET_NOISE_SENSITIVITY, 2);
246 246
247 if (rc != VPX_CODEC_OK) { 247 if (rc != VPX_CODEC_OK) {
248 LOGGER_ERROR(log, "Failed to set encoder control setting: %s", vpx_codec_err_to_string(rc)); 248 LOGGER_ERROR(log, "Failed to set encoder control setting: %s", vpx_codec_err_to_string(rc));
249 vpx_codec_destroy(vc->encoder); 249 vpx_codec_destroy(vc->encoder);
250 goto BASE_CLEANUP_1; 250 goto BASE_CLEANUP_1;
251 } 251 }
252 */ 252
253#endif
253 vc->linfts = current_time_monotonic(mono_time); 254 vc->linfts = current_time_monotonic(mono_time);
254 vc->lcfd = 60; 255 vc->lcfd = 60;
255 vc->vcb = cb; 256 vc->vcb = cb;
diff --git a/toxcore/DHT.c b/toxcore/DHT.c
index 55116bc0..fb2e125d 100644
--- a/toxcore/DHT.c
+++ b/toxcore/DHT.c
@@ -610,7 +610,7 @@ int unpack_nodes(Node_format *nodes, uint16_t max_num_nodes, uint16_t *processed
610 return num; 610 return num;
611} 611}
612 612
613/* Find index of ##type with public_key equal to pk. 613/* Find index in an array with public_key equal to pk.
614 * 614 *
615 * return index or UINT32_MAX if not found. 615 * return index or UINT32_MAX if not found.
616 */ 616 */
@@ -1112,7 +1112,7 @@ static bool is_pk_in_close_list(DHT *dht, const uint8_t *public_key, IP_Port ip_
1112} 1112}
1113 1113
1114/* Check if the node obtained with a get_nodes with public_key should be pinged. 1114/* Check if the node obtained with a get_nodes with public_key should be pinged.
1115 * NOTE: for best results call it after addto_lists; 1115 * NOTE: for best results call it after addto_lists.
1116 * 1116 *
1117 * return false if the node should not be pinged. 1117 * return false if the node should not be pinged.
1118 * return true if it should. 1118 * return true if it should.
diff --git a/toxcore/DHT.h b/toxcore/DHT.h
index 06a7e012..13f7ce20 100644
--- a/toxcore/DHT.h
+++ b/toxcore/DHT.h
@@ -271,8 +271,6 @@ int dht_delfriend(DHT *dht, const uint8_t *public_key, uint16_t lock_count);
271 * ip must be 4 bytes long. 271 * ip must be 4 bytes long.
272 * port must be 2 bytes long. 272 * port must be 2 bytes long.
273 * 273 *
274 * int dht_getfriendip(DHT *dht, uint8_t *public_key, IP_Port *ip_port);
275 *
276 * return -1, -- if public_key does NOT refer to a friend 274 * return -1, -- if public_key does NOT refer to a friend
277 * return 0, -- if public_key refers to a friend and we failed to find the friend (yet) 275 * return 0, -- if public_key refers to a friend and we failed to find the friend (yet)
278 * return 1, ip if public_key refers to a friend and we found him 276 * return 1, ip if public_key refers to a friend and we found him
diff --git a/toxcore/LAN_discovery.c b/toxcore/LAN_discovery.c
index b1be2600..c3d06014 100644
--- a/toxcore/LAN_discovery.c
+++ b/toxcore/LAN_discovery.c
@@ -57,8 +57,8 @@ static void fetch_broadcast_info(uint16_t port)
57 } 57 }
58 } 58 }
59 59
60 /* We copy these to the static variables broadcast_* only at the end of fetch_broadcast_info(). 60 /* We copy these to the static variables `broadcast_*` only at the end of `fetch_broadcast_info()`.
61 * The intention is to ensure that even if multiple threads enter fetch_broadcast_info() concurrently, only valid 61 * The intention is to ensure that even if multiple threads enter `fetch_broadcast_info()` concurrently, only valid
62 * interfaces will be set to be broadcast to. 62 * interfaces will be set to be broadcast to.
63 * */ 63 * */
64 int count = 0; 64 int count = 0;
@@ -123,7 +123,7 @@ static void fetch_broadcast_info(uint16_t port)
123static void fetch_broadcast_info(uint16_t port) 123static void fetch_broadcast_info(uint16_t port)
124{ 124{
125 /* Not sure how many platforms this will run on, 125 /* Not sure how many platforms this will run on,
126 * so it's wrapped in __linux for now. 126 * so it's wrapped in `__linux__` for now.
127 * Definitely won't work like this on Windows... 127 * Definitely won't work like this on Windows...
128 */ 128 */
129 broadcast_count = 0; 129 broadcast_count = 0;
@@ -146,15 +146,15 @@ static void fetch_broadcast_info(uint16_t port)
146 return; 146 return;
147 } 147 }
148 148
149 /* We copy these to the static variables broadcast_* only at the end of fetch_broadcast_info(). 149 /* We copy these to the static variables `broadcast_*` only at the end of `fetch_broadcast_info()`.
150 * The intention is to ensure that even if multiple threads enter fetch_broadcast_info() concurrently, only valid 150 * The intention is to ensure that even if multiple threads enter `fetch_broadcast_info()` concurrently, only valid
151 * interfaces will be set to be broadcast to. 151 * interfaces will be set to be broadcast to.
152 * */ 152 * */
153 int count = 0; 153 int count = 0;
154 IP_Port ip_ports[MAX_INTERFACES]; 154 IP_Port ip_ports[MAX_INTERFACES];
155 155
156 /* ifc.ifc_len is set by the ioctl() to the actual length used; 156 /* `ifc.ifc_len` is set by the `ioctl()` to the actual length used.
157 * on usage of the complete array the call should be repeated with 157 * On usage of the complete array the call should be repeated with
158 * a larger array, not done (640kB and 16 interfaces shall be 158 * a larger array, not done (640kB and 16 interfaces shall be
159 * enough, for everybody!) 159 * enough, for everybody!)
160 */ 160 */
@@ -239,8 +239,8 @@ static IP broadcast_ip(Family family_socket, Family family_broadcast)
239 if (net_family_is_ipv6(family_socket)) { 239 if (net_family_is_ipv6(family_socket)) {
240 if (net_family_is_ipv6(family_broadcast)) { 240 if (net_family_is_ipv6(family_broadcast)) {
241 ip.family = net_family_ipv6; 241 ip.family = net_family_ipv6;
242 /* FF02::1 is - according to RFC 4291 - multicast all-nodes link-local */ 242 /* `FF02::1` is - according to RFC 4291 - multicast all-nodes link-local */
243 /* FE80::*: MUST be exact, for that we would need to look over all 243 /* `FE80::*:` MUST be exact, for that we would need to look over all
244 * interfaces and check in which status they are */ 244 * interfaces and check in which status they are */
245 ip.ip.v6.uint8[ 0] = 0xFF; 245 ip.ip.v6.uint8[ 0] = 0xFF;
246 ip.ip.v6.uint8[ 1] = 0x02; 246 ip.ip.v6.uint8[ 1] = 0x02;
@@ -328,8 +328,8 @@ bool ip_is_lan(IP ip)
328 } 328 }
329 329
330 if (net_family_is_ipv6(ip.family)) { 330 if (net_family_is_ipv6(ip.family)) {
331 /* autogenerated for each interface: FE80::* (up to FEBF::*) 331 /* autogenerated for each interface: `FE80::*` (up to `FEBF::*`)
332 FF02::1 is - according to RFC 4291 - multicast all-nodes link-local */ 332 `FF02::1` is - according to RFC 4291 - multicast all-nodes link-local */
333 if (((ip.ip.v6.uint8[0] == 0xFF) && (ip.ip.v6.uint8[1] < 3) && (ip.ip.v6.uint8[15] == 1)) || 333 if (((ip.ip.v6.uint8[0] == 0xFF) && (ip.ip.v6.uint8[1] < 3) && (ip.ip.v6.uint8[15] == 1)) ||
334 ((ip.ip.v6.uint8[0] == 0xFE) && ((ip.ip.v6.uint8[1] & 0xC0) == 0x80))) { 334 ((ip.ip.v6.uint8[0] == 0xFE) && ((ip.ip.v6.uint8[1] & 0xC0) == 0x80))) {
335 return true; 335 return true;
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c
index e08758e7..ddd04518 100644
--- a/toxcore/Messenger.c
+++ b/toxcore/Messenger.c
@@ -125,7 +125,7 @@ static uint16_t address_checksum(const uint8_t *address, uint32_t len)
125 return check; 125 return check;
126} 126}
127 127
128/* Format: [real_pk (32 bytes)][nospam number (4 bytes)][checksum (2 bytes)] 128/* Format: `[real_pk (32 bytes)][nospam number (4 bytes)][checksum (2 bytes)]`
129 * 129 *
130 * return FRIEND_ADDRESS_SIZE byte address to give to others. 130 * return FRIEND_ADDRESS_SIZE byte address to give to others.
131 */ 131 */
@@ -971,12 +971,10 @@ static int write_cryptpacket_id(const Messenger *m, int32_t friendnumber, uint8_
971 m->friendlist[friendnumber].friendcon_id), packet, length + 1, congestion_control) != -1; 971 m->friendlist[friendnumber].friendcon_id), packet, length + 1, congestion_control) != -1;
972} 972}
973 973
974/**********CONFERENCES************/ 974/** CONFERENCES */
975 975
976 976
977/* Set the callback for conference invites. 977/* Set the callback for conference invites.
978 *
979 * Function(Messenger *m, uint32_t friendnumber, uint8_t *data, uint16_t length, void *userdata)
980 */ 978 */
981void m_callback_conference_invite(Messenger *m, m_conference_invite_cb *function) 979void m_callback_conference_invite(Messenger *m, m_conference_invite_cb *function)
982{ 980{
@@ -994,12 +992,10 @@ int send_conference_invite_packet(const Messenger *m, int32_t friendnumber, cons
994 return write_cryptpacket_id(m, friendnumber, PACKET_ID_INVITE_CONFERENCE, data, length, 0); 992 return write_cryptpacket_id(m, friendnumber, PACKET_ID_INVITE_CONFERENCE, data, length, 0);
995} 993}
996 994
997/****************FILE SENDING*****************/ 995/** FILE SENDING */
998 996
999 997
1000/* Set the callback for file send requests. 998/* Set the callback for file send requests.
1001 *
1002 * Function(Tox *tox, uint32_t friendnumber, uint32_t filenumber, uint32_t filetype, uint64_t filesize, uint8_t *filename, size_t filename_length, void *userdata)
1003 */ 999 */
1004void callback_file_sendrequest(Messenger *m, m_file_recv_cb *function) 1000void callback_file_sendrequest(Messenger *m, m_file_recv_cb *function)
1005{ 1001{
@@ -1007,9 +1003,6 @@ void callback_file_sendrequest(Messenger *m, m_file_recv_cb *function)
1007} 1003}
1008 1004
1009/* Set the callback for file control requests. 1005/* Set the callback for file control requests.
1010 *
1011 * Function(Tox *tox, uint32_t friendnumber, uint32_t filenumber, unsigned int control_type, void *userdata)
1012 *
1013 */ 1006 */
1014void callback_file_control(Messenger *m, m_file_recv_control_cb *function) 1007void callback_file_control(Messenger *m, m_file_recv_control_cb *function)
1015{ 1008{
@@ -1017,9 +1010,6 @@ void callback_file_control(Messenger *m, m_file_recv_control_cb *function)
1017} 1010}
1018 1011
1019/* Set the callback for file data. 1012/* Set the callback for file data.
1020 *
1021 * Function(Tox *tox, uint32_t friendnumber, uint32_t filenumber, uint64_t position, uint8_t *data, size_t length, void *userdata)
1022 *
1023 */ 1013 */
1024void callback_file_data(Messenger *m, m_file_recv_chunk_cb *function) 1014void callback_file_data(Messenger *m, m_file_recv_chunk_cb *function)
1025{ 1015{
@@ -1027,9 +1017,6 @@ void callback_file_data(Messenger *m, m_file_recv_chunk_cb *function)
1027} 1017}
1028 1018
1029/* Set the callback for file request chunk. 1019/* Set the callback for file request chunk.
1030 *
1031 * Function(Tox *tox, uint32_t friendnumber, uint32_t filenumber, uint64_t position, size_t length, void *userdata)
1032 *
1033 */ 1020 */
1034void callback_file_reqchunk(Messenger *m, m_file_chunk_request_cb *function) 1021void callback_file_reqchunk(Messenger *m, m_file_chunk_request_cb *function)
1035{ 1022{
@@ -1766,11 +1753,7 @@ static int handle_filecontrol(Messenger *m, int32_t friendnumber, uint8_t receiv
1766 } 1753 }
1767} 1754}
1768 1755
1769/**************************************/
1770
1771/* Set the callback for msi packets. 1756/* Set the callback for msi packets.
1772 *
1773 * Function(Messenger *m, int friendnumber, uint8_t *data, uint16_t length, void *userdata)
1774 */ 1757 */
1775void m_callback_msi_packet(Messenger *m, m_msi_packet_cb *function, void *userdata) 1758void m_callback_msi_packet(Messenger *m, m_msi_packet_cb *function, void *userdata)
1776{ 1759{
diff --git a/toxcore/Messenger.h b/toxcore/Messenger.h
index 4d2b1b20..85f730cf 100644
--- a/toxcore/Messenger.h
+++ b/toxcore/Messenger.h
@@ -19,7 +19,7 @@
19#define MAX_NAME_LENGTH 128 19#define MAX_NAME_LENGTH 128
20/* TODO(irungentoo): this must depend on other variable. */ 20/* TODO(irungentoo): this must depend on other variable. */
21#define MAX_STATUSMESSAGE_LENGTH 1007 21#define MAX_STATUSMESSAGE_LENGTH 1007
22/* Used for TCP relays in Messenger struct (may need to be % 2 == 0)*/ 22/* Used for TCP relays in Messenger struct (may need to be `% 2 == 0`)*/
23#define NUM_SAVED_TCP_RELAYS 8 23#define NUM_SAVED_TCP_RELAYS 8
24/* This cannot be bigger than 256 */ 24/* This cannot be bigger than 256 */
25#define MAX_CONCURRENT_FILE_PIPES 256 25#define MAX_CONCURRENT_FILE_PIPES 256
@@ -300,7 +300,7 @@ struct Messenger {
300 Messenger_Options options; 300 Messenger_Options options;
301}; 301};
302 302
303/* Format: [real_pk (32 bytes)][nospam number (4 bytes)][checksum (2 bytes)] 303/* Format: `[real_pk (32 bytes)][nospam number (4 bytes)][checksum (2 bytes)]`
304 * 304 *
305 * return FRIEND_ADDRESS_SIZE byte address to give to others. 305 * return FRIEND_ADDRESS_SIZE byte address to give to others.
306 */ 306 */
@@ -490,40 +490,40 @@ int m_set_usertyping(Messenger *m, int32_t friendnumber, uint8_t is_typing);
490int m_get_istyping(const Messenger *m, int32_t friendnumber); 490int m_get_istyping(const Messenger *m, int32_t friendnumber);
491 491
492/* Set the function that will be executed when a friend request is received. 492/* Set the function that will be executed when a friend request is received.
493 * Function format is function(uint8_t * public_key, uint8_t * data, size_t length) 493 * Function format is `function(uint8_t * public_key, uint8_t * data, size_t length)`
494 */ 494 */
495void m_callback_friendrequest(Messenger *m, m_friend_request_cb *function); 495void m_callback_friendrequest(Messenger *m, m_friend_request_cb *function);
496 496
497/* Set the function that will be executed when a message from a friend is received. 497/* Set the function that will be executed when a message from a friend is received.
498 * Function format is: function(uint32_t friendnumber, unsigned int type, uint8_t * message, uint32_t length) 498 * Function format is: `function(uint32_t friendnumber, unsigned int type, uint8_t * message, uint32_t length)`
499 */ 499 */
500void m_callback_friendmessage(Messenger *m, m_friend_message_cb *function); 500void m_callback_friendmessage(Messenger *m, m_friend_message_cb *function);
501 501
502/* Set the callback for name changes. 502/* Set the callback for name changes.
503 * Function(uint32_t friendnumber, uint8_t *newname, size_t length) 503 * `Function(uint32_t friendnumber, uint8_t *newname, size_t length)`
504 * You are not responsible for freeing newname. 504 * You are not responsible for freeing newname.
505 */ 505 */
506void m_callback_namechange(Messenger *m, m_friend_name_cb *function); 506void m_callback_namechange(Messenger *m, m_friend_name_cb *function);
507 507
508/* Set the callback for status message changes. 508/* Set the callback for status message changes.
509 * Function(uint32_t friendnumber, uint8_t *newstatus, size_t length) 509 * `Function(uint32_t friendnumber, uint8_t *newstatus, size_t length)`
510 * 510 *
511 * You are not responsible for freeing newstatus 511 * You are not responsible for freeing newstatus
512 */ 512 */
513void m_callback_statusmessage(Messenger *m, m_friend_status_message_cb *function); 513void m_callback_statusmessage(Messenger *m, m_friend_status_message_cb *function);
514 514
515/* Set the callback for status type changes. 515/* Set the callback for status type changes.
516 * Function(uint32_t friendnumber, Userstatus kind) 516 * `Function(uint32_t friendnumber, Userstatus kind)`
517 */ 517 */
518void m_callback_userstatus(Messenger *m, m_friend_status_cb *function); 518void m_callback_userstatus(Messenger *m, m_friend_status_cb *function);
519 519
520/* Set the callback for typing changes. 520/* Set the callback for typing changes.
521 * Function(uint32_t friendnumber, uint8_t is_typing) 521 * `Function(uint32_t friendnumber, uint8_t is_typing)`
522 */ 522 */
523void m_callback_typingchange(Messenger *m, m_friend_typing_cb *function); 523void m_callback_typingchange(Messenger *m, m_friend_typing_cb *function);
524 524
525/* Set the callback for read receipts. 525/* Set the callback for read receipts.
526 * Function(uint32_t friendnumber, uint32_t receipt) 526 * `Function(uint32_t friendnumber, uint32_t receipt)`
527 * 527 *
528 * If you are keeping a record of returns from m_sendmessage, 528 * If you are keeping a record of returns from m_sendmessage,
529 * receipt might be one of those values, meaning the message 529 * receipt might be one of those values, meaning the message
@@ -534,14 +534,14 @@ void m_callback_typingchange(Messenger *m, m_friend_typing_cb *function);
534void m_callback_read_receipt(Messenger *m, m_friend_read_receipt_cb *function); 534void m_callback_read_receipt(Messenger *m, m_friend_read_receipt_cb *function);
535 535
536/* Set the callback for connection status changes. 536/* Set the callback for connection status changes.
537 * function(uint32_t friendnumber, uint8_t status) 537 * `function(uint32_t friendnumber, uint8_t status)`
538 * 538 *
539 * Status: 539 * Status:
540 * 0 -- friend went offline after being previously online. 540 * 0 -- friend went offline after being previously online.
541 * 1 -- friend went online. 541 * 1 -- friend went online.
542 * 542 *
543 * Note that this callback is not called when adding friends, thus the "after 543 * Note that this callback is not called when adding friends, thus the
544 * being previously online" part. 544 * "after being previously online" part.
545 * It's assumed that when adding friends, their connection status is offline. 545 * It's assumed that when adding friends, their connection status is offline.
546 */ 546 */
547void m_callback_connectionstatus(Messenger *m, m_friend_connection_status_cb *function); 547void m_callback_connectionstatus(Messenger *m, m_friend_connection_status_cb *function);
@@ -556,11 +556,9 @@ void m_callback_connectionstatus_internal_av(Messenger *m, m_friend_connectionst
556 */ 556 */
557void m_callback_core_connection(Messenger *m, m_self_connection_status_cb *function); 557void m_callback_core_connection(Messenger *m, m_self_connection_status_cb *function);
558 558
559/**********CONFERENCES************/ 559/** CONFERENCES */
560 560
561/* Set the callback for conference invites. 561/* Set the callback for conference invites.
562 *
563 * Function(Messenger *m, uint32_t friendnumber, uint8_t *data, uint16_t length, void *userdata)
564 */ 562 */
565void m_callback_conference_invite(Messenger *m, m_conference_invite_cb *function); 563void m_callback_conference_invite(Messenger *m, m_conference_invite_cb *function);
566 564
@@ -571,34 +569,23 @@ void m_callback_conference_invite(Messenger *m, m_conference_invite_cb *function
571 */ 569 */
572int send_conference_invite_packet(const Messenger *m, int32_t friendnumber, const uint8_t *data, uint16_t length); 570int send_conference_invite_packet(const Messenger *m, int32_t friendnumber, const uint8_t *data, uint16_t length);
573 571
574/****************FILE SENDING*****************/ 572/** FILE SENDING */
575 573
576 574
577/* Set the callback for file send requests. 575/* Set the callback for file send requests.
578 *
579 * Function(Tox *tox, uint32_t friendnumber, uint32_t filenumber, uint32_t filetype, uint64_t filesize, uint8_t *filename, size_t filename_length, void *userdata)
580 */ 576 */
581void callback_file_sendrequest(Messenger *m, m_file_recv_cb *function); 577void callback_file_sendrequest(Messenger *m, m_file_recv_cb *function);
582 578
583 579
584/* Set the callback for file control requests. 580/* Set the callback for file control requests.
585 *
586 * Function(Tox *tox, uint32_t friendnumber, uint32_t filenumber, unsigned int control_type, void *userdata)
587 *
588 */ 581 */
589void callback_file_control(Messenger *m, m_file_recv_control_cb *function); 582void callback_file_control(Messenger *m, m_file_recv_control_cb *function);
590 583
591/* Set the callback for file data. 584/* Set the callback for file data.
592 *
593 * Function(Tox *tox, uint32_t friendnumber, uint32_t filenumber, uint64_t position, uint8_t *data, size_t length, void *userdata)
594 *
595 */ 585 */
596void callback_file_data(Messenger *m, m_file_recv_chunk_cb *function); 586void callback_file_data(Messenger *m, m_file_recv_chunk_cb *function);
597 587
598/* Set the callback for file request chunk. 588/* Set the callback for file request chunk.
599 *
600 * Function(Tox *tox, uint32_t friendnumber, uint32_t filenumber, uint64_t position, size_t length, void *userdata)
601 *
602 */ 589 */
603void callback_file_reqchunk(Messenger *m, m_file_chunk_request_cb *function); 590void callback_file_reqchunk(Messenger *m, m_file_chunk_request_cb *function);
604 591
@@ -673,11 +660,9 @@ int file_data(const Messenger *m, int32_t friendnumber, uint32_t filenumber, uin
673 */ 660 */
674uint64_t file_dataremaining(const Messenger *m, int32_t friendnumber, uint8_t filenumber, uint8_t send_receive); 661uint64_t file_dataremaining(const Messenger *m, int32_t friendnumber, uint8_t filenumber, uint8_t send_receive);
675 662
676/*************** A/V related ******************/ 663/** A/V related */
677 664
678/* Set the callback for msi packets. 665/* Set the callback for msi packets.
679 *
680 * Function(Messenger *m, uint32_t friendnumber, uint8_t *data, uint16_t length, void *userdata)
681 */ 666 */
682void m_callback_msi_packet(Messenger *m, m_msi_packet_cb *function, void *userdata); 667void m_callback_msi_packet(Messenger *m, m_msi_packet_cb *function, void *userdata);
683 668
@@ -696,7 +681,7 @@ int m_msi_packet(const Messenger *m, int32_t friendnumber, const uint8_t *data,
696int m_callback_rtp_packet(Messenger *m, int32_t friendnumber, uint8_t byte, 681int m_callback_rtp_packet(Messenger *m, int32_t friendnumber, uint8_t byte,
697 m_lossy_rtp_packet_cb *function, void *object); 682 m_lossy_rtp_packet_cb *function, void *object);
698 683
699/**********************************************/ 684/** CUSTOM PACKETS */
700 685
701/* Set handlers for custom lossy packets. 686/* Set handlers for custom lossy packets.
702 * 687 *
@@ -731,7 +716,7 @@ void custom_lossless_packet_registerhandler(Messenger *m, m_friend_lossless_pack
731 */ 716 */
732int send_custom_lossless_packet(const Messenger *m, int32_t friendnumber, const uint8_t *data, uint32_t length); 717int send_custom_lossless_packet(const Messenger *m, int32_t friendnumber, const uint8_t *data, uint32_t length);
733 718
734/**********************************************/ 719/** Messenger constructor/destructor/operations. */
735 720
736typedef enum Messenger_Error { 721typedef enum Messenger_Error {
737 MESSENGER_ERROR_NONE, 722 MESSENGER_ERROR_NONE,
@@ -783,7 +768,7 @@ uint8_t *messenger_save(const Messenger *m, uint8_t *data);
783 * 768 *
784 * @param data Data to load. 769 * @param data Data to load.
785 * @param length Length of data. 770 * @param length Length of data.
786 * @param type Type of section (STATE_TYPE_*). 771 * @param type Type of section (`STATE_TYPE_*`).
787 * @param status Result of loading section is stored here if the section is handled. 772 * @param status Result of loading section is stored here if the section is handled.
788 * @return true iff section handled. 773 * @return true iff section handled.
789 */ 774 */
diff --git a/toxcore/crypto_core.c b/toxcore/crypto_core.c
index 5875bca2..5538b1b8 100644
--- a/toxcore/crypto_core.c
+++ b/toxcore/crypto_core.c
@@ -242,7 +242,7 @@ int32_t decrypt_data(const uint8_t *public_key, const uint8_t *secret_key, const
242/* Increment the given nonce by 1. */ 242/* Increment the given nonce by 1. */
243void increment_nonce(uint8_t *nonce) 243void increment_nonce(uint8_t *nonce)
244{ 244{
245 /* TODO(irungentoo): use increment_nonce_number(nonce, 1) or 245 /* TODO(irungentoo): use `increment_nonce_number(nonce, 1)` or
246 * sodium_increment (change to little endian). 246 * sodium_increment (change to little endian).
247 * 247 *
248 * NOTE don't use breaks inside this loop. 248 * NOTE don't use breaks inside this loop.
diff --git a/toxcore/friend_requests.h b/toxcore/friend_requests.h
index 04863948..e3a03a51 100644
--- a/toxcore/friend_requests.h
+++ b/toxcore/friend_requests.h
@@ -30,14 +30,12 @@ typedef void fr_friend_request_cb(void *object, const uint8_t *public_key, const
30 void *user_data); 30 void *user_data);
31 31
32/* Set the function that will be executed when a friend request for us is received. 32/* Set the function that will be executed when a friend request for us is received.
33 * Function format is function(uint8_t * public_key, uint8_t * data, size_t length, void * userdata)
34 */ 33 */
35void callback_friendrequest(Friend_Requests *fr, fr_friend_request_cb *function, void *object); 34void callback_friendrequest(Friend_Requests *fr, fr_friend_request_cb *function, void *object);
36 35
37typedef int filter_function_cb(const uint8_t *public_key, void *user_data); 36typedef int filter_function_cb(const uint8_t *public_key, void *user_data);
38 37
39/* Set the function used to check if a friend request should be displayed to the user or not. 38/* Set the function used to check if a friend request should be displayed to the user or not.
40 * Function format is int function(uint8_t * public_key, void * userdata)
41 * It must return 0 if the request is ok (anything else if it is bad.) 39 * It must return 0 if the request is ok (anything else if it is bad.)
42 */ 40 */
43void set_filter_function(Friend_Requests *fr, filter_function_cb *function, void *userdata); 41void set_filter_function(Friend_Requests *fr, filter_function_cb *function, void *userdata);
diff --git a/toxcore/group.c b/toxcore/group.c
index fd7b2ac4..3b9c7f40 100644
--- a/toxcore/group.c
+++ b/toxcore/group.c
@@ -1131,7 +1131,7 @@ static void remove_conn_reason(Group_Chats *g_c, uint32_t groupnumber, uint16_t
1131 1131
1132/* Creates a new groupchat and puts it in the chats array. 1132/* Creates a new groupchat and puts it in the chats array.
1133 * 1133 *
1134 * type is one of GROUPCHAT_TYPE_* 1134 * type is one of `GROUPCHAT_TYPE_*`
1135 * 1135 *
1136 * return group number on success. 1136 * return group number on success.
1137 * return -1 on failure. 1137 * return -1 on failure.
@@ -1334,9 +1334,9 @@ int group_set_max_frozen(const Group_Chats *g_c, uint32_t groupnumber, uint32_t
1334 1334
1335/* List all the (frozen, if frozen is true) peers in the group chat. 1335/* List all the (frozen, if frozen is true) peers in the group chat.
1336 * 1336 *
1337 * Copies the names of the peers to the name[length][MAX_NAME_LENGTH] array. 1337 * Copies the names of the peers to the `name[length][MAX_NAME_LENGTH]` array.
1338 * 1338 *
1339 * Copies the lengths of the names to lengths[length] 1339 * Copies the lengths of the names to `lengths[length]`
1340 * 1340 *
1341 * returns the number of peers on success. 1341 * returns the number of peers on success.
1342 * 1342 *
@@ -1418,11 +1418,11 @@ int group_get_type(const Group_Chats *g_c, uint32_t groupnumber)
1418 return g->type; 1418 return g->type;
1419} 1419}
1420 1420
1421/* Copies the unique id of group_chat[groupnumber] into id. 1421/* Copies the unique id of `group_chat[groupnumber]` into `id`.
1422* 1422 *
1423* return false on failure. 1423 * return false on failure.
1424* return true on success. 1424 * return true on success.
1425*/ 1425 */
1426bool conference_get_id(const Group_Chats *g_c, uint32_t groupnumber, uint8_t *id) 1426bool conference_get_id(const Group_Chats *g_c, uint32_t groupnumber, uint8_t *id)
1427{ 1427{
1428 const Group_c *g = get_group_c(g_c, groupnumber); 1428 const Group_c *g = get_group_c(g_c, groupnumber);
@@ -2018,7 +2018,7 @@ static void handle_friend_invite_packet(Messenger *m, uint32_t friendnumber, con
2018 } 2018 }
2019} 2019}
2020 2020
2021/* Find index of friend in the close list; 2021/* Find index of friend in the close list.
2022 * 2022 *
2023 * returns index on success 2023 * returns index on success
2024 * returns -1 on failure. 2024 * returns -1 on failure.
@@ -2621,7 +2621,7 @@ static Message_Info *find_message_slot_or_reject(uint32_t message_number, uint8_
2621 2621
2622/* Stores message info in peer->last_message_infos. 2622/* Stores message info in peer->last_message_infos.
2623 * 2623 *
2624 * return true if message should be processed; 2624 * return true if message should be processed.
2625 * return false otherwise. 2625 * return false otherwise.
2626 */ 2626 */
2627static bool check_message_info(uint32_t message_number, uint8_t message_id, Group_Peer *peer) 2627static bool check_message_info(uint32_t message_number, uint8_t message_id, Group_Peer *peer)
@@ -3194,7 +3194,7 @@ static uint32_t saved_conf_size(const Group_c *g)
3194 return len; 3194 return len;
3195} 3195}
3196 3196
3197/* Save a future message number; the save will remain valid until we have sent 3197/* Save a future message number. The save will remain valid until we have sent
3198 * this many more messages. */ 3198 * this many more messages. */
3199#define SAVE_OFFSET_MESSAGE_NUMBER (1 << 16) 3199#define SAVE_OFFSET_MESSAGE_NUMBER (1 << 16)
3200#define SAVE_OFFSET_LOSSY_MESSAGE_NUMBER (1 << 13) 3200#define SAVE_OFFSET_LOSSY_MESSAGE_NUMBER (1 << 13)
diff --git a/toxcore/group.h b/toxcore/group.h
index d74d561d..c5601378 100644
--- a/toxcore/group.h
+++ b/toxcore/group.h
@@ -76,8 +76,8 @@ typedef enum Groupchat_Close_Type {
76#define GROUPCHAT_CLOSE_REASON_INTRODUCER (1 << 2) 76#define GROUPCHAT_CLOSE_REASON_INTRODUCER (1 << 2)
77 77
78typedef struct Groupchat_Close { 78typedef struct Groupchat_Close {
79 uint8_t type; /* GROUPCHAT_CLOSE_* */ 79 uint8_t type; /* `GROUPCHAT_CLOSE_*` */
80 uint8_t reasons; /* bit field with flags GROUPCHAT_CLOSE_REASON_* */ 80 uint8_t reasons; /* bit field with flags `GROUPCHAT_CLOSE_REASON_*` */
81 uint32_t number; 81 uint32_t number;
82 uint16_t group_number; 82 uint16_t group_number;
83} Groupchat_Close; 83} Groupchat_Close;
@@ -222,7 +222,7 @@ void g_callback_peer_list_changed(Group_Chats *g_c, peer_list_changed_cb *functi
222 222
223/* Creates a new groupchat and puts it in the chats array. 223/* Creates a new groupchat and puts it in the chats array.
224 * 224 *
225 * type is one of GROUPCHAT_TYPE_* 225 * type is one of `GROUPCHAT_TYPE_*`
226 * 226 *
227 * return group number on success. 227 * return group number on success.
228 * return -1 on failure. 228 * return -1 on failure.
@@ -357,9 +357,9 @@ int group_peernumber_is_ours(const Group_Chats *g_c, uint32_t groupnumber, int p
357 357
358/* List all the (frozen, if frozen is true) peers in the group chat. 358/* List all the (frozen, if frozen is true) peers in the group chat.
359 * 359 *
360 * Copies the names of the peers to the name[length][MAX_NAME_LENGTH] array. 360 * Copies the names of the peers to the `name[length][MAX_NAME_LENGTH]` array.
361 * 361 *
362 * Copies the lengths of the names to lengths[length] 362 * Copies the lengths of the names to `lengths[length]`
363 * 363 *
364 * returns the number of peers on success. 364 * returns the number of peers on success.
365 * 365 *
@@ -398,11 +398,11 @@ uint32_t copy_chatlist(const Group_Chats *g_c, uint32_t *out_list, uint32_t list
398 */ 398 */
399int group_get_type(const Group_Chats *g_c, uint32_t groupnumber); 399int group_get_type(const Group_Chats *g_c, uint32_t groupnumber);
400 400
401/* Copies the unique id of group_chat[groupnumber] into id. 401/* Copies the unique id of `group_chat[groupnumber]` into id.
402* 402 *
403* return false on failure. 403 * return false on failure.
404* return true on success. 404 * return true on success.
405*/ 405 */
406bool conference_get_id(const Group_Chats *g_c, uint32_t groupnumber, uint8_t *id); 406bool conference_get_id(const Group_Chats *g_c, uint32_t groupnumber, uint8_t *id);
407 407
408int32_t conference_by_id(const Group_Chats *g_c, const uint8_t *id); 408int32_t conference_by_id(const Group_Chats *g_c, const uint8_t *id);
@@ -471,7 +471,7 @@ uint8_t *conferences_save(const Group_Chats *g_c, uint8_t *data);
471 * 471 *
472 * @param data Data to load 472 * @param data Data to load
473 * @param length Length of data 473 * @param length Length of data
474 * @param type Type of section (STATE_TYPE_*) 474 * @param type Type of section (`STATE_TYPE_*`)
475 * @param status Result of loading section is stored here if the section is handled. 475 * @param status Result of loading section is stored here if the section is handled.
476 * @return true iff section handled. 476 * @return true iff section handled.
477 */ 477 */
diff --git a/toxcore/net_crypto.c b/toxcore/net_crypto.c
index 4eacb250..6a69bb5b 100644
--- a/toxcore/net_crypto.c
+++ b/toxcore/net_crypto.c
@@ -30,17 +30,17 @@ typedef struct Packet_Data {
30typedef struct Packets_Array { 30typedef struct Packets_Array {
31 Packet_Data *buffer[CRYPTO_PACKET_BUFFER_SIZE]; 31 Packet_Data *buffer[CRYPTO_PACKET_BUFFER_SIZE];
32 uint32_t buffer_start; 32 uint32_t buffer_start;
33 uint32_t buffer_end; /* packet numbers in array: {buffer_start, buffer_end) */ 33 uint32_t buffer_end; /* packet numbers in array: `{buffer_start, buffer_end)` */
34} Packets_Array; 34} Packets_Array;
35 35
36typedef enum Crypto_Conn_State { 36typedef enum Crypto_Conn_State {
37 CRYPTO_CONN_FREE = 0, /* the connection slot is free; this value is 0 so it is valid after 37 CRYPTO_CONN_FREE = 0, /* the connection slot is free. This value is 0 so it is valid after
38 * crypto_memzero(...) of the parent struct 38 * `crypto_memzero(...)` of the parent struct
39 */ 39 */
40 CRYPTO_CONN_NO_CONNECTION, /* the connection is allocated, but not yet used */ 40 CRYPTO_CONN_NO_CONNECTION, /* the connection is allocated, but not yet used */
41 CRYPTO_CONN_COOKIE_REQUESTING, /* we are sending cookie request packets */ 41 CRYPTO_CONN_COOKIE_REQUESTING, /* we are sending cookie request packets */
42 CRYPTO_CONN_HANDSHAKE_SENT, /* we are sending handshake packets */ 42 CRYPTO_CONN_HANDSHAKE_SENT, /* we are sending handshake packets */
43 CRYPTO_CONN_NOT_CONFIRMED, /* we are sending handshake packets; 43 CRYPTO_CONN_NOT_CONFIRMED, /* we are sending handshake packets.
44 * we have received one from the other, but no data */ 44 * we have received one from the other, but no data */
45 CRYPTO_CONN_ESTABLISHED, /* the connection is established */ 45 CRYPTO_CONN_ESTABLISHED, /* the connection is established */
46} Crypto_Conn_State; 46} Crypto_Conn_State;
@@ -725,7 +725,7 @@ static int send_packet_to(Net_Crypto *c, int crypt_connection_id, const uint8_t
725 return -1; 725 return -1;
726} 726}
727 727
728/** START: Array Related functions **/ 728/** START: Array Related functions */
729 729
730 730
731/* Return number of packets in array 731/* Return number of packets in array
@@ -1045,7 +1045,7 @@ static int handle_request_packet(Mono_Time *mono_time, const Logger *log, Packet
1045 return requested; 1045 return requested;
1046} 1046}
1047 1047
1048/** END: Array Related functions **/ 1048/** END: Array Related functions */
1049 1049
1050#define MAX_DATA_DATA_PACKET_SIZE (MAX_CRYPTO_PACKET_SIZE - (1 + sizeof(uint16_t) + CRYPTO_MAC_SIZE)) 1050#define MAX_DATA_DATA_PACKET_SIZE (MAX_CRYPTO_PACKET_SIZE - (1 + sizeof(uint16_t) + CRYPTO_MAC_SIZE))
1051 1051
diff --git a/toxcore/net_crypto.h b/toxcore/net_crypto.h
index 736a3dc3..3885a1ba 100644
--- a/toxcore/net_crypto.h
+++ b/toxcore/net_crypto.h
@@ -16,9 +16,9 @@
16 16
17#include <pthread.h> 17#include <pthread.h>
18 18
19/*** Crypto payloads. ***/ 19/** Crypto payloads. */
20 20
21/** Ranges. **/ 21/** Ranges. */
22 22
23/* Packets in this range are reserved for net_crypto internal use. */ 23/* Packets in this range are reserved for net_crypto internal use. */
24#define PACKET_ID_RANGE_RESERVED_START 0 24#define PACKET_ID_RANGE_RESERVED_START 0
@@ -41,7 +41,7 @@
41#define PACKET_ID_RANGE_LOSSY_CUSTOM_END 254 41#define PACKET_ID_RANGE_LOSSY_CUSTOM_END 254
42#define PACKET_ID_RANGE_LOSSY_END 254 42#define PACKET_ID_RANGE_LOSSY_END 254
43 43
44/** Messages. **/ 44/** Messages. */
45 45
46#define PACKET_ID_PADDING 0 // Denotes padding 46#define PACKET_ID_PADDING 0 // Denotes padding
47#define PACKET_ID_REQUEST 1 // Used to request unreceived packets 47#define PACKET_ID_REQUEST 1 // Used to request unreceived packets
diff --git a/toxcore/network.c b/toxcore/network.c
index ab0003e0..67122ea3 100644
--- a/toxcore/network.c
+++ b/toxcore/network.c
@@ -414,7 +414,7 @@ static void loglogdata(const Logger *log, const char *message, const uint8_t *bu
414{ 414{
415 char ip_str[IP_NTOA_LEN]; 415 char ip_str[IP_NTOA_LEN];
416 416
417 if (res < 0) { /* Windows doesn't necessarily know %zu */ 417 if (res < 0) { /* Windows doesn't necessarily know `%zu` */
418 int error = net_error(); 418 int error = net_error();
419 const char *strerror = net_new_strerror(error); 419 const char *strerror = net_new_strerror(error);
420 LOGGER_TRACE(log, "[%2u] %s %3u%c %s:%u (%u: %s) | %04x%04x", 420 LOGGER_TRACE(log, "[%2u] %s %3u%c %s:%u (%u: %s) | %04x%04x",
@@ -842,14 +842,14 @@ Networking_Core *new_networking_ex(const Logger *log, IP ip, uint16_t port_from,
842 net_kill_strerror(strerror); 842 net_kill_strerror(strerror);
843 } 843 }
844 844
845 /* a hanging program or a different user might block the standard port; 845 /* A hanging program or a different user might block the standard port.
846 * as long as it isn't a parameter coming from the commandline, 846 * As long as it isn't a parameter coming from the commandline,
847 * try a few ports after it, to see if we can find a "free" one 847 * try a few ports after it, to see if we can find a "free" one.
848 * 848 *
849 * if we go on without binding, the first sendto() automatically binds to 849 * If we go on without binding, the first sendto() automatically binds to
850 * a free port chosen by the system (i.e. anything from 1024 to 65535) 850 * a free port chosen by the system (i.e. anything from 1024 to 65535).
851 * 851 *
852 * returning NULL after bind fails has both advantages and disadvantages: 852 * Returning NULL after bind fails has both advantages and disadvantages:
853 * advantage: 853 * advantage:
854 * we can rely on getting the port in the range 33445..33450, which 854 * we can rely on getting the port in the range 33445..33450, which
855 * enables us to tell joe user to open their firewall to a small range 855 * enables us to tell joe user to open their firewall to a small range
diff --git a/toxcore/network.h b/toxcore/network.h
index 9fbefc28..b7e8ede2 100644
--- a/toxcore/network.h
+++ b/toxcore/network.h
@@ -95,7 +95,7 @@ typedef enum Net_Packet_Type {
95 NET_PACKET_CRYPTO = 0x20, /* Encrypted data packet ID. */ 95 NET_PACKET_CRYPTO = 0x20, /* Encrypted data packet ID. */
96 NET_PACKET_LAN_DISCOVERY = 0x21, /* LAN discovery packet ID. */ 96 NET_PACKET_LAN_DISCOVERY = 0x21, /* LAN discovery packet ID. */
97 97
98 /* See: docs/Prevent_Tracking.txt and onion.{c,h} */ 98 /* See: `docs/Prevent_Tracking.txt` and `onion.{c,h}` */
99 NET_PACKET_ONION_SEND_INITIAL = 0x80, 99 NET_PACKET_ONION_SEND_INITIAL = 0x80,
100 NET_PACKET_ONION_SEND_1 = 0x81, 100 NET_PACKET_ONION_SEND_1 = 0x81,
101 NET_PACKET_ONION_SEND_2 = 0x82, 101 NET_PACKET_ONION_SEND_2 = 0x82,
@@ -288,11 +288,11 @@ void ipport_copy(IP_Port *target, const IP_Port *source);
288 * IP versions are acceptable 288 * IP versions are acceptable
289 * @param extra can be NULL and is only set in special circumstances, see returns 289 * @param extra can be NULL and is only set in special circumstances, see returns
290 * 290 *
291 * returns in *to a valid IPAny (v4/v6), 291 * returns in `*to` a valid IPAny (v4/v6),
292 * prefers v6 if ip.family was TOX_AF_UNSPEC and both available 292 * prefers v6 if `ip.family` was TOX_AF_UNSPEC and both available
293 * returns in *extra an IPv4 address, if family was TOX_AF_UNSPEC and *to is TOX_AF_INET6 293 * returns in `*extra` an IPv4 address, if family was TOX_AF_UNSPEC and `*to` is TOX_AF_INET6
294 * 294 *
295 * @return 0 on failure, TOX_ADDR_RESOLVE_* on success. 295 * @return 0 on failure, `TOX_ADDR_RESOLVE_*` on success.
296 */ 296 */
297int addr_resolve(const char *address, IP *to, IP *extra); 297int addr_resolve(const char *address, IP *to, IP *extra);
298 298
@@ -305,8 +305,8 @@ int addr_resolve(const char *address, IP *to, IP *extra);
305 * IP versions are acceptable 305 * IP versions are acceptable
306 * @param extra can be NULL and is only set in special circumstances, see returns 306 * @param extra can be NULL and is only set in special circumstances, see returns
307 * 307 *
308 * returns in *tro a matching address (IPv6 or IPv4) 308 * returns in `*to` a matching address (IPv6 or IPv4)
309 * returns in *extra, if not NULL, an IPv4 address, if to->family was TOX_AF_UNSPEC 309 * returns in `*extra`, if not NULL, an IPv4 address, if `to->family` was TOX_AF_UNSPEC
310 * 310 *
311 * @return true on success, false on failure 311 * @return true on success, false on failure
312 */ 312 */
diff --git a/toxcore/onion.c b/toxcore/onion.c
index 4b7d446f..32a3e88d 100644
--- a/toxcore/onion.c
+++ b/toxcore/onion.c
@@ -135,7 +135,7 @@ int create_onion_path(const DHT *dht, Onion_Path *new_path, const Node_format *n
135 return 0; 135 return 0;
136} 136}
137 137
138/* Dump nodes in onion path to nodes of length num_nodes; 138/* Dump nodes in onion path to nodes of length num_nodes.
139 * 139 *
140 * return -1 on failure. 140 * return -1 on failure.
141 * return 0 on success. 141 * return 0 on success.
diff --git a/toxcore/onion.h b/toxcore/onion.h
index f125f3c3..da145081 100644
--- a/toxcore/onion.h
+++ b/toxcore/onion.h
@@ -140,8 +140,6 @@ int send_onion_response(Networking_Core *net, IP_Port dest, const uint8_t *data,
140int onion_send_1(const Onion *onion, const uint8_t *plain, uint16_t len, IP_Port source, const uint8_t *nonce); 140int onion_send_1(const Onion *onion, const uint8_t *plain, uint16_t len, IP_Port source, const uint8_t *nonce);
141 141
142/* Set the callback to be called when the dest ip_port doesn't have TOX_AF_INET6 or TOX_AF_INET as the family. 142/* Set the callback to be called when the dest ip_port doesn't have TOX_AF_INET6 or TOX_AF_INET as the family.
143 *
144 * Format: function(void *object, IP_Port dest, uint8_t *data, uint16_t length)
145 */ 143 */
146void set_callback_handle_recv_1(Onion *onion, onion_recv_1_cb *function, void *object); 144void set_callback_handle_recv_1(Onion *onion, onion_recv_1_cb *function, void *object);
147 145
diff --git a/toxcore/onion_client.c b/toxcore/onion_client.c
index dcec7ba8..e161928b 100644
--- a/toxcore/onion_client.c
+++ b/toxcore/onion_client.c
@@ -1686,7 +1686,7 @@ static void do_announce(Onion_Client *onion_c)
1686 1686
1687 uint32_t pathnum = list_nodes[i].path_used % NUMBER_ONION_PATHS; 1687 uint32_t pathnum = list_nodes[i].path_used % NUMBER_ONION_PATHS;
1688 1688
1689 /* A node/path is considered 'stable', and can be pinged less 1689 /* A node/path is considered "stable", and can be pinged less
1690 * aggressively, if it has survived for at least TIME_TO_STABLE 1690 * aggressively, if it has survived for at least TIME_TO_STABLE
1691 * and the latest packets sent to it are not timing out. 1691 * and the latest packets sent to it are not timing out.
1692 */ 1692 */