diff options
-rw-r--r-- | Dockerfile | 33 | ||||
-rw-r--r-- | ctrl/libhicnctrl/src/api_private.h | 12 | ||||
-rw-r--r-- | ctrl/libhicnctrl/src/commands/command_listener.c | 7 | ||||
-rw-r--r-- | ctrl/libhicnctrl/src/modules/hicn_light.c | 5 | ||||
-rw-r--r-- | ctrl/libhicnctrl/src/modules/hicn_light/connection.c | 8 | ||||
-rw-r--r-- | ctrl/libhicnctrl/src/modules/hicn_light/face.c | 12 | ||||
-rw-r--r-- | ctrl/libhicnctrl/src/modules/hicn_light/face.h | 2 | ||||
-rw-r--r-- | ctrl/libhicnctrl/src/objects/subscription.c | 2 | ||||
-rw-r--r-- | hicn-light/src/hicn/cli/hicnc.c | 54 | ||||
-rw-r--r-- | hicn-light/src/hicn/config/commands.c | 11 | ||||
-rw-r--r-- | hicn-light/src/hicn/core/connection.c | 11 | ||||
-rw-r--r-- | hicn-light/src/hicn/core/fib.c | 2 | ||||
-rw-r--r-- | hicn-light/src/hicn/core/msgbuf.h | 1 | ||||
-rw-r--r-- | hicn-light/src/hicn/io/udp.c | 9 | ||||
-rw-r--r-- | lib/includes/hicn/util/ip_address.h | 2 | ||||
-rw-r--r-- | lib/src/face.c | 6 | ||||
-rw-r--r-- | lib/src/util/ip_address.c | 6 |
17 files changed, 54 insertions, 129 deletions
diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index ad7f99785..000000000 --- a/Dockerfile +++ /dev/null @@ -1,33 +0,0 @@ -FROM ubuntu:focal -ENV DEBIAN_FRONTEND=noninteractive -WORKDIR /hicn-build - -ARG USERNAME=ubuntu -ARG USER_UID=1000 -ARG USER_GID=${USER_UID} - -COPY Makefile versions.cmake ./ -COPY scripts scripts/ - -USER root - -RUN apt update && apt-get install -y \ - make \ - sudo \ - curl \ - valgrind \ - git \ - zsh - -RUN make deps debug-tools - -# Add non-root user -RUN groupadd --gid ${USER_GID} ${USERNAME} && \ - useradd -s /bin/bash --uid ${USER_UID} --gid ${USER_GID} -m ${USERNAME} && \ - echo ${USERNAME} ALL=\(root\) NOPASSWD:ALL >/etc/sudoers.d/${USERNAME} && \ - chmod 0440 /etc/sudoers.d/${USERNAME} - -USER ${USERNAME} -WORKDIR /home/${USERNAME} - -ENV DEBIAN_FRONTEND= diff --git a/ctrl/libhicnctrl/src/api_private.h b/ctrl/libhicnctrl/src/api_private.h index 53be809da..2f483ad2d 100644 --- a/ctrl/libhicnctrl/src/api_private.h +++ b/ctrl/libhicnctrl/src/api_private.h @@ -75,16 +75,4 @@ typedef struct hc_sock_impl_s hc_sock_impl_t; int hc_data_ensure_available(hc_data_t *data, size_t count); u8 *hc_data_get_next(hc_data_t *data); -int hc_listener_to_face(const hc_listener_t *listener, hc_face_t *face); - -int hc_connection_to_face(const hc_connection_t *connection, hc_face_t *face); - -int hc_face_to_listener(const hc_face_t *face, hc_listener_t *listener); - -int hc_connection_to_local_listener(const hc_connection_t *connection, - hc_listener_t *listener); - -int hc_face_to_connection(const hc_face_t *face, hc_connection_t *connection, - bool generate_name); - #endif // HICN_API_PRIVATE_H diff --git a/ctrl/libhicnctrl/src/commands/command_listener.c b/ctrl/libhicnctrl/src/commands/command_listener.c index bba4f4541..c11742bba 100644 --- a/ctrl/libhicnctrl/src/commands/command_listener.c +++ b/ctrl/libhicnctrl/src/commands/command_listener.c @@ -68,8 +68,13 @@ int on_listener_create(hc_listener_t* listener) { case FACE_TYPE_HICN: listener->type = FACE_TYPE_HICN_LISTENER; break; - default: + case FACE_TYPE_UDP_LISTENER: + case FACE_TYPE_TCP_LISTENER: + case FACE_TYPE_HICN_LISTENER: break; + case FACE_TYPE_UNDEFINED: + case FACE_TYPE_N: + return -1; } return 0; } diff --git a/ctrl/libhicnctrl/src/modules/hicn_light.c b/ctrl/libhicnctrl/src/modules/hicn_light.c index 379cd2fa9..9c6722975 100644 --- a/ctrl/libhicnctrl/src/modules/hicn_light.c +++ b/ctrl/libhicnctrl/src/modules/hicn_light.c @@ -919,9 +919,8 @@ NEXT: if (hc_connection_to_local_listener(&object->connection, &listener.listener) < 0) { ERROR( - "[hicnlight_prepare_connection_create] Could not convert face " - "to " - "local listener."); + "[hicnlight_prepare_connection_create] Could not " + "convert connection to local listener."); return -1; } hc_request_set_state(current_request, diff --git a/ctrl/libhicnctrl/src/modules/hicn_light/connection.c b/ctrl/libhicnctrl/src/modules/hicn_light/connection.c index c7d06415e..2b3644939 100644 --- a/ctrl/libhicnctrl/src/modules/hicn_light/connection.c +++ b/ctrl/libhicnctrl/src/modules/hicn_light/connection.c @@ -95,22 +95,22 @@ static int hicnlight_connection_parse(const uint8_t *buffer, size_t size, } if (!IS_VALID_ADDRESS(item->local_address)) { - ERROR("[hc_connection_parse] Invalid address received"); + ERROR("[hc_connection_parse] Invalid local address received"); return -1; } if (!IS_VALID_PORT(ntohs(item->local_port))) { - ERROR("[hc_connection_parse] Invalid port received"); + ERROR("[hc_connection_parse] Invalid local port received"); return -1; } if (!IS_VALID_ADDRESS(item->remote_address)) { - ERROR("[hc_connection_parse] Invalid address received"); + ERROR("[hc_connection_parse] Invalid remote address received"); return -1; } if (!IS_VALID_PORT(ntohs(item->remote_port))) { - ERROR("[hc_connection_parse] Invalid port received"); + ERROR("[hc_connection_parse] Invalid remote port received"); return -1; } diff --git a/ctrl/libhicnctrl/src/modules/hicn_light/face.c b/ctrl/libhicnctrl/src/modules/hicn_light/face.c index 46adf633d..4dcd96191 100644 --- a/ctrl/libhicnctrl/src/modules/hicn_light/face.c +++ b/ctrl/libhicnctrl/src/modules/hicn_light/face.c @@ -161,15 +161,5 @@ int hc_face_to_connection(const hc_face_t *face, hc_connection_t *connection, } int hc_face_to_listener(const hc_face_t *face, hc_listener_t *listener) { - switch (face->type) { - case FACE_TYPE_HICN_LISTENER: - break; - case FACE_TYPE_TCP_LISTENER: - break; - case FACE_TYPE_UDP_LISTENER: - break; - default: - return -1; - } - return -1; /* XXX Not implemented */ + return -99; /* XXX Not implemented */ } diff --git a/ctrl/libhicnctrl/src/modules/hicn_light/face.h b/ctrl/libhicnctrl/src/modules/hicn_light/face.h index 9e1cd48c2..6f202b4ce 100644 --- a/ctrl/libhicnctrl/src/modules/hicn_light/face.h +++ b/ctrl/libhicnctrl/src/modules/hicn_light/face.h @@ -4,6 +4,8 @@ #include <hicn/ctrl/objects/connection.h> #include <hicn/ctrl/objects/face.h> +int hc_connection_to_face(const hc_connection_t *connection, hc_face_t *face); + int hc_face_from_connection(const hc_connection_t *connection, hc_face_t *face); int hc_face_to_connection(const hc_face_t *face, hc_connection_t *connection, diff --git a/ctrl/libhicnctrl/src/objects/subscription.c b/ctrl/libhicnctrl/src/objects/subscription.c index 087e42ffb..8db55660d 100644 --- a/ctrl/libhicnctrl/src/objects/subscription.c +++ b/ctrl/libhicnctrl/src/objects/subscription.c @@ -55,7 +55,7 @@ int _hc_subscription_cmp(const hc_object_t *object1, /* /!\ Please update constants in header file upon changes */ int hc_subscription_snprintf(char *s, size_t size, const hc_subscription_t *subscription) { - return -1; + return -99; /* Not implemented */ } int _hc_subscription_snprintf(char *s, size_t size, const hc_object_t *object) { diff --git a/hicn-light/src/hicn/cli/hicnc.c b/hicn-light/src/hicn/cli/hicnc.c index b4a6e8191..ed8d4ed97 100644 --- a/hicn-light/src/hicn/cli/hicnc.c +++ b/hicn-light/src/hicn/cli/hicnc.c @@ -60,55 +60,6 @@ void signal_handler(int sig) { stop = true; } -#if 0 -int hc_active_interface_snprintf(char *buf, size_t size, - hc_event_active_interface_update_t *event) { - int rc; - char *pos = buf; - - rc = ip_prefix_snprintf(pos, size, &event->prefix); - if ((rc < 0) || (rc >= size)) return rc; - pos += rc; - size -= rc; - - for (netdevice_type_t type = NETDEVICE_TYPE_UNDEFINED + 1; - type < NETDEVICE_TYPE_N; type++) { - if (!netdevice_flags_has(event->interface_type, type)) continue; - rc = snprintf(pos, size, " %s", netdevice_type_str(type)); - if ((rc < 0) || (rc >= size)) return pos - buf + rc; - - pos += rc; - size -= rc; - } - return pos - buf; -} - -// XXX hc_object_snprintf -void hc_subscription_display(command_type_t command_type, - const uint8_t *buffer) { - char buf[65535]; - - switch (command_type) { - case COMMAND_TYPE_CONNECTION_ADD: - case COMMAND_TYPE_CONNECTION_REMOVE: - case COMMAND_TYPE_CONNECTION_UPDATE: - hc_connection_snprintf(buf, sizeof(buf), (hc_connection_t *)buffer); - break; - case COMMAND_TYPE_ACTIVE_INTERFACE_UPDATE: - hc_active_interface_snprintf( - buf, sizeof(buf), (hc_event_active_interface_update_t *)buffer); - break; - case COMMAND_TYPE_ROUTE_LIST: - hc_route_snprintf(buf, sizeof(buf), (hc_route_t *)buffer); - break; - default: - INFO("Unknown event received"); - return; - } - INFO("%s %s", command_type_str(command_type), buf); -} -#endif - int main(int argc, char *const *argv) { log_conf.log_level = LOG_INFO; @@ -126,10 +77,13 @@ int main(int argc, char *const *argv) { // getopt_long stores the option index here. int optind = 0; - int c = getopt_long(argc, argv, "hS:P:", longFormOptions, &optind); + int c = getopt_long(argc, argv, "dhS:P:", longFormOptions, &optind); if (c == -1) break; switch (c) { + case 'd': + log_conf.log_level = LOG_DEBUG; + break; case 'S': server_ip = optarg; break; diff --git a/hicn-light/src/hicn/config/commands.c b/hicn-light/src/hicn/config/commands.c index e1d25367f..c6212aaf4 100644 --- a/hicn-light/src/hicn/config/commands.c +++ b/hicn-light/src/hicn/config/commands.c @@ -147,7 +147,9 @@ uint8_t *configuration_on_listener_add(forwarder_t *forwarder, uint8_t *packet, case FACE_TYPE_TCP_LISTENER: case FACE_TYPE_HICN_LISTENER: break; - default: + case FACE_TYPE_UDP: + case FACE_TYPE_TCP: + case FACE_TYPE_HICN: ERROR("Wrong listener type"); goto NACK; } @@ -388,7 +390,11 @@ uint8_t *configuration_on_connection_add(forwarder_t *forwarder, case FACE_TYPE_TCP: case FACE_TYPE_HICN: break; - default: + case FACE_TYPE_UDP_LISTENER: + case FACE_TYPE_TCP_LISTENER: + case FACE_TYPE_HICN_LISTENER: + case FACE_TYPE_UNDEFINED: + case FACE_TYPE_N: goto NACK; } @@ -1650,6 +1656,7 @@ void commands_notify_route(const forwarder_t *forwarder, fill_route_command(entry, &msg->payload); commands_notify(forwarder, TOPIC_ROUTE, (uint8_t *)&msg, sizeof(msg)); + free(msg); } void commands_notify_active_interface_update(const forwarder_t *forwarder, diff --git a/hicn-light/src/hicn/core/connection.c b/hicn-light/src/hicn/core/connection.c index 69edc7265..40802368f 100644 --- a/hicn-light/src/hicn/core/connection.c +++ b/hicn-light/src/hicn/core/connection.c @@ -37,7 +37,8 @@ connection_t *connection_create(face_type_t type, const char *name, assert(pair); assert(forwarder); - face_type_t listener_type; + /* initialized so that gcc-9 does not complain */ + face_type_t listener_type = FACE_TYPE_UNDEFINED; switch (type) { case FACE_TYPE_UDP: listener_type = FACE_TYPE_UDP_LISTENER; @@ -45,7 +46,13 @@ connection_t *connection_create(face_type_t type, const char *name, case FACE_TYPE_TCP: listener_type = FACE_TYPE_TCP_LISTENER; break; - default: + case FACE_TYPE_HICN: + return NULL; /* Not implemented */ + case FACE_TYPE_HICN_LISTENER: + case FACE_TYPE_UDP_LISTENER: + case FACE_TYPE_TCP_LISTENER: + case FACE_TYPE_UNDEFINED: + case FACE_TYPE_N: return NULL; } diff --git a/hicn-light/src/hicn/core/fib.c b/hicn-light/src/hicn/core/fib.c index b3b5d4036..2e8492457 100644 --- a/hicn-light/src/hicn/core/fib.c +++ b/hicn-light/src/hicn/core/fib.c @@ -360,7 +360,7 @@ END: #if 0 fib_dump(fib); #endif - ; /* required for clang */ + ; /* required by clang */ } /* diff --git a/hicn-light/src/hicn/core/msgbuf.h b/hicn-light/src/hicn/core/msgbuf.h index 26fd47540..ee9337225 100644 --- a/hicn-light/src/hicn/core/msgbuf.h +++ b/hicn-light/src/hicn/core/msgbuf.h @@ -76,6 +76,7 @@ static inline const hicn_name_t *msgbuf_get_name(const msgbuf_t *msgbuf) { } #define msgbuf_get_connection_id(M) ((M)->connection_id) +#define msgbuf_set_connection_id(M, ID) (M)->connection_id = (ID) #define msgbuf_get_packet(M) ((M)->packet) #define msgbuf_get_command_type(M) ((M)->command.type) #if WITH_WLDR diff --git a/hicn-light/src/hicn/io/udp.c b/hicn-light/src/hicn/io/udp.c index d704a64f1..d881b4b01 100644 --- a/hicn-light/src/hicn/io/udp.c +++ b/hicn-light/src/hicn/io/udp.c @@ -261,15 +261,10 @@ DECLARE_LISTENER(udp); #define RING_LEN 5 * MAX_MSG typedef struct { - /* - * Ring buffer - * - * This is sized to more than a batch to cope with transient failures of - * sendmmsg. - */ +#ifdef __linux__ + /* Ring buffer */ off_t *ring; -#ifdef __linux__ struct mmsghdr msghdr[MAX_MSG]; struct iovec iovecs[MAX_MSG]; #endif /* __linux__ */ diff --git a/lib/includes/hicn/util/ip_address.h b/lib/includes/hicn/util/ip_address.h index 55d5f5fc3..979efaa40 100644 --- a/lib/includes/hicn/util/ip_address.h +++ b/lib/includes/hicn/util/ip_address.h @@ -189,6 +189,8 @@ bool hicn_ip_address_match_family (const hicn_ip_address_t *address, uint32_t hicn_ip_address_get_hash (const hicn_ip_address_t *address); +void hicn_ip_address_clear (hicn_ip_address_t *address); + /* Prefix */ int hicn_ip_prefix_pton (const char *ip_address_str, diff --git a/lib/src/face.c b/lib/src/face.c index 832cd0936..81395c4b1 100644 --- a/lib/src/face.c +++ b/lib/src/face.c @@ -447,7 +447,9 @@ get_protocol (face_type_t face_type) case FACE_TYPE_UDP_LISTENER: return FACE_PROTOCOL_UDP; - default: - return FACE_PROTOCOL_UNKNOWN; + case FACE_TYPE_UNDEFINED: + case FACE_TYPE_N: + break; } + return FACE_PROTOCOL_UNKNOWN; } diff --git a/lib/src/util/ip_address.c b/lib/src/util/ip_address.c index 3624a6fca..b50864c96 100644 --- a/lib/src/util/ip_address.c +++ b/lib/src/util/ip_address.c @@ -241,6 +241,12 @@ hicn_ip_address_empty (const hicn_ip_address_t *ip) return (memcmp (ip, &IP_ADDRESS_EMPTY, sizeof (hicn_ip_address_t)) == 0); } +void +hicn_ip_address_clear (hicn_ip_address_t *address) +{ + memset (address, 0, sizeof (hicn_ip_address_t)); +} + /* Prefix */ /* Parse IP Prefixes in presentation format (in bits, separated by a slash) */ |