@@ -211,12 +211,6 @@ static IP_Port ip_port_normalize(const IP_Port *ip_port)
211211 return res ;
212212}
213213
214- /** @brief Compares pk1 and pk2 with pk.
215- *
216- * @retval 0 if both are same distance.
217- * @retval 1 if pk1 is closer.
218- * @retval 2 if pk2 is closer.
219- */
220214int id_closest (const uint8_t * pk , const uint8_t * pk1 , const uint8_t * pk2 )
221215{
222216 for (size_t i = 0 ; i < CRYPTO_PUBLIC_KEY_SIZE ; ++ i ) {
@@ -280,27 +274,6 @@ const uint8_t *dht_get_shared_key_sent(DHT *dht, const uint8_t *public_key)
280274
281275#define CRYPTO_SIZE (1 + CRYPTO_PUBLIC_KEY_SIZE * 2 + CRYPTO_NONCE_SIZE)
282276
283- /**
284- * @brief Create a request to peer.
285- *
286- * Packs the data and sender public key and encrypts the packet.
287- *
288- * @param[in] send_public_key public key of the sender.
289- * @param[in] send_secret_key secret key of the sender.
290- * @param[out] packet an array of @ref MAX_CRYPTO_REQUEST_SIZE big.
291- * @param[in] recv_public_key public key of the receiver.
292- * @param[in] data represents the data we send with the request.
293- * @param[in] data_length the length of the data.
294- * @param[in] request_id the id of the request (32 = friend request, 254 = ping request).
295- *
296- * @attention Constraints:
297- * @code
298- * sizeof(packet) >= MAX_CRYPTO_REQUEST_SIZE
299- * @endcode
300- *
301- * @retval -1 on failure.
302- * @return the length of the created packet on success.
303- */
304277int create_request (const Random * rng , const uint8_t * send_public_key , const uint8_t * send_secret_key ,
305278 uint8_t * packet , const uint8_t * recv_public_key ,
306279 const uint8_t * data , uint32_t data_length , uint8_t request_id )
@@ -334,28 +307,6 @@ int create_request(const Random *rng, const uint8_t *send_public_key, const uint
334307 return len + CRYPTO_SIZE ;
335308}
336309
337- /**
338- * @brief Decrypts and unpacks a DHT request packet.
339- *
340- * Puts the senders public key in the request in @p public_key, the data from
341- * the request in @p data.
342- *
343- * @param[in] self_public_key public key of the receiver (us).
344- * @param[in] self_secret_key secret key of the receiver (us).
345- * @param[out] public_key public key of the sender, copied from the input packet.
346- * @param[out] data decrypted request data, copied from the input packet, must
347- * have room for @ref MAX_CRYPTO_REQUEST_SIZE bytes.
348- * @param[in] packet is the request packet.
349- * @param[in] packet_length length of the packet.
350- *
351- * @attention Constraints:
352- * @code
353- * sizeof(data) >= MAX_CRYPTO_REQUEST_SIZE
354- * @endcode
355- *
356- * @retval -1 if not valid request.
357- * @return the length of the unpacked data.
358- */
359310int handle_request (const uint8_t * self_public_key , const uint8_t * self_secret_key , uint8_t * public_key , uint8_t * data ,
360311 uint8_t * request_id , const uint8_t * packet , uint16_t packet_length )
361312{
@@ -394,9 +345,6 @@ int handle_request(const uint8_t *self_public_key, const uint8_t *self_secret_ke
394345 return len1 ;
395346}
396347
397- /** @return packet size of packed node with ip_family on success.
398- * @retval -1 on failure.
399- */
400348int packed_node_size (Family ip_family )
401349{
402350 if (net_family_is_ipv4 (ip_family ) || net_family_is_tcp_ipv4 (ip_family )) {
@@ -411,13 +359,6 @@ int packed_node_size(Family ip_family)
411359}
412360
413361
414- /** @brief Pack an IP_Port structure into data of max size length.
415- *
416- * Packed_length is the offset of data currently packed.
417- *
418- * @return size of packed IP_Port data on success.
419- * @retval -1 on failure.
420- */
421362int pack_ip_port (const Logger * logger , uint8_t * data , uint16_t length , const IP_Port * ip_port )
422363{
423364 if (data == nullptr ) {
@@ -473,11 +414,6 @@ int pack_ip_port(const Logger *logger, uint8_t *data, uint16_t length, const IP_
473414 }
474415}
475416
476- /** @brief Encrypt plain and write resulting DHT packet into packet with max size length.
477- *
478- * @return size of packet on success.
479- * @retval -1 on failure.
480- */
481417int dht_create_packet (const Random * rng , const uint8_t public_key [CRYPTO_PUBLIC_KEY_SIZE ],
482418 const uint8_t * shared_key , const uint8_t type ,
483419 const uint8_t * plain , size_t plain_length ,
@@ -513,13 +449,6 @@ int dht_create_packet(const Random *rng, const uint8_t public_key[CRYPTO_PUBLIC_
513449 return 1 + CRYPTO_PUBLIC_KEY_SIZE + CRYPTO_NONCE_SIZE + encrypted_length ;
514450}
515451
516- /** @brief Unpack IP_Port structure from data of max size length into ip_port.
517- *
518- * len_processed is the offset of data currently unpacked.
519- *
520- * @return size of unpacked ip_port on success.
521- * @retval -1 on failure.
522- */
523452int unpack_ip_port (IP_Port * ip_port , const uint8_t * data , uint16_t length , bool tcp_enabled )
524453{
525454 if (data == nullptr ) {
@@ -580,11 +509,6 @@ int unpack_ip_port(IP_Port *ip_port, const uint8_t *data, uint16_t length, bool
580509 }
581510}
582511
583- /** @brief Pack number of nodes into data of maxlength length.
584- *
585- * @return length of packed nodes on success.
586- * @retval -1 on failure.
587- */
588512int pack_nodes (const Logger * logger , uint8_t * data , uint16_t length , const Node_format * nodes , uint16_t number )
589513{
590514 uint32_t packed_length = 0 ;
@@ -614,13 +538,6 @@ int pack_nodes(const Logger *logger, uint8_t *data, uint16_t length, const Node_
614538 return packed_length ;
615539}
616540
617- /** @brief Unpack data of length into nodes of size max_num_nodes.
618- * Put the length of the data processed in processed_data_len.
619- * tcp_enabled sets if TCP nodes are expected (true) or not (false).
620- *
621- * @return number of unpacked nodes on success.
622- * @retval -1 on failure.
623- */
624541int unpack_nodes (Node_format * nodes , uint16_t max_num_nodes , uint16_t * processed_data_len , const uint8_t * data ,
625542 uint16_t length , bool tcp_enabled )
626543{
@@ -2043,11 +1960,6 @@ int dht_bootstrap_from_address(DHT *dht, const char *address, bool ipv6enabled,
20431960 return 0 ;
20441961}
20451962
2046- /** @brief Send the given packet to node with public_key.
2047- *
2048- * @return number of bytes sent.
2049- * @retval -1 if failure.
2050- */
20511963int route_packet (const DHT * dht , const uint8_t * public_key , const uint8_t * packet , uint16_t length )
20521964{
20531965 for (uint32_t i = 0 ; i < LCLIENT_LIST ; ++ i ) {
@@ -2923,11 +2835,6 @@ void dht_save(const DHT *dht, uint8_t *data)
29232835/** Bootstrap from this number of nodes every time `dht_connect_after_load()` is called */
29242836#define SAVE_BOOTSTAP_FREQUENCY 8
29252837
2926- /** @brief Start sending packets after DHT loaded_friends_list and loaded_clients_list are set.
2927- *
2928- * @retval 0 if successful
2929- * @retval -1 otherwise
2930- */
29312838int dht_connect_after_load (DHT * dht )
29322839{
29332840 if (dht == nullptr ) {
@@ -2997,11 +2904,6 @@ static State_Load_Status dht_load_state_callback(void *outer, const uint8_t *dat
29972904 return STATE_LOAD_STATUS_CONTINUE ;
29982905}
29992906
3000- /** @brief Load the DHT from data of size size.
3001- *
3002- * @retval -1 if failure.
3003- * @retval 0 if success.
3004- */
30052907int dht_load (DHT * dht , const uint8_t * data , uint32_t length )
30062908{
30072909 const uint32_t cookie_len = sizeof (uint32_t );
@@ -3060,16 +2962,6 @@ bool dht_non_lan_connected(const DHT *dht)
30602962 return false;
30612963}
30622964
3063- /** @brief Copies our own ip_port structure to `dest`.
3064- *
3065- * WAN addresses take priority over LAN addresses.
3066- *
3067- * This function will zero the `dest` buffer before use.
3068- *
3069- * @retval 0 if our ip port can't be found (this usually means we're not connected to the DHT).
3070- * @retval 1 if IP is a WAN address.
3071- * @retval 2 if IP is a LAN address.
3072- */
30732965unsigned int ipport_self_copy (const DHT * dht , IP_Port * dest )
30742966{
30752967 ipport_reset (dest );
0 commit comments