summaryrefslogtreecommitdiff
path: root/src/tools/irm/irm_ipcp_disconnect.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/irm/irm_ipcp_disconnect.c')
-rw-r--r--src/tools/irm/irm_ipcp_disconnect.c52
1 files changed, 28 insertions, 24 deletions
diff --git a/src/tools/irm/irm_ipcp_disconnect.c b/src/tools/irm/irm_ipcp_disconnect.c
index 73f1588d..7ce724e1 100644
--- a/src/tools/irm/irm_ipcp_disconnect.c
+++ b/src/tools/irm/irm_ipcp_disconnect.c
@@ -1,10 +1,10 @@
/*
- * Ouroboros - Copyright (C) 2016 - 2018
+ * Ouroboros - Copyright (C) 2016 - 2024
*
- * Connect components of normal IPC Processes
+ * Connect components of unicast or broadcast IPC processes
*
- * Dimitri Staessens <dimitri.staessens@ugent.be>
- * Sander Vrijders <sander.vrijders@ugent.be>
+ * Dimitri Staessens <dimitri@ouroboros.rocks>
+ * Sander Vrijders <sander@ouroboros.rocks>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -45,28 +45,29 @@
#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"
- "where COMPONENT = {" DT " " MGMT "}\n");
+ " dst <name of destination IPCP>\n"
+ " [component [COMPONENT]]\n\n"
+ "where COMPONENT in {" DT " " MGMT "}\n");
}
int do_disconnect_ipcp(int argc,
char ** argv)
{
- char * ipcp = NULL;
- char * dst = NULL;
- char * comp = NULL;
- struct ipcp_info * ipcps;
- ssize_t len = 0;
- pid_t pid = -1;
- ssize_t i;
+ char * ipcp = NULL;
+ char * dst = NULL;
+ char * comp = "*";
+ char * component = NULL;
+ struct ipcp_list_info * ipcps;
+ ssize_t len = 0;
+ pid_t pid = -1;
+ ssize_t i;
while (argc > 0) {
if (matches(*argv, "name") == 0) {
@@ -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;
}