summaryrefslogtreecommitdiff
path: root/src/tools/irm
diff options
context:
space:
mode:
authorSander Vrijders <sander.vrijders@intec.ugent.be>2016-03-28 14:43:16 +0200
committerSander Vrijders <sander.vrijders@intec.ugent.be>2016-03-28 14:43:16 +0200
commita14d696bdbc72754e8019fa9579d5a338cc85a05 (patch)
tree2533a574e03a9954b9eeaf7750219d3175ce8b99 /src/tools/irm
parentd37add0f20c93432c0b4c12866810c124a7a18ec (diff)
downloadouroboros-a14d696bdbc72754e8019fa9579d5a338cc85a05.tar.gz
ouroboros-a14d696bdbc72754e8019fa9579d5a338cc85a05.zip
lib: Update irm.h API
Removes rina_name_t from that API. Passing ap_name and api_id as params instead. The IRM tool has been updated accordingly. Some errors in the build related to protobuf-c have also been resolved.
Diffstat (limited to 'src/tools/irm')
-rw-r--r--src/tools/irm/irm_bootstrap_ipcp.c20
-rw-r--r--src/tools/irm/irm_create_ipcp.c28
-rw-r--r--src/tools/irm/irm_destroy_ipcp.c17
-rw-r--r--src/tools/irm/irm_enroll_ipcp.c29
-rw-r--r--src/tools/irm/irm_register_ipcp.c32
-rw-r--r--src/tools/irm/irm_unregister_ipcp.c31
-rw-r--r--src/tools/irm/irm_utils.c16
-rw-r--r--src/tools/irm/irm_utils.h2
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);