kinetic-c  v0.12.0
Seagate Kinetic Protocol Client Library for C
kinetic_response.c
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 
21 #include "kinetic_response.h"
22 #include "kinetic_nbo.h"
23 #include "kinetic_session.h"
24 #include "kinetic_socket.h"
25 #include "kinetic_hmac.h"
26 #include "kinetic_logger.h"
27 #include "kinetic.pb-c.h"
28 #include "kinetic_nbo.h"
29 #include "kinetic_allocator.h"
30 #include "kinetic_controller.h"
31 #include "kinetic_pdu_unpack.h"
32 
33 #include <time.h>
34 
36 {
37  KINETIC_ASSERT(response);
38  return response->header.protobufLength;
39 }
40 
42 {
43  KINETIC_ASSERT(response);
44  return response->header.valueLength;
45 }
46 
48 {
50 
51  if (response != NULL &&
52  response->command != NULL &&
53  response->command->status != NULL &&
54  response->command->status->has_code != false)
55  {
57  response->command->status->code);
58  }
59 
60  return status;
61 }
62 
64 {
65  int64_t id = 0;
66  KINETIC_ASSERT(response);
67  KINETIC_ASSERT(response->proto);
69  response->command != NULL &&
70  response->command->header != NULL &&
71  response->command->header->has_connectionid)
72  {
73  id = response->command->header->connectionid;
74  }
75  return id;
76 }
77 
78 Com__Seagate__Kinetic__Proto__Command__KeyValue* KineticResponse_GetKeyValue(KineticResponse * response)
79 {
80  Com__Seagate__Kinetic__Proto__Command__KeyValue* keyValue = NULL;
81 
82  if (response != NULL &&
83  response->command != NULL &&
84  response->command->body != NULL)
85  {
86  keyValue = response->command->body->keyvalue;
87  }
88  return keyValue;
89 }
90 
91 Com__Seagate__Kinetic__Proto__Command__Range* KineticResponse_GetKeyRange(KineticResponse * response)
92 {
93  Com__Seagate__Kinetic__Proto__Command__Range* range = NULL;
94  if (response != NULL &&
95  response->proto != NULL &&
96  response->command != NULL &&
97  response->command->body != NULL)
98  {
99  range = response->command->body->range;
100  }
101  return range;
102 }
KineticStatus KineticProtoStatusCode_to_KineticStatus(Com__Seagate__Kinetic__Proto__Command__Status__StatusCode protoStatus)
Com__Seagate__Kinetic__Proto__Message * proto
uint32_t KineticResponse_GetValueLength(KineticResponse *response)
uint32_t KineticResponse_GetProtobufLength(KineticResponse *response)
KineticStatus KineticResponse_GetStatus(KineticResponse *response)
Com__Seagate__Kinetic__Proto__Command__KeyValue * KineticResponse_GetKeyValue(KineticResponse *response)
#define KINETIC_ASSERT(cond)
Com__Seagate__Kinetic__Proto__Command__Range * KineticResponse_GetKeyRange(KineticResponse *response)
Com__Seagate__Kinetic__Proto__Command * command
KineticPDUHeader header
Status not available (no reponse/status available)
KineticStatus
Kinetic status codes.
int64_t KineticResponse_GetConnectionID(KineticResponse *response)