diff options
author | dimitri staessens <dimitri.staessens@intec.ugent.be> | 2016-04-01 15:01:51 +0200 |
---|---|---|
committer | dimitri staessens <dimitri.staessens@intec.ugent.be> | 2016-04-01 15:01:51 +0200 |
commit | 65591e5211fb3c44450c52d7534918902e0760d5 (patch) | |
tree | b3f21e0bdb9cf0e773962db73be041bb86d0ee44 /src/tools/irm | |
parent | 3d859bb9a75932a6cffdd37466d510b479c9aa71 (diff) | |
parent | 0e1aeba4f2d2de3ce827bfaeb1d9f2480e628529 (diff) | |
download | ouroboros-65591e5211fb3c44450c52d7534918902e0760d5.tar.gz ouroboros-65591e5211fb3c44450c52d7534918902e0760d5.zip |
Merge branch 'be' of bitbucket.org:ouroboros-rina/ouroboros into be-build
Diffstat (limited to 'src/tools/irm')
-rw-r--r-- | src/tools/irm/irm.c | 2 | ||||
-rw-r--r-- | src/tools/irm/irm_bootstrap_ipcp.c | 19 | ||||
-rw-r--r-- | src/tools/irm/irm_create_ipcp.c | 28 | ||||
-rw-r--r-- | src/tools/irm/irm_destroy_ipcp.c | 16 | ||||
-rw-r--r-- | src/tools/irm/irm_enroll_ipcp.c | 28 | ||||
-rw-r--r-- | src/tools/irm/irm_register_ipcp.c | 31 | ||||
-rw-r--r-- | src/tools/irm/irm_unregister_ipcp.c | 30 | ||||
-rw-r--r-- | src/tools/irm/irm_utils.c | 16 | ||||
-rw-r--r-- | src/tools/irm/irm_utils.h | 6 |
9 files changed, 79 insertions, 97 deletions
diff --git a/src/tools/irm/irm.c b/src/tools/irm/irm.c index 895d52c2..d05e083e 100644 --- a/src/tools/irm/irm.c +++ b/src/tools/irm/irm.c @@ -21,7 +21,7 @@ */ #include <ouroboros/common.h> -#include <ouroboros/rina_name.h> +#include <ouroboros/instance_name.h> #include <ouroboros/irm.h> #include <stdio.h> #include <string.h> diff --git a/src/tools/irm/irm_bootstrap_ipcp.c b/src/tools/irm/irm_bootstrap_ipcp.c index 89950069..c7b82c4a 100644 --- a/src/tools/irm/irm_bootstrap_ipcp.c +++ b/src/tools/irm/irm_bootstrap_ipcp.c @@ -21,6 +21,7 @@ */ #include <stdio.h> +#include <stdlib.h> #include <ouroboros/irm.h> #include <ouroboros/common.h> @@ -38,29 +39,31 @@ static void usage() int do_bootstrap_ipcp(int argc, char ** argv) { - rina_name_t name; + instance_name_t api = {NULL, 0}; struct dif_config conf; conf.qosspecs = NULL; - name.ap_name = NULL; - name.api_id = 0; - while (argc > 0) { - if (!parse_name(argv, &name)) { + if (matches(*argv, "ap") == 0) { + api.name = *(argv + 1); + } else if (matches(*argv, "api") == 0) { + api.id = atoi(*(argv + 1)); + } else { printf("\"%s\" is unknown, try \"irm " - "enroll_ipcp\".\n", *argv); + "destroy_ipcp\".\n", *argv); return -1; } + argc -= 2; argv += 2; } - if (name.ap_name == NULL) { + if (api.name == NULL) { usage(); return -1; } - return irm_bootstrap_ipcp(name, conf); + return irm_bootstrap_ipcp(&api, &conf); } diff --git a/src/tools/irm/irm_create_ipcp.c b/src/tools/irm/irm_create_ipcp.c index 854a15f9..73d20dce 100644 --- a/src/tools/irm/irm_create_ipcp.c +++ b/src/tools/irm/irm_create_ipcp.c @@ -23,6 +23,7 @@ #include <stdio.h> #include <ouroboros/irm.h> #include <ouroboros/common.h> +#include <ouroboros/instance_name.h> #include <stdlib.h> #include <string.h> #include <errno.h> @@ -40,31 +41,30 @@ static void usage() int do_create_ipcp(int argc, char ** argv) { - rina_name_t name; char * ipcp_type = NULL; - - name.ap_name = NULL; - name.api_id = 0; + instance_name_t api = {NULL, 0}; while (argc > 0) { - if (!parse_name(argv, &name)) { - if (matches(*argv, "type") == 0) { - ipcp_type = *(argv + 1); - } else { - printf("\"%s\" is unknown, try \"irm " - "create_ipcp\".\n", *argv); - return -1; - } + if (matches(*argv, "type") == 0) { + ipcp_type = *(argv + 1); + } else if (matches(*argv, "ap") == 0) { + api.name = *(argv + 1); + } else if (matches(*argv, "api") == 0) { + api.id = atoi(*(argv + 1)); + } else { + printf("\"%s\" is unknown, try \"irm " + "create_ipcp\".\n", *argv); + return -1; } argc -= 2; argv += 2; } - if (ipcp_type == NULL || name.ap_name == NULL) { + if (ipcp_type == NULL || api.name == NULL) { usage(); return -1; } - return irm_create_ipcp(name, ipcp_type); + return irm_create_ipcp(&api, ipcp_type); } diff --git a/src/tools/irm/irm_destroy_ipcp.c b/src/tools/irm/irm_destroy_ipcp.c index 4f02f9cb..fe6ef57e 100644 --- a/src/tools/irm/irm_destroy_ipcp.c +++ b/src/tools/irm/irm_destroy_ipcp.c @@ -21,6 +21,7 @@ */ #include <stdio.h> +#include <stdlib.h> #include <ouroboros/irm.h> #include <ouroboros/common.h> @@ -36,13 +37,14 @@ static void usage() int do_destroy_ipcp(int argc, char ** argv) { - rina_name_t name; - - name.ap_name = NULL; - name.api_id = 0; + instance_name_t api = {NULL, 0}; while (argc > 0) { - if (!parse_name(argv, &name)) { + if (matches(*argv, "ap") == 0) { + api.name = *(argv + 1); + } else if (matches(*argv, "api") == 0) { + api.id = atoi(*(argv + 1)); + } else { printf("\"%s\" is unknown, try \"irm " "destroy_ipcp\".\n", *argv); return -1; @@ -52,10 +54,10 @@ int do_destroy_ipcp(int argc, char ** argv) argv += 2; } - if (name.ap_name == NULL) { + if (api.name == NULL) { usage(); return -1; } - return irm_destroy_ipcp(name); + return irm_destroy_ipcp(&api); } diff --git a/src/tools/irm/irm_enroll_ipcp.c b/src/tools/irm/irm_enroll_ipcp.c index 1dcdc919..5c9572bf 100644 --- a/src/tools/irm/irm_enroll_ipcp.c +++ b/src/tools/irm/irm_enroll_ipcp.c @@ -21,6 +21,7 @@ */ #include <stdio.h> +#include <stdlib.h> #include <ouroboros/irm.h> #include <ouroboros/common.h> @@ -37,31 +38,30 @@ static void usage() int do_enroll_ipcp(int argc, char ** argv) { - rina_name_t name; + instance_name_t api = {NULL, 0}; char * dif_name = NULL; - name.ap_name = NULL; - name.api_id = 0; - while (argc > 0) { - if (!parse_name(argv, &name)) { - if (matches(*argv, "dif") == 0) { - dif_name = *(argv + 1); - } else { - printf("\"%s\" is unknown, try \"irm " - "enroll_ipcp\".\n", *argv); - return -1; - } + if (matches(*argv, "ap") == 0) { + api.name = *(argv + 1); + } else if (matches(*argv, "api") == 0) { + api.id = atoi(*(argv + 1)); + } else if (matches(*argv, "dif") == 0) { + dif_name = *(argv + 1); + } else { + printf("\"%s\" is unknown, try \"irm " + "enroll_ipcp\".\n", *argv); + return -1; } argc -= 2; argv += 2; } - if (dif_name == NULL || name.ap_name == NULL) { + if (dif_name == NULL || api.name == NULL) { usage(); return -1; } - return irm_enroll_ipcp(name, dif_name); + return irm_enroll_ipcp(&api, dif_name); } diff --git a/src/tools/irm/irm_register_ipcp.c b/src/tools/irm/irm_register_ipcp.c index 468ef28f..f0c1ccff 100644 --- a/src/tools/irm/irm_register_ipcp.c +++ b/src/tools/irm/irm_register_ipcp.c @@ -45,36 +45,35 @@ static void usage() int do_register_ipcp(int argc, char ** argv) { - rina_name_t name; char * difs[MAX_DIFS]; size_t difs_size = 0; - - name.ap_name = NULL; - name.api_id = 0; + instance_name_t api = {NULL, 0}; while (argc > 0) { - if (!parse_name(argv, &name)) { - if (matches(*argv, "dif") == 0) { - difs[difs_size++] = *(argv + 1); - if (difs_size > MAX_DIFS) { - printf("Too many difs specified\n"); - return -1; - } - } else { - printf("\"%s\" is unknown, try \"irm " - "register_ipcp\".\n", *argv); + if (matches(*argv, "ap") == 0) { + api.name = *(argv + 1); + } else if (matches(*argv, "api") == 0) { + api.id = atoi(*(argv + 1)); + } else if (matches(*argv, "dif") == 0) { + difs[difs_size++] = *(argv + 1); + if (difs_size > MAX_DIFS) { + printf("Too many difs specified\n"); return -1; } + } else { + printf("\"%s\" is unknown, try \"irm " + "register_ipcp\".\n", *argv); + return -1; } argc -= 2; argv += 2; } - if (difs_size == 0 || name.ap_name == NULL) { + if (difs_size == 0 || api.name == NULL) { usage(); return -1; } - return irm_reg_ipcp(name, difs, difs_size); + return irm_reg_ipcp(&api, difs, difs_size); } diff --git a/src/tools/irm/irm_unregister_ipcp.c b/src/tools/irm/irm_unregister_ipcp.c index 0b669503..3fd6f148 100644 --- a/src/tools/irm/irm_unregister_ipcp.c +++ b/src/tools/irm/irm_unregister_ipcp.c @@ -45,36 +45,36 @@ static void usage() int do_unregister_ipcp(int argc, char ** argv) { - rina_name_t name; + instance_name_t api = {NULL, 0}; char * difs[MAX_DIFS]; size_t difs_size = 0; - name.ap_name = NULL; - name.api_id = 0; while (argc > 0) { - if (!parse_name(argv, &name)) { - if (matches(*argv, "dif") == 0) { - difs[difs_size++] = *(argv + 1); - if (difs_size > MAX_DIFS) { - printf("Too many difs specified\n"); - return -1; - } - } else { - printf("\"%s\" is unknown, try \"irm " - "unregister_ipcp\".\n", *argv); + if (matches(*argv, "ap") == 0) { + api.name = *(argv + 1); + } else if (matches(*argv, "api") == 0) { + api.id = atoi(*(argv + 1)); + } else if (matches(*argv, "dif") == 0) { + difs[difs_size++] = *(argv + 1); + if (difs_size > MAX_DIFS) { + printf("Too many difs specified\n"); return -1; } + } else { + printf("\"%s\" is unknown, try \"irm " + "unregister_ipcp\".\n", *argv); + return -1; } argc -= 2; argv += 2; } - if (difs_size == 0 || name.ap_name == NULL) { + if (difs_size == 0 || api.name == NULL) { usage(); return -1; } - return irm_unreg_ipcp(name, difs, difs_size); + return irm_unreg_ipcp(&api, difs, difs_size); } diff --git a/src/tools/irm/irm_utils.c b/src/tools/irm/irm_utils.c index 04cb7242..feb8ac98 100644 --- a/src/tools/irm/irm_utils.c +++ b/src/tools/irm/irm_utils.c @@ -36,19 +36,3 @@ int matches(const char * cmd, const char * pattern) return memcmp(pattern, cmd, len); } - - -bool parse_name(char ** argv, - rina_name_t * name) -{ - bool found = true; - - if (matches(*argv, "ap") == 0) - name->ap_name = *(argv + 1); - else if (matches(*argv, "api") == 0) - name->api_id = atoi(*(argv + 1)); - else - found = false; - - return found; -} diff --git a/src/tools/irm/irm_utils.h b/src/tools/irm/irm_utils.h index 2a478d09..da2259c6 100644 --- a/src/tools/irm/irm_utils.h +++ b/src/tools/irm/irm_utils.h @@ -20,10 +20,4 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include <ouroboros/rina_name.h> - -#include <stdbool.h> - int matches(const char * cmd, const char * pattern); - -bool parse_name(char ** argv, rina_name_t * name); |