2 // This file is part of the aMule Project.
4 // Copyright (c) 2003-2008 aMule Team ( admin@amule.org / http://www.amule.org )
5 // Copyright (c) 2002 Merkur ( devs@emule-project.net / http://www.emule-project.net )
7 // Any parts of this program derived from the xMule, lMule or eMule project,
8 // or contributed by third-party developers are copyrighted by their
11 // This program is free software; you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation; either version 2 of the License, or
14 // (at your option) any later version.
16 // This program is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU General Public License for more details.
21 // You should have received a copy of the GNU General Public License
22 // along with this program; if not, write to the Free Software
23 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
29 #include "Types.h" // Needed for int8, int32, uint8 and uint32
37 // TODO some parts could need some work to make it more efficient
42 CPacket(uint8 protocol
);
43 CPacket(byte
* header
); // only used for receiving packets
44 CPacket(const CMemFile
& datafile
, uint8 protocol
, uint8 ucOpcode
);
45 CPacket(int8 in_opcode
, uint32 in_size
, uint8 protocol
, bool bFromPF
= true);
46 CPacket(byte
* pPacketPart
, uint32 nSize
, bool bLast
, bool bFromPF
= true); // only used for splitted packets!
50 void AllocDataBuffer();
55 uint32
GetRealPacketSize() const { return size
+ 6; }
56 bool IsSplitted() { return m_bSplitted
; }
57 bool IsLastSplitted() { return m_bLastSplitted
; }
59 bool UnPackPacket(uint32 uMaxDecompressedSize
= 50000);
60 // -khaos--+++> Returns either -1, 0 or 1. -1 is unset, 0 is from complete file, 1 is from part file
61 bool IsFromPF() { return m_bFromPF
; }
63 uint8
GetOpCode() const { return opcode
; }
64 void SetOpCode(uint8 oc
) { opcode
= oc
; }
65 uint32
GetPacketSize() const { return size
; }
66 uint8
GetProtocol() const { return prot
; }
67 void SetProtocol(uint8 p
) { prot
= p
; }
68 const byte
* GetDataBuffer(void) const { return pBuffer
; }
69 void Copy16ToDataBuffer(const void* data
);
70 void CopyToDataBuffer(unsigned int offset
, const byte
* data
, unsigned int n
);
71 void CopyUInt32ToDataBuffer(uint32 data
, unsigned int offset
= 0);
74 //! CPacket is not assignable.
75 CPacket
& operator=(const CPacket
&);
91 // File_checked_for_headers