summaryrefslogtreecommitdiff
path: root/src/irmd/ipcp.c
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri@ouroboros.rocks>2026-08-16 18:55:15 +0000
committerSander Vrijders <sander@ouroboros.rocks>2026-08-31 08:31:45 +0200
commit5c239c128c04883dbed6d66f574edf8b48d11e11 (patch)
tree6dfcc043c81bd10e1366172b9db5cf5ce93bb8d8 /src/irmd/ipcp.c
parenta830ed966eb3b7d6dbcc43e42a7b6b7c5d796c6a (diff)
downloadouroboros-5c239c128c04883dbed6d66f574edf8b48d11e11.tar.gz
ouroboros-5c239c128c04883dbed6d66f574edf8b48d11e11.zip
lib: Replace shim IPCPs with points of attachment
Removes the UDP and Ethernet shim IPCPs. The unicast and broadcast IPCPs can now directly attach to a "legacy" socket. We adopt Saltzer's Point-of-Attachment terminology, also advocated in Day's "Patterns in Network Architecture". The "poa" component manages these PoA's with one management thread, one link monitoring thread and one thread per attached point. For Ethernet PoA's the irm connect and enroll can resolve the destination IPCP or Layer name with a broadcast name query over the attached PoAs (first reply wins). UDP PoA's require a destination IP address or FQDN. attach to a local endpoint (required both server and client side): irm ipcp poa attach name a udp 10.0.0.1 irm ipcp poa attach name a udp 10.0.0.1:3435 irm ipcp poa attach name a udp [::1]:3435 irm ipcp poa attach name a eth dev eth0 irm ipcp poa attach name a eth dev eth0 ethertype 0xA000 release a PoA (refused while it carries a flow): irm ipcp poa detach name a udp 10.0.0.1:3435 irm ipcp poa detach name a eth eth0 list an IPCP's PoAs: irm ipcp poa list name a connect to a peer, by name or at an address: irm ipcp connect name b dst a irm ipcp connect name b dst a eth irm ipcp connect name b dst a eth dev eth0 irm ipcp connect name b dst a udp 10.0.0.1:3435 irm ipcp connect name b dst a udp peer.example.com:3435 disconnect by peer name, no address: irm ipcp disconnect name b dst a irm ipcp disconnect name b dst a component mgmt enroll has the same shape as connect: irm ipcp enroll name b layer lr autobind irm ipcp enroll name b layer lr autobind eth dev eth0 irm ipcp enroll name b layer lr autobind udp 10.0.0.1:3435 the IRMd config file attaches PoAs and names peers the same way: udp = [ "10.0.0.1", "10.0.0.1:3436" ] eth = [ "eth0", {dev="eth1", ethertype=0xA007} ] enrol={dst="LAN", eth={dev="eth0"}} conn=[{dst="lan3", eth={}}, {dst="lan4", udp="10.0.0.1:3435"}] Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
Diffstat (limited to 'src/irmd/ipcp.c')
-rw-r--r--src/irmd/ipcp.c129
1 files changed, 122 insertions, 7 deletions
diff --git a/src/irmd/ipcp.c b/src/irmd/ipcp.c
index 7eccfc80..cd662221 100644
--- a/src/irmd/ipcp.c
+++ b/src/irmd/ipcp.c
@@ -34,6 +34,7 @@
#include <ouroboros/utils.h>
#include "ipcp.h"
+#include "reg/reg.h"
#include <fcntl.h>
#include <pthread.h>
@@ -72,6 +73,10 @@ static char * str_ipcp_cmd(int code)
return "alloc_resp";
case IPCP_MSG_CODE__IPCP_FLOW_DEALLOC:
return "dealloc";
+ case IPCP_MSG_CODE__IPCP_FLOW_UPDATE:
+ return "flow_update";
+ case IPCP_MSG_CODE__IPCP_REPLY:
+ return "reply";
default:
assert(false);
return "unknown";
@@ -196,7 +201,9 @@ int ipcp_bootstrap(pid_t pid,
msg.conf = ipcp_config_s_to_msg(conf);
recv_msg = send_recv_ipcp_msg(pid, &msg);
+
ipcp_config_msg__free_unpacked(msg.conf, NULL);
+
if (recv_msg == NULL)
return -EIPCP;
@@ -225,9 +232,88 @@ int ipcp_bootstrap(pid_t pid,
return ret;
}
-int ipcp_enroll(pid_t pid,
- const char * dst,
- struct layer_info * info)
+ssize_t ipcp_list_poas(pid_t pid,
+ struct poa_spec ** eps)
+{
+ ipcp_msg_t msg = IPCP_MSG__INIT;
+ ipcp_msg_t * recv_msg;
+ size_t nr;
+ size_t i;
+
+ if (eps == NULL)
+ return -EINVAL;
+
+ *eps = NULL;
+
+ msg.code = IPCP_MSG_CODE__IPCP_LIST_POAS;
+
+ recv_msg = send_recv_ipcp_msg(pid, &msg);
+ if (recv_msg == NULL)
+ return -EIPCP;
+
+ nr = recv_msg->n_poas;
+ if (nr == 0) {
+ ipcp_msg__free_unpacked(recv_msg, NULL);
+ return 0;
+ }
+
+ *eps = malloc(nr * sizeof(**eps));
+ if (*eps == NULL) {
+ ipcp_msg__free_unpacked(recv_msg, NULL);
+ return -ENOMEM;
+ }
+
+ for (i = 0; i < nr; i++)
+ (*eps)[i] = poa_spec_msg_to_s(recv_msg->poas[i]);
+
+ ipcp_msg__free_unpacked(recv_msg, NULL);
+
+ return (ssize_t) nr;
+}
+
+int ipcp_attach(pid_t pid,
+ const struct poa_spec * poa,
+ bool attach)
+{
+ ipcp_msg_t msg = IPCP_MSG__INIT;
+ ipcp_msg_t * recv_msg;
+ int ret;
+
+ if (poa == NULL)
+ return -EINVAL;
+
+ if (attach)
+ msg.code = IPCP_MSG_CODE__IPCP_ATTACH;
+ else
+ msg.code = IPCP_MSG_CODE__IPCP_DETACH;
+
+ msg.poa = poa_spec_s_to_msg(poa);
+ if (msg.poa == NULL)
+ return -EINVAL;
+
+ recv_msg = send_recv_ipcp_msg(pid, &msg);
+
+ poa_spec_msg__free_unpacked(msg.poa, NULL);
+
+ if (recv_msg == NULL)
+ return -EIPCP;
+
+ if (!recv_msg->has_result) {
+ ipcp_msg__free_unpacked(recv_msg, NULL);
+ return -EIPCP;
+ }
+
+ ret = recv_msg->result;
+
+ ipcp_msg__free_unpacked(recv_msg, NULL);
+
+ return ret;
+}
+
+int ipcp_enroll(pid_t pid,
+ const char * dst,
+ const struct poa_addr * addr,
+ struct layer_info * info)
{
ipcp_msg_t msg = IPCP_MSG__INIT;
ipcp_msg_t * recv_msg;
@@ -239,7 +325,16 @@ int ipcp_enroll(pid_t pid,
msg.code = IPCP_MSG_CODE__IPCP_ENROLL;
msg.dst = (char *) dst;
+ if (addr != NULL) {
+ msg.peer = poa_addr_s_to_msg(addr);
+ if (msg.peer == NULL)
+ return -ENOMEM;
+ }
+
recv_msg = send_recv_ipcp_msg(pid, &msg);
+
+ if (msg.peer != NULL)
+ poa_addr_msg__free_unpacked(msg.peer, NULL);
if (recv_msg == NULL)
return -EIPCP;
@@ -267,10 +362,11 @@ int ipcp_enroll(pid_t pid,
return 0;
}
-int ipcp_connect(pid_t pid,
- const char * dst,
- const char * component,
- qosspec_t qs)
+int ipcp_connect(pid_t pid,
+ const char * dst,
+ const char * component,
+ qosspec_t qs,
+ const struct poa_addr * addr)
{
ipcp_msg_t msg = IPCP_MSG__INIT;
ipcp_msg_t * recv_msg;
@@ -283,8 +379,21 @@ int ipcp_connect(pid_t pid,
msg.pid = pid;
msg.qosspec = qos_spec_s_to_msg(&qs);
+ if (addr != NULL) {
+ msg.peer = poa_addr_s_to_msg(addr);
+ if (msg.peer == NULL) {
+ free(msg.qosspec);
+ return -ENOMEM;
+ }
+ }
+
recv_msg = send_recv_ipcp_msg(pid, &msg);
+
+ if (msg.peer != NULL)
+ poa_addr_msg__free_unpacked(msg.peer, NULL);
+
free(msg.qosspec);
+
if (recv_msg == NULL)
return -EIPCP;
@@ -457,6 +566,8 @@ int ipcp_flow_update(const struct flow_info * flow,
msg.has_pk = true;
msg.pk.data = data.data;
msg.pk.len = data.len;
+ msg.has_is_poa = true;
+ msg.is_poa = reg_flow_is_poa(flow->id);
recv_msg = send_recv_ipcp_msg(flow->n_1_pid, &msg);
if (recv_msg == NULL) {
@@ -538,6 +649,8 @@ int ipcp_flow_alloc_resp(const struct flow_info * flow,
msg.has_pk = response == 0;
msg.pk.data = data.data;
msg.pk.len = data.len;
+ msg.has_is_poa = true;
+ msg.is_poa = reg_flow_is_poa(flow->id);
recv_msg = send_recv_ipcp_msg(flow->n_1_pid, &msg);
if (recv_msg == NULL)
@@ -567,6 +680,8 @@ int ipcp_flow_dealloc(pid_t pid,
msg.flow_id = flow_id;
msg.has_timeo_sec = true;
msg.timeo_sec = timeo;
+ msg.has_is_poa = true;
+ msg.is_poa = reg_flow_is_poa(flow_id);
recv_msg = send_recv_ipcp_msg(pid, &msg);
if (recv_msg == NULL)