Gnutella::Packets::Push Class Reference

#include <Push.h> [code]

Inherits Gnutella::Packets::Packet.

Inheritance diagram for Gnutella::Packets::Push:

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

Collaboration graph
[legend]
List of all members.

Detailed Description

Encapsulates the Push Gnutella packet.

The table below presents the data fields stored in a query hits' payload and how they can be accessed using the Push interface. For a detailed documentation of all basic Gnutella packets and the usage of all their fileds please refer to The Annotated Gnutella Protocol Specification v0.4.

Byte Offset Field Name getFunction setFunction
0..15 Servent ID N/A N/A
20..23 IP Address N/A N/A
24..25 Port N/A N/A
26..L-1 Optional Push Data N/A N/A

Todo:
Create accessors for the payload fields.

Definition at line 53 of file Push.h.

Public Member Functions

 Push (const QByteArray &rawHeader, const QByteArray &rawPayload)
 ~Push ()
const QUuid & serventId () const
 Gets the servent ID payload field.
const Extensions::GgepBlockggepBlock () const
 Gets the GGEP block containing all GGEP extensions.
void setGgepBlock (const Extensions::GgepBlock &block)
 Sets the GGEP block, which should be filled with all necessary GGEP extensions.
Pushcopy () const
 A virtual copy contructor.
QString name () const

Static Public Member Functions

static PushcastFrom (Packet &packet)
static const PushcastFrom (const Packet &packet)

Protected Member Functions

bool prepareReadPayload (const QByteArray &rawPayload)
 Verifies the structure of the rawPayload.
void readPayload (QDataStream &stream)
 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 &stream) const
 Writes the payload fields into the stream.

Private Attributes

Gnutella::Packets::Push::Data p

Classes

struct  Data


Constructor & Destructor Documentation

Push::Push const QByteArray &  rawHeader,
const QByteArray &  rawPayload
 

Creates a Push object from the raw bytes in rawHeader and rawPayload.

Definition at line 37 of file Push.cpp.

Push::~Push  ) 
 

Definition at line 43 of file Push.cpp.


Member Function Documentation

static const Push& Gnutella::Packets::Push::castFrom const Packet packet  )  [inline, static]
 

Definition at line 57 of file Push.h.

static Push& Gnutella::Packets::Push::castFrom Packet packet  )  [inline, static]
 

Definition at line 56 of file Push.h.

Push* Gnutella::Packets::Push::copy  )  const [inline, virtual]
 

A virtual copy contructor.

Implements Gnutella::Packets::Packet.

Definition at line 67 of file Push.h.

const Extensions::GgepBlock& Gnutella::Packets::Push::ggepBlock  )  const [inline]
 

Gets the GGEP block containing all GGEP extensions.

Definition at line 63 of file Push.h.

QString Gnutella::Packets::Push::name  )  const [inline, virtual]
 

Todo:
remove this?

Implements Gnutella::Packets::Packet.

Definition at line 69 of file Push.h.

bool Push::prepareReadPayload const QByteArray &  rawPayload  )  [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 47 of file Push.cpp.

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

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

Implements Gnutella::Packets::Packet.

Definition at line 69 of file Push.cpp.

void Push::readPayload QDataStream &  stream  )  [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 60 of file Push.cpp.

const QUuid& Gnutella::Packets::Push::serventId  )  const [inline]
 

Gets the servent ID payload field.

Definition at line 62 of file Push.h.

void Gnutella::Packets::Push::setGgepBlock const Extensions::GgepBlock block  )  [inline]
 

Sets the GGEP block, which should be filled with all necessary GGEP extensions.

Definition at line 65 of file Push.h.

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

Writes the payload fields into the stream.

Implements Gnutella::Packets::Packet.

Definition at line 74 of file Push.cpp.


Member Data Documentation

struct Gnutella::Packets::Push::Data Gnutella::Packets::Push::p [private]
 


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