From 89b58eaa2706c54aeb0a48252d1cfbd2b5ae01b7 Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Sat, 4 Mar 2023 03:48:48 +0100 Subject: irmd: Add configuration file support This adds initial support for configuration files using the C99 TOML parser (to be installed separately from https://github.com/cktan/tomlc99). The default location for the IRMd configuration file is /etc/ouroboros/irmd.conf. This is configurable at build time. An example file will be installed in the configuration directory with the name irmd.conf.example. Config file support can be disabled using the DISABLE_CONFIGFILE build option. There were some refactors and changes to the configuration messages and protobuf files. This works towards consolidation of protobuf C as an option for more generic handling of serialization/deserialization of various messages. Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- src/lib/dev.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/lib/dev.c') diff --git a/src/lib/dev.c b/src/lib/dev.c index c46bbdd7..e84efe55 100644 --- a/src/lib/dev.c +++ b/src/lib/dev.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -795,7 +796,7 @@ int flow_accept(qosspec_t * qs, crypt_dh_pkp_destroy(pkp); fd = flow_init(recv_msg->flow_id, recv_msg->pid, - msg_to_spec(recv_msg->qosspec), s, + qos_spec_msg_to_s(recv_msg->qosspec), s, recv_msg->mpl); irm_msg__free_unpacked(recv_msg, NULL); @@ -827,7 +828,6 @@ static int __flow_alloc(const char * dst, bool join) { irm_msg_t msg = IRM_MSG__INIT; - qosspec_msg_t qs_msg = QOSSPEC_MSG__INIT; irm_msg_t * recv_msg; int fd; void * pkp = NULL; /* public key pair */ @@ -846,8 +846,7 @@ static int __flow_alloc(const char * dst, msg.dst = (char *) dst; msg.has_pid = true; msg.pid = getpid(); - qs_msg = spec_to_msg(qs); - msg.qosspec = &qs_msg; + msg.qosspec = qos_spec_s_to_msg(qs); if (timeo != NULL) { msg.has_timeo_sec = true; @@ -871,6 +870,8 @@ static int __flow_alloc(const char * dst, } recv_msg = send_recv_irm_msg(&msg); + qosspec_msg__free_unpacked(msg.qosspec, NULL); + if (recv_msg == NULL) goto fail_send; @@ -1832,7 +1833,6 @@ int ipcp_flow_req_arr(const uint8_t * dst, { irm_msg_t msg = IRM_MSG__INIT; irm_msg_t * recv_msg; - qosspec_msg_t qs_msg; int fd; assert(dst != NULL); @@ -1843,8 +1843,7 @@ int ipcp_flow_req_arr(const uint8_t * dst, msg.has_hash = true; msg.hash.len = len; msg.hash.data = (uint8_t *) dst; - qs_msg = spec_to_msg(&qs); - msg.qosspec = &qs_msg; + msg.qosspec = qos_spec_s_to_msg(&qs); msg.has_mpl = true; msg.mpl = mpl; msg.has_pk = true; @@ -1852,6 +1851,8 @@ int ipcp_flow_req_arr(const uint8_t * dst, msg.pk.len = dlen; recv_msg = send_recv_irm_msg(&msg); + qosspec_msg__free_unpacked(msg.qosspec, NULL); + if (recv_msg == NULL) return -EIRMD; -- cgit v1.2.3