Gnutella::Packets Namespace Reference


Detailed Description

Contains classes that encapsulate the Gnutella packets.

Higher abstraction level is Gnutella

The basis class for all Gnutella packets is Packet. It implements many of the details related with parsing a packet from raw data and generating the raw data for a Packet object. The derived classes only need to implement a few pure virtual functions to support parsing and raw bytes generation. Of course the derived classes provide interface that allows setting and getting the packet fields.

Currently supported packets are Ping, Pong, Query, QueryHits, Push, Bye.

Todo:
Add support for Open vendor and standard vendor messages.

The searching-related extensions are not fully implemented and tested yet (XML metadata, EQHD).

The known Gnutella packet extensions are implemented in Extensions.

Todo:
Not all GGEP exptensions are implemented yet. Implement them as need arises.
Packets Resources


Classes

class  Bye
class  Packet
 Base class for all Gnutella packets. More...
class  Ping
 Encapsulates the Ping Gnutella packet. More...
class  Pong
 Encapsulates the Pong Gnutella packet. More...
class  Push
 Encapsulates the Push Gnutella packet. More...
class  Query
 Encapsulates the Query Gnutella packet. More...
class  QueryHits
 Encapsulates the QueryHits Gnutella packet. More...
class  QueryRouting
class  QueryRoutingPatch
class  QueryRoutingReset
class  UnknownPacket
 Represents a packet with unknown payload descriptor. More...
class  VendorCode

Namespaces

namespace  Extensions
namespace  Testing
namespace  VendorMessages

Enumerations

enum  Constants { MinimalByePayloadLength = 3 }
enum  PayloadDescriptor {
  PingDescriptor = 0x00,
  PongDescriptor = 0x01,
  QueryDescriptor = 0x80,
  QueryHitsDescriptor = 0x81,
  PushDescriptor = 0x40,
  ByeDescriptor = 0x02,
  IbmcDescriptor = 0x10,
  QueryRoutingDescriptor = 0x30,
  OpenVendorDescriptor = 0x31,
  StandardVendorDescriptor = 0x32
}
enum  PacketConstants {
  DefaultHops = 0,
  DefaultTtl = 5,
  MaximalTtl = 7,
  HeaderLength = 23,
  MaximalPayloadLength = 0x00010000 - HeaderLength,
  MaximalQueryPayloadLength = 0x00001000 - HeaderLength,
  MaximalPacketLength = HeaderLength + MaximalPayloadLength
}
 Packet-related global constants. More...

Functions

QDataStream & operator>> (QDataStream &in, PayloadDescriptor &pd)
 Reads a payload descriptor's value from a QDataStream.
QDataStream & operator<< (QDataStream &out, const PayloadDescriptor &pd)
 Writes a payload descriptor's value into a QDataStream.
QDataStream & operator>> (QDataStream &in, QHostAddress &ha)
 Reads an IP v4 address from a QDataStream.
QDataStream & operator<< (QDataStream &out, const QHostAddress &ha)
 Writes an IP v4 address into a QDataStream.
QDataStream & operator>> (QDataStream &in, Extensions::Extension &extension)
QDataStream & operator<< (QDataStream &out, const Extensions::Extension &extension)
QDataStream & operator>> (QDataStream &stream, VendorCode &vendorCode)
QDataStream & operator<< (QDataStream &stream, const VendorCode &vendorCode)


Enumeration Type Documentation

enum Gnutella::Packets::Constants
 

Enumerator:
MinimalByePayloadLength  code (2b), message (1b)

Definition at line 29 of file Bye.cpp.

enum Gnutella::Packets::PacketConstants
 

Packet-related global constants.

Todo:
Make this enum a member of Packet

Maybe move all such global constants in a Settings class and make it possible to be changed without rebuilding the complete source.

Enumerator:
DefaultHops  A default constructed Packet gets this hops value.
DefaultTtl  A default constructed Packet gets this ttl value.
MaximalTtl  Maximal acceptable tll value. Packets with excessive values are considered invalid.
HeaderLength  Packet header length.
MaximalPayloadLength  Maximal acceptable payload length. Most servents will drop a connection when receiving a messages larger than 64 KB from it.
MaximalQueryPayloadLength  Maximal acceptable payload length for a QueryPacket. Some servents may drop messages larger than 256 bytes (that would be for non-metadata queries).
MaximalPacketLength 

Definition at line 71 of file Packet.h.

enum Gnutella::Packets::PayloadDescriptor
 

Defines all known Gnutella descriptors (packets). The payloadDescriptor field of a Gnutella packet header determines the type of the current packet and therefore the contents of its payload

Todo:
Add reference to the Gnutella specs.
Enumerator:
PingDescriptor  Ping packet.
PongDescriptor  Pong packet.
QueryDescriptor  Query packet.
QueryHitsDescriptor  Query hits packet.
PushDescriptor  Push packet.
ByeDescriptor  Bye packet.
IbmcDescriptor  In-band control message.
QueryRoutingDescriptor  Query routing protocol packet.
OpenVendorDescriptor  Open vendor packet.
StandardVendorDescriptor  Standard vendor packet.

Definition at line 51 of file Packet.h.


Function Documentation

QDataStream & Gnutella::Packets::operator<< QDataStream &  stream,
const VendorCode vendorCode
 

Definition at line 69 of file VendorCode.cpp.

QDataStream& Gnutella::Packets::operator<< QDataStream &  out,
const Extensions::Extension &  extension
 

QDataStream & Gnutella::Packets::operator<< QDataStream &  out,
const QHostAddress &  ha
 

Writes an IP v4 address into a QDataStream.

Writes a 4 byte IP address ha into the out stream as a big endian value.

Definition at line 91 of file Packet.cpp.

QDataStream & Gnutella::Packets::operator<< QDataStream &  out,
const PayloadDescriptor pd
 

Writes a payload descriptor's value into a QDataStream.

Writes the single byte pd value into the out stream.

Definition at line 65 of file Packet.cpp.

QDataStream & Gnutella::Packets::operator>> QDataStream &  stream,
VendorCode vendorCode
 

Definition at line 56 of file VendorCode.cpp.

QDataStream& Gnutella::Packets::operator>> QDataStream &  in,
Extensions::Extension &  extension
 

QDataStream & Gnutella::Packets::operator>> QDataStream &  in,
QHostAddress &  ha
 

Reads an IP v4 address from a QDataStream.

Reads a 4 byte IP address ha from the in stream as a big endian value.

Definition at line 75 of file Packet.cpp.

QDataStream & Gnutella::Packets::operator>> QDataStream &  in,
PayloadDescriptor pd
 

Reads a payload descriptor's value from a QDataStream.

Reads the single byte pd value from the in stream.

Definition at line 53 of file Packet.cpp.