summaryrefslogtreecommitdiff
path: root/src/lib/sockets.c
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri@ouroboros.rocks>2023-03-04 03:48:48 +0100
committerSander Vrijders <sander@ouroboros.rocks>2023-03-08 15:59:37 +0100
commit89b58eaa2706c54aeb0a48252d1cfbd2b5ae01b7 (patch)
tree891c4a2de37e06fdb8879741911a6b7ff2f1b4b8 /src/lib/sockets.c
parentf16b4a1954ab4fbca0ec403f6a04c80375328921 (diff)
downloadouroboros-89b58eaa2706c54aeb0a48252d1cfbd2b5ae01b7.tar.gz
ouroboros-89b58eaa2706c54aeb0a48252d1cfbd2b5ae01b7.zip
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 <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
Diffstat (limited to 'src/lib/sockets.c')
-rw-r--r--src/lib/sockets.c48
1 files changed, 5 insertions, 43 deletions
diff --git a/src/lib/sockets.c b/src/lib/sockets.c
index c82d622f..bb594115 100644
--- a/src/lib/sockets.c
+++ b/src/lib/sockets.c
@@ -100,6 +100,7 @@ int server_socket_open(char * file_name)
return sockfd;
}
+__attribute__((no_sanitize_address))
irm_msg_t * send_recv_irm_msg(irm_msg_t * msg)
{
int sockfd;
@@ -117,18 +118,18 @@ irm_msg_t * send_recv_irm_msg(irm_msg_t * msg)
return NULL;
}
- pthread_cleanup_push(__cleanup_close_ptr, &sockfd);
-
irm_msg__pack(msg, buf);
+ pthread_cleanup_push(__cleanup_close_ptr, &sockfd);
+
if (write(sockfd, buf, len) != -1)
len = read(sockfd, buf, SOCK_BUF_SIZE);
+ pthread_cleanup_pop(true);
+
if (len > 0)
recv_msg = irm_msg__unpack(NULL, len, buf);
- pthread_cleanup_pop(true);
-
return recv_msg;
}
@@ -165,42 +166,3 @@ char * ipcp_sock_path(pid_t pid)
return full_name;
}
-
-qosspec_msg_t spec_to_msg(const qosspec_t * qs)
-{
- qosspec_t spec;
- qosspec_msg_t msg = QOSSPEC_MSG__INIT;
-
- spec = (qs == NULL ? qos_raw : *qs);
-
- msg.delay = spec.delay;
- msg.bandwidth = spec.bandwidth;
- msg.availability = spec.availability;
- msg.loss = spec.loss;
- msg.ber = spec.ber;
- msg.in_order = spec.in_order;
- msg.max_gap = spec.max_gap;
- msg.cypher_s = spec.cypher_s;
- msg.timeout = spec.timeout;
-
- return msg;
-}
-
-qosspec_t msg_to_spec(const qosspec_msg_t * msg)
-{
- qosspec_t spec;
-
- assert(msg);
-
- spec.delay = msg->delay;
- spec.bandwidth = msg->bandwidth;
- spec.availability = msg->availability;
- spec.loss = msg->loss;
- spec.ber = msg->ber;
- spec.in_order = msg->in_order;
- spec.max_gap = msg->max_gap;
- spec.cypher_s = msg->cypher_s;
- spec.timeout = msg->timeout;
-
- return spec;
-}