diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2016-10-04 11:12:23 +0000 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2016-10-04 11:12:55 +0000 |
commit | 2c09a5209ab00573a2422e1e65c437a6e2f59624 (patch) | |
tree | 40f6e44d235370c22565b43b31af8ebe93507ec8 /src/protocol.h | |
parent | f9bd92d235a187a9bfea4c956bf74e2e08cebb46 (diff) |
protocol.h: Move MESSAGE_START_SIZE into CMessageHeader
Also move the enum to the top, and remove a deceptive TODO
comment.
Diffstat (limited to 'src/protocol.h')
-rw-r--r-- | src/protocol.h | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/src/protocol.h b/src/protocol.h index 1bc1c25b37..cdb76b9038 100644 --- a/src/protocol.h +++ b/src/protocol.h @@ -18,8 +18,6 @@ #include <stdint.h> #include <string> -#define MESSAGE_START_SIZE 4 - /** Message header. * (4) message start. * (12) command. @@ -29,6 +27,16 @@ class CMessageHeader { public: + enum { + MESSAGE_START_SIZE = 4, + COMMAND_SIZE = 12, + MESSAGE_SIZE_SIZE = 4, + CHECKSUM_SIZE = 4, + + MESSAGE_SIZE_OFFSET = MESSAGE_START_SIZE + COMMAND_SIZE, + CHECKSUM_OFFSET = MESSAGE_SIZE_OFFSET + MESSAGE_SIZE_SIZE, + HEADER_SIZE = MESSAGE_START_SIZE + COMMAND_SIZE + MESSAGE_SIZE_SIZE + CHECKSUM_SIZE + }; typedef unsigned char MessageStartChars[MESSAGE_START_SIZE]; CMessageHeader(const MessageStartChars& pchMessageStartIn); @@ -48,17 +56,6 @@ public: READWRITE(FLATDATA(pchChecksum)); } - // TODO: make private (improves encapsulation) -public: - enum { - COMMAND_SIZE = 12, - MESSAGE_SIZE_SIZE = 4, - CHECKSUM_SIZE = 4, - - MESSAGE_SIZE_OFFSET = MESSAGE_START_SIZE + COMMAND_SIZE, - CHECKSUM_OFFSET = MESSAGE_SIZE_OFFSET + MESSAGE_SIZE_SIZE, - HEADER_SIZE = MESSAGE_START_SIZE + COMMAND_SIZE + MESSAGE_SIZE_SIZE + CHECKSUM_SIZE - }; char pchMessageStart[MESSAGE_START_SIZE]; char pchCommand[COMMAND_SIZE]; uint32_t nMessageSize; |