summaryrefslogtreecommitdiffstats
path: root/include/libipset/parse.h
blob: d18e3cc9c5a4f02b17b0a9da43a863cee8ebc0f8 (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
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
/* Copyright 2007-2010 Jozsef Kadlecsik (kadlec@blackhole.kfki.hu)
 *
 * 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.
 */
#ifndef LIBIPSET_PARSE_H
#define LIBIPSET_PARSE_H

#include <libipset/data.h>			/* enum ipset_opt */

/* For parsing/printing data */
#define IPSET_CIDR_SEPARATOR	"/"
#define IPSET_RANGE_SEPARATOR	"-"
#define IPSET_ELEM_SEPARATOR	","
#define IPSET_NAME_SEPARATOR	","
#define IPSET_PROTO_SEPARATOR	":"
#define IPSET_ESCAPE_START	"["
#define IPSET_ESCAPE_END	"]"

struct ipset_session;
struct ipset_arg;

typedef int (*ipset_parsefn)(struct ipset_session *s,
			     enum ipset_opt opt, const char *str);

extern int ipset_parse_ether(struct ipset_session *session,
			     enum ipset_opt opt, const char *str);
extern int ipset_parse_port(struct ipset_session *session,
			    enum ipset_opt opt, const char *str,
			    const char *proto);
extern int ipset_parse_tcpudp_port(struct ipset_session *session,
				   enum ipset_opt opt, const char *str,
				   const char *proto);
extern int ipset_parse_tcp_port(struct ipset_session *session,
				enum ipset_opt opt, const char *str);
extern int ipset_parse_single_tcp_port(struct ipset_session *session,
				       enum ipset_opt opt, const char *str);
extern int ipset_parse_proto(struct ipset_session *session,
			     enum ipset_opt opt, const char *str);
extern int ipset_parse_icmp(struct ipset_session *session,
			    enum ipset_opt opt, const char *str);
extern int ipset_parse_icmpv6(struct ipset_session *session,
			      enum ipset_opt opt, const char *str);
extern int ipset_parse_proto_port(struct ipset_session *session,
				  enum ipset_opt opt, const char *str);
extern int ipset_parse_family(struct ipset_session *session,
			      enum ipset_opt opt, const char *str);
extern int ipset_parse_ip(struct ipset_session *session,
			  enum ipset_opt opt, const char *str);
extern int ipset_parse_single_ip(struct ipset_session *session,
				 enum ipset_opt opt, const char *str);
extern int ipset_parse_net(struct ipset_session *session,
			   enum ipset_opt opt, const char *str);
extern int ipset_parse_range(struct ipset_session *session,
			     enum ipset_opt opt, const char *str);
extern int ipset_parse_netrange(struct ipset_session *session,
				enum ipset_opt opt, const char *str);
extern int ipset_parse_iprange(struct ipset_session *session,
			       enum ipset_opt opt, const char *str);
extern int ipset_parse_ipnet(struct ipset_session *session,
			     enum ipset_opt opt, const char *str);
extern int ipset_parse_ip4_single6(struct ipset_session *session,
				enum ipset_opt opt, const char *str);
extern int ipset_parse_ip4_net6(struct ipset_session *session,
				enum ipset_opt opt, const char *str);
extern int ipset_parse_name(struct ipset_session *session,
			    enum ipset_opt opt, const char *str);
extern int ipset_parse_before(struct ipset_session *session,
			      enum ipset_opt opt, const char *str);
extern int ipset_parse_after(struct ipset_session *session,
			     enum ipset_opt opt, const char *str);
extern int ipset_parse_setname(struct ipset_session *session,
			       enum ipset_opt opt, const char *str);
extern int ipset_parse_uint32(struct ipset_session *session,
			      enum ipset_opt opt, const char *str);
extern int ipset_parse_uint8(struct ipset_session *session,
			     enum ipset_opt opt, const char *str);
extern int ipset_parse_netmask(struct ipset_session *session,
			       enum ipset_opt opt, const char *str);
extern int ipset_parse_flag(struct ipset_session *session,
			    enum ipset_opt opt, const char *str);
extern int ipset_parse_typename(struct ipset_session *session,
				enum ipset_opt opt, const char *str);
extern int ipset_parse_iface(struct ipset_session *session,
			     enum ipset_opt opt, const char *str);
extern int ipset_parse_output(struct ipset_session *session,
			      int opt, const char *str);
extern int ipset_parse_ignored(struct ipset_session *session,
			       enum ipset_opt opt, const char *str);
extern int ipset_parse_elem(struct ipset_session *session,
			    enum ipset_opt opt, const char *str);
extern int ipset_call_parser(struct ipset_session *session,
			     const struct ipset_arg *arg,
			     const char *str);

/* Compatibility parser functions */
extern int ipset_parse_iptimeout(struct ipset_session *session,
				 enum ipset_opt opt, const char *str);
extern int ipset_parse_name_compat(struct ipset_session *session,
				   enum ipset_opt opt, const char *str);

#endif /* LIBIPSET_PARSE_H */