From 229385955109b866a23c4ac2aa03d4d11044c39d Mon Sep 17 00:00:00 2001 From: "Enrico Loparco (eloparco)" Date: Thu, 24 Jun 2021 09:15:41 +0200 Subject: [HICN-708] Rebase with master Signed-off-by: Enrico Loparco (eloparco) Change-Id: I2122e1d61dd3b2e039972624ffbdbcb3c5610159 --- hicn-light/src/hicn/config/configuration.c | 27 ++++++++++++++++----------- 1 file changed, 16 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 f5ed231b2..92f3d6359 100644 --- a/hicn-light/src/hicn/config/configuration.c +++ b/hicn-light/src/hicn/config/configuration.c @@ -21,8 +21,6 @@ * @endcode */ -#include - #ifndef _WIN32 #include #include @@ -53,13 +51,13 @@ #define DEFAULT_COST 1 #define DEFAULT_PORT 1234 -#define make_ack(msg) ((msg_header_t *)msg)->header.messageType = ACK_LIGHT -#define make_nack(msg) ((msg_header_t *)msg)->header.messageType = NACK_LIGHT +#define make_ack(msg) ((msg_header_t *)msg)->header.message_type = ACK_LIGHT +#define make_nack(msg) ((msg_header_t *)msg)->header.message_type = NACK_LIGHT #define msg_malloc_list(msg, N) \ do { \ msg = malloc(sizeof((msg)->header) + N * sizeof((msg)->payload)); \ - (msg)->header.messageType = RESPONSE_LIGHT; \ + (msg)->header.message_type = RESPONSE_LIGHT; \ (msg)->header.length = (uint16_t)(N); \ } while(0); @@ -208,15 +206,23 @@ configuration_on_listener_add(configuration_t * config, uint8_t * packet, control->port) < 0) { WARN("Unsupported address type for HICN (ingress id %u): " "must be either IPV4 or IPV6", ingress_id); - return false; + goto NACK; } - // NOTE: interface_name is expected NULL for hICN listener - face_type_t face_type = get_face_type_from_listener_type((hc_connection_type_t) control->listenerType); + if (!face_type_is_defined(control->type)) { + WARN("[configuration_on_listener_add] Invalid listener type"); + goto NACK; + } + + // XXX validate that we use face_type everywhere, as we use the untyped + // uint8_t for the control protocol + face_type_t face_type = get_face_type_from_listener_type((hc_connection_type_t) control->type); if (!face_type_is_defined(face_type)) goto NACK; - listener = listener_create(face_type, &address, control->interfaceName, control->symbolic, forwarder); + // NOTE: interface_name is expected NULL for hICN listener + + listener = listener_create(face_type, &address, control->interface_name, control->symbolic, forwarder); if (!listener) goto NACK; @@ -1422,7 +1428,7 @@ configuration_receive_command(configuration_t * config, msgbuf_t * msgbuf) case COMMAND_TYPE_ROUTE_LIST: case COMMAND_TYPE_POLICY_LIST: /* Free replies that have been allocated (not NACK's) */ - if (((msg_header_t *)reply)->header.messageType != NACK_LIGHT) + if (((msg_header_t *)reply)->header.message_type != NACK_LIGHT) free(reply); break; default: @@ -1450,4 +1456,3 @@ face_type_t get_face_type_from_listener_type(hc_connection_type_t listener_type) } return face_type; } - -- cgit 1.2.3-korg