3 // This file is part of the aMule Project.
5 // Copyright (c) 2003-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
30 #include "Types.h" // Needed for int8, int32, uint8 and uint32
38 // TODO some parts could need some work to make it more efficient
43 CPacket(uint8 protocol
);
44 CPacket(byte
* header
, byte
*buf
); // only used for receiving packets
45 CPacket(const CMemFile
& datafile
, uint8 protocol
, uint8 ucOpcode
);
46 CPacket(int8 in_opcode
, uint32 in_size
, uint8 protocol
, bool bFromPF
= true);
47 CPacket(byte
* pPacketPart
, uint32 nSize
, bool bLast
, bool bFromPF
= true); // only used for splitted packets!
55 uint32
GetRealPacketSize() const { return size
+ 6; }
56 static uint32
GetPacketSizeFromHeader(const byte
* rawHeader
);
57 bool IsSplitted() { return m_bSplitted
; }
58 bool IsLastSplitted() { return m_bLastSplitted
; }
60 bool UnPackPacket(uint32 uMaxDecompressedSize
= 50000);
61 // -khaos--+++> Returns either -1, 0 or 1. -1 is unset, 0 is from complete file, 1 is from part file
62 bool IsFromPF() { return m_bFromPF
; }
64 uint8
GetOpCode() const { return opcode
; }
65 void SetOpCode(uint8 oc
) { opcode
= oc
; }
66 uint32
GetPacketSize() const { return size
; }
67 uint8
GetProtocol() const { return prot
; }
68 void SetProtocol(uint8 p
) { prot
= p
; }
69 const byte
* GetDataBuffer(void) const { return pBuffer
; }
70 void Copy16ToDataBuffer(const void* data
);
71 void CopyToDataBuffer(unsigned int offset
, const byte
* data
, unsigned int n
);
72 void CopyUInt32ToDataBuffer(uint32 data
, unsigned int offset
= 0);
75 //! CPacket is not assignable.
76 CPacket
& operator=(const CPacket
&);
92 // File_checked_for_headers