From 6be9ae98877f23b05f69e6006036fec0f6c9d338 Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Tue, 26 Apr 2016 14:42:05 +0200 Subject: lib: instance ID's are now set to the process PID All instance-id's in ouroboros will be set by the system to the pid of the process associated with this application process instance. This means that the user has no way to choose the instance id's. Function calls that assumed manually defined instance id's have been replaced throughout the system. --- src/tools/irm/irm_create_ipcp.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src/tools/irm/irm_create_ipcp.c') diff --git a/src/tools/irm/irm_create_ipcp.c b/src/tools/irm/irm_create_ipcp.c index 08b55259..3c9b9cb8 100644 --- a/src/tools/irm/irm_create_ipcp.c +++ b/src/tools/irm/irm_create_ipcp.c @@ -39,7 +39,6 @@ static void usage() { printf("Usage: irm create_ipcp\n" " ap \n" - " [api ]\n" " type [TYPE]\n\n" "where TYPE = {" NORMAL " " SHIM_UDP "}\n"); } @@ -47,16 +46,14 @@ static void usage() int do_create_ipcp(int argc, char ** argv) { char * ipcp_type = NULL; - instance_name_t api = {NULL, 0}; + char * ipcp_name = NULL; enum ipcp_type type = 0; while (argc > 0) { 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)); + ipcp_name = *(argv + 1); } else { printf("\"%s\" is unknown, try \"irm " "create_ipcp\".\n", *argv); @@ -67,7 +64,7 @@ int do_create_ipcp(int argc, char ** argv) argv += 2; } - if (ipcp_type == NULL || api.name == NULL) { + if (ipcp_type == NULL || ipcp_name == NULL) { usage(); return -1; } @@ -81,5 +78,5 @@ int do_create_ipcp(int argc, char ** argv) return -1; } - return irm_create_ipcp(&api, type); + return irm_create_ipcp(ipcp_name, type); } -- cgit v1.2.3 From 45b7d79088174303193f8772c9b14fed2011551e Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Tue, 26 Apr 2016 15:24:26 +0200 Subject: lib: irm.h create_ipcp now returns pid_t ipcp_create now returns the pid of the created process to allow for more efficient scripting. --- include/ouroboros/irm.h | 6 ++++-- src/irmd/main.c | 6 +++--- src/lib/irm.c | 4 ++-- src/tools/irm/irm_create_ipcp.c | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) (limited to 'src/tools/irm/irm_create_ipcp.c') diff --git a/include/ouroboros/irm.h b/include/ouroboros/irm.h index 26ff536a..37524098 100644 --- a/include/ouroboros/irm.h +++ b/include/ouroboros/irm.h @@ -26,8 +26,10 @@ #include #include -int irm_create_ipcp(char * ipcp_name, - enum ipcp_type ipcp_type); +#include + +pid_t irm_create_ipcp(char * ipcp_name, + enum ipcp_type ipcp_type); int irm_destroy_ipcp(instance_name_t * api); diff --git a/src/irmd/main.c b/src/irmd/main.c index c47bcffc..31dabebb 100644 --- a/src/irmd/main.c +++ b/src/irmd/main.c @@ -218,8 +218,8 @@ static int reg_name_entry_del_name(char * name) return 0; } -static int create_ipcp(char * ap_name, - enum ipcp_type ipcp_type) +static pid_t create_ipcp(char * ap_name, + enum ipcp_type ipcp_type) { pid_t pid; struct ipcp_entry * tmp = NULL; @@ -254,7 +254,7 @@ static int create_ipcp(char * ap_name, LOG_DBG("Created IPC process with pid %d", pid); list_add(&tmp->next, &instance->ipcps); - return 0; + return pid; } static int destroy_ipcp(instance_name_t * api) diff --git a/src/lib/irm.c b/src/lib/irm.c index d3c77f2e..cc1c0d01 100644 --- a/src/lib/irm.c +++ b/src/lib/irm.c @@ -30,8 +30,8 @@ #include -int irm_create_ipcp(char * ipcp_name, - enum ipcp_type ipcp_type) +pid_t irm_create_ipcp(char * ipcp_name, + enum ipcp_type ipcp_type) { irm_msg_t msg = IRM_MSG__INIT; irm_msg_t * recv_msg = NULL; diff --git a/src/tools/irm/irm_create_ipcp.c b/src/tools/irm/irm_create_ipcp.c index 3c9b9cb8..e82bd980 100644 --- a/src/tools/irm/irm_create_ipcp.c +++ b/src/tools/irm/irm_create_ipcp.c @@ -78,5 +78,5 @@ int do_create_ipcp(int argc, char ** argv) return -1; } - return irm_create_ipcp(ipcp_name, type); + return !irm_create_ipcp(ipcp_name, type); } -- cgit v1.2.3