aboutsummaryrefslogtreecommitdiffstats
path: root/ctrl
diff options
context:
space:
mode:
authorLuca Muscariello <lumuscar@cisco.com>2022-06-09 21:34:09 +0200
committerLuca Muscariello <muscariello@ieee.org>2022-06-30 10:47:50 +0200
commit6b94663b2455e212009a544ae23bb6a8c55407f8 (patch)
tree0af780ce5eeb1009fd24b8af8af08e8368eda3bd /ctrl
parenta1ac96f497719b897793ac14b287cb8d840651c1 (diff)
refactor(lib, hicn-light, vpp, hiperf): HICN-723
- move infra data structure into the shared lib - new packet cache using double hashing and lookup on prefix suffix - testing updates - authenticated requests using interest manifests Co-authored-by: Mauro Sardara <msardara@cisco.com> Co-authored-by: Jordan Augé <jordan.auge+fdio@cisco.com> Co-authored-by: Michele Papalini <micpapal@cisco.com> Co-authored-by: Olivier Roques <oroques+fdio@cisco.com> Co-authored-by: Enrico Loparco <eloparco@cisco.com> Change-Id: Iaddebfe6aa5279ea8553433b0f519578f6b9ccd9 Signed-off-by: Luca Muscariello <muscariello@ieee.org>
Diffstat (limited to 'ctrl')
-rw-r--r--ctrl/CMakeLists.txt2
-rw-r--r--ctrl/facemgr/includes/hicn/facemgr/cfg.h2
-rw-r--r--ctrl/facemgr/src/cfg.c5
-rw-r--r--ctrl/facemgr/src/interfaces/network_framework/network_framework.c1
-rw-r--r--ctrl/facemgr/src/loop_dispatcher.c2
-rw-r--r--ctrl/libhicnctrl/includes/hicn/ctrl/api.h10
-rw-r--r--ctrl/libhicnctrl/includes/hicn/ctrl/hicn-light-ng.h35
-rw-r--r--ctrl/libhicnctrl/src/CMakeLists.txt3
-rw-r--r--ctrl/libhicnctrl/src/api.c35
-rw-r--r--ctrl/libhicnctrl/src/api_private.h3
-rw-r--r--ctrl/libhicnctrl/src/modules/hicn_light_common.c3
-rw-r--r--ctrl/libhicnctrl/src/modules/hicn_light_common.h5
-rw-r--r--ctrl/libhicnctrl/src/modules/hicn_light_ng_api.c187
13 files changed, 244 insertions, 49 deletions
diff --git a/ctrl/CMakeLists.txt b/ctrl/CMakeLists.txt
index d6fe72d3e..221121818 100644
--- a/ctrl/CMakeLists.txt
+++ b/ctrl/CMakeLists.txt
@@ -21,6 +21,6 @@ project(ctrl)
# Subdirectories
##############################################################
add_subdirectory(libhicnctrl)
-if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" OR "${CMAKE_SYSTEM_NAME}" STREQUAL "Android")
+if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" OR "${CMAKE_SYSTEM_NAME}" STREQUAL "Android" OR "${CMAKE_SYSTEM_NAME}" STREQUAL "iOS")
add_subdirectory(facemgr)
endif () \ No newline at end of file
diff --git a/ctrl/facemgr/includes/hicn/facemgr/cfg.h b/ctrl/facemgr/includes/hicn/facemgr/cfg.h
index fee38daf1..bbbe81825 100644
--- a/ctrl/facemgr/includes/hicn/facemgr/cfg.h
+++ b/ctrl/facemgr/includes/hicn/facemgr/cfg.h
@@ -163,8 +163,6 @@ int facemgr_cfg_rule_get_overlay_remote_port(const facemgr_cfg_rule_t* rule,
int family, uint16_t* port);
int facemgr_cfg_add_static_facelet(facemgr_cfg_t* cfg, facelet_t* facelet);
-int facemgr_cfg_remove_static_facelet(facemgr_cfg_t* cfg, facelet_t* facelet,
- facelet_t** removed_facelet);
int facemgr_cfg_get_static_facelet_array(const facemgr_cfg_t* cfg,
facelet_t*** array);
diff --git a/ctrl/facemgr/src/cfg.c b/ctrl/facemgr/src/cfg.c
index 9c374388a..76e1f5e72 100644
--- a/ctrl/facemgr/src/cfg.c
+++ b/ctrl/facemgr/src/cfg.c
@@ -1120,11 +1120,6 @@ int facemgr_cfg_add_static_facelet(facemgr_cfg_t *cfg, facelet_t *facelet) {
return facelet_array_add(cfg->static_facelets, facelet);
}
-int facemgr_cfg_remove_static_facelet(facemgr_cfg_t *cfg, facelet_t *facelet,
- facelet_t **removed_facelet) {
- return facelet_array_remove(cfg->static_facelets, facelet, removed_facelet);
-}
-
int facemgr_cfg_get_static_facelet_array(const facemgr_cfg_t *cfg,
facelet_t ***array) {
if (facelet_array_get_elements(cfg->static_facelets, array) < 0) {
diff --git a/ctrl/facemgr/src/interfaces/network_framework/network_framework.c b/ctrl/facemgr/src/interfaces/network_framework/network_framework.c
index 3adba0969..e1f5575d3 100644
--- a/ctrl/facemgr/src/interfaces/network_framework/network_framework.c
+++ b/ctrl/facemgr/src/interfaces/network_framework/network_framework.c
@@ -171,6 +171,7 @@ void dump_endpoint(nw_endpoint_t endpoint, int indent) {
free(s);
}
}
+}
void dump_path(nw_path_t path, int indent) {
/* nw_path_enumerate_interfaces : not interesting */
diff --git a/ctrl/facemgr/src/loop_dispatcher.c b/ctrl/facemgr/src/loop_dispatcher.c
index ed4540f5c..88e197492 100644
--- a/ctrl/facemgr/src/loop_dispatcher.c
+++ b/ctrl/facemgr/src/loop_dispatcher.c
@@ -28,7 +28,7 @@
#include <stdlib.h>
-#include <Dispatch/Dispatch.h>
+#include <dispatch/dispatch.h>
#include <hicn/facemgr/loop.h>
#include <hicn/util/log.h>
diff --git a/ctrl/libhicnctrl/includes/hicn/ctrl/api.h b/ctrl/libhicnctrl/includes/hicn/ctrl/api.h
index 8a59cf4d8..c259fc10c 100644
--- a/ctrl/libhicnctrl/includes/hicn/ctrl/api.h
+++ b/ctrl/libhicnctrl/includes/hicn/ctrl/api.h
@@ -72,6 +72,7 @@
#include <hicn/util/ip_address.h>
#include <hicn/face.h>
#include <hicn/strategy.h>
+#include <hicn/base.h>
/*
* This has to be common between hicn-light and hicn-plugin. We now we keep the
* minimum of the two
@@ -120,6 +121,7 @@
_(SERVE) \
_(STORE) \
_(CLEAR) \
+ _(GET) \
_(N)
typedef enum {
@@ -150,6 +152,7 @@ hc_action_t action_from_str(const char *action_str);
_(LOCAL_PREFIX) \
_(PROBE) \
_(SUBSCRIPTION) \
+ _(STATS) \
_(N)
typedef enum {
@@ -930,6 +933,13 @@ typedef struct {
flag_interface_type_t interface_type;
} hc_event_interface_update_t;
+/*----------------------------------------------------------------------------*
+ * Statistics
+ *----------------------------------------------------------------------------*/
+int hc_stats_get(hc_sock_t *s, hc_data_t **pdata); // General stats
+int hc_stats_list(hc_sock_t *s, hc_data_t **pdata); // Per-face stats
+int hc_stats_snprintf(char *s, size_t size, const hicn_light_stats_t *stats);
+
/* Result */
hc_msg_t *hc_result_get_msg(hc_sock_t *s, hc_result_t *result);
diff --git a/ctrl/libhicnctrl/includes/hicn/ctrl/hicn-light-ng.h b/ctrl/libhicnctrl/includes/hicn/ctrl/hicn-light-ng.h
index 7d105a84b..783eab086 100644
--- a/ctrl/libhicnctrl/includes/hicn/ctrl/hicn-light-ng.h
+++ b/ctrl/libhicnctrl/includes/hicn/ctrl/hicn-light-ng.h
@@ -90,7 +90,9 @@ typedef enum {
_(policy_remove, POLICY_REMOVE) \
_(policy_list, POLICY_LIST) \
_(subscription_add, SUBSCRIPTION_ADD) \
- _(subscription_remove, SUBSCRIPTION_REMOVE)
+ _(subscription_remove, SUBSCRIPTION_REMOVE) \
+ _(stats_get, STATS_GET) \
+ _(stats_list, STATS_LIST)
typedef enum {
COMMAND_TYPE_UNDEFINED,
@@ -282,6 +284,33 @@ typedef struct {
cmd_cache_list_reply_t payload;
} msg_cache_list_reply_t;
+/* Statistics */
+
+// General stats
+typedef struct {
+ void *_;
+} cmd_stats_get_t;
+
+typedef struct {
+ cmd_header_t header;
+ hicn_light_stats_t payload;
+} msg_stats_get_reply_t;
+
+// Per-face stats
+typedef struct {
+ void *_;
+} cmd_stats_list_t;
+
+typedef struct {
+ uint32_t id;
+ connection_stats_t stats;
+} cmd_stats_list_item_t;
+
+typedef struct {
+ cmd_header_t header;
+ cmd_stats_list_item_t payload;
+} msg_stats_list_reply_t;
+
/* WLDR */
typedef struct {
@@ -388,10 +417,10 @@ typedef struct {
cmd_header_t header; \
cmd_##l##_t payload; \
} msg_##l##_t;
-foreach_command_type
+foreach_command_type;
#undef _
- typedef struct {
+typedef struct {
cmd_header_t header;
cmd_listener_list_item_t payload;
} msg_listener_list_reply_t;
diff --git a/ctrl/libhicnctrl/src/CMakeLists.txt b/ctrl/libhicnctrl/src/CMakeLists.txt
index c8a93c56c..1bec03d50 100644
--- a/ctrl/libhicnctrl/src/CMakeLists.txt
+++ b/ctrl/libhicnctrl/src/CMakeLists.txt
@@ -60,7 +60,8 @@ endif ()
##############################################################
# Do not use modules if Android
##############################################################
-if (${CMAKE_SYSTEM_NAME} MATCHES Android)
+
+if (${CMAKE_SYSTEM_NAME} MATCHES Android OR ${CMAKE_SYSTEM_NAME} MATCHES iOS)
list(APPEND SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/modules/hicn_light_common.c
${CMAKE_CURRENT_SOURCE_DIR}/modules/hicn_light_ng_api.c
diff --git a/ctrl/libhicnctrl/src/api.c b/ctrl/libhicnctrl/src/api.c
index 472e07bc4..d68dc830e 100644
--- a/ctrl/libhicnctrl/src/api.c
+++ b/ctrl/libhicnctrl/src/api.c
@@ -440,7 +440,7 @@ GENERATE_FIND(connection);
/* CONNECTION VALIDATE */
int hc_connection_validate(const hc_connection_t *connection) {
- if (!IS_VALID_NAME(connection->name)) {
+ if (connection->name[0] != '\0' && !IS_VALID_NAME(connection->name)) {
ERROR("[hc_connection_validate] Invalid name specified");
return -1;
}
@@ -1060,6 +1060,28 @@ int hc_cache_snprintf(char *s, size_t size, const hc_cache_info_t *cache_info) {
(unsigned long)cache_info->num_stale_entries);
}
+int hc_stats_snprintf(char *s, size_t size, const hicn_light_stats_t *stats) {
+ return snprintf(
+ s, size,
+ "pkts processed: %u\n\tinterests: %u\n\t"
+ "data: %u\npkts from cache count: %u\npkts no pit count: "
+ "%u\nexpired:\n\t interests: "
+ "%u\n\t data: %u\ninterests aggregated: "
+ "%u\nlru evictions: "
+ "%u\ndropped: "
+ "%u\ninterests retx: "
+ "%u\npit entries: %u\ncs entries: %u",
+ stats->forwarder.countReceived, stats->forwarder.countInterestsReceived,
+ stats->forwarder.countObjectsReceived,
+ stats->forwarder.countInterestsSatisfiedFromStore,
+ stats->forwarder.countDroppedNoReversePath,
+ stats->forwarder.countInterestsExpired, stats->forwarder.countDataExpired,
+ stats->pkt_cache.n_lru_evictions, stats->forwarder.countDropped,
+ stats->forwarder.countInterestsAggregated,
+ stats->forwarder.countInterestsRetransmitted,
+ stats->pkt_cache.n_pit_entries, stats->pkt_cache.n_cs_entries);
+}
+
/*----------------------------------------------------------------------------*
* Strategy
*----------------------------------------------------------------------------*/
@@ -1161,6 +1183,17 @@ hc_result_t *hc_subscription_delete_conf(hc_sock_t *s,
}
/*----------------------------------------------------------------------------*
+ * STATISTICS
+ *----------------------------------------------------------------------------*/
+int hc_stats_get(hc_sock_t *s, hc_data_t **pdata) {
+ return s->hc_stats_get(s, pdata);
+}
+
+int hc_stats_list(hc_sock_t *s, hc_data_t **pdata) {
+ return s->hc_stats_list(s, pdata);
+}
+
+/*----------------------------------------------------------------------------*
* Result
*----------------------------------------------------------------------------*/
diff --git a/ctrl/libhicnctrl/src/api_private.h b/ctrl/libhicnctrl/src/api_private.h
index 65b175810..c708e1eb5 100644
--- a/ctrl/libhicnctrl/src/api_private.h
+++ b/ctrl/libhicnctrl/src/api_private.h
@@ -242,6 +242,9 @@ struct hc_sock_s {
int (*hc_subscription_create)(hc_sock_t *s, hc_subscription_t *subscription);
int (*hc_subscription_delete)(hc_sock_t *s, hc_subscription_t *subscription);
+ int (*hc_stats_get)(hc_sock_t *s, hc_data_t **data);
+ int (*hc_stats_list)(hc_sock_t *s, hc_data_t **data);
+
hc_result_t *(*hc_listener_create_conf)(hc_sock_t *s,
hc_listener_t *listener);
hc_result_t *(*hc_listener_list_conf)(hc_sock_t *s, hc_data_t **pdata);
diff --git a/ctrl/libhicnctrl/src/modules/hicn_light_common.c b/ctrl/libhicnctrl/src/modules/hicn_light_common.c
index bc04404bf..d1fb33993 100644
--- a/ctrl/libhicnctrl/src/modules/hicn_light_common.c
+++ b/ctrl/libhicnctrl/src/modules/hicn_light_common.c
@@ -15,9 +15,6 @@
#include "hicn_light_common.h"
-TYPEDEF_MAP(hc_sock_map, int, hc_sock_request_t *, int_cmp, int_snprintf,
- generic_snprintf);
-
hc_sock_request_t *hc_sock_request_create(int seq, hc_data_t *data,
HC_PARSE parse) {
assert(data);
diff --git a/ctrl/libhicnctrl/src/modules/hicn_light_common.h b/ctrl/libhicnctrl/src/modules/hicn_light_common.h
index 4749474c8..d24b5bb2d 100644
--- a/ctrl/libhicnctrl/src/modules/hicn_light_common.h
+++ b/ctrl/libhicnctrl/src/modules/hicn_light_common.h
@@ -17,6 +17,7 @@
#include <assert.h> // assert
+#include <hicn/util/khash.h>
#include "api_private.h"
#define PORT 9695
@@ -39,7 +40,7 @@ typedef struct {
* outgoing queries so that replied can be demultiplexed and treated
* appropriately.
*/
-TYPEDEF_MAP_H(hc_sock_map, int, hc_sock_request_t *);
+KHASH_MAP_INIT_INT(sock_map, hc_sock_request_t *);
struct hc_sock_light_s {
/* This must be the first element of the struct */
@@ -69,7 +70,7 @@ struct hc_sock_light_s {
hc_sock_request_t *cur_request;
bool async;
- hc_sock_map_t *map;
+ kh_sock_map_t *map;
};
typedef struct hc_sock_light_s hc_sock_light_t;
diff --git a/ctrl/libhicnctrl/src/modules/hicn_light_ng_api.c b/ctrl/libhicnctrl/src/modules/hicn_light_ng_api.c
index a58ee909e..488b2edbf 100644
--- a/ctrl/libhicnctrl/src/modules/hicn_light_ng_api.c
+++ b/ctrl/libhicnctrl/src/modules/hicn_light_ng_api.c
@@ -88,7 +88,9 @@
_(mapme_activator) \
_(mapme_timing) \
_(subscription_add) \
- _(subscription_remove)
+ _(subscription_remove) \
+ _(stats_get) \
+ _(stats_list)
const char *command_type_str[] = {
#define _(l, u) [COMMAND_TYPE_##u] = STRINGIZE(u),
@@ -169,21 +171,13 @@ static int _hcng_sock_light_reset(hc_sock_t *socket) {
void _hcng_sock_light_free(hc_sock_t *socket) {
hc_sock_light_t *s = TO_HC_SOCK_LIGHT(socket);
- hc_sock_request_t **request_array = NULL;
- int n = hc_sock_map_get_value_array(s->map, &request_array);
- if (n < 0) {
- ERROR("Could not retrieve pending request array for freeing up resources");
- } else {
- for (unsigned i = 0; i < n; i++) {
- hc_sock_request_t *request = request_array[i];
- if (hc_sock_map_remove(s->map, request->seq, NULL) < 0)
- ERROR("[hc_sock_light_process] Error removing request from map");
- hc_sock_light_request_free(request);
- }
- free(request_array);
- }
- hc_sock_map_free(s->map);
+ unsigned k_seq;
+ hc_sock_request_t *v_request;
+ kh_foreach(s->map, k_seq, v_request,
+ { hc_sock_light_request_free(v_request); });
+
+ kh_destroy_sock_map(s->map);
if (s->url) free(s->url);
close(s->fd);
free(s);
@@ -292,9 +286,13 @@ static void _hcng_sock_light_mark_complete(hc_sock_light_t *s,
hc_data_t **pdata) {
hc_data_t *data = s->cur_request->data;
- if (hc_sock_map_remove(s->map, s->cur_request->seq, NULL) < 0) {
+ khiter_t k = kh_get_sock_map(s->map, s->cur_request->seq);
+ if (k == kh_end(s->map)) {
ERROR("[hc_sock_light_mark_complete] Error removing request from map");
+ } else {
+ kh_del_sock_map(s->map, k);
}
+
hc_data_set_complete(data);
if (pdata) *pdata = data;
@@ -323,7 +321,7 @@ static int _hcng_sock_light_process_notification(hc_sock_light_t *s,
/* Copy the packet payload as the single entry in hc_data_t */
hc_data_push_many(*pdata, s->buf + s->roff, 1);
- return notification_size;
+ return (int)notification_size;
}
/*
@@ -333,12 +331,16 @@ static hc_sock_request_t *_hcng_sock_light_get_request(hc_sock_light_t *s,
int seq) {
hc_sock_request_t *request;
/* Retrieve request from sock map */
- if (hc_sock_map_get(s->map, seq, &request) < 0) {
- ERROR("[hc_sock_light_process] Error searching for matching request");
+ khiter_t k = kh_get_sock_map(s->map, seq);
+ if (k == kh_end(s->map)) {
+ ERROR(
+ "[_hcng_sock_light_get_request] Error searching for matching request");
return NULL;
}
+ request = kh_val(s->map, k);
+
if (!request) {
- ERROR("[hc_sock_light_process] No request matching sequence number");
+ ERROR("[_hcng_sock_light_get_request] No request matching sequence number");
return NULL;
}
return request;
@@ -593,7 +595,7 @@ int _hcng_sock_prepare_send(hc_sock_t *socket, hc_result_t *result,
hc_data_t *data =
hc_data_create(result->params.size_in, result->params.size_out, NULL);
if (!data) {
- ERROR("[_hcng_execute_command] Could not create data storage");
+ ERROR("[_hcng_sock_prepare_send] Could not create data storage");
goto ERR_DATA;
}
hc_data_set_callback(data, complete_cb, complete_cb_data);
@@ -606,15 +608,17 @@ int _hcng_sock_prepare_send(hc_sock_t *socket, hc_result_t *result,
hc_sock_request_t *request = NULL;
request = hc_sock_request_create(seq, data, result->params.parse);
if (!request) {
- ERROR("[_hcng_execute_command] Could not create request state");
+ ERROR("[_hcng_sock_prepare_send] Could not create request state");
goto ERR_REQUEST;
}
- // Add state to map
- if (hc_sock_map_add(s->map, seq, request) < 0) {
- ERROR("[_hcng_execute_command] Error adding request state to map");
+ int rc;
+ khiter_t k = kh_put_sock_map(s->map, seq, &rc);
+ if (rc != KH_ADDED && rc != KH_RESET) {
+ ERROR("[_hcng_sock_prepare_send] Error adding request state to map");
goto ERR_MAP;
}
+ kh_value(s->map, k) = request;
return sizeof(result->msg);
@@ -631,7 +635,7 @@ int _hcng_sock_set_recv_timeout_ms(hc_sock_t *socket, long timeout_ms) {
struct timeval tv;
tv.tv_sec = 0;
- tv.tv_usec = timeout_ms * 1000; // Convert ms into us
+ tv.tv_usec = (int)(timeout_ms * 1000); // Convert ms into us
if (setsockopt(s->fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) < 0) {
perror("setsockopt");
return -1;
@@ -659,10 +663,13 @@ static int _hcng_execute_command(hc_sock_t *socket, hc_msg_t *msg,
assert(params->size_out == 0);
assert(params->parse == NULL);
break;
+ case ACTION_GET:
case ACTION_LIST:
assert(params->size_in != 0);
assert(params->size_out != 0);
- assert(params->parse != NULL);
+ // TODO(eloparco): Parsing should not be necessary after
+ // (pending) refatoring
+ // assert(params->parse != NULL);
break;
case ACTION_SET:
case ACTION_SERVE:
@@ -701,10 +708,13 @@ static int _hcng_execute_command(hc_sock_t *socket, hc_msg_t *msg,
}
/* Add state to map */
- if (hc_sock_map_add(s->map, seq, request) < 0) {
+ int rc;
+ khiter_t k = kh_put_sock_map(s->map, seq, &rc);
+ if (rc != KH_ADDED && rc != KH_RESET) {
ERROR("[_hcng_execute_command] Error adding request state to map");
goto ERR_MAP;
}
+ kh_value(s->map, k) = request;
if (_hcng_sock_light_send(socket, msg, msg_len, seq) < 0) {
ERROR("[_hcng_execute_command] Error sending message");
@@ -1823,7 +1833,7 @@ static int _hcng_face_create(hc_sock_t *socket, hc_face_t *face) {
case FACE_TYPE_HICN:
case FACE_TYPE_TCP:
case FACE_TYPE_UDP:
- if (hc_face_to_connection(face, &connection, true) < 0) {
+ if (hc_face_to_connection(face, &connection, false) < 0) {
ERROR("[hc_face_create] Could not convert face to connection.");
return -1;
}
@@ -2955,6 +2965,120 @@ static int _hcng_subscription_delete(hc_sock_t *socket,
return ret;
}
+/*----------------------------------------------------------------------------*
+ * Statistics
+ *----------------------------------------------------------------------------*/
+
+/* STATS GET */
+
+static hc_result_t *_hcng_stats_get_serialize(hc_sock_t *socket,
+ hc_data_t **pdata, bool async) {
+ hc_result_t *res = malloc(sizeof(*res));
+ DEBUG("[hc_stats_get] async=%s", BOOLSTR(async));
+
+ msg_stats_get_t msg = {.header = {
+ .message_type = REQUEST_LIGHT,
+ .command_id = COMMAND_TYPE_STATS_GET,
+ .length = 0,
+ .seq_num = 0,
+ }};
+
+ hc_command_params_t params = {
+ .cmd = ACTION_GET,
+ .cmd_id = COMMAND_TYPE_STATS_GET,
+ .size_in = sizeof(hicn_light_stats_t),
+ .size_out = sizeof(hicn_light_stats_t),
+ };
+
+ *res = (hc_result_t){
+ .msg =
+ (hc_msg_t){
+ .hdr = msg.header,
+ .payload.stats_get = msg.payload,
+ },
+ .params = params,
+ .async = async,
+ .success = true,
+ };
+ return res;
+}
+
+static int _hcng_stats_get_internal(hc_sock_t *socket, hc_data_t **pdata,
+ bool async) {
+ hc_result_t *result = _hcng_stats_get_serialize(socket, pdata, async);
+
+ int ret = INPUT_ERROR;
+ if (result->success) {
+ ret = _hcng_execute_command(socket, (hc_msg_t *)&result->msg,
+ sizeof(result->msg), &result->params, pdata,
+ result->async);
+ }
+
+ hc_result_free(result);
+ DEBUG("[_hcng_stats_get] done or error");
+ return ret;
+}
+
+static int _hcng_stats_get(hc_sock_t *s, hc_data_t **pdata) {
+ DEBUG("[_hcng_stats_get]");
+ return _hcng_stats_get_internal(s, pdata, false);
+}
+
+/* STATS LIST */
+
+static hc_result_t *_hcng_stats_list_serialize(hc_sock_t *socket,
+ hc_data_t **pdata, bool async) {
+ hc_result_t *res = malloc(sizeof(*res));
+ DEBUG("[hc_stats_list] async=%s", BOOLSTR(async));
+
+ msg_stats_list_t msg = {.header = {
+ .message_type = REQUEST_LIGHT,
+ .command_id = COMMAND_TYPE_STATS_LIST,
+ .length = 0,
+ .seq_num = 0,
+ }};
+
+ hc_command_params_t params = {
+ .cmd = ACTION_LIST,
+ .cmd_id = COMMAND_TYPE_STATS_LIST,
+ .size_in = sizeof(cmd_stats_list_item_t),
+ .size_out = sizeof(cmd_stats_list_item_t),
+ };
+
+ *res = (hc_result_t){
+ .msg =
+ (hc_msg_t){
+ .hdr = msg.header,
+ .payload.stats_list = msg.payload,
+ },
+ .params = params,
+ .async = async,
+ .success = true,
+ };
+ return res;
+}
+
+static int _hcng_stats_list_internal(hc_sock_t *socket, hc_data_t **pdata,
+ bool async) {
+ hc_result_t *result = _hcng_stats_list_serialize(socket, pdata, async);
+
+ int ret = INPUT_ERROR;
+ if (result->success) {
+ ret = _hcng_execute_command(socket, (hc_msg_t *)&result->msg,
+ sizeof(result->msg), &result->params, pdata,
+ result->async);
+ }
+
+ hc_result_free(result);
+ DEBUG("[_hcng_stats_list] done or error");
+ return ret;
+}
+
+static int _hcng_stats_list(hc_sock_t *s, hc_data_t **pdata) {
+ DEBUG("[_hcng_stats_list]");
+ return _hcng_stats_list_internal(s, pdata, false);
+}
+
/* RESULT */
hc_msg_t *_hcng_result_get_msg(hc_result_t *result) { return &result->msg; }
int _hcng_result_get_cmd_id(hc_result_t *result) {
@@ -3018,6 +3142,9 @@ static hc_sock_t hc_sock_light_ng_interface = (hc_sock_t){
.hc_subscription_create = _hcng_subscription_create,
.hc_subscription_delete = _hcng_subscription_delete,
+ .hc_stats_get = _hcng_stats_get,
+ .hc_stats_list = _hcng_stats_list,
+
.hc_route_create = _hcng_route_create,
.hc_route_create_async = _hcng_route_create_async,
.hc_route_delete = _hcng_route_delete,
@@ -3094,7 +3221,7 @@ hc_sock_t *_hc_sock_create_url(const char *url) {
s->seq = 0;
s->cur_request = NULL;
- s->map = hc_sock_map_create();
+ s->map = kh_init_sock_map();
if (!s->map) goto ERR_MAP;
return (hc_sock_t *)(s);