Gnutella::Packets::UnknownPacket Class Reference

#include <UnknownPacket.h> [code]

Inherits Gnutella::Packets::Packet.

Inheritance diagram for Gnutella::Packets::UnknownPacket:

Inheritance graph
[legend]
Collaboration diagram for Gnutella::Packets::UnknownPacket:

Collaboration graph
[legend]
List of all members.

Detailed Description

Represents a packet with unknown payload descriptor.

Use this class when a packet of unknown type is read (see PacketReader). Just the header fileds are parsed since the structure of the payload is not known. The raw data is stored inside the object.

Definition at line 39 of file UnknownPacket.h.

Public Member Functions

 UnknownPacket (const QByteArray &rawHeader, const QByteArray &rawPayload)
UnknownPacketcopy () const
 A virtual copy contructor.
QString name () const

Protected Member Functions

bool prepareReadPayload (const QByteArray &)
 Verifies the structure of the rawPayload.
void readPayload (QDataStream &)
 Reads the payload fields from the stream. The structure of the data in the stream is already verified by verifyPayload().
int prepareWritePayload () const
 Gets ready to write the payload and returns the payload length.
void writePayload (QDataStream &) const
 Writes the payload fields into the stream.


Constructor & Destructor Documentation

UnknownPacket::UnknownPacket const QByteArray &  rawHeader,
const QByteArray &  rawPayload
 

Definition at line 28 of file UnknownPacket.cpp.


Member Function Documentation

UnknownPacket * UnknownPacket::copy  )  const [virtual]
 

A virtual copy contructor.

Implements Gnutella::Packets::Packet.

Definition at line 34 of file UnknownPacket.cpp.

QString UnknownPacket::name  )  const [virtual]
 

Todo:
remove this?

Implements Gnutella::Packets::Packet.

Definition at line 58 of file UnknownPacket.cpp.

bool UnknownPacket::prepareReadPayload const QByteArray &   )  [protected, virtual]
 

Verifies the structure of the rawPayload.

Verifies if the rawPayload can be correctly parsed by readPayload(). The function just goes over the whole rawPayload and checks if the structure of the payload is correct. Some data may be gathered and stored to ease the work of readPayload(). For example, the size of the query hit data field can only be calculated with knowledge of the payloadLength, which is not available in the QDataStream object passed to readPayload(). The size of this field is read here and stored for use later in readPayload().

Implements Gnutella::Packets::Packet.

Definition at line 39 of file UnknownPacket.cpp.

int UnknownPacket::prepareWritePayload  )  const [protected, virtual]
 

Gets ready to write the payload and returns the payload length.

Implements Gnutella::Packets::Packet.

Definition at line 48 of file UnknownPacket.cpp.

void UnknownPacket::readPayload QDataStream &   )  [protected, virtual]
 

Reads the payload fields from the stream. The structure of the data in the stream is already verified by verifyPayload().

Implements Gnutella::Packets::Packet.

Definition at line 44 of file UnknownPacket.cpp.

void UnknownPacket::writePayload QDataStream &   )  const [protected, virtual]
 

Writes the payload fields into the stream.

Implements Gnutella::Packets::Packet.

Definition at line 53 of file UnknownPacket.cpp.


The documentation for this class was generated from the following files: