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
25 #include "ECPacket.h" // Needed for ECPacket
26 #include "ECSocket.h" // Needed for CECSocket
28 /**********************************************************
32 **********************************************************/
34 bool CECPacket::ReadFromSocket(CECSocket
& socket
)
36 if (m_state
== bsName
) {
37 if (!socket
.ReadNumber(&m_opCode
, sizeof(ec_opcode_t
))) {
43 if (m_state
== bsChildCnt
|| m_state
== bsChildren
) {
44 if (!ReadChildren(socket
)) {
53 bool CECPacket::WritePacket(CECSocket
& socket
) const
55 if (!socket
.WriteNumber(&m_opCode
, sizeof(ec_opcode_t
))) return false;
56 if (!WriteChildren(socket
)) return false;
61 #include <common/Format.h> // Needed for CFormat
62 void CECPacket::DebugPrint(bool incoming
) const
64 wxString
GetDebugNameECOpCodes(uint8 arg
);
66 if (ECLogIsEnabled()) {
67 DoECLogLine(CFormat(wxT("%s %s %d")) % (incoming
? wxT("<") : wxT(">"))
68 % GetDebugNameECOpCodes(m_opCode
) % GetPacketLength());
69 CECTag::DebugPrint(1, false);
73 void CECPacket::DebugPrint(bool) const {}
77 * \fn CECPacket::CECPacket(ec_opcode_t opCode, EC_DETAIL_LEVEL detail_level)
79 * \brief Creates a new packet with given OPCODE.
83 * \fn ec_opcode_t CECPacket::GetOpCode(void) const
85 * \brief Returns OPCODE.
87 * \return The OpCode of the packet.
91 * \fn uint32 CECPacket::GetPacketLength(void) const
93 * \brief Returns the length of the packet.
95 * \return The length of the packet.
97 // File_checked_for_headers