From a5a6ffb506aa3c2a0c7fe8fd09abf3f737984aa5 Mon Sep 17 00:00:00 2001 From: "Enrico Loparco (eloparco)" Date: Tue, 23 Mar 2021 14:58:34 +0100 Subject: [HICN-645] Fix data structures to support hicn-light-daemon and hicn-light-control communication The daemon should be able to start, receive commands from hicn-light-control and execute them. Signed-off-by: Enrico Loparco (eloparco) Change-Id: I0ca5bb3d9bdfb37ac8cfa9f671f6c162c9a394f5 Signed-off-by: Enrico Loparco (eloparco) --- hicn-light/src/hicn/config/configuration.c | 44 ++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 11 deletions(-) (limited to 'hicn-light/src/hicn/config/configuration.c') diff --git a/hicn-light/src/hicn/config/configuration.c b/hicn-light/src/hicn/config/configuration.c index fed9d95ed..f5ed231b2 100644 --- a/hicn-light/src/hicn/config/configuration.c +++ b/hicn-light/src/hicn/config/configuration.c @@ -21,6 +21,8 @@ * @endcode */ +#include + #ifndef _WIN32 #include #include @@ -41,7 +43,7 @@ #include //the listener list #include -#include +#include #include #include #include @@ -210,13 +212,11 @@ configuration_on_listener_add(configuration_t * config, uint8_t * packet, } // NOTE: interface_name is expected NULL for hICN listener - face_type_t face_type; - if (!face_type_is_defined(control->listener_type)) + face_type_t face_type = get_face_type_from_listener_type((hc_connection_type_t) control->listenerType); + if (!face_type_is_defined(face_type)) goto NACK; - face_type = (face_type_t)control->listener_type; - - listener = listener_create(face_type, &address, control->interface_name, control->symbolic, forwarder); + listener = listener_create(face_type, &address, control->interfaceName, control->symbolic, forwarder); if (!listener) goto NACK; @@ -1061,10 +1061,11 @@ uint8_t * configuration_on_punting_add(configuration_t * config, uint8_t * packet, unsigned ingress_id) { -#if !defined(__APPLE__) && !defined(_WIN32) && defined(PUNTING) +// #if !defined(__APPLE__) && !defined(_WIN32) && defined(PUNTING) msg_punting_add_t * msg = (msg_punting_add_t *)packet; - cmd_punting_add_t * control = &msg->payload; +#if !defined(__APPLE__) && !defined(_WIN32) && defined(PUNTING) + cmd_punting_add_t * control = &msg->payload; if (ip_address_empty(&control->address)) goto NACK; @@ -1409,9 +1410,11 @@ configuration_receive_command(configuration_t * config, msgbuf_t * msgbuf) break; } - connection_table_t * table = forwarder_get_connection_table(config->forwarder); - const connection_t *connection = connection_table_at(table, ingress_id); - connection_send_packet(connection, reply, false); + if (connection_id_is_valid(msgbuf->connection_id)) { + connection_table_t * table = forwarder_get_connection_table(config->forwarder); + const connection_t *connection = connection_table_at(table, ingress_id); + connection_send_packet(connection, reply, sizeof(cmd_header_t)); + } switch (msgbuf->command.type) { case COMMAND_TYPE_LISTENER_LIST: @@ -1429,3 +1432,22 @@ configuration_receive_command(configuration_t * config, msgbuf_t * msgbuf) // XXX only if we consumed the whole packet. return (ssize_t)msgbuf_get_len(msgbuf); } + +face_type_t get_face_type_from_listener_type(hc_connection_type_t listener_type) { + face_type_t face_type; + switch (listener_type) { + case CONNECTION_TYPE_TCP: + face_type = FACE_TYPE_TCP_LISTENER; + break; + case CONNECTION_TYPE_UDP: + face_type = FACE_TYPE_UDP_LISTENER; + break; + case CONNECTION_TYPE_HICN: + face_type = FACE_TYPE_HICN_LISTENER; + break; + default: + face_type = FACE_TYPE_UNDEFINED; + } + return face_type; +} + -- cgit 1.2.3-korg