aboutsummaryrefslogtreecommitdiffstats
path: root/hicn-light/src/hicn/io/udpConnection.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/io/udpConnection.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/io/udpConnection.c')
-rw-r--r--hicn-light/src/hicn/io/udpConnection.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/hicn-light/src/hicn/io/udpConnection.c b/hicn-light/src/hicn/io/udpConnection.c
index 69cbea0e1..fb1865df3 100644
--- a/hicn-light/src/hicn/io/udpConnection.c
+++ b/hicn-light/src/hicn/io/udpConnection.c
@@ -57,6 +57,11 @@ typedef struct udp_state {
unsigned id;
unsigned delay;
+
+ /* This information would better be stored in the connection data structure
+ * but it is currently not reachable from within the implementation. */
+ connection_state_t state;
+ connection_state_t admin_state;
} _UdpState;
// Prototypes
@@ -72,6 +77,10 @@ static void _destroy(IoOperations **opsPtr);
static list_connections_type _getConnectionType(const IoOperations *ops);
static Ticks _sendProbe(IoOperations *ops, unsigned probeType,
uint8_t *message);
+static connection_state_t _getState(const IoOperations *ops);
+static void _setState(IoOperations *ops, connection_state_t state);
+static connection_state_t _getAdminState(const IoOperations *ops);
+static void _setAdminState(IoOperations *ops, connection_state_t admin_state);
/*
* This assigns a unique pointer to the void * which we use
@@ -99,6 +108,10 @@ static IoOperations _template = {
.class = &_streamConnection_Class,
.getConnectionType = &_getConnectionType,
.sendProbe = &_sendProbe,
+ .getState = &_getState,
+ .setState = &_setState,
+ .getAdminState = &_getAdminState,
+ .setAdminState = &_setAdminState,
};
// =================================================================
@@ -394,3 +407,31 @@ static void _setConnectionState(_UdpState *udpConnState, bool isUp) {
return;
}
}
+
+static connection_state_t _getState(const IoOperations *ops) {
+ parcAssertNotNull(ops, "Parameter must be non-null");
+ const _UdpState *udpConnState =
+ (const _UdpState *)ioOperations_GetClosure(ops);
+ return udpConnState->state;
+}
+
+static void _setState(IoOperations *ops, connection_state_t state) {
+ parcAssertNotNull(ops, "Parameter must be non-null");
+ _UdpState *udpConnState =
+ (_UdpState *)ioOperations_GetClosure(ops);
+ udpConnState->state = state;
+}
+
+static connection_state_t _getAdminState(const IoOperations *ops) {
+ parcAssertNotNull(ops, "Parameter must be non-null");
+ const _UdpState *udpConnState =
+ (const _UdpState *)ioOperations_GetClosure(ops);
+ return udpConnState->admin_state;
+}
+
+static void _setAdminState(IoOperations *ops, connection_state_t admin_state) {
+ parcAssertNotNull(ops, "Parameter must be non-null");
+ _UdpState *udpConnState =
+ (_UdpState *)ioOperations_GetClosure(ops);
+ udpConnState->admin_state = admin_state;
+}