diff options
author | Mauro Sardara <msardara@cisco.com> | 2019-02-11 10:44:29 +0100 |
---|---|---|
committer | Mauro Sardara <msardara@cisco.com> | 2019-02-18 10:48:38 +0000 |
commit | 79e0d4f89c4d532189aae06cc5dfbc14e3269703 (patch) | |
tree | adc83eccb824c019c3c43cc48bcd4de6656eea8d /hicn-light/src/config | |
parent | 7d2b217bd01a8da1a2ac57aaad59b3179c7af916 (diff) |
[HICN-50] Added udp application connector.
Change-Id: I0c5afad4b404ec485f50b1342b81e70ef85a5163
Signed-off-by: Mauro Sardara <msardara@cisco.com>
Signed-off-by: michele papalini <micpapal@cisco.com>
Diffstat (limited to 'hicn-light/src/config')
-rw-r--r-- | hicn-light/src/config/configuration.c | 24 | ||||
-rw-r--r-- | hicn-light/src/config/configurationListeners.c | 21 | ||||
-rw-r--r-- | hicn-light/src/config/configurationListeners.h | 3 |
3 files changed, 32 insertions, 16 deletions
diff --git a/hicn-light/src/config/configuration.c b/hicn-light/src/config/configuration.c index 1a41a9642..865dbca4d 100644 --- a/hicn-light/src/config/configuration.c +++ b/hicn-light/src/config/configuration.c @@ -115,7 +115,7 @@ struct iovec *configuration_ProcessRegisterHicnPrefix(Configuration *config, const char *symbolicOrConnid = control->symbolicOrConnid; - if (strcmp(symbolicOrConnid, "SELF_ROUTE") == 0) { + if (strcmp(symbolicOrConnid, "SELF") == 0) { success = forwarder_AddOrUpdateRoute(config->forwarder, control, ingressId); } else if (utils_IsNumber(symbolicOrConnid)) { // case for connid as input @@ -304,11 +304,14 @@ static void configuration_SendResponse(Configuration *config, struct iovec *msg, ConnectionTable *connectionTable = forwarder_GetConnectionTable(config->forwarder); const Connection *conn = connectionTable_FindById(connectionTable, egressId); - parcAssertNotNull(conn, - "Got null connection for control message we just received"); - IoOperations *ops = connection_GetIoOperations(conn); - streamState_SendCommandResponse(ops, msg); + if (conn == NULL) { + return; + } + + connection_SendCommandResponse(conn, msg); + //IoOperations *ops = connection_GetIoOperations(conn); + //streamState_SendCommandResponse(ops, msg); } struct iovec *configuration_ProcessCreateTunnel(Configuration *config, @@ -425,7 +428,8 @@ struct iovec *configuration_ProcessCreateTunnel(Configuration *config, */ struct iovec *configuration_ProcessRemoveTunnel(Configuration *config, - struct iovec *request) { + struct iovec *request, + unsigned ingressId) { header_control_message *header = request[0].iov_base; remove_connection_command *control = request[1].iov_base; @@ -434,7 +438,11 @@ struct iovec *configuration_ProcessRemoveTunnel(Configuration *config, const char *symbolicOrConnid = control->symbolicOrConnid; ConnectionTable *table = forwarder_GetConnectionTable(config->forwarder); - if (utils_IsNumber(symbolicOrConnid)) { + if (strcmp(symbolicOrConnid, "SELF") == 0) { + forwarder_RemoveConnectionIdFromRoutes(config->forwarder, ingressId); + connectionTable_RemoveById(table, ingressId); + success = true; + } else if (utils_IsNumber(symbolicOrConnid)) { // case for connid as input unsigned connid = (unsigned)strtold(symbolicOrConnid, NULL); @@ -997,7 +1005,7 @@ struct iovec *configuration_DispatchCommand(Configuration *config, break; case REMOVE_CONNECTION: - response = configuration_ProcessRemoveTunnel(config, control); + response = configuration_ProcessRemoveTunnel(config, control, ingressId); break; case REMOVE_ROUTE: diff --git a/hicn-light/src/config/configurationListeners.c b/hicn-light/src/config/configurationListeners.c index 01ab9a3e7..11276e2dd 100644 --- a/hicn-light/src/config/configurationListeners.c +++ b/hicn-light/src/config/configurationListeners.c @@ -217,7 +217,7 @@ static bool _setupTcpListenerOnInet(Forwarder *forwarder, ipv4_addr_t *addr4, struct sockaddr_in addr; memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; - addr.sin_port = *port; + addr.sin_port = htons(*port); addr.sin_addr.s_addr = *addr4; ListenerOps *ops = tcpListener_CreateInet(forwarder, addr); @@ -231,12 +231,13 @@ static bool _setupTcpListenerOnInet(Forwarder *forwarder, ipv4_addr_t *addr4, static bool _setupUdpListenerOnInet(Forwarder *forwarder, ipv4_addr_t *addr4, uint16_t *port) { + bool success = false; struct sockaddr_in addr; memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; - addr.sin_port = *port; + addr.sin_port = htons(*port); addr.sin_addr.s_addr = *addr4; ListenerOps *ops = udpListener_CreateInet(forwarder, addr); @@ -256,7 +257,7 @@ static bool _setupTcpListenerOnInet6Light(Forwarder *forwarder, struct sockaddr_in6 addr; memset(&addr, 0, sizeof(addr)); addr.sin6_family = AF_INET6; - addr.sin6_port = *port; + addr.sin6_port = htons(*port); addr.sin6_addr = *addr6; addr.sin6_scope_id = scopeId; @@ -276,7 +277,7 @@ static bool _setupUdpListenerOnInet6Light(Forwarder *forwarder, struct sockaddr_in6 addr; memset(&addr, 0, sizeof(addr)); addr.sin6_family = AF_INET6; - addr.sin6_port = *port; + addr.sin6_port = htons(*port); addr.sin6_addr = *addr6; addr.sin6_scope_id = 0; @@ -529,9 +530,13 @@ void configurationListeners_SetupAll(const Configuration *config, uint16_t port, } } - // if (localPath != NULL) { - // _setupLocalListener(forwarder, localPath); - //} - interfaceSetDestroy(&set); } + +void configurationListeners_SetutpLocalIPv4(const Configuration *config, + uint16_t port) { + Forwarder *forwarder = configuration_GetForwarder(config); + in_addr_t addr = inet_addr("127.0.0.1"); + _setupUdpListenerOnInet(forwarder, (ipv4_addr_t *) &(addr), &port); + _setupTcpListenerOnInet(forwarder, (ipv4_addr_t *) &(addr), &port); +} diff --git a/hicn-light/src/config/configurationListeners.h b/hicn-light/src/config/configurationListeners.h index 7332b0c64..c97617d81 100644 --- a/hicn-light/src/config/configurationListeners.h +++ b/hicn-light/src/config/configurationListeners.h @@ -47,6 +47,9 @@ void configurationListeners_SetupAll(const Configuration *config, uint16_t port, const char *localPath); +void configurationListeners_SetutpLocalIPv4(const Configuration *config, + uint16_t port); + bool configurationListeners_Remove(const Configuration *config); // light functions |