00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef PROTOCOL_BINARY_H
00036 #define PROTOCOL_BINARY_H
00037
00038 #include <stdint.h>
00039
00046 #ifdef __cplusplus
00047 extern "C"
00048 {
00049 #endif
00050
00055 typedef enum {
00056 PROTOCOL_BINARY_REQ = 0x80,
00057 PROTOCOL_BINARY_RES = 0x81
00058 } protocol_binary_magic;
00059
00064 typedef enum {
00065 PROTOCOL_BINARY_RESPONSE_SUCCESS = 0x00,
00066 PROTOCOL_BINARY_RESPONSE_KEY_ENOENT = 0x01,
00067 PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS = 0x02,
00068 PROTOCOL_BINARY_RESPONSE_E2BIG = 0x03,
00069 PROTOCOL_BINARY_RESPONSE_EINVAL = 0x04,
00070 PROTOCOL_BINARY_RESPONSE_NOT_STORED = 0x05,
00071 PROTOCOL_BINARY_RESPONSE_DELTA_BADVAL = 0x06,
00072 PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND = 0x81,
00073 PROTOCOL_BINARY_RESPONSE_ENOMEM = 0x82
00074 } protocol_binary_response_status;
00075
00080 typedef enum {
00081 PROTOCOL_BINARY_CMD_GET = 0x00,
00082 PROTOCOL_BINARY_CMD_SET = 0x01,
00083 PROTOCOL_BINARY_CMD_ADD = 0x02,
00084 PROTOCOL_BINARY_CMD_REPLACE = 0x03,
00085 PROTOCOL_BINARY_CMD_DELETE = 0x04,
00086 PROTOCOL_BINARY_CMD_INCREMENT = 0x05,
00087 PROTOCOL_BINARY_CMD_DECREMENT = 0x06,
00088 PROTOCOL_BINARY_CMD_QUIT = 0x07,
00089 PROTOCOL_BINARY_CMD_FLUSH = 0x08,
00090 PROTOCOL_BINARY_CMD_GETQ = 0x09,
00091 PROTOCOL_BINARY_CMD_NOOP = 0x0a,
00092 PROTOCOL_BINARY_CMD_VERSION = 0x0b,
00093 PROTOCOL_BINARY_CMD_GETK = 0x0c,
00094 PROTOCOL_BINARY_CMD_GETKQ = 0x0d,
00095 PROTOCOL_BINARY_CMD_APPEND = 0x0e,
00096 PROTOCOL_BINARY_CMD_PREPEND = 0x0f,
00097 PROTOCOL_BINARY_CMD_STAT = 0x10,
00098 PROTOCOL_BINARY_CMD_SETQ = 0x11,
00099 PROTOCOL_BINARY_CMD_ADDQ = 0x12,
00100 PROTOCOL_BINARY_CMD_REPLACEQ = 0x13,
00101 PROTOCOL_BINARY_CMD_DELETEQ = 0x14,
00102 PROTOCOL_BINARY_CMD_INCREMENTQ = 0x15,
00103 PROTOCOL_BINARY_CMD_DECREMENTQ = 0x16,
00104 PROTOCOL_BINARY_CMD_QUITQ = 0x17,
00105 PROTOCOL_BINARY_CMD_FLUSHQ = 0x18,
00106 PROTOCOL_BINARY_CMD_APPENDQ = 0x19,
00107 PROTOCOL_BINARY_CMD_PREPENDQ = 0x1a,
00108
00109
00110
00111
00112
00113 PROTOCOL_BINARY_CMD_RGET = 0x30,
00114 PROTOCOL_BINARY_CMD_RSET = 0x31,
00115 PROTOCOL_BINARY_CMD_RSETQ = 0x32,
00116 PROTOCOL_BINARY_CMD_RAPPEND = 0x33,
00117 PROTOCOL_BINARY_CMD_RAPPENDQ = 0x34,
00118 PROTOCOL_BINARY_CMD_RPREPEND = 0x35,
00119 PROTOCOL_BINARY_CMD_RPREPENDQ = 0x36,
00120 PROTOCOL_BINARY_CMD_RDELETE = 0x37,
00121 PROTOCOL_BINARY_CMD_RDELETEQ = 0x38,
00122 PROTOCOL_BINARY_CMD_RINCR = 0x39,
00123 PROTOCOL_BINARY_CMD_RINCRQ = 0x3a,
00124 PROTOCOL_BINARY_CMD_RDECR = 0x3b,
00125 PROTOCOL_BINARY_CMD_RDECRQ = 0x3c
00126
00127
00128 } protocol_binary_command;
00129
00134 typedef enum {
00135 PROTOCOL_BINARY_RAW_BYTES = 0x00
00136 } protocol_binary_datatypes;
00137
00142 typedef union {
00143 struct {
00144 uint8_t magic;
00145 uint8_t opcode;
00146 uint16_t keylen;
00147 uint8_t extlen;
00148 uint8_t datatype;
00149 uint16_t reserved;
00150 uint32_t bodylen;
00151 uint32_t opaque;
00152 uint64_t cas;
00153 } request;
00154 uint8_t bytes[24];
00155 } protocol_binary_request_header;
00156
00161 typedef union {
00162 struct {
00163 uint8_t magic;
00164 uint8_t opcode;
00165 uint16_t keylen;
00166 uint8_t extlen;
00167 uint8_t datatype;
00168 uint16_t status;
00169 uint32_t bodylen;
00170 uint32_t opaque;
00171 uint64_t cas;
00172 } response;
00173 uint8_t bytes[24];
00174 } protocol_binary_response_header;
00175
00179 typedef union {
00180 struct {
00181 protocol_binary_request_header header;
00182 } message;
00183 uint8_t bytes[sizeof(protocol_binary_request_header)];
00184 } protocol_binary_request_no_extras;
00185
00189 typedef union {
00190 struct {
00191 protocol_binary_response_header header;
00192 } message;
00193 uint8_t bytes[sizeof(protocol_binary_response_header)];
00194 } protocol_binary_response_no_extras;
00195
00200 typedef protocol_binary_request_no_extras protocol_binary_request_get;
00201 typedef protocol_binary_request_no_extras protocol_binary_request_getq;
00202 typedef protocol_binary_request_no_extras protocol_binary_request_getk;
00203 typedef protocol_binary_request_no_extras protocol_binary_request_getkq;
00204
00210 typedef union {
00211 struct {
00212 protocol_binary_response_header header;
00213 struct {
00214 uint32_t flags;
00215 } body;
00216 } message;
00217 uint8_t bytes[sizeof(protocol_binary_response_header) + 4];
00218 } protocol_binary_response_get;
00219
00220 typedef protocol_binary_response_get protocol_binary_response_getq;
00221 typedef protocol_binary_response_get protocol_binary_response_getk;
00222 typedef protocol_binary_response_get protocol_binary_response_getkq;
00223
00228 typedef protocol_binary_request_no_extras protocol_binary_request_delete;
00229
00234 typedef protocol_binary_response_no_extras protocol_binary_response_delete;
00235
00242 typedef union {
00243 struct {
00244 protocol_binary_request_header header;
00245 struct {
00246 uint32_t expiration;
00247 } body;
00248 } message;
00249 uint8_t bytes[sizeof(protocol_binary_request_header) + 4];
00250 } protocol_binary_request_flush;
00251
00256 typedef protocol_binary_response_no_extras protocol_binary_response_flush;
00257
00262 typedef union {
00263 struct {
00264 protocol_binary_request_header header;
00265 struct {
00266 uint32_t flags;
00267 uint32_t expiration;
00268 } body;
00269 } message;
00270 uint8_t bytes[sizeof(protocol_binary_request_header) + 8];
00271 } protocol_binary_request_set;
00272 typedef protocol_binary_request_set protocol_binary_request_add;
00273 typedef protocol_binary_request_set protocol_binary_request_replace;
00274
00279 typedef protocol_binary_response_no_extras protocol_binary_response_set;
00280 typedef protocol_binary_response_no_extras protocol_binary_response_add;
00281 typedef protocol_binary_response_no_extras protocol_binary_response_replace;
00282
00287 typedef protocol_binary_request_no_extras protocol_binary_request_noop;
00288
00293 typedef protocol_binary_response_no_extras protocol_binary_response_noop;
00294
00300 typedef union {
00301 struct {
00302 protocol_binary_request_header header;
00303 struct {
00304 uint64_t delta;
00305 uint64_t initial;
00306 uint32_t expiration;
00307 } body;
00308 } message;
00309 uint8_t bytes[sizeof(protocol_binary_request_header) + 20];
00310 } protocol_binary_request_incr;
00311 typedef protocol_binary_request_incr protocol_binary_request_decr;
00312
00318 typedef union {
00319 struct {
00320 protocol_binary_response_header header;
00321 struct {
00322 uint64_t value;
00323 } body;
00324 } message;
00325 uint8_t bytes[sizeof(protocol_binary_response_header) + 8];
00326 } protocol_binary_response_incr;
00327 typedef protocol_binary_response_incr protocol_binary_response_decr;
00328
00333 typedef protocol_binary_request_no_extras protocol_binary_request_quit;
00334
00339 typedef protocol_binary_response_no_extras protocol_binary_response_quit;
00340
00345 typedef protocol_binary_request_no_extras protocol_binary_request_append;
00346 typedef protocol_binary_request_no_extras protocol_binary_request_prepend;
00347
00352 typedef protocol_binary_response_no_extras protocol_binary_response_append;
00353 typedef protocol_binary_response_no_extras protocol_binary_response_prepend;
00354
00359 typedef protocol_binary_request_no_extras protocol_binary_request_version;
00360
00365 typedef protocol_binary_response_no_extras protocol_binary_response_version;
00366
00367
00372 typedef protocol_binary_request_no_extras protocol_binary_request_stats;
00373
00378 typedef protocol_binary_response_no_extras protocol_binary_response_stats;
00379
00388 typedef union {
00389 struct {
00390 protocol_binary_response_header header;
00391 struct {
00392 uint16_t size;
00393 uint8_t reserved;
00394 uint8_t flags;
00395 uint32_t max_results;
00396 } body;
00397 } message;
00398 uint8_t bytes[sizeof(protocol_binary_request_header) + 4];
00399 } protocol_binary_request_rangeop;
00400
00401 typedef protocol_binary_request_rangeop protocol_binary_request_rget;
00402 typedef protocol_binary_request_rangeop protocol_binary_request_rset;
00403 typedef protocol_binary_request_rangeop protocol_binary_request_rsetq;
00404 typedef protocol_binary_request_rangeop protocol_binary_request_rappend;
00405 typedef protocol_binary_request_rangeop protocol_binary_request_rappendq;
00406 typedef protocol_binary_request_rangeop protocol_binary_request_rprepend;
00407 typedef protocol_binary_request_rangeop protocol_binary_request_rprependq;
00408 typedef protocol_binary_request_rangeop protocol_binary_request_rdelete;
00409 typedef protocol_binary_request_rangeop protocol_binary_request_rdeleteq;
00410 typedef protocol_binary_request_rangeop protocol_binary_request_rincr;
00411 typedef protocol_binary_request_rangeop protocol_binary_request_rincrq;
00412 typedef protocol_binary_request_rangeop protocol_binary_request_rdecr;
00413 typedef protocol_binary_request_rangeop protocol_binary_request_rdecrq;
00414
00415 #ifdef __cplusplus
00416 }
00417 #endif
00418 #endif