aboutsummaryrefslogtreecommitdiffstats
path: root/ctrl/libhicnctrl/src/modules/hicn_light/strategy.c
diff options
context:
space:
mode:
authorJordan Augé <jordan.auge+fdio@cisco.com>2022-10-05 17:46:32 +0200
committerJordan Augé <jordan.auge+fdio@cisco.com>2022-10-05 18:04:08 +0200
commit7b75353ecccaeb6b8dd79f46593adb0551182a96 (patch)
tree34d2ff2bce7af28d5b5bfa5b241c26e48ca92d03 /ctrl/libhicnctrl/src/modules/hicn_light/strategy.c
parent3476dd9ddecc87d9212c3bf56a5be52079e27def (diff)
refactor(libhicnctrl): strategy/set missing in VFT
Change-Id: I19a8dd89a1f03127d414d1c086848079ff10d0df Ticket: HICN-803 Signed-off-by: Jordan Augé <jordan.auge+fdio@cisco.com>
Diffstat (limited to 'ctrl/libhicnctrl/src/modules/hicn_light/strategy.c')
-rw-r--r--ctrl/libhicnctrl/src/modules/hicn_light/strategy.c107
1 files changed, 20 insertions, 87 deletions
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[] = {