summaryrefslogtreecommitdiffstats
path: root/hicn-light/src
diff options
context:
space:
mode:
authorJordan Augé <jordan.auge+fdio@cisco.com>2019-10-23 09:58:42 +0200
committerJordan Augé <jordan.auge+fdio@cisco.com>2019-10-23 15:50:37 +0200
commitb8eca5937fc110e85d426cefba4feff00a20a04a (patch)
treea3790d6b90696bab055719e4223a576597ac7396 /hicn-light/src
parentb689543d557b05e8365733874d38b61421ad3d59 (diff)
[HICN-350] Minor cleanup in control API
Change-Id: I5c3705aa439a1cf6bdca915f82c0c014771cc542 Signed-off-by: Jordan Augé <jordan.auge+fdio@cisco.com>
Diffstat (limited to 'hicn-light/src')
-rw-r--r--hicn-light/src/hicn/config/configuration.c8
-rw-r--r--hicn-light/src/hicn/config/configurationListeners.c10
-rw-r--r--hicn-light/src/hicn/config/controlAddListener.c2
-rw-r--r--hicn-light/src/hicn/config/controlListListeners.c12
-rw-r--r--hicn-light/src/hicn/config/controlRemoveListener.c2
-rw-r--r--hicn-light/src/hicn/utils/commands.h34
6 files changed, 36 insertions, 32 deletions
diff --git a/hicn-light/src/hicn/config/configuration.c b/hicn-light/src/hicn/config/configuration.c
index 2b63a32a0..4771c4073 100644
--- a/hicn-light/src/hicn/config/configuration.c
+++ b/hicn-light/src/hicn/config/configuration.c
@@ -688,10 +688,10 @@ struct iovec *configuration_ProcessConnectionList(Configuration *config,
listConnectionsCommand->connid = connection_GetConnectionId(original);
const char *connectionName = symbolicNameTable_GetNameByIndex(config->symbolicNameTable, connection_GetConnectionId(original));
- snprintf(listConnectionsCommand->connectionName, 16, "%s", connectionName);
+ snprintf(listConnectionsCommand->connectionName, SYMBOLIC_NAME_LEN, "%s", connectionName);
_strlwr(listConnectionsCommand->connectionName);
- snprintf(listConnectionsCommand->interfaceName, 16, "%s", ioOperations_GetInterfaceName(connection_GetIoOperations(original)));
+ snprintf(listConnectionsCommand->interfaceName, SYMBOLIC_NAME_LEN, "%s", ioOperations_GetInterfaceName(connection_GetIoOperations(original)));
listConnectionsCommand->state =
connection_IsUp(original) ? IFACE_UP : IFACE_DOWN;
@@ -801,11 +801,11 @@ struct iovec *configuration_ProcessListenersList(Configuration *config,
}
const char * listenerName = listenerEntry->getListenerName(listenerEntry);
- snprintf(listListenersCommand->listenerName, 16, "%s", listenerName);
+ snprintf(listListenersCommand->listenerName, SYMBOLIC_NAME_LEN, "%s", listenerName);
if (listenerEntry->getEncapType(listenerEntry) == ENCAP_TCP ||
listenerEntry->getEncapType(listenerEntry) == ENCAP_UDP) {
const char * interfaceName = listenerEntry->getInterfaceName(listenerEntry);
- snprintf(listListenersCommand->interfaceName, 16, "%s", interfaceName);
+ snprintf(listListenersCommand->interfaceName, SYMBOLIC_NAME_LEN, "%s", interfaceName);
}
}
diff --git a/hicn-light/src/hicn/config/configurationListeners.c b/hicn-light/src/hicn/config/configurationListeners.c
index c321007e2..8abbeb781 100644
--- a/hicn-light/src/hicn/config/configurationListeners.c
+++ b/hicn-light/src/hicn/config/configurationListeners.c
@@ -595,11 +595,11 @@ void configurationListeners_SetupAll(const Configuration *config, uint16_t port,
const Address *address = addressListGetItem(addresses, j);
// Do not start on link address
- char listenerName[16];
+ char listenerName[SYMBOLIC_NAME_LEN];
#ifdef __ANDROID__
- snprintf(listenerName, 16, "local_%zu", i);
+ snprintf(listenerName, SYMBOLIC_NAME_LEN, "local_%zu", i);
#else
- snprintf(listenerName, 16, "local_%ld", i);
+ snprintf(listenerName, SYMBOLIC_NAME_LEN, "local_%ld", i);
#endif
if (addressGetType(address) != ADDR_LINK) {
_setupListenersOnAddress(forwarder, listenerName, address, port,
@@ -617,8 +617,8 @@ void configurationListeners_SetutpLocalIPv4(const Configuration *config,
in_addr_t addr = inet_addr("127.0.0.1");
uint16_t network_byte_order_port = htons(port);
- char listenerNameUdp[16] = "lo_udp";
- char listenerNameTcp[16] = "lo_tcp";
+ char listenerNameUdp[SYMBOLIC_NAME_LEN] = "lo_udp";
+ char listenerNameTcp[SYMBOLIC_NAME_LEN] = "lo_tcp";
char *loopback_interface = "lo";
_setupUdpListenerOnInet(forwarder, listenerNameUdp,(ipv4_addr_t *)&(addr),
&network_byte_order_port, loopback_interface);
diff --git a/hicn-light/src/hicn/config/controlAddListener.c b/hicn-light/src/hicn/config/controlAddListener.c
index cfd061131..1a94ff252 100644
--- a/hicn-light/src/hicn/config/controlAddListener.c
+++ b/hicn-light/src/hicn/config/controlAddListener.c
@@ -120,7 +120,7 @@ static CommandReturn _CreateListener(CommandParser *parser, CommandOps *ops,
}
// Fill remaining payload fields
- memcpy(addListenerCommand->interfaceName, interfaceName, 16);
+ memcpy(addListenerCommand->interfaceName, interfaceName, SYMBOLIC_NAME_LEN);
addListenerCommand->listenerMode = mode;
addListenerCommand->connectionType = type;
addListenerCommand->port = htons((uint16_t)atoi(port));
diff --git a/hicn-light/src/hicn/config/controlListListeners.c b/hicn-light/src/hicn/config/controlListListeners.c
index 5be7b0a9b..1489470a8 100644
--- a/hicn-light/src/hicn/config/controlListListeners.c
+++ b/hicn-light/src/hicn/config/controlListListeners.c
@@ -95,7 +95,7 @@ static CommandReturn _controlListListeners_Execute(CommandParser *parser,
char *addrString = NULL;
if (receivedHeader->length > 0) {
- printf("%6.6s %16s %50.70s %6s %10s\n", "iface", "name", "address", "type", "interface");
+ printf("%6.6s %.*s %50.70s %6s %10s\n", "iface", SYMBOLIC_NAME_LEN, "name", "address", "type", "interface");
} else {
printf(" --- No entry in the list \n");
@@ -114,15 +114,17 @@ static CommandReturn _controlListListeners_Execute(CommandParser *parser,
if (strcmp(listenerType[listListenersCommand->encapType], "UDP") == 0 ||
strcmp(listenerType[listListenersCommand->encapType], "TCP") == 0) {
- parcBufferComposer_Format(composer, "%6u %16s %50.70s %6s %10s",
+ parcBufferComposer_Format(composer, "%6u %.*s %50.70s %6s %10s",
listListenersCommand->connid,
- listListenersCommand->listenerName,addrString,
+ SYMBOLIC_NAME_LEN, listListenersCommand->listenerName,
+ addrString,
listenerType[listListenersCommand->encapType],
listListenersCommand->interfaceName);
} else {
- parcBufferComposer_Format(composer, "%6u %16s %50.70s %6s",
+ parcBufferComposer_Format(composer, "%6u %.*s %50.70s %6s",
listListenersCommand->connid,
- listListenersCommand->listenerName,addrString,
+ SYMBOLIC_NAME_LEN, listListenersCommand->listenerName,
+ addrString,
listenerType[listListenersCommand->encapType]);
}
diff --git a/hicn-light/src/hicn/config/controlRemoveListener.c b/hicn-light/src/hicn/config/controlRemoveListener.c
index 50581a8d9..545e189c0 100644
--- a/hicn-light/src/hicn/config/controlRemoveListener.c
+++ b/hicn-light/src/hicn/config/controlRemoveListener.c
@@ -99,7 +99,7 @@ if (!utils_ValidateSymbolicName(listenerId) &&
parcMemory_AllocateAndClear(sizeof(remove_listener_command));
// fill payload
//removeListenerCommand->listenerId = atoi(listenerId);
- strncpy(removeListenerCommand->symbolicOrListenerid, listenerId, strlen(listenerId));
+ snprintf(removeListenerCommand->symbolicOrListenerid, SYMBOLIC_NAME_LEN, "%s", listenerId);
// send message and receive response
struct iovec *response =
diff --git a/hicn-light/src/hicn/utils/commands.h b/hicn-light/src/hicn/utils/commands.h
index 1a313de6a..60d4cd5fa 100644
--- a/hicn-light/src/hicn/utils/commands.h
+++ b/hicn-light/src/hicn/utils/commands.h
@@ -35,6 +35,8 @@
#include <hicn/policy.h>
#endif /* WITH_POLICY */
+#define SYMBOLIC_NAME_LEN 16
+
typedef struct in6_addr ipv6_addr_t;
typedef uint32_t ipv4_addr_t;
@@ -115,8 +117,8 @@ typedef struct {
typedef enum { ETHER_MODE, IP_MODE, HICN_MODE } listener_mode;
typedef struct {
- char symbolic[16];
- char interfaceName[16];
+ char symbolic[SYMBOLIC_NAME_LEN];
+ char interfaceName[SYMBOLIC_NAME_LEN];
union commandAddr address;
uint16_t port;
// uint16_t etherType;
@@ -130,8 +132,8 @@ typedef struct {
//========== [01] ADD CONNECTION ==========
typedef struct {
- char symbolic[16];
- //char interfaceName[16];
+ char symbolic[SYMBOLIC_NAME_LEN];
+ //char interfaceName[SYMBOLIC_NAME_LEN];
union commandAddr remoteIp;
union commandAddr localIp;
uint16_t remotePort;
@@ -168,8 +170,8 @@ typedef struct {
uint32_t connid;
uint8_t state;
uint8_t admin_state;
- char interfaceName[16];
- char connectionName[16];
+ char interfaceName[SYMBOLIC_NAME_LEN];
+ char connectionName[SYMBOLIC_NAME_LEN];
} list_connections_command;
// SIZE=80
@@ -177,7 +179,7 @@ typedef struct {
//========== [03] ADD ROUTE ==========
typedef struct {
- char symbolicOrConnid[16];
+ char symbolicOrConnid[SYMBOLIC_NAME_LEN];
union commandAddr address;
uint16_t cost;
uint8_t addressType;
@@ -200,12 +202,12 @@ typedef struct {
//========== [05] REMOVE CONNECTION ==========
typedef struct {
- char symbolicOrConnid[16];
+ char symbolicOrConnid[SYMBOLIC_NAME_LEN];
} remove_connection_command;
//========== [06] REMOVE LISTENER ==========
typedef struct {
- char symbolicOrListenerid[16];
+ char symbolicOrListenerid[SYMBOLIC_NAME_LEN];
} remove_listener_command;
// SIZE=16
@@ -213,7 +215,7 @@ typedef struct {
//========== [07] REMOVE ROUTE ==========
typedef struct {
- char symbolicOrConnid[16];
+ char symbolicOrConnid[SYMBOLIC_NAME_LEN];
union commandAddr address;
uint8_t addressType;
uint8_t len;
@@ -259,7 +261,7 @@ typedef struct {
//========== [11] SET WLDR ==========
typedef struct {
- char symbolicOrConnid[16];
+ char symbolicOrConnid[SYMBOLIC_NAME_LEN];
uint8_t activate;
} set_wldr_command;
@@ -268,7 +270,7 @@ typedef struct {
//========== [12] ADD PUNTING ==========
typedef struct {
- char symbolicOrConnid[16];
+ char symbolicOrConnid[SYMBOLIC_NAME_LEN];
union commandAddr address;
uint8_t addressType;
uint8_t len;
@@ -280,8 +282,8 @@ typedef struct {
typedef struct {
union commandAddr address;
- char listenerName[16];
- char interfaceName[16];
+ char listenerName[SYMBOLIC_NAME_LEN];
+ char interfaceName[SYMBOLIC_NAME_LEN];
uint32_t connid;
uint16_t port;
uint8_t addressType;
@@ -307,7 +309,7 @@ typedef struct {
// SIZE=1
typedef struct {
- char symbolicOrConnid[16];
+ char symbolicOrConnid[SYMBOLIC_NAME_LEN];
uint8_t admin_state;
uint16_t pad16;
} connection_set_admin_state_command;
@@ -335,7 +337,7 @@ typedef struct {
} remove_policy_command;
typedef struct {
- char symbolicOrConnid[16];
+ char symbolicOrConnid[SYMBOLIC_NAME_LEN];
uint8_t admin_state;
policy_tags_t tags;
} update_connection_command;