aboutsummaryrefslogtreecommitdiffstats
path: root/hicn-light/src/hicn/config/configuration.c
diff options
context:
space:
mode:
authorJordan Augé <jordan.auge+fdio@cisco.com>2020-02-13 16:50:43 +0100
committerJordan Augé <jordan.auge+fdio@cisco.com>2020-02-13 16:57:03 +0100
commit1fb7b1be452111b9e26a100bc5dfdce266c30330 (patch)
treeee67c224ff4ca6f20919032ff1933b07f0b43707 /hicn-light/src/hicn/config/configuration.c
parentf9243a2bf823086404be1c41c7bcc1b27cfab7de (diff)
[HICN-518] new API in hicn-light to allow a producer to force MAP-Me messages to be resent
Change-Id: I2e17250c5e4f78341966507a4bf04d09b84bb9d0 Signed-off-by: Jordan Augé <jordan.auge+fdio@cisco.com>
Diffstat (limited to 'hicn-light/src/hicn/config/configuration.c')
-rw-r--r--hicn-light/src/hicn/config/configuration.c57
1 files changed, 42 insertions, 15 deletions
diff --git a/hicn-light/src/hicn/config/configuration.c b/hicn-light/src/hicn/config/configuration.c
index 509ad10ba..a5be84f32 100644
--- a/hicn-light/src/hicn/config/configuration.c
+++ b/hicn-light/src/hicn/config/configuration.c
@@ -1094,10 +1094,7 @@ struct iovec *configuration_MapMeEnable(Configuration *config,
parcMemory_Deallocate((void **)&result);
parcBufferComposer_Release(&composer);
- struct iovec *response =
- utils_CreateAck(header, control, sizeof(mapme_activator_command));
-
- return response;
+ return utils_CreateAck(header, control, sizeof(mapme_timing_command));
}
struct iovec *configuration_MapMeDiscovery(Configuration *config,
@@ -1118,10 +1115,7 @@ struct iovec *configuration_MapMeDiscovery(Configuration *config,
parcMemory_Deallocate((void **)&result);
parcBufferComposer_Release(&composer);
- struct iovec *response =
- utils_CreateAck(header, control, sizeof(mapme_activator_command));
-
- return response;
+ return utils_CreateAck(header, control, sizeof(mapme_timing_command));
}
struct iovec *configuration_MapMeTimescale(Configuration *config,
@@ -1141,10 +1135,7 @@ struct iovec *configuration_MapMeTimescale(Configuration *config,
parcMemory_Deallocate((void **)&result);
parcBufferComposer_Release(&composer);
- struct iovec *response =
- utils_CreateAck(header, control, sizeof(mapme_timing_command));
-
- return response;
+ return utils_CreateAck(header, control, sizeof(mapme_timing_command));
}
struct iovec *configuration_MapMeRetx(Configuration *config,
@@ -1164,12 +1155,44 @@ struct iovec *configuration_MapMeRetx(Configuration *config,
parcMemory_Deallocate((void **)&result);
parcBufferComposer_Release(&composer);
- struct iovec *response =
- utils_CreateAck(header, control, sizeof(mapme_timing_command));
+ return utils_CreateAck(header, control, sizeof(mapme_timing_command));
+}
- return response;
+struct iovec * configuration_MapMeSendUpdate(Configuration *config,
+ struct iovec *request, unsigned ingressId) {
+ header_control_message *header = request[0].iov_base;
+ mapme_send_update_command *control = request[1].iov_base;
+
+ FIB * fib = forwarder_getFib(config->forwarder);
+ if (!fib)
+ goto ERR;
+ Name *prefix = name_CreateFromAddress(control->addressType, control->address,
+ control->len);
+ if (!prefix)
+ goto ERR;
+ FibEntry *entry = fib_Contains(fib, prefix);
+ name_Release(&prefix);
+ if (!entry)
+ goto ERR;
+
+ const NumberSet * nexthops = fibEntry_GetNexthops(entry);
+ unsigned size = (unsigned) numberSet_Length(nexthops);
+
+ /* The command is accepted iif triggered by (one of) the producer of this prefix */
+ for (unsigned i = 0; i < size; i++) {
+ unsigned nhop = numberSet_GetItem(nexthops, i);
+ if (nhop == ingressId) {
+ MapMe * mapme = forwarder_getMapmeInstance(config->forwarder);
+ mapme_send_updates(mapme, entry, nexthops);
+ return utils_CreateAck(header, control, sizeof(mapme_timing_command));
+ }
+ }
+
+ERR:
+ return utils_CreateNack(header, control, sizeof(connection_set_admin_state_command));
}
+
struct iovec *configuration_ConnectionSetAdminState(Configuration *config,
struct iovec *request) {
header_control_message *header = request[0].iov_base;
@@ -1418,6 +1441,10 @@ struct iovec *configuration_DispatchCommand(Configuration *config,
response = configuration_MapMeRetx(config, control);
break;
+ case MAPME_SEND_UPDATE:
+ response = configuration_MapMeSendUpdate(config, control, ingressId);
+ break;
+
case CONNECTION_SET_ADMIN_STATE:
response = configuration_ConnectionSetAdminState(config, control);
break;