summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/tools/irm/irm.c8
-rw-r--r--src/tools/irm/irm_bootstrap_ipcp.c40
-rw-r--r--src/tools/irm/irm_create_ipcp.c41
-rw-r--r--src/tools/irm/irm_destroy_ipcp.c37
-rw-r--r--src/tools/irm/irm_enroll_ipcp.c43
-rw-r--r--src/tools/irm/irm_register_ipcp.c56
-rw-r--r--src/tools/irm/irm_unregister_ipcp.c56
-rw-r--r--src/tools/irm/irm_utils.c25
-rw-r--r--src/tools/irm/irm_utils.h4
9 files changed, 271 insertions, 39 deletions
diff --git a/src/tools/irm/irm.c b/src/tools/irm/irm.c
index cca8def4..44018b90 100644
--- a/src/tools/irm/irm.c
+++ b/src/tools/irm/irm.c
@@ -33,8 +33,7 @@ static void usage()
printf("Usage: irm [OPERATION]\n\n"
"where OPERATION = {create_ipcp destroy_ipcp \n"
" bootstrap_ipcp enroll_ipcp\n"
- " register_ipcp unregister_ipcp\n"
- " help}\n");
+ " register_ipcp unregister_ipcp\n");
}
static int do_help(int argc, char **argv)
@@ -65,10 +64,11 @@ static int do_cmd(const char * argv0,
for (c = cmds; c->cmd; ++c) {
if (matches(argv0, c->cmd) == 0)
- return -(c->func(argc-1, argv+1));
+ return c->func(argc - 1, argv + 1);
}
fprintf(stderr, "\"%s\" is unknown, try \"irm help\".\n", argv0);
+
return -1;
}
@@ -80,5 +80,5 @@ int main (int argc, char ** argv) {
return 0;
}
- return do_cmd(argv[1], argc-1, argv+1);
+ return do_cmd(argv[1], argc - 1, argv + 1);
}
diff --git a/src/tools/irm/irm_bootstrap_ipcp.c b/src/tools/irm/irm_bootstrap_ipcp.c
index ca0fba0e..6b640c14 100644
--- a/src/tools/irm/irm_bootstrap_ipcp.c
+++ b/src/tools/irm/irm_bootstrap_ipcp.c
@@ -21,12 +21,48 @@
*/
#include <stdio.h>
+#include <ouroboros/irm.h>
+#include <ouroboros/common.h>
#include "irm_ops.h"
+#include "irm_utils.h"
+
+static void usage()
+{
+ /* FIXME: Add dif_info stuff */
+ printf("Usage: irm bootstrap_ipcp\n"
+ " ap <application process name>\n"
+ " [api <application process instance>]\n"
+ " [ae <application entity name]\n"
+ " [aei <application entity instance>]\n");
+}
+
int do_bootstrap_ipcp(int argc, char ** argv)
{
- printf("Nothing here in %s\n", __FUNCTION__);
+ rina_name_t name;
+ struct dif_info info;
+
+ name.ap_name = NULL;
+ name.api_id = 0;
+ name.ae_name = "";
+ name.aei_id = 0;
+
+ while (argc > 0) {
+ if (!parse_name(argv, &name)) {
+ printf("\"%s\" is unknown, try \"irm "
+ "enroll_ipcp\".\n", *argv);
+ return -1;
+ }
+
+ argc -= 2;
+ argv += 2;
+ }
+
+ if (name.ap_name == NULL) {
+ usage();
+ return -1;
+ }
- return -1;
+ return irm_bootstrap_ipcp(name, info);
}
diff --git a/src/tools/irm/irm_create_ipcp.c b/src/tools/irm/irm_create_ipcp.c
index 5a8478e6..5c847988 100644
--- a/src/tools/irm/irm_create_ipcp.c
+++ b/src/tools/irm/irm_create_ipcp.c
@@ -22,6 +22,7 @@
#include <stdio.h>
#include <ouroboros/irm.h>
+#include <ouroboros/common.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
@@ -41,43 +42,33 @@ static void usage()
int do_create_ipcp(int argc, char ** argv)
{
- char * ap_name = NULL;
- int api_id = 0;
- char * ae_name = "";
- int aei_id = 0;
rina_name_t name;
char * ipcp_type = NULL;
+ name.ap_name = NULL;
+ name.api_id = 0;
+ name.ae_name = "";
+ name.aei_id = 0;
+
while (argc > 0) {
- if (matches(*argv, "ap") == 0) {
- ap_name = *(argv + 1);
- } else if (matches(*argv, "api") == 0) {
- api_id = atoi(*(argv + 1));
- } else if (matches(*argv, "ae") == 0) {
- ae_name = *(argv + 1);
- } else if (matches(*argv, "aei") == 0) {
- aei_id = atoi(*(argv + 1));
- } else if (matches(*argv, "type") == 0) {
- ipcp_type = *(argv + 1);
- } else {
- printf("\"%s\" is unknown, try \"irm "
- "create_ipcp\".\n", *argv);
- return -1;
+ 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;
+ }
}
argc -= 2;
- argv += 2;;
+ argv += 2;
}
- if (ipcp_type == NULL || ap_name == NULL) {
+ if (ipcp_type == NULL || name.ap_name == NULL) {
usage();
return -1;
}
- name.ap_name = ap_name;
- name.api_id = api_id;
- name.ae_name = ae_name;
- name.aei_id = aei_id;
-
return irm_create_ipcp(name, ipcp_type);
}
diff --git a/src/tools/irm/irm_destroy_ipcp.c b/src/tools/irm/irm_destroy_ipcp.c
index 69170b11..467d1b50 100644
--- a/src/tools/irm/irm_destroy_ipcp.c
+++ b/src/tools/irm/irm_destroy_ipcp.c
@@ -21,12 +21,45 @@
*/
#include <stdio.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"
+ " [ae <application entity name]\n"
+ " [aei <application entity instance>]\n");
+}
int do_destroy_ipcp(int argc, char ** argv)
{
- printf("Nothing here in %s\n", __FUNCTION__);
+ rina_name_t name;
+
+ name.ap_name = NULL;
+ name.api_id = 0;
+ name.ae_name = "";
+ name.aei_id = 0;
+
+ while (argc > 0) {
+ if (!parse_name(argv, &name)) {
+ printf("\"%s\" is unknown, try \"irm "
+ "destroy_ipcp\".\n", *argv);
+ return -1;
+ }
+
+ argc -= 2;
+ argv += 2;
+ }
+
+ if (name.ap_name == NULL) {
+ usage();
+ return -1;
+ }
- return -1;
+ return irm_destroy_ipcp(name);
}
diff --git a/src/tools/irm/irm_enroll_ipcp.c b/src/tools/irm/irm_enroll_ipcp.c
index 058feee2..94f28f82 100644
--- a/src/tools/irm/irm_enroll_ipcp.c
+++ b/src/tools/irm/irm_enroll_ipcp.c
@@ -21,12 +21,51 @@
*/
#include <stdio.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"
+ " [ae <application entity name]\n"
+ " [aei <application entity instance>]\n"
+ " dif <dif to enroll in>\n");
+}
int do_enroll_ipcp(int argc, char ** argv)
{
- printf("Nothing here in %s\n", __FUNCTION__);
+ rina_name_t name;
+ char * dif_name = NULL;
+
+ name.ap_name = NULL;
+ name.api_id = 0;
+ name.ae_name = "";
+ name.aei_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;
+ }
+ }
+
+ argc -= 2;
+ argv += 2;
+ }
+
+ if (dif_name == NULL || name.ap_name == NULL) {
+ usage();
+ return -1;
+ }
- return -1;
+ return irm_enroll_ipcp(name, dif_name);
}
diff --git a/src/tools/irm/irm_register_ipcp.c b/src/tools/irm/irm_register_ipcp.c
index f271afc4..c69ad350 100644
--- a/src/tools/irm/irm_register_ipcp.c
+++ b/src/tools/irm/irm_register_ipcp.c
@@ -21,12 +21,64 @@
*/
#include <stdio.h>
+#include <ouroboros/irm.h>
+#include <ouroboros/common.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
#include "irm_ops.h"
+#include "irm_utils.h"
+
+#define MAX_DIFS 128
+
+static void usage()
+{
+ printf("Usage: irm register_ipcp\n"
+ " ap <application process name>\n"
+ " [api <application process instance>]\n"
+ " [ae <application entity name]\n"
+ " [aei <application entity instance>]\n"
+ " dif <dif name to register with>\n"
+ " [dif <dif name to register with>]\n"
+ " [... (maximum %d difs)]\n", MAX_DIFS);
+}
+
int do_register_ipcp(int argc, char ** argv)
{
- printf("Nothing here in %s\n", __FUNCTION__);
+ rina_name_t name;
+ char * difs[MAX_DIFS];
+ size_t difs_size = 0;
+
+ name.ap_name = NULL;
+ name.api_id = 0;
+ name.ae_name = "";
+ name.aei_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);
+ return -1;
+ }
+ }
+
+ argc -= 2;
+ argv += 2;
+ }
+
+ if (difs_size == 0 || name.ap_name == NULL) {
+ usage();
+ return -1;
+ }
- return -1;
+ return irm_reg_ipcp(name, difs, difs_size);
}
diff --git a/src/tools/irm/irm_unregister_ipcp.c b/src/tools/irm/irm_unregister_ipcp.c
index bda406c7..a2dffc6c 100644
--- a/src/tools/irm/irm_unregister_ipcp.c
+++ b/src/tools/irm/irm_unregister_ipcp.c
@@ -21,12 +21,64 @@
*/
#include <stdio.h>
+#include <ouroboros/irm.h>
+#include <ouroboros/common.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
#include "irm_ops.h"
+#include "irm_utils.h"
+
+#define MAX_DIFS 128
+
+static void usage()
+{
+ printf("Usage: irm unregister_ipcp\n"
+ " ap <application process name>\n"
+ " [api <application process instance>]\n"
+ " [ae <application entity name]\n"
+ " [aei <application entity instance>]\n"
+ " dif <dif name to unregister from>\n"
+ " [dif <dif name to unregister from>]\n"
+ " [... (maximum %d difs)]\n", MAX_DIFS);
+}
+
int do_unregister_ipcp(int argc, char ** argv)
{
- printf("Nothing here in %s\n", __FUNCTION__);
+ rina_name_t name;
+ char * difs[MAX_DIFS];
+ size_t difs_size = 0;
+
+ name.ap_name = NULL;
+ name.api_id = 0;
+ name.ae_name = "";
+ name.aei_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);
+ return -1;
+ }
+ }
+
+ argc -= 2;
+ argv += 2;
+ }
+
+ if (difs_size == 0 || name.ap_name == NULL) {
+ usage();
+ return -1;
+ }
- return -1;
+ return irm_unreg_ipcp(name, difs, difs_size);
}
diff --git a/src/tools/irm/irm_utils.c b/src/tools/irm/irm_utils.c
index 34bec18c..021227fd 100644
--- a/src/tools/irm/irm_utils.c
+++ b/src/tools/irm/irm_utils.c
@@ -21,6 +21,11 @@
*/
#include <string.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <ouroboros/common.h>
+
+#include "irm_utils.h"
int matches(const char * cmd, const char * pattern)
{
@@ -31,3 +36,23 @@ 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 if (matches(*argv, "ae") == 0)
+ name->ae_name = *(argv + 1);
+ else if (matches(*argv, "aei") == 0)
+ name->aei_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 da2259c6..9332b108 100644
--- a/src/tools/irm/irm_utils.h
+++ b/src/tools/irm/irm_utils.h
@@ -20,4 +20,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+#include <stdbool.h>
+
int matches(const char * cmd, const char * pattern);
+
+bool parse_name(char ** argv, rina_name_t * name);