aboutsummaryrefslogtreecommitdiffstats
path: root/hicn-light/src/hicn/config/controlAddListener.c
diff options
context:
space:
mode:
authorAngelo Mantellini <manangel@cisco.com>2019-07-18 18:31:46 +0200
committerAngelo Mantellini <manangel@cisco.com>2019-10-12 13:27:54 +0000
commiteefc7ae95bbd680416163e5617bada1949b32afc (patch)
tree336a4100832001b2991be007749d12ec5c28c1a0 /hicn-light/src/hicn/config/controlAddListener.c
parent91304b8cb75df7cb516518b53e3c1156d0f27ba5 (diff)
[HICN-247] remove listener and bug fixing
Change-Id: I4e5419a837131680fe0e21eb295462ccb2be8613 Signed-off-by: Angelo Mantellini <manangel@cisco.com>
Diffstat (limited to 'hicn-light/src/hicn/config/controlAddListener.c')
-rw-r--r--hicn-light/src/hicn/config/controlAddListener.c55
1 files changed, 12 insertions, 43 deletions
diff --git a/hicn-light/src/hicn/config/controlAddListener.c b/hicn-light/src/hicn/config/controlAddListener.c
index c9253425a..cfd061131 100644
--- a/hicn-light/src/hicn/config/controlAddListener.c
+++ b/hicn-light/src/hicn/config/controlAddListener.c
@@ -58,27 +58,26 @@ static const int _indexProtocol = 2;
static const int _indexSymbolic = 3;
static const int _indexAddress = 4;
static const int _indexPort = 5;
-#ifdef __linux__
static const int _indexInterfaceName = 6;
-#endif
static CommandReturn _controlAddListener_HelpExecute(CommandParser *parser,
CommandOps *ops,
PARCList *args) {
printf("commands:\n");
- printf(" add listener hicn <symbolic> <localAddress> \n");
#ifdef __linux__
+ printf(" add listener hicn <symbolic> <localAddress> \n");
+#endif
printf(" add listener udp <symbolic> <localAddress> <port> <interface>\n");
printf(" add listener tcp <symbolic> <localAddress> <port> <interface>\n");
-#else
- printf(" add listener udp <symbolic> <localAddress> <port>\n");
- printf(" add listener tcp <symbolic> <localAddress> <port>\n");
-#endif
printf("\n");
printf(
" symbolic: User defined name for listener, must start with "
"alpha and be alphanum\n");
+#ifdef __linux__
printf(" protocol: hicn | udp\n");
+#else
+ printf(" protocol: udp\n");
+#endif
printf(
" localAddress: IPv4 or IPv6 address (or prefix protocol = hicn) "
"assigend to the local interface\n");
@@ -88,23 +87,18 @@ static CommandReturn _controlAddListener_HelpExecute(CommandParser *parser,
printf("\n");
printf("Notes:\n");
printf(" The symblic name must be unique or the source will reject it.\n");
+#ifdef __linux__
printf(
- " If protocol = hinc: the address 0::0 indicates the main listern, "
+ " If protocol = hicn: the address 0::0 indicates the main listern, "
"for which we can set punting rules.\n");
+#endif
return CommandReturn_Success;
}
-#ifdef __linux__
-static CommandReturn _CreateListener(CommandParser *parser, CommandOps *ops,
- const char *symbolic, const char *addr,
- const char *port, const char *interfaceName, listener_mode mode,
- connection_type type) {
-#else
static CommandReturn _CreateListener(CommandParser *parser, CommandOps *ops,
const char *symbolic, const char *addr,
- const char *port, listener_mode mode,
+ const char *port, char *interfaceName, listener_mode mode,
connection_type type) {
-#endif
ControlState *state = ops->closure;
// allocate command payload
@@ -126,9 +120,7 @@ static CommandReturn _CreateListener(CommandParser *parser, CommandOps *ops,
}
// Fill remaining payload fields
-#ifdef __linux__
memcpy(addListenerCommand->interfaceName, interfaceName, 16);
-#endif
addListenerCommand->listenerMode = mode;
addListenerCommand->connectionType = type;
addListenerCommand->port = htons((uint16_t)atoi(port));
@@ -149,11 +141,7 @@ static CommandReturn _CreateListener(CommandParser *parser, CommandOps *ops,
static CommandReturn _controlAddListener_Execute(CommandParser *parser,
CommandOps *ops,
PARCList *args) {
-#ifdef __linux__
if (parcList_Size(args) != 5 && parcList_Size(args) != 7) {
-#else
- if (parcList_Size(args) != 5 && parcList_Size(args) != 6) {
-#endif
_controlAddListener_HelpExecute(parser, ops, args);
return CommandReturn_Failure;
}
@@ -169,45 +157,26 @@ static CommandReturn _controlAddListener_Execute(CommandParser *parser,
return result;
}
- const char *host = parcList_GetAtIndex(args, _indexAddress);
-#ifdef __linux__
- const char *interfaceName = parcList_GetAtIndex(args, _indexInterfaceName);
-#endif
const char *protocol = parcList_GetAtIndex(args, _indexProtocol);
-
+ const char *host = parcList_GetAtIndex(args, _indexAddress);
+ char *interfaceName = parcList_GetAtIndex(args, _indexInterfaceName);
if ((strcasecmp("hicn", protocol) == 0)) {
const char *port =
"1234"; // this is a random port number that will be ignored
// here we discard the prefix len if it exists, since we don't use it in
// code but we let libhicn to find the right ip address.
-#ifdef __linux__
return _CreateListener(parser, ops, symbolic, host, port, "hicn", HICN_MODE,
HICN_CONN);
-#else
- return _CreateListener(parser, ops, symbolic, host, port, HICN_MODE,
- HICN_CONN);
-#endif
}
-
const char *port = parcList_GetAtIndex(args, _indexPort);
if ((strcasecmp("udp", protocol) == 0)) {
-#ifdef __linux__
return _CreateListener(parser, ops, symbolic, host, port, interfaceName, IP_MODE,
UDP_CONN);
-#else
- return _CreateListener(parser, ops, symbolic, host, port, IP_MODE,
- UDP_CONN);
-#endif
} else if ((strcasecmp("tcp", protocol) == 0)) {
-#ifdef __linux__
return _CreateListener(parser, ops, symbolic, host, port, interfaceName, IP_MODE,
TCP_CONN);
-#else
- return _CreateListener(parser, ops, symbolic, host, port, IP_MODE,
- TCP_CONN);
-#endif
} else {
_controlAddListener_HelpExecute(parser, ops, args);
return CommandReturn_Failure;