summaryrefslogtreecommitdiff
path: root/proto_lib/api_protocol.h
diff options
context:
space:
mode:
Diffstat (limited to 'proto_lib/api_protocol.h')
-rw-r--r--proto_lib/api_protocol.h32
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