packet.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef __BARRY_PACKET_H__
00025 #define __BARRY_PACKET_H__
00026
00027 #include <string>
00028 #include <stdint.h>
00029 #include "protocol.h"
00030
00031 namespace Barry { class Data; }
00032
00033 namespace Barry {
00034
00035
00036 class Parser;
00037 class Builder;
00038 class SocketZero;
00039 class Socket;
00040 class IConverter;
00041 namespace Mode {
00042 class Desktop;
00043 class JavaLoader;
00044 }
00045
00046 class Packet
00047 {
00048 friend class SocketZero;
00049 friend class Socket;
00050
00051 protected:
00052 Data &m_send, &m_receive;
00053
00054 Data& GetSend() { return m_send; }
00055 Data& GetReceive() { return m_receive; }
00056
00057 public:
00058 Packet(Data &send, Data &receive)
00059 : m_send(send), m_receive(receive)
00060 {}
00061 virtual ~Packet() {}
00062
00063
00064
00065
00066 unsigned int Command() const;
00067 };
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079 class ZeroPacket : public Packet
00080 {
00081 friend class Socket;
00082
00083 public:
00084 ZeroPacket(Data &send, Data &receive);
00085 ~ZeroPacket();
00086
00087
00088
00089
00090
00091
00092
00093 void GetAttribute(unsigned int object, unsigned int attribute);
00094 void Echo(uint64_t us_ticks);
00095 void Reset();
00096
00097
00098
00099
00100
00101 unsigned int ObjectID() const;
00102 unsigned int AttributeID() const;
00103 uint32_t ChallengeSeed() const;
00104 unsigned int RemainingTries() const;
00105 unsigned int SocketResponse() const;
00106 unsigned char SocketSequence() const;
00107 uint8_t CommandResponse() const;
00108 };
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125 class DBPacket : public Packet
00126 {
00127 friend class Socket;
00128
00129 private:
00130 Mode::Desktop &m_con;
00131 unsigned int m_last_dbop;
00132
00133 protected:
00134
00135 public:
00136 DBPacket(Mode::Desktop &con, Data &send, Data &receive);
00137 ~DBPacket();
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147 void ClearDatabase(unsigned int dbId);
00148 void GetDBDB();
00149 void GetRecordStateTable(unsigned int dbId);
00150 void SetRecordFlags(unsigned int dbId, unsigned int stateTableIndex, uint8_t flag1);
00151 void DeleteRecordByIndex(unsigned int dbId, unsigned int stateTableIndex);
00152 void GetRecordByIndex(unsigned int dbId, unsigned int stateTableIndex);
00153 bool SetRecordByIndex(unsigned int dbId, unsigned int stateTableIndex, Builder &build, const IConverter *ic);
00154 void GetRecords(unsigned int dbId);
00155 bool SetRecord(unsigned int dbId, Builder &build, const IConverter *ic);
00156
00157
00158
00159
00160
00161
00162 unsigned int ReturnCode() const;
00163 unsigned int DBOperation() const;
00164
00165 bool Parse(Parser &parser, const IConverter *ic);
00166
00167
00168 };
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185 class JLPacket : public Packet
00186 {
00187 friend class Socket;
00188
00189 private:
00190 Data &m_cmd, &m_data;
00191 int m_last_set_size;
00192
00193 public:
00194 JLPacket(Data &cmd, Data &send, Data &receive);
00195 ~JLPacket();
00196
00197
00198
00199
00200 bool HasData() const { return m_last_set_size == 2; }
00201 Data& GetReceive() { return m_receive; }
00202
00203
00204
00205
00206
00207
00208
00209
00210 int SimpleCmd(uint8_t cmd, uint8_t unknown = 0, uint16_t size = 0);
00211 int SimpleData(const void *data, uint16_t size);
00212 int BigEndianData(uint16_t value);
00213 int BigEndianData(uint32_t value);
00214
00215 int Hello() { return SimpleCmd(SB_COMMAND_JL_HELLO); }
00216 int Goodbye() { return SimpleCmd(SB_COMMAND_JL_GOODBYE); }
00217 int SetUnknown1();
00218 int SetCodFilename(const std::string &filename);
00219 int SetCodSize(off_t size);
00220 int SetTime(time_t when);
00221 int GetScreenshot();
00222 int GetData() { return SimpleCmd(SB_COMMAND_JL_SEND_DATA); }
00223 int DeviceInfo() { return SimpleCmd(SB_COMMAND_JL_DEVICE_INFO); }
00224 int OsMetrics() { return SimpleCmd(SB_COMMAND_JL_OS_METRICS); }
00225 int BootromMetrics() { return SimpleCmd(SB_COMMAND_JL_BOOTROM_METRICS); }
00226 int GetDirectory() { return SimpleCmd(SB_COMMAND_JL_GET_DIRECTORY); }
00227 int GetSubDir(uint16_t id);
00228 int GetDirEntry(uint8_t entry_cmd, uint16_t id);
00229 int Erase(uint16_t cmd, uint16_t id);
00230 int GetEventlog() { return SimpleCmd(SB_COMMAND_JL_GET_LOG); }
00231 int GetEventlogEntry(uint16_t entry_num);
00232 int ClearEventlog() { return SimpleCmd(SB_COMMAND_JL_CLEAR_LOG); }
00233 int SaveModule(uint16_t id);
00234 int PutData(const void *data, uint16_t size);
00235 int WipeApps() { return SimpleCmd(SB_COMMAND_JL_WIPE_APPS); }
00236 int WipeFs() { return SimpleCmd(SB_COMMAND_JL_WIPE_FS); }
00237 int LogStackTraces() { return SimpleCmd(SB_COMMAND_JL_LOG_STRACES); }
00238 int ResetToFactory() { return SimpleCmd(SB_COMMAND_JL_RESET_FACTORY); }
00239
00240
00241
00242 unsigned int Size();
00243 };
00244
00245
00246 }
00247
00248 #endif
00249