summaryrefslogtreecommitdiffstats
path: root/hicn-light/src/hicn/api
diff options
context:
space:
mode:
Diffstat (limited to 'hicn-light/src/hicn/api')
-rw-r--r--hicn-light/src/hicn/api/api.c39
-rw-r--r--hicn-light/src/hicn/api/api.h5
-rw-r--r--hicn-light/src/hicn/api/commands.h30
3 files changed, 23 insertions, 51 deletions
diff --git a/hicn-light/src/hicn/api/api.c b/hicn-light/src/hicn/api/api.c
index 291f3e6a3..9b3882379 100644
--- a/hicn-light/src/hicn/api/api.c
+++ b/hicn-light/src/hicn/api/api.c
@@ -806,10 +806,7 @@ int hc_parse_connection(void *in, hc_connection_t *connection) {
.local_port = ntohs(cmd->connectionData.localPort),
.remote_addr = UNION_CAST(cmd->connectionData.remoteIp, ip_address_t),
.remote_port = ntohs(cmd->connectionData.remotePort),
-#ifdef WITH_POLICY
- .desired_state = cmd->connectionData.desired_state,
- .tags = cmd->connectionData.tags,
-#endif /* WITH_POLICY */
+ .admin_state = cmd->connectionData.admin_state,
.state = state,
};
strncpy(connection->name, cmd->connectionData.symbolic, NAME_LEN);
@@ -843,10 +840,7 @@ int hc_connection_create(hc_sock_t *s, hc_connection_t *connection) {
.remotePort = htons(connection->remote_port),
.localPort = htons(connection->local_port),
.ipType = (u8)map_to_addr_type[connection->family],
-#ifdef WITH_POLICY
- .desired_state = connection->desired_state,
- .tags = connection->tags,
-#endif /* WITH_POLICY */
+ .admin_state = connection->admin_state,
.connectionType = (u8)map_to_connection_type[connection->type],
}};
strncpy(msg.payload.symbolic, connection->name, NAME_LEN);
@@ -890,40 +884,38 @@ int hc_connection_delete(hc_sock_t *s, hc_connection_t *connection) {
return hc_execute_command(s, (hc_msg_t *)&msg, sizeof(msg), &params, NULL);
}
-#ifdef WITH_POLICY
typedef struct {
header_control_message hdr;
- connection_set_state_command payload;
-} hc_msg_connection_set_state_t;
+ connection_set_admin_state_command payload;
+} hc_msg_connection_set_admin_state_t;
-int hc_connection_set_state(hc_sock_t *s, const char *conn_id_or_name,
- face_state_t state) {
- hc_msg_connection_set_state_t msg = {
+int hc_connection_set_admin_state(hc_sock_t *s, const char *conn_id_or_name,
+ hc_connection_state_t admin_state) {
+ hc_msg_connection_set_admin_state_t msg = {
.hdr =
{
.messageType = REQUEST_LIGHT,
- .commandID = CONNECTION_SET_STATE,
+ .commandID = CONNECTION_SET_ADMIN_STATE,
.length = 1,
.seqNum = s->send_seq,
},
.payload =
{
- .state = state,
+ .admin_state = admin_state,
},
};
strncpy(msg.payload.symbolicOrConnid, conn_id_or_name, NAME_LEN);
hc_command_params_t params = {
.cmd = ACTION_SET,
- .cmd_id = CONNECTION_SET_STATE,
- .size_in = sizeof(connection_set_state_command),
+ .cmd_id = CONNECTION_SET_ADMIN_STATE,
+ .size_in = sizeof(connection_set_admin_state_command),
.size_out = 0,
.parse = NULL,
};
return hc_execute_command(s, (hc_msg_t *)&msg, sizeof(msg), &params, NULL);
}
-#endif /* WITH_POLICY */
typedef struct {
header_control_message hdr;
@@ -1321,12 +1313,11 @@ ERR:
return LIBHICNCTRL_FAILURE;
}
-#ifdef WITH_POLICY
-int hc_face_set_state(hc_sock_t *s, const char *conn_id_or_name,
- face_state_t state) {
- return hc_connection_set_state(s, conn_id_or_name, state);
+int hc_face_set_admin_state(hc_sock_t *s, const char *conn_id_or_name,
+ hc_connection_state_t admin_state) {
+ return hc_connection_set_admin_state(s, conn_id_or_name, admin_state);
}
-#endif /* WITH_POLICY */
+
/* /!\ Please update constants in header file upon changes */
size_t hc_face_snprintf(char *s, size_t size, hc_face_t *face) {
return LIBHICNCTRL_SUCCESS;
diff --git a/hicn-light/src/hicn/api/api.h b/hicn-light/src/hicn/api/api.h
index e2358167c..ba07fa7ed 100644
--- a/hicn-light/src/hicn/api/api.h
+++ b/hicn-light/src/hicn/api/api.h
@@ -448,10 +448,7 @@ typedef struct {
u16 local_port; /* .rw */
ip_address_t remote_addr; /* .rw */
u16 remote_port; /* .rw */
-#ifdef WITH_POLICY
- face_state_t desired_state; /* .rw */
- face_tags_t tags; /* .rw */
-#endif /* WITH_POLICY */
+ hc_connection_state_t admin_state; /* .rw */
hc_connection_state_t state; /* .r. */
} hc_connection_t;
diff --git a/hicn-light/src/hicn/api/commands.h b/hicn-light/src/hicn/api/commands.h
index c26ac0172..236a75a33 100644
--- a/hicn-light/src/hicn/api/commands.h
+++ b/hicn-light/src/hicn/api/commands.h
@@ -31,10 +31,6 @@
#include <stdint.h>
#include <stdlib.h>
-#ifdef WITH_POLICY
-#include <hicn/api/face.h>
-#endif /* WITH_POLICY */
-
typedef struct in6_addr ipv6_addr_t;
typedef uint32_t ipv4_addr_t;
@@ -44,7 +40,7 @@ union commandAddr {
};
typedef enum {
- REQUEST_LIGHT = 0xc0, // this is a command
+ REQUEST_LIGHT = 0xc0, // this is a command
RESPONSE_LIGHT,
ACK_LIGHT,
NACK_LIGHT,
@@ -70,9 +66,7 @@ typedef enum {
MAPME_DISCOVERY,
MAPME_TIMESCALE,
MAPME_RETX,
-#ifdef WITH_POLICY
- CONNECTION_SET_STATE,
-#endif /* WITH_POLICY */
+ CONNECTION_SET_ADMIN_STATE,
LAST_COMMAND_VALUE
} command_id;
@@ -132,11 +126,7 @@ typedef struct {
uint16_t localPort;
uint8_t ipType;
uint8_t connectionType;
-#ifdef WITH_POLICY
- face_state_t
- desired_state; /* This is the desired state, not the actual state */
- face_tags_t tags;
-#endif /* WITH_POLICY */
+ uint8_t admin_state;
} add_connection_command;
// SIZE=56
@@ -294,14 +284,10 @@ typedef struct {
// SIZE=1
-//========== POLICY-RELATED FUNCTIONS ==========
-
-#ifdef WITH_POLICY
typedef struct {
char symbolicOrConnid[16];
- face_state_t state;
-} connection_set_state_command;
-#endif /* WITH_POLICY */
+ uint8_t admin_state;
+} connection_set_admin_state_command;
//===== size of commands ======
// REMINDER: when a new_command is added, the following switch has to be
@@ -344,10 +330,8 @@ static inline int payloadLengthDaemon(command_id id) {
return sizeof(mapme_timing_command);
case MAPME_RETX:
return sizeof(mapme_timing_command);
-#ifdef WITH_POLICY
- case CONNECTION_SET_STATE:
- return sizeof(connection_set_state_command);
-#endif /* WITH_POLICY */
+ case CONNECTION_SET_ADMIN_STATE:
+ return sizeof(connection_set_admin_state_command);
case LAST_COMMAND_VALUE:
return 0;
default: