aboutsummaryrefslogtreecommitdiffstats
path: root/hicn-light/src/hicn/config
diff options
context:
space:
mode:
authormichele papalini <micpapal@cisco.com>2020-01-09 14:55:32 +0100
committermichele papalini <micpapal@cisco.com>2020-01-09 17:23:36 +0100
commite4eca848c8d95f48652096284fd8e2752ed1a316 (patch)
tree8c229e9c852aff110ae961c82117bf8c2b825c63 /hicn-light/src/hicn/config
parent41e72f60c2da1586d5330365f065e8908e3b9b07 (diff)
[HICN-469] execute hicn-light-control from remote
Signed-off-by: michele papalini <micpapal@cisco.com> Change-Id: I2a23a5f7648614213b83e2409e2ff3784b083758 Signed-off-by: michele papalini <micpapal@cisco.com>
Diffstat (limited to 'hicn-light/src/hicn/config')
-rw-r--r--hicn-light/src/hicn/config/configurationFile.c3
-rw-r--r--hicn-light/src/hicn/config/controlRoot.c4
-rw-r--r--hicn-light/src/hicn/config/controlState.c16
-rw-r--r--hicn-light/src/hicn/config/controlState.h6
4 files changed, 16 insertions, 13 deletions
diff --git a/hicn-light/src/hicn/config/configurationFile.c b/hicn-light/src/hicn/config/configurationFile.c
index adc089396..3cce740ac 100644
--- a/hicn-light/src/hicn/config/configurationFile.c
+++ b/hicn-light/src/hicn/config/configurationFile.c
@@ -210,7 +210,8 @@ ConfigurationFile *configurationFile_Create(Forwarder *forwarder,
// because
// writeRead still not implemented from configuration file.
configFile->controlState =
- controlState_Create(configFile, _writeRead, false);
+ controlState_Create(configFile, _writeRead, false,
+ SRV_CTRL_IP, SRV_CTRL_PORT);
// we do not register Help commands
controlState_RegisterCommand(configFile->controlState,
diff --git a/hicn-light/src/hicn/config/controlRoot.c b/hicn-light/src/hicn/config/controlRoot.c
index e135dfc50..8c8cc1804 100644
--- a/hicn-light/src/hicn/config/controlRoot.c
+++ b/hicn-light/src/hicn/config/controlRoot.c
@@ -62,11 +62,11 @@ static CommandReturn _controlRoot_HelpExecute(CommandParser *parser,
CommandOps *ops, PARCList *args) {
printf("Command-line execution:\n");
printf(
- " controller [--keystore <keystorepath>] [--password <password>] "
+ " controller [--server <server-ip>] [--port <server-port>] "
"command\n");
printf("\n");
printf("Interactive execution:\n");
- printf(" controller [--keystore <keystorepath>] [--password <password>]\n");
+ printf(" controller [--server <server-ip>] [--port <server-port>]\n");
printf("\n");
printf(
"If the keystore is not specified, the default path is used. Keystore "
diff --git a/hicn-light/src/hicn/config/controlState.c b/hicn-light/src/hicn/config/controlState.c
index 6cd1b905d..2df8805c6 100644
--- a/hicn-light/src/hicn/config/controlState.c
+++ b/hicn-light/src/hicn/config/controlState.c
@@ -37,9 +37,6 @@
#include <hicn/utils/commands.h>
-#define SRV_IP "127.0.0.1"
-#define PORT 9695
-
struct controller_state {
CommandParser *parser;
bool debugFlag;
@@ -51,7 +48,7 @@ struct controller_state {
bool isInteractive;
};
-int controlState_connectToFwdDeamon() {
+int controlState_connectToFwdDeamon(char *server_ip, uint16_t port) {
int sockfd;
struct sockaddr_in servaddr;
@@ -64,8 +61,8 @@ int controlState_connectToFwdDeamon() {
// Filling server information
servaddr.sin_family = AF_INET;
- servaddr.sin_port = htons(PORT);
- inet_pton(AF_INET, SRV_IP, &(servaddr.sin_addr.s_addr));
+ servaddr.sin_port = htons(port);
+ inet_pton(AF_INET, server_ip, &(servaddr.sin_addr.s_addr));
// Establish connection
if (connect(sockfd, (struct sockaddr *)&servaddr, sizeof(servaddr)) < 0) {
@@ -79,7 +76,8 @@ int controlState_connectToFwdDeamon() {
ControlState *controlState_Create(
void *userdata,
struct iovec *(*writeRead)(ControlState *state, struct iovec *msg),
- bool openControllerConnetion) {
+ bool openControllerConnetion,
+ char *server_ip, uint16_t port) {
ControlState *state = parcMemory_AllocateAndClear(sizeof(ControlState));
parcAssertNotNull(state, "parcMemory_AllocateAndClear(%zu) returned NULL",
sizeof(ControlState));
@@ -92,7 +90,7 @@ ControlState *controlState_Create(
state->isInteractive = true;
if (openControllerConnetion) {
- state->sockfd = controlState_connectToFwdDeamon();
+ state->sockfd = controlState_connectToFwdDeamon(server_ip, port);
} else {
state->sockfd = 2; // stderr
}
@@ -235,4 +233,4 @@ bool controlState_isConfigFile(ControlState *state) {
} else {
return true;
}
-} \ No newline at end of file
+}
diff --git a/hicn-light/src/hicn/config/controlState.h b/hicn-light/src/hicn/config/controlState.h
index 25542657f..cc38cbe37 100644
--- a/hicn-light/src/hicn/config/controlState.h
+++ b/hicn-light/src/hicn/config/controlState.h
@@ -32,6 +32,9 @@
#include <hicn/utils/commands.h>
+#define SRV_CTRL_IP "127.0.0.1"
+#define SRV_CTRL_PORT 9695
+
struct controller_state;
typedef struct controller_state ControlState;
@@ -59,7 +62,8 @@ typedef struct controller_state ControlState;
ControlState *controlState_Create(
void *userdata,
struct iovec *(*writeRead)(ControlState *state, struct iovec *msg),
- bool openControllerConnetion);
+ bool openControllerConnetion,
+ char * server_ip, uint16_t port);
/**
* Destroys the control state, closing all network connections