June 21, 2014 Nesta Data Store Binary Protocol Abstract This memo explains the Nesta Data Store binary protocol. 1. Introduction Nesta Data Store is a high performance key-value data store. Can access to the data store using this protocol for application. 2. Packet Structure General format of a packet. Request header: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| Magic | Opcode | Reserved | +---------------+---------------+---------------+---------------+ Total 4 bytes Response header: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| Magic | Opcode | Status | Reserved | +---------------+---------------+---------------+---------------+ Total 4 bytes Header fields: Magic Magic number. Opcode Command code. length Length in bytes. Status Status of the response (non-zero on error). Reserved Really reserved for future use. 3. Defined Values 3.1. Magic Byte 0x80 Request packet for this protocol version 0x81 Response packet for this protocol version Magic byte / version. For each version of the protocol, we'll use a different request/response value pair. This is useful for protocol analyzers to distinguish the nature of the packet from the direction which it is moving. The version should hopefully correspond only to different meanings of the command byte. In an ideal world, we will not change the header format. As reserved bytes are given defined meaning, the protocol version / magic byte values should be incremented. 3.2. Response Status Possible values of this one-byte field: 0x00 No error 0x01 Key not found 0x02 Key exists 0x03 Value too large 0x04 Invalid arguments (Illegal handle) 0x05 Item not stored (Data version error) 0x06 End of Cursor 0x21 Unknown command 0x22 Out of memory 0x23 Connection refused 0x24 Illegal userid or password 3.3. Command Opcodes Possible values of the one-byte field: 0x01 nds_connect 0x02 nds_disconnect 0x03 nds_initialize 0x04 nds_finalize 0x05 nds_property 0x06 nds_open 0x07 nds_create 0x08 nds_colse 0x09 nds_file 0x0A nds_cmpfunc 0x0B nds_attach 0x0C nds_detach 0x10 nds_find 0x11 nds_get 0x12 nds_gets 0x13 nds_put 0x14 nds_puts 0x15 nds_delete 0x20 nds_cursor_open 0x21 nds_cursor_close 0x22 nds_cursor_next 0x23 nds_cursor_nextkey 0x24 nds_cursor_prev 0x25 nds_cursor_prevkey 0x26 nds_cursor_duplicate_last 0x27 nds_cursor_find 0x28 nds_cursor_seek 0x29 nds_cursor_key 0x2A nds_cursor_value 0x2B nds_cursor_update 0x2C nds_cursor_delete 0x2D nds_cursor_vsize 0x30 nds_trx_begin 0x31 nds_trx_set_target 0x32 nds_trx_commit 0x33 nds_trx_rollback 4. Commands 4.1. Introduction All communication is initiated by a request from the client, and the server will respond to each request with zero or multiple packets for each request. If the status code of a response packet is non-nil, the body of the packet will contain a textual error message. If the status code is nil, the command opcode will define the layout of the body of the message. uint32_t nds_connect(const char* ipaddr, unsigned int port, const char* userid, const char* password) Request data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x80 | 0x01 | Reserved | +---------------+---------------+---------------+---------------+ 4| userid length | password length | +---------------+---------------+---------------+---------------+ (*)| userid | +---------------+---------------+---------------+---------------+ (*)| password | +---------------+---------------+---------------+---------------+ Total 8 bytes + userid length + password length Response data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x81 | 0x01 | Status | Reserved | +---------------+---------------+---------------+---------------+ 4| connection handle | +---------------+---------------+---------------+---------------+ Total 8 bytes void nds_disconnect(uint32_t connection_handle); Request data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x80 | 0x02 | Reserved | +---------------+---------------+---------------+---------------+ 4| connection handle | +---------------+---------------+---------------+---------------+ Total 8 bytes Response data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x81 | 0x02 | Status | Reserved | +---------------+---------------+---------------+---------------+ Total 4 bytes uint32_t nds_initialize(uint32_t connection_handle, uint16_t dbtype); Request data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x80 | 0x03 | Reserved | +---------------+---------------+---------------+---------------+ 4| connection handle | +---------------+---------------+---------------+---------------+ 8| dbtype | +---------------+---------------+ Total 10 bytes Response data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x81 | 0x03 | Status | Reserved | +---------------+---------------+---------------+---------------+ 4| handle | +---------------+---------------+---------------+---------------+ Total 8 bytes uint32_t nds_finalize(uint32_t handle); Request data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x80 | 0x04 | Reserved | +---------------+---------------+---------------+---------------+ 4| handle | +---------------+---------------+---------------+---------------+ Total 8 bytes Response data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x81 | 0x04 | Status | Reserved | +---------------+---------------+---------------+---------------+ Total 4 bytes int nds_property(uint32_t handle, uint32_t kind, uint32_t value); Request data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x80 | 0x05 | Reserved | +---------------+---------------+---------------+---------------+ 4| handle | +---------------+---------------+---------------+---------------+ 8| kind | +---------------+---------------+---------------+---------------+ 10| value | +---------------+---------------+---------------+---------------+ Total 16 bytes Response data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x81 | 0x05 | Status | Reserved | +---------------+---------------+---------------+---------------+ Total 4 bytes uint32_t nds_open(uint32_t handle, const char* fname); Request data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x80 | 0x06 | Reserved | +---------------+---------------+---------------+---------------+ 4| handle | +---------------+---------------+---------------+---------------+ 8| filename length | filename | +---------------+---------------+---------------+---------------+ (*)| ... | +---------------+---------------+---------------+---------------+ Total 10 bytes + fname length Response data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x81 | 0x06 | Status | Reserved | +---------------+---------------+---------------+---------------+ 4| handle | +---------------+---------------+---------------+---------------+ Total 8 bytes uint32_t nds_create(uint32_t handle, const char* fname); Request data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x80 | 0x07 | Reserved | +---------------+---------------+---------------+---------------+ 4| handle | +---------------+---------------+---------------+---------------+ 8| filename length | filename | +---------------+---------------+---------------+---------------+ (*)| ... | +---------------+---------------+---------------+---------------+ Total 10 bytes + fname length Response data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x81 | 0x07 | Status | Reserved | +---------------+---------------+---------------+---------------+ Total 4 bytes void nds_close(uint32_t handle); Request data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x80 | 0x08 | Reserved | +---------------+---------------+---------------+---------------+ 4| handle | +---------------+---------------+---------------+---------------+ Total 8 bytes Response data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x81 | 0x08 | Status | Reserved | +---------------+---------------+---------------+---------------+ Total 4 bytes int nds_file(uint32_t handle, const char* fname); Request data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x80 | 0x09 | Reserved | +---------------+---------------+---------------+---------------+ 4| handle | +---------------+---------------+---------------+---------------+ 8| filename length | filename | +---------------+---------------+---------------+---------------+ (*)| ... | +---------------+---------------+---------------+---------------+ Total 10 bytes + fname length Response data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x81 | 0x09 | Status | Reserved | +---------------+---------------+---------------+---------------+ Total 4 bytes void nds_cmpfunc(uint32_t handle); Request data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x80 | 0x0A | Reserved | +---------------+---------------+---------------+---------------+ 4| handle | +---------------+---------------+---------------+---------------+ Total 8 bytes Response data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x81 | 0x0A | Status | Reserved | +---------------+---------------+---------------+---------------+ Total 4 bytes uint32_t nds_attach(const char* ipaddr, unsigned int port, const char* userid, const char* password, const char* fname); Request data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x80 | 0x0B | Reserved | +---------------+---------------+---------------+---------------+ 4| userid length | password length | +---------------+---------------+---------------+---------------+ (*)| userid | +---------------+---------------+---------------+---------------+ (*)| password | +---------------+---------------+---------------+---------------+ (*)| filename length | filename | +---------------+---------------+---------------+---------------+ (*)| ... | +---------------+---------------+---------------+---------------+ Total 10 bytes + userid length + password length + filename length Response data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x81 | 0x0B | Status | Reserved | +---------------+---------------+---------------+---------------+ 4| connection handle | +---------------+---------------+---------------+---------------+ 8| handle | +---------------+---------------+---------------+---------------+ Total 12 bytes void nds_detach(uint32_t handle); Request data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x80 | 0x0C | Reserved | +---------------+---------------+---------------+---------------+ 4| connection handle | +---------------+---------------+---------------+---------------+ 8| handle | +---------------+---------------+---------------+---------------+ Total 12 bytes Response data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x81 | 0x0C | Status | Reserved | +---------------+---------------+---------------+---------------+ Total 4 bytes int nds_find(uint32_t handle, const void* key, int keysize); Request data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x80 | 0x10 | Reserved | +---------------+---------------+---------------+---------------+ 4| handle | +---------------+---------------+---------------+---------------+ 8| key length | +---------------+---------------+---------------+---------------+ 12| key | +---------------+---------------+---------------+---------------+ (*)| ... | +---------------+---------------+---------------+---------------+ Total 12 bytes + key length Response data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x81 | 0x10 | Status | Reserved | +---------------+---------------+---------------+---------------+ 4| value length (If Status STATUS_SUCCESS only) | +---------------+---------------+---------------+---------------+ Total 8 bytes int nds_get(uint32_t handle, const void* key, int keysize, void* val, int valsize); Request data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x80 | 0x11 | Reserved | +---------------+---------------+---------------+---------------+ 4| handle | +---------------+---------------+---------------+---------------+ 8| key length | +---------------+---------------+---------------+---------------+ 12| key | +---------------+---------------+---------------+---------------+ (*)| ... | +---------------+---------------+---------------+---------------+ Total 12 bytes + key length Response data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x81 | 0x11 | Status | Reserved | +---------------+---------------+---------------+---------------+ 4| value length | +---------------+---------------+---------------+---------------+ 8| value | +---------------+---------------+---------------+---------------+ (*)| ... | +---------------+---------------+---------------+---------------+ Total 8 bytes + value length int nds_gets(uint32_t handle, const void* key, int keysize, void* val, int valsize, int64* cas); Request data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x80 | 0x12 | Reserved | +---------------+---------------+---------------+---------------+ 4| handle | +---------------+---------------+---------------+---------------+ 8| key length | +---------------+---------------+---------------+---------------+ 12| key | +---------------+---------------+---------------+---------------+ (*)| ... | +---------------+---------------+---------------+---------------+ Total 12 bytes + key length Response data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x81 | 0x12 | Status | Reserved | +---------------+---------------+---------------+---------------+ 4| value length | +---------------+---------------+---------------+---------------+ (*)| value | +---------------+---------------+---------------+---------------+ (*)| ... | +---------------+---------------+---------------+---------------+ (*0)| cas | +---------------+---------------+---------------+---------------+ (*4)| | +---------------+---------------+---------------+---------------+ (*8)| | +---------------+---------------+---------------+---------------+ (*12)| | +---------------+---------------+---------------+---------------+ Total 8 bytes + value length + cas(8 bytes) int nds_put(uint32_t handle, const void* key, int keysize, const void* val, int valsize); Request data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x80 | 0x13 | Reserved | +---------------+---------------+---------------+---------------+ 4| handle | +---------------+---------------+---------------+---------------+ 8| key length | +---------------+---------------+---------------+---------------+ 12| value length | +---------------+---------------+---------------+---------------+ (*)| key | +---------------+---------------+---------------+---------------+ (*)| ... | +---------------+---------------+---------------+---------------+ (*)| value | +---------------+---------------+---------------+---------------+ (*)| ... | +---------------+---------------+---------------+---------------+ Total 16 bytes + key length + value length Response data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x81 | 0x13 | Status | Reserved | +---------------+---------------+---------------+---------------+ Total 4 bytes int nds_puts(uint32_t handle, const void* key, int keysize, const void* val, int valsize, int64 cas); Request data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x80 | 0x14 | Reserved | +---------------+---------------+---------------+---------------+ 4| handle | +---------------+---------------+---------------+---------------+ 8| key length | +---------------+---------------+---------------+---------------+ 12| value length | +---------------+---------------+---------------+---------------+ 16| cas | +---------------+---------------+---------------+---------------+ 20| | +---------------+---------------+---------------+---------------+ 24| | +---------------+---------------+---------------+---------------+ 28| | +---------------+---------------+---------------+---------------+ (*0)| key | +---------------+---------------+---------------+---------------+ (*)| ... | +---------------+---------------+---------------+---------------+ (*0)| value | +---------------+---------------+---------------+---------------+ (*)| ... | +---------------+---------------+---------------+---------------+ Total 32 bytes + key length + value length Response data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x81 | 0x14 | Status | Reserved | +---------------+---------------+---------------+---------------+ Total 4 bytes int nds_delete(uint32_t handle, const void* key, int keysize); Request data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x80 | 0x15 | Reserved | +---------------+---------------+---------------+---------------+ 4| handle | +---------------+---------------+---------------+---------------+ 8| key length | +---------------+---------------+---------------+---------------+ (*)| key | +---------------+---------------+---------------+---------------+ Total 12 bytes + key length Response data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x81 | 0x15 | Status | Reserved | +---------------+---------------+---------------+---------------+ Total 4 bytes uint32_t nds_cursor_t* nds_cursor_open(uint32_t handle); Request data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x80 | 0x20 | Reserved | +---------------+---------------+---------------+---------------+ 4| handle | +---------------+---------------+---------------+---------------+ Total 8 bytes Response data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x81 | 0x20 | Status | Reserved | +---------------+---------------+---------------+---------------+ 4| cursor handle | +---------------+---------------+---------------+---------------+ Total 8 bytes void nds_cursor_close(uint32_t cursor_hadle); Request data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x80 | 0x21 | Reserved | +---------------+---------------+---------------+---------------+ 4| cursor handle | +---------------+---------------+---------------+---------------+ Total 8 bytes Response data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x81 | 0x21 | Status | Reserved | +---------------+---------------+---------------+---------------+ Total 4 bytes int nds_cursor_next(uint32_t cursor_handle); Request data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x80 | 0x22 | Reserved | +---------------+---------------+---------------+---------------+ 4| cursor handle | +---------------+---------------+---------------+---------------+ Total 8 bytes Response data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x81 | 0x22 | Status | Reserved | +---------------+---------------+---------------+---------------+ Total 4 bytes int nds_cursor_nextkey(uint32_t cursor_handle); Request data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x80 | 0x23 | Reserved | +---------------+---------------+---------------+---------------+ 4| cursor handle | +---------------+---------------+---------------+---------------+ Total 8 bytes Response data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x81 | 0x23 | Status | Reserved | +---------------+---------------+---------------+---------------+ Total 4 bytes int nds_cursor_prev(uint32_t cursor_handle); Request data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x80 | 0x24 | Reserved | +---------------+---------------+---------------+---------------+ 4| cursor handle | +---------------+---------------+---------------+---------------+ Total 8 bytes Response data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x81 | 0x24 | Status | Reserved | +---------------+---------------+---------------+---------------+ Total 4 bytes int nds_cursor_prevkey(uint32_t cursor_handle); Request data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x80 | 0x25 | Reserved | +---------------+---------------+---------------+---------------+ 4| cursor handle | +---------------+---------------+---------------+---------------+ Total 8 bytes Response data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x81 | 0x25 | Status | Reserved | +---------------+---------------+---------------+---------------+ Total 4 bytes int nds_cursor_duplicate_last(uint32_t cursor_handle); Request data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x80 | 0x26 | Reserved | +---------------+---------------+---------------+---------------+ 4| cursor handle | +---------------+---------------+---------------+---------------+ Total 8 bytes Response data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x81 | 0x26 | Status | Reserved | +---------------+---------------+---------------+---------------+ Total 4 bytes int nds_cursor_find(uint32_t cursor_handle, int cond, const void* key, int keysize); Request data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x80 | 0x27 | Reserved | +---------------+---------------+---------------+---------------+ 4| cursor handle | +---------------+---------------+---------------+---------------+ 8| condition | key length | +---------------+---------------+---------------+---------------+ 12| | Key | +---------------+---------------+---------------+---------------+ (*)| ... | +---------------+---------------+---------------+---------------+ Total 14 bytes + key length Response data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x81 | 0x27 | Status | Reserved | +---------------+---------------+---------------+---------------+ Total 4 bytes int nds_cursor_seek(uint32_t cursor_handle, int pos); Request data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x80 | 0x28 | Reserved | +---------------+---------------+---------------+---------------+ 4| cursor handle | +---------------+---------------+---------------+---------------+ 8| position | +---------------+---------------+ Total 10 bytes Response data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x81 | 0x28 | Status | Reserved | +---------------+---------------+---------------+---------------+ Total 4 bytes int nds_cursor_key(uint32_t cursor_handle, void* key, int keysize); Request data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x80 | 0x29 | Reserved | +---------------+---------------+---------------+---------------+ 4| cursor handle | +---------------+---------------+---------------+---------------+ Total 8 bytes Response data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x81 | 0x29 | Status | Reserved | +---------------+---------------+---------------+---------------+ 4| key length | +---------------+---------------+---------------+---------------+ (*)| Key | +---------------+---------------+---------------+---------------+ Total 8 bytes + key length int nds_cursor_value(uint32_t cursor_handle, void* val, int valsize); Request data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x80 | 0x2A | Reserved | +---------------+---------------+---------------+---------------+ 4| cursor handle | +---------------+---------------+---------------+---------------+ 8| value size | +---------------+---------------+---------------+---------------+ Total 12 bytes Response data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x81 | 0x2A | Status | Reserved | +---------------+---------------+---------------+---------------+ 4| Value length | +---------------+---------------+---------------+---------------+ (*)| Value | +---------------+---------------+---------------+---------------+ Total 8 bytes + Value length int nds_cursor_update(uint32_t cursor_handle, const void* val, int valsize); Request data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x80 | 0x2B | Reserved | +---------------+---------------+---------------+---------------+ 4| cursor handle | +---------------+---------------+---------------+---------------+ 8| Value length | +---------------+---------------+---------------+---------------+ (*)| Value | +---------------+---------------+---------------+---------------+ Total 12 bytes + Value length Response data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x81 | 0x2B | Status | Reserved | +---------------+---------------+---------------+---------------+ Total 4 bytes int nds_cursor_delete(uint32_t cursor_handle); Request data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x80 | 0x2C | Reserved | +---------------+---------------+---------------+---------------+ 4| cursor handle | +---------------+---------------+---------------+---------------+ Total 8 bytes Response data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x81 | 0x2C | Status | Reserved | +---------------+---------------+---------------+---------------+ Total 4 bytes int nds_cursor_vsize(uint32_t cursor_handle) Request data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x80 | 0x2D | Reserved | +---------------+---------------+---------------+---------------+ 4| cursor handle | +---------------+---------------+---------------+---------------+ Total 8 bytes Response data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x81 | 0x2D | Status | Reserved | +---------------+---------------+---------------+---------------+ 4| Value length | +---------------+---------------+---------------+---------------+ Total 8 bytes uint32_t nds_trx_begin(uint32_t connection_handle); Request data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x80 | 0x30 | Reserved | +---------------+---------------+---------------+---------------+ 4| connection handle | +---------------+---------------+---------------+---------------+ Total 8 bytes Response data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x81 | 0x30 | Status | Reserved | +---------------+---------------+---------------+---------------+ 4| transaction handle | +---------------+---------------+---------------+---------------+ Total 8 bytes void nds_trx_set_target(uint32_t transaction_handle, uint32_t handle); Request data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x80 | 0x31 | Reserved | +---------------+---------------+---------------+---------------+ 4| transaction handle | +---------------+---------------+---------------+---------------+ 8| handle | +---------------+---------------+---------------+---------------+ Total 12 bytes Response data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x81 | 0x31 | Status | Reserved | +---------------+---------------+---------------+---------------+ Total 4 bytes void nds_trx_commit(uint32_t transaction_handle); Request data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x80 | 0x32 | Reserved | +---------------+---------------+---------------+---------------+ 4| transaction handle | +---------------+---------------+---------------+---------------+ Total 8 bytes Response data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x81 | 0x32 | Status | Reserved | +---------------+---------------+---------------+---------------+ Total 4 bytes void nds_trx_rollback(uint32_t transaction_handle); Request data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x80 | 0x33 | Reserved | +---------------+---------------+---------------+---------------+ 4| transaction handle | +---------------+---------------+---------------+---------------+ Total 8 bytes Response data: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| 0x81 | 0x33 | Status | Reserved | +---------------+---------------+---------------+---------------+ Total 4 bytes [end of file]