aboutsummaryrefslogtreecommitdiffstats
path: root/hicn-light
diff options
context:
space:
mode:
Diffstat (limited to 'hicn-light')
-rw-r--r--hicn-light/cmake/Modules/Packaging.cmake17
-rw-r--r--hicn-light/config/hicn-light.service4
-rwxr-xr-xhicn-light/config/post3
-rwxr-xr-xhicn-light/config/postinst3
-rwxr-xr-xhicn-light/config/prerm3
-rwxr-xr-xhicn-light/config/preun3
-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
12 files changed, 66 insertions, 35 deletions
diff --git a/hicn-light/cmake/Modules/Packaging.cmake b/hicn-light/cmake/Modules/Packaging.cmake
index 006261b03..2b9f4a7b9 100644
--- a/hicn-light/cmake/Modules/Packaging.cmake
+++ b/hicn-light/cmake/Modules/Packaging.cmake
@@ -25,7 +25,22 @@ set(${HICN_LIGHT}_DEB_DEPENDENCIES
CACHE STRING "Dependencies for deb/rpm package."
)
+set(${HICN_LIGHT}_DEB_PACKAGE_CONTROL_EXTRA
+ "${CMAKE_CURRENT_SOURCE_DIR}/config/postinst;${CMAKE_CURRENT_SOURCE_DIR}/config/prerm"
+ CACHE STRING "Control scripts conffiles, postinst, postrm, prerm."
+)
+
set(${HICN_LIGHT}_RPM_DEPENDENCIES
"lib${LIBHICN} >= stable_version, libparc >= 1.0"
CACHE STRING "Dependencies for deb/rpm package."
-) \ No newline at end of file
+)
+
+set(${HICN_LIGHT}_RPM_POST_INSTALL_SCRIPT_FILE
+ "${CMAKE_CURRENT_SOURCE_DIR}/config/post"
+ CACHE STRING "Install script that will be copied in the %post section"
+)
+
+set(${HICN_LIGHT}_RPM_PRE_UNINSTALL_SCRIPT_FILE
+ "${CMAKE_CURRENT_SOURCE_DIR}/config/preun"
+ CACHE STRING "Install script that will be copied in the %post section"
+)
diff --git a/hicn-light/config/hicn-light.service b/hicn-light/config/hicn-light.service
index 0f976fc6c..f269b2f26 100644
--- a/hicn-light/config/hicn-light.service
+++ b/hicn-light/config/hicn-light.service
@@ -21,8 +21,8 @@ Environment=LOG_FILE=/tmp/hicn_light.log
Environment=CS_SIZE=1000
Environment=CONFIG=/etc/hicn/hicn_light.conf
# This will overrride the default environment
-EnvironmentFile=-/etc/default/source
-ExecStart=/usr/bin/hicnLightDaemon --port ${PORT} --log-file ${LOG_FILE} --capacity ${CS_SIZE} --config ${CONFIG}
+EnvironmentFile=-/etc/default/hicn-light
+ExecStart=/usr/bin/hicn-light-daemon --port ${PORT} --log-file ${LOG_FILE} --capacity ${CS_SIZE} --config ${CONFIG}
Restart=on-failure
[Install]
diff --git a/hicn-light/config/post b/hicn-light/config/post
new file mode 100755
index 000000000..dced2a093
--- /dev/null
+++ b/hicn-light/config/post
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+systemctl enable hicn-light \ No newline at end of file
diff --git a/hicn-light/config/postinst b/hicn-light/config/postinst
new file mode 100755
index 000000000..dced2a093
--- /dev/null
+++ b/hicn-light/config/postinst
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+systemctl enable hicn-light \ No newline at end of file
diff --git a/hicn-light/config/prerm b/hicn-light/config/prerm
new file mode 100755
index 000000000..4584c7057
--- /dev/null
+++ b/hicn-light/config/prerm
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+systemctl disable hicn-light \ No newline at end of file
diff --git a/hicn-light/config/preun b/hicn-light/config/preun
new file mode 100755
index 000000000..4584c7057
--- /dev/null
+++ b/hicn-light/config/preun
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+systemctl disable hicn-light \ No newline at end of file
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;