summaryrefslogtreecommitdiff
path: root/src/irmd/ipcp.c
diff options
context:
space:
mode:
authorDimitri Staessens <[email protected]>2023-03-14 12:50:27 +0100
committerSander Vrijders <[email protected]>2023-03-18 17:12:27 +0100
commit99b4f4d6d6f18321489bae50f1762b29165f7de1 (patch)
tree980ce47c1e7e84b91403ecc8f8263c8d05dfc1c3 /src/irmd/ipcp.c
parent3b2f38aeafa1d6d2976dd5581ef46a5d3b463825 (diff)
downloadouroboros-99b4f4d6d6f18321489bae50f1762b29165f7de1.tar.gz
ouroboros-99b4f4d6d6f18321489bae50f1762b29165f7de1.zip
irmd: Use buffer_t for piggybacked data
Instead of passing a const void * and len, it now passes buffer_t to operations that send piggybacked data (flow_req_arr and flow_reply) and a buffer_t * for operations that send and receive piggybacked data (flow_alloc and flow_accept). Signed-off-by: Dimitri Staessens <[email protected]> Signed-off-by: Sander Vrijders <[email protected]>
Diffstat (limited to 'src/irmd/ipcp.c')
-rw-r--r--src/irmd/ipcp.c37
1 files changed, 18 insertions, 19 deletions
diff --git a/src/irmd/ipcp.c b/src/irmd/ipcp.c
index c062809c..360934b0 100644
--- a/src/irmd/ipcp.c
+++ b/src/irmd/ipcp.c
@@ -99,6 +99,7 @@ ipcp_msg_t * send_recv_ipcp_msg(pid_t pid,
default:
tv.tv_sec = SOCKET_TIMEOUT / 1000;
tv.tv_usec = (SOCKET_TIMEOUT % 1000) * 1000;
+
break;
}
@@ -176,7 +177,7 @@ pid_t ipcp_create(const char * name,
argv[4] = NULL;
- if (posix_spawn(&pid, argv[0], NULL, NULL, argv, NULL)) {
+ if (posix_spawn(&pid, argv[0], NULL, NULL, argv, NULL) != 0) {
log_err("Failed to spawn new process");
return -1;
}
@@ -434,8 +435,7 @@ static int __ipcp_flow_alloc(pid_t pid,
size_t len,
qosspec_t qs,
bool join,
- const void * data,
- size_t dlen)
+ const buffer_t data)
{
ipcp_msg_t msg = IPCP_MSG__INIT;
ipcp_msg_t * recv_msg = NULL;
@@ -454,8 +454,8 @@ static int __ipcp_flow_alloc(pid_t pid,
msg.hash.data = (uint8_t *) dst;
msg.qosspec = qos_spec_s_to_msg(&qs);;
msg.has_pk = true;
- msg.pk.data = (uint8_t *) data;
- msg.pk.len = (uint32_t) dlen;
+ msg.pk.data = data.data;
+ msg.pk.len = data.len;
recv_msg = send_recv_ipcp_msg(pid, &msg);
free(msg.qosspec);
@@ -479,11 +479,10 @@ int ipcp_flow_alloc(pid_t pid,
const uint8_t * dst,
size_t len,
qosspec_t qs,
- const void * data,
- size_t dlen)
+ const buffer_t data)
{
- return __ipcp_flow_alloc(pid, flow_id, n_pid, dst, len, qs, false,
- data, dlen);
+ return __ipcp_flow_alloc(pid, flow_id, n_pid, dst,
+ len, qs, false, data);
}
int ipcp_flow_join(pid_t pid,
@@ -493,16 +492,16 @@ int ipcp_flow_join(pid_t pid,
size_t len,
qosspec_t qs)
{
- return __ipcp_flow_alloc(pid, flow_id, n_pid, dst, len, qs, true,
- NULL, 0);
+ buffer_t data = {NULL, 0};
+ return __ipcp_flow_alloc(pid, flow_id, n_pid, dst,
+ len, qs, true, data);
}
-int ipcp_flow_alloc_resp(pid_t pid,
- int flow_id,
- pid_t n_pid,
- int response,
- const void * data,
- size_t len)
+int ipcp_flow_alloc_resp(pid_t pid,
+ int flow_id,
+ pid_t n_pid,
+ int response,
+ const buffer_t data)
{
ipcp_msg_t msg = IPCP_MSG__INIT;
ipcp_msg_t * recv_msg = NULL;
@@ -516,8 +515,8 @@ int ipcp_flow_alloc_resp(pid_t pid,
msg.has_response = true;
msg.response = response;
msg.has_pk = true;
- msg.pk.data = (uint8_t *) data;
- msg.pk.len = (uint32_t) len;
+ msg.pk.data = data.data;
+ msg.pk.len = data.len;
recv_msg = send_recv_ipcp_msg(pid, &msg);
if (recv_msg == NULL)