-
Notifications
You must be signed in to change notification settings - Fork 66
/
common-global.h
57 lines (49 loc) · 1.35 KB
/
common-global.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
#ifndef SRC_COMMON_GLOBAL_H_
#define SRC_COMMON_GLOBAL_H_
#ifdef __KERNEL__
#include <linux/types.h>
#else
#include <stddef.h>
#endif
#include "common/config.h"
typedef enum global_type_id {
GTI_BOOL,
GTI_NUM8,
GTI_NUM32,
GTI_TIMEOUT,
GTI_PLATEAUS,
GTI_PREFIX6,
GTI_PREFIX4,
GTI_HAIRPIN_MODE,
} global_type_id;
struct global_field;
typedef void (*print_function)(void *value, bool csv);
typedef int (*parse_function)(struct global_field *field, char *str,
void *result);
/* This function does not need to validate xlator_type nor type->size. */
typedef int (*validate_function)(struct global_field *field, void *value,
bool force);
struct global_type {
global_type_id id;
const char *name;
size_t size;
print_function print;
parse_function parse;
validate_function validate;
char *candidates; /* Same as in struct wargp_type. */
};
struct global_field {
char *name; /* This being NULL means the end of the array. */
struct global_type *type;
const char *doc;
size_t offset;
xlator_type xt;
__u64 min;
__u64 max;
print_function print; /* Overrides type->print. */
validate_function validate; /* Overrides type->validate. */
char *candidates; /* Overrides type->candidates. */
};
void get_global_fields(struct global_field **fields, unsigned int *len);
long int global_field_index(struct global_field *field);
#endif /* SRC_COMMON_GLOBAL_H_ */