diff options
author | Gluzskiy Alexandr <sss@sss.chaoslab.ru> | 2013-02-12 13:47:03 +0200 |
---|---|---|
committer | Gluzskiy Alexandr <sss@sss.chaoslab.ru> | 2013-02-12 13:47:03 +0200 |
commit | b568c0cab255aefd400d48c05e2cabc6ca96c270 (patch) | |
tree | 471e2794310b6bb6a53d013327122f43d5518685 /proto_lib/api_protocol.h | |
parent | 224d96964ea3c9e541fcd5caa2778af25f71ba2e (diff) |
some work with proto library done
Diffstat (limited to 'proto_lib/api_protocol.h')
-rw-r--r-- | proto_lib/api_protocol.h | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/proto_lib/api_protocol.h b/proto_lib/api_protocol.h index 39681e4..452d6dc 100644 --- a/proto_lib/api_protocol.h +++ b/proto_lib/api_protocol.h @@ -29,11 +29,11 @@ struct service_s }; enum packet_type {AUTH_REPLY, AUTH_REQUEST, SERVICES_REPLY, SERVICES_REQUEST, COMMAND_REPLY, COMMAND_REQUEST, UNKNOWN}; +enum status {failure = 0x00, success = 0x01}; class packet { public: - packet(); packet(std::vector<unsigned char>&); const std::vector<unsigned char> &raw(); packet_type get_type(); @@ -42,21 +42,31 @@ public: bool is_client_packet(); bool assign(packet&); bool assign(std::vector<unsigned char>&); + + //helper functions: + //client functions + static packet *cli_make_auth_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(); + + static std::list<service_s> *cli_extract_services(packet&); + static std::string cli_parse_command_reply(packet&); + + //server functions + static bool serv_validate_client_proto(packet&); + static packet *serv_make_services_packet(std::list<service_s>&); + + //generic + static packet *make_status_packet(const unsigned char* type, status s); + static bool check_status_packet(const unsigned char *type, packet&); //false on fail + + private: + packet(); std::vector<unsigned char> data; }; -//server functions -bool serv_validate_client_proto(packet&); - -//client functions -packet *cli_make_auth_packet(); //should be first packet to server -packet *cli_make_command_packet(std::string &service, std::string &command); -packet *cli_request_services(); -std::list<service_s> cli_extract_services(packet&); -bool cli_check_auth_reply(packet&); //false on fail -std::string cli_parse_command_reply(packet&); #endif |