summaryrefslogtreecommitdiffstats
path: root/include/parser.h
blob: 0bdb3fa8225c025f7e362683c2276ceb1138018e (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
#ifndef NFTABLES_PARSER_H
#define NFTABLES_PARSER_H

#include <list.h>
#include <rule.h> // FIXME

#define MAX_INCLUDE_DEPTH		16
#define TABSIZE				8

#define YYLTYPE				struct location
#define YYLTYPE_IS_TRIVIAL		0
#define YYENABLE_NLS			0

#define SCOPE_NEST_MAX			3

struct parser_state {
	struct input_descriptor		*indesc;
	struct input_descriptor		indescs[MAX_INCLUDE_DEPTH];
	unsigned int			indesc_idx;

	struct list_head		*msgs;
	unsigned int			nerrs;

	struct scope			top_scope;
	struct scope			*scopes[SCOPE_NEST_MAX];
	unsigned int			scope;

	struct list_head		cmds;
	struct eval_ctx			ectx;
};

struct mnl_socket;

extern void parser_init(struct mnl_socket *nf_sock, struct nft_cache *cache,
			struct parser_state *state, struct list_head *msgs,
			unsigned int debug_level, struct output_ctx *octx);
extern int nft_parse(struct nft_ctx *ctx, void *, struct parser_state *state);

extern void *scanner_init(struct parser_state *state);
extern void scanner_destroy(void *scanner);

extern int scanner_read_file(void *scanner, const char *filename,
			     const struct location *loc);
extern int scanner_include_file(struct nft_ctx *ctx, void *scanner,
				const char *filename,
				const struct location *loc);
extern void scanner_push_buffer(void *scanner,
				const struct input_descriptor *indesc,
				const char *buffer);

#endif /* NFTABLES_PARSER_H */