summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSander Vrijders <sander.vrijders@ugent.be>2018-07-23 11:29:24 +0200
committerDimitri Staessens <dimitri.staessens@ugent.be>2018-07-23 11:50:21 +0200
commitd4ce582882e832acda9cbf3802ac1ee7cd5abbfd (patch)
tree0b4b3e3887cdbd51b60fe0f265d229a4f07234ba
parenta3903da659e0f265f24628e65582e15ea25d4572 (diff)
downloadouroboros-0.11.10.zip
ouroboros-0.11.10.tar.gz
tools: Enhance irm connect and disconnect command0.11.10
This enhances the irm connect and irm disconnect command to allow creating connections between IPCPs based on wildcard matching for the component name. In case no component was specified it sets up connections between all possible components. Signed-off-by: Sander Vrijders <sander.vrijders@ugent.be> Signed-off-by: Dimitri Staessens <dimitri.staessens@ugent.be>
-rw-r--r--CMakeLists.txt2
-rw-r--r--src/tools/irm/irm_ipcp_connect.c30
-rw-r--r--src/tools/irm/irm_ipcp_disconnect.c30
3 files changed, 35 insertions, 27 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3b3ef9b..a2caab1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -8,7 +8,7 @@ include(GNUInstallDirs)
set(PACKAGE_VERSION_MAJOR 0)
set(PACKAGE_VERSION_MINOR 11)
-set(PACKAGE_VERSION_PATCH 9)
+set(PACKAGE_VERSION_PATCH 10)
set(PACKAGE_NAME "${CMAKE_PROJECT_NAME}")
set(PACKAGE_DESCRIPTION "The Ouroboros prototype")
diff --git a/src/tools/irm/irm_ipcp_connect.c b/src/tools/irm/irm_ipcp_connect.c
index 42c0735..0b377dc 100644
--- a/src/tools/irm/irm_ipcp_connect.c
+++ b/src/tools/irm/irm_ipcp_connect.c
@@ -45,15 +45,15 @@
#include <stdlib.h>
#include <string.h>
-#define DT "dt"
-#define MGMT "mgmt"
+#define DT "dt"
+#define MGMT "mgmt"
static void usage(void)
{
printf("Usage: irm ipcp connect\n"
" name <ipcp name>\n"
- " component [COMPONENT]\n"
- " dst <name of destination IPCP>\n\n"
+ " dst <name of destination IPCP>\n"
+ " [component [COMPONENT]]\n\n"
"where COMPONENT = {" DT " " MGMT "}\n");
}
@@ -62,7 +62,8 @@ int do_connect_ipcp(int argc,
{
char * ipcp = NULL;
char * dst = NULL;
- char * comp = NULL;
+ char * comp = "*";
+ char * component = NULL;
struct ipcp_info * ipcps;
ssize_t len = 0;
pid_t pid = -1;
@@ -77,7 +78,7 @@ int do_connect_ipcp(int argc,
comp = *(argv + 1);
} else {
printf("\"%s\" is unknown, try \"irm "
- "ipcpi connect\".\n", *argv);
+ "ipcp connect\".\n", *argv);
return -1;
}
@@ -100,14 +101,17 @@ int do_connect_ipcp(int argc,
if (pid == -1)
return -1;
- if (!strcmp(comp, DT))
- comp = DT_COMP;
-
- if (!strcmp(comp , MGMT))
- comp = MGMT_COMP;
+ if (wildcard_match(comp, MGMT) == 0) {
+ component = MGMT_COMP;
+ if (irm_connect_ipcp(pid, dst, component))
+ return -1;
+ }
- if (irm_connect_ipcp(pid, dst, comp))
- return -1;
+ if (wildcard_match(comp, DT) == 0) {
+ component = DT_COMP;
+ if (irm_connect_ipcp(pid, dst, component))
+ return -1;
+ }
return 0;
}
diff --git a/src/tools/irm/irm_ipcp_disconnect.c b/src/tools/irm/irm_ipcp_disconnect.c
index 73f1588..c54bfdc 100644
--- a/src/tools/irm/irm_ipcp_disconnect.c
+++ b/src/tools/irm/irm_ipcp_disconnect.c
@@ -45,15 +45,15 @@
#include <stdlib.h>
#include <string.h>
-#define DT "dt"
-#define MGMT "mgmt"
+#define DT "dt"
+#define MGMT "mgmt"
static void usage(void)
{
printf("Usage: irm ipcp disconnect\n"
" name <ipcp name>\n"
- " component [COMPONENT]\n"
- " dst <name of destination IPCP>\n\n"
+ " dst <name of destination IPCP>\n"
+ " [component [COMPONENT]]\n\n"
"where COMPONENT = {" DT " " MGMT "}\n");
}
@@ -62,7 +62,8 @@ int do_disconnect_ipcp(int argc,
{
char * ipcp = NULL;
char * dst = NULL;
- char * comp = NULL;
+ char * comp = "*";
+ char * component = NULL;
struct ipcp_info * ipcps;
ssize_t len = 0;
pid_t pid = -1;
@@ -77,7 +78,7 @@ int do_disconnect_ipcp(int argc,
comp = *(argv + 1);
} else {
printf("\"%s\" is unknown, try \"irm "
- "ipcpi connect\".\n", *argv);
+ "ipcp connect\".\n", *argv);
return -1;
}
@@ -100,14 +101,17 @@ int do_disconnect_ipcp(int argc,
if (pid == -1)
return -1;
- if (!strcmp(comp, DT))
- comp = DT_COMP;
-
- if (!strcmp(comp , MGMT))
- comp = MGMT_COMP;
+ if (wildcard_match(comp, DT) == 0) {
+ component = DT_COMP;
+ if (irm_disconnect_ipcp(pid, dst, component))
+ return -1;
+ }
- if (irm_disconnect_ipcp(pid, dst, comp))
- return -1;
+ if (wildcard_match(comp, MGMT) == 0) {
+ component = MGMT_COMP;
+ if (irm_disconnect_ipcp(pid, dst, component))
+ return -1;
+ }
return 0;
}