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_UNKNOWN_COMMAND = 0x81,
00072 PROTOCOL_BINARY_RESPONSE_ENOMEM = 0x82
00073 } protocol_binary_response_status;
00074
00079 typedef enum {
00080 PROTOCOL_BINARY_CMD_GET = 0x00,
00081 PROTOCOL_BINARY_CMD_SET = 0x01,
00082 PROTOCOL_BINARY_CMD_ADD = 0x02,
00083 PROTOCOL_BINARY_CMD_REPLACE = 0x03,
00084 PROTOCOL_BINARY_CMD_DELETE = 0x04,
00085 PROTOCOL_BINARY_CMD_INCREMENT = 0x05,
00086 PROTOCOL_BINARY_CMD_DECREMENT = 0x06,
00087 PROTOCOL_BINARY_CMD_QUIT = 0x07,
00088 PROTOCOL_BINARY_CMD_FLUSH = 0x08,
00089 PROTOCOL_BINARY_CMD_GETQ = 0x09,
00090 PROTOCOL_BINARY_CMD_NOOP = 0x0a,
00091 PROTOCOL_BINARY_CMD_VERSION = 0x0b,
00092 PROTOCOL_BINARY_CMD_GETK = 0x0c,
00093 PROTOCOL_BINARY_CMD_GETKQ = 0x0d,
00094 PROTOCOL_BINARY_CMD_APPEND = 0x0e,
00095 PROTOCOL_BINARY_CMD_PREPEND = 0x0f,
00096 PROTOCOL_BINARY_CMD_STAT = 0x10,
00097 PROTOCOL_BINARY_CMD_SETQ = 0x11,
00098 PROTOCOL_BINARY_CMD_ADDQ = 0x12,
00099 PROTOCOL_BINARY_CMD_REPLACEQ = 0x13,
00100 PROTOCOL_BINARY_CMD_DELETEQ = 0x14,
00101 PROTOCOL_BINARY_CMD_INCREMENTQ = 0x15,
00102 PROTOCOL_BINARY_CMD_DECREMENTQ = 0x16,
00103 PROTOCOL_BINARY_CMD_QUITQ = 0x17,
00104 PROTOCOL_BINARY_CMD_FLUSHQ = 0x18,
00105 PROTOCOL_BINARY_CMD_APPENDQ = 0x19,
00106 PROTOCOL_BINARY_CMD_PREPENDQ = 0x1a
00107 } protocol_binary_command;
00108
00113 typedef enum {
00114 PROTOCOL_BINARY_RAW_BYTES = 0x00
00115 } protocol_binary_datatypes;
00116
00121 typedef union {
00122 struct {
00123 uint8_t magic;
00124 uint8_t opcode;
00125 uint16_t keylen;
00126 uint8_t extlen;
00127 uint8_t datatype;
00128 uint16_t reserved;
00129 uint32_t bodylen;
00130 uint32_t opaque;
00131 uint64_t cas;
00132 } request;
00133 uint8_t bytes[24];
00134 } protocol_binary_request_header;
00135
00140 typedef union {
00141 struct {
00142 uint8_t magic;
00143 uint8_t opcode;
00144 uint16_t keylen;
00145 uint8_t extlen;
00146 uint8_t datatype;
00147 uint16_t status;
00148 uint32_t bodylen;
00149 uint32_t opaque;
00150 uint64_t cas;
00151 } response;
00152 uint8_t bytes[24];
00153 } protocol_binary_response_header;
00154
00158 typedef union {
00159 struct {
00160 protocol_binary_request_header header;
00161 } message;
00162 uint8_t bytes[sizeof(protocol_binary_request_header)];
00163 } protocol_binary_request_no_extras;
00164
00168 typedef union {
00169 struct {
00170 protocol_binary_response_header header;
00171 } message;
00172 uint8_t bytes[sizeof(protocol_binary_response_header)];
00173 } protocol_binary_response_no_extras;
00174
00179 typedef protocol_binary_request_no_extras protocol_binary_request_get;
00180 typedef protocol_binary_request_no_extras protocol_binary_request_getq;
00181 typedef protocol_binary_request_no_extras protocol_binary_request_getk;
00182 typedef protocol_binary_request_no_extras protocol_binary_request_getkq;
00183
00189 typedef union {
00190 struct {
00191 protocol_binary_response_header header;
00192 struct {
00193 uint32_t flags;
00194 } body;
00195 } message;
00196 uint8_t bytes[sizeof(protocol_binary_response_header) + 4];
00197 } protocol_binary_response_get;
00198
00199 typedef protocol_binary_response_get protocol_binary_response_getq;
00200 typedef protocol_binary_response_get protocol_binary_response_getk;
00201 typedef protocol_binary_response_get protocol_binary_response_getkq;
00202
00207 typedef protocol_binary_request_no_extras protocol_binary_request_delete;
00208
00213 typedef protocol_binary_response_no_extras protocol_binary_response_delete;
00214
00221 typedef union {
00222 struct {
00223 protocol_binary_request_header header;
00224 struct {
00225 uint32_t expiration;
00226 } body;
00227 } message;
00228 uint8_t bytes[sizeof(protocol_binary_request_header) + 4];
00229 } protocol_binary_request_flush;
00230
00235 typedef protocol_binary_response_no_extras protocol_binary_response_flush;
00236
00241 typedef union {
00242 struct {
00243 protocol_binary_request_header header;
00244 struct {
00245 uint32_t flags;
00246 uint32_t expiration;
00247 } body;
00248 } message;
00249 uint8_t bytes[sizeof(protocol_binary_request_header) + 8];
00250 } protocol_binary_request_set;
00251 typedef protocol_binary_request_set protocol_binary_request_add;
00252 typedef protocol_binary_request_set protocol_binary_request_replace;
00253
00258 typedef protocol_binary_response_no_extras protocol_binary_response_set;
00259 typedef protocol_binary_response_no_extras protocol_binary_response_add;
00260 typedef protocol_binary_response_no_extras protocol_binary_response_replace;
00261
00266 typedef protocol_binary_request_no_extras protocol_binary_request_noop;
00267
00272 typedef protocol_binary_response_no_extras protocol_binary_response_noop;
00273
00279 typedef union {
00280 struct {
00281 protocol_binary_request_header header;
00282 struct {
00283 uint64_t delta;
00284 uint64_t initial;
00285 uint32_t expiration;
00286 } body;
00287 } message;
00288 uint8_t bytes[sizeof(protocol_binary_request_header) + 20];
00289 } protocol_binary_request_incr;
00290 typedef protocol_binary_request_incr protocol_binary_request_decr;
00291
00297 typedef union {
00298 struct {
00299 protocol_binary_response_header header;
00300 struct {
00301 uint64_t value;
00302 } body;
00303 } message;
00304 uint8_t bytes[sizeof(protocol_binary_response_header) + 8];
00305 } protocol_binary_response_incr;
00306 typedef protocol_binary_response_incr protocol_binary_response_decr;
00307
00312 typedef protocol_binary_request_no_extras protocol_binary_request_quit;
00313
00318 typedef protocol_binary_response_no_extras protocol_binary_response_quit;
00319
00324 typedef protocol_binary_request_no_extras protocol_binary_request_append;
00325 typedef protocol_binary_request_no_extras protocol_binary_request_prepend;
00326
00331 typedef protocol_binary_response_no_extras protocol_binary_response_append;
00332 typedef protocol_binary_response_no_extras protocol_binary_response_prepend;
00333
00338 typedef protocol_binary_request_no_extras protocol_binary_request_version;
00339
00344 typedef protocol_binary_response_no_extras protocol_binary_response_version;
00345
00346
00351 typedef protocol_binary_request_no_extras protocol_binary_request_stats;
00352
00357 typedef protocol_binary_response_no_extras protocol_binary_response_stats;
00358 #ifdef __cplusplus
00359 }
00360 #endif
00361 #endif