#include <Packet.h> [code]
Inherits Protocols::Generics::PacketBase.
Inherited by Protocols::Kad::Packets::PeerInfoPacket< type >, and Protocols::Kad::Packets::TcpPortPacket< type >.
Inheritance diagram for Protocols::Kad::Packets::Packet:


This class takes reads and writes the header of a Kad packet. The derived classes must implement reading and writing the payload.
The header of Kad packets contains 2 bytes: One defining the protocol id and the other containing the kind of Kad packet.
Check the derived classes for more info about the payload of the different packet types.
Definition at line 79 of file Packet.h.
Public Member Functions | |
| virtual QString | protocol () const |
| Returns the string "Kad". | |
| virtual QString | name () const =0 |
| Returns the name of the PacketBase type the dynamic object belongs to. | |
| virtual Packet * | copy () const =0 |
| Virtual copy constructor. | |
| Protocol | protocolId () const |
| Returns the Protocol of the Packet object. | |
| PacketType | packetType () const |
| Returns the PacketType of the Packet object. | |
Protected Member Functions | |
| Packet (Data *d, PacketType packetType) | |
| Constructs a Packet object with a specific PacketType. | |
| virtual bool | readHeader (const QByteArray &rawHeader) |
| Reads the header fields from raw data. | |
| virtual bool | readPayload (const QByteArray &rawPayload) |
| Parses the raw bytes in to extract the payload fields. | |
| virtual bool | readTrailer (const QByteArray &rawTrailer) |
| Kad packets do not have trailers. | |
| virtual QByteArray | writeHeader () const |
| Writes the packet header and returns the raw bytes. | |
| virtual QByteArray | writePayload () const |
| Writes the payload fields into raw bytes and returns a QByteArray. | |
| virtual QByteArray | writeTrailer () const |
| Kad packets do not have trailers. | |
| virtual void | readPayload (BinaryReader &)=0 |
| Reads the payload fields from binaryReader. Called by the implementation of bool Packet::readPayload (const QByteArray &). | |
| virtual void | writePayload (BinaryWriter &) const =0 |
Private Member Functions | |
| Q_DECLARE_SHARED_DATA (Data) | |
Classes | |
| class | Data |
| Extended private data. More... | |
|
||||||||||||
|
Constructs a Packet object with a specific PacketType.
Definition at line 42 of file Packet.cpp. |
|
|
Virtual copy constructor.
Implements Protocols::Generics::PacketBase. Implemented in Protocols::Kad::Packets::PeerInfoPacket< type >, and Protocols::Kad::Packets::TcpPortPacket< type >. |
|
|
Returns the name of the PacketBase type the dynamic object belongs to.
Implements Protocols::Generics::PacketBase. Implemented in Protocols::Kad::Packets::PeerInfoPacket< type >, and Protocols::Kad::Packets::TcpPortPacket< type >. |
|
|
Returns the PacketType of the Packet object.
|
|
|
Returns the string "Kad".
Implements Protocols::Generics::PacketBase. Definition at line 28 of file Packet.cpp. |
|
|
Returns the Protocol of the Packet object.
|
|
|
|
|
|
Reads the header fields from raw data.
Implements Protocols::Generics::PacketBase. Definition at line 53 of file Packet.cpp. |
|
|
Reads the payload fields from binaryReader. Called by the implementation of bool Packet::readPayload (const QByteArray &).
Implemented in Protocols::Kad::Packets::PeerInfoPacket< type >, and Protocols::Kad::Packets::TcpPortPacket< type >. |
|
|
Parses the raw bytes in to extract the payload fields. A derived class can either choose to override this function or override Packet::readPayload (BinaryReader& ), which makes parsing using the BinaryReader object much easier. Implements Protocols::Generics::PacketBase. Definition at line 110 of file Packet.cpp. |
|
|
Kad packets do not have trailers.
Definition at line 74 of file Packet.cpp. |
|
|
Writes the packet header and returns the raw bytes.
Implements Protocols::Generics::PacketBase. Definition at line 81 of file Packet.cpp. |
|
|
Implemented in Protocols::Kad::Packets::PeerInfoPacket< type >, and Protocols::Kad::Packets::TcpPortPacket< type >. |
|
|
Writes the payload fields into raw bytes and returns a QByteArray. A derived class can either choose to override this function or override Packet::writePayload (BinaryWriter &), which makes writing fields into a QByteArray buffer much easier. Implements Protocols::Generics::PacketBase. Definition at line 129 of file Packet.cpp. |
|
|
Kad packets do not have trailers. The function returns and empty QByteArray since Kad packets do not have trailers. Definition at line 99 of file Packet.cpp. |