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
|
#ifndef _LIBNFTNL_UDATA_H_
#define _LIBNFTNL_UDATA_H_
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
enum nftnl_udata_rule_types {
NFTNL_UDATA_RULE_COMMENT,
NFTNL_UDATA_RULE_EBTABLES_POLICY,
__NFTNL_UDATA_RULE_MAX
};
#define NFTNL_UDATA_RULE_MAX (__NFTNL_UDATA_RULE_MAX - 1)
#define NFTNL_UDATA_COMMENT_MAXLEN 128
enum nftnl_udata_set_types {
NFTNL_UDATA_SET_KEYBYTEORDER,
NFTNL_UDATA_SET_DATABYTEORDER,
NFTNL_UDATA_SET_MERGE_ELEMENTS,
__NFTNL_UDATA_SET_MAX
};
#define NFTNL_UDATA_SET_MAX (__NFTNL_UDATA_SET_MAX - 1)
enum nftnl_udata_set_elem_types {
NFTNL_UDATA_SET_ELEM_COMMENT,
NFTNL_UDATA_SET_ELEM_FLAGS,
__NFTNL_UDATA_SET_ELEM_MAX
};
#define NFTNL_UDATA_SET_ELEM_MAX (__NFTNL_UDATA_SET_ELEM_MAX - 1)
/**
* enum nftnl_udata_set_elem_flags - meaning of bits in UDATA_SET_ELEM_FLAGS
*
* @SET_ELEM_F_INTERVAL_OPEN: set element denotes a half-open range
*/
enum nftnl_udata_set_elem_flags {
NFTNL_SET_ELEM_F_INTERVAL_OPEN = 0x1,
};
/*
* nftnl user data attributes API
*/
struct nftnl_udata;
struct nftnl_udata_buf;
/* nftnl_udata_buf */
struct nftnl_udata_buf *nftnl_udata_buf_alloc(uint32_t data_size);
void nftnl_udata_buf_free(const struct nftnl_udata_buf *buf);
uint32_t nftnl_udata_buf_len(const struct nftnl_udata_buf *buf);
void *nftnl_udata_buf_data(const struct nftnl_udata_buf *buf);
void nftnl_udata_buf_put(struct nftnl_udata_buf *buf, const void *data,
uint32_t len);
struct nftnl_udata *nftnl_udata_start(const struct nftnl_udata_buf *buf);
struct nftnl_udata *nftnl_udata_end(const struct nftnl_udata_buf *buf);
/* putters */
bool nftnl_udata_put(struct nftnl_udata_buf *buf, uint8_t type, uint32_t len,
const void *value);
bool nftnl_udata_put_u32(struct nftnl_udata_buf *buf, uint8_t type,
uint32_t data);
bool nftnl_udata_put_strz(struct nftnl_udata_buf *buf, uint8_t type,
const char *strz);
/* nftnl_udata_attr */
uint8_t nftnl_udata_type(const struct nftnl_udata *attr);
uint8_t nftnl_udata_len(const struct nftnl_udata *attr);
void *nftnl_udata_get(const struct nftnl_udata *attr);
uint32_t nftnl_udata_get_u32(const struct nftnl_udata *attr);
/* iterator */
struct nftnl_udata *nftnl_udata_next(const struct nftnl_udata *attr);
#define nftnl_udata_for_each(buf, attr) \
for ((attr) = nftnl_udata_start(buf); \
(char *)(nftnl_udata_end(buf)) > (char *)(attr); \
(attr) = nftnl_udata_next(attr))
#define nftnl_udata_for_each_data(data, data_len, attr) \
for ((attr) = (struct nftnl_udata *)(data); \
(char *)(data + data_len) > (char *)(attr); \
(attr) = nftnl_udata_next(attr))
typedef int (*nftnl_udata_cb_t)(const struct nftnl_udata *attr, void *data);
int nftnl_udata_parse(const void *data, uint32_t data_len, nftnl_udata_cb_t cb,
void *cb_data);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* _LIBNFTNL_UDATA_H_ */
|