1a85a6e15STrond Norbye /* 2a85a6e15STrond Norbye * Copyright (c) <2008>, Sun Microsystems, Inc. 3a85a6e15STrond Norbye * All rights reserved. 4a85a6e15STrond Norbye * 5a85a6e15STrond Norbye * Redistribution and use in source and binary forms, with or without 6a85a6e15STrond Norbye * modification, are permitted provided that the following conditions are met: 7a85a6e15STrond Norbye * * Redistributions of source code must retain the above copyright 8a85a6e15STrond Norbye * notice, this list of conditions and the following disclaimer. 9a85a6e15STrond Norbye * * Redistributions in binary form must reproduce the above copyright 10a85a6e15STrond Norbye * notice, this list of conditions and the following disclaimer in the 11a85a6e15STrond Norbye * documentation and/or other materials provided with the distribution. 12a85a6e15STrond Norbye * * Neither the name of the nor the 13a85a6e15STrond Norbye * names of its contributors may be used to endorse or promote products 14a85a6e15STrond Norbye * derived from this software without specific prior written permission. 15a85a6e15STrond Norbye * 16a85a6e15STrond Norbye * THIS SOFTWARE IS PROVIDED BY SUN MICROSYSTEMS, INC. ``AS IS'' AND ANY 17a85a6e15STrond Norbye * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18a85a6e15STrond Norbye * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19a85a6e15STrond Norbye * DISCLAIMED. IN NO EVENT SHALL SUN MICROSYSTEMS, INC. BE LIABLE FOR ANY 20a85a6e15STrond Norbye * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21a85a6e15STrond Norbye * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22a85a6e15STrond Norbye * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23a85a6e15STrond Norbye * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24a85a6e15STrond Norbye * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25a85a6e15STrond Norbye * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26a85a6e15STrond Norbye */ 27a85a6e15STrond Norbye /* 28a85a6e15STrond Norbye * Summary: Constants used by to implement the binary protocol. 29a85a6e15STrond Norbye * 30a85a6e15STrond Norbye * Copy: See Copyright for the status of this software. 31a85a6e15STrond Norbye * 32a85a6e15STrond Norbye * Author: Trond Norbye <[email protected]> 33a85a6e15STrond Norbye */ 34a85a6e15STrond Norbye 35a85a6e15STrond Norbye #ifndef PROTOCOL_BINARY_H 36a85a6e15STrond Norbye #define PROTOCOL_BINARY_H 37a85a6e15STrond Norbye 38a85a6e15STrond Norbye /** 39a85a6e15STrond Norbye * This file contains definitions of the constants and packet formats 40a85a6e15STrond Norbye * defined in the binary specification. Please note that you _MUST_ remember 41a85a6e15STrond Norbye * to convert each multibyte field to / from network byte order to / from 42a85a6e15STrond Norbye * host order. 43a85a6e15STrond Norbye */ 44a85a6e15STrond Norbye #ifdef __cplusplus 45a85a6e15STrond Norbye extern "C" 46a85a6e15STrond Norbye { 47a85a6e15STrond Norbye #endif 48a85a6e15STrond Norbye 49a85a6e15STrond Norbye /** 50a85a6e15STrond Norbye * Definition of the legal "magic" values used in a packet. 51a85a6e15STrond Norbye * See section 3.1 Magic byte 52a85a6e15STrond Norbye */ 53a85a6e15STrond Norbye typedef enum { 54a85a6e15STrond Norbye PROTOCOL_BINARY_REQ = 0x80, 55df1b7e42STrond Norbye PROTOCOL_BINARY_RES = 0x81 56a85a6e15STrond Norbye } protocol_binary_magic; 57a85a6e15STrond Norbye 58a85a6e15STrond Norbye /** 59a85a6e15STrond Norbye * Definition of the valid response status numbers. 60a85a6e15STrond Norbye * See section 3.2 Response Status 61a85a6e15STrond Norbye */ 62a85a6e15STrond Norbye typedef enum { 63a85a6e15STrond Norbye PROTOCOL_BINARY_RESPONSE_SUCCESS = 0x00, 64a85a6e15STrond Norbye PROTOCOL_BINARY_RESPONSE_KEY_ENOENT = 0x01, 65a85a6e15STrond Norbye PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS = 0x02, 66a85a6e15STrond Norbye PROTOCOL_BINARY_RESPONSE_E2BIG = 0x03, 67a85a6e15STrond Norbye PROTOCOL_BINARY_RESPONSE_EINVAL = 0x04, 68a85a6e15STrond Norbye PROTOCOL_BINARY_RESPONSE_NOT_STORED = 0x05, 69cce46e8fSDustin Sallings PROTOCOL_BINARY_RESPONSE_DELTA_BADVAL = 0x06, 70f1307c4dSDustin Sallings PROTOCOL_BINARY_RESPONSE_AUTH_ERROR = 0x20, 71f1307c4dSDustin Sallings PROTOCOL_BINARY_RESPONSE_AUTH_CONTINUE = 0x21, 72a85a6e15STrond Norbye PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND = 0x81, 73df1b7e42STrond Norbye PROTOCOL_BINARY_RESPONSE_ENOMEM = 0x82 74a85a6e15STrond Norbye } protocol_binary_response_status; 75a85a6e15STrond Norbye 76a85a6e15STrond Norbye /** 77*81176472Sclark.kang * Definition of the different command opcodes. 78a85a6e15STrond Norbye * See section 3.3 Command Opcodes 79a85a6e15STrond Norbye */ 80a85a6e15STrond Norbye typedef enum { 81a85a6e15STrond Norbye PROTOCOL_BINARY_CMD_GET = 0x00, 82a85a6e15STrond Norbye PROTOCOL_BINARY_CMD_SET = 0x01, 83a85a6e15STrond Norbye PROTOCOL_BINARY_CMD_ADD = 0x02, 84a85a6e15STrond Norbye PROTOCOL_BINARY_CMD_REPLACE = 0x03, 85a85a6e15STrond Norbye PROTOCOL_BINARY_CMD_DELETE = 0x04, 86a85a6e15STrond Norbye PROTOCOL_BINARY_CMD_INCREMENT = 0x05, 87a85a6e15STrond Norbye PROTOCOL_BINARY_CMD_DECREMENT = 0x06, 88a85a6e15STrond Norbye PROTOCOL_BINARY_CMD_QUIT = 0x07, 89a85a6e15STrond Norbye PROTOCOL_BINARY_CMD_FLUSH = 0x08, 90a85a6e15STrond Norbye PROTOCOL_BINARY_CMD_GETQ = 0x09, 91a85a6e15STrond Norbye PROTOCOL_BINARY_CMD_NOOP = 0x0a, 92a85a6e15STrond Norbye PROTOCOL_BINARY_CMD_VERSION = 0x0b, 93a85a6e15STrond Norbye PROTOCOL_BINARY_CMD_GETK = 0x0c, 94a85a6e15STrond Norbye PROTOCOL_BINARY_CMD_GETKQ = 0x0d, 95a85a6e15STrond Norbye PROTOCOL_BINARY_CMD_APPEND = 0x0e, 96a85a6e15STrond Norbye PROTOCOL_BINARY_CMD_PREPEND = 0x0f, 970e8a58a8STrond Norbye PROTOCOL_BINARY_CMD_STAT = 0x10, 980e8a58a8STrond Norbye PROTOCOL_BINARY_CMD_SETQ = 0x11, 990e8a58a8STrond Norbye PROTOCOL_BINARY_CMD_ADDQ = 0x12, 1000e8a58a8STrond Norbye PROTOCOL_BINARY_CMD_REPLACEQ = 0x13, 1010e8a58a8STrond Norbye PROTOCOL_BINARY_CMD_DELETEQ = 0x14, 1020e8a58a8STrond Norbye PROTOCOL_BINARY_CMD_INCREMENTQ = 0x15, 1030e8a58a8STrond Norbye PROTOCOL_BINARY_CMD_DECREMENTQ = 0x16, 1040e8a58a8STrond Norbye PROTOCOL_BINARY_CMD_QUITQ = 0x17, 1050e8a58a8STrond Norbye PROTOCOL_BINARY_CMD_FLUSHQ = 0x18, 1060e8a58a8STrond Norbye PROTOCOL_BINARY_CMD_APPENDQ = 0x19, 10737be4c42SDustin Sallings PROTOCOL_BINARY_CMD_PREPENDQ = 0x1a, 108d87f568aSdormando PROTOCOL_BINARY_CMD_TOUCH = 0x1c, 109d87f568aSdormando PROTOCOL_BINARY_CMD_GAT = 0x1d, 110d87f568aSdormando PROTOCOL_BINARY_CMD_GATQ = 0x1e, 1110d16e8c0Sdormando PROTOCOL_BINARY_CMD_GATK = 0x23, 1120d16e8c0Sdormando PROTOCOL_BINARY_CMD_GATKQ = 0x24, 11337be4c42SDustin Sallings 114f1307c4dSDustin Sallings PROTOCOL_BINARY_CMD_SASL_LIST_MECHS = 0x20, 115f1307c4dSDustin Sallings PROTOCOL_BINARY_CMD_SASL_AUTH = 0x21, 116f1307c4dSDustin Sallings PROTOCOL_BINARY_CMD_SASL_STEP = 0x22, 117f1307c4dSDustin Sallings 11837be4c42SDustin Sallings /* These commands are used for range operations and exist within 11937be4c42SDustin Sallings * this header for use in other projects. Range operations are 12037be4c42SDustin Sallings * not expected to be implemented in the memcached server itself. 12137be4c42SDustin Sallings */ 12237be4c42SDustin Sallings PROTOCOL_BINARY_CMD_RGET = 0x30, 12337be4c42SDustin Sallings PROTOCOL_BINARY_CMD_RSET = 0x31, 12437be4c42SDustin Sallings PROTOCOL_BINARY_CMD_RSETQ = 0x32, 12537be4c42SDustin Sallings PROTOCOL_BINARY_CMD_RAPPEND = 0x33, 12637be4c42SDustin Sallings PROTOCOL_BINARY_CMD_RAPPENDQ = 0x34, 12737be4c42SDustin Sallings PROTOCOL_BINARY_CMD_RPREPEND = 0x35, 12837be4c42SDustin Sallings PROTOCOL_BINARY_CMD_RPREPENDQ = 0x36, 12937be4c42SDustin Sallings PROTOCOL_BINARY_CMD_RDELETE = 0x37, 13037be4c42SDustin Sallings PROTOCOL_BINARY_CMD_RDELETEQ = 0x38, 13137be4c42SDustin Sallings PROTOCOL_BINARY_CMD_RINCR = 0x39, 13237be4c42SDustin Sallings PROTOCOL_BINARY_CMD_RINCRQ = 0x3a, 13337be4c42SDustin Sallings PROTOCOL_BINARY_CMD_RDECR = 0x3b, 13437be4c42SDustin Sallings PROTOCOL_BINARY_CMD_RDECRQ = 0x3c 13537be4c42SDustin Sallings /* End Range operations */ 13637be4c42SDustin Sallings 137a85a6e15STrond Norbye } protocol_binary_command; 138a85a6e15STrond Norbye 139a85a6e15STrond Norbye /** 140a85a6e15STrond Norbye * Definition of the data types in the packet 141a85a6e15STrond Norbye * See section 3.4 Data Types 142a85a6e15STrond Norbye */ 143a85a6e15STrond Norbye typedef enum { 144df1b7e42STrond Norbye PROTOCOL_BINARY_RAW_BYTES = 0x00 145a85a6e15STrond Norbye } protocol_binary_datatypes; 146a85a6e15STrond Norbye 147a85a6e15STrond Norbye /** 148a85a6e15STrond Norbye * Definition of the header structure for a request packet. 149a85a6e15STrond Norbye * See section 2 150a85a6e15STrond Norbye */ 151a85a6e15STrond Norbye typedef union { 152a85a6e15STrond Norbye struct { 153a85a6e15STrond Norbye uint8_t magic; 154a85a6e15STrond Norbye uint8_t opcode; 155a85a6e15STrond Norbye uint16_t keylen; 156a85a6e15STrond Norbye uint8_t extlen; 157a85a6e15STrond Norbye uint8_t datatype; 158a85a6e15STrond Norbye uint16_t reserved; 159a85a6e15STrond Norbye uint32_t bodylen; 160a85a6e15STrond Norbye uint32_t opaque; 161a85a6e15STrond Norbye uint64_t cas; 162a85a6e15STrond Norbye } request; 163a85a6e15STrond Norbye uint8_t bytes[24]; 164a85a6e15STrond Norbye } protocol_binary_request_header; 165a85a6e15STrond Norbye 166a85a6e15STrond Norbye /** 167a85a6e15STrond Norbye * Definition of the header structure for a response packet. 168a85a6e15STrond Norbye * See section 2 169a85a6e15STrond Norbye */ 170a85a6e15STrond Norbye typedef union { 171a85a6e15STrond Norbye struct { 172a85a6e15STrond Norbye uint8_t magic; 173a85a6e15STrond Norbye uint8_t opcode; 174a85a6e15STrond Norbye uint16_t keylen; 175a85a6e15STrond Norbye uint8_t extlen; 176a85a6e15STrond Norbye uint8_t datatype; 177a85a6e15STrond Norbye uint16_t status; 178a85a6e15STrond Norbye uint32_t bodylen; 179a85a6e15STrond Norbye uint32_t opaque; 180a85a6e15STrond Norbye uint64_t cas; 181a85a6e15STrond Norbye } response; 182a85a6e15STrond Norbye uint8_t bytes[24]; 183a85a6e15STrond Norbye } protocol_binary_response_header; 184a85a6e15STrond Norbye 185a85a6e15STrond Norbye /** 186a85a6e15STrond Norbye * Definition of a request-packet containing no extras 187a85a6e15STrond Norbye */ 188a85a6e15STrond Norbye typedef union { 189a85a6e15STrond Norbye struct { 190a85a6e15STrond Norbye protocol_binary_request_header header; 191a85a6e15STrond Norbye } message; 192a85a6e15STrond Norbye uint8_t bytes[sizeof(protocol_binary_request_header)]; 193a85a6e15STrond Norbye } protocol_binary_request_no_extras; 194a85a6e15STrond Norbye 195a85a6e15STrond Norbye /** 196a85a6e15STrond Norbye * Definition of a response-packet containing no extras 197a85a6e15STrond Norbye */ 198a85a6e15STrond Norbye typedef union { 199a85a6e15STrond Norbye struct { 200a85a6e15STrond Norbye protocol_binary_response_header header; 201a85a6e15STrond Norbye } message; 202a85a6e15STrond Norbye uint8_t bytes[sizeof(protocol_binary_response_header)]; 203a85a6e15STrond Norbye } protocol_binary_response_no_extras; 204a85a6e15STrond Norbye 205a85a6e15STrond Norbye /** 206a85a6e15STrond Norbye * Definition of the packet used by the get, getq, getk and getkq command. 2075da8dbabSTrond Norbye * See section 4 208a85a6e15STrond Norbye */ 209a85a6e15STrond Norbye typedef protocol_binary_request_no_extras protocol_binary_request_get; 210a85a6e15STrond Norbye typedef protocol_binary_request_no_extras protocol_binary_request_getq; 211a85a6e15STrond Norbye typedef protocol_binary_request_no_extras protocol_binary_request_getk; 212a85a6e15STrond Norbye typedef protocol_binary_request_no_extras protocol_binary_request_getkq; 213a85a6e15STrond Norbye 214a85a6e15STrond Norbye /** 215a85a6e15STrond Norbye * Definition of the packet returned from a successful get, getq, getk and 216a85a6e15STrond Norbye * getkq. 2175da8dbabSTrond Norbye * See section 4 218a85a6e15STrond Norbye */ 219a85a6e15STrond Norbye typedef union { 220a85a6e15STrond Norbye struct { 221a85a6e15STrond Norbye protocol_binary_response_header header; 222a85a6e15STrond Norbye struct { 223a85a6e15STrond Norbye uint32_t flags; 224a85a6e15STrond Norbye } body; 225a85a6e15STrond Norbye } message; 226a85a6e15STrond Norbye uint8_t bytes[sizeof(protocol_binary_response_header) + 4]; 227a85a6e15STrond Norbye } protocol_binary_response_get; 228a85a6e15STrond Norbye 229a85a6e15STrond Norbye typedef protocol_binary_response_get protocol_binary_response_getq; 230a85a6e15STrond Norbye typedef protocol_binary_response_get protocol_binary_response_getk; 231a85a6e15STrond Norbye typedef protocol_binary_response_get protocol_binary_response_getkq; 232a85a6e15STrond Norbye 233a85a6e15STrond Norbye /** 234a85a6e15STrond Norbye * Definition of the packet used by the delete command 2355da8dbabSTrond Norbye * See section 4 236a85a6e15STrond Norbye */ 2375da8dbabSTrond Norbye typedef protocol_binary_request_no_extras protocol_binary_request_delete; 238a85a6e15STrond Norbye 239a85a6e15STrond Norbye /** 240a85a6e15STrond Norbye * Definition of the packet returned by the delete command 2415da8dbabSTrond Norbye * See section 4 242a85a6e15STrond Norbye */ 243a85a6e15STrond Norbye typedef protocol_binary_response_no_extras protocol_binary_response_delete; 244a85a6e15STrond Norbye 245a85a6e15STrond Norbye /** 246a85a6e15STrond Norbye * Definition of the packet used by the flush command 2475da8dbabSTrond Norbye * See section 4 248a85a6e15STrond Norbye * Please note that the expiration field is optional, so remember to see 249a85a6e15STrond Norbye * check the header.bodysize to see if it is present. 250a85a6e15STrond Norbye */ 251a85a6e15STrond Norbye typedef union { 252a85a6e15STrond Norbye struct { 253a85a6e15STrond Norbye protocol_binary_request_header header; 254a85a6e15STrond Norbye struct { 255a85a6e15STrond Norbye uint32_t expiration; 256a85a6e15STrond Norbye } body; 257a85a6e15STrond Norbye } message; 258a85a6e15STrond Norbye uint8_t bytes[sizeof(protocol_binary_request_header) + 4]; 259a85a6e15STrond Norbye } protocol_binary_request_flush; 260a85a6e15STrond Norbye 261a85a6e15STrond Norbye /** 262a85a6e15STrond Norbye * Definition of the packet returned by the flush command 2635da8dbabSTrond Norbye * See section 4 264a85a6e15STrond Norbye */ 265a85a6e15STrond Norbye typedef protocol_binary_response_no_extras protocol_binary_response_flush; 266a85a6e15STrond Norbye 267a85a6e15STrond Norbye /** 268a85a6e15STrond Norbye * Definition of the packet used by set, add and replace 2695da8dbabSTrond Norbye * See section 4 270a85a6e15STrond Norbye */ 271a85a6e15STrond Norbye typedef union { 272a85a6e15STrond Norbye struct { 273a85a6e15STrond Norbye protocol_binary_request_header header; 274a85a6e15STrond Norbye struct { 275a85a6e15STrond Norbye uint32_t flags; 276a85a6e15STrond Norbye uint32_t expiration; 277a85a6e15STrond Norbye } body; 278a85a6e15STrond Norbye } message; 279a85a6e15STrond Norbye uint8_t bytes[sizeof(protocol_binary_request_header) + 8]; 280a85a6e15STrond Norbye } protocol_binary_request_set; 281a85a6e15STrond Norbye typedef protocol_binary_request_set protocol_binary_request_add; 282a85a6e15STrond Norbye typedef protocol_binary_request_set protocol_binary_request_replace; 283a85a6e15STrond Norbye 284a85a6e15STrond Norbye /** 285a85a6e15STrond Norbye * Definition of the packet returned by set, add and replace 2865da8dbabSTrond Norbye * See section 4 287a85a6e15STrond Norbye */ 288a85a6e15STrond Norbye typedef protocol_binary_response_no_extras protocol_binary_response_set; 289a85a6e15STrond Norbye typedef protocol_binary_response_no_extras protocol_binary_response_add; 290a85a6e15STrond Norbye typedef protocol_binary_response_no_extras protocol_binary_response_replace; 291a85a6e15STrond Norbye 292a85a6e15STrond Norbye /** 293a85a6e15STrond Norbye * Definition of the noop packet 2945da8dbabSTrond Norbye * See section 4 295a85a6e15STrond Norbye */ 296a85a6e15STrond Norbye typedef protocol_binary_request_no_extras protocol_binary_request_noop; 297a85a6e15STrond Norbye 298a85a6e15STrond Norbye /** 299a85a6e15STrond Norbye * Definition of the packet returned by the noop command 3005da8dbabSTrond Norbye * See section 4 301a85a6e15STrond Norbye */ 302eb43524cSTrond Norbye typedef protocol_binary_response_no_extras protocol_binary_response_noop; 303a85a6e15STrond Norbye 304a85a6e15STrond Norbye /** 305a85a6e15STrond Norbye * Definition of the structure used by the increment and decrement 306a85a6e15STrond Norbye * command. 3075da8dbabSTrond Norbye * See section 4 308a85a6e15STrond Norbye */ 309a85a6e15STrond Norbye typedef union { 310a85a6e15STrond Norbye struct { 311a85a6e15STrond Norbye protocol_binary_request_header header; 312a85a6e15STrond Norbye struct { 313a85a6e15STrond Norbye uint64_t delta; 314a85a6e15STrond Norbye uint64_t initial; 315a85a6e15STrond Norbye uint32_t expiration; 316a85a6e15STrond Norbye } body; 317a85a6e15STrond Norbye } message; 318a85a6e15STrond Norbye uint8_t bytes[sizeof(protocol_binary_request_header) + 20]; 319a85a6e15STrond Norbye } protocol_binary_request_incr; 320a85a6e15STrond Norbye typedef protocol_binary_request_incr protocol_binary_request_decr; 321a85a6e15STrond Norbye 322a85a6e15STrond Norbye /** 323a85a6e15STrond Norbye * Definition of the response from an incr or decr command 324a85a6e15STrond Norbye * command. 3255da8dbabSTrond Norbye * See section 4 326a85a6e15STrond Norbye */ 327a85a6e15STrond Norbye typedef union { 328a85a6e15STrond Norbye struct { 329a85a6e15STrond Norbye protocol_binary_response_header header; 330a85a6e15STrond Norbye struct { 331a85a6e15STrond Norbye uint64_t value; 332a85a6e15STrond Norbye } body; 333a85a6e15STrond Norbye } message; 334a85a6e15STrond Norbye uint8_t bytes[sizeof(protocol_binary_response_header) + 8]; 335a85a6e15STrond Norbye } protocol_binary_response_incr; 336a85a6e15STrond Norbye typedef protocol_binary_response_incr protocol_binary_response_decr; 337a85a6e15STrond Norbye 338a85a6e15STrond Norbye /** 339a85a6e15STrond Norbye * Definition of the quit 3405da8dbabSTrond Norbye * See section 4 341a85a6e15STrond Norbye */ 342a85a6e15STrond Norbye typedef protocol_binary_request_no_extras protocol_binary_request_quit; 343a85a6e15STrond Norbye 344a85a6e15STrond Norbye /** 345a85a6e15STrond Norbye * Definition of the packet returned by the quit command 3465da8dbabSTrond Norbye * See section 4 347a85a6e15STrond Norbye */ 348a85a6e15STrond Norbye typedef protocol_binary_response_no_extras protocol_binary_response_quit; 349a85a6e15STrond Norbye 350a85a6e15STrond Norbye /** 351a85a6e15STrond Norbye * Definition of the packet used by append and prepend command 3525da8dbabSTrond Norbye * See section 4 353a85a6e15STrond Norbye */ 354a85a6e15STrond Norbye typedef protocol_binary_request_no_extras protocol_binary_request_append; 355a85a6e15STrond Norbye typedef protocol_binary_request_no_extras protocol_binary_request_prepend; 356a85a6e15STrond Norbye 357a85a6e15STrond Norbye /** 358a85a6e15STrond Norbye * Definition of the packet returned from a successful append or prepend 3595da8dbabSTrond Norbye * See section 4 360a85a6e15STrond Norbye */ 361a85a6e15STrond Norbye typedef protocol_binary_response_no_extras protocol_binary_response_append; 362a85a6e15STrond Norbye typedef protocol_binary_response_no_extras protocol_binary_response_prepend; 363a85a6e15STrond Norbye 3645da8dbabSTrond Norbye /** 3655da8dbabSTrond Norbye * Definition of the packet used by the version command 3665da8dbabSTrond Norbye * See section 4 3675da8dbabSTrond Norbye */ 3685da8dbabSTrond Norbye typedef protocol_binary_request_no_extras protocol_binary_request_version; 3695da8dbabSTrond Norbye 3705da8dbabSTrond Norbye /** 3715da8dbabSTrond Norbye * Definition of the packet returned from a successful version command 3725da8dbabSTrond Norbye * See section 4 3735da8dbabSTrond Norbye */ 3745da8dbabSTrond Norbye typedef protocol_binary_response_no_extras protocol_binary_response_version; 3755da8dbabSTrond Norbye 3765da8dbabSTrond Norbye 3775da8dbabSTrond Norbye /** 3785da8dbabSTrond Norbye * Definition of the packet used by the stats command. 3795da8dbabSTrond Norbye * See section 4 3805da8dbabSTrond Norbye */ 3815da8dbabSTrond Norbye typedef protocol_binary_request_no_extras protocol_binary_request_stats; 3825da8dbabSTrond Norbye 3835da8dbabSTrond Norbye /** 3845da8dbabSTrond Norbye * Definition of the packet returned from a successful stats command 3855da8dbabSTrond Norbye * See section 4 3865da8dbabSTrond Norbye */ 3875da8dbabSTrond Norbye typedef protocol_binary_response_no_extras protocol_binary_response_stats; 38837be4c42SDustin Sallings 38937be4c42SDustin Sallings /** 390d87f568aSdormando * Definition of the packet used by the touch command. 391d87f568aSdormando */ 392d87f568aSdormando typedef union { 393d87f568aSdormando struct { 394d87f568aSdormando protocol_binary_request_header header; 395d87f568aSdormando struct { 396d87f568aSdormando uint32_t expiration; 397d87f568aSdormando } body; 398d87f568aSdormando } message; 399d87f568aSdormando uint8_t bytes[sizeof(protocol_binary_request_header) + 4]; 400d87f568aSdormando } protocol_binary_request_touch; 401d87f568aSdormando 402d87f568aSdormando /** 403d87f568aSdormando * Definition of the packet returned from the touch command 404d87f568aSdormando */ 405d87f568aSdormando typedef protocol_binary_response_no_extras protocol_binary_response_touch; 406d87f568aSdormando 407d87f568aSdormando /** 408d87f568aSdormando * Definition of the packet used by the GAT(Q) command. 409d87f568aSdormando */ 410d87f568aSdormando typedef union { 411d87f568aSdormando struct { 412d87f568aSdormando protocol_binary_request_header header; 413d87f568aSdormando struct { 414d87f568aSdormando uint32_t expiration; 415d87f568aSdormando } body; 416d87f568aSdormando } message; 417d87f568aSdormando uint8_t bytes[sizeof(protocol_binary_request_header) + 4]; 418d87f568aSdormando } protocol_binary_request_gat; 419d87f568aSdormando 420d87f568aSdormando typedef protocol_binary_request_gat protocol_binary_request_gatq; 4210d16e8c0Sdormando typedef protocol_binary_request_gat protocol_binary_request_gatk; 4220d16e8c0Sdormando typedef protocol_binary_request_gat protocol_binary_request_gatkq; 423d87f568aSdormando 424d87f568aSdormando /** 425d87f568aSdormando * Definition of the packet returned from the GAT(Q) 426d87f568aSdormando */ 427d87f568aSdormando typedef protocol_binary_response_get protocol_binary_response_gat; 428d87f568aSdormando typedef protocol_binary_response_get protocol_binary_response_gatq; 4290d16e8c0Sdormando typedef protocol_binary_response_get protocol_binary_response_gatk; 4300d16e8c0Sdormando typedef protocol_binary_response_get protocol_binary_response_gatkq; 431d87f568aSdormando 432d87f568aSdormando /** 43337be4c42SDustin Sallings * Definition of a request for a range operation. 43437be4c42SDustin Sallings * See http://code.google.com/p/memcached/wiki/RangeOps 43537be4c42SDustin Sallings * 43637be4c42SDustin Sallings * These types are used for range operations and exist within 43737be4c42SDustin Sallings * this header for use in other projects. Range operations are 43837be4c42SDustin Sallings * not expected to be implemented in the memcached server itself. 43937be4c42SDustin Sallings */ 44037be4c42SDustin Sallings typedef union { 44137be4c42SDustin Sallings struct { 44237be4c42SDustin Sallings protocol_binary_response_header header; 44337be4c42SDustin Sallings struct { 44437be4c42SDustin Sallings uint16_t size; 44537be4c42SDustin Sallings uint8_t reserved; 44637be4c42SDustin Sallings uint8_t flags; 44737be4c42SDustin Sallings uint32_t max_results; 44837be4c42SDustin Sallings } body; 44937be4c42SDustin Sallings } message; 45037be4c42SDustin Sallings uint8_t bytes[sizeof(protocol_binary_request_header) + 4]; 45137be4c42SDustin Sallings } protocol_binary_request_rangeop; 45237be4c42SDustin Sallings 45337be4c42SDustin Sallings typedef protocol_binary_request_rangeop protocol_binary_request_rget; 45437be4c42SDustin Sallings typedef protocol_binary_request_rangeop protocol_binary_request_rset; 45537be4c42SDustin Sallings typedef protocol_binary_request_rangeop protocol_binary_request_rsetq; 45637be4c42SDustin Sallings typedef protocol_binary_request_rangeop protocol_binary_request_rappend; 45737be4c42SDustin Sallings typedef protocol_binary_request_rangeop protocol_binary_request_rappendq; 45837be4c42SDustin Sallings typedef protocol_binary_request_rangeop protocol_binary_request_rprepend; 45937be4c42SDustin Sallings typedef protocol_binary_request_rangeop protocol_binary_request_rprependq; 46037be4c42SDustin Sallings typedef protocol_binary_request_rangeop protocol_binary_request_rdelete; 46137be4c42SDustin Sallings typedef protocol_binary_request_rangeop protocol_binary_request_rdeleteq; 46237be4c42SDustin Sallings typedef protocol_binary_request_rangeop protocol_binary_request_rincr; 46337be4c42SDustin Sallings typedef protocol_binary_request_rangeop protocol_binary_request_rincrq; 46437be4c42SDustin Sallings typedef protocol_binary_request_rangeop protocol_binary_request_rdecr; 46537be4c42SDustin Sallings typedef protocol_binary_request_rangeop protocol_binary_request_rdecrq; 46637be4c42SDustin Sallings 467a85a6e15STrond Norbye #ifdef __cplusplus 468a85a6e15STrond Norbye } 469a85a6e15STrond Norbye #endif 470a85a6e15STrond Norbye #endif /* PROTOCOL_BINARY_H */ 471