2 // This file is part of the aMule Project.
4 // Copyright (c) 2004-2011 Angel Vidal ( kry@amule.org )
5 // Copyright (c) 2004-2011 aMule Team ( admin@amule.org / http://www.amule.org )
6 // Copyright (c) 2003-2011 Barry Dunne (http://www.emule-project.net)
8 // Any parts of this program derived from the xMule, lMule or eMule project,
9 // or contributed by third-party developers are copyrighted by their
10 // respective authors.
12 // This program is free software; you can redistribute it and/or modify
13 // it under the terms of the GNU General Public License as published by
14 // the Free Software Foundation; either version 2 of the License, or
15 // (at your option) any later version.
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
22 // You should have received a copy of the GNU General Public License
23 // along with this program; if not, write to the Free Software
24 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
29 Please do not change anything here and release it..
30 There is going to be a new forum created just for the Kademlia side of the client..
31 If you feel there is an error or a way to improve something, please
32 post it in the forum first and let us look at it.. If it is a real improvement,
33 it will be added to the offical client.. Changing something without knowing
34 what all it does can cause great harm to the network if released in mass form..
35 Any mod that changes anything within the Kademlia side will not be allowed to advertise
36 there client on the eMule forum..
42 #include "../kademlia/Kademlia.h"
43 #include "../utils/KadUDPKey.h"
45 ////////////////////////////////////////
47 ////////////////////////////////////////
53 CContact(const CUInt128
&clientID
,
54 uint32_t ip
, uint16_t udpPort
, uint16_t tcpPort
, uint8_t version
,
55 const CKadUDPKey
& kadKey
, bool ipVerified
,
56 const CUInt128
&target
= CKademlia::GetPrefs()->GetKadID());
58 CContact(const CContact
& k1
);
60 const CUInt128
& GetClientID() const throw() { return m_clientID
; }
61 void SetClientID(const CUInt128
& clientID
) throw() { m_clientID
= clientID
; m_distance
= CKademlia::GetPrefs()->GetKadID() ^ clientID
; }
63 const wxString
GetClientIDString() const { return m_clientID
.ToHexString(); }
65 const CUInt128
& GetDistance() const throw() { return m_distance
; }
66 const wxString
GetDistanceString() const { return m_distance
.ToBinaryString(); }
68 uint32_t GetIPAddress() const throw() { return m_ip
; }
69 void SetIPAddress(uint32_t ip
) throw() { if (m_ip
!= ip
) { SetIPVerified(false); m_ip
= ip
; } }
71 uint16_t GetTCPPort() const throw() { return m_tcpPort
; }
72 void SetTCPPort(uint16_t port
) throw() { m_tcpPort
= port
; }
74 uint16_t GetUDPPort() const throw() { return m_udpPort
; }
75 void SetUDPPort(uint16_t port
) throw() { m_udpPort
= port
; }
77 uint8_t GetType() const throw() { return m_type
; }
79 void UpdateType() throw();
80 void CheckingType() throw();
82 bool InUse() const throw() { return m_inUse
> 0; }
83 void IncUse() throw() { m_inUse
++; }
84 void DecUse() { if (m_inUse
) m_inUse
--; else { wxFAIL
; } }
86 time_t GetCreatedTime() const throw() { return m_created
; }
88 void SetExpireTime(time_t value
) throw() { m_expires
= value
; };
89 time_t GetExpireTime() const throw() { return m_expires
; }
91 time_t GetLastTypeSet() const throw() { return m_lastTypeSet
; }
93 time_t GetLastSeen() const throw();
95 uint8_t GetVersion() const throw() { return m_version
; }
96 void SetVersion(uint8_t value
) throw() { m_version
= value
; }
98 const CKadUDPKey
& GetUDPKey() const throw() { return m_udpKey
; }
99 void SetUDPKey(const CKadUDPKey
& key
) throw() { m_udpKey
= key
; }
101 bool IsIPVerified() const throw() { return m_ipVerified
; }
102 void SetIPVerified(bool ipVerified
) throw() { m_ipVerified
= ipVerified
; }
104 bool GetReceivedHelloPacket() const throw() { return m_receivedHelloPacket
; }
105 void SetReceivedHelloPacket() throw() { m_receivedHelloPacket
= true; }
114 time_t m_lastTypeSet
;
120 bool m_receivedHelloPacket
;
126 #endif // __CONTACT_H__
127 // File_checked_for_headers