From 0d789ed8d938cc342c8f2138280795a1d5a61e3d Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Tue, 28 Jun 2016 16:11:19 +0200 Subject: lib, irmd, ipcpd: Change of IRM API This changes the IRM API after discussions with Dimitri. The register operation is now split into a bind and register operation. The same for unregister; unbind and unregister. PIDs are now used as the application instance name. A name for a PID is only provided for scriptability in bash. It is therefore also no longer passed down to the IPCP. Every operation on an IPCP through the IRM API has to use the PID. Quering of the PIDs by name is possible. The IRM tool has been updated to use this new API as well. A subcommand 'ipcp' has been added for operations that take effect on IPCPs only. Fixes #12 --- src/ipcpd/ipcp-data.h | 1 - src/ipcpd/ipcp-ops.h | 2 +- src/ipcpd/ipcp.c | 6 +----- src/ipcpd/local/main.c | 29 +++++------------------------ src/ipcpd/shim-eth-llc/main.c | 6 +----- src/ipcpd/shim-udp/main.c | 29 +++++------------------------ 6 files changed, 13 insertions(+), 60 deletions(-) (limited to 'src/ipcpd') diff --git a/src/ipcpd/ipcp-data.h b/src/ipcpd/ipcp-data.h index 2e86ba11..ce20730b 100644 --- a/src/ipcpd/ipcp-data.h +++ b/src/ipcpd/ipcp-data.h @@ -25,7 +25,6 @@ #define IPCPD_IPCP_DATA_H #include -#include #include #include #include diff --git a/src/ipcpd/ipcp-ops.h b/src/ipcpd/ipcp-ops.h index a1d9f23f..879ce8e2 100644 --- a/src/ipcpd/ipcp-ops.h +++ b/src/ipcpd/ipcp-ops.h @@ -24,7 +24,7 @@ #ifndef IPCPD_IPCP_OPS_H #define IPCPD_IPCP_OPS_H -#include +#include #include #include diff --git a/src/ipcpd/ipcp.c b/src/ipcpd/ipcp.c index b5108712..54d1fad3 100644 --- a/src/ipcpd/ipcp.c +++ b/src/ipcpd/ipcp.c @@ -47,17 +47,13 @@ struct ipcp * ipcp_instance_create() int ipcp_arg_check(int argc, char * argv[]) { - if (argc != 3) + if (argc != 2) return -1; /* argument 1: pid of irmd */ if (atoi(argv[1]) == 0) return -1; - /* name conformity responsibility of NMS */ - - /* argument 2: ap name */ - return 0; } diff --git a/src/ipcpd/local/main.c b/src/ipcpd/local/main.c index 06e2b0a4..1f1cf839 100644 --- a/src/ipcpd/local/main.c +++ b/src/ipcpd/local/main.c @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include #include @@ -67,7 +67,7 @@ struct ipcp * _ipcp; /* the shim needs access to these internals */ struct shim_ap_data { - instance_name_t * api; + pid_t api; struct shm_du_map * dum; struct bmp * fds; struct shm_ap_rbuff * rb; @@ -82,7 +82,7 @@ struct shim_ap_data { } * _ap_instance; -static int shim_ap_init(char * ap_name) +static int shim_ap_init() { int i; @@ -91,30 +91,16 @@ static int shim_ap_init(char * ap_name) return -1; } - _ap_instance->api = instance_name_create(); - if (_ap_instance->api == NULL) { - free(_ap_instance); - return -1; - } - - if (instance_name_init_from(_ap_instance->api, - ap_name, - getpid()) == NULL) { - instance_name_destroy(_ap_instance->api); - free(_ap_instance); - return -1; - } + _ap_instance->api = getpid(); _ap_instance->fds = bmp_create(AP_MAX_FLOWS, 0); if (_ap_instance->fds == NULL) { - instance_name_destroy(_ap_instance->api); free(_ap_instance); return -1; } _ap_instance->dum = shm_du_map_open(); if (_ap_instance->dum == NULL) { - instance_name_destroy(_ap_instance->api); bmp_destroy(_ap_instance->fds); free(_ap_instance); return -1; @@ -122,7 +108,6 @@ static int shim_ap_init(char * ap_name) _ap_instance->rb = shm_ap_rbuff_create(); if (_ap_instance->rb == NULL) { - instance_name_destroy(_ap_instance->api); shm_du_map_close(_ap_instance->dum); bmp_destroy(_ap_instance->fds); free(_ap_instance); @@ -153,8 +138,6 @@ void shim_ap_fini() if (_ipcp->state != IPCP_SHUTDOWN) LOG_WARN("Cleaning up AP while not in shutdown."); - if (_ap_instance->api != NULL) - instance_name_destroy(_ap_instance->api); if (_ap_instance->fds != NULL) bmp_destroy(_ap_instance->fds); if (_ap_instance->dum != NULL) @@ -592,8 +575,6 @@ static struct ipcp * ipcp_local_create() int main (int argc, char * argv[]) { - /* argument 1: pid of irmd ? */ - /* argument 2: ap name */ struct sigaction sig_act; sigset_t sigset; sigemptyset(&sigset); @@ -607,7 +588,7 @@ int main (int argc, char * argv[]) exit(1); } - if (shim_ap_init(argv[2]) < 0) + if (shim_ap_init() < 0) exit(1); /* store the process id of the irmd */ diff --git a/src/ipcpd/shim-eth-llc/main.c b/src/ipcpd/shim-eth-llc/main.c index 9bd6920b..6cb5c9cc 100644 --- a/src/ipcpd/shim-eth-llc/main.c +++ b/src/ipcpd/shim-eth-llc/main.c @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include #include @@ -675,7 +675,6 @@ static void * eth_llc_ipcp_sdu_reader(void * o) dst_mac, MAC_SIZE) && memcmp(br_addr, dst_mac, MAC_SIZE)) { - LOG_DBG("Not a unicast or broadcast frame."); #if defined(PACKET_RX_RING) && defined(PACKET_TX_RING) offset = (offset + 1) & (SHM_BLOCKS_IN_MAP - 1); header->tp_status = TP_STATUS_KERNEL; @@ -715,7 +714,6 @@ static void * eth_llc_ipcp_sdu_reader(void * o) if (j < 0) { pthread_rwlock_unlock(&shim_data(_ipcp)->flows_lock); pthread_rwlock_unlock(&_ipcp->state_lock); - LOG_DBG("Received data for unknown flow."); #if defined(PACKET_RX_RING) && defined(PACKET_TX_RING) offset = (offset + 1) & (SHM_BLOCKS_IN_MAP - 1); @@ -1236,8 +1234,6 @@ static struct ipcp_ops eth_llc_ops = { int main(int argc, char * argv[]) { - /* argument 1: pid of irmd ? */ - /* argument 2: ap name */ struct sigaction sig_act; sigset_t sigset; int i = 0; diff --git a/src/ipcpd/shim-udp/main.c b/src/ipcpd/shim-udp/main.c index 221e60d2..99b8aa7f 100644 --- a/src/ipcpd/shim-udp/main.c +++ b/src/ipcpd/shim-udp/main.c @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include #include @@ -86,7 +86,7 @@ struct ipcp * _ipcp; /* the shim needs access to these internals */ struct shim_ap_data { - instance_name_t * api; + pid_t api; struct shm_du_map * dum; struct bmp * fds; struct shm_ap_rbuff * rb; @@ -103,7 +103,7 @@ struct shim_ap_data { pthread_mutex_t fd_set_lock; } * _ap_instance; -static int shim_ap_init(char * ap_name) +static int shim_ap_init() { int i; @@ -112,30 +112,16 @@ static int shim_ap_init(char * ap_name) return -1; } - _ap_instance->api = instance_name_create(); - if (_ap_instance->api == NULL) { - free(_ap_instance); - return -1; - } - - if (instance_name_init_from(_ap_instance->api, - ap_name, - getpid()) == NULL) { - instance_name_destroy(_ap_instance->api); - free(_ap_instance); - return -1; - } + _ap_instance->api = getpid(); _ap_instance->fds = bmp_create(AP_MAX_FLOWS, 0); if (_ap_instance->fds == NULL) { - instance_name_destroy(_ap_instance->api); free(_ap_instance); return -1; } _ap_instance->dum = shm_du_map_open(); if (_ap_instance->dum == NULL) { - instance_name_destroy(_ap_instance->api); bmp_destroy(_ap_instance->fds); free(_ap_instance); return -1; @@ -143,7 +129,6 @@ static int shim_ap_init(char * ap_name) _ap_instance->rb = shm_ap_rbuff_create(); if (_ap_instance->rb == NULL) { - instance_name_destroy(_ap_instance->api); shm_du_map_close(_ap_instance->dum); bmp_destroy(_ap_instance->fds); free(_ap_instance); @@ -174,8 +159,6 @@ void shim_ap_fini() if (_ipcp->state != IPCP_SHUTDOWN) LOG_WARN("Cleaning up AP while not in shutdown."); - if (_ap_instance->api != NULL) - instance_name_destroy(_ap_instance->api); if (_ap_instance->fds != NULL) bmp_destroy(_ap_instance->fds); if (_ap_instance->dum != NULL) @@ -1576,8 +1559,6 @@ static struct ipcp * ipcp_udp_create() int main (int argc, char * argv[]) { - /* argument 1: pid of irmd ? */ - /* argument 2: ap name */ struct sigaction sig_act; sigset_t sigset; sigemptyset(&sigset); @@ -1591,7 +1572,7 @@ int main (int argc, char * argv[]) exit(1); } - if (shim_ap_init(argv[2]) < 0) + if (shim_ap_init() < 0) exit(1); /* store the process id of the irmd */ -- cgit v1.2.3