libktorrent  2.1.1
constants.h
1 /***************************************************************************
2  * Copyright (C) 2005 by Joris Guisson *
3  * joris.guisson@gmail.com *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19  ***************************************************************************/
20 #ifndef BTCONSTANTS_H
21 #define BTCONSTANTS_H
22 
23 #include <QtGlobal>
24 
25 namespace bt
26 {
27  typedef quint64 Uint64;
28  typedef quint32 Uint32;
29  typedef quint16 Uint16;
30  typedef quint8 Uint8;
31 
32  typedef qint64 Int64;
33  typedef qint32 Int32;
34  typedef qint16 Int16;
35  typedef qint8 Int8;
36 
37  typedef Uint64 TimeStamp;
38 
39  typedef enum
40  {
41  // also leave some room if we want to add new priorities in the future
42  PREVIEW_PRIORITY = 60,
43  FIRST_PRIORITY = 50,
44  NORMAL_PRIORITY = 40,
45  LAST_PRIORITY = 30,
46  ONLY_SEED_PRIORITY = 20,
47  EXCLUDED = 10
48  }Priority;
49 
50  enum ConfirmationResult
51  {
52  KEEP_DATA,
53  THROW_AWAY_DATA,
54  CANCELED
55  };
56 
57  const Uint32 MAX_MSGLEN = 9 + 131072;
58  const Uint16 MIN_PORT = 6881;
59  const Uint16 MAX_PORT = 6889;
60  const Uint32 MAX_PIECE_LEN = 16384;
61 
62  const Uint8 CHOKE = 0;
63  const Uint8 UNCHOKE = 1;
64  const Uint8 INTERESTED = 2;
65  const Uint8 NOT_INTERESTED = 3;
66  const Uint8 HAVE = 4;
67  const Uint8 BITFIELD = 5;
68  const Uint8 REQUEST = 6;
69  const Uint8 PIECE = 7;
70  const Uint8 CANCEL = 8;
71  const Uint8 PORT = 9;
72  const Uint8 SUGGEST_PIECE = 13;
73  const Uint8 HAVE_ALL = 14;
74  const Uint8 HAVE_NONE = 15;
75  const Uint8 REJECT_REQUEST = 16;
76  const Uint8 ALLOWED_FAST = 17;
77  const Uint8 EXTENDED = 20; // extension protocol message
78 
79 
80  // flags for things which a peer supports
81  const Uint32 DHT_SUPPORT = 0x01;
82  const Uint32 EXT_PROT_SUPPORT = 0x10;
83  const Uint32 FAST_EXT_SUPPORT = 0x04;
84 
85  enum TransportProtocol
86  {
87  TCP,
88  UTP
89  };
90 }
91 
92 
93 #endif