Upstream tarball 20080304
[amule.git] / src / kademlia / net / KademliaUDPListener.h
blobd0175a25f8b058e779251eb9eb87daf30623269b
1 //
2 // This file is part of the aMule Project.
3 //
4 // Copyright (c) 2004-2008 Angel Vidal (Kry) ( kry@amule.org )
5 // Copyright (c) 2004-2008 aMule Team ( admin@amule.org / http://www.amule.org )
6 // Copyright (c) 2003 Barry Dunne (http://www.emule-project.net)
7 //
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.
21 //
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
27 // Note To Mods //
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..
39 #ifndef __KAD_UDP_LISTENER_H__
40 #define __KAD_UDP_LISTENER_H__
42 #include "../utils/UInt128.h"
43 #include "../../Tag.h"
45 class CKnownFile;
46 class CMemFile;
47 struct SSearchTerm;
49 ////////////////////////////////////////
50 namespace Kademlia {
51 ////////////////////////////////////////
53 class CSearch;
55 class CKademliaUDPListener
57 friend class CSearch;
59 public:
60 virtual ~CKademliaUDPListener() {};
61 void Bootstrap(uint32 ip, uint16 port);
62 void FirewalledCheck(uint32 ip, uint16 port);
63 void SendMyDetails(byte opcode, uint32 ip, uint16 port);
64 void PublishPacket(uint32 ip, uint16 port, const CUInt128& targetID, const CUInt128& contactID, const TagPtrList& tags);
65 void SendNullPacket(byte opcode, uint32 ip, uint16 port);
66 virtual void ProcessPacket(const byte* data, uint32 lenData, uint32 ip, uint16 port);
67 void SendPacket(const CMemFile& data, byte opcode, uint32 destinationHost, uint16 destinationPort);
69 private:
70 void AddContact (const byte* data, uint32 lenData, uint32 ip, uint16 port, uint16 tport = 0);
71 void AddContacts(const byte* data, uint32 lenData, uint16 numContacts);
72 static SSearchTerm* CreateSearchExpressionTree(CMemFile& bio, int iLevel);
73 static void Free(SSearchTerm* pSearchTerms);
75 void ProcessBootstrapRequest (const byte* packetData, uint32 lenPacket, uint32 ip, uint16 port);
76 void ProcessBootstrapResponse (const byte* packetData, uint32 lenPacket, uint32 ip, uint16 port);
77 void ProcessHelloRequest (const byte* packetData, uint32 lenPacket, uint32 ip, uint16 port);
78 void ProcessHelloResponse (const byte* packetData, uint32 lenPacket, uint32 ip, uint16 port);
79 void ProcessKademliaRequest (const byte* packetData, uint32 lenPacket, uint32 ip, uint16 port);
80 void ProcessKademliaResponse (const byte* packetData, uint32 lenPacket, uint32 ip, uint16 port);
81 void ProcessSearchRequest (const byte* packetData, uint32 lenPacket, uint32 ip, uint16 port);
82 void ProcessSearchResponse (const byte* packetData, uint32 lenPacket, uint32 ip, uint16 port);
83 void ProcessPublishRequest (const byte* packetData, uint32 lenPacket, uint32 ip, uint16 port);
84 void ProcessPublishResponse (const byte* packetData, uint32 lenPacket, uint32 ip, uint16 port);
85 void ProcessSearchNotesRequest (const byte* packetData, uint32 lenPacket, uint32 ip, uint16 port);
86 void ProcessSearchNotesResponse (const byte* packetData, uint32 lenPacket, uint32 ip, uint16 port);
87 void ProcessPublishNotesRequest (const byte* packetData, uint32 lenPacket, uint32 ip, uint16 port);
88 void ProcessPublishNotesResponse (const byte* packetData, uint32 lenPacket, uint32 ip, uint16 port);
89 void ProcessFirewalledRequest (const byte* packetData, uint32 lenPacket, uint32 ip, uint16 port);
90 void ProcessFirewalledResponse (const byte* packetData, uint32 lenPacket, uint32 ip, uint16 port);
91 void ProcessFirewalledResponse2 (const byte* packetData, uint32 lenPacket, uint32 ip, uint16 port);
92 void ProcessFindBuddyRequest (const byte* packetData, uint32 lenPacket, uint32 ip, uint16 port);
93 void ProcessFindBuddyResponse (const byte* packetData, uint32 lenPacket, uint32 ip, uint16 port);
94 void ProcessCallbackRequest (const byte* packetData, uint32 lenPacket, uint32 ip, uint16 port);
96 void DebugClientOutput(const wxString& place, uint32 kad_ip, uint32 port, const byte* data = NULL, int len = 0);
99 } // End namespace
101 #endif //__KAD_UDP_LISTENER_H__
102 // File_checked_for_headers