Gnutella::Packets::Extensions::Ggep Class Reference

#include <Ggep.h> [code]

Inherited by Gnutella::Packets::Extensions::Ggeps::DailyUptime, Gnutella::Packets::Extensions::Ggeps::IpPort, Gnutella::Packets::Extensions::Ggeps::PackedHostCaches, Gnutella::Packets::Extensions::Ggeps::SupportsCachedPongs, Gnutella::Packets::Extensions::Ggeps::UdpHostCache, Gnutella::Packets::Extensions::Ggeps::Ultrapeer, Gnutella::Packets::Extensions::Ggeps::UnknownGgep, and Gnutella::Packets::Extensions::Ggeps::VendorCode.

Inheritance diagram for Gnutella::Packets::Extensions::Ggep:

Inheritance graph
[legend]
Collaboration diagram for Gnutella::Packets::Extensions::Ggep:

Collaboration graph
[legend]
List of all members.

Detailed Description

Encapsulates a packet extension as gefined by the GGEP.

The derived classes need not care about COBS and deflate encodings. All this is handled in the base class. The virtual functions prepareReadData(), readData(), prepareWriteData(), writeData() will receive only unencoded / uncompressed data.

Todo:
Add reference to the specs.
Todo:
Test if encoding/decoding works.

Definition at line 43 of file Ggep.h.

Public Types

typedef QByteArray GgepId
 GGEP extension ID as written in the extension header.
enum  HeaderFlag {
  LastExtension = 0x80,
  Encoding = 0x40,
  Compression = 0x20,
  Reserved = 0x10,
  IDLength = 0x0f
}

Public Member Functions

virtual ~Ggep ()
virtual Ggepcopy () const =0
void prepareRead (const QByteArray &rawData)
void read (QDataStream &stream)
int prepareWrite () const
void write (QDataStream &stream) const
bool isFlagSet (HeaderFlag flag) const
void setFlag (HeaderFlag flag)
void resetFlag (HeaderFlag flag)
GgepId id () const

Static Public Member Functions

static GgepfromId (const GgepId &id, int flags, int dataSize)

Protected Member Functions

 Ggep (const GgepId &id, int flags=0, int dataSize=0)
 Ggep (const Ggep &other)
Ggepoperator= (const Ggep &other)
int dataLength () const
virtual bool prepareReadData (const QByteArray &rawData)=0
 Verifies the structure of rawData.
virtual void readData (QDataStream &stream)=0
 Reads the extension data from stream.
virtual int prepareWriteData () const =0
 Prepares for writing the extension data and returns its length.
virtual void writeData (QDataStream &stream) const =0
 Writes the extension data to the stream;.

Private Member Functions

void invalidateData ()

Private Attributes

Datad
Private p

Classes

struct  Data
struct  Private


Member Typedef Documentation

typedef QByteArray Gnutella::Packets::Extensions::Ggep::GgepId
 

GGEP extension ID as written in the extension header.

Note:
GgepId is currently a typedef of QByteArray. It is important that the ID contains no ending zero; therefore, when declaring a variable, make sure you always use the constructor QByteArray::QByteArray (char *, int) by explicitly specifying the ID length!

Definition at line 64 of file Ggep.h.


Member Enumeration Documentation

enum Gnutella::Packets::Extensions::Ggep::HeaderFlag
 

Enumerator:
LastExtension 
Encoding 
Compression 
Reserved 
IDLength 

Definition at line 46 of file Ggep.h.


Constructor & Destructor Documentation

Ggep::~Ggep  )  [virtual]
 

Definition at line 59 of file Ggep.cpp.

Ggep::Ggep const GgepId id,
int  flags = 0,
int  dataSize = 0
[protected]
 

Definition at line 43 of file Ggep.cpp.

Gnutella::Packets::Extensions::Ggep::Ggep const Ggep other  )  [inline, protected]
 

Definition at line 132 of file Ggep.h.


Member Function Documentation

virtual Ggep* Gnutella::Packets::Extensions::Ggep::copy  )  const [pure virtual]
 

Implemented in Gnutella::Packets::Extensions::Ggeps::DailyUptime, Gnutella::Packets::Extensions::Ggeps::IpPort, Gnutella::Packets::Extensions::Ggeps::PackedHostCaches, Gnutella::Packets::Extensions::Ggeps::SupportsCachedPongs, Gnutella::Packets::Extensions::Ggeps::UdpHostCache, Gnutella::Packets::Extensions::Ggeps::Ultrapeer, Gnutella::Packets::Extensions::Ggeps::UnknownGgep, and Gnutella::Packets::Extensions::Ggeps::VendorCode.

int Gnutella::Packets::Extensions::Ggep::dataLength  )  const [inline, protected]
 

Definition at line 148 of file Ggep.h.

Ggep * Ggep::fromId const GgepId id,
int  flags,
int  dataSize
[static]
 

Definition at line 93 of file Ggep.cpp.

Ggep::GgepId Gnutella::Packets::Extensions::Ggep::id  )  const [inline]
 

Definition at line 145 of file Ggep.h.

void Ggep::invalidateData  )  [private]
 

Definition at line 77 of file Ggep.cpp.

