diff options
Diffstat (limited to 'hicn-light/src/hicn/config')
-rw-r--r-- | hicn-light/src/hicn/config/configuration.c | 44 | ||||
-rw-r--r-- | hicn-light/src/hicn/config/configuration.h | 5 | ||||
-rw-r--r-- | hicn-light/src/hicn/config/controlListConnections.c | 4 | ||||
-rw-r--r-- | hicn-light/src/hicn/config/controlListListeners.c | 4 | ||||
-rw-r--r-- | hicn-light/src/hicn/config/controlListPolicies.c | 4 | ||||
-rw-r--r-- | hicn-light/src/hicn/config/controlListRoutes.c | 4 |
6 files changed, 45 insertions, 20 deletions
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 <hicn/ctrl/commands.h> + #ifndef _WIN32 #include <arpa/inet.h> #include <unistd.h> @@ -41,7 +43,7 @@ #include <hicn/core/listener.h> //the listener list #include <hicn/core/listener_table.h> -#include <hicn/utils/commands.h> +#include <hicn/ctrl/commands.h> #include <hicn/utils/utils.h> #include <hicn/utils/punting.h> #include <hicn/util/log.h> @@ -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; +} + diff --git a/hicn-light/src/hicn/config/configuration.h b/hicn-light/src/hicn/config/configuration.h index fa1b0410c..1cf772b42 100644 --- a/hicn-light/src/hicn/config/configuration.h +++ b/hicn-light/src/hicn/config/configuration.h @@ -27,7 +27,8 @@ #define configuration_h #include "../core/msgbuf.h" -#include "../utils/commands.h" +#include "../core/strategy.h" +#include <hicn/ctrl/api.h> typedef struct configuration_s configuration_t; @@ -126,4 +127,6 @@ uint8_t * configuration_dispatch_command(configuration_t * config, command_type_t command_type, uint8_t * packet, unsigned ingress_id); +face_type_t get_face_type_from_listener_type(hc_connection_type_t listener_type); + #endif // configuration_h diff --git a/hicn-light/src/hicn/config/controlListConnections.c b/hicn-light/src/hicn/config/controlListConnections.c index c47431726..fedc99868 100644 --- a/hicn-light/src/hicn/config/controlListConnections.c +++ b/hicn-light/src/hicn/config/controlListConnections.c @@ -98,8 +98,8 @@ static CommandReturn _controlListConnections_Execute(CommandParser *parser, } // Process/Print message - header_control_message *receivedHeader = - (header_control_message *)response[0].iov_base; + cmd_header_t *receivedHeader = + (cmd_header_t *)response[0].iov_base; uint8_t *receivedPayload = (uint8_t *)response[1].iov_base; char *sourceString = NULL; diff --git a/hicn-light/src/hicn/config/controlListListeners.c b/hicn-light/src/hicn/config/controlListListeners.c index f0ab820f5..e8909fc7c 100644 --- a/hicn-light/src/hicn/config/controlListListeners.c +++ b/hicn-light/src/hicn/config/controlListListeners.c @@ -79,8 +79,8 @@ static CommandReturn _controlListListeners_Execute(CommandParser *parser, } // Process/Print message - header_control_message *receivedHeader = - (header_control_message *)response[0].iov_base; + cmd_header_t *receivedHeader = + (cmd_header_t *)response[0].iov_base; uint8_t *receivedPayload = (uint8_t *)response[1].iov_base; // Allocate output to pass to the main function if the call is not interactive diff --git a/hicn-light/src/hicn/config/controlListPolicies.c b/hicn-light/src/hicn/config/controlListPolicies.c index 9ea3bae75..424893a3d 100644 --- a/hicn-light/src/hicn/config/controlListPolicies.c +++ b/hicn-light/src/hicn/config/controlListPolicies.c @@ -92,8 +92,8 @@ static CommandReturn _controlListPolicies_Execute(CommandParser *parser, } // Process/Print message - header_control_message *receivedHeader = - (header_control_message *)response[0].iov_base; + cmd_header_t *receivedHeader = + (cmd_header_t *)response[0].iov_base; uint8_t *receivedPayload = (uint8_t *)response[1].iov_base; if (!receivedPayload) { printf("No payload!\n"); diff --git a/hicn-light/src/hicn/config/controlListRoutes.c b/hicn-light/src/hicn/config/controlListRoutes.c index 33a1ac6f5..df1c24334 100644 --- a/hicn-light/src/hicn/config/controlListRoutes.c +++ b/hicn-light/src/hicn/config/controlListRoutes.c @@ -91,8 +91,8 @@ static CommandReturn _controlListRoutes_Execute(CommandParser *parser, } // Process/Print message - header_control_message *receivedHeader = - (header_control_message *)response[0].iov_base; + cmd_header_t *receivedHeader = + (cmd_header_t *)response[0].iov_base; uint8_t *receivedPayload = (uint8_t *)response[1].iov_base; // Allocate output to pass to the main function if the call is not interactive |