summaryrefslogtreecommitdiff
path: root/src/irmd/reg/reg.h
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri@ouroboros.rocks>2024-02-17 10:19:46 +0100
committerSander Vrijders <sander@ouroboros.rocks>2024-02-19 11:49:07 +0100
commit06ee3370998f965b469d1c2859e3e34159c71e20 (patch)
tree93881747a4f1e99f6932231b0cb2358941cb9741 /src/irmd/reg/reg.h
parent7bb8aed15c7f29de4d9719acf8db7fdf73731af5 (diff)
downloadouroboros-06ee3370998f965b469d1c2859e3e34159c71e20.tar.gz
ouroboros-06ee3370998f965b469d1c2859e3e34159c71e20.zip
irmd: Revise IRMd internals
This is a full revision of the IRMd internal implementation. The registry is now a proper subcomponent managing its own internal lock (a single mutex). Some tests are added for the registry and its data structures. Some macros for tests are added in <ouroboros/test.h>. Flow allocation is now more symmetric between the client side (alloc) and server size (accept). Each will create a flow in pending state (ALLOC_PENDING/ACCEPT_PENDING) that is potentially fulfilled by an IPCP using respond_alloc and respond_accept primitives. Deallocation is split in flow_dealloc (application side) and ipcp_flow_dealloc (IPCP side) to get the flow in DEALLOC_PENDING and DEALLOCATED state. Cleanup of failed flow allocation is now properly handled instead of relying on the sanitizer thread. The new sanitizer only needs to monitor crashed processes. On shutdown, the IRMd will now detect hanging processes and SIGKILL them and clean up their fuse mountpoints if needed. A lot of other things have been cleaned up and shuffled around a bit. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
Diffstat (limited to 'src/irmd/reg/reg.h')
-rw-r--r--src/irmd/reg/reg.h151
1 files changed, 151 insertions, 0 deletions
diff --git a/src/irmd/reg/reg.h b/src/irmd/reg/reg.h
new file mode 100644
index 00000000..e6deb8e4
--- /dev/null
+++ b/src/irmd/reg/reg.h
@@ -0,0 +1,151 @@
+/*
+ * Ouroboros - Copyright (C) 2016 - 2024
+ *
+ * The IPC Resource Manager - Registry
+ *
+ * Dimitri Staessens <dimitri@ouroboros.rocks>
+ * Sander Vrijders <sander@ouroboros.rocks>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., http://www.fsf.org/about/contact/.
+ */
+
+#ifndef OUROBOROS_IRMD_REG_H
+#define OUROBOROS_IRMD_REG_H
+
+#include <ouroboros/flow.h>
+#include <ouroboros/ipcp.h>
+#include <ouroboros/name.h>
+#include <ouroboros/proc.h>
+#include <ouroboros/protobuf.h>
+#include <ouroboros/time.h>
+#include <ouroboros/utils.h>
+
+int reg_init(void);
+
+void reg_clear(void);
+
+void reg_fini(void);
+
+int reg_create_flow(struct flow_info * info);
+
+int reg_destroy_flow(int flow_id);
+
+bool reg_has_flow(int flow_id);
+
+int reg_create_ipcp(const struct ipcp_info * info);
+
+int reg_destroy_ipcp(pid_t pid);
+
+bool reg_has_ipcp(pid_t pid);
+
+int reg_set_layer_for_ipcp(struct ipcp_info * info,
+ const struct layer_info * layer);
+
+int reg_get_ipcp(struct ipcp_info * info,
+ struct layer_info * layer);
+
+int reg_get_ipcp_by_layer(struct ipcp_info * info,
+ struct layer_info * layer);
+
+/* TODO don't rely on protobuf here */
+int reg_list_ipcps(ipcp_list_msg_t *** msg);
+
+int reg_create_name(const struct name_info * info);
+
+int reg_destroy_name(const char * name);
+
+bool reg_has_name(const char * name);
+
+/* TODO don't rely on protobuf here */
+int reg_list_names(name_info_msg_t *** names);
+
+int reg_create_proc(const struct proc_info * info);
+
+int reg_destroy_proc(pid_t pid);
+
+bool reg_has_proc(pid_t pid);
+
+void reg_kill_all_proc(int signal);
+
+pid_t reg_get_dead_proc(void);
+
+int reg_create_spawned(pid_t pid);
+
+int reg_destroy_spawned(pid_t pid);
+
+bool reg_has_spawned(pid_t pid);
+
+void reg_kill_all_spawned(int signal);
+
+int reg_first_spawned(void);
+
+int reg_bind_proc(const char * name,
+ pid_t proc);
+
+int reg_unbind_proc(const char * name,
+ pid_t proc);
+
+int reg_create_prog(const struct prog_info * info);
+
+int reg_destroy_prog(const char * name);
+
+bool reg_has_prog(const char * name);
+
+int reg_get_exec(enum hash_algo algo,
+ const uint8_t * hash,
+ char *** exec);
+
+int reg_bind_prog(const char * name,
+ char ** exec,
+ uint8_t flags);
+
+int reg_unbind_prog(const char * name,
+ const char * prog);
+
+int reg_prepare_flow_alloc(struct flow_info * info);
+
+int reg_wait_flow_allocated(struct flow_info * info,
+ buffer_t * pbuf,
+ const struct timespec * abstime);
+
+int reg_respond_alloc(struct flow_info * info,
+ buffer_t * pbuf);
+
+int reg_prepare_flow_accept(struct flow_info * info,
+ buffer_t * pbuf);
+
+int reg_wait_flow_accepted(struct flow_info * info,
+ buffer_t * pbuf,
+ const struct timespec * abstime);
+
+int reg_wait_flow_accepting(enum hash_algo algo,
+ const uint8_t * hash,
+ const struct timespec * abstime);
+
+int reg_respond_accept(struct flow_info * info,
+ buffer_t * pbuf);
+
+void reg_dealloc_flow(struct flow_info * info);
+
+void reg_dealloc_flow_resp(struct flow_info * info);
+
+int reg_wait_proc(pid_t pid,
+ const struct timespec * abstime);
+
+int reg_wait_ipcp_boot(struct ipcp_info * ipcp,
+ const struct timespec * abstime);
+
+int reg_respond_ipcp(const struct ipcp_info * info);
+
+#endif /* OUROBOROS_IRMD_REG_H */