Provides an API for building and analyzing raw DB protocol packets. More...
#include <packet.h>
Public Member Functions | |
void | ClearDatabase (unsigned int dbId) |
Builds a command packet for the CLEAR_DATABASE command code, placing the data in the send buffer. | |
void | GetDBDB () |
Builds a command packet for the GET_DBDB command code, placing the data in m_send. | |
void | GetRecordStateTable (unsigned int dbId) |
Builds a command packet in the send buffer for the GET_RECORD_STATE_TABLE command. | |
void | SetRecordFlags (unsigned int dbId, unsigned int stateTableIndex, uint8_t flag1) |
Builds a command packet in the send buffer for the SET_RECORD_FLAGS command code. | |
void | DeleteRecordByIndex (unsigned int dbId, unsigned int stateTableIndex) |
Builds a command packet in the send buffer for the DELETE_RECORD_BY_INDEX command code. | |
void | GetRecordByIndex (unsigned int dbId, unsigned int stateTableIndex) |
Builds a command packet in the send buffer for the GET_RECORD_BY_INDEX command code. | |
bool | SetRecordByIndex (unsigned int dbId, unsigned int stateTableIndex, Builder &build, const IConverter *ic) |
Builds a command packet in the m_send buffer for the SET_RECORD_BY_INDEX command code. | |
void | GetRecords (unsigned int dbId) |
Builds a command packet in the send buffer for the GET_RECORDS command code. | |
bool | SetRecord (unsigned int dbId, Builder &build, const IConverter *ic) |
Builds a command packet in the m_send buffer for the SET_RECORD command code. | |
unsigned int | DBOperation () const |
Returns the database operation code from the receive packet, assuming that receive contains a response packet. | |
bool | Parse (Parser &parser, const std::string &dbname, const IConverter *ic) |
Parses the data in the receive buffer, and attempts to be smart about it, using the last send command as guidance for what to expect in the response. | |
bool | ParseMeta (DBData &data) |
Fills DBData's meta data based on its data block, and the last dbop. |
Provides an API for building and analyzing raw DB protocol packets.
This class relies on 3 external objects: a Mode::Desktop object, a send Data buffer, and a receive data buffer. Socket and connection details are retrieved on a readonly basis from the Mode::Desktop object, but both send and receive buffers can be modified.
Note that the receive buffer may be modified during a packet send, and this DBPacket class provides API helpers to analyze the results.
Definition at line 133 of file packet.h.
void Barry::DBPacket::ClearDatabase | ( | unsigned int | dbId | ) |
Builds a command packet for the CLEAR_DATABASE command code, placing the data in the send buffer.
Definition at line 205 of file packet.cc.
References Barry::Mode::Desktop::GetDBCommand().
unsigned int Barry::DBPacket::DBOperation | ( | ) | const |
void Barry::DBPacket::DeleteRecordByIndex | ( | unsigned int | dbId, | |
unsigned int | stateTableIndex | |||
) |
Builds a command packet in the send buffer for the DELETE_RECORD_BY_INDEX command code.
Definition at line 306 of file packet.cc.
References Barry::Mode::Desktop::GetDBCommand().
void Barry::DBPacket::GetDBDB | ( | ) |
Builds a command packet for the GET_DBDB command code, placing the data in m_send.
Definition at line 228 of file packet.cc.
References Barry::Mode::Desktop::GetDBCommand().
void Barry::DBPacket::GetRecordByIndex | ( | unsigned int | dbId, | |
unsigned int | stateTableIndex | |||
) |
Builds a command packet in the send buffer for the GET_RECORD_BY_INDEX command code.
Definition at line 331 of file packet.cc.
References Barry::Mode::Desktop::GetDBCommand().
void Barry::DBPacket::GetRecords | ( | unsigned int | dbId | ) |
Builds a command packet in the send buffer for the GET_RECORDS command code.
Definition at line 396 of file packet.cc.
References Barry::Mode::Desktop::GetDBCommand().
void Barry::DBPacket::GetRecordStateTable | ( | unsigned int | dbId | ) |
Builds a command packet in the send buffer for the GET_RECORD_STATE_TABLE command.
Definition at line 251 of file packet.cc.
References Barry::Mode::Desktop::GetDBCommand().
bool Barry::DBPacket::Parse | ( | Parser & | parser, | |
const std::string & | dbname, | |||
const IConverter * | ic | |||
) |
Parses the data in the receive buffer, and attempts to be smart about it, using the last send command as guidance for what to expect in the response.
Definition at line 492 of file packet.cc.
References Barry::Parser::ParseRecord().
bool Barry::DBPacket::ParseMeta | ( | DBData & | data | ) |
bool Barry::DBPacket::SetRecord | ( | unsigned int | dbId, | |
Builder & | build, | |||
const IConverter * | ic | |||
) |
Builds a command packet in the m_send buffer for the SET_RECORD command code.
Definition at line 423 of file packet.cc.
References Barry::Builder::BuildRecord(), and Barry::Mode::Desktop::GetDBCommand().
bool Barry::DBPacket::SetRecordByIndex | ( | unsigned int | dbId, | |
unsigned int | stateTableIndex, | |||
Builder & | build, | |||
const IConverter * | ic | |||
) |
Builds a command packet in the m_send buffer for the SET_RECORD_BY_INDEX command code.
Definition at line 359 of file packet.cc.
References Barry::Builder::BuildRecord(), and Barry::Mode::Desktop::GetDBCommand().
void Barry::DBPacket::SetRecordFlags | ( | unsigned int | dbId, | |
unsigned int | stateTableIndex, | |||
uint8_t | flag1 | |||
) |
Builds a command packet in the send buffer for the SET_RECORD_FLAGS command code.
FIXME - this API call is incomplete, since there are unknown flags in the SetRecordFlags protocol packet. Currently it is only used to set all flags to zero.
Definition at line 278 of file packet.cc.
References Barry::Mode::Desktop::GetDBCommand().