diff options
author | 2019-01-31 18:20:48 +0100 | |
---|---|---|
committer | 2019-02-01 15:23:03 +0100 | |
commit | f5a0b8a5e24cede05e15ab696f0e15257a503525 (patch) | |
tree | 8cab87196baf7ea5468cebc4002da45175d91ae8 /hicn-light/src/config | |
parent | bf29f9a52ffa3a1f32f700e4fd36ea53885d83aa (diff) |
[HICN24] Windows compatibility for hicn-light
Change-Id: I8e19e52c9b4ec0fcbd7344c28765f5da1937569c
Signed-off-by: Angelo Mantellini <manangel@cisco.com>
Diffstat (limited to 'hicn-light/src/config')
38 files changed, 68 insertions, 67 deletions
diff --git a/hicn-light/src/config/commandOps.c b/hicn-light/src/config/commandOps.c index 027c86e0a..2f7ebe49d 100644 --- a/hicn-light/src/config/commandOps.c +++ b/hicn-light/src/config/commandOps.c @@ -14,14 +14,10 @@ */ #include <src/config.h> - #include <stdbool.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> -#include <strings.h> - -#include <parc/assert/parc_Assert.h> #include <string.h> #ifndef __ANDROID__ @@ -33,7 +29,7 @@ extern int errno; #endif #include <parc/algol/parc_Memory.h> - +#include <parc/assert/parc_Assert.h> #include <src/config/commandOps.h> #include <src/config/commandParser.h> diff --git a/hicn-light/src/config/commandParser.c b/hicn-light/src/config/commandParser.c index 84d273c9d..9a947d8b7 100644 --- a/hicn-light/src/config/commandParser.c +++ b/hicn-light/src/config/commandParser.c @@ -15,13 +15,11 @@ #include <src/config.h> +#include <parc/assert/parc_Assert.h> #include <stdbool.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> -#include <strings.h> - -#include <parc/assert/parc_Assert.h> #include <string.h> #include <parc/security/parc_Security.h> @@ -124,11 +122,13 @@ static PARCList *parseStringIntoTokens(const char *originalString) { char *tofree = parcMemory_StringDuplicate(originalString, strlen(originalString) + 1); char *string = tofree; - - while ((token = strsep(&string, " \t\n")) != NULL) { + + token = strtok(string, " \t\n"); + while (token != NULL) { if (strlen(token) > 0) { parcList_Add(list, strdup(token)); } + token = strtok(NULL, " \t\n"); } parcMemory_Deallocate((void **)&tofree); diff --git a/hicn-light/src/config/configuration.c b/hicn-light/src/config/configuration.c index 737605932..71616cd78 100644 --- a/hicn-light/src/config/configuration.c +++ b/hicn-light/src/config/configuration.c @@ -20,14 +20,17 @@ * <#example#> * @endcode */ + +#ifndef _WIN32 #include <arpa/inet.h> +#include <unistd.h> +#endif #include <ctype.h> #include <parc/assert/parc_Assert.h> #include <src/config.h> #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <unistd.h> #include <parc/algol/parc_HashMap.h> #include <parc/algol/parc_Memory.h> @@ -364,11 +367,11 @@ struct iovec *configuration_ProcessCreateTunnel(Configuration *config, logger_Log(config->logger, LoggerFacility_Config, PARCLogLevel_Error, __func__, "Unsupported tunnel protocol: GRE"); break; -#ifndef __APPLE__ +#if !defined(__APPLE__) && !defined(_WIN32) case HICN_CONN: ops = hicnTunnel_Create(config->forwarder, source, destination); break; -#endif /* __APPLE__ */ +#endif /* __APPLE__ _WIN32*/ default: logger_Log(config->logger, LoggerFacility_Config, PARCLogLevel_Error, __func__, "Unsupported tunnel protocol: %d", diff --git a/hicn-light/src/config/configuration.h b/hicn-light/src/config/configuration.h index 2bf66c0b1..4dfcb0d16 100644 --- a/hicn-light/src/config/configuration.h +++ b/hicn-light/src/config/configuration.h @@ -26,8 +26,8 @@ #ifndef configuration_h #define configuration_h -#include <src/utils/commands.h> #include <src/core/logger.h> +#include <src/utils/commands.h> struct configuration; typedef struct configuration Configuration; diff --git a/hicn-light/src/config/configurationFile.c b/hicn-light/src/config/configurationFile.c index eab8f9362..3facf5afe 100644 --- a/hicn-light/src/config/configurationFile.c +++ b/hicn-light/src/config/configurationFile.c @@ -13,12 +13,14 @@ * limitations under the License. */ +#ifndef _WIN32 +#include <unistd.h> +#endif #include <ctype.h> #include <errno.h> #include <src/config.h> #include <stdio.h> #include <string.h> -#include <unistd.h> #include <parc/algol/parc_ArrayList.h> #include <parc/algol/parc_List.h> @@ -157,9 +159,16 @@ static PARCList *_parseArgs(char *str) { const char delimiters[] = " \t"; char *token; - while ((token = strsep(&str, delimiters)) != NULL) { - parcList_Add(list, token); + token = strtok(str, delimiters); + while (token != NULL) { + if (strlen(token) > 0) { + parcList_Add(list, strdup(token)); + } + token = strtok(NULL, delimiters); } + // while ((token = strsep(&str, delimiters)) != NULL) { + // parcList_Add(list, token); + // } return list; } diff --git a/hicn-light/src/config/configurationListeners.c b/hicn-light/src/config/configurationListeners.c index 0982a2b13..01ab9a3e7 100644 --- a/hicn-light/src/config/configurationListeners.c +++ b/hicn-light/src/config/configurationListeners.c @@ -13,13 +13,15 @@ * limitations under the License. */ +#ifndef _WIN32 #include <arpa/inet.h> +#include <unistd.h> +#endif #include <parc/assert/parc_Assert.h> #include <src/config.h> #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <unistd.h> #include <parc/algol/parc_Memory.h> #include <parc/algol/parc_Network.h> @@ -40,7 +42,7 @@ static bool _setupHicnListenerOnInet4(Forwarder *forwarder, const char *symbolic, Address *address) { bool success = false; -#ifndef __APPLE__ +#if !defined(__APPLE__) && !defined(_WIN32) ListenerOps *ops = hicnListener_CreateInet(forwarder, (char *)symbolic, address); if (ops != NULL) { @@ -48,14 +50,14 @@ static bool _setupHicnListenerOnInet4(Forwarder *forwarder, parcAssertTrue(success, "Failed to add Hicn listener %s to ListenerSet", symbolic); } -#endif /* __APPLE__ */ +#endif /* __APPLE__ _WIN32*/ return success; } static bool _setupHicnListenerOnInet6(Forwarder *forwarder, const char *symbolic, Address *address) { bool success = false; -#ifndef __APPLE__ +#if !defined(__APPLE__) && !defined(_WIN32) ListenerOps *ops = hicnListener_CreateInet6(forwarder, (char *)symbolic, address); if (ops != NULL) { @@ -63,7 +65,7 @@ static bool _setupHicnListenerOnInet6(Forwarder *forwarder, parcAssertTrue(success, "Failed to add Hicn listener %s to ListenerSet", symbolic); } -#endif /* __APPLE__ */ +#endif /* __APPLE__ _WIN32 */ return success; } @@ -79,7 +81,7 @@ bool configurationListeners_Remove(const Configuration *config) { bool _AddPuntingInet(const Configuration *config, Punting *punting, unsigned ingressId) { -#ifndef __APPLE__ +#if !defined(__APPLE__) && !defined(_WIN32) struct sockaddr *addr = parcNetwork_SockAddress("0.0.0.0", 1234); if (addr == NULL) { printf("Error creating address\n"); @@ -139,7 +141,7 @@ bool _AddPuntingInet(const Configuration *config, Punting *punting, bool _AddPuntingInet6(const Configuration *config, Punting *punting, unsigned ingressId) { -#ifndef __APPLE__ +#if !defined(__APPLE__) && !defined(_WIN32) struct sockaddr *addr = parcNetwork_SockAddress("0::0", 1234); if (addr == NULL) { printf("Error creating address\n"); @@ -149,9 +151,9 @@ bool _AddPuntingInet6(const Configuration *config, Punting *punting, Address *fakeAddr = addressCreateFromInet6((struct sockaddr_in6 *)addr); // comments: - // EncapType: I use the Hicn encap since the punting is available only for Hicn - // listeners LocalAddress: The only listern for which we need punting rules is - // the main one, which has no address + // EncapType: I use the Hicn encap since the punting is available only for + // Hicn listeners LocalAddress: The only listern for which we need punting + // rules is the main one, which has no address // so I create a fake empty address. This need to be consistent // with the address set at creation time diff --git a/hicn-light/src/config/controlAdd.c b/hicn-light/src/config/controlAdd.c index 72f8e9759..7feee98ad 100644 --- a/hicn-light/src/config/controlAdd.c +++ b/hicn-light/src/config/controlAdd.c @@ -20,7 +20,6 @@ #include <stdint.h> #include <stdio.h> #include <stdlib.h> -#include <strings.h> #include <parc/algol/parc_Memory.h> diff --git a/hicn-light/src/config/controlAddConnection.c b/hicn-light/src/config/controlAddConnection.c index 0603e37a5..7a95e5d91 100644 --- a/hicn-light/src/config/controlAddConnection.c +++ b/hicn-light/src/config/controlAddConnection.c @@ -21,7 +21,6 @@ #include <stdint.h> #include <stdio.h> #include <stdlib.h> -#include <strings.h> #include <parc/algol/parc_Memory.h> #include <parc/algol/parc_Network.h> diff --git a/hicn-light/src/config/controlAddListener.c b/hicn-light/src/config/controlAddListener.c index 8f687c3a6..2cabfd035 100644 --- a/hicn-light/src/config/controlAddListener.c +++ b/hicn-light/src/config/controlAddListener.c @@ -21,7 +21,6 @@ #include <stdint.h> #include <stdio.h> #include <stdlib.h> -#include <strings.h> #include <parc/assert/parc_Assert.h> diff --git a/hicn-light/src/config/controlAddPunting.c b/hicn-light/src/config/controlAddPunting.c index bd87e517c..13d00b7e0 100644 --- a/hicn-light/src/config/controlAddPunting.c +++ b/hicn-light/src/config/controlAddPunting.c @@ -20,7 +20,6 @@ #include <stdint.h> #include <stdio.h> #include <stdlib.h> -#include <strings.h> #include <parc/assert/parc_Assert.h> @@ -93,7 +92,7 @@ static CommandReturn _controlAddPunting_Execute(CommandParser *parser, } const char *prefixStr = parcList_GetAtIndex(args, _indexPrefix); - char addr[strlen(prefixStr) + 1]; + char *addr = (char *)malloc((strlen(prefixStr) + 1) * sizeof(char)); // separate address and len char *slash; @@ -107,6 +106,7 @@ static CommandReturn _controlAddPunting_Execute(CommandParser *parser, if (len == 0) { printf("ERROR: a prefix can not be of length 0\n"); + free(addr); return CommandReturn_Failure; } @@ -119,6 +119,7 @@ static CommandReturn _controlAddPunting_Execute(CommandParser *parser, if (len > 32) { printf("ERROR: exceeded INET mask length, max=32\n"); parcMemory_Deallocate(&addPuntingCommand); + free(addr); return CommandReturn_Failure; } addPuntingCommand->addressType = ADDR_INET; @@ -126,15 +127,19 @@ static CommandReturn _controlAddPunting_Execute(CommandParser *parser, if (len > 128) { printf("ERROR: exceeded INET6 mask length, max=128\n"); parcMemory_Deallocate(&addPuntingCommand); + free(addr); return CommandReturn_Failure; } addPuntingCommand->addressType = ADDR_INET6; } else { printf("Error: %s is not a valid network address \n", addr); parcMemory_Deallocate(&addPuntingCommand); + free(addr); return CommandReturn_Failure; } + free(addr); + // Fill remaining payload fields addPuntingCommand->len = len; strcpy(addPuntingCommand->symbolicOrConnid, symbolicOrConnid); diff --git a/hicn-light/src/config/controlAddRoute.c b/hicn-light/src/config/controlAddRoute.c index c5ddab523..27aae4019 100644 --- a/hicn-light/src/config/controlAddRoute.c +++ b/hicn-light/src/config/controlAddRoute.c @@ -20,7 +20,6 @@ #include <stdint.h> #include <stdio.h> #include <stdlib.h> -#include <strings.h> #include <parc/assert/parc_Assert.h> @@ -97,7 +96,7 @@ static CommandReturn _controlAddRoute_Execute(CommandParser *parser, } const char *prefixStr = parcList_GetAtIndex(args, 3); - char addr[strlen(prefixStr) + 1]; + char *addr = (char *)malloc((strlen(prefixStr) + 1) * sizeof(char)); // separate address and len char *slash; @@ -111,6 +110,7 @@ static CommandReturn _controlAddRoute_Execute(CommandParser *parser, if (len == 0) { printf("ERROR: a prefix can not be of length 0\n"); + free(addr); return CommandReturn_Failure; } @@ -123,6 +123,7 @@ static CommandReturn _controlAddRoute_Execute(CommandParser *parser, if (len > 32) { printf("ERROR: exceeded INET mask length, max=32\n"); parcMemory_Deallocate(&addRouteCommand); + free(addr); return CommandReturn_Failure; } addRouteCommand->addressType = ADDR_INET; @@ -130,15 +131,19 @@ static CommandReturn _controlAddRoute_Execute(CommandParser *parser, if (len > 128) { printf("ERROR: exceeded INET6 mask length, max=128\n"); parcMemory_Deallocate(&addRouteCommand); + free(addr); return CommandReturn_Failure; } addRouteCommand->addressType = ADDR_INET6; } else { printf("Error: %s is not a valid network address \n", addr); parcMemory_Deallocate(&addRouteCommand); + free(addr); return CommandReturn_Failure; } + free(addr); + // Fill remaining payload fields addRouteCommand->len = len; addRouteCommand->cost = (uint16_t)cost; diff --git a/hicn-light/src/config/controlCache.c b/hicn-light/src/config/controlCache.c index d7afbfe7d..e8d19e828 100644 --- a/hicn-light/src/config/controlCache.c +++ b/hicn-light/src/config/controlCache.c @@ -19,7 +19,6 @@ #include <stdint.h> #include <stdio.h> #include <stdlib.h> -#include <strings.h> #include <parc/assert/parc_Assert.h> diff --git a/hicn-light/src/config/controlCacheClear.c b/hicn-light/src/config/controlCacheClear.c index c5a4e9fde..2679f368e 100644 --- a/hicn-light/src/config/controlCacheClear.c +++ b/hicn-light/src/config/controlCacheClear.c @@ -19,7 +19,6 @@ #include <stdint.h> #include <stdio.h> #include <stdlib.h> -#include <strings.h> #include <parc/assert/parc_Assert.h> diff --git a/hicn-light/src/config/controlCacheServe.c b/hicn-light/src/config/controlCacheServe.c index 85d598025..9181810dd 100644 --- a/hicn-light/src/config/controlCacheServe.c +++ b/hicn-light/src/config/controlCacheServe.c @@ -19,7 +19,6 @@ #include <stdint.h> #include <stdio.h> #include <stdlib.h> -#include <strings.h> #include <parc/assert/parc_Assert.h> diff --git a/hicn-light/src/config/controlCacheStore.c b/hicn-light/src/config/controlCacheStore.c index 3bbb34386..d586188fb 100644 --- a/hicn-light/src/config/controlCacheStore.c +++ b/hicn-light/src/config/controlCacheStore.c @@ -19,7 +19,6 @@ #include <stdint.h> #include <stdio.h> #include <stdlib.h> -#include <strings.h> #include <parc/assert/parc_Assert.h> diff --git a/hicn-light/src/config/controlList.c b/hicn-light/src/config/controlList.c index 8afaa60dc..7e4636b00 100644 --- a/hicn-light/src/config/controlList.c +++ b/hicn-light/src/config/controlList.c @@ -19,7 +19,6 @@ #include <stdint.h> #include <stdio.h> #include <stdlib.h> -#include <strings.h> #include <parc/assert/parc_Assert.h> diff --git a/hicn-light/src/config/controlListConnections.c b/hicn-light/src/config/controlListConnections.c index 474ddc45f..b7dda0bbe 100644 --- a/hicn-light/src/config/controlListConnections.c +++ b/hicn-light/src/config/controlListConnections.c @@ -19,7 +19,6 @@ #include <stdint.h> #include <stdio.h> #include <stdlib.h> -#include <strings.h> #include <parc/assert/parc_Assert.h> diff --git a/hicn-light/src/config/controlListInterfaces.c b/hicn-light/src/config/controlListInterfaces.c index 20338b553..914cc3552 100644 --- a/hicn-light/src/config/controlListInterfaces.c +++ b/hicn-light/src/config/controlListInterfaces.c @@ -19,7 +19,6 @@ #include <stdint.h> #include <stdio.h> #include <stdlib.h> -#include <strings.h> #include <parc/assert/parc_Assert.h> diff --git a/hicn-light/src/config/controlListListeners.c b/hicn-light/src/config/controlListListeners.c index a149051e2..e84912205 100644 --- a/hicn-light/src/config/controlListListeners.c +++ b/hicn-light/src/config/controlListListeners.c @@ -19,7 +19,6 @@ #include <stdint.h> #include <stdio.h> #include <stdlib.h> -#include <strings.h> #include <parc/algol/parc_Memory.h> #include <parc/assert/parc_Assert.h> diff --git a/hicn-light/src/config/controlListRoutes.c b/hicn-light/src/config/controlListRoutes.c index 4a21b5ef4..ba116ce76 100644 --- a/hicn-light/src/config/controlListRoutes.c +++ b/hicn-light/src/config/controlListRoutes.c @@ -19,7 +19,6 @@ #include <stdint.h> #include <stdio.h> #include <stdlib.h> -#include <strings.h> #include <parc/assert/parc_Assert.h> diff --git a/hicn-light/src/config/controlMapMe.c b/hicn-light/src/config/controlMapMe.c index 2253f52b6..a839a9173 100644 --- a/hicn-light/src/config/controlMapMe.c +++ b/hicn-light/src/config/controlMapMe.c @@ -19,7 +19,6 @@ #include <stdint.h> #include <stdio.h> #include <stdlib.h> -#include <strings.h> #include <parc/algol/parc_Memory.h> #include <parc/assert/parc_Assert.h> diff --git a/hicn-light/src/config/controlMapMeDiscovery.c b/hicn-light/src/config/controlMapMeDiscovery.c index f8f4bf082..fd10cf18e 100644 --- a/hicn-light/src/config/controlMapMeDiscovery.c +++ b/hicn-light/src/config/controlMapMeDiscovery.c @@ -19,7 +19,6 @@ #include <stdint.h> #include <stdio.h> #include <stdlib.h> -#include <strings.h> #include <parc/algol/parc_Memory.h> #include <parc/assert/parc_Assert.h> diff --git a/hicn-light/src/config/controlMapMeEnable.c b/hicn-light/src/config/controlMapMeEnable.c index db77450e5..587aa6eb6 100644 --- a/hicn-light/src/config/controlMapMeEnable.c +++ b/hicn-light/src/config/controlMapMeEnable.c @@ -19,7 +19,6 @@ #include <stdint.h> #include <stdio.h> #include <stdlib.h> -#include <strings.h> #include <parc/algol/parc_Memory.h> #include <parc/assert/parc_Assert.h> diff --git a/hicn-light/src/config/controlMapMeRetx.c b/hicn-light/src/config/controlMapMeRetx.c index bb16b8833..21541d837 100644 --- a/hicn-light/src/config/controlMapMeRetx.c +++ b/hicn-light/src/config/controlMapMeRetx.c @@ -19,7 +19,6 @@ #include <stdint.h> #include <stdio.h> #include <stdlib.h> -#include <strings.h> #include <parc/algol/parc_Memory.h> #include <parc/assert/parc_Assert.h> diff --git a/hicn-light/src/config/controlMapMeTimescale.c b/hicn-light/src/config/controlMapMeTimescale.c index 9303b4b0f..872a50abc 100644 --- a/hicn-light/src/config/controlMapMeTimescale.c +++ b/hicn-light/src/config/controlMapMeTimescale.c @@ -19,7 +19,6 @@ #include <stdint.h> #include <stdio.h> #include <stdlib.h> -#include <strings.h> #include <parc/algol/parc_Memory.h> #include <parc/assert/parc_Assert.h> diff --git a/hicn-light/src/config/controlQuit.c b/hicn-light/src/config/controlQuit.c index 635fe278f..6df163c49 100644 --- a/hicn-light/src/config/controlQuit.c +++ b/hicn-light/src/config/controlQuit.c @@ -19,7 +19,6 @@ #include <stdint.h> #include <stdio.h> #include <stdlib.h> -#include <strings.h> #include <parc/assert/parc_Assert.h> diff --git a/hicn-light/src/config/controlRemove.c b/hicn-light/src/config/controlRemove.c index ede075a1b..da4b69fd9 100644 --- a/hicn-light/src/config/controlRemove.c +++ b/hicn-light/src/config/controlRemove.c @@ -19,7 +19,6 @@ #include <stdint.h> #include <stdio.h> #include <stdlib.h> -#include <strings.h> #include <parc/assert/parc_Assert.h> diff --git a/hicn-light/src/config/controlRemoveConnection.c b/hicn-light/src/config/controlRemoveConnection.c index 93365ad17..c701fc77f 100644 --- a/hicn-light/src/config/controlRemoveConnection.c +++ b/hicn-light/src/config/controlRemoveConnection.c @@ -20,7 +20,6 @@ #include <stdint.h> #include <stdio.h> #include <stdlib.h> -#include <strings.h> #include <parc/assert/parc_Assert.h> diff --git a/hicn-light/src/config/controlRemovePunting.c b/hicn-light/src/config/controlRemovePunting.c index cf4c4fbd4..0ae80ec9b 100644 --- a/hicn-light/src/config/controlRemovePunting.c +++ b/hicn-light/src/config/controlRemovePunting.c @@ -20,7 +20,6 @@ #include <stdint.h> #include <stdio.h> #include <stdlib.h> -#include <strings.h> #include <parc/assert/parc_Assert.h> diff --git a/hicn-light/src/config/controlRemoveRoute.c b/hicn-light/src/config/controlRemoveRoute.c index b9b4ed1e4..f654718f8 100644 --- a/hicn-light/src/config/controlRemoveRoute.c +++ b/hicn-light/src/config/controlRemoveRoute.c @@ -20,10 +20,7 @@ #include <stdint.h> #include <stdio.h> #include <stdlib.h> -#include <strings.h> - #include <parc/assert/parc_Assert.h> - #include <parc/algol/parc_List.h> #include <parc/algol/parc_Memory.h> #include <parc/algol/parc_Network.h> @@ -90,7 +87,7 @@ static CommandReturn _controlRemoveRoute_Execute(CommandParser *parser, } const char *prefixStr = parcList_GetAtIndex(args, 3); - char addr[strlen(prefixStr) + 1]; + char *addr = (char *)malloc(sizeof(char) * (strlen(prefixStr) + 1)); // separate address and len char *slash; @@ -104,6 +101,7 @@ static CommandReturn _controlRemoveRoute_Execute(CommandParser *parser, if (len == 0) { printf("ERROR: a prefix can not be of length 0\n"); + free(addr); return CommandReturn_Failure; } @@ -116,6 +114,7 @@ static CommandReturn _controlRemoveRoute_Execute(CommandParser *parser, if (len > 32) { printf("ERROR: exceeded INET mask length, max=32\n"); parcMemory_Deallocate(&removeRouteCommand); + free(addr); return CommandReturn_Failure; } removeRouteCommand->addressType = ADDR_INET; @@ -124,15 +123,18 @@ static CommandReturn _controlRemoveRoute_Execute(CommandParser *parser, if (len > 128) { printf("ERROR: exceeded INET6 mask length, max=128\n"); parcMemory_Deallocate(&removeRouteCommand); + free(addr); return CommandReturn_Failure; } removeRouteCommand->addressType = ADDR_INET6; } else { printf("Error: %s is not a valid network address \n", addr); parcMemory_Deallocate(&removeRouteCommand); + free(addr); return CommandReturn_Failure; } + free(addr); // Fill remaining payload fields removeRouteCommand->len = len; strcpy(removeRouteCommand->symbolicOrConnid, symbolicOrConnid); diff --git a/hicn-light/src/config/controlRoot.c b/hicn-light/src/config/controlRoot.c index 5d6c5f98e..49b613208 100644 --- a/hicn-light/src/config/controlRoot.c +++ b/hicn-light/src/config/controlRoot.c @@ -19,7 +19,6 @@ #include <stdint.h> #include <stdio.h> #include <stdlib.h> -#include <strings.h> #include <parc/assert/parc_Assert.h> diff --git a/hicn-light/src/config/controlSet.c b/hicn-light/src/config/controlSet.c index c6fd9aa3e..07ca7e6b0 100644 --- a/hicn-light/src/config/controlSet.c +++ b/hicn-light/src/config/controlSet.c @@ -19,7 +19,6 @@ #include <stdint.h> #include <stdio.h> #include <stdlib.h> -#include <strings.h> #include <parc/assert/parc_Assert.h> diff --git a/hicn-light/src/config/controlSetDebug.c b/hicn-light/src/config/controlSetDebug.c index ca432420e..1739e777a 100644 --- a/hicn-light/src/config/controlSetDebug.c +++ b/hicn-light/src/config/controlSetDebug.c @@ -19,7 +19,6 @@ #include <stdint.h> #include <stdio.h> #include <stdlib.h> -#include <strings.h> #include <parc/assert/parc_Assert.h> diff --git a/hicn-light/src/config/controlSetStrategy.c b/hicn-light/src/config/controlSetStrategy.c index 7b7c11762..579862eeb 100644 --- a/hicn-light/src/config/controlSetStrategy.c +++ b/hicn-light/src/config/controlSetStrategy.c @@ -19,7 +19,6 @@ #include <stdint.h> #include <stdio.h> #include <stdlib.h> -#include <strings.h> #include <parc/assert/parc_Assert.h> @@ -109,7 +108,7 @@ static CommandReturn _controlSetStrategy_Execute(CommandParser *parser, } const char *prefixStr = parcList_GetAtIndex(args, 2); - char addr[strlen(prefixStr) + 1]; + char *addr = (char *)malloc(sizeof(char) * (strlen(prefixStr) + 1)); // separate address and len char *slash; uint32_t len = UINT32_MAX; @@ -121,6 +120,7 @@ static CommandReturn _controlSetStrategy_Execute(CommandParser *parser, } if (len == 0) { printf("ERROR: a prefix can not be of length 0\n"); + free(addr); return CommandReturn_Failure; } @@ -136,6 +136,7 @@ static CommandReturn _controlSetStrategy_Execute(CommandParser *parser, } else if (len > 32) { printf("ERROR: exceeded INET mask length, max=32\n"); parcMemory_Deallocate(&setStrategyCommand); + free(addr); return CommandReturn_Failure; } setStrategyCommand->addressType = ADDR_INET; @@ -147,6 +148,7 @@ static CommandReturn _controlSetStrategy_Execute(CommandParser *parser, } else if (len > 128) { printf("ERROR: exceeded INET6 mask length, max=128\n"); parcMemory_Deallocate(&setStrategyCommand); + free(addr); return CommandReturn_Failure; } setStrategyCommand->addressType = ADDR_INET6; @@ -163,9 +165,12 @@ static CommandReturn _controlSetStrategy_Execute(CommandParser *parser, printf("Error: invalid strategy \n"); parcMemory_Deallocate(&setStrategyCommand); _controlSetStrategy_HelpExecute(parser, ops, args); + free(addr); return CommandReturn_Failure; } + free(addr); + // Fill remaining payload fields setStrategyCommand->len = len; setStrategyCommand->strategyType = strategy; diff --git a/hicn-light/src/config/controlSetWldr.c b/hicn-light/src/config/controlSetWldr.c index 9da404036..7bb055af8 100644 --- a/hicn-light/src/config/controlSetWldr.c +++ b/hicn-light/src/config/controlSetWldr.c @@ -19,7 +19,6 @@ #include <stdint.h> #include <stdio.h> #include <stdlib.h> -#include <strings.h> #include <parc/assert/parc_Assert.h> diff --git a/hicn-light/src/config/controlState.c b/hicn-light/src/config/controlState.c index d8260e8e8..96c0529ed 100644 --- a/hicn-light/src/config/controlState.c +++ b/hicn-light/src/config/controlState.c @@ -19,7 +19,6 @@ #include <stdint.h> #include <stdio.h> #include <stdlib.h> -#include <strings.h> #include <parc/assert/parc_Assert.h> #include <string.h> @@ -66,7 +65,7 @@ int controlState_connectToFwdDeamon() { // Filling server information servaddr.sin_family = AF_INET; servaddr.sin_port = htons(PORT); - servaddr.sin_addr.s_addr = INADDR_ANY; + inet_pton(AF_INET, SRV_IP, &(servaddr.sin_addr.s_addr)); // Establish connection if (connect(sockfd, (struct sockaddr *)&servaddr, sizeof(servaddr)) < 0) { @@ -150,10 +149,12 @@ static PARCList *_controlState_ParseStringIntoTokens( parcMemory_StringDuplicate(originalString, strlen(originalString) + 1); char *string = tofree; - while ((token = strsep(&string, " \t\n")) != NULL) { + token = strtok(string, " \t\n"); + while (token != NULL) { if (strlen(token) > 0) { parcList_Add(list, strdup(token)); } + token = strtok(NULL, " \t\n"); } parcMemory_Deallocate((void **)&tofree); diff --git a/hicn-light/src/config/controlUnset.c b/hicn-light/src/config/controlUnset.c index 2da6a6518..2742940fa 100644 --- a/hicn-light/src/config/controlUnset.c +++ b/hicn-light/src/config/controlUnset.c @@ -19,7 +19,6 @@ #include <stdint.h> #include <stdio.h> #include <stdlib.h> -#include <strings.h> #include <parc/assert/parc_Assert.h> diff --git a/hicn-light/src/config/controlUnsetDebug.c b/hicn-light/src/config/controlUnsetDebug.c index 4892bd513..bf3f6fe68 100644 --- a/hicn-light/src/config/controlUnsetDebug.c +++ b/hicn-light/src/config/controlUnsetDebug.c @@ -19,7 +19,6 @@ #include <stdint.h> #include <stdio.h> #include <stdlib.h> -#include <strings.h> #include <parc/assert/parc_Assert.h> |