From 99d19307fae8f1370f52a62aee88fded624ad464 Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Tue, 28 Jun 2016 16:38:03 +0200 Subject: lib, irmd, ipcpd: Change pid to api Changes the variable name as well to API instead of PID. --- src/ipcpd/ipcp-ops.h | 4 ++-- src/ipcpd/ipcp.c | 6 +++--- src/ipcpd/local/main.c | 20 +++++++++--------- src/ipcpd/shim-eth-llc/main.c | 16 +++++++------- src/ipcpd/shim-udp/main.c | 36 ++++++++++++++++---------------- src/ipcpd/shim-udp/tests/shim_udp_test.c | 3 --- 6 files changed, 41 insertions(+), 44 deletions(-) (limited to 'src/ipcpd') diff --git a/src/ipcpd/ipcp-ops.h b/src/ipcpd/ipcp-ops.h index 879ce8e2..40c331ec 100644 --- a/src/ipcpd/ipcp-ops.h +++ b/src/ipcpd/ipcp-ops.h @@ -38,12 +38,12 @@ struct ipcp_ops { size_t len); int (* ipcp_name_reg)(char * name); int (* ipcp_name_unreg)(char * name); - int (* ipcp_flow_alloc)(pid_t n_pid, + int (* ipcp_flow_alloc)(pid_t n_api, int port_id, char * dst_ap_name, char * src_ae_name, enum qos_cube qos); - int (* ipcp_flow_alloc_resp)(pid_t n_pid, + int (* ipcp_flow_alloc_resp)(pid_t n_api, int port_id, int response); int (* ipcp_flow_dealloc)(int port_id); diff --git a/src/ipcpd/ipcp.c b/src/ipcpd/ipcp.c index 54d1fad3..4acbffa2 100644 --- a/src/ipcpd/ipcp.c +++ b/src/ipcpd/ipcp.c @@ -50,7 +50,7 @@ int ipcp_arg_check(int argc, char * argv[]) if (argc != 2) return -1; - /* argument 1: pid of irmd */ + /* argument 1: api of irmd */ if (atoi(argv[1]) == 0) return -1; @@ -203,7 +203,7 @@ void * ipcp_main_loop(void * o) } ret_msg.has_result = true; ret_msg.result = - _ipcp->ops->ipcp_flow_alloc(msg->pid, + _ipcp->ops->ipcp_flow_alloc(msg->api, msg->port_id, msg->dst_name, msg->src_ae_name, @@ -216,7 +216,7 @@ void * ipcp_main_loop(void * o) } ret_msg.has_result = true; ret_msg.result = - _ipcp->ops->ipcp_flow_alloc_resp(msg->pid, + _ipcp->ops->ipcp_flow_alloc_resp(msg->api, msg->port_id, msg->result); break; diff --git a/src/ipcpd/local/main.c b/src/ipcpd/local/main.c index 1f1cf839..2120e4e8 100644 --- a/src/ipcpd/local/main.c +++ b/src/ipcpd/local/main.c @@ -50,7 +50,7 @@ #define shim_data(type) ((struct ipcp_local_data *) type->data) /* global for trapping signal */ -int irmd_pid; +int irmd_api; /* this IPCP's data */ #ifdef MAKE_CHECK @@ -226,7 +226,7 @@ void ipcp_sig_handler(int sig, siginfo_t * info, void * c) case SIGTERM: case SIGHUP: case SIGQUIT: - if (info->si_pid == irmd_pid) { + if (info->si_pid == irmd_api) { bool clean_threads = false; LOG_DBG("Terminating by order of %d. Bye.", info->si_pid); @@ -276,7 +276,7 @@ static int ipcp_local_bootstrap(struct dif_config * conf) pthread_rwlock_unlock(&_ipcp->state_lock); - LOG_DBG("Bootstrapped local IPCP with pid %d.", + LOG_DBG("Bootstrapped local IPCP with api %d.", getpid()); return 0; @@ -320,7 +320,7 @@ static int ipcp_local_name_unreg(char * name) return 0; } -static int ipcp_local_flow_alloc(pid_t n_pid, +static int ipcp_local_flow_alloc(pid_t n_api, int port_id, char * dst_name, char * src_ae_name, @@ -346,7 +346,7 @@ static int ipcp_local_flow_alloc(pid_t n_pid, return -1; /* -ENOTENROLLED */ } - rb = shm_ap_rbuff_open(n_pid); + rb = shm_ap_rbuff_open(n_api); if (rb == NULL) { pthread_rwlock_unlock(&_ipcp->state_lock); return -1; /* -ENORBUFF */ @@ -376,13 +376,13 @@ static int ipcp_local_flow_alloc(pid_t n_pid, pthread_rwlock_unlock(&_ap_instance->flows_lock); pthread_rwlock_unlock(&_ipcp->state_lock); LOG_ERR("Could not get port id from IRMd"); - /* shm_ap_rbuff_close(n_pid); */ + /* shm_ap_rbuff_close(n_api); */ return -1; } out_fd = bmp_allocate(_ap_instance->fds); if (!bmp_is_id_valid(_ap_instance->fds, out_fd)) { - /* shm_ap_rbuff_close(n_pid); */ + /* shm_ap_rbuff_close(n_api); */ pthread_rwlock_unlock(&_ap_instance->flows_lock); pthread_rwlock_unlock(&_ipcp->state_lock); return -1; /* -ENOMOREFDS */ @@ -403,7 +403,7 @@ static int ipcp_local_flow_alloc(pid_t n_pid, return 0; } -static int ipcp_local_flow_alloc_resp(pid_t n_pid, +static int ipcp_local_flow_alloc_resp(pid_t n_api, int port_id, int response) { @@ -436,7 +436,7 @@ static int ipcp_local_flow_alloc_resp(pid_t n_pid, return -1; } - rb = shm_ap_rbuff_open(n_pid); + rb = shm_ap_rbuff_open(n_api); if (rb == NULL) { LOG_ERR("Could not open N + 1 ringbuffer."); _ap_instance->flows[in_fd].state = FLOW_NULL; @@ -592,7 +592,7 @@ int main (int argc, char * argv[]) exit(1); /* store the process id of the irmd */ - irmd_pid = atoi(argv[1]); + irmd_api = atoi(argv[1]); /* init sig_act */ memset(&sig_act, 0, sizeof(sig_act)); diff --git a/src/ipcpd/shim-eth-llc/main.c b/src/ipcpd/shim-eth-llc/main.c index 6cb5c9cc..48b6391f 100644 --- a/src/ipcpd/shim-eth-llc/main.c +++ b/src/ipcpd/shim-eth-llc/main.c @@ -70,7 +70,7 @@ typedef ShimEthLlcMsg shim_eth_llc_msg_t; #define MAX_SAPS 64 /* global for trapping signal */ -int irmd_pid; +int irmd_api; struct ipcp * _ipcp; @@ -816,7 +816,7 @@ void ipcp_sig_handler(int sig, siginfo_t * info, void * c) case SIGINT: case SIGTERM: case SIGHUP: - if (info->si_pid == irmd_pid) { + if (info->si_pid == irmd_api) { bool clean_threads = false; LOG_DBG("Terminating by order of %d. Bye.", info->si_pid); @@ -988,7 +988,7 @@ static int eth_llc_ipcp_bootstrap(struct dif_config * conf) pthread_rwlock_unlock(&_ipcp->state_lock); - LOG_DBG("Bootstrapped shim IPCP over Ethernet with LLC with pid %d.", + LOG_DBG("Bootstrapped shim IPCP over Ethernet with LLC with api %d.", getpid()); return 0; @@ -1028,7 +1028,7 @@ static int eth_llc_ipcp_name_unreg(char * name) return 0; } -static int eth_llc_ipcp_flow_alloc(pid_t n_pid, +static int eth_llc_ipcp_flow_alloc(pid_t n_api, int port_id, char * dst_name, char * src_ae_name, @@ -1047,7 +1047,7 @@ static int eth_llc_ipcp_flow_alloc(pid_t n_pid, if (qos != QOS_CUBE_BE) LOG_DBGF("QoS requested. Ethernet LLC can't do that. For now."); - rb = shm_ap_rbuff_open(n_pid); + rb = shm_ap_rbuff_open(n_api); if (rb == NULL) return -1; /* -ENORBUFF */ @@ -1106,7 +1106,7 @@ static int eth_llc_ipcp_flow_alloc(pid_t n_pid, return index; } -static int eth_llc_ipcp_flow_alloc_resp(pid_t n_pid, +static int eth_llc_ipcp_flow_alloc_resp(pid_t n_api, int port_id, int response) { @@ -1132,7 +1132,7 @@ static int eth_llc_ipcp_flow_alloc_resp(pid_t n_pid, return -1; } - rb = shm_ap_rbuff_open(n_pid); + rb = shm_ap_rbuff_open(n_api); if (rb == NULL) { LOG_ERR("Could not open N + 1 ringbuffer."); ipcp_flow(index)->state = FLOW_NULL; @@ -1250,7 +1250,7 @@ int main(int argc, char * argv[]) } /* store the process id of the irmd */ - irmd_pid = atoi(argv[1]); + irmd_api = atoi(argv[1]); /* init sig_act */ memset(&sig_act, 0, sizeof(sig_act)); diff --git a/src/ipcpd/shim-udp/main.c b/src/ipcpd/shim-udp/main.c index 99b8aa7f..a28c262f 100644 --- a/src/ipcpd/shim-udp/main.c +++ b/src/ipcpd/shim-udp/main.c @@ -69,7 +69,7 @@ typedef ShimUdpMsg shim_udp_msg_t; _ipcp->data)->s_saddr.sin_addr.s_addr) /* global for trapping signal */ -int irmd_pid; +int irmd_api; /* this IPCP's data */ #ifdef MAKE_CHECK @@ -817,7 +817,7 @@ void ipcp_sig_handler(int sig, siginfo_t * info, void * c) case SIGINT: case SIGTERM: case SIGHUP: - if (info->si_pid == irmd_pid) { + if (info->si_pid == irmd_api) { bool clean_threads = false; LOG_DBG("Terminating by order of %d. Bye.", info->si_pid); @@ -947,7 +947,7 @@ static int ipcp_udp_bootstrap(struct dif_config * conf) pthread_rwlock_unlock(&_ipcp->state_lock); - LOG_DBG("Bootstrapped shim IPCP over UDP with pid %d.", + LOG_DBG("Bootstrapped shim IPCP over UDP with api %d.", getpid()); LOG_DBG("Bound to IP address %s.", ipstr); @@ -961,7 +961,7 @@ static int ipcp_udp_bootstrap(struct dif_config * conf) /* NOTE: Disgusted with this crap */ static int ddns_send(char * cmd) { - pid_t pid = 0; + pid_t api = 0; int wstatus; int pipe_fd[2]; char * argv[] = {NSUPDATE_EXEC, 0}; @@ -972,13 +972,13 @@ static int ddns_send(char * cmd) return -1; } - pid = fork(); - if (pid == -1) { + api = fork(); + if (api == -1) { LOG_ERR("Failed to fork."); return -1; } - if (pid == 0) { + if (api == 0) { close(pipe_fd[1]); dup2(pipe_fd[0], 0); execve(argv[0], &argv[0], envp); @@ -992,7 +992,7 @@ static int ddns_send(char * cmd) return -1; } - waitpid(pid, &wstatus, 0); + waitpid(api, &wstatus, 0); if (WIFEXITED(wstatus) == true && WEXITSTATUS(wstatus) == 0) LOG_DBG("Succesfully communicated with DNS server."); @@ -1005,7 +1005,7 @@ static int ddns_send(char * cmd) static uint32_t ddns_resolve(char * name, uint32_t dns_addr) { - pid_t pid = 0; + pid_t api = 0; int wstatus; int pipe_fd[2]; char dnsstr[INET_ADDRSTRLEN]; @@ -1026,13 +1026,13 @@ static uint32_t ddns_resolve(char * name, uint32_t dns_addr) return 0; } - pid = fork(); - if (pid == -1) { + api = fork(); + if (api == -1) { LOG_ERR("Failed to fork."); return 0; } - if (pid == 0) { + if (api == 0) { char * argv[] = {NSLOOKUP_EXEC, name, dnsstr, 0}; char * envp[] = {0}; @@ -1052,7 +1052,7 @@ static uint32_t ddns_resolve(char * name, uint32_t dns_addr) close(pipe_fd[0]); - waitpid(pid, &wstatus, 0); + waitpid(api, &wstatus, 0); if (WIFEXITED(wstatus) == true && WEXITSTATUS(wstatus) == 0) LOG_DBG("Succesfully communicated with nslookup."); @@ -1198,7 +1198,7 @@ static int ipcp_udp_name_unreg(char * name) return 0; } -static int ipcp_udp_flow_alloc(pid_t n_pid, +static int ipcp_udp_flow_alloc(pid_t n_api, int port_id, char * dst_name, char * src_ae_name, @@ -1228,7 +1228,7 @@ static int ipcp_udp_flow_alloc(pid_t n_pid, if (qos != QOS_CUBE_BE) LOG_DBG("QoS requested. UDP/IP can't do that."); - rb = shm_ap_rbuff_open(n_pid); + rb = shm_ap_rbuff_open(n_api); if (rb == NULL) return -1; /* -ENORBUFF */ @@ -1348,7 +1348,7 @@ static int ipcp_udp_flow_alloc(pid_t n_pid, return fd; } -static int ipcp_udp_flow_alloc_resp(pid_t n_pid, +static int ipcp_udp_flow_alloc_resp(pid_t n_api, int port_id, int response) { @@ -1389,7 +1389,7 @@ static int ipcp_udp_flow_alloc_resp(pid_t n_pid, return -1; } - rb = shm_ap_rbuff_open(n_pid); + rb = shm_ap_rbuff_open(n_api); if (rb == NULL) { LOG_ERR("Could not open N + 1 ringbuffer."); _ap_instance->flows[fd].state = FLOW_NULL; @@ -1576,7 +1576,7 @@ int main (int argc, char * argv[]) exit(1); /* store the process id of the irmd */ - irmd_pid = atoi(argv[1]); + irmd_api = atoi(argv[1]); /* init sig_act */ memset(&sig_act, 0, sizeof(sig_act)); diff --git a/src/ipcpd/shim-udp/tests/shim_udp_test.c b/src/ipcpd/shim-udp/tests/shim_udp_test.c index e5e8b32d..b222ac42 100644 --- a/src/ipcpd/shim-udp/tests/shim_udp_test.c +++ b/src/ipcpd/shim-udp/tests/shim_udp_test.c @@ -34,9 +34,6 @@ struct ipcp * _ipcp; int shim_udp_test(int argc, char ** argv) { - /* argument 1: pid of irmd ? */ - /* argument 2: ap name */ - /* argument 3: instance id */ struct shm_du_map * dum; char * ipcp_name = "test-shim-ipcp"; int i = 0; -- cgit v1.2.3