summaryrefslogtreecommitdiff
path: root/src/irmd/reg/reg.h
blob: 17dfcc32d8be402178895eae77a05325b31a5b03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/*
 * 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_proc(const struct proc_info * info);

/* Use this for all processes, including ipcps */
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);

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_ipcp(const struct ipcp_info * info);

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_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 */