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
|
/*
* Ouroboros - Copyright (C) 2016 - 2017
*
* The IPC Resource Manager - Registry
*
* Dimitri Staessens <dimitri.staessens@intec.ugent.be>
*
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef OUROBOROS_IRMD_REGISTRY_H
#define OUROBOROS_IRMD_REGISTRY_H
#include <ouroboros/config.h>
#include <ouroboros/list.h>
#include <ouroboros/irm_config.h>
#include <ouroboros/shared.h>
#include "api_table.h"
#include "apn_table.h"
#include <stdint.h>
#include <stdbool.h>
#include <pthread.h>
#include <string.h>
#include <sys/types.h>
#define registry_has_name(r, name) \
(registry_get_entry(r, name) != NULL)
enum reg_name_state {
REG_NAME_NULL = 0,
REG_NAME_IDLE,
REG_NAME_AUTO_ACCEPT,
REG_NAME_AUTO_EXEC,
REG_NAME_FLOW_ACCEPT,
REG_NAME_FLOW_ARRIVED,
REG_NAME_DESTROY
};
/* An entry in the registry */
struct reg_entry {
struct list_head next;
char * name;
/* DIFs in which this name is registered */
struct list_head difs;
/* APs that can be instantiated by the irmd */
struct list_head reg_apns;
/* Instances that are listening for this name */
struct list_head reg_apis;
enum reg_name_state state;
char * req_ae_name;
qoscube_t qos;
int response;
pthread_cond_t state_cond;
pthread_mutex_t state_lock;
};
int reg_entry_add_apn(struct reg_entry * e,
struct apn_entry * a);
void reg_entry_del_apn(struct reg_entry * e,
char * apn);
char * reg_entry_get_apn(struct reg_entry * e);
int reg_entry_add_api(struct reg_entry * e,
pid_t api);
void reg_entry_del_api(struct reg_entry * e,
pid_t api);
pid_t reg_entry_get_api(struct reg_entry * e);
enum reg_name_state reg_entry_get_state(struct reg_entry * e);
int reg_entry_set_state(struct reg_entry * e,
enum reg_name_state state);
int reg_entry_leave_state(struct reg_entry * e,
enum reg_name_state state);
struct reg_entry * registry_add_name(struct list_head * registry,
char * name);
void registry_del_name(struct list_head * registry,
char * name);
void registry_del_api(struct list_head * registry,
pid_t api);
void registry_sanitize_apis(struct list_head * registry);
struct reg_entry * registry_get_entry(struct list_head * registry,
char * name);
int registry_add_name_to_dif(struct list_head * registry,
char * name,
char * dif_name,
enum ipcp_type type);
void registry_del_name_from_dif(struct list_head * registry,
char * name,
char * dif_name);
void registry_destroy(struct list_head * registry);
#endif /* OUROBOROS_IRMD_REGISTRY_H */
|