bool Gnutella::Packets::Extensions::Ggep::isFlagSet HeaderFlag  flag  )  const [inline]
 

Definition at line 136 of file Ggep.h.

Ggep & Ggep::operator= const Ggep other  )  [protected]
 

Definition at line 65 of file Ggep.cpp.

void Ggep::prepareRead const QByteArray &  rawExtensionData  ) 
 

The header of this extension was already verified and read out in GgepBlock::prepareRead(). We need to only verify the data here. However, if the data is compressed or encoded we will postpone the call to prepareReadData() until read() where we will decode the data. It is actually not important where the check is made, becuase prepareRead() returns no value. If the isValid flag is false, then in readData() the data should be read wihtout trying to parse it, as it is not with correct structure. This will allow the following extensions to be read correctly, as the stream will be on the correct byte in the underlying buffer.

Definition at line 119 of file Ggep.cpp.

virtual bool Gnutella::Packets::Extensions::Ggep::prepareReadData const QByteArray &  rawData  )  [protected, pure virtual]
 

Verifies the structure of rawData.

Implemented in Gnutella::Packets::Extensions::Ggeps::DailyUptime, Gnutella::Packets::Extensions::Ggeps::IpPort, Gnutella::Packets::Extensions::Ggeps::PackedHostCaches, Gnutella::Packets::Extensions::Ggeps::SupportsCachedPongs, Gnutella::Packets::Extensions::Ggeps::UdpHostCache, Gnutella::Packets::Extensions::Ggeps::Ultrapeer, Gnutella::Packets::Extensions::Ggeps::UnknownGgep, and Gnutella::Packets::Extensions::Ggeps::VendorCode.

int Ggep::prepareWrite  )  const
 

Definition at line 193 of file Ggep.cpp.

virtual int Gnutella::Packets::Extensions::Ggep::prepareWriteData  )  const [protected, pure virtual]
 

Prepares for writing the extension data and returns its length.

Implemented in Gnutella::Packets::Extensions::Ggeps::DailyUptime, Gnutella::Packets::Extensions::Ggeps::IpPort, Gnutella::Packets::Extensions::Ggeps::PackedHostCaches, Gnutella::Packets::Extensions::Ggeps::SupportsCachedPongs, Gnutella::Packets::Extensions::Ggeps::UdpHostCache, Gnutella::Packets::Extensions::Ggeps::Ultrapeer, Gnutella::Packets::Extensions::Ggeps::UnknownGgep, and Gnutella::Packets::Extensions::Ggeps::VendorCode.

void Ggep::read QDataStream &  stream  ) 
 

Definition at line 140 of file Ggep.cpp.

virtual void Gnutella::Packets::Extensions::Ggep::readData QDataStream &  stream  )  [protected, pure virtual]
 

Reads the extension data from stream.

Implemented in Gnutella::Packets::Extensions::Ggeps::DailyUptime, Gnutella::Packets::Extensions::Ggeps::IpPort, Gnutella::Packets::Extensions::Ggeps::PackedHostCaches, Gnutella::Packets::Extensions::Ggeps::SupportsCachedPongs, Gnutella::Packets::Extensions::Ggeps::UdpHostCache, Gnutella::Packets::Extensions::Ggeps::Ultrapeer, Gnutella::Packets::Extensions::Ggeps::UnknownGgep, and Gnutella::Packets::Extensions::Ggeps::VendorCode.

void Gnutella::Packets::Extensions::Ggep::resetFlag HeaderFlag  flag  )  [inline]
 

Definition at line 142 of file Ggep.h.

void Gnutella::Packets::Extensions::Ggep::setFlag HeaderFlag  flag  )  [inline]
 

Definition at line 139 of file Ggep.h.

void Ggep::write QDataStream &  stream  )  const
 

Definition at line 238 of file Ggep.cpp.

virtual void Gnutella::Packets::Extensions::Ggep::writeData QDataStream &  stream  )  const [protected, pure virtual]
 

Writes the extension data to the stream;.

Implemented in Gnutella::Packets::Extensions::Ggeps::DailyUptime, Gnutella::Packets::Extensions::Ggeps::IpPort, Gnutella::Packets::Extensions::Ggeps::PackedHostCaches, Gnutella::Packets::Extensions::Ggeps::SupportsCachedPongs, Gnutella::Packets::Extensions::Ggeps::UdpHostCache, Gnutella::Packets::Extensions::Ggeps::Ultrapeer, Gnutella::Packets::Extensions::Ggeps::UnknownGgep, and Gnutella::Packets::Extensions::Ggeps::VendorCode.


Member Data Documentation

Data* Gnutella::Packets::Extensions::Ggep::d [private]
 

Reimplemented in Gnutella::Packets::Extensions::Ggeps::Ultrapeer.

Definition at line 122 of file Ggep.h.

Private Gnutella::Packets::Extensions::Ggep::p [private]
 

Reimplemented in Gnutella::Packets::Extensions::Ggeps::IpPort, Gnutella::Packets::Extensions::Ggeps::PackedHostCaches, Gnutella::Packets::Extensions::Ggeps::SupportsCachedPongs, and Gnutella::Packets::Extensions::Ggeps::UdpHostCache.

Definition at line 123 of file Ggep.h.


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