49 op->request->message.command.header->has_messagetype =
true;
65 op->request->message.command.header->has_messagetype =
true;
70 op->value.data = op->entry->value.array.data;
71 op->value.len = op->entry->value.bytesUsed;
84 op->request->message.command.header->messagetype = command_id;
85 op->request->message.command.header->has_messagetype =
true;
90 if (op->entry->value.array.data != NULL) {
92 op->value.data = op->entry->value.array.data;
93 op->value.len = op->entry->value.bytesUsed;
130 op->request->message.command.header->messagetype =
132 op->request->message.command.header->has_messagetype =
true;
144 op->request->message.command.header->has_messagetype =
true;
149 if (op->entry->value.array.data != NULL) {
151 op->value.data = op->entry->value.array.data;
152 op->value.len = op->entry->value.bytesUsed;
168 op->request->command->header->has_messagetype =
true;
172 op->buffers = buffers;
178 Com__Seagate__Kinetic__Proto__Command__P2POperation*
build_p2pOp(uint32_t nestingLevel, KineticP2P_Operation
const *
const p2pOp)
186 Com__Seagate__Kinetic__Proto__Command__P2POperation* proto_p2pOp = calloc(1,
sizeof(Com__Seagate__Kinetic__Proto__Command__P2POperation));
187 if (proto_p2pOp == NULL) {
goto error_cleanup; }
191 proto_p2pOp->peer = calloc(1,
sizeof(Com__Seagate__Kinetic__Proto__Command__P2POperation__Peer));
192 if (proto_p2pOp->peer == NULL) {
goto error_cleanup; }
196 proto_p2pOp->peer->hostname = p2pOp->peer.hostname;
197 proto_p2pOp->peer->has_port =
true;
198 proto_p2pOp->peer->port = p2pOp->peer.port;
199 proto_p2pOp->peer->has_tls =
true;
200 proto_p2pOp->peer->tls = p2pOp->peer.tls;
202 proto_p2pOp->n_operation = p2pOp->numOperations;
203 proto_p2pOp->operation = calloc(p2pOp->numOperations,
sizeof(Com__Seagate__Kinetic__Proto__Command__P2POperation__Operation*));
204 if (proto_p2pOp->operation == NULL) {
goto error_cleanup; }
206 for(
size_t i = 0; i < proto_p2pOp->n_operation; i++) {
209 Com__Seagate__Kinetic__Proto__Command__P2POperation__Operation * p2p_op_op = calloc(1,
sizeof(Com__Seagate__Kinetic__Proto__Command__P2POperation__Operation));
210 if (p2p_op_op == NULL) {
goto error_cleanup; }
214 p2p_op_op->has_key =
true;
215 p2p_op_op->key.data = p2pOp->operations[i].key.array.data;
216 p2p_op_op->key.len = p2pOp->operations[i].key.bytesUsed;
219 p2p_op_op->newkey.data = p2pOp->operations[i].newKey.array.data;
220 p2p_op_op->newkey.len = p2pOp->operations[i].newKey.bytesUsed;
223 p2p_op_op->version.data = p2pOp->operations[i].version.array.data;
224 p2p_op_op->version.len = p2pOp->operations[i].version.bytesUsed;
230 if (p2pOp->operations[i].chainedOperation == NULL) {
231 p2p_op_op->p2pop = NULL;
233 p2p_op_op->p2pop =
build_p2pOp(nestingLevel + 1, p2pOp->operations[i].chainedOperation);
234 if (p2p_op_op->p2pop == NULL) {
goto error_cleanup; }
237 p2p_op_op->status = NULL;
239 proto_p2pOp->operation[i] = p2p_op_op;
249 KineticP2P_Operation*
const p2pOp)
254 op->request->command->header->has_messagetype =
true;
255 op->request->command->body = &op->request->message.body;
259 op->request->command->body->p2poperation =
build_p2pOp(0, p2pOp);
261 if (op->request->command->body->p2poperation == NULL) {
284 op->request->command->header->has_messagetype =
true;
285 op->request->command->body = &op->request->message.body;
286 op->request->command->body->getlog = &op->request->message.getLog;
287 op->request->command->body->getlog->types = &op->request->message.getLogType;
288 op->request->command->body->getlog->types[0] = type;
289 op->request->command->body->getlog->n_types = 1;
292 if (name.
data == NULL || name.
len == 0) {
295 op->request->message.getLogDevice.name.data = name.
data;
296 op->request->message.getLogDevice.name.len = name.
len;
297 op->request->message.getLogDevice.has_name =
true;
298 op->request->command->body->getlog->device = &op->request->message.getLogDevice;
301 op->deviceInfo = info;
312 op->request->message.command.header->has_messagetype =
true;
313 op->request->command->body = &op->request->message.body;
314 op->request->command->body->security = &op->request->message.security;
317 op->request->message.security.oldlockpin = (ProtobufCBinaryData) {
318 .data = old_pin.
data, .len = old_pin.
len };
319 op->request->message.security.has_oldlockpin =
true;
320 op->request->message.security.newlockpin = (ProtobufCBinaryData) {
321 .data = new_pin.
data, .len = new_pin.
len };
322 op->request->message.security.has_newlockpin =
true;
325 op->request->message.security.olderasepin = (ProtobufCBinaryData) {
326 .data = old_pin.
data, .len = old_pin.
len };
327 op->request->message.security.has_olderasepin =
true;
328 op->request->message.security.newerasepin = (ProtobufCBinaryData) {
329 .data = new_pin.
data, .len = new_pin.
len };
330 op->request->message.security.has_newerasepin =
true;
334 op->request->pinAuth =
false;
346 op->request->message.command.header->has_messagetype =
true;
347 op->request->command->body = &op->request->message.body;
348 op->request->command->body->pinop = &op->request->message.pinOp;
349 op->request->command->body->pinop->pinoptype = secure_erase ?
352 op->request->command->body->pinop->has_pinoptype =
true;
355 op->request->pinAuth =
true;
367 op->request->message.command.header->has_messagetype =
true;
368 op->request->command->body = &op->request->message.body;
369 op->request->command->body->pinop = &op->request->message.pinOp;
371 op->request->command->body->pinop->pinoptype = lock ?
374 op->request->command->body->pinop->has_pinoptype =
true;
377 op->request->pinAuth =
true;
388 op->request->message.command.header->has_messagetype =
true;
389 op->request->command->body = &op->request->message.body;
391 op->request->command->body->setup = &op->request->message.setup;
392 op->request->command->body->setup->newclusterversion = new_cluster_version;
393 op->request->command->body->setup->has_newclusterversion =
true;
396 op->pendingClusterVersion = new_cluster_version;
407 op->request->message.command.header->has_messagetype =
true;
408 op->request->command->body = &op->request->message.body;
409 op->request->command->body->security = &op->request->message.security;
411 op->request->command->body->security->n_acl = ACLs->
ACL_count;
412 op->request->command->body->security->acl = ACLs->
ACLs;
427 if (fw_path == NULL) {
428 LOG0(
"ERROR: FW update file was NULL");
433 fp = fopen(fw_path,
"r");
435 LOG0(
"ERROR: Specified FW update file could not be opened");
440 if (fseek(fp, 0L, SEEK_END) != 0) {
441 LOG0(
"ERROR: Specified FW update file could not be seek");
446 long len = ftell(fp);
448 LOG0(
"ERROR: Specified FW update file could not be queried for length");
452 if (fseek(fp, 0L, SEEK_SET) != 0) {
453 LOG0(
"ERROR: Specified FW update file could not be seek back to start");
458 op->value.data = calloc(len, 1);
459 if (op->value.data == NULL) {
460 LOG0(
"ERROR: Failed allocating memory to store FW update image");
465 size_t read = fread(op->value.data, 1, len, fp);
466 if ((
long)read != len) {
467 LOGF0(
"ERROR: Expected to read %ld bytes from FW file, but read %zu", len, read);
476 op->request->message.command.header->has_messagetype =
true;
477 op->request->command->body = &op->request->message.body;
479 op->request->command->body->setup = &op->request->message.setup;
480 op->request->command->body->setup->firmwaredownload =
true;
481 op->request->command->body->setup->has_firmwaredownload =
true;
KineticStatus KineticBuilder_BuildLockUnlock(KineticOperation *const op, bool lock, ByteArray *pin)
Structure for handling generic arrays of bytes.
void ByteBuffer_Reset(ByteBuffer *buffer)
void com__seagate__kinetic__proto__command__p2_poperation__peer__init(Com__Seagate__Kinetic__Proto__Command__P2POperation__Peer *message)
Com__Seagate__Kinetic__Proto__Command__MessageType
void KineticMessage_ConfigureKeyRange(KineticMessage *const message, const KineticKeyRange *range)
One or more of byte buffers did not fit all data.
KineticStatus KineticBuilder_BuildSetACL(KineticOperation *const op, struct ACL *ACLs)
KineticStatus KineticBuilder_BuildGetLog(KineticOperation *const op, Com__Seagate__Kinetic__Proto__Command__GetLog__Type type, ByteArray name, KineticLogInfo **info)
KineticStatus KineticBuilder_BuildGetPrevious(KineticOperation *const op, KineticEntry *const entry)
KineticStatus KineticCallbacks_Get(KineticOperation *const operation, KineticStatus const status)
void com__seagate__kinetic__proto__command__p2_poperation__operation__init(Com__Seagate__Kinetic__Proto__Command__P2POperation__Operation *message)
#define KINETIC_OBJ_SIZE
Max object/value size.
Com__Seagate__Kinetic__Proto__Command__P2POperation * build_p2pOp(uint32_t nestingLevel, KineticP2P_Operation const *const p2pOp)
KineticStatus KineticCallbacks_Delete(KineticOperation *const operation, KineticStatus const status)
#define KINETIC_P2P_MAX_NESTING
Limit for P2P operation nesting.
Failed allocating/deallocating memory.
void KineticOperation_ValidateOperation(KineticOperation *op)
KineticStatus KineticBuilder_BuildSetPin(KineticOperation *const op, ByteArray old_pin, ByteArray new_pin, bool lock)
void KineticMessage_ConfigureKeyValue(KineticMessage *const message, const KineticEntry *entry)
void com__seagate__kinetic__proto__command__p2_poperation__init(Com__Seagate__Kinetic__Proto__Command__P2POperation *message)
Com__Seagate__Kinetic__Proto__Command__GetLog__Type
KineticStatus KineticBuilder_BuildPut(KineticOperation *const op, KineticEntry *const entry)
KineticStatus KineticBuilder_BuildUpdateFirmware(KineticOperation *const op, const char *fw_path)
Kinetic Key Range request structure.
KineticStatus KineticBuilder_BuildGet(KineticOperation *const op, KineticEntry *const entry)
void KineticAllocator_FreeP2PProtobuf(Com__Seagate__Kinetic__Proto__Command__P2POperation *proto_p2pOp)
Base log info structure which is allocated by client and passed to KineticAdminClient_GetLog.
KineticStatus(* KineticOperationCallback)(KineticOperation *const operation, KineticStatus const status)
#define KINETIC_ASSERT(cond)
KineticStatus KineticBuilder_BuildNoop(KineticOperation *const op)
Specified file does not exist or could not be read/writtten.
KineticStatus KineticBuilder_BuildGetKeyRange(KineticOperation *const op, KineticKeyRange *range, ByteBufferArray *buffers)
KineticStatus KineticCallbacks_SetACL(KineticOperation *const operation, KineticStatus const status)
KineticStatus KineticCallbacks_GetKeyRange(KineticOperation *const operation, KineticStatus const status)
size_t len
Number of bytes in the data field.
Com__Seagate__Kinetic__Proto__Command__Security__ACL ** ACLs
ACL struct array.
#define LOGF0(message,...)
KineticStatus KineticCallbacks_P2POperation(KineticOperation *const operation, KineticStatus const status)
bool ByteBuffer_IsNull(ByteBuffer const buffer)
KineticStatus KineticBuilder_BuildGetNext(KineticOperation *const op, KineticEntry *const entry)
static void build_get_command(KineticOperation *const op, KineticEntry *const entry, KineticOperationCallback cb, Com__Seagate__Kinetic__Proto__Command__MessageType command_id)
uint8_t * data
Pointer to an allocated array of data bytes.
KineticStatus KineticCallbacks_Basic(KineticOperation *const operation, KineticStatus const status)
KineticStatus KineticCallbacks_Put(KineticOperation *const operation, KineticStatus const status)
Status not available (no reponse/status available)
A device name is required, but was empty.
size_t ACL_count
How many ACL * structs are in ACLs[].
KineticStatus
Kinetic status codes.
KineticStatus KineticBuilder_BuildErase(KineticOperation *const op, bool secure_erase, ByteArray *pin)
KineticStatus KineticCallbacks_SetClusterVersion(KineticOperation *const operation, KineticStatus const status)
size_t bytesUsed
Reflects the number of bytes used from the array
KineticStatus KineticBuilder_BuildSetClusterVersion(KineticOperation *op, int64_t new_cluster_version)
#define KINETIC_P2P_OPERATION_LIMIT
Limit for P2P operations.
KineticStatus KineticCallbacks_UpdateFirmware(KineticOperation *const operation, KineticStatus const status)
KineticStatus KineticBuilder_BuildP2POperation(KineticOperation *const op, KineticP2P_Operation *const p2pOp)
KineticStatus KineticBuilder_BuildDelete(KineticOperation *const op, KineticEntry *const entry)
KineticStatus KineticBuilder_BuildFlush(KineticOperation *const op)
KineticStatus KineticCallbacks_GetLog(KineticOperation *const operation, KineticStatus const status)
#define LOGF2(message,...)
ByteBuffer value
Value data associated with the key.