aboutsummaryrefslogtreecommitdiffstats
path: root/ctrl/libhicnctrl/src/api.c
diff options
context:
space:
mode:
authorJordan Augé <jordan.auge+fdio@cisco.com>2019-11-21 00:38:09 +0100
committerJordan Augé <jordan.auge+fdio@cisco.com>2019-11-21 00:51:06 +0100
commitae6f3b8e1f55fc4bb7807c293850d3cb46cab1fd (patch)
treefcc8cc1f42a21e8d6da3051ccfcb161c90cd02c8 /ctrl/libhicnctrl/src/api.c
parent275b80b81746cdf5fc9b8299e7441c9d0d8718de (diff)
[HICN-379] Add face priority support in face manager
Change-Id: Iae19e016aae833b4bc95ff6d91d51b188f398e25 Signed-off-by: Jordan Augé <jordan.auge+fdio@cisco.com>
Diffstat (limited to 'ctrl/libhicnctrl/src/api.c')
-rw-r--r--ctrl/libhicnctrl/src/api.c39
1 files changed, 27 insertions, 12 deletions
diff --git a/ctrl/libhicnctrl/src/api.c b/ctrl/libhicnctrl/src/api.c
index 2d8ee40f0..84c3390e5 100644
--- a/ctrl/libhicnctrl/src/api.c
+++ b/ctrl/libhicnctrl/src/api.c
@@ -625,6 +625,9 @@ hc_sock_recv(hc_sock_t * s)
return rc;
}
+/*
+ * Returns -99 in case of internal error, -1 in case of API command failure
+ */
int
hc_sock_process(hc_sock_t * s, hc_data_t ** data)
{
@@ -646,11 +649,11 @@ hc_sock_process(hc_sock_t * s, hc_data_t ** data)
hc_sock_request_t * request = NULL;
if (hc_sock_map_get(s->map, msg->hdr.seqNum, &request) < 0) {
ERROR("[hc_sock_process] Error searching for matching request");
- return -1;
+ return -99;
}
if (!request) {
ERROR("[hc_sock_process] No request matching received sequence number");
- return -1;
+ return -99;
}
s->remaining = msg->hdr.length;
@@ -665,6 +668,7 @@ hc_sock_process(hc_sock_t * s, hc_data_t ** data)
assert(!data);
hc_data_set_error(request->data);
s->cur_request = request;
+ err = -1;
break;
case RESPONSE_LIGHT:
assert(data);
@@ -681,7 +685,7 @@ hc_sock_process(hc_sock_t * s, hc_data_t ** data)
break;
default:
ERROR("[hc_sock_process] Invalid response received");
- return -1;
+ return -99;
}
available -= sizeof(hc_msg_header_t);
@@ -702,15 +706,15 @@ hc_sock_process(hc_sock_t * s, hc_data_t ** data)
int rc;
rc = hc_data_ensure_available(s->cur_request->data, num_chunks);
if (rc < 0)
- return -1;
+ return -99;
for (int i = 0; i < num_chunks; i++) {
u8 * dst = hc_data_get_next(s->cur_request->data);
if (!dst)
- return -1;
+ return -99;
rc = s->cur_request->parse(s->buf + s->roff + i * s->cur_request->data->in_element_size, dst);
if (rc < 0)
- err = -1; /* FIXME we let the loop complete (?) */
+ err = -99; /* FIXME we let the loop complete (?) */
s->cur_request->data->size++;
}
}
@@ -721,7 +725,7 @@ hc_sock_process(hc_sock_t * s, hc_data_t ** data)
if (s->remaining == 0) {
if (hc_sock_map_remove(s->map, s->cur_request->seq, NULL) < 0) {
ERROR("[hc_sock_process] Error removing request from map");
- return -1;
+ return -99;
}
hc_data_set_complete(s->cur_request->data);
if (data)
@@ -890,9 +894,20 @@ hc_execute_command(hc_sock_t * s, hc_msg_t * msg, size_t msg_len,
*/
if (hc_sock_recv(s) < 0)
continue; //break;
- if (hc_sock_process(s, pdata) < 0) {
- ERROR("[hc_execute_command] Error processing socket results");
- goto ERR_PROCESS;
+ int rc = hc_sock_process(s, pdata);
+ switch(rc) {
+ case 0:
+ break;
+ case -1:
+ ret = rc;
+ break;
+ case -99:
+ ERROR("[hc_execute_command] Error processing socket results");
+ goto ERR_PROCESS;
+ break;
+ default:
+ ERROR("[hc_execute_command] Unexpected return value");
+ goto ERR_PROCESS;
}
}
@@ -909,7 +924,7 @@ ERR_REQUEST:
ERR_SEQ:
hc_data_free(data);
ERR_DATA:
- return -1;
+ return -99;
}
/*----------------------------------------------------------------------------*
@@ -1665,7 +1680,7 @@ _hc_connection_set_priority(hc_sock_t * s, const char * conn_id_or_name,
} msg = {
.hdr = {
.messageType = REQUEST_LIGHT,
- .commandID = CONNECTION_SET_ADMIN_STATE,
+ .commandID = CONNECTION_SET_PRIORITY,
.length = 1,
.seqNum = 0,
},