summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/dev.c78
-rw-r--r--src/lib/ipcp.c88
-rw-r--r--src/lib/ipcpd_messages.proto31
-rw-r--r--src/lib/irm.c10
-rw-r--r--src/lib/irmd_messages.proto72
5 files changed, 148 insertions, 131 deletions
diff --git a/src/lib/dev.c b/src/lib/dev.c
index c138b009..60dee701 100644
--- a/src/lib/dev.c
+++ b/src/lib/dev.c
@@ -43,9 +43,11 @@ int ap_reg(char * ap_name,
return -EINVAL;
}
- msg.code = IRM_MSG_CODE__IRM_AP_REG;
- msg.ap_name = ap_name;
- msg.dif_name = difs;
+ msg.code = IRM_MSG_CODE__IRM_AP_REG;
+ msg.has_pid = true;
+ msg.pid = getpid();
+ msg.ap_name = ap_name;
+ msg.dif_name = difs;
msg.n_dif_name = difs_size;
recv_msg = send_recv_irm_msg(&msg);
@@ -78,9 +80,11 @@ int ap_unreg(char * ap_name,
return -EINVAL;
}
- msg.code = IRM_MSG_CODE__IRM_AP_UNREG;
- msg.ap_name = ap_name;
- msg.dif_name = difs;
+ msg.code = IRM_MSG_CODE__IRM_AP_UNREG;
+ msg.has_pid = true;
+ msg.pid = getpid();
+ msg.ap_name = ap_name;
+ msg.dif_name = difs;
msg.n_dif_name = difs_size;
recv_msg = send_recv_irm_msg(&msg);
@@ -110,9 +114,11 @@ int flow_accept(int fd,
return -EINVAL;
}
- msg.code = IRM_MSG_CODE__IRM_FLOW_ACCEPT;
- msg.has_fd = true;
- msg.fd = fd;
+ msg.code = IRM_MSG_CODE__IRM_FLOW_ACCEPT;
+ msg.has_pid = true;
+ msg.pid = getpid();
+ msg.has_fd = true;
+ msg.fd = fd;
recv_msg = send_recv_irm_msg(&msg);
if (recv_msg == NULL)
@@ -122,7 +128,7 @@ int flow_accept(int fd,
irm_msg__free_unpacked(recv_msg, NULL);
return -1;
}
- cli_fd = recv_msg->fd;
+ cli_fd = recv_msg->fd;
ap_name = recv_msg->ap_name;
ae_name = recv_msg->ae_name;
@@ -131,17 +137,19 @@ int flow_accept(int fd,
}
int flow_alloc_resp(int fd,
- int result)
+ int response)
{
irm_msg_t msg = IRM_MSG__INIT;
irm_msg_t * recv_msg = NULL;
int ret = -1;
- msg.code = IRM_MSG_CODE__IRM_FLOW_ALLOC_RESP;
- msg.has_fd = true;
+ msg.code = IRM_MSG_CODE__IRM_FLOW_ALLOC_RESP;
+ msg.has_pid = true;
+ msg.pid = getpid();
+ msg.has_fd = true;
msg.fd = fd;
- msg.has_result = true;
- msg.result = result;
+ msg.has_response = true;
+ msg.response = response;
recv_msg = send_recv_irm_msg(&msg);
if (recv_msg == NULL)
@@ -158,7 +166,7 @@ int flow_alloc_resp(int fd,
return ret;
}
-int flow_alloc(char * dst_ap_name,
+int flow_alloc(char * dst_name,
char * src_ap_name,
char * src_ae_name,
struct qos_spec * qos,
@@ -168,18 +176,18 @@ int flow_alloc(char * dst_ap_name,
irm_msg_t * recv_msg = NULL;
int fd = 0;
- if (dst_ap_name == NULL ||
+ if (dst_name == NULL ||
src_ap_name == NULL ||
qos == NULL) {
return -EINVAL;
}
- msg.code = IRM_MSG_CODE__IRM_FLOW_ALLOC;
- msg.dst_ap_name = dst_ap_name;
- msg.ap_name = src_ap_name;
- msg.ae_name = src_ae_name;
- msg.has_oflags = true;
- msg.oflags = oflags;
+ msg.code = IRM_MSG_CODE__IRM_FLOW_ALLOC;
+ msg.dst_name = dst_name;
+ msg.ap_name = src_ap_name;
+ msg.ae_name = src_ae_name;
+ msg.has_oflags = true;
+ msg.oflags = oflags;
recv_msg = send_recv_irm_msg(&msg);
if (recv_msg == NULL)
@@ -201,9 +209,11 @@ int flow_alloc_res(int fd)
irm_msg_t * recv_msg = NULL;
int result = 0;
- msg.code = IRM_MSG_CODE__IRM_FLOW_ALLOC_RES;
- msg.has_fd = true;
- msg.fd = fd;
+ msg.code = IRM_MSG_CODE__IRM_FLOW_ALLOC_RES;
+ msg.has_pid = true;
+ msg.pid = getpid();
+ msg.has_fd = true;
+ msg.fd = fd;
recv_msg = send_recv_irm_msg(&msg);
if (recv_msg == NULL)
@@ -226,9 +236,11 @@ int flow_dealloc(int fd)
irm_msg_t * recv_msg = NULL;
int ret = -1;
- msg.code = IRM_MSG_CODE__IRM_FLOW_DEALLOC;
- msg.has_fd = true;
- msg.fd = fd;
+ msg.code = IRM_MSG_CODE__IRM_FLOW_DEALLOC;
+ msg.has_pid = true;
+ msg.pid = getpid();
+ msg.has_fd = true;
+ msg.fd = fd;
recv_msg = send_recv_irm_msg(&msg);
if (recv_msg == NULL)
@@ -251,9 +263,11 @@ int flow_cntl(int fd, int oflags)
irm_msg_t * recv_msg = NULL;
int ret = -1;
- msg.has_fd = true;
- msg.fd = fd;
- msg.oflags = oflags;
+ msg.has_pid = true;
+ msg.pid = getpid();
+ msg.has_fd = true;
+ msg.fd = fd;
+ msg.oflags = oflags;
recv_msg = send_recv_irm_msg(&msg);
if (recv_msg == NULL)
diff --git a/src/lib/ipcp.c b/src/lib/ipcp.c
index 338d8683..387572b3 100644
--- a/src/lib/ipcp.c
+++ b/src/lib/ipcp.c
@@ -99,12 +99,11 @@ static ipcp_msg_t * send_recv_ipcp_msg(pid_t pid,
return recv_msg;
}
-pid_t ipcp_create(instance_name_t * api,
- enum ipcp_type ipcp_type)
+pid_t ipcp_create(char * ipcp_name,
+ enum ipcp_type ipcp_type)
{
pid_t pid = 0;
char irmd_pid[10];
- char * api_id = NULL;
size_t len = 0;
char * ipcp_dir = "bin";
char * full_name = NULL;
@@ -122,21 +121,12 @@ pid_t ipcp_create(instance_name_t * api,
return pid;
}
- api_id = malloc(n_digits(api->id) + 1);
- if (!api_id) {
- LOG_ERR("Failed to malloc");
- exit(EXIT_FAILURE);
- }
- sprintf(api_id, "%d", api->id);
-
if (ipcp_type == IPCP_NORMAL)
exec_name = IPCP_NORMAL_EXEC;
else if (ipcp_type == IPCP_SHIM_UDP)
exec_name = IPCP_SHIM_UDP_EXEC;
- else {
- free(api_id);
+ else
exit(EXIT_FAILURE);
- }
len += strlen(INSTALL_DIR);
len += strlen(ipcp_dir);
@@ -146,7 +136,6 @@ pid_t ipcp_create(instance_name_t * api,
full_name = malloc(len + 1);
if (full_name == NULL) {
LOG_ERR("Failed to malloc");
- free(api_id);
exit(EXIT_FAILURE);
}
@@ -161,8 +150,7 @@ pid_t ipcp_create(instance_name_t * api,
char * argv[] = {full_name,
irmd_pid,
- api->name,
- api_id,
+ ipcp_name,
0};
char * envp[] = {0};
@@ -172,7 +160,6 @@ pid_t ipcp_create(instance_name_t * api,
LOG_DBG("%s", strerror(errno));
LOG_ERR("Failed to load IPCP daemon");
LOG_ERR("Make sure to run the installed version");
- free(api_id);
free(full_name);
exit(EXIT_FAILURE);
}
@@ -326,21 +313,18 @@ int ipcp_enroll(pid_t pid,
return ret;
}
-int ipcp_ap_reg(pid_t pid,
- uint32_t reg_ap_id,
- char * ap_name)
+int ipcp_name_reg(pid_t pid,
+ char * name)
{
ipcp_msg_t msg = IPCP_MSG__INIT;
ipcp_msg_t * recv_msg = NULL;
int ret = -1;
- if (ap_name == NULL)
+ if (name == NULL)
return -1;
- msg.code = IPCP_MSG_CODE__IPCP_AP_REG;
- msg.ap_name = ap_name;
- msg.has_reg_ap_id = true;
- msg.reg_ap_id = reg_ap_id;
+ msg.code = IPCP_MSG_CODE__IPCP_NAME_REG;
+ msg.name = name;
recv_msg = send_recv_ipcp_msg(pid, &msg);
if (recv_msg == NULL)
@@ -357,16 +341,15 @@ int ipcp_ap_reg(pid_t pid,
return ret;
}
-int ipcp_ap_unreg(pid_t pid,
- uint32_t reg_ap_id)
+int ipcp_name_unreg(pid_t pid,
+ char * name)
{
ipcp_msg_t msg = IPCP_MSG__INIT;
ipcp_msg_t * recv_msg = NULL;
int ret = -1;
- msg.code = IPCP_MSG_CODE__IPCP_AP_UNREG;
- msg.has_reg_ap_id = true;
- msg.reg_ap_id = reg_ap_id;
+ msg.code = IPCP_MSG_CODE__IPCP_NAME_UNREG;
+ msg.name = name;
recv_msg = send_recv_ipcp_msg(pid, &msg);
if (recv_msg == NULL)
@@ -385,7 +368,7 @@ int ipcp_ap_unreg(pid_t pid,
int ipcp_flow_alloc(pid_t pid,
uint32_t port_id,
- char * dst_ap_name,
+ char * dst_name,
char * src_ap_name,
char * src_ae_name,
struct qos_spec * qos)
@@ -394,13 +377,13 @@ int ipcp_flow_alloc(pid_t pid,
ipcp_msg_t * recv_msg = NULL;
int ret = -1;
- if (dst_ap_name == NULL || src_ap_name == NULL || src_ae_name == NULL)
+ if (dst_name == NULL || src_ap_name == NULL || src_ae_name == NULL)
return -EINVAL;
msg.code = IPCP_MSG_CODE__IPCP_FLOW_ALLOC;
- msg.ap_name = src_ap_name;
- msg.ae_name = src_ae_name;
- msg.dst_ap_name = dst_ap_name;
+ msg.src_ap_name = src_ap_name;
+ msg.src_ae_name = src_ae_name;
+ msg.dst_name = dst_name;
msg.port_id = port_id;
msg.has_port_id = true;
@@ -449,22 +432,21 @@ int ipcp_flow_alloc_resp(pid_t pid,
}
int ipcp_flow_req_arr(pid_t pid,
- uint32_t reg_ap_id,
- char * ap_name,
- char * ae_name)
+ char * dst_name,
+ char * src_ap_name,
+ char * src_ae_name)
{
irm_msg_t msg = IRM_MSG__INIT;
irm_msg_t * recv_msg = NULL;
int fd = -1;
- if (ap_name == NULL || ae_name == NULL)
+ if (src_ap_name == NULL || src_ae_name == NULL)
return -EINVAL;
msg.code = IRM_MSG_CODE__IPCP_FLOW_REQ_ARR;
- msg.ap_name = ap_name;
- msg.ae_name = ae_name;
- msg.reg_ap_id = reg_ap_id;
- msg.has_reg_ap_id = true;
+ msg.dst_name = dst_name;
+ msg.ap_name = src_ap_name;
+ msg.ae_name = src_ae_name;
msg.pid = pid;
msg.has_pid = true;
@@ -485,17 +467,17 @@ int ipcp_flow_req_arr(pid_t pid,
int ipcp_flow_alloc_reply(pid_t pid,
uint32_t port_id,
- int result)
+ int response)
{
irm_msg_t msg = IRM_MSG__INIT;
irm_msg_t * recv_msg = NULL;
int ret = -1;
- msg.code = IRM_MSG_CODE__IPCP_FLOW_ALLOC_REPLY;
- msg.port_id = port_id;
- msg.has_port_id = true;
- msg.result = result;
- msg.has_result = true;
+ msg.code = IRM_MSG_CODE__IPCP_FLOW_ALLOC_REPLY;
+ msg.port_id = port_id;
+ msg.has_port_id = true;
+ msg.response = response;
+ msg.has_response = true;
recv_msg = send_recv_irm_msg(&msg);
if (recv_msg == NULL)
@@ -521,9 +503,9 @@ int ipcp_flow_dealloc(pid_t pid,
ipcp_msg_t * recv_msg = NULL;
int ret = -1;
- msg.code = IPCP_MSG_CODE__IPCP_FLOW_DEALLOC;
+ msg.code = IPCP_MSG_CODE__IPCP_FLOW_DEALLOC;
msg.has_port_id = true;
- msg.port_id = port_id;
+ msg.port_id = port_id;
recv_msg = send_recv_ipcp_msg(pid, &msg);
if (recv_msg == NULL)
@@ -543,9 +525,9 @@ int ipcp_flow_dealloc(pid_t pid,
irm_msg_t * recv_msg = NULL;
int ret = -1;
- msg.code = IRM_MSG_CODE__IPCP_FLOW_DEALLOC;
+ msg.code = IRM_MSG_CODE__IPCP_FLOW_DEALLOC;
msg.has_port_id = true;
- msg.port_id = port_id;
+ msg.port_id = port_id;
recv_msg = send_recv_irm_msg(&msg);
if (recv_msg == NULL)
diff --git a/src/lib/ipcpd_messages.proto b/src/lib/ipcpd_messages.proto
index 796638c7..da4bb469 100644
--- a/src/lib/ipcpd_messages.proto
+++ b/src/lib/ipcpd_messages.proto
@@ -1,16 +1,16 @@
import "dif_config.proto";
enum ipcp_msg_code {
- IPCP_BOOTSTRAP = 1;
- IPCP_ENROLL = 2;
- IPCP_REG = 3;
- IPCP_UNREG = 4;
- IPCP_AP_REG = 5;
- IPCP_AP_UNREG = 6;
- IPCP_FLOW_ALLOC = 7;
- IPCP_FLOW_ALLOC_RESP = 8;
- IPCP_FLOW_DEALLOC = 9;
- IPCP_REPLY = 10;
+ IPCP_BOOTSTRAP = 1;
+ IPCP_ENROLL = 2;
+ IPCP_REG = 3;
+ IPCP_UNREG = 4;
+ IPCP_NAME_REG = 5;
+ IPCP_NAME_UNREG = 6;
+ IPCP_FLOW_ALLOC = 7;
+ IPCP_FLOW_ALLOC_RESP = 8;
+ IPCP_FLOW_DEALLOC = 9;
+ IPCP_REPLY = 10;
};
message ipcp_msg {
@@ -19,11 +19,12 @@ message ipcp_msg {
optional string n_1_dif = 3;
repeated string dif_names = 4;
optional int32 len = 5;
- optional string ap_name = 6;
- optional int32 reg_ap_id = 7;
- optional int32 port_id = 8;
- optional string dst_ap_name = 9;
- optional string ae_name = 10;
+ optional string name = 6;
+ optional int32 port_id = 7;
+ optional string dst_name = 8;
+ optional string src_ap_name = 9;
+ optional string src_ae_name = 10;
optional dif_config_msg conf = 11;
optional int32 result = 12;
+ optional int32 fd = 13;
};
diff --git a/src/lib/irm.c b/src/lib/irm.c
index b17cb04c..cc1c0d01 100644
--- a/src/lib/irm.c
+++ b/src/lib/irm.c
@@ -30,20 +30,18 @@
#include <stdlib.h>
-int irm_create_ipcp(instance_name_t * api,
- enum ipcp_type ipcp_type)
+pid_t irm_create_ipcp(char * ipcp_name,
+ enum ipcp_type ipcp_type)
{
irm_msg_t msg = IRM_MSG__INIT;
irm_msg_t * recv_msg = NULL;
int ret = -1;
- if (api == NULL || api->name == NULL)
+ if (ipcp_name == NULL)
return -EINVAL;
msg.code = IRM_MSG_CODE__IRM_CREATE_IPCP;
- msg.ap_name = api->name;
- msg.has_api_id = true;
- msg.api_id = api->id;
+ msg.ap_name = ipcp_name;
msg.has_ipcp_type = true;
msg.ipcp_type = ipcp_type;
diff --git a/src/lib/irmd_messages.proto b/src/lib/irmd_messages.proto
index 92ea439e..89e2c882 100644
--- a/src/lib/irmd_messages.proto
+++ b/src/lib/irmd_messages.proto
@@ -1,41 +1,63 @@
+/*
+ * Ouroboros - Copyright (C) 2016
+ *
+ * IRM messages
+ *
+ * Sander Vrijders <sander.vrijders@intec.ugent.be>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
import "dif_config.proto";
enum irm_msg_code {
- IRM_CREATE_IPCP = 1;
- IRM_DESTROY_IPCP = 2;
- IRM_BOOTSTRAP_IPCP = 3;
- IRM_ENROLL_IPCP = 4;
- IRM_REG_IPCP = 5;
- IRM_UNREG_IPCP = 6;
- IRM_AP_REG = 7;
- IRM_AP_UNREG = 8;
- IRM_FLOW_ACCEPT = 9;
- IRM_FLOW_ALLOC_RESP = 10;
- IRM_FLOW_ALLOC = 11;
- IRM_FLOW_ALLOC_RES = 12;
- IRM_FLOW_DEALLOC = 13;
- IRM_FLOW_CONTROL = 14;
- IRM_FLOW_WRITE = 15;
- IRM_FLOW_READ = 16;
- IPCP_FLOW_REQ_ARR = 17;
+ IRM_CREATE_IPCP = 1;
+ IRM_DESTROY_IPCP = 2;
+ IRM_BOOTSTRAP_IPCP = 3;
+ IRM_ENROLL_IPCP = 4;
+ IRM_REG_IPCP = 5;
+ IRM_UNREG_IPCP = 6;
+ IRM_AP_REG = 7;
+ IRM_AP_UNREG = 8;
+ IRM_FLOW_ACCEPT = 9;
+ IRM_FLOW_ALLOC_RESP = 10;
+ IRM_FLOW_ALLOC = 11;
+ IRM_FLOW_ALLOC_RES = 12;
+ IRM_FLOW_DEALLOC = 13;
+ IRM_FLOW_CONTROL = 14;
+ IRM_FLOW_WRITE = 15;
+ IRM_FLOW_READ = 16;
+ IPCP_FLOW_REQ_ARR = 17;
IPCP_FLOW_ALLOC_REPLY = 18;
- IPCP_FLOW_DEALLOC = 19;
- IRM_REPLY = 20;
+ IPCP_FLOW_DEALLOC = 19;
+ IRM_REPLY = 20;
};
message irm_msg {
required irm_msg_code code = 1;
optional string ap_name = 2;
- optional uint32 api_id = 3;
optional string ae_name = 4;
+ optional uint32 api_id = 3;
optional uint32 ipcp_type = 5;
repeated string dif_name = 6;
optional int32 fd = 7;
- optional int32 result = 8;
+ optional int32 response = 8;
optional int32 oflags = 9;
- optional string dst_ap_name = 10;
+ optional string dst_name = 10;
optional uint32 port_id = 11;
- optional uint32 reg_ap_id = 12;
- optional int32 pid = 13;
- optional dif_config_msg conf = 14;
+ optional int32 pid = 12;
+ optional dif_config_msg conf = 13;
+ optional int32 result = 14;
};