4e8d2f6d10
I ended up cherry-picking different parts from each implementation. I liked David's changes to the read state machine to implement SASL. I used Stephene's implementation of the binary protocol integrated with the ASCII protocol.
32 lines
557 B
C
32 lines
557 B
C
#ifndef BINARY_PROTOCOL_H
|
|
#define BINARY_PROTOCOL_H
|
|
|
|
#define CMD_GET 0x00
|
|
#define CMD_SET 0x01
|
|
#define CMD_SASL 0x21
|
|
|
|
#define RESP_OK 0x00
|
|
#define RESP_SASL_ERR 0x20
|
|
|
|
typedef struct __attribute__ ((__packed__)) {
|
|
uint8_t magic;
|
|
uint8_t opcode;
|
|
uint16_t key_len;
|
|
|
|
uint8_t extra_len;
|
|
uint8_t data_type;
|
|
union {
|
|
uint16_t vbucket; // request use
|
|
uint16_t status; // response use
|
|
};
|
|
|
|
uint32_t body_len;
|
|
uint32_t opaque;
|
|
uint64_t version;
|
|
|
|
// Used for set only.
|
|
uint64_t extras;
|
|
} binary_header_t;
|
|
|
|
#endif /* BINARY_PROTOCOL_H */
|