summaryrefslogtreecommitdiffstats
path: root/sys/contrib/ipfilter/netinet/ip_lookup.h
blob: 181e1bc5d176eae3edf5073c8ea8e9c8ea2e16f1 (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
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
/*
 * Copyright (C) 2012 by Darren Reed.
 *
 * See the IPFILTER.LICENCE file for details on licencing.
 *
 * $Id$
 */
#ifndef __IP_LOOKUP_H__
#define __IP_LOOKUP_H__

#if defined(__STDC__) || defined(__GNUC__) || defined(_AIX51)
# define	SIOCLOOKUPADDTABLE	_IOWR('r', 60, struct iplookupop)
# define	SIOCLOOKUPDELTABLE	_IOWR('r', 61, struct iplookupop)
# define	SIOCLOOKUPSTAT		_IOWR('r', 64, struct iplookupop)
# define	SIOCLOOKUPSTATW		_IOW('r', 64, struct iplookupop)
# define	SIOCLOOKUPFLUSH		_IOWR('r', 65, struct iplookupflush)
# define	SIOCLOOKUPADDNODE	_IOWR('r', 67, struct iplookupop)
# define	SIOCLOOKUPADDNODEW	_IOW('r', 67, struct iplookupop)
# define	SIOCLOOKUPDELNODE	_IOWR('r', 68, struct iplookupop)
# define	SIOCLOOKUPDELNODEW	_IOW('r', 68, struct iplookupop)
#else
# define	SIOCLOOKUPADDTABLE	_IOWR(r, 60, struct iplookupop)
# define	SIOCLOOKUPDELTABLE	_IOWR(r, 61, struct iplookupop)
# define	SIOCLOOKUPSTAT		_IOWR(r, 64, struct iplookupop)
# define	SIOCLOOKUPSTATW		_IOW(r, 64, struct iplookupop)
# define	SIOCLOOKUPFLUSH		_IOWR(r, 65, struct iplookupflush)
# define	SIOCLOOKUPADDNODE	_IOWR(r, 67, struct iplookupop)
# define	SIOCLOOKUPADDNODEW	_IOW(r, 67, struct iplookupop)
# define	SIOCLOOKUPDELNODE	_IOWR(r, 68, struct iplookupop)
# define	SIOCLOOKUPDELNODEW	_IOW(r, 68, struct iplookupop)
#endif

#define	LOOKUP_POOL_MAX	(IPL_LOGSIZE)
#define	LOOKUP_POOL_SZ	(IPL_LOGSIZE + 1)

typedef	struct	iplookupop	{
	int	iplo_type;	/* IPLT_* */
	int	iplo_unit;	/* IPL_LOG* */
	u_int	iplo_arg;
	char	iplo_name[FR_GROUPLEN];
	size_t	iplo_size;	/* sizeof struct at iplo_struct */
	void	*iplo_struct;
} iplookupop_t;

#define	LOOKUP_ANON	0x80000000


typedef	struct	iplookupflush	{
	int	iplf_type;	/* IPLT_* */
	int	iplf_unit;	/* IPL_LOG* */
	u_int	iplf_arg;
	u_int	iplf_count;
	char	iplf_name[FR_GROUPLEN];
} iplookupflush_t;

typedef	struct	iplookuplink	{
	int	ipll_type;	/* IPLT_* */
	int	ipll_unit;	/* IPL_LOG* */
	u_int	ipll_num;
	char	ipll_group[FR_GROUPLEN];
} iplookuplink_t;

#define	IPLT_ALL	-1
#define	IPLT_NONE	0
#define	IPLT_POOL	1
#define	IPLT_HASH	2
#define	IPLT_DSTLIST	3


#define	IPLT_ANON	0x80000000


typedef	union	{
	struct	iplookupiterkey {
		u_char	ilik_ival;
		u_char	ilik_type;	/* IPLT_* */
		u_char	ilik_otype;
		signed char	ilik_unit;	/* IPL_LOG* */
	} ilik_unstr;
	u_32_t	ilik_key;
} iplookupiterkey_t;

typedef	struct	ipflookupiter	{
	int			ili_nitems;
	iplookupiterkey_t	ili_lkey;
	char			ili_name[FR_GROUPLEN];
	void			*ili_data;
} ipflookupiter_t;

#define	ili_key		ili_lkey.ilik_key
#define	ili_ival	ili_lkey.ilik_unstr.ilik_ival
#define	ili_unit	ili_lkey.ilik_unstr.ilik_unit
#define	ili_type	ili_lkey.ilik_unstr.ilik_type
#define	ili_otype	ili_lkey.ilik_unstr.ilik_otype

#define	IPFLOOKUPITER_LIST	0
#define	IPFLOOKUPITER_NODE	1


typedef struct ipf_lookup {
	int	ipfl_type;
	void	*(*ipfl_create) __P((ipf_main_softc_t *));
	void	(*ipfl_destroy) __P((ipf_main_softc_t *, void *));
	int	(*ipfl_init) __P((ipf_main_softc_t *, void *));
	void	(*ipfl_fini) __P((ipf_main_softc_t *, void *));
	int	(*ipfl_addr_find) __P((ipf_main_softc_t *, void *,
				       int, void *, u_int));
	size_t	(*ipfl_flush) __P((ipf_main_softc_t *, void *,
				   iplookupflush_t *));
	int	(*ipfl_iter_deref) __P((ipf_main_softc_t *, void *,
					int, int, void *));
	int	(*ipfl_iter_next) __P((ipf_main_softc_t *, void *,
				       ipftoken_t *, ipflookupiter_t *));
	int	(*ipfl_node_add) __P((ipf_main_softc_t *, void *,
				      iplookupop_t *, int));
	int	(*ipfl_node_del) __P((ipf_main_softc_t *, void *,
				      iplookupop_t *, int));
	int	(*ipfl_stats_get) __P((ipf_main_softc_t *, void *,
				       iplookupop_t *));
	int	(*ipfl_table_add) __P((ipf_main_softc_t *, void *,
				       iplookupop_t *));
	int	(*ipfl_table_del) __P((ipf_main_softc_t *, void *,
				       iplookupop_t *));
	int	(*ipfl_table_deref) __P((ipf_main_softc_t *, void *, void *));
	void	*(*ipfl_table_find) __P((void *, int, char *));
	void	*(*ipfl_select_add_ref) __P((void *, int, char *));
	int	(*ipfl_select_node) __P((fr_info_t *, void *, u_32_t *,
					 frdest_t *));
	void	(*ipfl_expire) __P((ipf_main_softc_t *, void *));
	void	(*ipfl_sync) __P((ipf_main_softc_t *, void *));
} ipf_lookup_t;

extern int ipf_lookup_init __P((void));
extern int ipf_lookup_ioctl __P((ipf_main_softc_t *, caddr_t, ioctlcmd_t, int, int, void *));
extern void ipf_lookup_main_unload __P((void));
extern void ipf_lookup_deref __P((ipf_main_softc_t *, int, void *));
extern void ipf_lookup_iterderef __P((ipf_main_softc_t *, u_32_t, void *));
extern void *ipf_lookup_res_name __P((ipf_main_softc_t *, int, u_int, char *,
				      lookupfunc_t *));
extern void *ipf_lookup_res_num __P((ipf_main_softc_t *, int, u_int, u_int,
				     lookupfunc_t *));
extern void ipf_lookup_soft_destroy __P((ipf_main_softc_t *, void *));
extern void *ipf_lookup_soft_create __P((ipf_main_softc_t *));
extern int ipf_lookup_soft_init __P((ipf_main_softc_t *, void *));
extern int ipf_lookup_soft_fini __P((ipf_main_softc_t *, void *));
extern void *ipf_lookup_find_htable __P((ipf_main_softc_t *, int, char *));
extern void ipf_lookup_expire __P((ipf_main_softc_t *));
extern void ipf_lookup_sync __P((ipf_main_softc_t *, void *));
#ifndef _KERNEL
extern	void	ipf_lookup_dump __P((ipf_main_softc_t *, void *));
#endif
#endif /* __IP_LOOKUP_H__ */
OpenPOWER on IntegriCloud