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/CMakeLists.txt | 4 +- hicn-light/src/hicn/cli/color.c | 1 + hicn-light/src/hicn/config/configuration.c | 27 +- hicn-light/src/hicn/config/configuration.h | 1 + hicn-light/src/hicn/core/CMakeLists.txt | 2 +- hicn-light/src/hicn/core/fib_entry.c | 9 +- hicn-light/src/hicn/core/fib_entry.h | 7 +- hicn-light/src/hicn/core/forwarder.c | 4 +- hicn-light/src/hicn/core/forwarder.h | 2 +- hicn-light/src/hicn/core/mapme.h | 2 +- hicn-light/src/hicn/core/messageHandler.h | 39 ++- hicn-light/src/hicn/core/msgbuf.h | 6 +- hicn-light/src/hicn/core/nameBitvector.c | 2 +- hicn-light/src/hicn/core/strategy.h | 11 - hicn-light/src/hicn/io/tcp.c | 1 - hicn-light/src/hicn/strategies/low_latency.h | 4 +- hicn-light/src/hicn/utils/CMakeLists.txt | 3 +- hicn-light/src/hicn/utils/commands.h | 378 --------------------------- hicn-light/src/hicn/utils/utils.h | 5 +- 19 files changed, 58 insertions(+), 450 deletions(-) delete mode 100644 hicn-light/src/hicn/utils/commands.h (limited to 'hicn-light') diff --git a/hicn-light/CMakeLists.txt b/hicn-light/CMakeLists.txt index fa8c6664e..33caa5cdc 100644 --- a/hicn-light/CMakeLists.txt +++ b/hicn-light/CMakeLists.txt @@ -75,7 +75,7 @@ else() ${LIBHICNCTRL_STATIC} ) else () - set(HICN_LIBRARIES ${LIBHICN_SHARED}) + set(HICN_LIBRARIES ${LIBHICN_SHARED} ${LIBHICNCTRL_SHARED}) list(APPEND DEPENDENCIES ${LIBEVENT_SHARED} ${LIBHICN_SHARED} @@ -123,8 +123,6 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") endif() if (BUILD_TESTS) - include (GTestImport) - if(${CMAKE_VERSION} VERSION_GREATER "3.10.0") include (GoogleTest) else() diff --git a/hicn-light/src/hicn/cli/color.c b/hicn-light/src/hicn/cli/color.c index 2fff2ead6..7fb25e6b2 100644 --- a/hicn-light/src/hicn/cli/color.c +++ b/hicn-light/src/hicn/cli/color.c @@ -32,6 +32,7 @@ vprintfc(color_t color, const char * fmt, va_list ap) case COLOR_UNDEFINED: case COLOR_N: + default: // XXX color_s = ""; break; } 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; } - diff --git a/hicn-light/src/hicn/config/configuration.h b/hicn-light/src/hicn/config/configuration.h index 1cf772b42..91f851a59 100644 --- a/hicn-light/src/hicn/config/configuration.h +++ b/hicn-light/src/hicn/config/configuration.h @@ -29,6 +29,7 @@ #include "../core/msgbuf.h" #include "../core/strategy.h" #include +#include typedef struct configuration_s configuration_t; diff --git a/hicn-light/src/hicn/core/CMakeLists.txt b/hicn-light/src/hicn/core/CMakeLists.txt index 32b546400..277bcedb2 100644 --- a/hicn-light/src/hicn/core/CMakeLists.txt +++ b/hicn-light/src/hicn/core/CMakeLists.txt @@ -78,4 +78,4 @@ set(TO_INSTALL_HEADER_FILES if (BUILD_TESTS) add_subdirectory(test) -endif() \ No newline at end of file +endif() diff --git a/hicn-light/src/hicn/core/fib_entry.c b/hicn-light/src/hicn/core/fib_entry.c index 5c6e28d5b..59e5f7e7c 100644 --- a/hicn-light/src/hicn/core/fib_entry.c +++ b/hicn-light/src/hicn/core/fib_entry.c @@ -20,7 +20,6 @@ //#include #include #include -#include #ifdef WITH_MAPME #include @@ -122,7 +121,7 @@ fib_entry_filter_nexthops(fib_entry_t * entry, nexthops_t * nexthops, unsigned nexthop, i; uint_fast32_t flags; - policy_t policy = fib_entry_get_policy(entry); + hicn_policy_t policy = fib_entry_get_policy(entry); nexthops_enumerate(nexthops, i, nexthop, { conn = connection_table_at(table, nexthop); @@ -325,14 +324,14 @@ fib_entry_get_available_nexthops(fib_entry_t * entry, unsigned ingress_id, nexth return fib_entry_filter_nexthops(entry, fib_entry_get_nexthops(entry), ingress_id, true); } -policy_t +hicn_policy_t fib_entry_get_policy(const fib_entry_t * entry) { return entry->policy; } void -fib_entry_set_policy(fib_entry_t * entry, policy_t policy) +fib_entry_set_policy(fib_entry_t * entry, hicn_policy_t policy) { entry->policy = policy; @@ -406,7 +405,7 @@ fib_entry_get_nexthops_from_strategy(fib_entry_t * entry, * If multipath is disabled, we don't offer much choice to the forwarding * strategy, but still go through it for accounting purposes. */ - policy_t policy = fib_entry_get_policy(entry); + hicn_policy_t policy = fib_entry_get_policy(entry); if ((policy.tags[POLICY_TAG_MULTIPATH].state == POLICY_STATE_PROHIBIT) || (policy.tags[POLICY_TAG_MULTIPATH].state != POLICY_STATE_AVOID)) { nexthops_select_one(nexthops); diff --git a/hicn-light/src/hicn/core/fib_entry.h b/hicn-light/src/hicn/core/fib_entry.h index 5ec0f29de..3b249a8fe 100644 --- a/hicn-light/src/hicn/core/fib_entry.h +++ b/hicn-light/src/hicn/core/fib_entry.h @@ -42,7 +42,6 @@ #include "msgbuf.h" #include "nexthops.h" #include "prefix_stats.h" -//#include "../utils/commands.h" // strategy type typedef struct { Name *name; @@ -53,7 +52,7 @@ typedef struct { const void * forwarder; #ifdef WITH_POLICY - policy_t policy; + hicn_policy_t policy; #endif /* WITH_POLICY */ prefix_counters_t prefix_counters; @@ -114,9 +113,9 @@ void fib_entry_on_data(fib_entry_t * fib_entry, const nexthops_t * nexthops, Ticks data_reception); #ifdef WITH_POLICY -policy_t fib_entry_get_policy(const fib_entry_t *fib_entry); +hicn_policy_t fib_entry_get_policy(const fib_entry_t *fib_entry); void fib_entry_reconsider_policy(fib_entry_t *fib_entry); -void fib_entry_set_policy(fib_entry_t *fib_entry, policy_t policy); +void fib_entry_set_policy(fib_entry_t *fib_entry, hicn_policy_t policy); void fib_entry_update_stats(fib_entry_t *fib_entry, uint64_t now); #endif /* WITH_POLICY */ diff --git a/hicn-light/src/hicn/core/forwarder.c b/hicn-light/src/hicn/core/forwarder.c index 9954ecd0a..e1a7243ca 100644 --- a/hicn-light/src/hicn/core/forwarder.c +++ b/hicn-light/src/hicn/core/forwarder.c @@ -941,7 +941,7 @@ forwarder_remove_route(forwarder_t * forwarder, ip_prefix_t * prefix, bool forwarder_add_or_update_policy(forwarder_t * forwarder, ip_prefix_t * prefix, - policy_t * policy) + hicn_policy_t * policy) { assert(forwarder); assert(prefix); @@ -1188,7 +1188,7 @@ forwarder_receive(forwarder_t * forwarder, listener_t * listener, msgbuf->connection_id = listener_create_connection(listener, pair); msg_header_t * msg = (msg_header_t*) packet; - msgbuf->command.type = msg->header.commandID; + msgbuf->command.type = msg->header.command_id; if (msgbuf->command.type >= COMMAND_TYPE_N || msgbuf->command.type == COMMAND_TYPE_UNDEFINED) { ERROR("Invalid command"); return -msgbuf_get_len(msgbuf); diff --git a/hicn-light/src/hicn/core/forwarder.h b/hicn-light/src/hicn/core/forwarder.h index f5ac375da..17d8a1994 100644 --- a/hicn-light/src/hicn/core/forwarder.h +++ b/hicn-light/src/hicn/core/forwarder.h @@ -162,7 +162,7 @@ bool forwarder_remove_route(forwarder_t * forwarder, ip_prefix_t * prefix, * @brief Adds or updates a policy on the message processor */ bool forwarder_add_or_update_policy(forwarder_t * forwarder, - ip_prefix_t * prefix, policy_t * policy); + ip_prefix_t * prefix, hicn_policy_t * policy); /** * @brief Removes a policy from the message processor diff --git a/hicn-light/src/hicn/core/mapme.h b/hicn-light/src/hicn/core/mapme.h index d1d21079f..29b59faf5 100644 --- a/hicn-light/src/hicn/core/mapme.h +++ b/hicn-light/src/hicn/core/mapme.h @@ -26,12 +26,12 @@ #include #include +#include #include #include "connection.h" #include "fib_entry.h" #include "msgbuf.h" -#include "../utils/commands.h" typedef struct mapme_s mapme_t; diff --git a/hicn-light/src/hicn/core/messageHandler.h b/hicn-light/src/hicn/core/messageHandler.h index 1df511a5c..c6a03eee4 100644 --- a/hicn-light/src/hicn/core/messageHandler.h +++ b/hicn-light/src/hicn/core/messageHandler.h @@ -50,6 +50,8 @@ #define CONTROL_PORT 9695 #define HTTP_PORT 8080 +// XXX Hardcoded packet format HF_INET6_TCP + #define IPV6_DEFAULT_VERSION 6 #define IPV6_DEFAULT_TRAFFIC_CLASS 0 #define IPV6_DEFAULT_FLOW_LABEL 0 @@ -183,7 +185,7 @@ static inline bool messageHandler_IsInterest(const uint8_t *message) { if (!messageHandler_IsTCP(message)) return false; bool flag; - hicn_packet_test_ece((hicn_header_t *)message, + hicn_packet_test_ece(HF_INET6_TCP, (hicn_header_t *)message, &flag); // ECE flag is set to 0 in interest packets if (flag == false) return true; return false; @@ -193,7 +195,7 @@ static inline bool messageHandler_IsData(const uint8_t *message) { if (!messageHandler_IsTCP(message)) return false; bool flag; - hicn_packet_test_ece((hicn_header_t *)message, + hicn_packet_test_ece(HF_INET6_TCP, (hicn_header_t *)message, &flag); // ECE flag is set to 1 in data packets if (flag == true) return true; return false; @@ -354,13 +356,10 @@ static inline uint32_t messageHandler_GetPathLabel(const uint8_t *message) { } static inline void messageHandler_SetPathLabel(uint8_t *message, + uint32_t old_path_label, uint32_t new_path_label) { if (!messageHandler_IsTCP(message)) return; - uint32_t old_path_label; - int res = hicn_data_get_path_label((hicn_header_t *)message, &old_path_label); - if (res < 0) return; - hicn_data_set_path_label((hicn_header_t *)message, new_path_label); messageHandler_UpdateTCPCheckSum(message, (uint16_t *)&old_path_label, @@ -376,20 +375,12 @@ static inline void messageHandler_UpdatePathLabel(uint8_t *message, uint32_t pl_new_32bit = (uint32_t)((((pl_old_8bit << 1) | (pl_old_8bit >> 7)) ^ outFace) << 24UL); - hicn_data_set_path_label((hicn_header_t *)message, pl_new_32bit); - - messageHandler_UpdateTCPCheckSum(message, (uint16_t *)&pl_old_32bit, - (uint16_t *)&pl_new_32bit, 2); + // XXX path label should be 8 bits now ? + messageHandler_SetPathLabel(message, pl_old_32bit, pl_new_32bit); } static inline void messageHandler_ResetPathLabel(uint8_t *message) { - if (!messageHandler_IsTCP(message)) return; - - uint32_t pl_old_32bit = messageHandler_GetPathLabel(message); - uint32_t pl_new_32bit = 0; - hicn_data_set_path_label((hicn_header_t *)message, pl_new_32bit); - messageHandler_UpdateTCPCheckSum(message, (uint16_t *)&pl_old_32bit, - (uint16_t *)&pl_new_32bit, 2); + messageHandler_SetPathLabel(message, messageHandler_GetPathLabel(message), 0); } static inline uint16_t messageHandler_GetInterestLifetime( @@ -555,7 +546,7 @@ static inline uint8_t * messageHandler_CreateProbePacket(hicn_format_t format, hicn_packet_init_header(format, (hicn_header_t *) pkt); - hicn_packet_set_dst_port((hicn_header_t *) pkt, BFD_PORT); + hicn_packet_set_dst_port(format, (hicn_header_t *) pkt, BFD_PORT); hicn_interest_set_lifetime ((hicn_header_t *) pkt, probe_lifetime); return pkt; @@ -573,10 +564,10 @@ static inline void messageHandler_CreateProbeReply(uint8_t * probe, uint16_t src_prt; uint16_t dst_prt; - hicn_packet_get_src_port((const hicn_header_t *) probe, &src_prt); - hicn_packet_get_dst_port((const hicn_header_t *) probe, &dst_prt); - hicn_packet_set_src_port((hicn_header_t *) probe, dst_prt); - hicn_packet_set_dst_port((hicn_header_t *) probe, src_prt); + hicn_packet_get_src_port(format, (const hicn_header_t *) probe, &src_prt); + hicn_packet_get_dst_port(format, (const hicn_header_t *) probe, &dst_prt); + hicn_packet_set_src_port(format, (hicn_header_t *) probe, dst_prt); + hicn_packet_set_dst_port(format, (hicn_header_t *) probe, src_prt); hicn_data_set_name (format, (hicn_header_t *) probe, &probe_name); hicn_data_set_locator (format, (hicn_header_t *) probe, &probe_locator); @@ -598,8 +589,8 @@ static inline void messageHandler_SetProbeName(uint8_t * probe, hicn_format_t fo static inline bool messageHandler_IsAProbe(const uint8_t *packet){ uint16_t src_prt; uint16_t dst_prt; - hicn_packet_get_src_port ((const hicn_header_t *) packet, &src_prt); - hicn_packet_get_dst_port ((const hicn_header_t *) packet, &dst_prt); + hicn_packet_get_src_port (HF_INET6_TCP, (const hicn_header_t *) packet, &src_prt); + hicn_packet_get_dst_port (HF_INET6_TCP, (const hicn_header_t *) packet, &dst_prt); if(dst_prt == BFD_PORT){ //interest probe diff --git a/hicn-light/src/hicn/core/msgbuf.h b/hicn-light/src/hicn/core/msgbuf.h index a52e6b298..f3125a2e7 100644 --- a/hicn-light/src/hicn/core/msgbuf.h +++ b/hicn-light/src/hicn/core/msgbuf.h @@ -24,7 +24,7 @@ #include "name.h" #include "ticks.h" #include "messageHandler.h" -#include "../utils/commands.h" +#include struct name_s; @@ -84,8 +84,8 @@ typedef struct { /* Path label */ #define msgbuf_get_pathlabel(M) (messageHandler_GetPathLabel((M)->packet)) -#define msgbuf_set_pathlabel(M, label) (messageHandler_SetPathLabel((M)->packet, label)) -#define msgbuf_update_pathlabel(M, outface) (messageHandler_SetPathLabel((M)->packet, outface)) +#define msgbuf_set_pathlabel(M, label) (messageHandler_SetPathLabel((M)->packet, msgbuf_get_pathlabel(M), label)) +#define msgbuf_update_pathlabel(M, outface) (messageHandler_UpdatePathLabel((M)->packet, outface)) #define msgbuf_reset_pathlabel(M) (messageHandler_ResetPathLabel((M)->packet)) /* WLDR */ diff --git a/hicn-light/src/hicn/core/nameBitvector.c b/hicn-light/src/hicn/core/nameBitvector.c index d3dc8c0ee..999f7a928 100644 --- a/hicn-light/src/hicn/core/nameBitvector.c +++ b/hicn-light/src/hicn/core/nameBitvector.c @@ -21,7 +21,7 @@ #include #include // hash32 -#include +#include #define DEFAULT_PORT 1234 #define NAME_LEN 2 diff --git a/hicn-light/src/hicn/core/strategy.h b/hicn-light/src/hicn/core/strategy.h index 67630bbab..c684750f1 100644 --- a/hicn-light/src/hicn/core/strategy.h +++ b/hicn-light/src/hicn/core/strategy.h @@ -24,17 +24,6 @@ #include "../strategies/low_latency.h" #include "../strategies/random.h" -typedef enum { - STRATEGY_TYPE_UNDEFINED, - STRATEGY_TYPE_LOADBALANCER, - STRATEGY_TYPE_LOW_LATENCY, - STRATEGY_TYPE_RANDOM, - STRATEGY_TYPE_N -} strategy_type_t; - -#define STRATEGY_TYPE_VALID(type) \ - ((type != STRATEGY_TYPE_UNDEFINED) && (type != STRATEGY_TYPE_N)) - typedef union { strategy_load_balancer_options_t load_balancer; strategy_low_latency_options_t low_latency; diff --git a/hicn-light/src/hicn/io/tcp.c b/hicn-light/src/hicn/io/tcp.c index e4f5d196f..7c9d19729 100644 --- a/hicn-light/src/hicn/io/tcp.c +++ b/hicn-light/src/hicn/io/tcp.c @@ -38,7 +38,6 @@ #include "../core/msgbuf.h" #include "../core/forwarder.h" #include "../core/messageHandler.h" -#include "../utils/commands.h" // 128 KB output queue #define OUTPUT_QUEUE_BYTES (128 * 1024) diff --git a/hicn-light/src/hicn/strategies/low_latency.h b/hicn-light/src/hicn/strategies/low_latency.h index ff8255eae..47e9a202b 100644 --- a/hicn-light/src/hicn/strategies/low_latency.h +++ b/hicn-light/src/hicn/strategies/low_latency.h @@ -20,10 +20,10 @@ #ifndef HICNLIGHT_STRATEGY_LOW_LATENCY_H #define HICNLIGHT_STRATEGY_LOW_LATENCY_H -#define MAX_FWD_STRATEGY_RELATED_PREFIXES 10 - struct name_s; +#include + typedef struct { } strategy_low_latency_nexthop_state_t; diff --git a/hicn-light/src/hicn/utils/CMakeLists.txt b/hicn-light/src/hicn/utils/CMakeLists.txt index 99592b31d..1fdfdee9f 100644 --- a/hicn-light/src/hicn/utils/CMakeLists.txt +++ b/hicn-light/src/hicn/utils/CMakeLists.txt @@ -13,8 +13,9 @@ cmake_minimum_required(VERSION 3.5 FATAL_ERROR) +# XXX This is installed in hicn/utils... list(APPEND HEADER_FILES - ${CMAKE_CURRENT_SOURCE_DIR}/commands.h +# ${CMAKE_CURRENT_SOURCE_DIR}/commands.h # ${CMAKE_CURRENT_SOURCE_DIR}/interface.h # ${CMAKE_CURRENT_SOURCE_DIR}/interfaceSet.h ${CMAKE_CURRENT_SOURCE_DIR}/punting.h diff --git a/hicn-light/src/hicn/utils/commands.h b/hicn-light/src/hicn/utils/commands.h deleted file mode 100644 index ede6177f4..000000000 --- a/hicn-light/src/hicn/utils/commands.h +++ /dev/null @@ -1,378 +0,0 @@ -/* - * Copyright (c) 2017-2019 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * @file commands.h - * @brief All hicn-light commands: 14 in total. - * - * Header and payload in binary format. - */ - -#ifndef commands_h -#define commands_h - -#ifndef _WIN32 -#include -#include -#endif - -#include -#include - -#ifdef WITH_POLICY -#include -#endif /* WITH_POLICY */ -#include - -#include "../core/strategy.h" // to be moved in libhicn - -#define SYMBOLIC_NAME_LEN 16 - -typedef struct in6_addr ipv6_addr_t; -typedef uint32_t ipv4_addr_t; - -typedef enum { - MESSAGE_COMMAND_SUBTYPE_UNDEFINED, - REQUEST_LIGHT = 0xc0, // this is a command - RESPONSE_LIGHT, - ACK_LIGHT, - NACK_LIGHT, - MESSAGE_COMMAND_SUBTYPE_N -} message_command_subtype_t; - -#define message_type_is_valid(message_type) \ - ((message_type != MESSAGE_TYPE_UNDEFINED) && (message_type != MESSAGE_COMMAND_SUBTYPE_N)) - -#define message_type_from_uchar(x) \ - (((x) < REQUEST_LIGHT) || (((x) >= MESSAGE_COMMAND_SUBTYPE_N)) ? MESSAGE_COMMAND_SUBTYPE_N : (message_command_subtype_t)(x)) - -#define foreach_command_type \ - _(listener_add, LISTENER_ADD) \ - _(listener_remove, LISTENER_REMOVE) \ - _(listener_list, LISTENER_LIST) \ - _(connection_add, CONNECTION_ADD) \ - _(connection_remove, CONNECTION_REMOVE) \ - _(connection_list, CONNECTION_LIST) \ - _(connection_set_admin_state, CONNECTION_SET_ADMIN_STATE) \ - _(connection_update, CONNECTION_UPDATE) \ - _(connection_set_priority, CONNECTION_SET_PRIORITY) \ - _(connection_set_tags, CONNECTION_SET_TAGS) \ - _(route_add, ROUTE_ADD) \ - _(route_remove, ROUTE_REMOVE) \ - _(route_list, ROUTE_LIST) \ - _(cache_set_store, CACHE_SET_STORE) \ - _(cache_set_serve, CACHE_SET_SERVE) \ - _(cache_clear, CACHE_CLEAR) \ - _(strategy_set, STRATEGY_SET) \ - _(wldr_set, WLDR_SET) \ - _(punting_add, PUNTING_ADD) \ - _(mapme_enable, MAPME_ENABLE) \ - _(mapme_set_discovery, MAPME_SET_DISCOVERY) \ - _(mapme_set_timescale, MAPME_SET_TIMESCALE) \ - _(mapme_set_retx, MAPME_SET_RETX) \ - _(mapme_send_update, MAPME_SEND_UPDATE) \ - _(policy_add, POLICY_ADD) \ - _(policy_remove, POLICY_REMOVE) \ - _(policy_list, POLICY_LIST) \ - -typedef enum { - COMMAND_TYPE_UNDEFINED, -#define _(l, u) COMMAND_TYPE_ ## u, - foreach_command_type -#undef _ - COMMAND_TYPE_N, -} command_type_t; - -#define command_type_is_valid(command_type) \ - ((command_type != COMMAND_TYPE_UNDEFINED) && (command_type != COMMAND_TYPE_N)) - -#define command_type_from_uchar(x) \ - (((x) >= COMMAND_TYPE_N) ? COMMAND_TYPE_N : (command_type_t)(x)) - -/* Should be at least 8 bytes */ -typedef struct { - uint8_t messageType; - uint8_t commandID; - uint16_t length; /* Number of structures in the payload */ - uint32_t seqNum; -} cmd_header_t; - -typedef struct { - cmd_header_t header; -} msg_header_t; - -/* Listener */ - -typedef struct { - char symbolic[SYMBOLIC_NAME_LEN]; - char interface_name[SYMBOLIC_NAME_LEN]; - ip_address_t address; - uint16_t port; - uint8_t family; - uint8_t listener_type; -} cmd_listener_add_t; - -typedef struct { - char symbolicOrListenerid[SYMBOLIC_NAME_LEN]; -} cmd_listener_remove_t; - -typedef struct { -} cmd_listener_list_t; - -typedef struct { - ip_address_t address; - char name[SYMBOLIC_NAME_LEN]; - char interface_name[SYMBOLIC_NAME_LEN]; - uint32_t id; - uint16_t port; - uint8_t family; - uint8_t type; -} cmd_listener_list_item_t; - -/* Connection */ - -typedef struct { - char symbolic[SYMBOLIC_NAME_LEN]; - //char interface_name[SYMBOLIC_NAME_LEN]; - ip_address_t remote_ip; - ip_address_t local_ip; - uint16_t remote_port; - uint16_t local_port; - uint8_t family; - uint8_t type; - uint8_t admin_state; -#ifdef WITH_POLICY - uint32_t priority; - policy_tags_t tags; -#endif /* WITH_POLICY */ -} cmd_connection_add_t; - -typedef struct { - char symbolicOrConnid[SYMBOLIC_NAME_LEN]; -} cmd_connection_remove_t; - -typedef struct { -} cmd_connection_list_t; - -typedef struct { - char symbolic[SYMBOLIC_NAME_LEN]; - //char interface_name[SYMBOLIC_NAME_LEN]; - ip_address_t remote_ip; - ip_address_t local_ip; - uint16_t remote_port; - uint16_t local_port; - uint8_t family; - uint8_t type; - uint8_t admin_state; -#ifdef WITH_POLICY - uint32_t priority; - policy_tags_t tags; -#endif /* WITH_POLICY */ - uint32_t id; - uint8_t state; - char interface_name[SYMBOLIC_NAME_LEN]; - char name[SYMBOLIC_NAME_LEN]; -} cmd_connection_list_item_t; - -typedef struct { - char symbolicOrConnid[SYMBOLIC_NAME_LEN]; - uint8_t admin_state; - uint8_t pad8[3]; -} cmd_connection_set_admin_state_t; - -typedef struct { - char symbolicOrConnid[SYMBOLIC_NAME_LEN]; - uint8_t admin_state; - uint32_t priority; - policy_tags_t tags; -} cmd_connection_update_t; - -typedef struct { - char symbolicOrConnid[SYMBOLIC_NAME_LEN]; - uint32_t priority; -} cmd_connection_set_priority_t; - -typedef struct { - char symbolicOrConnid[SYMBOLIC_NAME_LEN]; - policy_tags_t tags; -} cmd_connection_set_tags_t; - -/* Route */ - -typedef struct { - char symbolicOrConnid[SYMBOLIC_NAME_LEN]; - ip_address_t address; - uint16_t cost; - uint8_t family; - uint8_t len; -} cmd_route_add_t; - -typedef struct { - char symbolicOrConnid[SYMBOLIC_NAME_LEN]; - ip_address_t address; - uint8_t family; - uint8_t len; -} cmd_route_remove_t; - -typedef struct { -} cmd_route_list_t; - -typedef struct { - ip_address_t address; - uint32_t connection_id; - uint16_t cost; - uint8_t family; - uint8_t len; -} cmd_route_list_item_t; - -/* Cache */ - -typedef struct { - uint8_t activate; -} cmd_cache_set_store_t; - -typedef struct { - uint8_t activate; -} cmd_cache_set_serve_t; - -typedef struct { -} cmd_cache_clear_t; - -/* WLDR */ - -typedef struct { - char symbolicOrConnid[SYMBOLIC_NAME_LEN]; - uint8_t activate; -} cmd_wldr_set_t; - -/* Strategy */ - -typedef struct { - ip_address_t address; - uint8_t strategy_type; - uint8_t family; - uint8_t len; - uint8_t related_prefixes; - union { - struct { - ip_address_t addresses[MAX_FWD_STRATEGY_RELATED_PREFIXES]; - uint8_t lens[MAX_FWD_STRATEGY_RELATED_PREFIXES]; - uint8_t families[MAX_FWD_STRATEGY_RELATED_PREFIXES]; - } low_latency; - }; -} cmd_strategy_set_t; - -/* Punting */ - -typedef struct { - char symbolicOrConnid[SYMBOLIC_NAME_LEN]; - ip_address_t address; - uint8_t family; - uint8_t len; -} cmd_punting_add_t; - -/* MAP-Me */ - -typedef struct { - uint8_t activate; -} cmd_mapme_activator_t; - -typedef cmd_mapme_activator_t cmd_mapme_enable_t; -typedef cmd_mapme_activator_t cmd_mapme_set_discovery_t; - -typedef struct { - uint32_t timePeriod; -} cmd_mapme_timing_t; - -typedef cmd_mapme_timing_t cmd_mapme_set_timescale_t; -typedef cmd_mapme_timing_t cmd_mapme_set_retx_t; - -typedef struct { - ip_address_t address; - uint8_t family; - uint8_t len; -} cmd_mapme_send_update_t; - -/* Policy */ - -typedef struct { - ip_address_t address; - uint8_t family; - uint8_t len; - policy_t policy; -} cmd_policy_add_t; - -typedef struct { - ip_address_t address; - uint8_t family; - uint8_t len; -} cmd_policy_remove_t; - -typedef struct { -} cmd_policy_list_t; - -typedef struct { - ip_address_t address; - uint8_t family; - uint8_t len; - policy_t policy; -} cmd_policy_list_item_t; - -/* Full messages */ - -#define _(l, u) \ -typedef struct { \ - cmd_header_t header; \ - cmd_ ## l ## _t payload; \ -} msg_ ## l ## _t; - foreach_command_type -#undef _ - -typedef struct { - cmd_header_t header; - cmd_listener_list_item_t payload; -} msg_listener_list_reply_t; - -typedef struct { - cmd_header_t header; - cmd_connection_list_item_t payload; -} msg_connection_list_reply_t; - -typedef struct { - cmd_header_t header; - cmd_route_list_item_t payload; -} msg_route_list_reply_t; - -typedef struct { - cmd_header_t header; - cmd_policy_list_item_t payload; -} msg_policy_list_reply_t; - -//===== size of commands ====== -// REMINDER: when a new_command is added, the following switch has to be -// updated. -static inline int command_get_payload_len(command_type_t command_type) { - switch (command_type) { -#define _(l, u) \ - case COMMAND_TYPE_ ## u: \ - return sizeof(cmd_## l ## _t); - foreach_command_type -#undef _ - case COMMAND_TYPE_UNDEFINED: - case COMMAND_TYPE_N: - return 0; - } -} -#endif diff --git a/hicn-light/src/hicn/utils/utils.h b/hicn-light/src/hicn/utils/utils.h index 368a93f5a..ee94250bb 100644 --- a/hicn-light/src/hicn/utils/utils.h +++ b/hicn-light/src/hicn/utils/utils.h @@ -17,7 +17,8 @@ #define utils_h //#include -#include +//#include +#include /** * Return true if string is purely an integer @@ -30,6 +31,8 @@ bool utils_IsNumber(const char *string); */ bool utils_ValidateSymbolicName(const char *symbolic); +// XXX cf IS_VALID_xxx in libhicntrl + /** *Convert IPv4/IPv6 address from binary to text string. `uint8_t *ipAddress` has *to be a `in_addr_t * or `a struct in6_addr *. -- cgit 1.2.3-korg