summaryrefslogtreecommitdiff
path: root/src/tools/irm/irm_unbind_ipcp.c
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri.staessens@ugent.be>2018-03-22 11:02:15 +0100
committerSander Vrijders <sander.vrijders@ugent.be>2018-03-22 12:36:58 +0100
commit751fb58bcf5fdb31c0627a5153684e96126cffb6 (patch)
tree5c4e8d8b2b2b323738703644c422a7e6c7095d5e /src/tools/irm/irm_unbind_ipcp.c
parentfd5508b8daec47e9f646c086d4cc310583154b97 (diff)
downloadouroboros-751fb58bcf5fdb31c0627a5153684e96126cffb6.tar.gz
ouroboros-751fb58bcf5fdb31c0627a5153684e96126cffb6.zip
lib: Simplify reg/unreg API
The reg/unreg API is simplified to registering and unregistering a single name with a single IPCP. The functionality associated with registering names was moved from the IRMd to the irm tool. The function to list IPCPs was simplified to return all IPCPs in the system with their basic properties needed for management. The above changes led to some needed changes in the irm tool and the management functions that were depending on the previous behaviour of list_ipcps. Command line functionality to list IPCPs in the system is also added to the irm tool. Some older code was refactored. Signed-off-by: Dimitri Staessens <dimitri.staessens@ugent.be> Signed-off-by: Sander Vrijders <sander.vrijders@ugent.be>
Diffstat (limited to 'src/tools/irm/irm_unbind_ipcp.c')
-rw-r--r--src/tools/irm/irm_unbind_ipcp.c32
1 files changed, 19 insertions, 13 deletions
diff --git a/src/tools/irm/irm_unbind_ipcp.c b/src/tools/irm/irm_unbind_ipcp.c
index f804da90..9b2a930a 100644
--- a/src/tools/irm/irm_unbind_ipcp.c
+++ b/src/tools/irm/irm_unbind_ipcp.c
@@ -45,6 +45,8 @@
#include "irm_ops.h"
#include "irm_utils.h"
+#include <string.h>
+
static void usage(void)
{
printf("Usage: irm unbind ipcp <name>\n"
@@ -52,15 +54,14 @@ static void usage(void)
"\n");
}
-int do_unbind_ipcp(int argc, char ** argv)
+int do_unbind_ipcp(int argc,
+ char ** argv)
{
- char * ipcp = NULL;
- char * name = NULL;
-
- pid_t * pids = NULL;
- ssize_t len = 0;
-
- int i;
+ char * ipcp = NULL;
+ char * name = NULL;
+ struct ipcp_info * ipcps;
+ ssize_t len;
+ ssize_t i;
while (argc > 0) {
if (matches(*argv, "name") == 0) {
@@ -81,17 +82,22 @@ int do_unbind_ipcp(int argc, char ** argv)
--argc;
}
- if (ipcp == NULL) {
+ if (ipcp == NULL || name == NULL) {
usage();
return -1;
}
- len = irm_list_ipcps(ipcp, &pids);
-
+ len = irm_list_ipcps(&ipcps);
for (i = 0; i < len; ++i)
- irm_unbind_process(pids[i], name);
+ if (strcmp(ipcps[i].name, ipcp) == 0) {
+ if (irm_unbind_process(ipcps[i].pid, name)) {
+ free(ipcps);
+ return -1;
+ }
+ break;
+ }
- free(pids);
+ free(ipcps);
return 0;
}