aboutsummaryrefslogtreecommitdiff
path: root/ffi/irm_wrap.h
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri@ouroboros.rocks>2026-03-04 21:26:43 +0100
committerDimitri Staessens <dimitri@ouroboros.rocks>2026-03-07 15:27:04 +0100
commit7a4c37e8b673328dda59cec11ab9dce66c22a312 (patch)
treed2a05d2fa022d97ba79d8af2d32ec9e7cc3bd9e1 /ffi/irm_wrap.h
parent62924a033cb2a0130cc6a072e03590f8eec5ac72 (diff)
downloadpyouroboros-7a4c37e8b673328dda59cec11ab9dce66c22a312.tar.gz
pyouroboros-7a4c37e8b673328dda59cec11ab9dce66c22a312.zip
ouroboros: Add IRM wrapper
Add ouroboros.irm module wrapping the Ouroboros IRM C API, providing Python interfaces for IPCP lifecycle (create, destroy, bootstrap, enroll, connect), name management (create, destroy, register, list), and program/process binding. Split the monolithic CFFI build into separate _ouroboros_dev_cffi and _ouroboros_irm_cffi modules, each linking only its required library. Also includes: - ouroboros.cli module with higher-level wrappers mirroring CLI tools - FRCT flag support (set/get) in the Flow API - FlowPeer event type in FEventType - QoS defaults updated to match ouroboros source - Bug fixes: flow_set_snd_timeout typo, flow_set_flags calling convention, FlowSet name mangling, fqueue_type return type - .gitignore, copyright updates, version bump to 0.23.0
Diffstat (limited to 'ffi/irm_wrap.h')
-rw-r--r--ffi/irm_wrap.h90
1 files changed, 90 insertions, 0 deletions
diff --git a/ffi/irm_wrap.h b/ffi/irm_wrap.h
new file mode 100644
index 0000000..23b64a0
--- /dev/null
+++ b/ffi/irm_wrap.h
@@ -0,0 +1,90 @@
+/*
+ * Ouroboros - Copyright (C) 2016 - 2026
+ *
+ * An IRM wrapper for Python bindings
+ *
+ * Dimitri Staessens <dimitri@ouroboros.rocks>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., http://www.fsf.org/about/contact/.
+ */
+
+#include <ouroboros/irm.h>
+#include <arpa/inet.h>
+#include <string.h>
+#include <stdlib.h>
+
+static int ipcp_config_udp4_set_ip(struct ipcp_config * conf,
+ const char * ip_str)
+{
+ return inet_pton(AF_INET, ip_str, &conf->udp4.ip_addr) == 1 ? 0 : -1;
+}
+
+static int ipcp_config_udp4_set_dns(struct ipcp_config * conf,
+ const char * dns_str)
+{
+ return inet_pton(AF_INET, dns_str, &conf->udp4.dns_addr) == 1 ? 0 : -1;
+}
+
+static int ipcp_config_udp6_set_ip(struct ipcp_config * conf,
+ const char * ip_str)
+{
+ return inet_pton(AF_INET6, ip_str, &conf->udp6.ip_addr) == 1 ? 0 : -1;
+}
+
+static int ipcp_config_udp6_set_dns(struct ipcp_config * conf,
+ const char * dns_str)
+{
+ return inet_pton(AF_INET6, dns_str, &conf->udp6.dns_addr) == 1 ? 0 : -1;
+}
+
+static void ipcp_config_init_uni(struct ipcp_config * conf,
+ uint8_t addr_size, uint8_t eid_size,
+ uint8_t max_ttl,
+ enum pol_link_state ls_pol,
+ long t_recalc, long t_update, long t_timeo,
+ enum pol_dir dir_pol,
+ uint32_t dht_alpha, uint32_t dht_k,
+ uint32_t dht_t_expire, uint32_t dht_t_refresh,
+ uint32_t dht_t_replicate,
+ enum pol_addr_auth addr_auth,
+ enum pol_cong_avoid cong_avoid)
+{
+ memset(conf, 0, sizeof(*conf));
+ conf->type = IPCP_UNICAST;
+ conf->unicast.dt.addr_size = addr_size;
+ conf->unicast.dt.eid_size = eid_size;
+ conf->unicast.dt.max_ttl = max_ttl;
+ conf->unicast.dt.routing.pol = ROUTING_LINK_STATE;
+ conf->unicast.dt.routing.ls.pol = ls_pol;
+ conf->unicast.dt.routing.ls.t_recalc = t_recalc;
+ conf->unicast.dt.routing.ls.t_update = t_update;
+ conf->unicast.dt.routing.ls.t_timeo = t_timeo;
+ conf->unicast.dir.pol = dir_pol;
+ conf->unicast.dir.dht.params.alpha = dht_alpha;
+ conf->unicast.dir.dht.params.k = dht_k;
+ conf->unicast.dir.dht.params.t_expire = dht_t_expire;
+ conf->unicast.dir.dht.params.t_refresh = dht_t_refresh;
+ conf->unicast.dir.dht.params.t_replicate = dht_t_replicate;
+ conf->unicast.addr_auth_type = addr_auth;
+ conf->unicast.cong_avoid = cong_avoid;
+}
+
+static void ipcp_config_init_eth(struct ipcp_config * conf,
+ const char * dev,
+ uint16_t ethertype)
+{
+ memset(conf, 0, sizeof(*conf));
+ strncpy(conf->eth.dev, dev, DEV_NAME_SIZE);
+ conf->eth.ethertype = ethertype;
+}