diff options
Diffstat (limited to 'ctrl')
-rw-r--r-- | ctrl/libhicnctrl/src/module.h | 6 | ||||
-rw-r--r-- | ctrl/libhicnctrl/src/modules/hicn_light/connection.c | 5 | ||||
-rw-r--r-- | ctrl/libhicnctrl/src/modules/hicn_light/listener.c | 5 | ||||
-rw-r--r-- | ctrl/libhicnctrl/src/modules/hicn_light/route.c | 4 | ||||
-rw-r--r-- | ctrl/libhicnctrl/src/modules/hicn_light/stats.c | 9 | ||||
-rw-r--r-- | ctrl/libhicnctrl/src/modules/hicn_light/strategy.c | 107 | ||||
-rw-r--r-- | ctrl/libhicnctrl/src/modules/hicn_light/subscription.c | 5 | ||||
-rw-r--r-- | ctrl/libhicnctrl/src/modules/hicn_plugin/listener.c | 5 | ||||
-rw-r--r-- | ctrl/libhicnctrl/src/modules/hicn_plugin/route.c | 5 | ||||
-rw-r--r-- | ctrl/libhicnctrl/src/objects/listener.c | 6 |
10 files changed, 68 insertions, 89 deletions
diff --git a/ctrl/libhicnctrl/src/module.h b/ctrl/libhicnctrl/src/module.h index 44ba5ddbb..c06f3ce86 100644 --- a/ctrl/libhicnctrl/src/module.h +++ b/ctrl/libhicnctrl/src/module.h @@ -53,11 +53,13 @@ typedef struct { [ACTION_CREATE] = NULL, \ [ACTION_DELETE] = NULL, \ [ACTION_LIST] = NULL, \ + [ACTION_SET] = NULL, \ }, \ .serialize = { \ [ACTION_CREATE] = PREFIX##_##NAME##_serialize_create, \ [ACTION_DELETE] = PREFIX##_##NAME##_serialize_delete, \ [ACTION_LIST] = PREFIX##_##NAME##_serialize_list, \ + [ACTION_SET] = PREFIX##_##NAME##_serialize_set, \ } \ } @@ -70,11 +72,13 @@ typedef struct { [ACTION_CREATE] = NULL, \ [ACTION_DELETE] = NULL, \ [ACTION_LIST] = NULL, \ + [ACTION_SET] = NULL, \ }, \ .serialize = { \ [ACTION_CREATE] = PREFIX##_##NAME##_serialize_create, \ [ACTION_DELETE] = PREFIX##_##NAME##_serialize_delete, \ [ACTION_LIST] = PREFIX##_##NAME##_serialize_list, \ + [ACTION_SET] = PREFIX##_##NAME##_serialize_set, \ }}; #define DECLARE_VPP_MODULE_OBJECT_OPS(PREFIX, NAME) \ @@ -84,12 +88,14 @@ typedef struct { [ACTION_CREATE] = PREFIX##_##NAME##_create, \ [ACTION_DELETE] = PREFIX##_##NAME##_delete, \ [ACTION_LIST] = PREFIX##_##NAME##_list, \ + [ACTION_SET] = PREFIX##_##NAME##_set, \ }, \ .serialize = \ { \ [ACTION_CREATE] = NULL, \ [ACTION_DELETE] = NULL, \ [ACTION_LIST] = NULL, \ + [ACTION_SET] = NULL, \ }, \ }; diff --git a/ctrl/libhicnctrl/src/modules/hicn_light/connection.c b/ctrl/libhicnctrl/src/modules/hicn_light/connection.c index c7d06415e..83f7a2e27 100644 --- a/ctrl/libhicnctrl/src/modules/hicn_light/connection.c +++ b/ctrl/libhicnctrl/src/modules/hicn_light/connection.c @@ -495,4 +495,9 @@ int hicnlight_connection_serialize_list(const hc_object_t *object, return sizeof(msg_header_t); // Do not use msg_connection_list_t } +int hicnlight_connection_serialize_set(const hc_object_t *object, + uint8_t *packet) { + return -1; +} + DECLARE_MODULE_OBJECT_OPS(hicnlight, connection); diff --git a/ctrl/libhicnctrl/src/modules/hicn_light/listener.c b/ctrl/libhicnctrl/src/modules/hicn_light/listener.c index 68d4b8fcd..46fded2ca 100644 --- a/ctrl/libhicnctrl/src/modules/hicn_light/listener.c +++ b/ctrl/libhicnctrl/src/modules/hicn_light/listener.c @@ -173,4 +173,9 @@ int hicnlight_listener_serialize_list(const hc_object_t *object, return sizeof(msg_header_t); // Do not use msg_listener_list_t } +int hicnlight_listener_serialize_set(const hc_object_t *object, + uint8_t *packet) { + return -1; +} + DECLARE_MODULE_OBJECT_OPS(hicnlight, listener); diff --git a/ctrl/libhicnctrl/src/modules/hicn_light/route.c b/ctrl/libhicnctrl/src/modules/hicn_light/route.c index 22cf6fbc5..38510704c 100644 --- a/ctrl/libhicnctrl/src/modules/hicn_light/route.c +++ b/ctrl/libhicnctrl/src/modules/hicn_light/route.c @@ -170,4 +170,8 @@ int hicnlight_route_serialize_list(const hc_object_t *object, uint8_t *packet) { return sizeof(msg_header_t); // Do not use msg_route_list_t } +int hicnlight_route_serialize_set(const hc_object_t *object, uint8_t *packet) { + return -1; +} + DECLARE_MODULE_OBJECT_OPS(hicnlight, route); diff --git a/ctrl/libhicnctrl/src/modules/hicn_light/stats.c b/ctrl/libhicnctrl/src/modules/hicn_light/stats.c index 81c506770..a60190a13 100644 --- a/ctrl/libhicnctrl/src/modules/hicn_light/stats.c +++ b/ctrl/libhicnctrl/src/modules/hicn_light/stats.c @@ -60,6 +60,10 @@ int hicnlight_stats_serialize_list(const hc_object_t *object, uint8_t *packet) { return sizeof(msg_header_t); // Do not use msg_stats_list_t } +int hicnlight_stats_serialize_set(const hc_object_t *object, uint8_t *packet) { + return -1; +} + DECLARE_MODULE_OBJECT_OPS(hicnlight, stats); /* PER-FACE STATS */ @@ -101,4 +105,9 @@ int hicnlight_face_stats_serialize_list(const hc_object_t *object, return sizeof(msg_header_t); // Do not use msg_stats_list_t } +int hicnlight_face_stats_serialize_set(const hc_object_t *object, + uint8_t *packet) { + return -1; +} + DECLARE_MODULE_OBJECT_OPS(hicnlight, face_stats); diff --git a/ctrl/libhicnctrl/src/modules/hicn_light/strategy.c b/ctrl/libhicnctrl/src/modules/hicn_light/strategy.c index 35e241f3e..16ce2d047 100644 --- a/ctrl/libhicnctrl/src/modules/hicn_light/strategy.c +++ b/ctrl/libhicnctrl/src/modules/hicn_light/strategy.c @@ -28,62 +28,28 @@ int hicnlight_strategy_serialize_list(const hc_object_t *object, assert(!object); return -1; } -#if 0 -// per prefix -static hc_result_t *_strategy_set_serialize(hc_sock_t *socket, - hc_strategy_t *strategy) { - return -1; - hc_result_t *res = malloc(sizeof(*res)); - char strategy_s[MAXSZ_HC_STRATEGY]; - strncpy(strategy->name, strategy_str(strategy->type), - MAXSZ_STRATEGY_NAME - 1); - - int rc = hc_strategy_snprintf(strategy_s, MAXSZ_HC_STRATEGY, strategy); - if (rc >= MAXSZ_HC_STRATEGY) - WARN("[hicnlight_strategy_create] Unexpected truncation of strategy string"); - DEBUG("[hicnlight_strategy_create] strategy=%s", strategy_s); - - if (!IS_VALID_FAMILY(strategy->family) || - !IS_VALID_STRATEGY_TYPE(strategy->type)) { - res->success = false; - return res; - } - - msg_strategy_set_t msg = {.header = - { - .message_type = REQUEST_LIGHT, - .command_id = COMMAND_TYPE_STRATEGY_SET, - .length = 1, - .seq_num = 0, - }, - .payload = { - .address = strategy->address, - .family = strategy->family, - .len = strategy->len, - .type = strategy->type, - }}; - - hc_command_params_t params = { - .cmd = ACTION_SET, - .cmd_id = COMMAND_TYPE_STRATEGY_SET, - .size_in = sizeof(cmd_strategy_set_t), - .size_out = 0, - .parse = NULL, - }; - *res = (hc_result_t){ - .msg = - (hc_msg_t){ - .header = msg.header, - .payload.strategy_set = msg.payload, - }, - .params = params, - .async = false, - .success = true, - }; - return res; +int hicnlight_strategy_serialize_set(const hc_object_t *object, + uint8_t *packet) { + const hc_strategy_t *strategy = &object->strategy; + + msg_strategy_set_t *msg = (msg_strategy_set_t *)packet; + *msg = (msg_strategy_set_t){.header = + { + .message_type = REQUEST_LIGHT, + .command_id = COMMAND_TYPE_STRATEGY_SET, + .length = 1, + .seq_num = 0, + }, + .payload = { + .address = strategy->address, + .family = strategy->family, + .len = strategy->len, + .type = strategy->type, + }}; + + return sizeof(msg_strategy_set_t); } -#endif #if 0 static hc_result_t *_strategy_add_local_prefix_serialize( @@ -143,39 +109,6 @@ static hc_result_t *_strategy_add_local_prefix_serialize( }; return res; } -#endif - -#if 0 -static int hicnlight_strategy_set(hc_sock_t *socket, hc_strategy_t *strategy) { - hc_result_t *result = _strategy_set_serialize(socket, strategy); - - int ret = INPUT_ERROR; - if (result->success) { - ret = hicnlight_execute_command(socket, (hc_msg_t *)&result->msg, - sizeof(result->msg), &result->params, NULL, - result->async); - } - - hc_result_free(result); - return ret; - return -1; // XXX added -} - -static int hicnlight_strategy_add_local_prefix(hc_sock_t *socket, - hc_strategy_t *strategy) { - hc_result_t *result = _strategy_add_local_prefix_serialize(socket, strategy); - - int ret = INPUT_ERROR; - if (result->success) { - ret = hicnlight_execute_command(socket, (hc_msg_t *)&result->msg, - sizeof(result->msg), &result->params, NULL, - result->async); - } - - hc_result_free(result); - return ret; - return -1; // XXX added -} /* How to retrieve that from the forwarder ? */ static const char *strategies[] = { diff --git a/ctrl/libhicnctrl/src/modules/hicn_light/subscription.c b/ctrl/libhicnctrl/src/modules/hicn_light/subscription.c index d00055e89..e2de09bf5 100644 --- a/ctrl/libhicnctrl/src/modules/hicn_light/subscription.c +++ b/ctrl/libhicnctrl/src/modules/hicn_light/subscription.c @@ -63,4 +63,9 @@ int hicnlight_subscription_serialize_list(const hc_object_t *object, return -1; } +int hicnlight_subscription_serialize_set(const hc_object_t *object, + uint8_t *packet) { + return -1; +} + DECLARE_MODULE_OBJECT_OPS(hicnlight, subscription); diff --git a/ctrl/libhicnctrl/src/modules/hicn_plugin/listener.c b/ctrl/libhicnctrl/src/modules/hicn_plugin/listener.c index f0aa4e884..0e9c5406d 100644 --- a/ctrl/libhicnctrl/src/modules/hicn_plugin/listener.c +++ b/ctrl/libhicnctrl/src/modules/hicn_plugin/listener.c @@ -181,4 +181,9 @@ static int vpp_listener_list(hc_sock_t *sock, hc_object_t *object, return _vpp_listener_list(sock, data); } +static int vpp_listener_set(hc_sock_t *sock, hc_object_t *object, + hc_data_t *data) { + return -1; +} + DECLARE_VPP_MODULE_OBJECT_OPS(vpp, listener); diff --git a/ctrl/libhicnctrl/src/modules/hicn_plugin/route.c b/ctrl/libhicnctrl/src/modules/hicn_plugin/route.c index 45aced9cb..e066862e2 100644 --- a/ctrl/libhicnctrl/src/modules/hicn_plugin/route.c +++ b/ctrl/libhicnctrl/src/modules/hicn_plugin/route.c @@ -538,4 +538,9 @@ static int vpp_route_list(hc_sock_t *sock, hc_object_t *object, return _vpp_route_list(sock, data); } +static int vpp_route_set(hc_sock_t *sock, hc_object_t *object, + hc_data_t *data) { + return -1; +} + DECLARE_VPP_MODULE_OBJECT_OPS(vpp, route); diff --git a/ctrl/libhicnctrl/src/objects/listener.c b/ctrl/libhicnctrl/src/objects/listener.c index 660a4931d..f7da6bd9c 100644 --- a/ctrl/libhicnctrl/src/objects/listener.c +++ b/ctrl/libhicnctrl/src/objects/listener.c @@ -135,8 +135,10 @@ int hc_listener_cmp(const hc_listener_t *l1, const hc_listener_t *l2) { rc = INT_CMP(l1->family, l2->family); if (rc != 0) return rc; - rc = strncmp(l1->interface_name, l2->interface_name, INTERFACE_LEN); - if (rc != 0) return rc; + if (!isempty(l1->interface_name) && !isempty(l2->interface_name)) { + rc = strncmp(l1->interface_name, l2->interface_name, INTERFACE_LEN); + if (rc != 0) return rc; + } rc = hicn_ip_address_cmp(&l1->local_addr, &l2->local_addr); if (rc != 0) return rc; |