From 109ffe9a777658936a38d0c146579a67c60a0d17 Mon Sep 17 00:00:00 2001 From: xuxiuxi <xuxiuxi@454eff88-639b-444f-9e54-f578c98de674> Date: 星期四, 11 五月 2017 17:48:48 +0800 Subject: [PATCH] --- FaceServer/ev_proto.h | 35 ++++++++++++++++++++++++++++++++++- 1 files changed, 34 insertions(+), 1 deletions(-) diff --git a/FaceServer/ev_proto.h b/FaceServer/ev_proto.h index 6dc27be..469ca52 100644 --- a/FaceServer/ev_proto.h +++ b/FaceServer/ev_proto.h @@ -3,8 +3,22 @@ #include <stddef.h> #include <stdint.h> +#include <limits.h> #pragma pack(1) + +struct EVPProto +{ + enum EVPP + { + EVPP__FIRST, + EVPP_RAW_BIN = 1, + EVPP_RAW_TEXT, + EVPP_PROTOBUF, + EVPP_HTTP, + EVPP__LAST + }; +}; struct EVPCommand { @@ -13,7 +27,7 @@ EVPC__FIRST, EVPC_STATUS = 1, EVPC_USER_DEFINE = 128, - EVPC__LAST + EVPC__LAST = USHRT_MAX }; }; @@ -25,6 +39,8 @@ EVPS_OK = 1, EVPS_ERROR = 128, EVPS_INTERNAL_ERROR, + EVPS_PROTO_ERROR, + EVPS_COMMAND_ERROR, EVPS_PARAMETER_ERROR, EVPS__LAST }; @@ -32,19 +48,36 @@ struct EVPHeader { +private: + uint8_t _padding1; + +public: + uint8_t proto; // EVPProto::EVPP int16_t cmd; // EVPCommand::EVPC uint32_t size; // sizeof(EVPHeader)+sizeof(subcmd) + + void hton(); + void ntoh(); + + EVPHeader() : _padding1(0), proto(EVPProto::EVPP__FIRST), cmd(EVPCommand::EVPC__FIRST), size(8) + {} }; struct EVP_Status { int16_t status; + + void hton(); + void ntoh(); }; struct EVP_VariableBuffer { int16_t type; uint8_t buff[0]; + + void hton(); + void ntoh(); }; //#todo -- Gitblit v1.8.0