aboutsummaryrefslogtreecommitdiffstats
path: root/hicn-light/src/hicn/io
diff options
context:
space:
mode:
authorJordan Augé <jordan.auge+fdio@cisco.com>2019-11-17 00:07:12 +0100
committerJordan Augé <jordan.auge+fdio@cisco.com>2019-11-17 11:03:31 +0100
commit2ada8954ecd3601d115a22696c4c3ab90858cec3 (patch)
tree6db983388333e8776eecaf9c07c5b7bd6f2f10be /hicn-light/src/hicn/io
parent2dcc25795fab0100ce33852f08d77a5fd90d8f14 (diff)
[HICN-379] Add face priority support in face manager
Change-Id: If4f75d44fc66414a4a70135de7827f5082b97112 Signed-off-by: Jordan Augé <jordan.auge+fdio@cisco.com>
Diffstat (limited to 'hicn-light/src/hicn/io')
-rw-r--r--hicn-light/src/hicn/io/hicnConnection.c31
-rw-r--r--hicn-light/src/hicn/io/ioOperations.c10
-rw-r--r--hicn-light/src/hicn/io/ioOperations.h23
-rw-r--r--hicn-light/src/hicn/io/streamConnection.c31
-rw-r--r--hicn-light/src/hicn/io/udpConnection.c31
5 files changed, 126 insertions, 0 deletions
diff --git a/hicn-light/src/hicn/io/hicnConnection.c b/hicn-light/src/hicn/io/hicnConnection.c
index d56231c38..e35454438 100644
--- a/hicn-light/src/hicn/io/hicnConnection.c
+++ b/hicn-light/src/hicn/io/hicnConnection.c
@@ -78,6 +78,9 @@ typedef struct hicn_state {
* but it is currently not reachable from within the implementation. */
connection_state_t state;
connection_state_t admin_state;
+#ifdef WITH_POLICY
+ uint32_t priority;
+#endif /* WITH_POLICY */
} _HicnState;
// Prototypes
@@ -97,6 +100,10 @@ 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);
+#ifdef WITH_POLICY
+static uint32_t _getPriority(const IoOperations *ops);
+static void _setPriority(IoOperations *ops, uint32_t priority);
+#endif /* WITH_POLICY */
static const char * _getInterfaceName(const IoOperations *ops);
/*
@@ -129,6 +136,10 @@ static IoOperations _template = {
.setState = &_setState,
.getAdminState = &_getAdminState,
.setAdminState = &_setAdminState,
+#ifdef WITH_POLICY
+ .getPriority = &_getPriority,
+ .setPriority = &_setPriority,
+#endif /* WITH_POLICY */
.getInterfaceName = &_getInterfaceName,
};
@@ -168,6 +179,10 @@ IoOperations *hicnConnection_Create(Forwarder *forwarder, const char * interface
_setConnectionState(hicnConnState, true);
+#ifdef WITH_POLICY
+ hicnConnState->priority = 0;
+#endif /* WITH_POLICY */
+
if (logger_IsLoggable(hicnConnState->logger, LoggerFacility_IO,
PARCLogLevel_Info)) {
char *str = addressPair_ToString(hicnConnState->addressPair);
@@ -592,6 +607,22 @@ static void _setAdminState(IoOperations *ops, connection_state_t admin_state) {
hicnConnState->admin_state = admin_state;
}
+#ifdef WITH_POLICY
+static uint32_t _getPriority(const IoOperations *ops) {
+ parcAssertNotNull(ops, "Parameter must be non-null");
+ const _HicnState *hicnConnState =
+ (const _HicnState *)ioOperations_GetClosure(ops);
+ return hicnConnState->priority;
+}
+
+static void _setPriority(IoOperations *ops, uint32_t priority) {
+ parcAssertNotNull(ops, "Parameter must be non-null");
+ _HicnState *hicnConnState =
+ (_HicnState *)ioOperations_GetClosure(ops);
+ hicnConnState->priority = priority;
+}
+#endif /* WITH_POLICY
+*/
static const char * _getInterfaceName(const IoOperations *ops)
{
parcAssertNotNull(ops, "Parameter must be non-null");
diff --git a/hicn-light/src/hicn/io/ioOperations.c b/hicn-light/src/hicn/io/ioOperations.c
index b2d346ed8..336e9f12e 100644
--- a/hicn-light/src/hicn/io/ioOperations.c
+++ b/hicn-light/src/hicn/io/ioOperations.c
@@ -86,6 +86,16 @@ void ioOperations_SetAdminState(IoOperations *ops, connection_state_t admin_stat
ops->setAdminState(ops, admin_state);
}
+#ifdef WITH_POLICY
+uint32_t ioOperations_GetPriority(const IoOperations *ops) {
+ return ops->getPriority(ops);
+}
+
+void ioOperations_SetPriority(IoOperations *ops, uint32_t priority) {
+ ops->setPriority(ops, priority);
+}
+#endif /* WITH_POLICY */
+
const char * ioOperations_GetInterfaceName(const IoOperations *ops) {
return ops->getInterfaceName(ops);
}
diff --git a/hicn-light/src/hicn/io/ioOperations.h b/hicn-light/src/hicn/io/ioOperations.h
index c8a107199..ee8720e77 100644
--- a/hicn-light/src/hicn/io/ioOperations.h
+++ b/hicn-light/src/hicn/io/ioOperations.h
@@ -89,6 +89,10 @@ struct io_ops {
void (*setState)(IoOperations *ops, connection_state_t state);
connection_state_t (*getAdminState)(const IoOperations *ops);
void (*setAdminState)(IoOperations *ops, connection_state_t admin_state);
+#ifdef WITH_POLICY
+ uint32_t (*getPriority)(const IoOperations *ops);
+ void (*setPriority)(IoOperations *ops, uint32_t priority);
+#endif /* WITH_POLICY */
const char * (*getInterfaceName)(const IoOperations *ops);
};
@@ -416,6 +420,25 @@ connection_state_t ioOperations_GetAdminState(const IoOperations *ops);
*/
void ioOperations_SetAdminState(IoOperations *ops, connection_state_t admin_state);
+#ifdef WITH_POLICY
+/**
+ * Returns the priority of the connection
+ *
+ * @param [in] ops The connection implementation.
+ *
+ * @return Connection state (uint32_t).
+ */
+uint32_t ioOperations_GetPriority(const IoOperations *ops);
+
+/**
+ * Sets the priority of the connection
+ *
+ * @param [in] ops The connection implementation.
+ * @param [in] state New state to set (uint32_t).
+ */
+void ioOperations_SetPriority(IoOperations *ops, uint32_t priority);
+#endif /* WITH_POLICY */
+
/**
* Sets the interface name associated to the connection.
*
diff --git a/hicn-light/src/hicn/io/streamConnection.c b/hicn-light/src/hicn/io/streamConnection.c
index 4e2f9c37e..27ec45d48 100644
--- a/hicn-light/src/hicn/io/streamConnection.c
+++ b/hicn-light/src/hicn/io/streamConnection.c
@@ -66,6 +66,9 @@ typedef struct stream_state {
* but it is currently not reachable from within the implementation. */
connection_state_t state;
connection_state_t admin_state;
+#ifdef WITH_POLICY
+ uint32_t priority;
+#endif /* WITH_POLICY */
} _StreamState;
// Prototypes
@@ -91,6 +94,10 @@ static connection_state_t _streamConnection_getState(const IoOperations *ops);
static void _streamConnection_setState(IoOperations *ops, connection_state_t state);
static connection_state_t _streamConnection_getAdminState(const IoOperations *ops);
static void _streamConnection_setAdminState(IoOperations *ops, connection_state_t admin_state);
+#ifdef WITH_POLICY
+static uint32_t _streamConnection_getPriority(const IoOperations *ops);
+static void _streamConnection_setPriority(IoOperations *ops, uint32_t priority);
+#endif /* WITH_POLICY */
static const char * _streamConnection_getInterfaceName(const IoOperations *ops);
/*
@@ -123,6 +130,10 @@ static IoOperations _template = {
.setState = &_streamConnection_setState,
.getAdminState = &_streamConnection_getAdminState,
.setAdminState = &_streamConnection_setAdminState,
+#ifdef WITH_POLICY
+ .getPriority = &_streamConnection_getPriority,
+ .setPriority = &_streamConnection_setPriority,
+#endif /* WITH_POLICY */
.getInterfaceName = &_streamConnection_getInterfaceName,
};
@@ -147,6 +158,10 @@ IoOperations *streamConnection_AcceptConnection(Forwarder *forwarder, int fd,
stream->addressPair = pair;
stream->isClosed = false;
+#ifdef WITH_POLICY
+ stream->priority = 0;
+#endif /* WITH_POLICY */
+
// allocate a connection
IoOperations *io_ops = parcMemory_AllocateAndClear(sizeof(IoOperations));
parcAssertNotNull(io_ops, "parcMemory_AllocateAndClear(%zu) returned NULL",
@@ -736,6 +751,22 @@ static void _streamConnection_setAdminState(IoOperations *ops, connection_state_
stream->admin_state = admin_state;
}
+#ifdef WITH_POLICY
+static uint32_t _streamConnection_getPriority(const IoOperations *ops) {
+ parcAssertNotNull(ops, "Parameter must be non-null");
+ const _StreamState *stream =
+ (const _StreamState *)ioOperations_GetClosure(ops);
+ return stream->priority;
+}
+
+static void _streamConnection_setPriority(IoOperations *ops, uint32_t priority) {
+ parcAssertNotNull(ops, "Parameter must be non-null");
+ _StreamState *stream =
+ (_StreamState *)ioOperations_GetClosure(ops);
+ stream->priority = priority;
+}
+#endif /* WITH_POLICY */
+
static const char * _streamConnection_getInterfaceName(const IoOperations *ops)
{
parcAssertNotNull(ops, "Parameter must be non-null");
diff --git a/hicn-light/src/hicn/io/udpConnection.c b/hicn-light/src/hicn/io/udpConnection.c
index 9ad70403f..4e29eba7d 100644
--- a/hicn-light/src/hicn/io/udpConnection.c
+++ b/hicn-light/src/hicn/io/udpConnection.c
@@ -63,6 +63,9 @@ typedef struct udp_state {
* but it is currently not reachable from within the implementation. */
connection_state_t state;
connection_state_t admin_state;
+#ifdef WITH_POLICY
+ uint32_t priority;
+#endif /* WITH_POLICY */
} _UdpState;
// Prototypes
@@ -82,6 +85,10 @@ 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);
+#ifdef WITH_POLICY
+static uint32_t _getPriority(const IoOperations *ops);
+static void _setPriority(IoOperations *ops, uint32_t priority);
+#endif /* WITH_POLICY */
static const char * _getInterfaceName(const IoOperations *ops);
/*
@@ -114,6 +121,10 @@ static IoOperations _template = {
.setState = &_setState,
.getAdminState = &_getAdminState,
.setAdminState = &_setAdminState,
+#ifdef WITH_POLICY
+ .getPriority = &_getPriority,
+ .setPriority = &_setPriority,
+#endif /* WITH_POLICY */
.getInterfaceName = &_getInterfaceName,
};
@@ -151,6 +162,10 @@ IoOperations *udpConnection_Create(Forwarder *forwarder, const char * interfaceN
_setConnectionState(udpConnState, true);
+#ifdef WITH_POLICY
+ udpConnState->priority = 0;
+#endif /* WITH_POLICY */
+
if (logger_IsLoggable(udpConnState->logger, LoggerFacility_IO,
PARCLogLevel_Info)) {
char *str = addressPair_ToString(udpConnState->addressPair);
@@ -443,6 +458,22 @@ static void _setAdminState(IoOperations *ops, connection_state_t admin_state) {
udpConnState->admin_state = admin_state;
}
+#ifdef WITH_POLICY
+static uint32_t _getPriority(const IoOperations *ops) {
+ parcAssertNotNull(ops, "Parameter must be non-null");
+ const _UdpState *udpConnState =
+ (const _UdpState *)ioOperations_GetClosure(ops);
+ return udpConnState->priority;
+}
+
+static void _setPriority(IoOperations *ops, uint32_t priority) {
+ parcAssertNotNull(ops, "Parameter must be non-null");
+ _UdpState *udpConnState =
+ (_UdpState *)ioOperations_GetClosure(ops);
+ udpConnState->priority = priority;
+}
+#endif /* WITH_POLICY */
+
static const char * _getInterfaceName(const IoOperations *ops)
{
parcAssertNotNull(ops, "Parameter must be non-null");