-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplugin_extra_configuration.h
160 lines (108 loc) · 4.06 KB
/
plugin_extra_configuration.h
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
149
150
151
152
153
154
155
156
157
158
159
160
//
// Created by thomas on 28/05/20.
//
#ifndef UBPF_TOOLS_PLUGIN_EXTRA_CONFIGURATION_H
#define UBPF_TOOLS_PLUGIN_EXTRA_CONFIGURATION_H
#include <json-c/json_object.h>
#include <netinet/in.h>
#include "uthash.h"
#include "utlist.h"
#include <xbgp_compliant_api/xbgp_common_vm_defs.h>
#include "tommy.h"
#define MAX_STR_BUF_PFX 45
enum type_val {
conf_val_type_undef = 0,
conf_val_type_int,
conf_val_type_double,
conf_val_type_ipv4,
conf_val_type_ipv6,
conf_val_type_ipv4_prefix,
conf_val_type_ipv6_prefix,
conf_val_type_list,
conf_val_type_dict,
conf_val_type_string,
conf_val_type_max,
};
struct prefix_ip6 {
int family;
int prefix_len;
struct in6_addr p;
};
struct prefix_ip4 {
int family;
int prefix_len;
struct in_addr p;
};
/*struct conf_lst {
struct conf_val *cf_val;
struct conf_lst *next, *prev;
};*/
struct conf_arg {
tommy_hashdyn_node hash_node;
struct conf_val *val;
size_t len_key;
char key[0];
};
typedef tommy_hashdyn dict;
struct conf_val {
int type;
union {
struct prefix_ip4 ip4_pfx;
struct prefix_ip6 ip6_pfx;
struct in_addr ip4;
struct in6_addr ip6;
uint64_t int_val;
double dbl_val;
struct {
size_t len;
char *str;
} string;
struct {
size_t len;
struct conf_val **array;
} lst;
dict dict;
} val;
};
int extra_info_from_json(const char *path, const char *key);
int json_parse_extra_info(json_object *manifest);
struct conf_val *get_extra_from_key(const char *key);
int get_global_info(const char *key, struct global_info *info);
int get_info_lst_idx(const struct global_info *info, unsigned int array_idx, struct global_info *value);
int get_info_dict(struct global_info *info, const char *key, struct global_info *value);
int extra_info_copy_data(struct global_info *info, void *buf, size_t len);
int extra_info_copy_data_lst_idx(const char *key, int arr_idx, void *buf, size_t len);
int delete_conf_arg(const char *key);
int delete_all_extra_info(void);
int extra_conf_parse_int(json_object *value, struct conf_val *val);
int extra_conf_parse_float(json_object *value, struct conf_val *val);
int extra_conf_parse_ip4(json_object *value, struct conf_val *val);
int extra_conf_parse_ip6(json_object *value, struct conf_val *val);
int extra_conf_parse_ip4_prefix(json_object *value, struct conf_val *val);
int extra_conf_parse_ip6_prefix(json_object *value, struct conf_val *val);
int extra_conf_parse_str(json_object *value, struct conf_val *val);
int extra_conf_parse_list(json_object *value, struct conf_val *val);
int extra_conf_parse_dict(json_object *value, struct conf_val *val);
int delete_current_info(struct conf_val *val);
int extra_conf_parse_delete_int(struct conf_val *val);
int extra_conf_parse_delete_float(struct conf_val *val);
int extra_conf_parse_delete_ip4(struct conf_val *val);
int extra_conf_parse_delete_ip6(struct conf_val *val);
int extra_conf_parse_delete_ip4_prefix(struct conf_val *val);
int extra_conf_parse_delete_ip6_prefix(struct conf_val *val);
int extra_conf_parse_delete_str(struct conf_val *val);
int extra_conf_parse_delete_list(struct conf_val *val);
int extra_conf_delete_dict(struct conf_val *val);
int extra_conf_copy_int(struct global_info *info, void *buf, size_t len);
int extra_conf_copy_float(struct global_info *info, void *buf, size_t len);
int extra_conf_copy_ip4(struct global_info *info, void *buf, size_t len);
int extra_conf_copy_ip6(struct global_info *info, void *buf, size_t len);
int extra_conf_copy_ip4_prefix(struct global_info *info, void *buf, size_t len);
int extra_conf_copy_ip6_prefix(struct global_info *info, void *buf, size_t len);
int extra_conf_copy_str(struct global_info *info, void *buf, size_t len);
static inline int error_cpy(struct global_info *val __attribute__((unused)),
void *buf __attribute__((unused)),
size_t len __attribute__((unused))) {
return -1;
}
#endif //UBPF_TOOLS_PLUGIN_EXTRA_CONFIGURATION_H