diff options
Diffstat (limited to 'hicn-light')
-rw-r--r-- | hicn-light/src/hicn/config/CMakeLists.txt | 1 | ||||
-rw-r--r-- | hicn-light/src/hicn/config/command_stats.c | 18 | ||||
-rw-r--r-- | hicn-light/src/hicn/config/commands.c | 56 | ||||
-rw-r--r-- | hicn-light/src/hicn/core/connection.c | 1 | ||||
-rw-r--r-- | hicn-light/src/hicn/core/forwarder.c | 2 |
5 files changed, 31 insertions, 47 deletions
diff --git a/hicn-light/src/hicn/config/CMakeLists.txt b/hicn-light/src/hicn/config/CMakeLists.txt index b1b04d679..36abe96ce 100644 --- a/hicn-light/src/hicn/config/CMakeLists.txt +++ b/hicn-light/src/hicn/config/CMakeLists.txt @@ -23,6 +23,7 @@ list(APPEND SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/../../../../ctrl/libhicnctrl/src/modules/hicn_light/listener.c ${CMAKE_CURRENT_SOURCE_DIR}/../../../../ctrl/libhicnctrl/src/modules/hicn_light/face.c ${CMAKE_CURRENT_SOURCE_DIR}/../../../../ctrl/libhicnctrl/src/modules/hicn_light/route.c + ${CMAKE_CURRENT_SOURCE_DIR}/../../../../ctrl/libhicnctrl/src/modules/hicn_light/stats.c ${CMAKE_CURRENT_SOURCE_DIR}/../../../../ctrl/libhicnctrl/src/modules/hicn_light/strategy.c ${CMAKE_CURRENT_SOURCE_DIR}/../../../../ctrl/libhicnctrl/src/modules/hicn_light/subscription.c ${CMAKE_CURRENT_SOURCE_DIR}/configuration.c diff --git a/hicn-light/src/hicn/config/command_stats.c b/hicn-light/src/hicn/config/command_stats.c deleted file mode 100644 index 70f74fd8c..000000000 --- a/hicn-light/src/hicn/config/command_stats.c +++ /dev/null @@ -1,18 +0,0 @@ -#include <math.h> -#include "command.h" - -/* Commands */ - -static const command_parser_t command_stats_get = { - .action = ACTION_GET, - .object = OBJECT_STATS, - .nparams = 0, -}; -COMMAND_REGISTER(command_stats_get); - -static const command_parser_t command_stats_list = { - .action = ACTION_LIST, - .object = OBJECT_STATS, - .nparams = 0, -}; -COMMAND_REGISTER(command_stats_list);
\ No newline at end of file diff --git a/hicn-light/src/hicn/config/commands.c b/hicn-light/src/hicn/config/commands.c index 6aa76ac7b..e1d25367f 100644 --- a/hicn-light/src/hicn/config/commands.c +++ b/hicn-light/src/hicn/config/commands.c @@ -549,14 +549,6 @@ static inline void fill_connections_command(const connection_t *connection, } } -static inline void fill_connection_stats_command(connection_t *connection, - cmd_stats_list_item_t *cmd) { - assert(connection && cmd); - - cmd->id = connection->id; - cmd->stats = connection->stats; -} - uint8_t *configuration_on_connection_list(forwarder_t *forwarder, uint8_t *packet, unsigned ingress_id, size_t *reply_size) { @@ -1065,51 +1057,57 @@ NACK: /* Statistics */ -uint8_t *configuration_on_stats_get(forwarder_t *forwarder, uint8_t *packet, - unsigned ingress_id, size_t *reply_size) { +uint8_t *configuration_on_stats_list(forwarder_t *forwarder, uint8_t *packet, + unsigned ingress_id, size_t *reply_size) { assert(forwarder && packet); - INFO("CMD: stats get (ingress=%d)", ingress_id); + INFO("CMD: stats list (ingress=%d)", ingress_id); - msg_stats_get_t *msg_received = (msg_stats_get_t *)packet; + size_t n = 1; + msg_stats_list_t *msg_received = (msg_stats_list_t *)packet; + uint8_t command_id = msg_received->header.command_id; uint32_t seq_num = msg_received->header.seq_num; - msg_stats_get_reply_t *msg = malloc(sizeof(*msg)); - *msg = (msg_stats_get_reply_t){ - .header = {.message_type = RESPONSE_LIGHT, - .length = 1, - .seq_num = seq_num}, - .payload = {.forwarder = forwarder_get_stats(forwarder), - .pkt_cache = - pkt_cache_get_stats(forwarder_get_pkt_cache(forwarder))} + msg_stats_list_reply_t *msg = NULL; + msg_malloc_list(msg, command_id, n, seq_num); + if (!msg) goto NACK; - }; + cmd_stats_list_item_t *payload = &msg->payload; + payload->stats.forwarder = forwarder_get_stats(forwarder); + payload->stats.pkt_cache = + pkt_cache_get_stats(forwarder_get_pkt_cache(forwarder)); - *reply_size = sizeof(*msg); + *reply_size = sizeof(msg->header) + n * sizeof(msg->payload); + return (uint8_t *)msg; + +NACK: + *reply_size = sizeof(msg_header_t); + make_nack(msg); return (uint8_t *)msg; } -uint8_t *configuration_on_stats_list(forwarder_t *forwarder, uint8_t *packet, - unsigned ingress_id, size_t *reply_size) { +uint8_t *configuration_on_face_stats_list(forwarder_t *forwarder, + uint8_t *packet, unsigned ingress_id, + size_t *reply_size) { assert(forwarder && packet); - INFO("CMD: stats list (ingress=%d)", ingress_id); + INFO("CMD: face stats list (ingress=%d)", ingress_id); connection_table_t *table = forwarder_get_connection_table(forwarder); // -1 since current connection (i.e. the one used to send // the command) is not considered size_t n = connection_table_len(table) - 1; - msg_stats_list_t *msg_received = (msg_stats_list_t *)packet; + msg_face_stats_list_t *msg_received = (msg_face_stats_list_t *)packet; uint8_t command_id = msg_received->header.command_id; uint32_t seq_num = msg_received->header.seq_num; - msg_stats_list_reply_t *msg = NULL; + msg_face_stats_list_reply_t *msg = NULL; msg_malloc_list(msg, command_id, n, seq_num); if (!msg) goto NACK; - cmd_stats_list_item_t *payload = &msg->payload; + cmd_face_stats_list_item_t *payload = &msg->payload; connection_t *connection; connection_table_foreach(table, connection, { if (connection->id == ingress_id) continue; - fill_connection_stats_command(connection, payload); + payload->stats = connection->stats; payload++; }); diff --git a/hicn-light/src/hicn/core/connection.c b/hicn-light/src/hicn/core/connection.c index ff73a9ae8..69edc7265 100644 --- a/hicn-light/src/hicn/core/connection.c +++ b/hicn-light/src/hicn/core/connection.c @@ -154,6 +154,7 @@ int connection_initialize(connection_t *connection, face_type_t type, .wldr = NULL, .wldr_autostart = true, }; + connection->stats.conn_id = connection_id; connection->interface_type = connection_get_netdevice_type(connection->interface_name); diff --git a/hicn-light/src/hicn/core/forwarder.c b/hicn-light/src/hicn/core/forwarder.c index fbf7040e3..face35fd6 100644 --- a/hicn-light/src/hicn/core/forwarder.c +++ b/hicn-light/src/hicn/core/forwarder.c @@ -1486,6 +1486,8 @@ ssize_t forwarder_receive(forwarder_t *forwarder, listener_t *listener, forwarder->stats.countReceived++; msgbuf->type = type; #endif + forwarder->stats.countReceived++; + /* Initialize packet buffer stored in msgbuf through libhicn */ msgbuf_initialize_from_packet(msgbuf); hicn_packet_analyze(msgbuf_get_pkbuf(msgbuf)); |