Always include the boost-package. Otherwise it won't get searched on a second run.
[amule.git] / src / ClientCredits.h
blob2c44818d01314b2f460920a437409b4029d7d934
1 //
2 // This file is part of the aMule Project.
3 //
4 // Copyright (c) 2003-2011 aMule Team ( admin@amule.org / http://www.amule.org )
5 // Copyright (c) 2002-2011 Merkur ( devs@emule-project.net / http://www.emule-project.net )
6 //
7 // Any parts of this program derived from the xMule, lMule or eMule project,
8 // or contributed by third-party developers are copyrighted by their
9 // respective authors.
11 // This program is free software; you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation; either version 2 of the License, or
14 // (at your option) any later version.
16 // This program is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU General Public License for more details.
21 // You should have received a copy of the GNU General Public License
22 // along with this program; if not, write to the Free Software
23 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #ifndef CLIENTCREDITS_H
27 #define CLIENTCREDITS_H
29 #include "MD4Hash.h" // Needed for CMD4Hash
31 #define MAXPUBKEYSIZE 80
33 #define CRYPT_CIP_REMOTECLIENT 10
34 #define CRYPT_CIP_LOCALCLIENT 20
35 #define CRYPT_CIP_NONECLIENT 30
37 class CreditStruct
39 public:
40 CreditStruct();
42 CMD4Hash key;
43 uint64 uploaded; // uploaded TO him
44 uint64 downloaded; // downloaded from him
45 uint32 nLastSeen;
46 uint16 nReserved3;
47 uint8 nKeySize;
48 uint8_t abySecureIdent[MAXPUBKEYSIZE];
51 enum EIdentState{
52 IS_NOTAVAILABLE,
53 IS_IDNEEDED,
54 IS_IDENTIFIED,
55 IS_IDFAILED,
56 IS_IDBADGUY
59 class CClientCredits
62 public:
63 CClientCredits(CreditStruct* in_credits);
64 CClientCredits(const CMD4Hash& key);
65 ~CClientCredits();
67 const CMD4Hash& GetKey() const {return m_pCredits->key;}
68 const uint8_t* GetSecureIdent() const {return m_abyPublicKey;}
69 uint8 GetSecIDKeyLen() const {return m_nPublicKeyLen;}
70 const CreditStruct* GetDataStruct() const {return m_pCredits;}
71 void ClearWaitStartTime();
72 void AddDownloaded(uint32 bytes, uint32 dwForIP, bool cryptoavail);
73 void AddUploaded(uint32 bytes, uint32 dwForIP, bool cryptoavail);
74 uint64 GetUploadedTotal() const;
75 uint64 GetDownloadedTotal() const;
76 float GetScoreRatio(uint32 dwForIP, bool cryptoavail);
77 void SetLastSeen();
78 bool SetSecureIdent(const uint8_t* pachIdent, uint8 nIdentLen); // Public key cannot change, use only if there is not public key yet
79 uint32 m_dwCryptRndChallengeFor;
80 uint32 m_dwCryptRndChallengeFrom;
81 EIdentState GetCurrentIdentState(uint32 dwForIP) const; // can be != m_identState
82 uint32 GetSecureWaitStartTime(uint32 dwForIP);
83 void SetSecWaitStartTime(uint32 dwForIP);
84 void Verified(uint32 dwForIP);
85 EIdentState GetIdentState() const { return m_identState; }
86 void SetIdentState(EIdentState state) { m_identState = state; }
88 private:
89 EIdentState m_identState;
90 void InitalizeIdent();
91 CreditStruct* m_pCredits;
92 uint8_t m_abyPublicKey[80]; // even keys which are not verified will be stored here, and - if verified - copied into the struct
93 uint8 m_nPublicKeyLen;
94 uint32 m_dwIdentIP;
95 uint32 m_dwSecureWaitTime;
96 uint32 m_dwUnSecureWaitTime;
97 uint32 m_dwWaitTimeIP; // client IP assigned to the waittime
100 #endif // CLIENTCREDITS_H
101 // File_checked_for_headers