aboutsummaryrefslogtreecommitdiffstats
path: root/hicn-light/src/hicn/core/connection.c
diff options
context:
space:
mode:
authorJordan Augé <jordan.auge+fdio@cisco.com>2019-05-09 11:26:31 +0200
committerJordan Augé <jordan.auge+fdio@cisco.com>2019-05-09 11:26:31 +0200
commit3e2cd52a6ae2345a44f39761beb5315a45832d95 (patch)
tree14f55c9fd58003faed83a3d47756a46d97c09322 /hicn-light/src/hicn/core/connection.c
parentc8e6bdf4282c34fd3199cdeec42895cbbc05d9c1 (diff)
[HICN-192] Add interface to administratively set a connection up and down
Change-Id: I8d00262fd8601328a50d0e2a6bef952031246818 Signed-off-by: Jordan Augé <jordan.auge+fdio@cisco.com>
Diffstat (limited to 'hicn-light/src/hicn/core/connection.c')
-rw-r--r--hicn-light/src/hicn/core/connection.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/hicn-light/src/hicn/core/connection.c b/hicn-light/src/hicn/core/connection.c
index 61db61ba7..a5d5fb5b9 100644
--- a/hicn-light/src/hicn/core/connection.c
+++ b/hicn-light/src/hicn/core/connection.c
@@ -18,6 +18,7 @@
#include <stdio.h>
#include <hicn/core/connection.h>
+#include <hicn/core/connectionState.h>
#include <hicn/core/messageHandler.h>
#include <hicn/core/ticks.h>
#include <hicn/core/wldr.h>
@@ -45,7 +46,6 @@ struct connection {
// file/hicnLightControl) this value is set to false so
// that a base station can not disable wldr at the client
Wldr *wldr;
-
};
Connection *connection_Create(IoOperations *ops) {
@@ -64,6 +64,10 @@ Connection *connection_Create(IoOperations *ops) {
conn->counter = 0;
conn->last_sent = 0;
conn->delay = INT_MAX;
+
+ /* By default, a connection will aim at the UP state */
+ connection_SetAdminState(conn, CONNECTION_STATE_UP);
+
return conn;
}
@@ -280,3 +284,35 @@ void connection_HandleWldrNotification(Connection *conn, Message *message) {
if (conn->wldr != NULL)
wldr_HandleWldrNotification(conn->wldr, conn, message);
}
+
+connection_state_t connection_GetState(const Connection *conn)
+{
+ parcAssertNotNull(conn, "Parameter conn must be non-null");
+ if (!conn->ops)
+ return CONNECTION_STATE_UNDEFINED;
+ return ioOperations_GetState(conn->ops);
+}
+
+void connection_SetState(Connection *conn, connection_state_t state)
+{
+ parcAssertNotNull(conn, "Parameter conn must be non-null");
+ if (!conn->ops)
+ return;
+ ioOperations_SetState(conn->ops, state);
+}
+
+connection_state_t connection_GetAdminState(const Connection *conn)
+{
+ parcAssertNotNull(conn, "Parameter conn must be non-null");
+ if (!conn->ops)
+ return CONNECTION_STATE_UNDEFINED;
+ return ioOperations_GetAdminState(conn->ops);
+}
+
+void connection_SetAdminState(Connection *conn, connection_state_t admin_state)
+{
+ parcAssertNotNull(conn, "Parameter conn must be non-null");
+ if (!conn->ops)
+ return;
+ ioOperations_SetAdminState(conn->ops, admin_state);
+}