From 2ada8954ecd3601d115a22696c4c3ab90858cec3 Mon Sep 17 00:00:00 2001 From: Jordan Augé Date: Sun, 17 Nov 2019 00:07:12 +0100 Subject: [HICN-379] Add face priority support in face manager MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: If4f75d44fc66414a4a70135de7827f5082b97112 Signed-off-by: Jordan Augé --- hicn-light/src/hicn/io/hicnConnection.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'hicn-light/src/hicn/io/hicnConnection.c') 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"); -- cgit 1.2.3-korg