summaryrefslogtreecommitdiff
path: root/src/irmd/reg/name.h
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri@ouroboros.rocks>2023-03-18 21:02:10 +0100
committerSander Vrijders <sander@ouroboros.rocks>2023-03-21 18:12:28 +0100
commit54156a3d9a2a7f87591e5efd37a8fe6f708b933f (patch)
tree8df5ecafc1fd199adb05ea8f4573103c38c63848 /src/irmd/reg/name.h
parent9ce5f6b0b1ae281bfa82df31a92026d946366286 (diff)
downloadouroboros-54156a3d9a2a7f87591e5efd37a8fe6f708b933f.tar.gz
ouroboros-54156a3d9a2a7f87591e5efd37a8fe6f708b933f.zip
irmd: Move registry objects to their own sources
Rename internal data structures so it's clear that they are the IRMd representation of these objects for management purposes. Split functionality for these objects off and and move them to their own source files. Rename internal functions of the IRMd to reflect this, with some small refactoring. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
Diffstat (limited to 'src/irmd/reg/name.h')
-rw-r--r--src/irmd/reg/name.h103
1 files changed, 103 insertions, 0 deletions
diff --git a/src/irmd/reg/name.h b/src/irmd/reg/name.h
new file mode 100644
index 00000000..0731782c
--- /dev/null
+++ b/src/irmd/reg/name.h
@@ -0,0 +1,103 @@
+/*
+ * Ouroboros - Copyright (C) 2016 - 2023
+ *
+ * The IPC Resource Manager - Registry - Names
+ *
+ * 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_NAME_H
+#define OUROBOROS_IRMD_REG_NAME_H
+
+#include <ouroboros/hash.h>
+#include <ouroboros/ipcp.h>
+#include <ouroboros/list.h>
+#include <ouroboros/irm.h>
+
+#include "proc.h"
+#include "prog.h"
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <pthread.h>
+#include <string.h>
+#include <sys/types.h>
+
+enum name_state {
+ NAME_NULL = 0,
+ NAME_IDLE,
+ NAME_AUTO_ACCEPT,
+ NAME_AUTO_EXEC,
+ NAME_FLOW_ACCEPT,
+ NAME_FLOW_ARRIVED,
+ NAME_DESTROY
+};
+
+/* An entry in the registry */
+struct reg_name {
+ struct list_head next;
+ char * name;
+
+ /* Policies for this name. */
+ enum pol_balance pol_lb; /* Load balance incoming flows. */
+ /* Programs that can be instantiated by the irmd. */
+ struct list_head reg_progs;
+ /* Processes that are listening for this name. */
+ struct list_head reg_pids;
+
+ enum name_state state;
+ pthread_cond_t cond;
+ pthread_mutex_t mtx;
+};
+
+struct reg_name * reg_name_create(const char * name,
+ enum pol_balance lb);
+
+void reg_name_destroy(struct reg_name * n);
+
+int reg_name_add_prog(struct reg_name * n,
+ struct reg_prog * p);
+
+void reg_name_del_prog(struct reg_name * n,
+ const char * prog);
+
+char * reg_name_get_prog(struct reg_name * n);
+
+int reg_name_add_pid(struct reg_name * n,
+ pid_t pid);
+
+void reg_name_del_pid(struct reg_name * n,
+ pid_t pid);
+
+void reg_name_del_pid_el(struct reg_name * n,
+ struct pid_el * p);
+
+pid_t reg_name_get_pid(struct reg_name * n);
+
+void reg_name_set_policy(struct reg_name * n,
+ enum pol_balance lb);
+
+enum name_state reg_name_get_state(struct reg_name * n);
+
+int reg_name_set_state(struct reg_name * n,
+ enum name_state state);
+
+int reg_name_leave_state(struct reg_name * n,
+ enum name_state state,
+ struct timespec * timeout);
+
+#endif /* OUROBOROS_IRMD_REG_NAME_H */