From 1fb7b1be452111b9e26a100bc5dfdce266c30330 Mon Sep 17 00:00:00 2001 From: Jordan Augé Date: Thu, 13 Feb 2020 16:50:43 +0100 Subject: [HICN-518] new API in hicn-light to allow a producer to force MAP-Me messages to be resent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I2e17250c5e4f78341966507a4bf04d09b84bb9d0 Signed-off-by: Jordan Augé --- hicn-light/src/hicn/config/configuration.c | 57 ++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 15 deletions(-) (limited to 'hicn-light/src/hicn/config/configuration.c') 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; -- cgit 1.2.3-korg