summaryrefslogtreecommitdiff
path: root/src/lib/ipcp.c
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/lib/ipcp.c
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/lib/ipcp.c')
-rw-r--r--src/lib/ipcp.c90
1 files changed, 44 insertions, 46 deletions
diff --git a/src/lib/ipcp.c b/src/lib/ipcp.c
index 77263bcf..2b6b6825 100644
--- a/src/lib/ipcp.c
+++ b/src/lib/ipcp.c
@@ -35,7 +35,7 @@
#include <sys/types.h>
#include <sys/wait.h>
-static ipcp_msg_t * send_recv_ipcp_msg(pid_t pid,
+static ipcp_msg_t * send_recv_ipcp_msg(pid_t api,
ipcp_msg_t * msg)
{
int sockfd = 0;
@@ -44,7 +44,7 @@ static ipcp_msg_t * send_recv_ipcp_msg(pid_t pid,
ssize_t count = 0;
ipcp_msg_t * recv_msg = NULL;
- sock_path = ipcp_sock_path(pid);
+ sock_path = ipcp_sock_path(api);
if (sock_path == NULL)
return NULL;
@@ -99,26 +99,25 @@ static ipcp_msg_t * send_recv_ipcp_msg(pid_t pid,
return recv_msg;
}
-pid_t ipcp_create(char * ipcp_name,
- enum ipcp_type ipcp_type)
+pid_t ipcp_create(enum ipcp_type ipcp_type)
{
- pid_t pid = 0;
- char irmd_pid[10];
+ pid_t api = 0;
+ char irmd_api[10];
size_t len = 0;
char * ipcp_dir = "/sbin/";
char * full_name = NULL;
char * exec_name = NULL;
- sprintf(irmd_pid, "%u", getpid());
+ sprintf(irmd_api, "%u", getpid());
- pid = fork();
- if (pid == -1) {
+ api = fork();
+ if (api == -1) {
LOG_ERR("Failed to fork");
- return pid;
+ return api;
}
- if (pid != 0) {
- return pid;
+ if (api != 0) {
+ return api;
}
if (ipcp_type == IPCP_NORMAL)
@@ -149,8 +148,7 @@ pid_t ipcp_create(char * ipcp_name,
full_name[len] = '\0';
char * argv[] = {full_name,
- irmd_pid,
- ipcp_name,
+ irmd_api,
0};
char * envp[] = {0};
@@ -164,16 +162,16 @@ pid_t ipcp_create(char * ipcp_name,
exit(EXIT_FAILURE);
}
-int ipcp_destroy(pid_t pid)
+int ipcp_destroy(pid_t api)
{
int status;
- if (kill(pid, SIGTERM)) {
+ if (kill(api, SIGTERM)) {
LOG_ERR("Failed to destroy IPCP");
return -1;
}
- if (waitpid(pid, &status, 0) < 0) {
+ if (waitpid(api, &status, 0) < 0) {
LOG_ERR("Failed to destroy IPCP");
return -1;
}
@@ -181,7 +179,7 @@ int ipcp_destroy(pid_t pid)
return 0;
}
-int ipcp_reg(pid_t pid,
+int ipcp_reg(pid_t api,
char ** dif_names,
size_t len)
{
@@ -198,7 +196,7 @@ int ipcp_reg(pid_t pid,
msg.dif_names = dif_names;
msg.len = len;
- recv_msg = send_recv_ipcp_msg(pid, &msg);
+ recv_msg = send_recv_ipcp_msg(api, &msg);
if (recv_msg == NULL)
return -1;
@@ -213,7 +211,7 @@ int ipcp_reg(pid_t pid,
return ret;
}
-int ipcp_unreg(pid_t pid,
+int ipcp_unreg(pid_t api,
char ** dif_names,
size_t len)
{
@@ -230,7 +228,7 @@ int ipcp_unreg(pid_t pid,
msg.dif_names = dif_names;
msg.len = len;
- recv_msg = send_recv_ipcp_msg(pid, &msg);
+ recv_msg = send_recv_ipcp_msg(api, &msg);
if (recv_msg == NULL)
return -1;
@@ -246,7 +244,7 @@ int ipcp_unreg(pid_t pid,
}
-int ipcp_bootstrap(pid_t pid,
+int ipcp_bootstrap(pid_t api,
dif_config_msg_t * conf)
{
ipcp_msg_t msg = IPCP_MSG__INIT;
@@ -259,7 +257,7 @@ int ipcp_bootstrap(pid_t pid,
msg.code = IPCP_MSG_CODE__IPCP_BOOTSTRAP;
msg.conf = conf;
- recv_msg = send_recv_ipcp_msg(pid, &msg);
+ recv_msg = send_recv_ipcp_msg(api, &msg);
if (recv_msg == NULL)
return -1;
@@ -274,7 +272,7 @@ int ipcp_bootstrap(pid_t pid,
return ret;
}
-int ipcp_enroll(pid_t pid,
+int ipcp_enroll(pid_t api,
char * dif_name,
char * n_1_dif)
{
@@ -289,7 +287,7 @@ int ipcp_enroll(pid_t pid,
msg.dif_name = dif_name;
msg.n_1_dif = n_1_dif;
- recv_msg = send_recv_ipcp_msg(pid, &msg);
+ recv_msg = send_recv_ipcp_msg(api, &msg);
if (recv_msg == NULL) {
return -1;
}
@@ -305,7 +303,7 @@ int ipcp_enroll(pid_t pid,
return ret;
}
-int ipcp_name_reg(pid_t pid,
+int ipcp_name_reg(pid_t api,
char * name)
{
ipcp_msg_t msg = IPCP_MSG__INIT;
@@ -318,7 +316,7 @@ int ipcp_name_reg(pid_t pid,
msg.code = IPCP_MSG_CODE__IPCP_NAME_REG;
msg.name = name;
- recv_msg = send_recv_ipcp_msg(pid, &msg);
+ recv_msg = send_recv_ipcp_msg(api, &msg);
if (recv_msg == NULL)
return -1;
@@ -333,7 +331,7 @@ int ipcp_name_reg(pid_t pid,
return ret;
}
-int ipcp_name_unreg(pid_t pid,
+int ipcp_name_unreg(pid_t api,
char * name)
{
ipcp_msg_t msg = IPCP_MSG__INIT;
@@ -343,7 +341,7 @@ int ipcp_name_unreg(pid_t pid,
msg.code = IPCP_MSG_CODE__IPCP_NAME_UNREG;
msg.name = name;
- recv_msg = send_recv_ipcp_msg(pid, &msg);
+ recv_msg = send_recv_ipcp_msg(api, &msg);
if (recv_msg == NULL)
return -1;
@@ -358,9 +356,9 @@ int ipcp_name_unreg(pid_t pid,
return ret;
}
-int ipcp_flow_alloc(pid_t pid,
+int ipcp_flow_alloc(pid_t api,
int port_id,
- pid_t n_pid,
+ pid_t n_api,
char * dst_name,
char * src_ae_name,
enum qos_cube qos)
@@ -375,14 +373,14 @@ int ipcp_flow_alloc(pid_t pid,
msg.code = IPCP_MSG_CODE__IPCP_FLOW_ALLOC;
msg.has_port_id = true;
msg.port_id = port_id;
- msg.has_pid = true;
- msg.pid = n_pid;
+ msg.has_api = true;
+ msg.api = n_api;
msg.src_ae_name = src_ae_name;
msg.dst_name = dst_name;
msg.has_qos_cube = true;
msg.qos_cube = qos;
- recv_msg = send_recv_ipcp_msg(pid, &msg);
+ recv_msg = send_recv_ipcp_msg(api, &msg);
if (recv_msg == NULL)
return -1;
@@ -397,9 +395,9 @@ int ipcp_flow_alloc(pid_t pid,
return ret;
}
-int ipcp_flow_alloc_resp(pid_t pid,
+int ipcp_flow_alloc_resp(pid_t api,
int port_id,
- pid_t n_pid,
+ pid_t n_api,
int response)
{
ipcp_msg_t msg = IPCP_MSG__INIT;
@@ -409,12 +407,12 @@ int ipcp_flow_alloc_resp(pid_t pid,
msg.code = IPCP_MSG_CODE__IPCP_FLOW_ALLOC_RESP;
msg.has_port_id = true;
msg.port_id = port_id;
- msg.has_pid = true;
- msg.pid = n_pid;
+ msg.has_api = true;
+ msg.api = n_api;
msg.has_response = true;
msg.response = response;
- recv_msg = send_recv_ipcp_msg(pid, &msg);
+ recv_msg = send_recv_ipcp_msg(api, &msg);
if (recv_msg == NULL)
return -1;
@@ -429,7 +427,7 @@ int ipcp_flow_alloc_resp(pid_t pid,
return ret;
}
-int ipcp_flow_req_arr(pid_t pid,
+int ipcp_flow_req_arr(pid_t api,
char * dst_name,
char * src_ae_name)
{
@@ -441,8 +439,8 @@ int ipcp_flow_req_arr(pid_t pid,
return -EINVAL;
msg.code = IRM_MSG_CODE__IPCP_FLOW_REQ_ARR;
- msg.has_pid = true;
- msg.pid = pid;
+ msg.has_api = true;
+ msg.api = api;
msg.dst_name = dst_name;
msg.ae_name = src_ae_name;
@@ -461,7 +459,7 @@ int ipcp_flow_req_arr(pid_t pid,
return port_id;
}
-int ipcp_flow_alloc_reply(pid_t pid,
+int ipcp_flow_alloc_reply(pid_t api,
int port_id,
int response)
{
@@ -491,10 +489,10 @@ int ipcp_flow_alloc_reply(pid_t pid,
}
-int ipcp_flow_dealloc(pid_t pid,
+int ipcp_flow_dealloc(pid_t api,
int port_id)
{
- if (pid != 0) {
+ if (api != 0) {
ipcp_msg_t msg = IPCP_MSG__INIT;
ipcp_msg_t * recv_msg = NULL;
int ret = -1;
@@ -503,7 +501,7 @@ int ipcp_flow_dealloc(pid_t pid,
msg.has_port_id = true;
msg.port_id = port_id;
- recv_msg = send_recv_ipcp_msg(pid, &msg);
+ recv_msg = send_recv_ipcp_msg(api, &msg);
if (recv_msg == NULL)
return 0;