aboutsummaryrefslogtreecommitdiffstats
path: root/ctrl/libhicnctrl
diff options
context:
space:
mode:
authorJordan Augé <jordan.auge+fdio@cisco.com>2019-11-27 09:05:39 +0100
committerJordan Augé <jordan.auge+fdio@cisco.com>2019-12-05 00:32:28 +0100
commit94350c13fe983a7cfb99dafecb0d029ed58361bf (patch)
treeed82fbed47a3ec2b9855e93402b3f75f3f403b57 /ctrl/libhicnctrl
parentdafa145fb5a4a10c1e600ee72fe639ac4f7e718d (diff)
[HICN-420] MAP-Me code refactoring & face manager changes in support of mobility
Change-Id: Ifde50b4c161d1bda1326f18b705f575e539aea71 Signed-off-by: Jordan Augé <jordan.auge+fdio@cisco.com>
Diffstat (limited to 'ctrl/libhicnctrl')
-rw-r--r--ctrl/libhicnctrl/includes/hicn/ctrl/api.h2
-rw-r--r--ctrl/libhicnctrl/includes/hicn/ctrl/commands.h8
-rw-r--r--ctrl/libhicnctrl/src/api.c57
3 files changed, 67 insertions, 0 deletions
diff --git a/ctrl/libhicnctrl/includes/hicn/ctrl/api.h b/ctrl/libhicnctrl/includes/hicn/ctrl/api.h
index 068b3eb08..65633c249 100644
--- a/ctrl/libhicnctrl/includes/hicn/ctrl/api.h
+++ b/ctrl/libhicnctrl/includes/hicn/ctrl/api.h
@@ -527,6 +527,7 @@ int hc_connection_parse(void *in, hc_connection_t *connection);
int hc_connection_set_admin_state(hc_sock_t * s, const char * conn_id_or_name, face_state_t state);
#ifdef WITH_POLICY
int hc_connection_set_priority(hc_sock_t * s, const char * conn_id_or_name, uint32_t priority);
+int hc_connection_set_tags(hc_sock_t * s, const char * conn_id_or_name, policy_tags_t tags);
#endif /* WITH_POLICY */
#define foreach_connection(VAR, data) foreach_type(hc_connection_t, VAR, data)
@@ -575,6 +576,7 @@ int hc_face_list_async(hc_sock_t *s); //, hc_data_t ** pdata);
int hc_face_set_admin_state(hc_sock_t * s, const char * conn_id_or_name, face_state_t state);
#ifdef WITH_POLICY
int hc_face_set_priority(hc_sock_t * s, const char * conn_id_or_name, uint32_t priority);
+int hc_face_set_tags(hc_sock_t * s, const char * conn_id_or_name, policy_tags_t tags);
#endif /* WITH_POLICY */
#define foreach_face(VAR, data) foreach_type(hc_face_t, VAR, data)
diff --git a/ctrl/libhicnctrl/includes/hicn/ctrl/commands.h b/ctrl/libhicnctrl/includes/hicn/ctrl/commands.h
index c250216f0..bb566e688 100644
--- a/ctrl/libhicnctrl/includes/hicn/ctrl/commands.h
+++ b/ctrl/libhicnctrl/includes/hicn/ctrl/commands.h
@@ -76,6 +76,7 @@ typedef enum {
REMOVE_POLICY,
UPDATE_CONNECTION,
CONNECTION_SET_PRIORITY,
+ CONNECTION_SET_TAGS,
#endif /* WITH_POLICY */
LAST_COMMAND_VALUE
} command_id;
@@ -345,6 +346,11 @@ typedef struct {
uint32_t priority;
} connection_set_priority_command;
+typedef struct {
+ char symbolicOrConnid[SYMBOLIC_NAME_LEN];
+ policy_tags_t tags;
+} connection_set_tags_command;
+
#endif /* WITH_POLICY */
//===== size of commands ======
@@ -403,6 +409,8 @@ static inline int payloadLengthDaemon(command_id id) {
return sizeof(update_connection_command);
case CONNECTION_SET_PRIORITY:
return sizeof(connection_set_priority_command);
+ case CONNECTION_SET_TAGS:
+ return sizeof(connection_set_tags_command);
#endif /* WITH_POLICY */
case LAST_COMMAND_VALUE:
return 0;
diff --git a/ctrl/libhicnctrl/src/api.c b/ctrl/libhicnctrl/src/api.c
index f7efd6b44..8a81c6c5f 100644
--- a/ctrl/libhicnctrl/src/api.c
+++ b/ctrl/libhicnctrl/src/api.c
@@ -1711,6 +1711,56 @@ hc_connection_set_priority_async(hc_sock_t * s, const char * conn_id_or_name,
return _hc_connection_set_priority(s, conn_id_or_name, priority, true);
}
+int
+_hc_connection_set_tags(hc_sock_t * s, const char * conn_id_or_name,
+ policy_tags_t tags, bool async)
+{
+ int rc;
+ DEBUG("[hc_connection_set_tags] connection_id/name=%s tags=%d async=%s",
+ conn_id_or_name, tags, BOOLSTR(async));
+ struct {
+ header_control_message hdr;
+ connection_set_tags_command payload;
+ } msg = {
+ .hdr = {
+ .messageType = REQUEST_LIGHT,
+ .commandID = CONNECTION_SET_TAGS,
+ .length = 1,
+ .seqNum = 0,
+ },
+ .payload = {
+ .tags = tags,
+ },
+ };
+ rc = snprintf(msg.payload.symbolicOrConnid, SYMBOLIC_NAME_LEN, "%s", conn_id_or_name);
+ if (rc >= SYMBOLIC_NAME_LEN)
+ WARN("[_hc_connection_set_tags] Unexpected truncation of symbolic name string");
+
+ hc_command_params_t params = {
+ .cmd = ACTION_SET,
+ .cmd_id = CONNECTION_SET_TAGS,
+ .size_in = sizeof(connection_set_tags_command),
+ .size_out = 0,
+ .parse = NULL,
+ };
+
+ return hc_execute_command(s, (hc_msg_t*)&msg, sizeof(msg), &params, NULL, async);
+}
+
+int
+hc_connection_set_tags(hc_sock_t * s, const char * conn_id_or_name,
+ policy_tags_t tags)
+{
+ return _hc_connection_set_tags(s, conn_id_or_name, tags, false);
+}
+
+int
+hc_connection_set_tags_async(hc_sock_t * s, const char * conn_id_or_name,
+ policy_tags_t tags)
+{
+ return _hc_connection_set_tags(s, conn_id_or_name, tags, true);
+}
+
/*----------------------------------------------------------------------------*
* Routes
*----------------------------------------------------------------------------*/
@@ -2559,6 +2609,13 @@ hc_face_set_priority(hc_sock_t * s, const char * conn_id_or_name,
return hc_connection_set_priority(s, conn_id_or_name, priority);
}
+int
+hc_face_set_tags(hc_sock_t * s, const char * conn_id_or_name,
+ policy_tags_t tags)
+{
+ return hc_connection_set_tags(s, conn_id_or_name, tags);
+}
+
/*----------------------------------------------------------------------------*
* Punting
*----------------------------------------------------------------------------*/