35 KineticSession* session =
KineticCalloc(1,
sizeof(KineticSession));
36 if (session == NULL) {
37 LOG0(
"Failed allocating a new session!");
42 session->config = *config;
44 session->config.hmacKey.data = session->config.keyData;
45 strncpy(session->config.host, config->
host,
sizeof(session->config.host));
48 session->messageBus = b;
56 if (session != NULL) {
65 if (response == NULL) {
66 LOG0(
"Failed allocating new response!");
76 if (response->
command != NULL) {
77 protobuf_c_message_free_unpacked(&response->
command->base, NULL);
79 if (response->
proto != NULL) {
80 protobuf_c_message_free_unpacked(&response->
proto->base, NULL);
89 LOGF3(
"Allocating new operation on session %p", (
void*)session);
90 KineticOperation* newOperation =
91 (KineticOperation*)
KineticCalloc(1,
sizeof(KineticOperation));
92 if (newOperation == NULL) {
93 LOGF0(
"Failed allocating new operation on session %p", (
void*)session);
96 newOperation->session = session;
97 newOperation->timeoutSeconds = session->timeoutSeconds;
98 newOperation->request = (KineticRequest*)
KineticCalloc(1,
sizeof(KineticRequest));
99 if (newOperation->request == NULL) {
100 LOGF0(
"Failed allocating new PDU on session %p", (
void*)session);
111 LOGF3(
"Freeing operation %p on session %p", (
void*)operation, (
void*)operation->session);
112 if (operation->request != NULL) {
114 operation->request = NULL;
116 if (operation->response != NULL) {
118 operation->response = NULL;
125 if (proto_p2pOp != NULL) {
126 if (proto_p2pOp->peer != NULL) {
127 free(proto_p2pOp->peer);
128 proto_p2pOp->peer = NULL;
130 if (proto_p2pOp->operation != NULL) {
131 for(
size_t i = 0; i < proto_p2pOp->n_operation; i++) {
132 if (proto_p2pOp->operation[i] != NULL) {
133 if (proto_p2pOp->operation[i]->p2pop != NULL) {
135 proto_p2pOp->operation[i]->p2pop = NULL;
137 if (proto_p2pOp->operation[i]->status != NULL) {
138 free(proto_p2pOp->operation[i]->status);
139 proto_p2pOp->operation[i]->status = NULL;
141 free(proto_p2pOp->operation[i]);
142 proto_p2pOp->operation[i] = NULL;
145 free(proto_p2pOp->operation);
146 proto_p2pOp->operation = NULL;
void * KineticCalloc(size_t count, size_t size)
#define KINETIC_SOCKET_INVALID
Invalid socket file descriptor value.
Structure used to specify the configuration for a session.
void KineticAllocator_FreeOperation(KineticOperation *operation)
Com__Seagate__Kinetic__Proto__Message * proto
void KineticAllocator_FreeSession(KineticSession *session)
KineticResponse * KineticAllocator_NewKineticResponse(size_t const valueLength)
uint16_t timeoutSeconds
Operation timeout. If 0, use the default (10 seconds).
char host[256]
Host name/IP address of Kinetic Device.
void KineticAllocator_FreeP2PProtobuf(Com__Seagate__Kinetic__Proto__Command__P2POperation *proto_p2pOp)
void KineticRequest_Init(KineticRequest *request, KineticSession const *const session)
#define KINETIC_ASSERT(cond)
void KineticFree(void *pointer)
Com__Seagate__Kinetic__Proto__Command * command
#define LOGF3(message,...)
size_t len
Number of bytes in the data field.
void KineticResourceWaiter_Init(KineticResourceWaiter *const waiter)
#define LOGF0(message,...)
KineticOperation * KineticAllocator_NewOperation(KineticSession *const session)
void KineticAllocator_FreeKineticResponse(KineticResponse *response)
uint8_t * data
Pointer to an allocated array of data bytes.
KineticSession * KineticAllocator_NewSession(struct bus *b, KineticSessionConfig *config)
void KineticResourceWaiter_Destroy(KineticResourceWaiter *const waiter)