diff options
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/irm/CMakeLists.txt | 11 | ||||
-rw-r--r-- | src/tools/irm/irm.c | 16 | ||||
-rw-r--r-- | src/tools/irm/irm_bind.c | 81 | ||||
-rw-r--r-- | src/tools/irm/irm_ipcp.c | 77 | ||||
-rw-r--r-- | src/tools/irm/irm_ipcp_bootstrap.c (renamed from src/tools/irm/irm_bootstrap_ipcp.c) | 60 | ||||
-rw-r--r-- | src/tools/irm/irm_ipcp_create.c (renamed from src/tools/irm/irm_create_ipcp.c) | 14 | ||||
-rw-r--r-- | src/tools/irm/irm_ipcp_destroy.c (renamed from src/tools/irm/irm_destroy_ipcp.c) | 33 | ||||
-rw-r--r-- | src/tools/irm/irm_ipcp_enroll.c (renamed from src/tools/irm/irm_enroll_ipcp.c) | 33 | ||||
-rw-r--r-- | src/tools/irm/irm_ops.h | 4 | ||||
-rw-r--r-- | src/tools/irm/irm_register.c | 66 | ||||
-rw-r--r-- | src/tools/irm/irm_unbind.c | 63 | ||||
-rw-r--r-- | src/tools/irm/irm_unregister.c | 53 |
12 files changed, 332 insertions, 179 deletions
diff --git a/src/tools/irm/CMakeLists.txt b/src/tools/irm/CMakeLists.txt index d1f227a8..68297615 100644 --- a/src/tools/irm/CMakeLists.txt +++ b/src/tools/irm/CMakeLists.txt @@ -7,10 +7,13 @@ include_directories(${CMAKE_BINARY_DIR}/include) set(SOURCE_FILES # Add source files here irm.c - irm_create_ipcp.c - irm_destroy_ipcp.c - irm_bootstrap_ipcp.c - irm_enroll_ipcp.c + irm_ipcp_create.c + irm_ipcp_destroy.c + irm_ipcp_bootstrap.c + irm_ipcp_enroll.c + irm_unbind.c + irm_bind.c + irm_ipcp.c irm_register.c irm_unregister.c irm_utils.c diff --git a/src/tools/irm/irm.c b/src/tools/irm/irm.c index a1dc5ade..14420207 100644 --- a/src/tools/irm/irm.c +++ b/src/tools/irm/irm.c @@ -21,7 +21,6 @@ */ #include <ouroboros/common.h> -#include <ouroboros/instance_name.h> #include <ouroboros/irm.h> #include <stdio.h> #include <string.h> @@ -32,10 +31,8 @@ static void usage() { printf("Usage: irm [OPERATION]\n\n" - "where OPERATION = {create_ipcp destroy_ipcp \n" - " bootstrap_ipcp enroll_ipcp\n" - " register unregister\n" - " register_ipcp unregister_ipcp\n"); + "where OPERATION = {ipcp bind unbind\n" + " register unregister\n"); } static int do_help(int argc, char **argv) @@ -48,10 +45,9 @@ static const struct cmd { const char * cmd; int (* func)(int argc, char ** argv); } cmds[] = { - { "create_ipcp", do_create_ipcp }, - { "destroy_ipcp", do_destroy_ipcp }, - { "bootstrap_ipcp", do_bootstrap_ipcp }, - { "enroll_ipcp", do_enroll_ipcp }, + { "ipcp", ipcp_cmd }, + { "bind", do_bind }, + { "unbind", do_unbind }, { "register", do_register }, { "unregister", do_unregister }, { "help", do_help }, @@ -78,7 +74,7 @@ int main(int argc, char ** argv) { if (argc < 2) { usage(); - return 0; + return -1; } return do_cmd(argv[1], argc - 1, argv + 1); diff --git a/src/tools/irm/irm_bind.c b/src/tools/irm/irm_bind.c new file mode 100644 index 00000000..85e5bd3d --- /dev/null +++ b/src/tools/irm/irm_bind.c @@ -0,0 +1,81 @@ +/* + * Ouroboros - Copyright (C) 2016 + * + * Bind AP to a name + * + * Sander Vrijders <[email protected]> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include <stdio.h> +#include <string.h> + +#include <ouroboros/irm.h> + +#include "irm_ops.h" +#include "irm_utils.h" + +static void usage() +{ + printf("Usage: irm bind\n" + " name <name>\n" + " apn <application process name>\n" + " [auto] (instantiate apn if not running)\n" + " [unique] (there can only be one instantiation)\n" + " [-- <application arguments>]\n"); +} + + +int do_bind(int argc, char ** argv) +{ + char * name = NULL; + char * ap_name = NULL; + uint16_t flags = 0; + + while (argc > 0) { + if (matches(*argv, "name") == 0) { + name = *(argv + 1); + ++argv; + --argc; + } else if (matches(*argv, "apn") == 0) { + ap_name = *(argv + 1); + ++argv; + --argc; + } else if (strcmp(*argv, "auto") == 0) { + flags |= BIND_AP_AUTO; + } else if (strcmp(*argv, "unique") == 0) { + flags |= BIND_AP_UNIQUE; + } else if (strcmp(*argv, "--") == 0) { + ++argv; + --argc; + break; + } else { + printf("\"%s\" is unknown, try \"irm " + "bind\".\n", *argv); + return -1; + } + + ++argv; + --argc; + } + + if (name == NULL || ap_name == NULL) { + usage(); + return -1; + } + + return irm_bind(name, ap_name, flags, argc, argv); +} diff --git a/src/tools/irm/irm_ipcp.c b/src/tools/irm/irm_ipcp.c new file mode 100644 index 00000000..f658ead5 --- /dev/null +++ b/src/tools/irm/irm_ipcp.c @@ -0,0 +1,77 @@ +/* + * Ouroboros - Copyright (C) 2016 + * + * A tool to instruct the IRM daemon + * + * Sander Vrijders <[email protected]> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include <stdio.h> + +#include "irm_ops.h" +#include "irm_utils.h" + +static void usage() +{ + printf("Usage: irm ipcp [OPERATION]\n\n" + "where OPERATION = {create destroy\n" + " bootstrap enroll help\n"); +} + +static int do_help(int argc, char **argv) +{ + usage(); + return 0; +} + +static const struct cmd { + const char * cmd; + int (* func)(int argc, char ** argv); +} cmds[] = { + { "create", do_create_ipcp }, + { "destroy", do_destroy_ipcp }, + { "bootstrap", do_bootstrap_ipcp }, + { "enroll", do_enroll_ipcp }, + { "help", do_help }, + { 0 } +}; + +static int do_cmd(const char * argv0, + int argc, + char ** argv) +{ + const struct cmd * c; + + for (c = cmds; c->cmd; ++c) { + if (matches(argv0, c->cmd) == 0) + return c->func(argc - 1, argv + 1); + } + + fprintf(stderr, "\"%s\" is unknown, try \"irm ipcp help\".\n", argv0); + + return -1; +} + +int ipcp_cmd(int argc, char ** argv) +{ + if (argc < 1) { + usage(); + return -1; + } + + return do_cmd(argv[0], argc, argv); +} diff --git a/src/tools/irm/irm_bootstrap_ipcp.c b/src/tools/irm/irm_ipcp_bootstrap.c index e11b5f3f..c2b696e4 100644 --- a/src/tools/irm/irm_bootstrap_ipcp.c +++ b/src/tools/irm/irm_ipcp_bootstrap.c @@ -26,7 +26,7 @@ #include <arpa/inet.h> #include <ouroboros/irm.h> -#include <ouroboros/dif_config.h> +#include <ouroboros/irm_config.h> #include "irm_ops.h" #include "irm_utils.h" @@ -50,29 +50,28 @@ static void usage() { /* FIXME: Add dif_config stuff */ - printf("Usage: irm bootstrap_ipcp\n" - " ap <application process name>\n" - " [api <application process instance>]\n" - " dif <DIF name>\n" - " type [TYPE]\n\n" + printf("Usage: irm ipcp bootstrap\n" + " name <ipcp name>\n" + " dif <DIF name>\n" + " type [TYPE]\n\n" "where TYPE = {" NORMAL " " LOCAL " " SHIM_UDP " " SHIM_ETH_LLC"}\n\n" "if TYPE == " NORMAL "\n" - " [addr <address size> (default: %d)]\n" - " [cep_id <CEP-id size> (default: %d)]\n" - " [pdu_len <PDU length size> (default: %d)]\n" - " [qos_id <QoS-id size> (default: %d)]\n" - " [seqno <sequence number size> (default: %d)]\n" - " [ttl <time to live size> (default: %d)]\n" - " [chk <checksum size> (default: %d)]\n" - " [min_pdu <minimum PDU size> (default: %d)]\n" - " [max_pdu <maximum PDU size> (default: %d)]\n" + " [addr <address size> (default: %d)]\n" + " [cep_id <CEP-id size> (default: %d)]\n" + " [pdu_len <PDU length size> (default: %d)]\n" + " [qos_id <QoS-id size> (default: %d)]\n" + " [seqno <sequence number size> (default: %d)]\n" + " [ttl <time to live size> (default: %d)]\n" + " [chk <checksum size> (default: %d)]\n" + " [min_pdu <minimum PDU size> (default: %d)]\n" + " [max_pdu <maximum PDU size> (default: %d)]\n" "if TYPE == " SHIM_UDP "\n" - " ip <IP address in dotted notation>\n" - " [dns <DDNS IP address in dotted notation>" + " ip <IP address in dotted notation>\n" + " [dns <DDNS IP address in dotted notation>" " (default = none: %d)]\n" "if TYPE == " SHIM_ETH_LLC "\n" - " if_name <interface name>\n", + " if_name <interface name>\n", DEFAULT_ADDR_SIZE, DEFAULT_CEP_ID_SIZE, DEFAULT_PDU_LEN_SIZE, DEFAULT_QOS_ID_SIZE, DEFAULT_SEQ_NO_SIZE, DEFAULT_TTL_SIZE, @@ -82,7 +81,7 @@ static void usage() int do_bootstrap_ipcp(int argc, char ** argv) { - instance_name_t api = {NULL, 0}; + char * name = NULL; struct dif_config conf; uint8_t addr_size = DEFAULT_ADDR_SIZE; uint8_t cep_id_size = DEFAULT_CEP_ID_SIZE; @@ -98,16 +97,17 @@ int do_bootstrap_ipcp(int argc, char ** argv) char * ipcp_type = NULL; char * dif_name = NULL; char * if_name = NULL; + pid_t * apis; + ssize_t len = 0; + int i = 0; while (argc > 0) { if (matches(*argv, "type") == 0) { ipcp_type = *(argv + 1); } else if (matches(*argv, "dif") == 0) { dif_name = *(argv + 1); - } else if (matches(*argv, "ap") == 0) { - api.name = *(argv + 1); - } else if (matches(*argv, "api") == 0) { - api.id = atoi(*(argv + 1)); + } else if (matches(*argv, "name") == 0) { + name = *(argv + 1); } else if (matches(*argv, "ip") == 0) { if (inet_pton (AF_INET, *(argv + 1), &ip_addr) != 1) { usage(); @@ -140,7 +140,7 @@ int do_bootstrap_ipcp(int argc, char ** argv) max_pdu_size = atoi(*(argv + 1)); } else { printf("\"%s\" is unknown, try \"irm " - "bootstrap_ipcp\".\n", *argv); + "ipcp bootstrap\".\n", *argv); return -1; } @@ -148,7 +148,7 @@ int do_bootstrap_ipcp(int argc, char ** argv) argv += 2; } - if (api.name == NULL || dif_name == NULL || ipcp_type == NULL) { + if (name == NULL || dif_name == NULL || ipcp_type == NULL) { usage(); return -1; } @@ -188,5 +188,13 @@ int do_bootstrap_ipcp(int argc, char ** argv) return -1; } - return irm_bootstrap_ipcp(&api, &conf); + len = irm_list_ipcps(name, &apis); + if (len <= 0) + return -1; + + for (i = 0; i < len; i++) + if (irm_bootstrap_ipcp(apis[i], &conf)) + return -1; + + return 0; } diff --git a/src/tools/irm/irm_create_ipcp.c b/src/tools/irm/irm_ipcp_create.c index cb957d94..b43a544e 100644 --- a/src/tools/irm/irm_create_ipcp.c +++ b/src/tools/irm/irm_ipcp_create.c @@ -21,13 +21,9 @@ */ #include <ouroboros/irm.h> -#include <ouroboros/common.h> -#include <ouroboros/instance_name.h> #include <stdio.h> -#include <stdlib.h> #include <string.h> -#include <errno.h> #include "irm_ops.h" #include "irm_utils.h" @@ -39,9 +35,9 @@ static void usage() { - printf("Usage: irm create_ipcp\n" - " ap <application process name>\n" - " type [TYPE]\n\n" + printf("Usage: irm ipcp create\n" + " name <ipcp name>\n" + " type [TYPE]\n\n" "where TYPE = {" NORMAL " " LOCAL " " SHIM_UDP " " SHIM_ETH_LLC "}\n"); } @@ -55,11 +51,11 @@ int do_create_ipcp(int argc, char ** argv) while (argc > 0) { if (matches(*argv, "type") == 0) { ipcp_type = *(argv + 1); - } else if (matches(*argv, "ap") == 0) { + } else if (matches(*argv, "name") == 0) { ipcp_name = *(argv + 1); } else { printf("\"%s\" is unknown, try \"irm " - "create_ipcp\".\n", *argv); + "ipcp create\".\n", *argv); return -1; } diff --git a/src/tools/irm/irm_destroy_ipcp.c b/src/tools/irm/irm_ipcp_destroy.c index fe6ef57e..ebd4283d 100644 --- a/src/tools/irm/irm_destroy_ipcp.c +++ b/src/tools/irm/irm_ipcp_destroy.c @@ -21,32 +21,31 @@ */ #include <stdio.h> -#include <stdlib.h> + #include <ouroboros/irm.h> -#include <ouroboros/common.h> #include "irm_ops.h" #include "irm_utils.h" static void usage() { - printf("Usage: irm destroy_ipcp\n" - " ap <application process name>\n" - " [api <application process instance>]\n"); + printf("Usage: irm ipcp destroy\n" + " name <ipcp name>\n"); } int do_destroy_ipcp(int argc, char ** argv) { - instance_name_t api = {NULL, 0}; + char * name = NULL; + pid_t * apis; + ssize_t len = 0; + int i = 0; while (argc > 0) { - if (matches(*argv, "ap") == 0) { - api.name = *(argv + 1); - } else if (matches(*argv, "api") == 0) { - api.id = atoi(*(argv + 1)); + if (matches(*argv, "name") == 0) { + name = *(argv + 1); } else { printf("\"%s\" is unknown, try \"irm " - "destroy_ipcp\".\n", *argv); + "ipcp destroy\".\n", *argv); return -1; } @@ -54,10 +53,18 @@ int do_destroy_ipcp(int argc, char ** argv) argv += 2; } - if (api.name == NULL) { + if (name == NULL) { usage(); return -1; } - return irm_destroy_ipcp(&api); + len = irm_list_ipcps(name, &apis); + if (len <= 0) + return -1; + + for (i = 0; i < len; i++) + if (irm_destroy_ipcp(apis[i])) + return -1; + + return 0; } diff --git a/src/tools/irm/irm_enroll_ipcp.c b/src/tools/irm/irm_ipcp_enroll.c index 5c9572bf..d6b1b27e 100644 --- a/src/tools/irm/irm_enroll_ipcp.c +++ b/src/tools/irm/irm_ipcp_enroll.c @@ -21,31 +21,30 @@ */ #include <stdio.h> -#include <stdlib.h> + #include <ouroboros/irm.h> -#include <ouroboros/common.h> #include "irm_ops.h" #include "irm_utils.h" static void usage() { - printf("Usage: irm enroll_ipcp\n" - " ap <application process name>\n" - " [api <application process instance>]\n" - " dif <dif to enroll in>\n"); + printf("Usage: irm ipcp enroll\n" + " name <ipcp name>\n" + " dif <dif to enroll in>\n"); } int do_enroll_ipcp(int argc, char ** argv) { - instance_name_t api = {NULL, 0}; + char * name = NULL; char * dif_name = NULL; + pid_t * apis; + ssize_t len = 0; + int i = 0; while (argc > 0) { - if (matches(*argv, "ap") == 0) { - api.name = *(argv + 1); - } else if (matches(*argv, "api") == 0) { - api.id = atoi(*(argv + 1)); + if (matches(*argv, "name") == 0) { + name = *(argv + 1); } else if (matches(*argv, "dif") == 0) { dif_name = *(argv + 1); } else { @@ -58,10 +57,18 @@ int do_enroll_ipcp(int argc, char ** argv) argv += 2; } - if (dif_name == NULL || api.name == NULL) { + if (dif_name == NULL || name == NULL) { usage(); return -1; } - return irm_enroll_ipcp(&api, dif_name); + len = irm_list_ipcps(name, &apis); + if (len <= 0) + return -1; + + for (i = 0; i < len; i++) + if (irm_enroll_ipcp(apis[i], dif_name)) + return -1; + + return 0; } diff --git a/src/tools/irm/irm_ops.h b/src/tools/irm/irm_ops.h index ea51cbeb..24eee0df 100644 --- a/src/tools/irm/irm_ops.h +++ b/src/tools/irm/irm_ops.h @@ -20,9 +20,13 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +int ipcp_cmd(int argc, char ** argv); int do_create_ipcp(int argc, char ** argv); int do_destroy_ipcp(int argc, char ** argv); int do_bootstrap_ipcp(int argc, char ** argv); int do_enroll_ipcp(int argc, char ** argv); + +int do_bind(int argc, char ** argv); +int do_unbind(int argc, char ** argv); int do_register(int argc, char ** argv); int do_unregister(int argc, char ** argv); diff --git a/src/tools/irm/irm_register.c b/src/tools/irm/irm_register.c index 67c81025..62470d1d 100644 --- a/src/tools/irm/irm_register.c +++ b/src/tools/irm/irm_register.c @@ -1,7 +1,7 @@ /* * Ouroboros - Copyright (C) 2016 * - * Register AP's in DIFs + * Register names in IPCPs * * Dimitri Staessens <[email protected]> * Sander Vrijders <[email protected]> @@ -21,15 +21,9 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include <ouroboros/config.h> -#include <stdio.h> #include <ouroboros/irm.h> -#include <ouroboros/common.h> -#include <stdlib.h> -#include <string.h> -#include <errno.h> -#include <sys/types.h> -#include <signal.h> + +#include <stdio.h> #include "irm_ops.h" #include "irm_utils.h" @@ -39,13 +33,10 @@ static void usage() { printf("Usage: irm register\n" - " n <name>\n" - " apn <application process name>\n" - " [api <application instance id>]\n" - " [auto] (instantiate apn if not running)\n" + " name <name>\n" + " dif <dif name to register with>\n" " [dif <dif name to register with>]\n" " [... (maximum %d difs)]\n" - " [-- <application arguments>]\n" , MAX_DIFS); } @@ -53,33 +44,12 @@ static void usage() int do_register(int argc, char ** argv) { char * name = NULL; - char ** args = NULL; char * difs[MAX_DIFS]; size_t difs_len = 0; - bool api_opt = false; - bool args_opt = false; - bool autoexec = false; - int i = argc; - instance_name_t api = {NULL, 0}; - - while (i > 0) { + while (argc > 0) { if (matches(*argv, "name") == 0) { name = *(argv + 1); - } else if (matches(*argv, "apn") == 0) { - api.name = *(argv + 1); - } else if (matches(*argv, "api") == 0) { - api.id = atoi(*(argv + 1)); - api_opt = true; - } else if (strcmp(*argv, "auto") == 0) { - autoexec = true; - ++i; - --argv; - } else if (strcmp(*argv, "--") == 0) { - ++argv; - --i; - args_opt = true; - break; } else if (matches(*argv, "dif") == 0) { difs[difs_len++] = *(argv + 1); if (difs_len > MAX_DIFS) { @@ -92,32 +62,14 @@ int do_register(int argc, char ** argv) return -1; } - i -= 2; + argc -= 2; argv += 2; } - if (name == NULL || api.name == NULL) { + if (difs_len < 1 || name == NULL) { usage(); return -1; } - if (api_opt && kill(api.id, 0) < 0) { - printf("No application running with that pid."); - return -1; - } - - if (api_opt && autoexec) { - printf("Instance is given, auto disabled.\n"); - autoexec = false; - } - - args = argv; - - if (args_opt && api_opt) { - printf("Instance is given, args ignored.\n"); - args = NULL; - i = 0; - } - - return irm_reg(name, &api, i, args, autoexec, difs, difs_len); + return irm_reg(name, difs, difs_len); } diff --git a/src/tools/irm/irm_unbind.c b/src/tools/irm/irm_unbind.c new file mode 100644 index 00000000..9e8f3c9c --- /dev/null +++ b/src/tools/irm/irm_unbind.c @@ -0,0 +1,63 @@ +/* + * Ouroboros - Copyright (C) 2016 + * + * Unbind names in the processing system + * + * Sander Vrijders <[email protected]> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include <stdio.h> + +#include <ouroboros/irm.h> + +#include "irm_ops.h" +#include "irm_utils.h" + +static void usage() +{ + printf("Usage: irm unbind\n" + " name <name>\n" + " ap <application process name>\n"); +} + +int do_unbind(int argc, char ** argv) +{ + char * name = NULL; + char * ap_name = NULL; + + while (argc > 0) { + if (matches(*argv, "name") == 0) { + name = *(argv + 1); + } else if (matches(*argv, "ap") == 0) { + ap_name = *(argv + 1); + } else { + printf("\"%s\" is unknown, try \"irm " + "unbind\".\n", *argv); + return -1; + } + + argc -= 2; + argv += 2; + } + + if (name == NULL && ap_name == NULL) { + usage(); + return -1; + } + + return irm_unbind(name, ap_name, 0); +} diff --git a/src/tools/irm/irm_unregister.c b/src/tools/irm/irm_unregister.c index d778e285..edcd42bb 100644 --- a/src/tools/irm/irm_unregister.c +++ b/src/tools/irm/irm_unregister.c @@ -1,7 +1,7 @@ /* * Ouroboros - Copyright (C) 2016 * - * Unregister IPC Processes in an N-1 DIF + * Unregister names from IPCPs * * Dimitri Staessens <[email protected]> * Sander Vrijders <[email protected]> @@ -21,15 +21,10 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include <ouroboros/config.h> #include <stdio.h> -#include <ouroboros/irm.h> -#include <ouroboros/common.h> -#include <stdlib.h> #include <string.h> -#include <errno.h> -#include <sys/types.h> -#include <signal.h> + +#include <ouroboros/irm.h> #include "irm_ops.h" #include "irm_utils.h" @@ -39,40 +34,22 @@ static void usage() { printf("Usage: irm unregister\n" - " [name <name>]\n" - " [apn <application process name>]\n" - " [api <application process instance>]\n" + " name <name>\n" " dif <dif name to unregister from>\n" " [dif <dif name to unregister from>]\n" " [... (maximum %d difs)]\n" - " [hard] (unregisters everything using that name)\n" , MAX_DIFS); } int do_unregister(int argc, char ** argv) { - instance_name_t api = {NULL, 0}; char * difs[MAX_DIFS]; size_t difs_len = 0; char * name = NULL; - bool hard_opt = false; - bool ap_id = false; - instance_name_t * ptr_api = NULL; while (argc > 0) { if (matches(*argv, "name") == 0) { name = *(argv + 1); - } else if (matches(*argv, "ap") == 0) { - api.name = *(argv + 1); - ptr_api = &api; - } else if (matches(*argv, "api") == 0) { - api.id = atoi(*(argv + 1)); - ap_id = true; - } else if (strcmp(*argv, "hard") == 0) { - hard_opt = true; - /* this has no value */ - ++argc; - --argv; } else if (matches(*argv, "dif") == 0) { difs[difs_len++] = *(argv + 1); if (difs_len > MAX_DIFS) { @@ -89,28 +66,10 @@ int do_unregister(int argc, char ** argv) argv += 2; } - if (difs_len == 0) { - usage(); - return -1; - } - - if (name == NULL && api.name == NULL) { - printf("apn or name must be set.\n"); - usage(); - return -1; - } - - if (ap_id && api.name == NULL) { - printf("api requires apn.\n"); - usage(); - return -1; - } - - if (hard_opt && api.name != NULL) { - printf("apn and/or api must not be set when using hard.\n"); + if (difs_len == 0 || name == NULL) { usage(); return -1; } - return irm_unreg(name, ptr_api, difs, difs_len, hard_opt); + return irm_unreg(name, difs, difs_len); } |