File indexing completed on 2025-01-05 04:37:11
0001 /* 0002 SPDX-FileCopyrightText: 2005 Joris Guisson <joris.guisson@gmail.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 #ifndef DHTPACK_H 0007 #define DHTPACK_H 0008 0009 #include "kbucket.h" 0010 0011 namespace dht 0012 { 0013 /** 0014 * Pack a KBucketEntry into a byte array. 0015 * If the array is not large enough, an error will be thrown 0016 * @param e The entry 0017 * @param ba The byte array 0018 * @param off The offset into the array 0019 */ 0020 void PackBucketEntry(const KBucketEntry &e, QByteArray &ba, bt::Uint32 off); 0021 0022 /** 0023 * Unpack a KBucketEntry from a byte array. 0024 * If a full entry cannot be read an error will be thrown. 0025 * @param ba The byte array 0026 * @param off The offset 0027 * @param ip_version The ip version (4 or 6) 0028 * @return The entry 0029 */ 0030 KBucketEntry UnpackBucketEntry(const QByteArray &ba, bt::Uint32 off, int ip_version); 0031 0032 } 0033 0034 #endif