2 // This file is part of the aMule Project.
4 // Copyright (c) 2003-2008 aMule Team ( admin@amule.org / http://www.amule.org )
5 // Copyright (c) 2002 Merkur ( devs@emule-project.net / http://www.emule-project.net )
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
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
45 uint64 uploaded
; // uploaded TO him
46 uint64 downloaded
; // downloaded from him
50 byte abySecureIdent
[MAXPUBKEYSIZE
];
56 __attribute__((__packed__
));
71 CClientCredits(CreditStruct
* in_credits
);
72 CClientCredits(const CMD4Hash
& key
);
75 const CMD4Hash
& GetKey() const {return m_pCredits
->key
;}
76 const byte
* GetSecureIdent() const {return m_abyPublicKey
;}
77 uint8
GetSecIDKeyLen() const {return m_nPublicKeyLen
;}
78 const CreditStruct
* GetDataStruct() const {return m_pCredits
;}
79 void ClearWaitStartTime();
80 void AddDownloaded(uint32 bytes
, uint32 dwForIP
, bool cryptoavail
);
81 void AddUploaded(uint32 bytes
, uint32 dwForIP
, bool cryptoavail
);
82 uint64
GetUploadedTotal() const;
83 uint64
GetDownloadedTotal() const;
84 float GetScoreRatio(uint32 dwForIP
, bool cryptoavail
);
86 bool SetSecureIdent(const byte
* pachIdent
, uint8 nIdentLen
); // Public key cannot change, use only if there is not public key yet
87 uint32 m_dwCryptRndChallengeFor
;
88 uint32 m_dwCryptRndChallengeFrom
;
89 EIdentState
GetCurrentIdentState(uint32 dwForIP
) const; // can be != m_identState
90 uint32
GetSecureWaitStartTime(uint32 dwForIP
);
91 void SetSecWaitStartTime(uint32 dwForIP
);
92 void Verified(uint32 dwForIP
);
93 EIdentState
GetIdentState() const { return m_identState
; }
94 void SetIdentState(EIdentState state
) { m_identState
= state
; }
97 EIdentState m_identState
;
98 void InitalizeIdent();
99 CreditStruct
* m_pCredits
;
100 byte m_abyPublicKey
[80]; // even keys which are not verified will be stored here, and - if verified - copied into the struct
101 uint8 m_nPublicKeyLen
;
104 uint32 m_dwSecureWaitTime
;
105 uint32 m_dwUnSecureWaitTime
;
106 uint32 m_dwWaitTimeIP
; // client IP assigned to the waittime
109 #endif // CLIENTCREDITS_H
110 // File_checked_for_headers