1 /*
2     SPDX-FileCopyrightText: 2005 Joris Guisson <joris.guisson@gmail.com>
3 
4     SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 #ifndef BTCONSTANTS_H
7 #define BTCONSTANTS_H
8 
9 #include <QtGlobal>
10 
11 namespace bt
12 {
13 typedef quint64 Uint64;
14 typedef quint32 Uint32;
15 typedef quint16 Uint16;
16 typedef quint8 Uint8;
17 
18 typedef qint64 Int64;
19 typedef qint32 Int32;
20 typedef qint16 Int16;
21 typedef qint8 Int8;
22 
23 typedef Uint64 TimeStamp;
24 
25 typedef enum {
26     // also leave some room if we want to add new priorities in the future
27     FIRST_PREVIEW_PRIORITY = 55,
28     FIRST_PRIORITY = 50,
29     NORMAL_PREVIEW_PRIORITY = 45,
30     NORMAL_PRIORITY = 40,
31     LAST_PREVIEW_PRIORITY = 35,
32     LAST_PRIORITY = 30,
33     ONLY_SEED_PRIORITY = 20,
34     EXCLUDED = 10,
35 } Priority;
36 
37 enum ConfirmationResult {
38     KEEP_DATA,
39     THROW_AWAY_DATA,
40     CANCELED,
41 };
42 
43 const Uint32 MAX_MSGLEN = 9 + 131072;
44 const Uint16 MIN_PORT = 6881;
45 const Uint16 MAX_PORT = 6889;
46 const Uint32 MAX_PIECE_LEN = 16384;
47 
48 const Uint8 CHOKE = 0;
49 const Uint8 UNCHOKE = 1;
50 const Uint8 INTERESTED = 2;
51 const Uint8 NOT_INTERESTED = 3;
52 const Uint8 HAVE = 4;
53 const Uint8 BITFIELD = 5;
54 const Uint8 REQUEST = 6;
55 const Uint8 PIECE = 7;
56 const Uint8 CANCEL = 8;
57 const Uint8 PORT = 9;
58 const Uint8 SUGGEST_PIECE = 13;
59 const Uint8 HAVE_ALL = 14;
60 const Uint8 HAVE_NONE = 15;
61 const Uint8 REJECT_REQUEST = 16;
62 const Uint8 ALLOWED_FAST = 17;
63 const Uint8 EXTENDED = 20; // extension protocol message
64 
65 // flags for things which a peer supports
66 const Uint32 DHT_SUPPORT = 0x01;
67 const Uint32 EXT_PROT_SUPPORT = 0x10;
68 const Uint32 FAST_EXT_SUPPORT = 0x04;
69 
70 enum TransportProtocol { TCP, UTP };
71 }
72 
73 #endif
74