From f4f67651db3891652f4dd08dec990aa0560bb35c Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Fri, 22 Apr 2016 17:39:30 +0200 Subject: irmd: reg/unreg whatevercast names Unregistering ap's now works. An AP now registers/unregisters its AP-I by sending its AP name and its pid to the IRMd. The IPCPs register whatevercast names. An AP name is currently mapped on a whatevercast name represented by the same string literal. The IRMd allows registration of only one AP-I per AP. A Name Space Management system is needed in the processing system so we can resolve this completely. Changing the stack to register whatevercast names required some changes all over the ipcpd implemented and in the library. --- include/ouroboros/ipcp.h | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'include') diff --git a/include/ouroboros/ipcp.h b/include/ouroboros/ipcp.h index 3198a882..1c8d3f86 100644 --- a/include/ouroboros/ipcp.h +++ b/include/ouroboros/ipcp.h @@ -54,15 +54,14 @@ int ipcp_bootstrap(pid_t pid, /* Flow related ops, these go from IRMd to IPCP */ -int ipcp_ap_reg(pid_t pid, - uint32_t reg_api_id, - char * ap_name); -int ipcp_ap_unreg(pid_t pid, - uint32_t reg_api_id); +int ipcp_name_reg(pid_t pid, + char * name); +int ipcp_name_unreg(pid_t pid, + char * name); int ipcp_flow_alloc(pid_t pid, uint32_t port_id, - char * dst_ap_name, + char * dst_name, char * src_ap_name, char * src_ae_name, struct qos_spec * qos); @@ -73,13 +72,13 @@ int ipcp_flow_alloc_resp(pid_t pid, /* These operations go from the IPCP to the IRMd */ /* Returns the port_id */ -int ipcp_flow_req_arr(pid_t pid, - uint32_t reg_api_id, - char * ap_name, - char * ae_name); +int ipcp_flow_req_arr(pid_t pid, + char * dst_name, + char * src_ap_name, + char * src_ae_name); int ipcp_flow_alloc_reply(pid_t pid, uint32_t port_id, - int result); + int response); /* * This operation can go both ways -- cgit v1.2.3 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. --- include/ouroboros/ipcp.h | 4 +- include/ouroboros/irm.h | 4 +- src/ipcpd/ipcp-data.c | 18 ++++- src/ipcpd/ipcp-data.h | 2 +- src/ipcpd/ipcp.c | 3 +- src/ipcpd/shim-udp/main.c | 29 ++----- src/ipcpd/shim-udp/tests/shim_udp_test.c | 3 +- src/irmd/main.c | 127 +++++++++++++++---------------- src/lib/ipcp.c | 21 +---- src/lib/irm.c | 10 +-- src/tools/irm/irm_create_ipcp.c | 11 +-- 11 files changed, 101 insertions(+), 131 deletions(-) (limited to 'include') diff --git a/include/ouroboros/ipcp.h b/include/ouroboros/ipcp.h index 1c8d3f86..e3c17bda 100644 --- a/include/ouroboros/ipcp.h +++ b/include/ouroboros/ipcp.h @@ -33,8 +33,8 @@ struct ipcp; /* Returns the process id */ -pid_t ipcp_create(instance_name_t * api, - enum ipcp_type ipcp_type); +pid_t ipcp_create(char * ipcp_name, + enum ipcp_type ipcp_type); int ipcp_destroy(pid_t pid); diff --git a/include/ouroboros/irm.h b/include/ouroboros/irm.h index 24bb2c42..26ff536a 100644 --- a/include/ouroboros/irm.h +++ b/include/ouroboros/irm.h @@ -26,8 +26,8 @@ #include #include -int irm_create_ipcp(instance_name_t * api, - enum ipcp_type ipcp_type); +int irm_create_ipcp(char * ipcp_name, + enum ipcp_type ipcp_type); int irm_destroy_ipcp(instance_name_t * api); diff --git a/src/ipcpd/ipcp-data.c b/src/ipcpd/ipcp-data.c index e6997e3e..106226de 100644 --- a/src/ipcpd/ipcp-data.c +++ b/src/ipcpd/ipcp-data.c @@ -104,18 +104,28 @@ struct ipcp_data * ipcp_data_create() } struct ipcp_data * ipcp_data_init(struct ipcp_data * dst, - instance_name_t * iname, - enum ipcp_type ipcp_type) + const char * ipcp_name, + enum ipcp_type ipcp_type) { if (dst == NULL) return NULL; - dst->iname = instance_name_dup(iname); + dst->iname = instance_name_create(); + if (dst->iname == NULL) + return NULL; + + if(instance_name_init_from(dst->iname, ipcp_name, getpid()) == NULL) { + instance_name_destroy(dst->iname); + return NULL; + } + dst->type = ipcp_type; dst->dum = shm_du_map_open(); - if (dst->dum == NULL) + if (dst->dum == NULL) { + instance_name_destroy(dst->iname); return NULL; + } /* init the lists */ INIT_LIST_HEAD(&dst->registry); diff --git a/src/ipcpd/ipcp-data.h b/src/ipcpd/ipcp-data.h index 7e48df24..1dea8c3c 100644 --- a/src/ipcpd/ipcp-data.h +++ b/src/ipcpd/ipcp-data.h @@ -53,7 +53,7 @@ struct ipcp_data { struct ipcp_data * ipcp_data_create(); struct ipcp_data * ipcp_data_init(struct ipcp_data * dst, - instance_name_t * iname, + const char * ipcp_name, enum ipcp_type ipcp_type); void ipcp_data_destroy(struct ipcp_data * data); diff --git a/src/ipcpd/ipcp.c b/src/ipcpd/ipcp.c index c1071e05..23c432f1 100644 --- a/src/ipcpd/ipcp.c +++ b/src/ipcpd/ipcp.c @@ -31,7 +31,7 @@ int ipcp_arg_check(int argc, char * argv[]) { - if (argc != 4) + if (argc != 3) return -1; /* argument 1: pid of irmd */ @@ -41,7 +41,6 @@ int ipcp_arg_check(int argc, char * argv[]) /* name conformity responsibility of NMS */ /* argument 2: ap name */ - /* argument 3: instance id */ return 0; } diff --git a/src/ipcpd/shim-udp/main.c b/src/ipcpd/shim-udp/main.c index f67c66ca..785f2344 100644 --- a/src/ipcpd/shim-udp/main.c +++ b/src/ipcpd/shim-udp/main.c @@ -96,7 +96,7 @@ void ipcp_sig_handler(int sig, siginfo_t * info, void * c) case SIGHUP: LOG_DBG("Terminating by order of %d. Bye.", info->si_pid); if (info->si_pid == irmd_pid) { - shm_du_map_close(_ipcp->data->dum); + /* shm_du_map_close(_ipcp->data->dum); */ exit(0); } default: @@ -104,29 +104,13 @@ void ipcp_sig_handler(int sig, siginfo_t * info, void * c) } } -struct ipcp_udp_data * ipcp_udp_data_create(char * ap_name, - char * ap_id) +struct ipcp_udp_data * ipcp_udp_data_create(char * ap_name) { struct ipcp_udp_data * udp_data; struct ipcp_data * data; - instance_name_t * instance_name; enum ipcp_type ipcp_type; int n; - instance_name = instance_name_create(); - if (instance_name == NULL) { - LOG_ERR("Failed to create instance name struct."); - return NULL; - } - - instance_name = instance_name_init_with( - instance_name, ap_name, (uint16_t) atoi(ap_id)); - - if (instance_name == NULL) { - LOG_ERR("Failed to create instance name struct."); - return NULL; - } - udp_data = malloc(sizeof *udp_data); if (udp_data == NULL) { LOG_DBGF("Failed to allocate."); @@ -135,7 +119,7 @@ struct ipcp_udp_data * ipcp_udp_data_create(char * ap_name, ipcp_type = THIS_TYPE; data = (struct ipcp_data *) udp_data; - if (ipcp_data_init(data, instance_name, ipcp_type) == NULL) { + if (ipcp_data_init(data, ap_name, ipcp_type) == NULL) { free(udp_data); return NULL; } @@ -548,7 +532,7 @@ int ipcp_udp_du_read(uint32_t port_id, return 0; } -struct ipcp * ipcp_udp_create(char * ap_name, char * i_id) +struct ipcp * ipcp_udp_create(char * ap_name) { struct ipcp * i; struct ipcp_udp_data * data; @@ -558,7 +542,7 @@ struct ipcp * ipcp_udp_create(char * ap_name, char * i_id) if (i == NULL) return NULL; - data = ipcp_udp_data_create(ap_name, i_id); + data = ipcp_udp_data_create(ap_name); if (data == NULL) { free(i); return NULL; @@ -597,7 +581,6 @@ int main (int argc, char * argv[]) { /* argument 1: pid of irmd ? */ /* argument 2: ap name */ - /* argument 3: instance id */ struct sigaction sig_act; if (ipcp_arg_check(argc, argv)) { @@ -619,7 +602,7 @@ int main (int argc, char * argv[]) sigaction(SIGTERM, &sig_act, NULL); sigaction(SIGHUP, &sig_act, NULL); - _ipcp = ipcp_udp_create(argv[2], argv[3]); + _ipcp = ipcp_udp_create(argv[2]); if (_ipcp == NULL) { LOG_ERR("Won't."); exit(1); diff --git a/src/ipcpd/shim-udp/tests/shim_udp_test.c b/src/ipcpd/shim-udp/tests/shim_udp_test.c index 0fcf9f4d..4e0c2dd6 100644 --- a/src/ipcpd/shim-udp/tests/shim_udp_test.c +++ b/src/ipcpd/shim-udp/tests/shim_udp_test.c @@ -39,7 +39,6 @@ int shim_udp_test(int argc, char ** argv) /* argument 3: instance id */ struct shm_du_map * dum; char * ipcp_name = "test-shim-ipcp"; - char * i_id = "1"; int i = 0; char bogus[15]; @@ -57,7 +56,7 @@ int shim_udp_test(int argc, char ** argv) exit(1); } - _ipcp = ipcp_udp_create(ipcp_name, i_id); + _ipcp = ipcp_udp_create(ipcp_name); if (_ipcp == NULL) { LOG_ERR("Could not instantiate shim IPCP."); shm_du_map_close(dum); diff --git a/src/irmd/main.c b/src/irmd/main.c index df3070f4..c47bcffc 100644 --- a/src/irmd/main.c +++ b/src/irmd/main.c @@ -48,7 +48,6 @@ struct ipcp_entry { struct list_head next; - pid_t pid; instance_name_t * api; char * dif_name; }; @@ -75,8 +74,9 @@ struct irm { struct irm * instance = NULL; -static pid_t find_pid_by_ipcp_name(instance_name_t * api) +static struct ipcp_entry * find_ipcp_entry_by_name(instance_name_t * api) { + struct ipcp_entry * tmp = NULL; struct list_head * pos = NULL; list_for_each(pos, &instance->ipcps) { @@ -84,44 +84,43 @@ static pid_t find_pid_by_ipcp_name(instance_name_t * api) list_entry(pos, struct ipcp_entry, next); if (instance_name_cmp(api, tmp->api) == 0) - return tmp->pid; + return tmp; } - return 0; + return tmp; } -static struct ipcp_entry * find_ipcp_by_name(instance_name_t * api) +static instance_name_t * get_ipcp_by_name(char * ap_name) { - struct ipcp_entry * tmp = NULL; struct list_head * pos = NULL; list_for_each(pos, &instance->ipcps) { - struct ipcp_entry * tmp = + struct ipcp_entry * e = list_entry(pos, struct ipcp_entry, next); - if (instance_name_cmp(api, tmp->api) == 0) - return tmp; + if (strcmp(e->api->name, ap_name) == 0) + return e->api; } - return tmp; + return NULL; } -static pid_t find_pid_by_dif_name(char * dif_name) +static instance_name_t * get_ipcp_by_dif_name(char * dif_name) { struct list_head * pos = NULL; list_for_each(pos, &instance->ipcps) { - struct ipcp_entry * tmp = + struct ipcp_entry * e = list_entry(pos, struct ipcp_entry, next); - if (tmp->dif_name == NULL) - return tmp->pid; + if (e->dif_name == NULL) + continue; - if (strcmp(dif_name, tmp->dif_name) == 0) - return tmp->pid; + if (strcmp(dif_name, e->dif_name) == 0) + return e->api; } - return 0; + return NULL; } static struct reg_name_entry * reg_name_entry_create() @@ -219,13 +218,13 @@ static int reg_name_entry_del_name(char * name) return 0; } -static int create_ipcp(instance_name_t * api, - enum ipcp_type ipcp_type) +static int create_ipcp(char * ap_name, + enum ipcp_type ipcp_type) { pid_t pid; struct ipcp_entry * tmp = NULL; - pid = ipcp_create(api, ipcp_type); + pid = ipcp_create(ap_name, ipcp_type); if (pid == -1) { LOG_ERR("Failed to create IPCP"); return -1; @@ -238,13 +237,18 @@ static int create_ipcp(instance_name_t * api, INIT_LIST_HEAD(&tmp->next); - tmp->pid = pid; - tmp->api = instance_name_dup(api); + tmp->api = instance_name_create(); if (tmp->api == NULL) { free(tmp); return -1; } + if(instance_name_init_from(tmp->api, ap_name, pid) == NULL) { + instance_name_destroy(tmp->api); + free(tmp); + return -1; + } + tmp->dif_name = NULL; LOG_DBG("Created IPC process with pid %d", pid); @@ -255,19 +259,20 @@ static int create_ipcp(instance_name_t * api, static int destroy_ipcp(instance_name_t * api) { - pid_t pid = 0; struct list_head * pos = NULL; struct list_head * n = NULL; - pid = find_pid_by_ipcp_name(api); - if (pid == 0) { - LOG_ERR("No such IPCP"); + if (api->id == 0) + api = get_ipcp_by_name(api->name); + + if (api == NULL) { + LOG_ERR("No such IPCP in the system."); return -1; } - LOG_DBG("Destroying ipcp with pid %d", pid); + LOG_DBG("Destroying ipcp %s-%d", api->name, api->id); - if (ipcp_destroy(pid)) + if (ipcp_destroy(api->id)) LOG_ERR("Could not destroy IPCP"); list_for_each_safe(pos, n, &(instance->ipcps)) { @@ -286,7 +291,15 @@ static int bootstrap_ipcp(instance_name_t * api, { struct ipcp_entry * entry = NULL; - entry = find_ipcp_by_name(api); + if (api->id == 0) + api = get_ipcp_by_name(api->name); + + if (api == NULL) { + LOG_ERR("No such IPCP in the system."); + return -1; + } + + entry = find_ipcp_entry_by_name(api); if (entry == NULL) { LOG_ERR("No such IPCP"); return -1; @@ -298,7 +311,7 @@ static int bootstrap_ipcp(instance_name_t * api, return -1; } - if (ipcp_bootstrap(entry->pid, conf)) { + if (ipcp_bootstrap(entry->api->id, conf)) { LOG_ERR("Could not bootstrap IPCP"); free(entry->dif_name); entry->dif_name = NULL; @@ -316,7 +329,7 @@ static int enroll_ipcp(instance_name_t * api, ssize_t n_1_difs_size = 0; struct ipcp_entry * entry = NULL; - entry = find_ipcp_by_name(api); + entry = find_ipcp_entry_by_name(api); if (entry == NULL) { LOG_ERR("No such IPCP"); return -1; @@ -344,7 +357,7 @@ static int enroll_ipcp(instance_name_t * api, return -1; } - if (ipcp_enroll(entry->pid, member, n_1_difs[0])) { + if (ipcp_enroll(entry->api->id, member, n_1_difs[0])) { LOG_ERR("Could not enroll IPCP"); free(entry->dif_name); entry->dif_name = NULL; @@ -358,15 +371,7 @@ static int reg_ipcp(instance_name_t * api, char ** difs, size_t difs_size) { - pid_t pid = 0; - - pid = find_pid_by_ipcp_name(api); - if (pid == 0) { - LOG_ERR("No such IPCP"); - return -1; - } - - if (ipcp_reg(pid, difs, difs_size)) { + if (ipcp_reg(api->id, difs, difs_size)) { LOG_ERR("Could not register IPCP to N-1 DIF(s)"); return -1; } @@ -378,15 +383,8 @@ static int unreg_ipcp(instance_name_t * api, char ** difs, size_t difs_size) { - pid_t pid = 0; - - pid = find_pid_by_ipcp_name(api); - if (pid == 0) { - LOG_ERR("No such IPCP"); - return -1; - } - if (ipcp_unreg(pid, difs, difs_size)) { + if (ipcp_unreg(api->id, difs, difs_size)) { LOG_ERR("Could not unregister IPCP from N-1 DIF(s)"); return -1; } @@ -418,7 +416,7 @@ static int ap_unreg_id(uint32_t reg_ap_id, struct ipcp_entry * e = list_entry(pos, struct ipcp_entry, next); - if (ipcp_name_unreg(e->pid, rne->name)) { + if (ipcp_name_unreg(e->api->id, rne->name)) { LOG_ERR("Could not unregister %s in DIF %s.", rne->name, e->dif_name); --ret; @@ -426,12 +424,6 @@ static int ap_unreg_id(uint32_t reg_ap_id, } } else { for (i = 0; i < len; ++i) { - pid = find_pid_by_dif_name(difs[i]); - if (pid == 0) { - LOG_ERR("%s: No such DIF.", difs[i]); - continue; - } - if (ipcp_name_unreg(pid, rne->name)) { LOG_ERR("Could not unregister %s in DIF %s.", rne->name, difs[i]); @@ -450,14 +442,14 @@ static int ap_reg(char * ap_name, char ** difs, size_t len) { - pid_t pid = 0; int i; int ret = 0; int reg_ap_id = 0; struct list_head * pos = NULL; struct reg_name_entry * rne = NULL; - instance_name_t * api = NULL; + instance_name_t * api = NULL; + instance_name_t * ipcpi = NULL; if (instance->ipcps.next == NULL) LOG_ERR("No IPCPs in this system."); @@ -493,7 +485,7 @@ static int ap_reg(char * ap_name, struct ipcp_entry * e = list_entry(pos, struct ipcp_entry, next); - if (ipcp_name_reg(e->pid, api->name)) { + if (ipcp_name_reg(e->api->id, ap_name)) { LOG_ERR("Could not register %s in DIF %s.", api->name, e->dif_name); } else { @@ -502,13 +494,13 @@ static int ap_reg(char * ap_name, } } else { for (i = 0; i < len; ++i) { - pid = find_pid_by_dif_name(difs[i]); - if (pid == 0) { + ipcpi = get_ipcp_by_dif_name(difs[i]); + if (ipcpi == NULL) { LOG_ERR("%s: No such DIF.", difs[i]); continue; } - if (ipcp_name_reg(pid, api->name)) { + if (ipcp_name_reg(ipcpi->id, api->name)) { LOG_ERR("Could not register %s in DIF %s.", api->name, difs[i]); } else { @@ -539,6 +531,7 @@ static int ap_unreg(char * ap_name, instance_name_t * api = instance_name_create(); if (api == NULL) return -1; + if (instance_name_init_from(api, ap_name, ap_id) == NULL) { instance_name_destroy(api); return -1; @@ -652,14 +645,17 @@ int main() if (instance == NULL) return -1; - if ((instance->dum = shm_du_map_create()) == NULL) + if ((instance->dum = shm_du_map_create()) == NULL) { + free(instance); return -1; + } INIT_LIST_HEAD(&instance->ipcps); INIT_LIST_HEAD(&instance->reg_names); sockfd = server_socket_open(IRM_SOCK_PATH); if (sockfd < 0) { + shm_du_map_close(instance->dum); free(instance); return -1; } @@ -694,12 +690,13 @@ int main() } api.name = msg->ap_name; - api.id = msg->api_id; + if (msg->has_api_id == true) + api.id = msg->api_id; switch (msg->code) { case IRM_MSG_CODE__IRM_CREATE_IPCP: ret_msg.has_result = true; - ret_msg.result = create_ipcp(&api, + ret_msg.result = create_ipcp(msg->ap_name, msg->ipcp_type); break; case IRM_MSG_CODE__IRM_DESTROY_IPCP: diff --git a/src/lib/ipcp.c b/src/lib/ipcp.c index b93f5488..387572b3 100644 --- a/src/lib/ipcp.c +++ b/src/lib/ipcp.c @@ -99,12 +99,11 @@ static ipcp_msg_t * send_recv_ipcp_msg(pid_t pid, return recv_msg; } -pid_t ipcp_create(instance_name_t * api, - enum ipcp_type ipcp_type) +pid_t ipcp_create(char * ipcp_name, + enum ipcp_type ipcp_type) { pid_t pid = 0; char irmd_pid[10]; - char * api_id = NULL; size_t len = 0; char * ipcp_dir = "bin"; char * full_name = NULL; @@ -122,21 +121,12 @@ pid_t ipcp_create(instance_name_t * api, return pid; } - api_id = malloc(n_digits(api->id) + 1); - if (!api_id) { - LOG_ERR("Failed to malloc"); - exit(EXIT_FAILURE); - } - sprintf(api_id, "%d", api->id); - if (ipcp_type == IPCP_NORMAL) exec_name = IPCP_NORMAL_EXEC; else if (ipcp_type == IPCP_SHIM_UDP) exec_name = IPCP_SHIM_UDP_EXEC; - else { - free(api_id); + else exit(EXIT_FAILURE); - } len += strlen(INSTALL_DIR); len += strlen(ipcp_dir); @@ -146,7 +136,6 @@ pid_t ipcp_create(instance_name_t * api, full_name = malloc(len + 1); if (full_name == NULL) { LOG_ERR("Failed to malloc"); - free(api_id); exit(EXIT_FAILURE); } @@ -161,8 +150,7 @@ pid_t ipcp_create(instance_name_t * api, char * argv[] = {full_name, irmd_pid, - api->name, - api_id, + ipcp_name, 0}; char * envp[] = {0}; @@ -172,7 +160,6 @@ pid_t ipcp_create(instance_name_t * api, LOG_DBG("%s", strerror(errno)); LOG_ERR("Failed to load IPCP daemon"); LOG_ERR("Make sure to run the installed version"); - free(api_id); free(full_name); exit(EXIT_FAILURE); } diff --git a/src/lib/irm.c b/src/lib/irm.c index b17cb04c..d3c77f2e 100644 --- a/src/lib/irm.c +++ b/src/lib/irm.c @@ -30,20 +30,18 @@ #include -int irm_create_ipcp(instance_name_t * api, - enum ipcp_type ipcp_type) +int irm_create_ipcp(char * ipcp_name, + enum ipcp_type ipcp_type) { irm_msg_t msg = IRM_MSG__INIT; irm_msg_t * recv_msg = NULL; int ret = -1; - if (api == NULL || api->name == NULL) + if (ipcp_name == NULL) return -EINVAL; msg.code = IRM_MSG_CODE__IRM_CREATE_IPCP; - msg.ap_name = api->name; - msg.has_api_id = true; - msg.api_id = api->id; + msg.ap_name = ipcp_name; msg.has_ipcp_type = true; msg.ipcp_type = ipcp_type; 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 'include') 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