summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2018-01-13 20:57:18 +0000
committeriphydf <iphydf@users.noreply.github.com>2018-01-16 10:43:18 +0000
commitb3ec05543acdc0019b545de170720dc32d8f28d3 (patch)
tree649d87a6150ad0617361f0c50342c138015d91d6
parent6fc0be514250fd8990c4393097002ad2b0101232 (diff)
Make pack/unpack_ip_port public DHT functions.
These will be needed for new group chats.
-rw-r--r--toxcore/DHT.c4
-rw-r--r--toxcore/DHT.h14
2 files changed, 16 insertions, 2 deletions
diff --git a/toxcore/DHT.c b/toxcore/DHT.c
index 8eaf7a4d..41c24ac0 100644
--- a/toxcore/DHT.c
+++ b/toxcore/DHT.c
@@ -286,7 +286,7 @@ int packed_node_size(uint8_t ip_family)
286 * Returns size of packed IP_Port data on success 286 * Returns size of packed IP_Port data on success
287 * Return -1 on failure. 287 * Return -1 on failure.
288 */ 288 */
289static int pack_ip_port(uint8_t *data, uint16_t length, const IP_Port *ip_port) 289int pack_ip_port(uint8_t *data, uint16_t length, const IP_Port *ip_port)
290{ 290{
291 if (data == NULL) { 291 if (data == NULL) {
292 return -1; 292 return -1;
@@ -364,7 +364,7 @@ static int DHT_create_packet(const uint8_t public_key[CRYPTO_PUBLIC_KEY_SIZE],
364 * Return size of unpacked ip_port on success. 364 * Return size of unpacked ip_port on success.
365 * Return -1 on failure. 365 * Return -1 on failure.
366 */ 366 */
367static int unpack_ip_port(IP_Port *ip_port, const uint8_t *data, uint16_t length, uint8_t tcp_enabled) 367int unpack_ip_port(IP_Port *ip_port, const uint8_t *data, uint16_t length, uint8_t tcp_enabled)
368{ 368{
369 if (data == NULL) { 369 if (data == NULL) {
370 return -1; 370 return -1;
diff --git a/toxcore/DHT.h b/toxcore/DHT.h
index 624bc690..8fdd80b0 100644
--- a/toxcore/DHT.h
+++ b/toxcore/DHT.h
@@ -180,6 +180,20 @@ typedef struct {
180 */ 180 */
181int packed_node_size(uint8_t ip_family); 181int packed_node_size(uint8_t ip_family);
182 182
183/* Packs an IP_Port structure into data of max size length.
184 *
185 * Returns size of packed IP_Port data on success
186 * Return -1 on failure.
187 */
188int pack_ip_port(uint8_t *data, uint16_t length, const IP_Port *ip_port);
189
190/* Unpack IP_Port structure from data of max size length into ip_port.
191 *
192 * Return size of unpacked ip_port on success.
193 * Return -1 on failure.
194 */
195int unpack_ip_port(IP_Port *ip_port, const uint8_t *data, uint16_t length, uint8_t tcp_enabled);
196
183/* Pack number of nodes into data of maxlength length. 197/* Pack number of nodes into data of maxlength length.
184 * 198 *
185 * return length of packed nodes on success. 199 * return length of packed nodes on success.