diff options
author | Gluzskiy Alexandr <sss@sss.chaoslab.ru> | 2013-02-12 21:34:09 +0200 |
---|---|---|
committer | Gluzskiy Alexandr <sss@sss.chaoslab.ru> | 2013-02-12 21:34:09 +0200 |
commit | 85a13d70cc5249e2f583bb16f0914646aefe4fe6 (patch) | |
tree | 3c83832a146120a8ec8f026ab97af2698936e72c /proto_lib | |
parent | 1d41574c6e8e7bbf3705645feb429df6281ccb83 (diff) |
server and shell exec module should work now
TODO: implement basic protocol support in client
Diffstat (limited to 'proto_lib')
-rw-r--r-- | proto_lib/api_protocol.h | 1 | ||||
-rw-r--r-- | proto_lib/packet.cpp | 17 |
2 files changed, 13 insertions, 5 deletions
diff --git a/proto_lib/api_protocol.h b/proto_lib/api_protocol.h index 2e42d42..b18d2e7 100644 --- a/proto_lib/api_protocol.h +++ b/proto_lib/api_protocol.h @@ -64,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 packet *serv_make_command_reply_packet(std::vector<unsigned char>&, status s); static svc_cmd serv_extract_command(packet&); //generic diff --git a/proto_lib/packet.cpp b/proto_lib/packet.cpp index 0ed3150..92272a8 100644 --- a/proto_lib/packet.cpp +++ b/proto_lib/packet.cpp @@ -271,11 +271,18 @@ packet *packet::serv_make_command_reply_packet(std::string &str, status s) pack_serv_header(v); pack_buffer(type_command, sizeof(type_command), v); v.push_back(s); - if(!str.empty()) - { - for(size_t i = 0; i < str.length(); i++) - v.push_back(str[i]); - } + pack_buffer(str, v); + pack_buffer(proto_footer, sizeof(proto_footer), v); + return new packet(v); +} + +packet *packet::serv_make_command_reply_packet(std::vector<unsigned char>& data, status s) +{ + std::vector<unsigned char> v; + pack_serv_header(v); + pack_buffer(type_command, sizeof(type_command), v); + v.push_back(s); + pack_buffer(data, v); pack_buffer(proto_footer, sizeof(proto_footer), v); return new packet(v); } |