kinetic-c  v0.12.0
Seagate Kinetic Protocol Client Library for C
kinetic_request.h
Go to the documentation of this file.
1 /*
2 * kinetic-c
3 * Copyright (C) 2015 Seagate Technology.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 *
19 */
20 #ifndef KINETIC_REQUEST_H
21 #define KINETIC_REQUEST_H
22 
23 #include "kinetic_types_internal.h"
24 
25 /* Special 'failed to pack' sentinel. */
26 #define KINETIC_REQUEST_PACK_FAILURE ((size_t)-1)
27 
28 /* Pack the command into request->message.message.commandBytes.data.
29  * Returns the allocated size,
30  * or KINETIC_REQUEST_PACK_FAILURE on malloc failure. */
31 size_t KineticRequest_PackCommand(KineticRequest* request);
32 
33 /* Populate the request's authentication info. If PIN is non-NULL,
34  * use PIN authentication, otherwise use HMAC. */
36  KineticRequest *request, ByteArray *pin);
37 
38 /* Pack the header, command, and value (if any), allocating a buffer and
39  * returning the buffer and its size in *msg and *msgSize.
40  * Returns KINETIC_STATUS_SUCCESS on success, or KINETIC_STATUS_MEMORY_ERROR
41  * on allocation failure. */
42 KineticStatus KineticRequest_PackMessage(KineticOperation *operation,
43  uint8_t **msg, size_t *msgSize);
44 
45 /* Send the request. Returns whether the request was successfully queued
46  * up for delivery, or whether it was rejected due to invalid arguments.
47  * If this returns false, then the asynchronous result callback will
48  * not be called. */
49 bool KineticRequest_SendRequest(KineticOperation *operation,
50  uint8_t *msg, size_t msgSize);
51 
52 bool KineticRequest_LockSend(KineticSession* session);
53 bool KineticRequest_UnlockSend(KineticSession* session);
54 
55 #endif
Structure for handling generic arrays of bytes.
Definition: byte_array.h:34
Structure used to specify the configuration for a session.
bool KineticRequest_LockSend(KineticSession *session)
bool KineticRequest_SendRequest(KineticOperation *operation, uint8_t *msg, size_t msgSize)
KineticStatus KineticRequest_PackMessage(KineticOperation *operation, uint8_t **msg, size_t *msgSize)
size_t KineticRequest_PackCommand(KineticRequest *request)
KineticStatus
Kinetic status codes.
bool KineticRequest_UnlockSend(KineticSession *session)
KineticStatus KineticRequest_PopulateAuthentication(KineticSessionConfig *config, KineticRequest *request, ByteArray *pin)