31 #define CL_PROTO_RESULT_OK 0
32 #define CL_PROTO_RESULT_FAIL_UNKNOWN 1 // unknown failure
33 #define CL_PROTO_RESULT_FAIL_NOTFOUND 2
34 #define CL_PROTO_RESULT_FAIL_GENERATION 3
35 #define CL_PROTO_RESULT_FAIL_PARAMETER 4
36 #define CL_PROTO_RESULT_FAIL_KEY_EXISTS 5 // if 'WRITE_ADD', could fail because already exists
37 #define CL_PROTO_RESULT_FAIL_BIN_EXISTS 6
38 #define CL_PROTO_RESULT_FAIL_CLUSTER_KEY_MISMATCH 7
39 #define CL_PROTO_RESULT_FAIL_PARTITION_OUT_OF_SPACE 8
40 #define CL_PROTO_RESULT_FAIL_TIMEOUT 9
41 #define CL_PROTO_RESULT_FAIL_NOXDS 10
42 #define CL_PROTO_RESULT_FAIL_UNAVAILABLE 11 // error returned during node down and partition isn't available
43 #define CL_PROTO_RESULT_FAIL_INCOMPATIBLE_TYPE 12 // op and bin type incompatibilty
44 #define CL_PROTO_RESULT_FAIL_RECORD_TOO_BIG 13
45 #define CL_PROTO_RESULT_FAIL_KEY_BUSY 14
47 #define CL_PROTO_RESULT_FAIL_BIN_NOT_FOUND 17
102 #define CL_PROTO_VERSION 2
103 #define CL_PROTO_TYPE_INFO 1 // ascii-format message for determining server info
104 #define CL_PROTO_TYPE_CL_MSG 3
105 #define CL_PROTO_TYPE_CL_MSG_COMPRESSED 4
107 #define CL_RESULT_OK 0
108 #define CL_RESULT_FAIL 1
109 #define CL_RESULT_NOTFOUND 2
111 #if defined(__APPLE__) || defined(CF_WINDOWS)
113 #pragma pack(push, 1) // packing is now 1
119 #pragma pack(pop) // packing is back to what it was
121 #pragma pack(push, 1) // packing is now 1
128 typedef struct cl_comp_proto_s {
133 #pragma pack(pop) // packing is back to what it was
139 #pragma pack(push, 1)
147 #pragma pack(push, 1) // packing is now 1
157 #pragma pack(pop) // packing is back to what it was
174 #pragma pack(push, 1) // packing is now 1
179 #pragma pack(pop) // packing is back to what it was
186 #pragma pack(push, 1) // packing is now 1
201 #pragma pack(pop) // packing is back to what it was
208 #pragma pack(push, 1) // packing is now 1
213 #pragma pack(pop) // packing is back to what it was
231 typedef struct cl_comp_proto_s {
298 #define CL_MSG_FIELD_TYPE_NAMESPACE 0 // UTF8 string
299 #define CL_MSG_FIELD_TYPE_SET 1
300 #define CL_MSG_FIELD_TYPE_KEY 2 // contains a key type
301 #define CL_MSG_FIELD_TYPE_BIN 3 // used for secondary key access - contains a bin, thus a name and value
302 #define CL_MSG_FIELD_TYPE_DIGEST_RIPE 4 // used to send the digest just computed to the server so it doesn't have to
303 #define CL_MSG_FIELD_TYPE_GU_TID 5
304 #define CL_MSG_FIELD_TYPE_DIGEST_RIPE_ARRAY 6
305 #define CL_MSG_FIELD_TYPE_TRID 7
309 #define CL_MSG_FIELD_TYPE_SCAN_OPTIONS 8
310 #define CL_MSG_FIELD_TYPE_QUERY_OPTIONS 8
313 #define CL_MSG_FIELD_TYPE_INDEX_NAME 21
314 #define CL_MSG_FIELD_TYPE_INDEX_RANGE 22
315 #define CL_MSG_FIELD_TYPE_INDEX_FILTER 23
316 #define CL_MSG_FIELD_TYPE_INDEX_LIMIT 24
317 #define CL_MSG_FIELD_TYPE_INDEX_ORDER_BY 25
320 #define CL_MSG_FIELD_TYPE_UDF_FILENAME 30
321 #define CL_MSG_FIELD_TYPE_UDF_FUNCTION 31
322 #define CL_MSG_FIELD_TYPE_UDF_ARGLIST 32
323 #define CL_MSG_FIELD_TYPE_UDF_OP 33
335 #define CL_UDF_MSG_VAL_RECORD 0
336 #define CL_UDF_MSG_VAL_STREAM 1
339 #define CL_MSG_FIELD_TYPE_QUERY_BINLIST 40
342 #define CL_MSG_OP_READ 1 // read the value in question
343 #define CL_MSG_OP_WRITE 2 // write the value in question
344 #define CL_MSG_OP_WRITE_UNIQUE 3 // write a namespace-wide unique value
345 #define CL_MSG_OP_WRITE_NOW 4 // write the server-current time
346 #define CL_MSG_OP_INCR 5
347 #define CL_MSG_OP_APPEND_SEGMENT 6 // Append segment to a particle
348 #define CL_MSG_OP_APPEND_SEGMENT_EXT 7 // Extended append - with parameters
349 #define CL_MSG_OP_APPEND_SEGMENT_QUERY 8 // Query to return subset of segments
350 #define CL_MSG_OP_APPEND 9 // Add to an existing particle
351 #define CL_MSG_OP_PREPEND 10 // Add to the beginning of an existing particle
352 #define CL_MSG_OP_TOUCH 11 // Touch
354 #define CL_MSG_OP_MC_INCR 129 // Memcache-compatible version of the increment command
355 #define CL_MSG_OP_MC_APPEND 130 // Memcache compatible append. Allow appending to ints.
356 #define CL_MSG_OP_MC_PREPEND 131 // Memcache compatile prepend. Allow prepending to ints.
357 #define CL_MSG_OP_MC_TOUCH 132 // Memcache compatible touch - does not change generation count
359 #define CL_MSG_INFO1_READ (1 << 0) // contains a read operation
360 #define CL_MSG_INFO1_GET_ALL (1 << 1) // get all bins, period
361 #define CL_MSG_INFO1_GET_ALL_NODATA (1 << 2) // get all bins WITHOUT data (currently unimplemented)
362 #define CL_MSG_INFO1_VERIFY (1 << 3) // verify is a GET transaction that includes data, and assert if the data aint right
363 #define CL_MSG_INFO1_XDS (1 << 4) // operation is being performed by XDS
364 #define CL_MSG_INFO1_NOBINDATA (1 << 5) // do not get information about bins and its data
365 #define CL_MSG_INFO1_CHECK_KEY (1 << 6) // check key against record's stored key
367 #define CL_MSG_INFO2_WRITE (1 << 0) // contains a write semantic
368 #define CL_MSG_INFO2_DELETE (1 << 1) // fling a record into the belly of Moloch
369 #define CL_MSG_INFO2_GENERATION (1 << 2) // pay attention to the generation
370 #define CL_MSG_INFO2_GENERATION_GT (1 << 3) // apply write if new generation >= old, good for restore
371 #define CL_MSG_INFO2_GENERATION_DUP (1 << 4) // if a generation collision, create a duplicate
372 #define CL_MSG_INFO2_CREATE_ONLY (1 << 5) // write record only if it doesn't exist
373 #define CL_MSG_INFO2_BIN_CREATE_ONLY (1 << 6) // write bin only if it doesn't exist
374 #define CL_MSG_INFO2_WRITE_MERGE (1 << 7) // merge this with current
376 #define CL_MSG_INFO3_LAST (1 << 0) // this is the last of a multi-part message
377 #define CL_MSG_INFO3_TRACE (1 << 1) // apply server trace logging for this transaction
378 #define CL_MSG_INFO3_TOMBSTONE (1 << 2) // if set on response, a version was a delete tombstone
379 #define CL_MSG_INFO3_UPDATE_ONLY (1 << 3) // update existing record only, do not create new record
380 #define CL_MSG_INFO3_CREATE_OR_REPLACE (1 << 4) // completely replace existing record, or create new record
381 #define CL_MSG_INFO3_REPLACE_ONLY (1 << 5) // completely replace existing record, do not create new record
382 #define CL_MSG_INFO3_BIN_REPLACE_ONLY (1 << 6) // replace existing bin, do not create new bin
387 return ( ((uint8_t *)op) +
sizeof(cl_msg_op) + op->name_sz);
392 return( op->op_sz - (4 + op->name_sz) );
397 return( f->field_sz - 1 );
400 static inline cl_msg_field *
403 return ( (cl_msg_field *) (((uint8_t *)mf) +
sizeof(mf->field_sz) + mf->field_sz) );
409 static inline cl_msg_field *
413 cl_msg_field *fp = NULL;
415 fp = (cl_msg_field *)msg->data;
416 for (n = 0; n < msg->n_fields; n++) {
418 if (fp->type == type)
423 if (n == msg->n_fields)
435 static inline cl_msg_op *
438 return ( (cl_msg_op *) (((uint8_t *) op) +
sizeof(op->op_sz) + op->op_sz ) );
442 static inline cl_msg_op *
447 if (msg->n_ops == 0)
return(0);
448 cl_msg_field *mf = (cl_msg_field *) msg->data;
449 for (uint32_t i = 0; i < msg->n_fields; i++)
451 current = (cl_msg_op *) mf;
456 if (*n >= msg->n_ops)
return(0);
467 return(
sizeof(cl_proto) + proto->sz);
static uint8_t * cl_msg_op_get_value_p(cl_msg_op *op)
void cl_msg_swap_header_from_be(cl_msg *m)
static cl_msg_field * cl_msg_field_get_next(cl_msg_field *mf)
static cl_msg_op * cl_msg_op_get_next(cl_msg_op *op)
void cl_msg_swap_field_from_be(cl_msg_field *mf)
void cl_proto_swap_to_be(cl_proto *m)
static uint32_t cl_msg_field_get_value_sz(cl_msg_field *f)
void cl_msg_swap_op_to_be(cl_msg_op *op)
static cl_msg_op * cl_msg_op_iterate(cl_msg *msg, cl_msg_op *current, int *n)
void cl_msg_swap_header_to_be(cl_msg *m)
static uint32_t cl_msg_op_get_value_sz(cl_msg_op *op)
static cl_msg_field * cl_msg_field_get(cl_msg *msg, uint8_t type)
static size_t cl_proto_size_get(cl_proto *proto)
void cl_msg_swap_field_to_be(cl_msg_field *mf)
struct cl_proto_s __attribute__((__packed__)) cl_proto
void cl_proto_swap_from_be(cl_proto *m)
void cl_msg_swap_op_from_be(cl_msg_op *op)