2 * Copyright (C) 2012 by Darren Reed.
4 * See the IPFILTER.LICENCE file for details on licencing.
8 #ifndef __IP_LOOKUP_H__
9 #define __IP_LOOKUP_H__
11 #if defined(__STDC__) || defined(__GNUC__) || defined(_AIX51)
12 # define SIOCLOOKUPADDTABLE _IOWR('r', 60, struct iplookupop)
13 # define SIOCLOOKUPDELTABLE _IOWR('r', 61, struct iplookupop)
14 # define SIOCLOOKUPSTAT _IOWR('r', 64, struct iplookupop)
15 # define SIOCLOOKUPSTATW _IOW('r', 64, struct iplookupop)
16 # define SIOCLOOKUPFLUSH _IOWR('r', 65, struct iplookupflush)
17 # define SIOCLOOKUPADDNODE _IOWR('r', 67, struct iplookupop)
18 # define SIOCLOOKUPADDNODEW _IOW('r', 67, struct iplookupop)
19 # define SIOCLOOKUPDELNODE _IOWR('r', 68, struct iplookupop)
20 # define SIOCLOOKUPDELNODEW _IOW('r', 68, struct iplookupop)
22 # define SIOCLOOKUPADDTABLE _IOWR(r, 60, struct iplookupop)
23 # define SIOCLOOKUPDELTABLE _IOWR(r, 61, struct iplookupop)
24 # define SIOCLOOKUPSTAT _IOWR(r, 64, struct iplookupop)
25 # define SIOCLOOKUPSTATW _IOW(r, 64, struct iplookupop)
26 # define SIOCLOOKUPFLUSH _IOWR(r, 65, struct iplookupflush)
27 # define SIOCLOOKUPADDNODE _IOWR(r, 67, struct iplookupop)
28 # define SIOCLOOKUPADDNODEW _IOW(r, 67, struct iplookupop)
29 # define SIOCLOOKUPDELNODE _IOWR(r, 68, struct iplookupop)
30 # define SIOCLOOKUPDELNODEW _IOW(r, 68, struct iplookupop)
33 #define LOOKUP_POOL_MAX (IPL_LOGSIZE)
34 #define LOOKUP_POOL_SZ (IPL_LOGSIZE + 1)
36 typedef struct iplookupop {
37 int iplo_type; /* IPLT_* */
38 int iplo_unit; /* IPL_LOG* */
40 char iplo_name[FR_GROUPLEN];
41 size_t iplo_size; /* sizeof struct at iplo_struct */
45 #define LOOKUP_ANON 0x80000000
48 typedef struct iplookupflush {
49 int iplf_type; /* IPLT_* */
50 int iplf_unit; /* IPL_LOG* */
53 char iplf_name[FR_GROUPLEN];
56 typedef struct iplookuplink {
57 int ipll_type; /* IPLT_* */
58 int ipll_unit; /* IPL_LOG* */
60 char ipll_group[FR_GROUPLEN];
67 #define IPLT_DSTLIST 3
70 #define IPLT_ANON 0x80000000
74 struct iplookupiterkey {
76 u_char ilik_type; /* IPLT_* */
78 signed char ilik_unit; /* IPL_LOG* */
83 typedef struct ipflookupiter {
85 iplookupiterkey_t ili_lkey;
86 char ili_name[FR_GROUPLEN];
90 #define ili_key ili_lkey.ilik_key
91 #define ili_ival ili_lkey.ilik_unstr.ilik_ival
92 #define ili_unit ili_lkey.ilik_unstr.ilik_unit
93 #define ili_type ili_lkey.ilik_unstr.ilik_type
94 #define ili_otype ili_lkey.ilik_unstr.ilik_otype
96 #define IPFLOOKUPITER_LIST 0
97 #define IPFLOOKUPITER_NODE 1
100 typedef struct ipf_lookup {
102 void *(*ipfl_create) __P((ipf_main_softc_t *));
103 void (*ipfl_destroy) __P((ipf_main_softc_t *, void *));
104 int (*ipfl_init) __P((ipf_main_softc_t *, void *));
105 void (*ipfl_fini) __P((ipf_main_softc_t *, void *));
106 int (*ipfl_addr_find) __P((ipf_main_softc_t *, void *,
107 int, void *, u_int));
108 size_t (*ipfl_flush) __P((ipf_main_softc_t *, void *,
110 int (*ipfl_iter_deref) __P((ipf_main_softc_t *, void *,
112 int (*ipfl_iter_next) __P((ipf_main_softc_t *, void *,
113 ipftoken_t *, ipflookupiter_t *));
114 int (*ipfl_node_add) __P((ipf_main_softc_t *, void *,
115 iplookupop_t *, int));
116 int (*ipfl_node_del) __P((ipf_main_softc_t *, void *,
117 iplookupop_t *, int));
118 int (*ipfl_stats_get) __P((ipf_main_softc_t *, void *,
120 int (*ipfl_table_add) __P((ipf_main_softc_t *, void *,
122 int (*ipfl_table_del) __P((ipf_main_softc_t *, void *,
124 int (*ipfl_table_deref) __P((ipf_main_softc_t *, void *, void *));
125 void *(*ipfl_table_find) __P((void *, int, char *));
126 void *(*ipfl_select_add_ref) __P((void *, int, char *));
127 int (*ipfl_select_node) __P((fr_info_t *, void *, u_32_t *,
129 void (*ipfl_expire) __P((ipf_main_softc_t *, void *));
130 void (*ipfl_sync) __P((ipf_main_softc_t *, void *));
133 extern int ipf_lookup_init __P((void));
134 extern int ipf_lookup_ioctl __P((ipf_main_softc_t *, caddr_t, ioctlcmd_t, int, int, void *));
135 extern void ipf_lookup_main_unload __P((void));
136 extern void ipf_lookup_deref __P((ipf_main_softc_t *, int, void *));
137 extern void ipf_lookup_iterderef __P((ipf_main_softc_t *, u_32_t, void *));
138 extern void *ipf_lookup_res_name __P((ipf_main_softc_t *, int, u_int, char *,
140 extern void *ipf_lookup_res_num __P((ipf_main_softc_t *, int, u_int, u_int,
142 extern void ipf_lookup_soft_destroy __P((ipf_main_softc_t *, void *));
143 extern void *ipf_lookup_soft_create __P((ipf_main_softc_t *));
144 extern int ipf_lookup_soft_init __P((ipf_main_softc_t *, void *));
145 extern int ipf_lookup_soft_fini __P((ipf_main_softc_t *, void *));
146 extern void *ipf_lookup_find_htable __P((ipf_main_softc_t *, int, char *));
147 extern void ipf_lookup_expire __P((ipf_main_softc_t *));
148 extern void ipf_lookup_sync __P((ipf_main_softc_t *, void *));
150 extern void ipf_lookup_dump __P((ipf_main_softc_t *, void *));
152 #endif /* __IP_LOOKUP_H__ */