aboutsummaryrefslogtreecommitdiffstats
path: root/hicn-light/src/hicn/strategies/rnd.c
diff options
context:
space:
mode:
authormichele papalini <micpapal@cisco.com>2019-12-10 13:40:16 +0100
committermichele papalini <micpapal@cisco.com>2020-01-21 10:26:25 +0100
commit43980f3096655df2b2ecec50e700dd6989b0e0d6 (patch)
tree1a8e23e6fe645d8d1951b84f14e4123f17d4efe9 /hicn-light/src/hicn/strategies/rnd.c
parentde13ed1c3155f699cb1e322dcd4d64a06ae00bb9 (diff)
[HICN-442] new forwarding strategy
Signed-off-by: michele papalini <micpapal@cisco.com> Change-Id: I62c03bddedc83e523fc60f4b50d2c69e38b50318 Signed-off-by: Angelo Mantellini <angelo.mantellini@cisco.com> Signed-off-by: michele papalini <micpapal@cisco.com>
Diffstat (limited to 'hicn-light/src/hicn/strategies/rnd.c')
-rw-r--r--hicn-light/src/hicn/strategies/rnd.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/hicn-light/src/hicn/strategies/rnd.c b/hicn-light/src/hicn/strategies/rnd.c
index 637fd90f9..064f3965b 100644
--- a/hicn-light/src/hicn/strategies/rnd.c
+++ b/hicn-light/src/hicn/strategies/rnd.c
@@ -28,9 +28,12 @@
static void _strategyRnd_ReceiveObject(StrategyImpl *strategy,
const NumberSet *egressId,
- const Message *objectMessage, Ticks rtt);
+ const Message *objectMessage,
+ Ticks pitEntryCreation,
+ Ticks objReception);
static void _strategyRnd_OnTimeout(StrategyImpl *strategy,
const NumberSet *egressId);
+
static NumberSet *_strategyRnd_LookupNexthop(StrategyImpl *strategy,
#ifdef WITH_POLICY
NumberSet * nexthops,
@@ -62,21 +65,21 @@ static StrategyImpl _template = {
.getStrategy = &_strategyRnd_GetStrategy,
};
+#ifndef WITH_POLICY
struct strategy_rnd;
typedef struct strategy_rnd StrategyRnd;
struct strategy_rnd {
-#ifndef WITH_POLICY
NumberSet *nexthops;
-#endif /* ! WITH_POLICY */
};
+#endif /* ! WITH_POLICY */
StrategyImpl *strategyRnd_Create() {
+#ifndef WITH_POLICY
StrategyRnd *strategy = parcMemory_AllocateAndClear(sizeof(StrategyRnd));
parcAssertNotNull(strategy, "parcMemory_AllocateAndClear(%zu) returned NULL",
sizeof(StrategyRnd));
-#ifndef WITH_POLICY
strategy->nexthops = numberSet_Create();
#endif /* ! WITH_POLICY */
srand((unsigned int)time(NULL));
@@ -85,7 +88,9 @@ StrategyImpl *strategyRnd_Create() {
parcAssertNotNull(impl, "parcMemory_AllocateAndClear(%zu) returned NULL",
sizeof(StrategyImpl));
memcpy(impl, &_template, sizeof(StrategyImpl));
+#ifndef WITH_POLICY
impl->context = strategy;
+#endif /* ! WITH_POLICY */
return impl;
}
@@ -111,7 +116,8 @@ static int _select_Nexthop(StrategyRnd *strategy) {
static void _strategyRnd_ReceiveObject(StrategyImpl *strategy,
const NumberSet *egressId,
const Message *objectMessage,
- Ticks rtt) {}
+ Ticks pitEntryCreation,
+ Ticks objReception) {}
static void _strategyRnd_OnTimeout(StrategyImpl *strategy,
const NumberSet *egressId) {}
@@ -193,13 +199,13 @@ static void _strategyRnd_ImplDestroy(StrategyImpl **strategyPtr) {
"Parameter must dereference to non-null pointer");
StrategyImpl *impl = *strategyPtr;
- StrategyRnd *strategy = (StrategyRnd *)impl->context;
#ifndef WITH_POLICY
+ StrategyRnd *strategy = (StrategyRnd *)impl->context;
numberSet_Release(&(strategy->nexthops));
+ parcMemory_Deallocate((void **)&strategy);
#endif /* ! WITH_POLICY */
- parcMemory_Deallocate((void **)&strategy);
parcMemory_Deallocate((void **)&impl);
*strategyPtr = NULL;
}