summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ipcpd/ipcp.c16
-rw-r--r--src/ipcpd/ipcp.h3
-rw-r--r--src/ipcpd/local/main.c10
-rw-r--r--src/ipcpd/normal/main.c16
-rw-r--r--src/ipcpd/shim-eth-llc/main.c10
-rw-r--r--src/ipcpd/shim-udp/main.c8
-rw-r--r--src/irmd/ipcp.c14
-rw-r--r--src/irmd/ipcp.h8
-rw-r--r--src/irmd/main.c4
-rw-r--r--src/tools/irm/irm_ipcp_bootstrap.c4
-rw-r--r--src/tools/irm/irm_ipcp_create.c5
-rw-r--r--src/tools/irm/irm_ipcp_enroll.c3
12 files changed, 41 insertions, 60 deletions
diff --git a/src/ipcpd/ipcp.c b/src/ipcpd/ipcp.c
index 2e4c3fca..96f00dc0 100644
--- a/src/ipcpd/ipcp.c
+++ b/src/ipcpd/ipcp.c
@@ -440,22 +440,26 @@ int ipcp_parse_arg(int argc, char * argv[])
if (atoi(argv[1]) == 0)
return -1;
- if (argv[2] == NULL)
+ ipcpi.irmd_api = atoi(argv[1]);
+
+ /* argument 2: IPCP name */
+ ipcpi.name = argv[2];
+
+ /* argument 3: logfile name (if any) */
+ if (argv[3] == NULL)
return 0;
len += strlen(INSTALL_PREFIX);
len += strlen(LOG_DIR);
- len += strlen(argv[2]);
+ len += strlen(argv[3]);
log_file = malloc(len + 1);
- if (log_file == NULL) {
- LOG_ERR("Failed to malloc");
+ if (log_file == NULL)
return -1;
- }
strcpy(log_file, INSTALL_PREFIX);
strcat(log_file, LOG_DIR);
- strcat(log_file, argv[2]);
+ strcat(log_file, argv[3]);
log_file[len] = '\0';
if (set_logfile(log_file))
diff --git a/src/ipcpd/ipcp.h b/src/ipcpd/ipcp.h
index ae5a56da..a75186ba 100644
--- a/src/ipcpd/ipcp.h
+++ b/src/ipcpd/ipcp.h
@@ -38,6 +38,9 @@ enum ipcp_state {
};
struct ipcp {
+ int irmd_api;
+ char * name;
+
struct ipcp_data * data;
struct ipcp_ops * ops;
int irmd_fd;
diff --git a/src/ipcpd/local/main.c b/src/ipcpd/local/main.c
index 01e58b91..5117f59d 100644
--- a/src/ipcpd/local/main.c
+++ b/src/ipcpd/local/main.c
@@ -1,5 +1,5 @@
/*
- * Ouroboros - Copyright (C) 2016
+ * Ouroboros - Copyright (C) 2016 - 2017
*
* Local IPC process
*
@@ -41,9 +41,6 @@
#define EVENT_WAIT_TIMEOUT 100 /* us */
#define THIS_TYPE IPCP_LOCAL
-/* global for trapping signal */
-int irmd_api;
-
struct {
int in_out[IRMD_MAX_FLOWS];
flow_set_t * flows;
@@ -127,7 +124,7 @@ void ipcp_sig_handler(int sig, siginfo_t * info, void * c)
case SIGTERM:
case SIGHUP:
case SIGQUIT:
- if (info->si_pid == irmd_api) {
+ if (info->si_pid == ipcpi.irmd_api) {
pthread_rwlock_wrlock(&ipcpi.state_lock);
if (ipcp_get_state() == IPCP_INIT)
@@ -349,9 +346,6 @@ int main(int argc, char * argv[])
exit(EXIT_FAILURE);
}
- /* store the process id of the irmd */
- irmd_api = atoi(argv[1]);
-
/* init sig_act */
memset(&sig_act, 0, sizeof(sig_act));
diff --git a/src/ipcpd/normal/main.c b/src/ipcpd/normal/main.c
index 8db754aa..94f463af 100644
--- a/src/ipcpd/normal/main.c
+++ b/src/ipcpd/normal/main.c
@@ -26,6 +26,7 @@
#include <ouroboros/dev.h>
#include <ouroboros/ipcp-dev.h>
#include <ouroboros/time_utils.h>
+#include <ouroboros/irm.h>
#include "fmgr.h"
#include "ribmgr.h"
@@ -55,7 +56,7 @@ void ipcp_sig_handler(int sig, siginfo_t * info, void * c)
case SIGINT:
case SIGTERM:
case SIGHUP:
- if (info->si_pid == irmd_api) {
+ if (info->si_pid == ipcpi.irmd_api) {
pthread_rwlock_wrlock(&ipcpi.state_lock);
if (ipcp_get_state() == IPCP_INIT)
@@ -195,12 +196,6 @@ static int normal_ipcp_enroll(char * dst_name)
pthread_rwlock_unlock(&ipcpi.state_lock);
- /* FIXME: Remove once we obtain neighbors during enrollment */
- if (fmgr_nm1_dt_flow(dst_name, QOS_CUBE_BE)) {
- LOG_ERR("Failed to establish data transfer flow.");
- return -1;
- }
-
LOG_DBG("Enrolled with %s.", dst_name);
return 0;
@@ -317,8 +312,11 @@ int main(int argc, char * argv[])
exit(EXIT_FAILURE);
}
- /* store the process id of the irmd */
- irmd_api = atoi(argv[1]);
+ if (irm_bind_api(getpid(), ipcpi.name)) {
+ LOG_ERR("Failed to bind AP name.");
+ close_logfile();
+ exit(EXIT_FAILURE);
+ }
/* 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 623f2071..da496b07 100644
--- a/src/ipcpd/shim-eth-llc/main.c
+++ b/src/ipcpd/shim-eth-llc/main.c
@@ -1,5 +1,5 @@
/*
- * Ouroboros - Copyright (C) 2016
+ * Ouroboros - Copyright (C) 2016 - 2017
*
* Shim IPC process over Ethernet with LLC
*
@@ -77,9 +77,6 @@ typedef ShimEthLlcMsg shim_eth_llc_msg_t;
#define EVENT_WAIT_TIMEOUT 100 /* us */
#define NAME_QUERY_TIMEOUT 100000000 /* ns */
-/* global for trapping signal */
-int irmd_api;
-
struct eth_llc_frame {
uint8_t dst_hwaddr[MAC_SIZE];
uint8_t src_hwaddr[MAC_SIZE];
@@ -675,7 +672,7 @@ void ipcp_sig_handler(int sig, siginfo_t * info, void * c)
case SIGINT:
case SIGTERM:
case SIGHUP:
- if (info->si_pid == irmd_api) {
+ if (info->si_pid == ipcpi.irmd_api) {
pthread_rwlock_wrlock(&ipcpi.state_lock);
if (ipcp_get_state() == IPCP_INIT)
@@ -1123,9 +1120,6 @@ int main(int argc, char * argv[])
exit(EXIT_FAILURE);
}
- /* store the process id of the irmd */
- 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 8c0c0aac..99aac40e 100644
--- a/src/ipcpd/shim-udp/main.c
+++ b/src/ipcpd/shim-udp/main.c
@@ -60,9 +60,6 @@ typedef ShimUdpMsg shim_udp_msg_t;
#define UDP_MAX_PORTS 0xFFFF
-/* global for trapping signal */
-int irmd_api;
-
struct uf {
int udp;
int skfd;
@@ -529,7 +526,7 @@ void ipcp_sig_handler(int sig, siginfo_t * info, void * c)
case SIGINT:
case SIGTERM:
case SIGHUP:
- if (info->si_pid == irmd_api) {
+ if (info->si_pid == ipcpi.irmd_api) {
pthread_rwlock_wrlock(&ipcpi.state_lock);
if (ipcp_get_state() == IPCP_INIT)
@@ -1191,9 +1188,6 @@ int main(int argc, char * argv[])
exit(EXIT_FAILURE);
}
- /* store the process id of the irmd */
- irmd_api = atoi(argv[1]);
-
/* init sig_act */
memset(&sig_act, 0, sizeof(sig_act));
diff --git a/src/irmd/ipcp.c b/src/irmd/ipcp.c
index 07ae0dc2..f16587e1 100644
--- a/src/irmd/ipcp.c
+++ b/src/irmd/ipcp.c
@@ -1,5 +1,5 @@
/*
- * Ouroboros - Copyright (C) 2016
+ * Ouroboros - Copyright (C) 2016 - 2017
*
* The API to instruct IPCPs
*
@@ -100,7 +100,7 @@ ipcp_msg_t * send_recv_ipcp_msg(pid_t api, ipcp_msg_t * msg)
return recv_msg;
}
-pid_t ipcp_create(enum ipcp_type ipcp_type)
+pid_t ipcp_create(char * name, enum ipcp_type ipcp_type)
{
pid_t api = -1;
char irmd_api[10];
@@ -109,7 +109,7 @@ pid_t ipcp_create(enum ipcp_type ipcp_type)
char * full_name = NULL;
char * exec_name = NULL;
char * log_file = NULL;
- char * argv[4];
+ char * argv[5];
sprintf(irmd_api, "%u", getpid());
@@ -119,9 +119,8 @@ pid_t ipcp_create(enum ipcp_type ipcp_type)
return api;
}
- if (api != 0) {
+ if (api != 0)
return api;
- }
if (ipcp_type == IPCP_NORMAL)
exec_name = IPCP_NORMAL_EXEC;
@@ -162,8 +161,9 @@ pid_t ipcp_create(enum ipcp_type ipcp_type)
/* log_file to be placed at the end */
argv[0] = full_name;
argv[1] = irmd_api;
- argv[2] = log_file;
- argv[3] = NULL;
+ argv[2] = name;
+ argv[3] = log_file;
+ argv[4] = NULL;
execv(argv[0], &argv[0]);
diff --git a/src/irmd/ipcp.h b/src/irmd/ipcp.h
index a3c2e89a..658aa2ea 100644
--- a/src/irmd/ipcp.h
+++ b/src/irmd/ipcp.h
@@ -1,5 +1,5 @@
/*
- * Ouroboros - Copyright (C) 2016
+ * Ouroboros - Copyright (C) 2016 - 2017
*
* The API for the IRM to instruct IPCPs
*
@@ -28,8 +28,8 @@
#ifndef OUROBOROS_IPCP_H
#define OUROBOROS_IPCP_H
-/* Returns the process id */
-pid_t ipcp_create(enum ipcp_type ipcp_type);
+pid_t ipcp_create(char * name,
+ enum ipcp_type ipcp_type);
int ipcp_destroy(pid_t api);
@@ -45,7 +45,7 @@ int ipcp_name_reg(pid_t api,
int ipcp_name_unreg(pid_t api,
char * name);
-int ipcp_name_query(pid_t api,
+int ipcp_name_query(pid_t api,
char * name);
int ipcp_flow_alloc(pid_t api,
diff --git a/src/irmd/main.c b/src/irmd/main.c
index b7292e74..ceeb7184 100644
--- a/src/irmd/main.c
+++ b/src/irmd/main.c
@@ -1,5 +1,5 @@
/*
- * Ouroboros - Copyright (C) 2016
+ * Ouroboros - Copyright (C) 2016 - 2017
*
* The IPC Resource Manager
*
@@ -245,7 +245,7 @@ static pid_t create_ipcp(char * name, enum ipcp_type ipcp_type)
pthread_rwlock_wrlock(&irmd->reg_lock);
- api->pid = ipcp_create(ipcp_type);
+ api->pid = ipcp_create(name, ipcp_type);
if (api->pid == -1) {
pthread_rwlock_unlock(&irmd->reg_lock);
pthread_rwlock_unlock(&irmd->state_lock);
diff --git a/src/tools/irm/irm_ipcp_bootstrap.c b/src/tools/irm/irm_ipcp_bootstrap.c
index a812f0b4..10e53294 100644
--- a/src/tools/irm/irm_ipcp_bootstrap.c
+++ b/src/tools/irm/irm_ipcp_bootstrap.c
@@ -1,5 +1,5 @@
/*
- * Ouroboros - Copyright (C) 2016
+ * Ouroboros - Copyright (C) 2016 - 2017
*
* Bootstrap IPC Processes
*
@@ -199,8 +199,6 @@ int do_bootstrap_ipcp(int argc, char ** argv)
api = irm_create_ipcp(name, conf.type);
if (api == 0)
return -1;
- if (conf.type == IPCP_NORMAL)
- irm_bind_api(api, name);
len = irm_list_ipcps(name, &apis);
}
diff --git a/src/tools/irm/irm_ipcp_create.c b/src/tools/irm/irm_ipcp_create.c
index b4a2d5f7..e8ed1186 100644
--- a/src/tools/irm/irm_ipcp_create.c
+++ b/src/tools/irm/irm_ipcp_create.c
@@ -1,5 +1,5 @@
/*
- * Ouroboros - Copyright (C) 2016
+ * Ouroboros - Copyright (C) 2016 - 2017
*
* Create IPC Processes
*
@@ -85,8 +85,5 @@ int do_create_ipcp(int argc, char ** argv)
if (api == 0)
return -1;
- if (type == IPCP_NORMAL)
- irm_bind_api(api, ipcp_name);
-
return 0;
}
diff --git a/src/tools/irm/irm_ipcp_enroll.c b/src/tools/irm/irm_ipcp_enroll.c
index 824b68de..3731fa81 100644
--- a/src/tools/irm/irm_ipcp_enroll.c
+++ b/src/tools/irm/irm_ipcp_enroll.c
@@ -1,5 +1,5 @@
/*
- * Ouroboros - Copyright (C) 2016
+ * Ouroboros - Copyright (C) 2016 - 2017
*
* Enroll IPC Processes
*
@@ -68,7 +68,6 @@ int do_enroll_ipcp(int argc, char ** argv)
api = irm_create_ipcp(name, IPCP_NORMAL);
if (api == 0)
return -1;
- irm_bind_api(api, name);
len = irm_list_ipcps(name, &apis);
}