2 // This file is part of the aMule Project.
4 // Copyright (c) 2008-2011 Dévai Tamás ( gonosztopi@amule.org )
5 // Copyright (c) 2008-2011 aMule Team ( admin@amule.org / http://www.amule.org )
6 // Copyright (c) 2002-2011 Merkur ( devs@emule-project.net / 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
27 #ifndef KADEMLIA_NET_PACKETTRACKING_H
28 #define KADEMLIA_NET_PACKETTRACKING_H
32 #include "../utils/UInt128.h"
33 #include "../../Types.h"
38 struct TrackPackets_Struct
{
44 struct TrackChallenge_Struct
{
52 struct TrackPacketsIn_Struct
{
53 struct TrackedRequestIn_Struct
{
55 uint32_t m_firstAdded
;
60 TrackPacketsIn_Struct()
67 uint32_t m_lastExpire
;
68 typedef std::list
<TrackedRequestIn_Struct
> TrackedRequestList
;
69 TrackedRequestList m_trackedRequests
;
75 CPacketTracking() throw() { lastTrackInCleanup
= 0; }
76 virtual ~CPacketTracking();
79 void AddTrackedOutPacket(uint32_t ip
, uint8_t opcode
);
80 bool IsOnOutTrackList(uint32_t ip
, uint8_t opcode
, bool dontRemove
= false);
81 bool InTrackListIsAllowedPacket(uint32_t ip
, uint8_t opcode
, bool validReceiverkey
);
82 void InTrackListCleanup();
83 void AddLegacyChallenge(const CUInt128
& contactID
, const CUInt128
& challengeID
, uint32_t ip
, uint8_t opcode
);
84 bool IsLegacyChallenge(const CUInt128
& challengeID
, uint32_t ip
, uint8_t opcode
, CUInt128
& contactID
);
85 bool HasActiveLegacyChallenge(uint32_t ip
) const;
88 static bool IsTrackedOutListRequestPacket(uint8_t opcode
) throw();
89 typedef std::list
<TrackPackets_Struct
> TrackedPacketList
;
90 typedef std::list
<TrackChallenge_Struct
> TrackChallengeList
;
91 typedef std::map
<uint32_t, TrackPacketsIn_Struct
*> TrackedPacketInMap
;
92 TrackedPacketList listTrackedRequests
;
93 TrackChallengeList listChallengeRequests
;
94 TrackedPacketInMap m_mapTrackPacketsIn
;
95 uint32_t lastTrackInCleanup
;
98 } // namespace Kademlia
100 #endif /* KADEMLIA_NET_PACKETTRACKING_H */