diff options
author | Dimitri Staessens <dimitri.staessens@intec.ugent.be> | 2016-03-29 12:06:58 +0200 |
---|---|---|
committer | Dimitri Staessens <dimitri.staessens@intec.ugent.be> | 2016-03-29 12:06:58 +0200 |
commit | 1d4442e472d20f261986089ea468daa93631d1f4 (patch) | |
tree | 3b27a134c762190b096de421310a50910dca4a34 /src/tools | |
parent | e5d67f7d4df123c2490201447681f2efd553dcc1 (diff) | |
parent | 37c4ccaf59a0406053573e14909be48322ffb084 (diff) | |
download | ouroboros-1d4442e472d20f261986089ea468daa93631d1f4.tar.gz ouroboros-1d4442e472d20f261986089ea468daa93631d1f4.zip |
Merged in sandervrijders/ouroboros/be-gpb (pull request #45)
Replace custom ser/des with GPB
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/irm/irm_bootstrap_ipcp.c | 20 | ||||
-rw-r--r-- | src/tools/irm/irm_create_ipcp.c | 28 | ||||
-rw-r--r-- | src/tools/irm/irm_destroy_ipcp.c | 17 | ||||
-rw-r--r-- | src/tools/irm/irm_enroll_ipcp.c | 29 | ||||
-rw-r--r-- | src/tools/irm/irm_register_ipcp.c | 32 | ||||
-rw-r--r-- | src/tools/irm/irm_unregister_ipcp.c | 31 | ||||
-rw-r--r-- | src/tools/irm/irm_utils.c | 16 | ||||
-rw-r--r-- | src/tools/irm/irm_utils.h | 2 |
8 files changed, 83 insertions, 92 deletions
diff --git a/src/tools/irm/irm_bootstrap_ipcp.c b/src/tools/irm/irm_bootstrap_ipcp.c index 89950069..0843083d 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,32 @@ static void usage() int do_bootstrap_ipcp(int argc, char ** argv) { - rina_name_t name; + char * ap_name = NULL; + int api_id = 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) { + ap_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 (ap_name == NULL) { usage(); return -1; } - return irm_bootstrap_ipcp(name, conf); + return irm_bootstrap_ipcp(ap_name, api_id, &conf); } diff --git a/src/tools/irm/irm_create_ipcp.c b/src/tools/irm/irm_create_ipcp.c index 854a15f9..3262bd5c 100644 --- a/src/tools/irm/irm_create_ipcp.c +++ b/src/tools/irm/irm_create_ipcp.c @@ -40,31 +40,31 @@ 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; + char * ap_name = NULL; + int api_id = 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) { + ap_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 || ap_name == NULL) { usage(); return -1; } - return irm_create_ipcp(name, ipcp_type); + return irm_create_ipcp(ap_name, api_id, ipcp_type); } diff --git a/src/tools/irm/irm_destroy_ipcp.c b/src/tools/irm/irm_destroy_ipcp.c index 4f02f9cb..fbbeb5bd 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,15 @@ static void usage() int do_destroy_ipcp(int argc, char ** argv) { - rina_name_t name; - - name.ap_name = NULL; - name.api_id = 0; + char * ap_name = NULL; + int api_id = 0; while (argc > 0) { - if (!parse_name(argv, &name)) { + if (matches(*argv, "ap") == 0) { + ap_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 +55,10 @@ int do_destroy_ipcp(int argc, char ** argv) argv += 2; } - if (name.ap_name == NULL) { + if (ap_name == NULL) { usage(); return -1; } - return irm_destroy_ipcp(name); + return irm_destroy_ipcp(ap_name, api_id); } diff --git a/src/tools/irm/irm_enroll_ipcp.c b/src/tools/irm/irm_enroll_ipcp.c index 1dcdc919..70798821 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,31 @@ static void usage() int do_enroll_ipcp(int argc, char ** argv) { - rina_name_t name; + char * ap_name = NULL; + int api_id = 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) { + ap_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 || ap_name == NULL) { usage(); return -1; } - return irm_enroll_ipcp(name, dif_name); + return irm_enroll_ipcp(ap_name, api_id, dif_name); } diff --git a/src/tools/irm/irm_register_ipcp.c b/src/tools/irm/irm_register_ipcp.c index 468ef28f..b8808ecd 100644 --- a/src/tools/irm/irm_register_ipcp.c +++ b/src/tools/irm/irm_register_ipcp.c @@ -45,36 +45,36 @@ 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; + char * ap_name = NULL; + int 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 " - "register_ipcp\".\n", *argv); + if (matches(*argv, "ap") == 0) { + ap_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 || ap_name == NULL) { usage(); return -1; } - return irm_reg_ipcp(name, difs, difs_size); + return irm_reg_ipcp(ap_name, api_id, difs, difs_size); } diff --git a/src/tools/irm/irm_unregister_ipcp.c b/src/tools/irm/irm_unregister_ipcp.c index 0b669503..1321c263 100644 --- a/src/tools/irm/irm_unregister_ipcp.c +++ b/src/tools/irm/irm_unregister_ipcp.c @@ -45,36 +45,37 @@ static void usage() int do_unregister_ipcp(int argc, char ** argv) { - rina_name_t name; + char * ap_name = NULL; + int api_id = 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) { + ap_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 || ap_name == NULL) { usage(); return -1; } - return irm_unreg_ipcp(name, difs, difs_size); + return irm_unreg_ipcp(ap_name, api_id, 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..3d328d95 100644 --- a/src/tools/irm/irm_utils.h +++ b/src/tools/irm/irm_utils.h @@ -25,5 +25,3 @@ #include <stdbool.h> int matches(const char * cmd, const char * pattern); - -bool parse_name(char ** argv, rina_name_t * name); |