summaryrefslogtreecommitdiff
path: root/proto_lib/api_protocol.h
diff options
context:
space:
mode:
authorGluzskiy Alexandr <sss@sss.chaoslab.ru>2013-02-12 20:36:08 +0200
committerGluzskiy Alexandr <sss@sss.chaoslab.ru>2013-02-12 20:36:08 +0200
commit1d41574c6e8e7bbf3705645feb429df6281ccb83 (patch)
treed0bf256321aef49dd386a9c459104c2fb019ca64 /proto_lib/api_protocol.h
parentc98a83a1591b1bcb58b3ed29bdbfb1446948f466 (diff)
working on service support
Diffstat (limited to 'proto_lib/api_protocol.h')
-rw-r--r--proto_lib/api_protocol.h16
1 files changed, 11 insertions, 5 deletions
diff --git a/proto_lib/api_protocol.h b/proto_lib/api_protocol.h
index 88195e2..2e42d42 100644
--- a/proto_lib/api_protocol.h
+++ b/proto_lib/api_protocol.h
@@ -17,6 +17,7 @@
#ifndef API_PROTOCOL_H
#define API_PROTOCOL_H
+namespace proto {
struct service_s
{
@@ -28,8 +29,13 @@ struct service_s
std::list<cmd> cmds;
};
-enum packet_type {AUTH_REPLY, AUTH_REQUEST, SERVICES_REPLY, SERVICES_REQUEST, COMMAND_REPLY, COMMAND_REQUEST, UNKNOWN};
-enum status {failure = 0x00, success = 0x01};
+struct svc_cmd
+{
+ std::string service, command;
+};
+
+enum packet_type {TYPE_AUTH_REPLY, TYPE_AUTH_REQUEST, TYPE_SERVICES_REPLY, TYPE_SERVICES_REQUEST, TYPE_COMMAND_REPLY, TYPE_COMMAND_REQUEST, TYPE_CUSTOM, TYPE_UNKNOWN};
+enum status {STATUS_FAILURE = 0x00, STATUS_SUCCESS = 0x01};
class packet
{
@@ -47,7 +53,7 @@ public:
//helper functions:
//client functions
- static packet *cli_make_auth_packet(); //should be first packet to server
+ static packet *cli_make_init_packet(); //should be first packet to server
static packet *cli_make_command_packet(std::string &service, std::string &command);
static packet *cli_make_request_services_packet();
@@ -58,6 +64,7 @@ public:
static bool serv_validate_client_proto(packet&); //false on fail
static packet *serv_make_services_packet(std::list<service_s>&);
static packet *serv_make_command_reply_packet(std::string&, status s);
+ static svc_cmd serv_extract_command(packet&);
//generic
static packet *make_status_packet(packet_type type, status s);
@@ -66,7 +73,6 @@ private:
std::vector<unsigned char> data;
};
-
-
+};
#endif