diff options
author | Martin Lucina <martin@lucina.net> | 2012-04-27 14:18:08 +0200 |
---|---|---|
committer | Martin Sustrik <sustrik@250bpm.com> | 2012-04-29 09:02:14 +0200 |
commit | 512f3a604924fec9d89e2b4bfd6f73aa66309fa7 (patch) | |
tree | 563b8ec0bb0babc8093f39d2ed52d2ae308335ba /src/wire.hpp | |
parent | a84a77a4861c8fc1b0b6d3ec0931e83395cb34b5 (diff) |
Implement protocol versioning (except PGM)
Implements SP protocol versioning, legacy protocol support, and the
following pattern protocol versions:
PAIR: v2
PUBSUB: v1 (legacy), v3
REQREP: v1
PIPELINE: v2
SURVEY: v1
Engine support is only for stream_engine_t at this stage.
Signed-off-by: Martin Lucina <martin@lucina.net>
Diffstat (limited to 'src/wire.hpp')
-rw-r--r-- | src/wire.hpp | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/src/wire.hpp b/src/wire.hpp index f840fce..e751818 100644 --- a/src/wire.hpp +++ b/src/wire.hpp @@ -24,11 +24,50 @@ #include "stdint.hpp" // Protocol-related constants. -#define XS_CMD_SUBSCRIBE 1 -#define XS_CMD_UNSUBSCRIBE 2 + +// Protocol header. +#define SP_HEADER_LENGTH 8 + +// Patterns. +#define SP_PAIR 1 +#define SP_PUBSUB 2 +#define SP_REQREP 3 +#define SP_PIPELINE 4 +#define SP_SURVEY 5 + +// Roles. +#define SP_PAIR_PAIR 1 +#define SP_PUBSUB_PUB 1 +#define SP_PUBSUB_SUB 2 +#define SP_REQREP_REQ 1 +#define SP_REQREP_REP 2 +#define SP_PIPELINE_PUSH 1 +#define SP_PIPELINE_PULL 2 +#define SP_SURVEY_SURVEYOR 1 +#define SP_SURVEY_RESPONDENT 2 + +// PUBSUB pattern commands. +#define SP_PUBSUB_CMD_SUBSCRIBE 1 +#define SP_PUBSUB_CMD_UNSUBSCRIBE 2 namespace xs { + // Protocol header type. + typedef unsigned char sp_header_t [SP_HEADER_LENGTH]; + + // Get the SP protocol header for the specified pattern, version and role. + inline void sp_get_header (sp_header_t header_, int pattern_, int version_, + int role_) + { + header_ [0] = 0; + header_ [1] = 0; + header_ [2] = 'S'; + header_ [3] = 'P'; + header_ [4] = pattern_ & 0xff; + header_ [5] = version_ & 0xff; + header_ [6] = role_ & 0xff; + header_ [7] = 0; + } // Helper functions to convert different integer types to/from network // byte order. |