2 // This file is part of the aMule Project.
4 // Copyright (c) 2004-2008 aMule Team ( admin@amule.org / http://www.amule.org )
6 // Any parts of this program derived from the xMule, lMule or eMule project,
7 // or contributed by third-party developers are copyrighted by their
10 // This program is free software; you can redistribute it and/or modify
11 // it under the terms of the GNU General Public License as published by
12 // the Free Software Foundation; either version 2 of the License, or
13 // (at your option) any later version.
15 // This program is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
20 // You should have received a copy of the GNU General Public License
21 // along with this program; if not, write to the Free Software
22 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
30 // Define this to keep partial packets
31 // (those that had an error upon reception/creation)
32 #undef KEEP_PARTIAL_PACKETS
37 * High level EC packet handler class
39 class CECPacket
: protected CECEmptyTag
{
40 friend class CECSocket
;
42 CECPacket(ec_opcode_t opCode
, EC_DETAIL_LEVEL detail_level
= EC_DETAIL_FULL
)
43 : CECEmptyTag(0), m_opCode(opCode
)
45 // since EC_DETAIL_FULL is default - no point transmit it
46 if ( detail_level
!= EC_DETAIL_FULL
) {
47 AddTag(CECTag(EC_TAG_DETAIL_LEVEL
, (uint64
)detail_level
));
52 using CECTag::GetTagByIndex
;
53 using CECTag::GetTagByIndexSafe
;
54 using CECTag::GetTagByName
;
55 using CECTag::GetTagByNameSafe
;
56 using CECTag::GetTagCount
;
58 ec_opcode_t
GetOpCode(void) const { return m_opCode
; }
59 uint32_t GetPacketLength(void) const { return CECTag::GetTagLen(); }
60 EC_DETAIL_LEVEL
GetDetailLevel() const
62 const CECTag
*tag
= GetTagByName(EC_TAG_DETAIL_LEVEL
);
63 return (tag
) ? (EC_DETAIL_LEVEL
)tag
->GetInt() : EC_DETAIL_FULL
;
65 void DebugPrint(bool incoming
) const;
68 CECPacket(const CECSocket
& socket
)
72 bool ReadFromSocket(CECSocket
& socket
);
73 bool WritePacket(CECSocket
& socket
) const;
77 bool ECLogIsEnabled();
78 void DoECLogLine(const wxString
&line
);
80 #endif /* ECPACKET_H */
81 // File_checked_for_headers