summaryrefslogtreecommitdiff
path: root/src/ipcpd/local
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@intec.ugent.be>2016-06-28 17:02:42 +0200
committerdimitri staessens <dimitri.staessens@intec.ugent.be>2016-06-28 17:02:42 +0200
commita19521aa74edfa4a2eb62466b04c9264c3b6576c (patch)
tree36b94730d8690c2d131f39b3cc3ff715674f9fcc /src/ipcpd/local
parentacd29da104d0d8ddace2b2693314542bb5a56fcc (diff)
parent99d19307fae8f1370f52a62aee88fded624ad464 (diff)
downloadouroboros-a19521aa74edfa4a2eb62466b04c9264c3b6576c.tar.gz
ouroboros-a19521aa74edfa4a2eb62466b04c9264c3b6576c.zip
Merged in sandervrijders/ouroboros/be (pull request #144)
lib, irmd, ipcpd: Change of IRM API
Diffstat (limited to 'src/ipcpd/local')
-rw-r--r--src/ipcpd/local/main.c49
1 files changed, 15 insertions, 34 deletions
diff --git a/src/ipcpd/local/main.c b/src/ipcpd/local/main.c
index 06e2b0a4..2120e4e8 100644
--- a/src/ipcpd/local/main.c
+++ b/src/ipcpd/local/main.c
@@ -28,7 +28,7 @@
#include <ouroboros/list.h>
#include <ouroboros/utils.h>
#include <ouroboros/ipcp.h>
-#include <ouroboros/dif_config.h>
+#include <ouroboros/irm_config.h>
#include <ouroboros/sockets.h>
#include <ouroboros/bitmap.h>
#include <ouroboros/common.h>
@@ -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
@@ -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)
@@ -243,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);
@@ -293,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;
@@ -337,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,
@@ -363,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 */
@@ -393,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 */
@@ -420,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)
{
@@ -453,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,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,11 +588,11 @@ 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 */
- irmd_pid = atoi(argv[1]);
+ irmd_api = atoi(argv[1]);
/* init sig_act */
memset(&sig_act, 0, sizeof(sig_act));