#include <PacketBase.h> [code]
Inherits Protocols::Generics::PacketBase.
Inherited by Protocols::Gnutella::Packets::Ping, Protocols::Gnutella::Packets::Pong, Protocols::Gnutella::Packets::Push, Protocols::Gnutella::Packets::Query, and Protocols::Gnutella::Packets::QueryHits.
Inheritance diagram for Protocols::Gnutella::Packets::PacketBase:


A typical Gnutella packet consists of two parts: header and payload. All packet types share the same header structure but have different payload structure. The table below presents the data fields stored in a header and how they can be accessed using the PacketBase interface. For a detailed documentation of all basic Gnutella packets and the usage of all their fileds please refer to:
http://gnutella-specs.rakjar.de/index.php/Standard_Message_Architecture.
PacketBase class is an abstract class that defines a common interface for all Gnutella packets.The functions rawHeader() and rawPayload() can be used to get the packet as raw bytes ready for transmission.
If you derive from PacketBase, make sure you provide implementation for readPayload() and writePayload().
Definition at line 103 of file PacketBase.h.
Public Member Functions | |
| virtual QString | protocol () const |
| Returns the string "Gnutella". | |
| virtual QString | name () const =0 |
| Returns the name of the PacketBase type the dynamic object belongs to. | |
| virtual auto_ptr< DataBase > | copy () const =0 |
| Virtual copy constructor. | |
| const QUuid & | descriptorId () const |
| Gets the value of the descriptor ID header field. | |
| void | setDescriptorId (const QUuid &descriptorId) |
| Sets the value of the descriptror ID header field. | |
| PacketType | packetType () const |
| Gets the payload desctiptor header field. | |
| uchar | ttl () const |
| Gets the value of the TTL header field. | |
| void | setTtl (uchar ttl) |
| Sets the value of the TTL header field. | |
| uchar | hops () const |
| Gets the value of the hops header field. | |
| void | setHops (uchar hops) |
| Gets the value of the hops header field. | |
| void | doHop () |
| Increments hops and decrements ttl by one. | |
Protected Member Functions | |
| PacketBase (Data *d, PacketType packetType) | |
| Constructs a PacketBase object. | |
| virtual bool | readHeader (const QByteArray &rawHeader) |
| Reads the header fields from raw data. | |
| virtual bool | readPayload (const QByteArray &rawPayload) |
| Reads the payload fields from raw bytes. | |
| virtual QByteArray | writeHeader () const |
| Writes the packet header fields and returns the raw bytes. | |
| virtual QByteArray | writePayload () const |
| Returns the raw bytes representation of the payload fields. | |
| virtual void | readPayload (BinaryReader &)=0 |
| Reads the payload fields from binaryReader. | |
| virtual void | writePayload (BinaryWriter &) const =0 |
Private Member Functions | |
| Q_DECLARE_SHARED_DATA (Data) | |
Classes | |
| class | Data |
|
||||||||||||
|
Constructs a PacketBase object.
Definition at line 43 of file PacketBase.cpp. |
|
|
Virtual copy constructor.
Implements Protocols::Generics::PacketBase. Implemented in Protocols::Gnutella::Packets::Ping, Protocols::Gnutella::Packets::Pong, Protocols::Gnutella::Packets::Push, Protocols::Gnutella::Packets::Query, and Protocols::Gnutella::Packets::QueryHits. |
|
|
Gets the value of the descriptor ID header field.
Definition at line 162 of file PacketBase.h. |
|
|
Increments hops and decrements ttl by one.
Definition at line 190 of file PacketBase.h. |
|
|
Gets the value of the hops header field.
Definition at line 182 of file PacketBase.h. |
|
|
Returns the name of the PacketBase type the dynamic object belongs to.
Implements Protocols::Generics::PacketBase. Implemented in Protocols::Gnutella::Packets::Ping, Protocols::Gnutella::Packets::Pong, Protocols::Gnutella::Packets::Push, Protocols::Gnutella::Packets::Query, and Protocols::Gnutella::Packets::QueryHits. |
|
|
Gets the payload desctiptor header field.
Definition at line 170 of file PacketBase.h. |
|
|
Returns the string "Gnutella".
Implements Protocols::Generics::PacketBase. Definition at line 28 of file PacketBase.cpp. |
|
|
|
|
|
Reads the header fields from raw data.
Implements Protocols::Generics::PacketBase. Definition at line 65 of file PacketBase.cpp. |
|
|
Reads the payload fields from binaryReader.
Implemented in Protocols::Gnutella::Packets::Ping, Protocols::Gnutella::Packets::Pong, Protocols::Gnutella::Packets::Push, Protocols::Gnutella::Packets::Query, and Protocols::Gnutella::Packets::QueryHits. |
|
|
Reads the payload fields from raw bytes.
Implements Protocols::Generics::PacketBase. Definition at line 110 of file PacketBase.cpp. |
|
|
Sets the value of the descriptror ID header field.
Definition at line 166 of file PacketBase.h. |
|
|
Gets the value of the hops header field.
Definition at line 186 of file PacketBase.h. |
|
|
Sets the value of the TTL header field.
Definition at line 178 of file PacketBase.h. |
|
|
Gets the value of the TTL header field.
Definition at line 174 of file PacketBase.h. |
|
|
Writes the packet header fields and returns the raw bytes.
Implements Protocols::Generics::PacketBase. Definition at line 81 of file PacketBase.cpp. |
|
|
|
Returns the raw bytes representation of the payload fields.
Implements Protocols::Generics::PacketBase. Definition at line 137 of file PacketBase.cpp. |