From a070b0de9f9e9cbca150eea4eda74757ca588bed Mon Sep 17 00:00:00 2001 From: Jordan Augé Date: Wed, 23 Sep 2020 17:50:52 +0200 Subject: [HICN-645] Control plane (WIP) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I4be6a40b690b62f22f57de6d8c10b01a1be42a6d Signed-off-by: Jordan Augé Signed-off-by: Enrico Loparco (eloparco) Signed-off-by: Mauro Sardara --- ctrl/libhicnctrl/src/api.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'ctrl/libhicnctrl/src/api.c') diff --git a/ctrl/libhicnctrl/src/api.c b/ctrl/libhicnctrl/src/api.c index 84f34d3c2..080b6541a 100644 --- a/ctrl/libhicnctrl/src/api.c +++ b/ctrl/libhicnctrl/src/api.c @@ -3115,3 +3115,46 @@ hc_policy_snprintf(char * s, size_t size, hc_policy_t * policy) } #endif /* WITH_POLICY */ + +const char * action_str[] = { +#define _(x) [ACTION_ ## x] = #x, + foreach_action +#undef _ +}; + +hc_action_t +action_from_str(const char * action_str) +{ +#define _(x) \ + if (strcasecmp(action_str, # x) == 0) \ + return ACTION_ ## x; \ + else + foreach_action +#undef _ + if (strcasecmp(action_str, "add") == 0) + return ACTION_CREATE; + else + if (strcasecmp(action_str, "remove") == 0) + return ACTION_DELETE; + else + return ACTION_UNDEFINED; +} + +const char * object_str[] = { +#define _(x) [OBJECT_ ## x] = #x, + foreach_object +#undef _ +}; + +hc_object_type_t +object_from_str(const char * object_str) +{ +#define _(x) \ + if (strcasecmp(object_str, # x) == 0) \ + return OBJECT_ ## x; \ + else + foreach_object +#undef _ + return OBJECT_UNDEFINED; +} + -- cgit 1.2.3-korg