From a61398ad90acdfa4ea0ac03f3d2b9bcbfd7a6dd3 Mon Sep 17 00:00:00 2001 From: Jordan Augé Date: Fri, 30 Sep 2022 12:29:05 +0200 Subject: refactor(hicn-light): cleanup and optimizations to UDP socket face MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ticket: HICN-771 Change-Id: Ie84dc2f61888c3fdd7b3728b2a13cacbac503d1a Signed-off-by: Jordan Augé --- ctrl/libhicnctrl/src/api_private.h | 12 ------------ ctrl/libhicnctrl/src/commands/command_listener.c | 7 ++++++- ctrl/libhicnctrl/src/modules/hicn_light.c | 5 ++--- ctrl/libhicnctrl/src/modules/hicn_light/connection.c | 8 ++++---- ctrl/libhicnctrl/src/modules/hicn_light/face.c | 12 +----------- ctrl/libhicnctrl/src/modules/hicn_light/face.h | 2 ++ ctrl/libhicnctrl/src/objects/subscription.c | 2 +- 7 files changed, 16 insertions(+), 32 deletions(-) (limited to 'ctrl') 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 #include +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) { -- cgit 1.2.3-korg