aboutsummaryrefslogtreecommitdiffstats
path: root/ctrl/libhicnctrl
diff options
context:
space:
mode:
authorEnrico Loparco (eloparco) <eloparco@cisco.com>2021-03-23 14:58:34 +0100
committerMauro Sardara <msardara@cisco.com>2021-03-30 15:23:55 +0000
commita5a6ffb506aa3c2a0c7fe8fd09abf3f737984aa5 (patch)
treecfb82e9667e287b08c665d4d671b6e767490d403 /ctrl/libhicnctrl
parenta070b0de9f9e9cbca150eea4eda74757ca588bed (diff)
[HICN-645] Fix data structures to support hicn-light-daemon and hicn-light-control communication
The daemon should be able to start, receive commands from hicn-light-control and execute them. Signed-off-by: Enrico Loparco (eloparco) <eloparco@cisco.com> Change-Id: I0ca5bb3d9bdfb37ac8cfa9f671f6c162c9a394f5 Signed-off-by: Enrico Loparco (eloparco) <eloparco@cisco.com>
Diffstat (limited to 'ctrl/libhicnctrl')
-rw-r--r--ctrl/libhicnctrl/includes/hicn/ctrl/commands.h575
-rw-r--r--ctrl/libhicnctrl/src/api.c282
-rw-r--r--ctrl/libhicnctrl/src/hicn_plugin_api.c2
3 files changed, 438 insertions, 421 deletions
diff --git a/ctrl/libhicnctrl/includes/hicn/ctrl/commands.h b/ctrl/libhicnctrl/includes/hicn/ctrl/commands.h
index d8e5329b3..767ef98a3 100644
--- a/ctrl/libhicnctrl/includes/hicn/ctrl/commands.h
+++ b/ctrl/libhicnctrl/includes/hicn/ctrl/commands.h
@@ -43,47 +43,6 @@ typedef struct in6_addr ipv6_addr_t;
typedef uint32_t ipv4_addr_t;
typedef enum {
- REQUEST_LIGHT = 0xc0, // this is a command
- RESPONSE_LIGHT,
- ACK_LIGHT,
- NACK_LIGHT,
- LAST_MSG_TYPE_VALUE
-} message_type;
-
-typedef enum {
- ADD_LISTENER = 0,
- ADD_CONNECTION,
- LIST_CONNECTIONS,
- ADD_ROUTE,
- LIST_ROUTES,
- REMOVE_CONNECTION,
- REMOVE_LISTENER,
- REMOVE_ROUTE,
- CACHE_STORE,
- CACHE_SERVE,
- CACHE_CLEAR,
- SET_STRATEGY,
- SET_WLDR,
- ADD_PUNTING,
- LIST_LISTENERS,
- MAPME_ENABLE,
- MAPME_DISCOVERY,
- MAPME_TIMESCALE,
- MAPME_RETX,
- MAPME_SEND_UPDATE,
- CONNECTION_SET_ADMIN_STATE,
-#ifdef WITH_POLICY
- ADD_POLICY,
- LIST_POLICIES,
- REMOVE_POLICY,
- UPDATE_CONNECTION,
- CONNECTION_SET_PRIORITY,
- CONNECTION_SET_TAGS,
-#endif /* WITH_POLICY */
- LAST_COMMAND_VALUE
-} command_id;
-
-typedef enum {
ADDR_INET = 1,
ADDR_INET6,
ADDR_LINK,
@@ -98,58 +57,144 @@ typedef enum {
HICN_CONN
} connection_type;
-typedef enum { ACTIVATE_ON, ACTIVATE_OFF } activate_type;
+typedef struct in6_addr ipv6_addr_t;
+typedef uint32_t ipv4_addr_t;
-//========== HEADER ==========
+typedef enum {
+ MESSAGE_COMMAND_SUBTYPE_UNDEFINED,
+ REQUEST_LIGHT = 0xc0, // this is a command
+ RESPONSE_LIGHT,
+ ACK_LIGHT,
+ NACK_LIGHT,
+ MESSAGE_COMMAND_SUBTYPE_N
+} message_command_subtype_t;
+
+#define message_type_is_valid(message_type) \
+ ((message_type != MESSAGE_TYPE_UNDEFINED) && (message_type != MESSAGE_COMMAND_SUBTYPE_N))
+
+#define message_type_from_uchar(x) \
+ (((x) < REQUEST_LIGHT) || (((x) >= MESSAGE_COMMAND_SUBTYPE_N)) ? MESSAGE_COMMAND_SUBTYPE_N : (message_command_subtype_t)(x))
+
+#define foreach_command_type \
+ _(listener_add, LISTENER_ADD) \
+ _(listener_remove, LISTENER_REMOVE) \
+ _(listener_list, LISTENER_LIST) \
+ _(connection_add, CONNECTION_ADD) \
+ _(connection_remove, CONNECTION_REMOVE) \
+ _(connection_list, CONNECTION_LIST) \
+ _(connection_set_admin_state, CONNECTION_SET_ADMIN_STATE) \
+ _(connection_update, CONNECTION_UPDATE) \
+ _(connection_set_priority, CONNECTION_SET_PRIORITY) \
+ _(connection_set_tags, CONNECTION_SET_TAGS) \
+ _(route_add, ROUTE_ADD) \
+ _(route_remove, ROUTE_REMOVE) \
+ _(route_list, ROUTE_LIST) \
+ _(cache_set_store, CACHE_SET_STORE) \
+ _(cache_set_serve, CACHE_SET_SERVE) \
+ _(cache_clear, CACHE_CLEAR) \
+ _(strategy_set, STRATEGY_SET) \
+ _(wldr_set, WLDR_SET) \
+ _(punting_add, PUNTING_ADD) \
+ _(mapme_enable, MAPME_ENABLE) \
+ _(mapme_set_discovery, MAPME_SET_DISCOVERY) \
+ _(mapme_set_timescale, MAPME_SET_TIMESCALE) \
+ _(mapme_set_retx, MAPME_SET_RETX) \
+ _(mapme_send_update, MAPME_SEND_UPDATE) \
+ _(policy_add, POLICY_ADD) \
+ _(policy_remove, POLICY_REMOVE) \
+ _(policy_list, POLICY_LIST) \
+
+typedef enum {
+ COMMAND_TYPE_UNDEFINED,
+#define _(l, u) COMMAND_TYPE_ ## u,
+ foreach_command_type
+#undef _
+ COMMAND_TYPE_N,
+} command_type_t;
+
+#define command_type_is_valid(command_type) \
+ ((command_type != COMMAND_TYPE_UNDEFINED) && (command_type != COMMAND_TYPE_N))
+#define command_type_from_uchar(x) \
+ (((x) >= COMMAND_TYPE_N) ? COMMAND_TYPE_N : (command_type_t)(x))
+
+/* Header */
+
+/* Should be at least 8 bytes */
typedef struct {
- uint8_t messageType;
- uint8_t commandID;
- uint16_t length; // tells the number of structures in the payload
- uint32_t seqNum;
-} header_control_message;
-// for the moment has to be at least 8 bytes
+ uint8_t messageType;
+ uint8_t commandID ;
+ uint16_t length; /* Number of structures in the payload */
+ uint32_t seqNum;
+} cmd_header_t;
-// SIZE=8
+typedef struct {
+ cmd_header_t header;
+} msg_header_t;
-//========== [00] ADD LISTENER ==========
+/* Listener */
typedef enum { ETHER_MODE, IP_MODE, HICN_MODE } listener_mode;
typedef struct {
- char symbolic[SYMBOLIC_NAME_LEN];
- char interfaceName[SYMBOLIC_NAME_LEN];
- ip_address_t address;
- uint16_t port;
- // uint16_t etherType;
- uint8_t addressType;
- uint8_t listenerMode;
- uint8_t connectionType;
-} add_listener_command;
-
-// SIZE=56
-
-//========== [01] ADD CONNECTION ==========
-
-typedef struct {
- char symbolic[SYMBOLIC_NAME_LEN];
- //char interfaceName[SYMBOLIC_NAME_LEN];
- ip_address_t remoteIp;
- ip_address_t localIp;
- uint16_t remotePort;
- uint16_t localPort;
- uint8_t ipType;
- uint8_t connectionType;
- uint8_t admin_state;
+ char symbolic[SYMBOLIC_NAME_LEN];
+ char interfaceName[SYMBOLIC_NAME_LEN];
+ ip_address_t address;
+ uint16_t port;
+ // uint16_t etherType;
+ uint8_t addressType;
+ uint8_t listenerMode;
+ uint8_t connectionType;
+ uint8_t family;
+ uint8_t listenerType;
+} cmd_listener_add_t;
+
+typedef struct {
+ char symbolicOrListenerid[SYMBOLIC_NAME_LEN];
+} cmd_listener_remove_t;
+
+typedef struct {
+ ip_address_t address;
+ char listenerName[SYMBOLIC_NAME_LEN];
+ char interfaceName[SYMBOLIC_NAME_LEN];
+ uint32_t connid;
+ uint16_t port;
+ uint8_t addressType;
+ uint8_t encapType;
+} cmd_listener_list_t;
+
+typedef struct {
+ ip_address_t address;
+ char name[SYMBOLIC_NAME_LEN];
+ char interface_name[SYMBOLIC_NAME_LEN];
+ uint32_t id;
+ uint16_t port;
+ uint8_t family;
+ uint8_t type;
+} cmd_listener_list_item_t;
+
+/* Connection */
+
+typedef struct {
+ char symbolic[SYMBOLIC_NAME_LEN];
+ //char interface_name[SYMBOLIC_NAME_LEN];
+ ip_address_t remote_ip;
+ ip_address_t local_ip;
+ uint16_t remote_port;
+ uint16_t local_port;
+ uint8_t family;
+ uint8_t type;
+ uint8_t connection_type;
+ uint8_t admin_state;
#ifdef WITH_POLICY
- uint32_t priority;
- policy_tags_t tags;
+ uint32_t priority;
+ policy_tags_t tags;
#endif /* WITH_POLICY */
-} add_connection_command;
+} cmd_connection_add_t;
-// SIZE=56
-
-//========== [02] LIST CONNECTIONS ==========
+typedef struct {
+ char symbolicOrConnid[SYMBOLIC_NAME_LEN];
+} cmd_connection_remove_t;
typedef enum {
CONN_GRE,
@@ -167,268 +212,238 @@ typedef enum {
} connection_state;
typedef struct {
- add_connection_command connectionData;
+ cmd_connection_add_t connectionData;
uint32_t connid;
uint8_t state;
char interfaceName[SYMBOLIC_NAME_LEN];
char connectionName[SYMBOLIC_NAME_LEN];
-} list_connections_command;
-
-// SIZE=80
-
-//========== [03] ADD ROUTE ==========
+} cmd_connection_list_t;
typedef struct {
- char symbolicOrConnid[SYMBOLIC_NAME_LEN];
- ip_address_t address;
- uint16_t cost;
- uint8_t addressType;
- uint8_t len;
-} add_route_command;
-
-// SIZE=36
-
-//========== [04] LIST ROUTE ==========
+ char symbolic[SYMBOLIC_NAME_LEN];
+ //char interface_name[SYMBOLIC_NAME_LEN];
+ ip_address_t remote_ip;
+ ip_address_t local_ip;
+ uint16_t remote_port;
+ uint16_t local_port;
+ uint8_t family;
+ uint8_t type;
+ uint8_t admin_state;
+#ifdef WITH_POLICY
+ uint32_t priority;
+ policy_tags_t tags;
+#endif /* WITH_POLICY */
+ uint32_t id;
+ uint8_t state;
+ char interface_name[SYMBOLIC_NAME_LEN];
+ char name[SYMBOLIC_NAME_LEN];
+} cmd_connection_list_item_t;
typedef struct {
- ip_address_t address;
- uint32_t connid;
- uint16_t cost;
- uint8_t addressType;
- uint8_t len;
-} list_routes_command;
+ char symbolicOrConnid[SYMBOLIC_NAME_LEN];
+ uint8_t admin_state;
+ uint8_t pad8[3];
+} cmd_connection_set_admin_state_t;
-// SIZE=24
-
-//========== [05] REMOVE CONNECTION ==========
typedef struct {
- char symbolicOrConnid[SYMBOLIC_NAME_LEN];
-} remove_connection_command;
+ char symbolicOrConnid[SYMBOLIC_NAME_LEN];
+ uint8_t admin_state;
+ uint32_t priority;
+ policy_tags_t tags;
+} cmd_connection_update_t;
-//========== [06] REMOVE LISTENER ==========
typedef struct {
- char symbolicOrListenerid[SYMBOLIC_NAME_LEN];
-} remove_listener_command;
-
-// SIZE=16
-
-//========== [07] REMOVE ROUTE ==========
+ char symbolicOrConnid[SYMBOLIC_NAME_LEN];
+ uint32_t priority;
+} cmd_connection_set_priority_t;
typedef struct {
- char symbolicOrConnid[SYMBOLIC_NAME_LEN];
- ip_address_t address;
- uint8_t addressType;
- uint8_t len;
-} remove_route_command;
-
-// SIZE=36
+ char symbolicOrConnid[SYMBOLIC_NAME_LEN];
+ policy_tags_t tags;
+} cmd_connection_set_tags_t;
-//========== [08] CACHE STORE ==========
+/* Route */
typedef struct {
- uint8_t activate;
-} cache_store_command;
+ char symbolicOrConnid[SYMBOLIC_NAME_LEN];
+ ip_address_t address;
+ uint16_t cost;
+ uint8_t addressType;
+ uint8_t family;
+ uint8_t len;
+} cmd_route_add_t;
-// SIZE=1
-
-//========== [09] CACHE SERVE ==========
+typedef struct {
+ char symbolicOrConnid[SYMBOLIC_NAME_LEN];
+ ip_address_t address;
+ uint8_t addressType;
+ uint8_t family;
+ uint8_t len;
+} cmd_route_remove_t;
typedef struct {
- uint8_t activate;
-} cache_serve_command;
+ ip_address_t address;
+ uint32_t connid;
+ uint16_t cost;
+ uint8_t addressType;
+ uint8_t len;
+} cmd_route_list_t;
-// SIZE=1
+typedef struct {
+ ip_address_t address;
+ uint32_t connection_id;
+ uint16_t cost;
+ uint8_t family;
+ uint8_t len;
+} cmd_route_list_item_t;
-//========== [10] SET STRATEGY ==========
+/* Cache */
-typedef enum {
- SET_STRATEGY_LOADBALANCER,
- SET_STRATEGY_RANDOM,
- SET_STRATEGY_LOW_LATENCY,
- LAST_STRATEGY_VALUE
-} strategy_type;
+typedef struct {
+ uint8_t activate;
+} cmd_cache_set_store_t;
typedef struct {
- ip_address_t address;
- uint8_t strategyType;
- uint8_t addressType;
- uint8_t len;
- uint8_t related_prefixes;
- ip_address_t addresses[MAX_FWD_STRATEGY_RELATED_PREFIXES];
- uint8_t lens[MAX_FWD_STRATEGY_RELATED_PREFIXES];
- uint8_t addresses_type[MAX_FWD_STRATEGY_RELATED_PREFIXES];
-} set_strategy_command;
+ uint8_t activate;
+} cmd_cache_set_serve_t;
-// SIZE=208
+typedef struct {
+} cmd_cache_clear_t;
-//========== [11] SET WLDR ==========
+/* WLDR */
typedef struct {
- char symbolicOrConnid[SYMBOLIC_NAME_LEN];
- uint8_t activate;
-} set_wldr_command;
-
-// SIZE=17
+ char symbolicOrConnid[SYMBOLIC_NAME_LEN];
+ uint8_t activate;
+} cmd_wldr_set_t;
-//========== [12] ADD PUNTING ==========
+/* Strategy */
typedef struct {
- char symbolicOrConnid[SYMBOLIC_NAME_LEN];
- ip_address_t address;
- uint8_t addressType;
- uint8_t len;
-} add_punting_command;
+ ip_address_t address;
+ uint8_t strategy_type;
+ uint8_t address_type;
+ uint8_t family;
+ uint8_t len;
+ uint8_t related_prefixes;
+ union {
+ struct {
+ ip_address_t addresses[MAX_FWD_STRATEGY_RELATED_PREFIXES];
+ uint8_t lens[MAX_FWD_STRATEGY_RELATED_PREFIXES];
+ uint8_t families[MAX_FWD_STRATEGY_RELATED_PREFIXES];
+ } low_latency;
+ };
+} cmd_strategy_set_t;
+
+/* Punting */
-// SIZE=36
+typedef struct {
+ char symbolicOrConnid[SYMBOLIC_NAME_LEN];
+ ip_address_t address;
+ uint8_t addressType;
+ uint8_t family;
+ uint8_t len;
+} cmd_punting_add_t;
-//========== [13] LIST LISTENER ==========
+/* MAP-Me */
typedef struct {
- ip_address_t address;
- char listenerName[SYMBOLIC_NAME_LEN];
- char interfaceName[SYMBOLIC_NAME_LEN];
- uint32_t connid;
- uint16_t port;
- uint8_t addressType;
- uint8_t encapType;
-} list_listeners_command;
+ uint8_t activate;
+} cmd_mapme_activator_t;
-// SIZE=56
+typedef cmd_mapme_activator_t cmd_mapme_enable_t;
+typedef cmd_mapme_activator_t cmd_mapme_set_discovery_t;
-//========== [14] MAPME ==========
+typedef struct {
+ uint32_t timePeriod;
+} cmd_mapme_timing_t;
-// (enable/discovery/timescale/retx)
+typedef cmd_mapme_timing_t cmd_mapme_set_timescale_t;
+typedef cmd_mapme_timing_t cmd_mapme_set_retx_t;
typedef struct {
- uint8_t activate;
-} mapme_activator_command;
+ ip_address_t address;
+ uint8_t family;
+ uint8_t len;
+} cmd_mapme_send_update_t;
-// SIZE=1
+#ifdef WITH_POLICY
+/* Policy */
typedef struct {
- uint32_t timePeriod;
-} mapme_timing_command;
+ ip_address_t address;
+ uint8_t addressType;
+ uint8_t family;
+ uint8_t len;
+ policy_t policy;
+} cmd_policy_add_t;
typedef struct {
- ip_address_t address;
- uint8_t addressType;
- uint8_t len;
-} mapme_send_update_command;
+ ip_address_t address;
+ uint8_t addressType;
+ uint8_t family;
+ uint8_t len;
+} cmd_policy_remove_t;
-// SIZE=1
+typedef struct {
+ ip_address_t address;
+ uint8_t addressType;
+ uint8_t len;
+ policy_t policy;
+} cmd_policy_list_t;
typedef struct {
- char symbolicOrConnid[SYMBOLIC_NAME_LEN];
- uint8_t admin_state;
- uint8_t pad8[3];
-} connection_set_admin_state_command;
+ ip_address_t address;
+ uint8_t family;
+ uint8_t len;
+ policy_t policy;
+} cmd_policy_list_item_t;
-#ifdef WITH_POLICY
+#endif /* WITH_POLICY */
-typedef struct {
- ip_address_t address;
- uint8_t addressType;
- uint8_t len;
- policy_t policy;
-} add_policy_command;
+/* Full messages */
-typedef struct {
- ip_address_t address;
- uint8_t addressType;
- uint8_t len;
- policy_t policy;
-} list_policies_command;
+#define _(l, u) \
+typedef struct { \
+ cmd_header_t header; \
+ cmd_ ## l ## _t payload; \
+} msg_ ## l ## _t;
+ foreach_command_type
+#undef _
typedef struct {
- ip_address_t address;
- uint8_t addressType;
- uint8_t len;
-} remove_policy_command;
+ cmd_header_t header;
+ cmd_listener_list_item_t payload;
+} msg_listener_list_reply_t;
typedef struct {
- char symbolicOrConnid[SYMBOLIC_NAME_LEN];
- uint8_t admin_state;
- uint32_t priority;
- policy_tags_t tags;
-} update_connection_command;
+ cmd_header_t header;
+ cmd_connection_list_item_t payload;
+} msg_connection_list_reply_t;
typedef struct {
- char symbolicOrConnid[SYMBOLIC_NAME_LEN];
- uint32_t priority;
-} connection_set_priority_command;
+ cmd_header_t header;
+ cmd_route_list_item_t payload;
+} msg_route_list_reply_t;
typedef struct {
- char symbolicOrConnid[SYMBOLIC_NAME_LEN];
- policy_tags_t tags;
-} connection_set_tags_command;
-
-#endif /* WITH_POLICY */
+ cmd_header_t header;
+ cmd_policy_list_item_t payload;
+} msg_policy_list_reply_t;
//===== size of commands ======
// REMINDER: when a new_command is added, the following switch has to be
// updated.
-static inline int payloadLengthDaemon(command_id id) {
- switch (id) {
- case ADD_LISTENER:
- return sizeof(add_listener_command);
- case ADD_CONNECTION:
- return sizeof(add_connection_command);
- case LIST_CONNECTIONS:
- return 0; // list connections: payload always 0
- case ADD_ROUTE:
- return sizeof(add_route_command);
- case LIST_ROUTES:
- return 0; // list routes: payload always 0
- case REMOVE_CONNECTION:
- return sizeof(remove_connection_command);
- case REMOVE_LISTENER:
- return sizeof(remove_listener_command);
- case REMOVE_ROUTE:
- return sizeof(remove_route_command);
- case CACHE_STORE:
- return sizeof(cache_store_command);
- case CACHE_SERVE:
- return sizeof(cache_serve_command);
- case CACHE_CLEAR:
- return 0; // cache clear
- case SET_STRATEGY:
- return sizeof(set_strategy_command);
- case SET_WLDR:
- return sizeof(set_wldr_command);
- case ADD_PUNTING:
- return sizeof(add_punting_command);
- case LIST_LISTENERS:
- return 0; // list listeners: payload always 0
- case MAPME_ENABLE:
- return sizeof(mapme_activator_command);
- case MAPME_DISCOVERY:
- return sizeof(mapme_activator_command);
- case MAPME_TIMESCALE:
- return sizeof(mapme_timing_command);
- case MAPME_RETX:
- return sizeof(mapme_timing_command);
- case MAPME_SEND_UPDATE:
- return sizeof(mapme_send_update_command);
- case CONNECTION_SET_ADMIN_STATE:
- return sizeof(connection_set_admin_state_command);
-#ifdef WITH_POLICY
- case ADD_POLICY:
- return sizeof(add_policy_command);
- case LIST_POLICIES:
- return 0; // list policies: payload always 0
- case REMOVE_POLICY:
- return sizeof(remove_policy_command);
- case UPDATE_CONNECTION:
- 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;
- default:
- return 0;
- }
+static inline int command_get_payload_len(command_type_t command_type) {
+ switch (command_type) {
+#define _(l, u) \
+ case COMMAND_TYPE_ ## u: \
+ return sizeof(cmd_## l ## _t);
+ foreach_command_type
+#undef _
+ case COMMAND_TYPE_UNDEFINED:
+ case COMMAND_TYPE_N:
+ return 0;
+ }
}
#endif
diff --git a/ctrl/libhicnctrl/src/api.c b/ctrl/libhicnctrl/src/api.c
index 080b6541a..ef9f4af65 100644
--- a/ctrl/libhicnctrl/src/api.c
+++ b/ctrl/libhicnctrl/src/api.c
@@ -57,7 +57,7 @@ typedef struct {
/**
* Messages to the forwarder might be multiplexed thanks to the seqNum fields in
- * the header_control_message structure. The forwarder simply answers back the
+ * the cmd_header_t structure. The forwarder simply answers back the
* original sequence number. We maintain a map of such sequence number to
* outgoing queries so that replied can be demultiplexed and treated
* appropriately.
@@ -272,28 +272,28 @@ static const address_type map_to_addr_type[] = {
******************************************************************************/
#define foreach_hc_command \
- _(add_connection) \
- _(remove_connection) \
- _(list_connections) \
- _(add_listener) \
- _(remove_listener) \
- _(list_listeners) \
- _(add_route) \
- _(remove_route) \
- _(list_routes) \
- _(cache_store) \
- _(cache_serve) \
+ _(connection_add) \
+ _(connection_remove) \
+ _(connection_list) \
+ _(listener_add) \
+ _(listener_remove) \
+ _(listener_list) \
+ _(route_add) \
+ _(route_remove) \
+ _(route_list) \
+ _(cache_set_store) \
+ _(cache_set_serve) \
/*_(cache_clear) */ \
- _(set_strategy) \
- _(set_wldr) \
- _(add_punting) \
+ _(strategy_set) \
+ _(wldr_set) \
+ _(punting_add) \
_(mapme_activator) \
_(mapme_timing)
-typedef header_control_message hc_msg_header_t;
+typedef cmd_header_t hc_msg_header_t;
typedef union {
-#define _(x) x ## _command x;
+#define _(x) cmd_ ## x ## _t x;
foreach_hc_command
#undef _
} hc_msg_payload_t;
@@ -486,7 +486,7 @@ hc_sock_create_url(const char * url)
s->url = url ? strdup(url) : NULL;
- s->fd = socket(AF_INET, SOCK_STREAM, 0);
+ s->fd = socket(AF_INET, SOCK_DGRAM, 0);
if (s->fd < 0)
goto ERR_SOCKET;
@@ -526,7 +526,7 @@ hc_sock_free(hc_sock_t * s)
hc_sock_request_t ** request_array = NULL;
int n = hc_sock_map_get_value_array(s->map, &request_array);
if (n < 0) {
- ERROR("Could not retrieve pending request array for freeing up resources");
+ ERROR("Could not retrieve pending request array for freeing up resources");
} else {
for (unsigned i = 0; i < n; i++) {
hc_sock_request_t * request = request_array[i];
@@ -620,7 +620,7 @@ hc_sock_recv(hc_sock_t * s)
rc = (int)recv(s->fd, s->buf + s->woff, RECV_BUFLEN - s->woff, 0);
if (rc == 0) {
/* Connection has been closed */
- return 0;
+ return 0;
}
if (rc < 0) {
/*
@@ -649,15 +649,15 @@ hc_sock_process(hc_sock_t * s, hc_data_t ** data)
while(available > 0) {
if (!s->cur_request) { // No message being parsed, alternatively (remaining == 0)
- hc_msg_t * msg = (hc_msg_t*)(s->buf + s->roff);
+ cmd_header_t hdr = ((msg_header_t *) (s->buf + s->roff))->header;
/* We expect a message header */
- if (available < sizeof(hc_msg_header_t)) {
+ if (available < sizeof(cmd_header_t)) {
break;
}
hc_sock_request_t * request = NULL;
- if (hc_sock_map_get(s->map, msg->hdr.seqNum, &request) < 0) {
+ if (hc_sock_map_get(s->map, hdr.seqNum, &request) < 0) {
ERROR("[hc_sock_process] Error searching for matching request");
return -99;
}
@@ -666,19 +666,23 @@ hc_sock_process(hc_sock_t * s, hc_data_t ** data)
return -99;
}
- s->remaining = msg->hdr.length;
- switch(msg->hdr.messageType) {
+ s->remaining = hdr.length;
+ switch(hdr.messageType) {
case ACK_LIGHT:
+ DEBUG("ack received");
assert(s->remaining == 1);
assert(!data);
s->cur_request = request;
+ hc_data_set_complete(request->data);
break;
case NACK_LIGHT:
+ DEBUG("nack received");
assert(s->remaining == 1);
assert(!data);
hc_data_set_error(request->data);
s->cur_request = request;
err = -1;
+ hc_data_set_complete(request->data);
break;
case RESPONSE_LIGHT:
assert(data);
@@ -697,9 +701,8 @@ hc_sock_process(hc_sock_t * s, hc_data_t ** data)
ERROR("[hc_sock_process] Invalid response received");
return -99;
}
-
- available -= sizeof(hc_msg_header_t);
- s->roff += sizeof(hc_msg_header_t);
+ available -= sizeof(cmd_header_t);
+ s->roff += sizeof(cmd_header_t);
} else {
/* We expect the complete payload, or at least a chunk of it */
size_t num_chunks = available / s->cur_request->data->in_element_size;
@@ -824,7 +827,7 @@ typedef int (*HC_PARSE)(const u8 *, u8 *);
typedef struct {
hc_action_t cmd;
- command_id cmd_id;
+ command_type_t cmd_id;
size_t size_in;
size_t size_out;
HC_PARSE parse;
@@ -966,13 +969,10 @@ _hc_listener_create(hc_sock_t * s, hc_listener_t * listener, bool async)
if (!IS_VALID_CONNECTION_TYPE(listener->type))
return -1;
- struct {
- header_control_message hdr;
- add_listener_command payload;
- } msg = {
- .hdr = {
+ msg_listener_add_t msg = {
+ .header = {
.messageType = REQUEST_LIGHT,
- .commandID = ADD_LISTENER,
+ .commandID = COMMAND_TYPE_LISTENER_ADD,
.length = 1,
.seqNum = 0,
},
@@ -982,6 +982,8 @@ _hc_listener_create(hc_sock_t * s, hc_listener_t * listener, bool async)
.addressType = (u8)map_to_addr_type[listener->family],
.listenerMode = (u8)map_to_listener_mode[listener->type],
.connectionType = (u8)map_to_connection_type[listener->type],
+ .family = listener->family,
+ .listenerType = listener->type,
}
};
@@ -995,8 +997,8 @@ _hc_listener_create(hc_sock_t * s, hc_listener_t * listener, bool async)
hc_command_params_t params = {
.cmd = ACTION_CREATE,
- .cmd_id = ADD_LISTENER,
- .size_in = sizeof(add_listener_command),
+ .cmd_id = COMMAND_TYPE_LISTENER_ADD,
+ .size_in = sizeof(cmd_listener_add_t),
.size_out = 0,
.parse = NULL,
};
@@ -1068,12 +1070,12 @@ _hc_listener_delete(hc_sock_t * s, hc_listener_t * listener, bool async)
BOOLSTR(async));
struct {
- header_control_message hdr;
- remove_listener_command payload;
+ cmd_header_t hdr;
+ cmd_listener_remove_t payload;
} msg = {
.hdr = {
.messageType = REQUEST_LIGHT,
- .commandID = REMOVE_LISTENER,
+ .commandID = COMMAND_TYPE_LISTENER_REMOVE,
.length = 1,
.seqNum = 0,
},
@@ -1101,8 +1103,8 @@ _hc_listener_delete(hc_sock_t * s, hc_listener_t * listener, bool async)
hc_command_params_t params = {
.cmd = ACTION_DELETE,
- .cmd_id = REMOVE_LISTENER,
- .size_in = sizeof(remove_listener_command),
+ .cmd_id = COMMAND_TYPE_LISTENER_REMOVE,
+ .size_in = sizeof(cmd_listener_remove_t),
.size_out = 0,
.parse = NULL,
};
@@ -1131,11 +1133,11 @@ _hc_listener_list(hc_sock_t * s, hc_data_t ** pdata, bool async)
DEBUG("[hc_listener_list] async=%s", BOOLSTR(async));
struct {
- header_control_message hdr;
+ cmd_header_t hdr;
} msg = {
.hdr = {
.messageType = REQUEST_LIGHT,
- .commandID = LIST_LISTENERS,
+ .commandID = COMMAND_TYPE_LISTENER_LIST,
.length = 0,
.seqNum = 0,
},
@@ -1143,8 +1145,8 @@ _hc_listener_list(hc_sock_t * s, hc_data_t ** pdata, bool async)
hc_command_params_t params = {
.cmd = ACTION_LIST,
- .cmd_id = LIST_LISTENERS,
- .size_in = sizeof(list_listeners_command),
+ .cmd_id = COMMAND_TYPE_LISTENER_LIST,
+ .size_in = sizeof(cmd_listener_list_t),
.size_out = sizeof(hc_listener_t),
.parse = (HC_PARSE)hc_listener_parse,
};
@@ -1215,7 +1217,7 @@ hc_listener_parse(void * in, hc_listener_t * listener)
{
int rc;
- list_listeners_command * cmd = (list_listeners_command *)in;
+ cmd_listener_list_t * cmd = (cmd_listener_list_t *)in;
if (!IS_VALID_LIST_LISTENERS_TYPE(cmd->encapType))
return -1;
@@ -1287,22 +1289,22 @@ _hc_connection_create(hc_sock_t * s, hc_connection_t * connection, bool async)
return -1;
struct {
- header_control_message hdr;
- add_connection_command payload;
+ cmd_header_t hdr;
+ cmd_connection_add_t payload;
} msg = {
.hdr = {
.messageType = REQUEST_LIGHT,
- .commandID = ADD_CONNECTION,
+ .commandID = COMMAND_TYPE_CONNECTION_ADD,
.length = 1,
.seqNum = 0,
},
.payload = {
- .remoteIp = connection->remote_addr,
- .localIp = connection->local_addr,
- .remotePort = htons(connection->remote_port),
- .localPort = htons(connection->local_port),
- .ipType = (u8)map_to_addr_type[connection->family],
- .connectionType = (u8)map_to_connection_type[connection->type],
+ .remote_ip = connection->remote_addr,
+ .local_ip = connection->local_addr,
+ .remote_port = htons(connection->remote_port),
+ .local_port = htons(connection->local_port),
+ .type = (u8)map_to_addr_type[connection->family],
+ .connection_type = (u8)map_to_connection_type[connection->type],
.admin_state = connection->admin_state,
#ifdef WITH_POLICY
.priority = connection->priority,
@@ -1317,8 +1319,8 @@ _hc_connection_create(hc_sock_t * s, hc_connection_t * connection, bool async)
hc_command_params_t params = {
.cmd = ACTION_CREATE,
- .cmd_id = ADD_CONNECTION,
- .size_in = sizeof(add_connection_command),
+ .cmd_id = COMMAND_TYPE_CONNECTION_ADD,
+ .size_in = sizeof(cmd_connection_add_t),
.size_out = 0,
.parse = NULL,
};
@@ -1389,12 +1391,12 @@ _hc_connection_delete(hc_sock_t * s, hc_connection_t * connection, bool async)
DEBUG("[_hc_connection_delete] connection=%s async=%s", connection_s, BOOLSTR(async));
struct {
- header_control_message hdr;
- remove_connection_command payload;
+ cmd_header_t hdr;
+ cmd_connection_remove_t payload;
} msg = {
.hdr = {
.messageType = REQUEST_LIGHT,
- .commandID = REMOVE_CONNECTION,
+ .commandID = COMMAND_TYPE_CONNECTION_REMOVE,
.length = 1,
.seqNum = 0,
},
@@ -1422,8 +1424,8 @@ _hc_connection_delete(hc_sock_t * s, hc_connection_t * connection, bool async)
hc_command_params_t params = {
.cmd = ACTION_DELETE,
- .cmd_id = REMOVE_CONNECTION,
- .size_in = sizeof(remove_connection_command),
+ .cmd_id = COMMAND_TYPE_CONNECTION_REMOVE,
+ .size_in = sizeof(cmd_connection_remove_t),
.size_out = 0,
.parse = NULL,
};
@@ -1451,11 +1453,11 @@ _hc_connection_list(hc_sock_t * s, hc_data_t ** pdata, bool async)
DEBUG("[hc_connection_list] async=%s", BOOLSTR(async));
struct {
- header_control_message hdr;
+ cmd_header_t hdr;
} msg = {
.hdr = {
.messageType = REQUEST_LIGHT,
- .commandID = LIST_CONNECTIONS,
+ .commandID = COMMAND_TYPE_CONNECTION_LIST,
.length = 0,
.seqNum = 0,
},
@@ -1463,8 +1465,8 @@ _hc_connection_list(hc_sock_t * s, hc_data_t ** pdata, bool async)
hc_command_params_t params = {
.cmd = ACTION_LIST,
- .cmd_id = LIST_CONNECTIONS,
- .size_in = sizeof(list_connections_command),
+ .cmd_id = COMMAND_TYPE_CONNECTION_LIST,
+ .size_in = sizeof(cmd_connection_list_t),
.size_out = sizeof(hc_connection_t),
.parse = (HC_PARSE)hc_connection_parse,
};
@@ -1548,12 +1550,12 @@ int
hc_connection_parse(void * in, hc_connection_t * connection)
{
int rc;
- list_connections_command * cmd = (list_connections_command *)in;
+ cmd_connection_list_t * cmd = (cmd_connection_list_t *)in;
- if (!IS_VALID_LIST_CONNECTIONS_TYPE(cmd->connectionData.connectionType))
+ if (!IS_VALID_LIST_CONNECTIONS_TYPE(cmd->connectionData.connection_type))
return -1;
- hc_connection_type_t type = map_from_list_connections_type[cmd->connectionData.connectionType];
+ hc_connection_type_t type = map_from_list_connections_type[cmd->connectionData.connection_type];
if (type == CONNECTION_TYPE_UNDEFINED)
return -1;
@@ -1564,10 +1566,10 @@ hc_connection_parse(void * in, hc_connection_t * connection)
if (state == HC_CONNECTION_STATE_UNDEFINED)
return -1;
- if (!IS_VALID_ADDR_TYPE(cmd->connectionData.ipType))
+ if (!IS_VALID_ADDR_TYPE(cmd->connectionData.type))
return -1;
- int family = map_from_addr_type[cmd->connectionData.ipType];
+ int family = map_from_addr_type[cmd->connectionData.type];
if (!IS_VALID_FAMILY(family))
return -1;
@@ -1575,12 +1577,12 @@ hc_connection_parse(void * in, hc_connection_t * connection)
.id = cmd->connid,
.type = type,
.family = family,
- .local_addr = cmd->connectionData.localIp,
+ .local_addr = cmd->connectionData.local_ip,
//.local_addr = UNION_CAST(cmd->connectionData.localIp, ip_address_t),
- .local_port = ntohs(cmd->connectionData.localPort),
- .remote_addr = cmd->connectionData.remoteIp,
+ .local_port = ntohs(cmd->connectionData.local_port),
+ .remote_addr = cmd->connectionData.remote_ip,
//.remote_addr = UNION_CAST(cmd->connectionData.remoteIp, ip_address_t),
- .remote_port = ntohs(cmd->connectionData.remotePort),
+ .remote_port = ntohs(cmd->connectionData.remote_port),
.admin_state = cmd->connectionData.admin_state,
#ifdef WITH_POLICY
.priority = cmd->connectionData.priority,
@@ -1642,12 +1644,12 @@ _hc_connection_set_admin_state(hc_sock_t * s, const char * conn_id_or_name,
DEBUG("[hc_connection_set_admin_state] connection_id/name=%s admin_state=%s async=%s",
conn_id_or_name, face_state_str(state), BOOLSTR(async));
struct {
- header_control_message hdr;
- connection_set_admin_state_command payload;
+ cmd_header_t hdr;
+ cmd_connection_set_admin_state_t payload;
} msg = {
.hdr = {
.messageType = REQUEST_LIGHT,
- .commandID = CONNECTION_SET_ADMIN_STATE,
+ .commandID = COMMAND_TYPE_CONNECTION_SET_ADMIN_STATE,
.length = 1,
.seqNum = 0,
},
@@ -1661,8 +1663,8 @@ _hc_connection_set_admin_state(hc_sock_t * s, const char * conn_id_or_name,
hc_command_params_t params = {
.cmd = ACTION_SET,
- .cmd_id = CONNECTION_SET_ADMIN_STATE,
- .size_in = sizeof(connection_set_admin_state_command),
+ .cmd_id = COMMAND_TYPE_CONNECTION_SET_ADMIN_STATE,
+ .size_in = sizeof(cmd_connection_set_admin_state_t),
.size_out = 0,
.parse = NULL,
};
@@ -1692,12 +1694,12 @@ _hc_connection_set_priority(hc_sock_t * s, const char * conn_id_or_name,
DEBUG("[hc_connection_set_priority] connection_id/name=%s priority=%d async=%s",
conn_id_or_name, priority, BOOLSTR(async));
struct {
- header_control_message hdr;
- connection_set_priority_command payload;
+ cmd_header_t hdr;
+ cmd_connection_set_priority_t payload;
} msg = {
.hdr = {
.messageType = REQUEST_LIGHT,
- .commandID = CONNECTION_SET_PRIORITY,
+ .commandID = COMMAND_TYPE_CONNECTION_SET_PRIORITY,
.length = 1,
.seqNum = 0,
},
@@ -1711,8 +1713,8 @@ _hc_connection_set_priority(hc_sock_t * s, const char * conn_id_or_name,
hc_command_params_t params = {
.cmd = ACTION_SET,
- .cmd_id = CONNECTION_SET_PRIORITY,
- .size_in = sizeof(connection_set_priority_command),
+ .cmd_id = COMMAND_TYPE_CONNECTION_SET_PRIORITY,
+ .size_in = sizeof(cmd_connection_set_priority_t),
.size_out = 0,
.parse = NULL,
};
@@ -1742,12 +1744,12 @@ _hc_connection_set_tags(hc_sock_t * s, const char * conn_id_or_name,
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;
+ cmd_header_t hdr;
+ cmd_connection_set_tags_t payload;
} msg = {
.hdr = {
.messageType = REQUEST_LIGHT,
- .commandID = CONNECTION_SET_TAGS,
+ .commandID = COMMAND_TYPE_CONNECTION_SET_TAGS,
.length = 1,
.seqNum = 0,
},
@@ -1761,8 +1763,8 @@ _hc_connection_set_tags(hc_sock_t * s, const char * conn_id_or_name,
hc_command_params_t params = {
.cmd = ACTION_SET,
- .cmd_id = CONNECTION_SET_TAGS,
- .size_in = sizeof(connection_set_tags_command),
+ .cmd_id = COMMAND_TYPE_CONNECTION_SET_TAGS,
+ .size_in = sizeof(cmd_connection_set_tags_t),
.size_out = 0,
.parse = NULL,
};
@@ -1806,12 +1808,12 @@ _hc_route_create(hc_sock_t * s, hc_route_t * route, bool async)
return -1;
struct {
- header_control_message hdr;
- add_route_command payload;
+ cmd_header_t hdr;
+ cmd_route_add_t payload;
} msg = {
.hdr = {
.messageType = REQUEST_LIGHT,
- .commandID = ADD_ROUTE,
+ .commandID = COMMAND_TYPE_ROUTE_ADD,
.length = 1,
.seqNum = 0,
},
@@ -1833,8 +1835,8 @@ _hc_route_create(hc_sock_t * s, hc_route_t * route, bool async)
hc_command_params_t params = {
.cmd = ACTION_CREATE,
- .cmd_id = ADD_ROUTE,
- .size_in = sizeof(add_route_command),
+ .cmd_id = COMMAND_TYPE_ROUTE_ADD,
+ .size_in = sizeof(cmd_route_add_t),
.size_out = 0,
.parse = NULL,
};
@@ -1869,12 +1871,12 @@ _hc_route_delete(hc_sock_t * s, hc_route_t * route, bool async)
return -1;
struct {
- header_control_message hdr;
- remove_route_command payload;
+ cmd_header_t hdr;
+ cmd_route_remove_t payload;
} msg = {
.hdr = {
.messageType = REQUEST_LIGHT,
- .commandID = REMOVE_ROUTE,
+ .commandID = COMMAND_TYPE_ROUTE_REMOVE,
.length = 1,
.seqNum = 0,
},
@@ -1893,8 +1895,8 @@ _hc_route_delete(hc_sock_t * s, hc_route_t * route, bool async)
hc_command_params_t params = {
.cmd = ACTION_DELETE,
- .cmd_id = REMOVE_ROUTE,
- .size_in = sizeof(remove_route_command),
+ .cmd_id = COMMAND_TYPE_ROUTE_REMOVE,
+ .size_in = sizeof(cmd_route_remove_t),
.size_out = 0,
.parse = NULL,
};
@@ -1922,11 +1924,11 @@ _hc_route_list(hc_sock_t * s, hc_data_t ** pdata, bool async)
//DEBUG("[hc_route_list] async=%s", BOOLSTR(async));
struct {
- header_control_message hdr;
+ cmd_header_t hdr;
} msg = {
.hdr = {
.messageType = REQUEST_LIGHT,
- .commandID = LIST_ROUTES,
+ .commandID = COMMAND_TYPE_ROUTE_LIST,
.length = 0,
.seqNum = 0,
},
@@ -1934,8 +1936,8 @@ _hc_route_list(hc_sock_t * s, hc_data_t ** pdata, bool async)
hc_command_params_t params = {
.cmd = ACTION_LIST,
- .cmd_id = LIST_ROUTES,
- .size_in = sizeof(list_routes_command),
+ .cmd_id = COMMAND_TYPE_ROUTE_LIST,
+ .size_in = sizeof(cmd_route_list_t),
.size_out = sizeof(hc_route_t),
.parse = (HC_PARSE)hc_route_parse,
};
@@ -1960,7 +1962,7 @@ hc_route_list_async(hc_sock_t * s)
int
hc_route_parse(void * in, hc_route_t * route)
{
- list_routes_command * cmd = (list_routes_command *) in;
+ cmd_route_list_t * cmd = (cmd_route_list_t *) in;
if (!IS_VALID_ADDR_TYPE(cmd->addressType)) {
ERROR("[hc_route_parse] Invalid address type");
@@ -2516,11 +2518,11 @@ int
hc_face_list_async(hc_sock_t * s)
{
struct {
- header_control_message hdr;
+ cmd_header_t hdr;
} msg = {
.hdr = {
.messageType = REQUEST_LIGHT,
- .commandID = LIST_CONNECTIONS,
+ COMMAND_TYPE_CONNECTION_LIST,
.length = 0,
.seqNum = 0,
},
@@ -2528,8 +2530,8 @@ hc_face_list_async(hc_sock_t * s)
hc_command_params_t params = {
.cmd = ACTION_LIST,
- .cmd_id = LIST_CONNECTIONS,
- .size_in = sizeof(list_connections_command),
+ .cmd_id = COMMAND_TYPE_CONNECTION_LIST,
+ .size_in = sizeof(cmd_connection_list_t),
.size_out = sizeof(hc_face_t),
.parse = (HC_PARSE)hc_connection_parse_to_face,
};
@@ -2656,12 +2658,12 @@ _hc_punting_create(hc_sock_t * s, hc_punting_t * punting, bool async)
return -1;
struct {
- header_control_message hdr;
- add_punting_command payload;
+ cmd_header_t hdr;
+ cmd_punting_add_t payload;
} msg = {
.hdr = {
.messageType = REQUEST_LIGHT,
- .commandID = ADD_PUNTING,
+ .commandID = COMMAND_TYPE_PUNTING_ADD,
.length = 1,
.seqNum = 0,
},
@@ -2677,8 +2679,8 @@ _hc_punting_create(hc_sock_t * s, hc_punting_t * punting, bool async)
hc_command_params_t params = {
.cmd = ACTION_CREATE,
- .cmd_id = ADD_PUNTING,
- .size_in = sizeof(add_punting_command),
+ .cmd_id = COMMAND_TYPE_PUNTING_ADD,
+ .size_in = sizeof(cmd_punting_add_t),
.size_out = 0,
.parse = NULL,
};
@@ -2777,12 +2779,12 @@ int
_hc_cache_set_store(hc_sock_t * s, int enabled, bool async)
{
struct {
- header_control_message hdr;
- cache_store_command payload;
+ cmd_header_t hdr;
+ cmd_cache_set_store_t payload;
} msg = {
.hdr = {
.messageType = REQUEST_LIGHT,
- .commandID = CACHE_STORE,
+ .commandID = COMMAND_TYPE_CACHE_SET_STORE,
.length = 1,
.seqNum = 0,
},
@@ -2793,8 +2795,8 @@ _hc_cache_set_store(hc_sock_t * s, int enabled, bool async)
hc_command_params_t params = {
.cmd = ACTION_SET,
- .cmd_id = CACHE_STORE,
- .size_in = sizeof(cache_store_command),
+ .cmd_id = COMMAND_TYPE_CACHE_SET_STORE,
+ .size_in = sizeof(cmd_cache_set_store_t),
.size_out = 0,
.parse = NULL,
};
@@ -2818,12 +2820,12 @@ int
_hc_cache_set_serve(hc_sock_t * s, int enabled, bool async)
{
struct {
- header_control_message hdr;
- cache_serve_command payload;
+ cmd_header_t hdr;
+ cmd_cache_set_serve_t payload;
} msg = {
.hdr = {
.messageType = REQUEST_LIGHT,
- .commandID = CACHE_SERVE,
+ .commandID = COMMAND_TYPE_CACHE_SET_SERVE,
.length = 1,
.seqNum = 0,
},
@@ -2834,8 +2836,8 @@ _hc_cache_set_serve(hc_sock_t * s, int enabled, bool async)
hc_command_params_t params = {
.cmd = ACTION_SET,
- .cmd_id = CACHE_SERVE,
- .size_in = sizeof(cache_serve_command),
+ .cmd_id = COMMAND_TYPE_CACHE_SET_SERVE,
+ .size_in = sizeof(cmd_cache_set_serve_t),
.size_out = 0,
.parse = NULL,
};
@@ -2955,12 +2957,12 @@ _hc_policy_create(hc_sock_t * s, hc_policy_t * policy, bool async)
return -1;
struct {
- header_control_message hdr;
- add_policy_command payload;
+ cmd_header_t hdr;
+ cmd_policy_add_t payload;
} msg = {
.hdr = {
.messageType = REQUEST_LIGHT,
- .commandID = ADD_POLICY,
+ COMMAND_TYPE_POLICY_ADD,
.length = 1,
.seqNum = 0,
},
@@ -2974,8 +2976,8 @@ _hc_policy_create(hc_sock_t * s, hc_policy_t * policy, bool async)
hc_command_params_t params = {
.cmd = ACTION_CREATE,
- .cmd_id = ADD_POLICY,
- .size_in = sizeof(add_policy_command),
+ .cmd_id = COMMAND_TYPE_POLICY_ADD,
+ .size_in = sizeof(cmd_policy_add_t),
.size_out = 0,
.parse = NULL,
};
@@ -3004,12 +3006,12 @@ _hc_policy_delete(hc_sock_t * s, hc_policy_t * policy, bool async)
return -1;
struct {
- header_control_message hdr;
- remove_policy_command payload;
+ cmd_header_t hdr;
+ cmd_policy_remove_t payload;
} msg = {
.hdr = {
.messageType = REQUEST_LIGHT,
- .commandID = REMOVE_POLICY,
+ .commandID = COMMAND_TYPE_POLICY_REMOVE,
.length = 1,
.seqNum = 0,
},
@@ -3022,8 +3024,8 @@ _hc_policy_delete(hc_sock_t * s, hc_policy_t * policy, bool async)
hc_command_params_t params = {
.cmd = ACTION_DELETE,
- .cmd_id = REMOVE_POLICY,
- .size_in = sizeof(remove_policy_command),
+ .cmd_id = COMMAND_TYPE_POLICY_REMOVE,
+ .size_in = sizeof(cmd_policy_remove_t),
.size_out = 0,
.parse = NULL,
};
@@ -3049,11 +3051,11 @@ int
_hc_policy_list(hc_sock_t * s, hc_data_t ** pdata, bool async)
{
struct {
- header_control_message hdr;
+ cmd_header_t hdr;
} msg = {
.hdr = {
.messageType = REQUEST_LIGHT,
- .commandID = LIST_POLICIES,
+ .commandID = COMMAND_TYPE_POLICY_LIST,
.length = 0,
.seqNum = 0,
},
@@ -3061,8 +3063,8 @@ _hc_policy_list(hc_sock_t * s, hc_data_t ** pdata, bool async)
hc_command_params_t params = {
.cmd = ACTION_LIST,
- .cmd_id = LIST_POLICIES,
- .size_in = sizeof(list_policies_command),
+ .cmd_id = COMMAND_TYPE_POLICY_LIST,
+ .size_in = sizeof(cmd_policy_list_t),
.size_out = sizeof(hc_policy_t),
.parse = (HC_PARSE)hc_policy_parse,
};
@@ -3087,7 +3089,7 @@ hc_policy_list_async(hc_sock_t * s, hc_data_t ** pdata)
int
hc_policy_parse(void * in, hc_policy_t * policy)
{
- list_policies_command * cmd = (list_policies_command *) in;
+ cmd_policy_list_t * cmd = (cmd_policy_list_t *) in;
if (!IS_VALID_ADDR_TYPE(cmd->addressType))
return -1;
diff --git a/ctrl/libhicnctrl/src/hicn_plugin_api.c b/ctrl/libhicnctrl/src/hicn_plugin_api.c
index 406f43404..04d01e2a6 100644
--- a/ctrl/libhicnctrl/src/hicn_plugin_api.c
+++ b/ctrl/libhicnctrl/src/hicn_plugin_api.c
@@ -61,7 +61,7 @@ vapi_skc_ctx_t vapi_skc = {
/**
* Messages to the forwarder might be multiplexed thanks to the seqNum fields in
- * the header_control_message structure. The forwarder simply answers back the
+ * the cmd_header_t structure. The forwarder simply answers back the
* original sequence number. We maintain a map of such sequence number to
* outgoing queries so that replied can be demultiplexed and treated
* appropriately.