ip_lookup.h revision 1.2.4.2 1 1.2.4.2 yamt /* $NetBSD: ip_lookup.h,v 1.2.4.2 2012/04/17 00:08:16 yamt Exp $ */
2 1.2.4.2 yamt
3 1.2.4.2 yamt /*
4 1.2.4.2 yamt * Copyright (C) 2010 by Darren Reed.
5 1.2.4.2 yamt *
6 1.2.4.2 yamt * See the IPFILTER.LICENCE file for details on licencing.
7 1.2.4.2 yamt *
8 1.2.4.2 yamt * Id: ip_lookup.h,v 2.23.2.3 2012/01/26 05:29:12 darrenr Exp
9 1.2.4.2 yamt */
10 1.2.4.2 yamt #ifndef __IP_LOOKUP_H__
11 1.2.4.2 yamt #define __IP_LOOKUP_H__
12 1.2.4.2 yamt
13 1.2.4.2 yamt #if defined(__STDC__) || defined(__GNUC__) || defined(_AIX51)
14 1.2.4.2 yamt # define SIOCLOOKUPADDTABLE _IOWR('r', 60, struct iplookupop)
15 1.2.4.2 yamt # define SIOCLOOKUPDELTABLE _IOWR('r', 61, struct iplookupop)
16 1.2.4.2 yamt # define SIOCLOOKUPSTAT _IOWR('r', 64, struct iplookupop)
17 1.2.4.2 yamt # define SIOCLOOKUPSTATW _IOW('r', 64, struct iplookupop)
18 1.2.4.2 yamt # define SIOCLOOKUPFLUSH _IOWR('r', 65, struct iplookupflush)
19 1.2.4.2 yamt # define SIOCLOOKUPADDNODE _IOWR('r', 67, struct iplookupop)
20 1.2.4.2 yamt # define SIOCLOOKUPADDNODEW _IOW('r', 67, struct iplookupop)
21 1.2.4.2 yamt # define SIOCLOOKUPDELNODE _IOWR('r', 68, struct iplookupop)
22 1.2.4.2 yamt # define SIOCLOOKUPDELNODEW _IOW('r', 68, struct iplookupop)
23 1.2.4.2 yamt #else
24 1.2.4.2 yamt # define SIOCLOOKUPADDTABLE _IOWR(r, 60, struct iplookupop)
25 1.2.4.2 yamt # define SIOCLOOKUPDELTABLE _IOWR(r, 61, struct iplookupop)
26 1.2.4.2 yamt # define SIOCLOOKUPSTAT _IOWR(r, 64, struct iplookupop)
27 1.2.4.2 yamt # define SIOCLOOKUPSTATW _IOW(r, 64, struct iplookupop)
28 1.2.4.2 yamt # define SIOCLOOKUPFLUSH _IOWR(r, 65, struct iplookupflush)
29 1.2.4.2 yamt # define SIOCLOOKUPADDNODE _IOWR(r, 67, struct iplookupop)
30 1.2.4.2 yamt # define SIOCLOOKUPADDNODEW _IOW(r, 67, struct iplookupop)
31 1.2.4.2 yamt # define SIOCLOOKUPDELNODE _IOWR(r, 68, struct iplookupop)
32 1.2.4.2 yamt # define SIOCLOOKUPDELNODEW _IOW(r, 68, struct iplookupop)
33 1.2.4.2 yamt #endif
34 1.2.4.2 yamt
35 1.2.4.2 yamt #define LOOKUP_POOL_MAX (IPL_LOGSIZE)
36 1.2.4.2 yamt #define LOOKUP_POOL_SZ (IPL_LOGSIZE + 1)
37 1.2.4.2 yamt
38 1.2.4.2 yamt typedef struct iplookupop {
39 1.2.4.2 yamt int iplo_type; /* IPLT_* */
40 1.2.4.2 yamt int iplo_unit; /* IPL_LOG* */
41 1.2.4.2 yamt u_int iplo_arg;
42 1.2.4.2 yamt char iplo_name[FR_GROUPLEN];
43 1.2.4.2 yamt size_t iplo_size; /* sizeof struct at iplo_struct */
44 1.2.4.2 yamt void *iplo_struct;
45 1.2.4.2 yamt } iplookupop_t;
46 1.2.4.2 yamt
47 1.2.4.2 yamt #define LOOKUP_ANON 0x80000000
48 1.2.4.2 yamt
49 1.2.4.2 yamt
50 1.2.4.2 yamt typedef struct iplookupflush {
51 1.2.4.2 yamt int iplf_type; /* IPLT_* */
52 1.2.4.2 yamt int iplf_unit; /* IPL_LOG* */
53 1.2.4.2 yamt u_int iplf_arg;
54 1.2.4.2 yamt u_int iplf_count;
55 1.2.4.2 yamt char iplf_name[FR_GROUPLEN];
56 1.2.4.2 yamt } iplookupflush_t;
57 1.2.4.2 yamt
58 1.2.4.2 yamt typedef struct iplookuplink {
59 1.2.4.2 yamt int ipll_type; /* IPLT_* */
60 1.2.4.2 yamt int ipll_unit; /* IPL_LOG* */
61 1.2.4.2 yamt u_int ipll_num;
62 1.2.4.2 yamt char ipll_group[FR_GROUPLEN];
63 1.2.4.2 yamt } iplookuplink_t;
64 1.2.4.2 yamt
65 1.2.4.2 yamt #define IPLT_ALL -1
66 1.2.4.2 yamt #define IPLT_NONE 0
67 1.2.4.2 yamt #define IPLT_POOL 1
68 1.2.4.2 yamt #define IPLT_HASH 2
69 1.2.4.2 yamt #define IPLT_DSTLIST 3
70 1.2.4.2 yamt
71 1.2.4.2 yamt
72 1.2.4.2 yamt #define IPLT_ANON 0x80000000
73 1.2.4.2 yamt
74 1.2.4.2 yamt
75 1.2.4.2 yamt typedef union {
76 1.2.4.2 yamt struct iplookupiterkey {
77 1.2.4.2 yamt u_char ilik_ival;
78 1.2.4.2 yamt u_char ilik_type; /* IPLT_* */
79 1.2.4.2 yamt u_char ilik_otype;
80 1.2.4.2 yamt signed char ilik_unit; /* IPL_LOG* */
81 1.2.4.2 yamt } ilik_unstr;
82 1.2.4.2 yamt u_32_t ilik_key;
83 1.2.4.2 yamt } iplookupiterkey_t;
84 1.2.4.2 yamt
85 1.2.4.2 yamt typedef struct ipflookupiter {
86 1.2.4.2 yamt int ili_nitems;
87 1.2.4.2 yamt iplookupiterkey_t ili_lkey;
88 1.2.4.2 yamt char ili_name[FR_GROUPLEN];
89 1.2.4.2 yamt void *ili_data;
90 1.2.4.2 yamt } ipflookupiter_t;
91 1.2.4.2 yamt
92 1.2.4.2 yamt #define ili_key ili_lkey.ilik_key
93 1.2.4.2 yamt #define ili_ival ili_lkey.ilik_unstr.ilik_ival
94 1.2.4.2 yamt #define ili_unit ili_lkey.ilik_unstr.ilik_unit
95 1.2.4.2 yamt #define ili_type ili_lkey.ilik_unstr.ilik_type
96 1.2.4.2 yamt #define ili_otype ili_lkey.ilik_unstr.ilik_otype
97 1.2.4.2 yamt
98 1.2.4.2 yamt #define IPFLOOKUPITER_LIST 0
99 1.2.4.2 yamt #define IPFLOOKUPITER_NODE 1
100 1.2.4.2 yamt
101 1.2.4.2 yamt
102 1.2.4.2 yamt typedef struct ipf_lookup {
103 1.2.4.2 yamt int ipfl_type;
104 1.2.4.2 yamt void *(*ipfl_create)(ipf_main_softc_t *);
105 1.2.4.2 yamt void (*ipfl_destroy)(ipf_main_softc_t *, void *);
106 1.2.4.2 yamt int (*ipfl_init)(ipf_main_softc_t *, void *);
107 1.2.4.2 yamt void (*ipfl_fini)(ipf_main_softc_t *, void *);
108 1.2.4.2 yamt int (*ipfl_addr_find)(ipf_main_softc_t *, void *,
109 1.2.4.2 yamt int, void *, u_int);
110 1.2.4.2 yamt size_t (*ipfl_flush)(ipf_main_softc_t *, void *,
111 1.2.4.2 yamt iplookupflush_t *);
112 1.2.4.2 yamt int (*ipfl_iter_deref)(ipf_main_softc_t *, void *,
113 1.2.4.2 yamt int, int, void *);
114 1.2.4.2 yamt int (*ipfl_iter_next)(ipf_main_softc_t *, void *,
115 1.2.4.2 yamt ipftoken_t *, ipflookupiter_t *);
116 1.2.4.2 yamt int (*ipfl_node_add)(ipf_main_softc_t *, void *,
117 1.2.4.2 yamt iplookupop_t *, int);
118 1.2.4.2 yamt int (*ipfl_node_del)(ipf_main_softc_t *, void *,
119 1.2.4.2 yamt iplookupop_t *, int);
120 1.2.4.2 yamt int (*ipfl_stats_get)(ipf_main_softc_t *, void *,
121 1.2.4.2 yamt iplookupop_t *);
122 1.2.4.2 yamt int (*ipfl_table_add)(ipf_main_softc_t *, void *,
123 1.2.4.2 yamt iplookupop_t *);
124 1.2.4.2 yamt int (*ipfl_table_del)(ipf_main_softc_t *, void *,
125 1.2.4.2 yamt iplookupop_t *);
126 1.2.4.2 yamt int (*ipfl_table_deref)(ipf_main_softc_t *, void *, void *);
127 1.2.4.2 yamt void *(*ipfl_table_find)(void *, int, char *);
128 1.2.4.2 yamt void *(*ipfl_select_add_ref)(void *, int, char *);
129 1.2.4.2 yamt int (*ipfl_select_node)(fr_info_t *, void *, u_32_t *,
130 1.2.4.2 yamt frdest_t *);
131 1.2.4.2 yamt void (*ipfl_expire)(ipf_main_softc_t *, void *);
132 1.2.4.2 yamt void (*ipfl_sync)(ipf_main_softc_t *, void *);
133 1.2.4.2 yamt } ipf_lookup_t;
134 1.2.4.2 yamt
135 1.2.4.2 yamt extern int ipf_lookup_init(void);
136 1.2.4.2 yamt extern int ipf_lookup_ioctl(ipf_main_softc_t *, void *, ioctlcmd_t, int, int, void *);
137 1.2.4.2 yamt extern void ipf_lookup_main_unload(void);
138 1.2.4.2 yamt extern void ipf_lookup_deref(ipf_main_softc_t *, int, void *);
139 1.2.4.2 yamt extern void ipf_lookup_iterderef(ipf_main_softc_t *, u_32_t, void *);
140 1.2.4.2 yamt extern void *ipf_lookup_res_name(ipf_main_softc_t *, int, u_int, char *,
141 1.2.4.2 yamt lookupfunc_t *);
142 1.2.4.2 yamt extern void *ipf_lookup_res_num(ipf_main_softc_t *, int, u_int, u_int,
143 1.2.4.2 yamt lookupfunc_t *);
144 1.2.4.2 yamt extern void ipf_lookup_soft_destroy(ipf_main_softc_t *, void *);
145 1.2.4.2 yamt extern void *ipf_lookup_soft_create(ipf_main_softc_t *);
146 1.2.4.2 yamt extern int ipf_lookup_soft_init(ipf_main_softc_t *, void *);
147 1.2.4.2 yamt extern int ipf_lookup_soft_fini(ipf_main_softc_t *, void *);
148 1.2.4.2 yamt extern void *ipf_lookup_find_htable(ipf_main_softc_t *, int, char *);
149 1.2.4.2 yamt extern void ipf_lookup_expire(ipf_main_softc_t *);
150 1.2.4.2 yamt extern void ipf_lookup_sync(ipf_main_softc_t *, void *);
151 1.2.4.2 yamt #ifndef _KERNEL
152 1.2.4.2 yamt extern void ipf_lookup_dump(ipf_main_softc_t *, void *);
153 1.2.4.2 yamt #endif
154 1.2.4.2 yamt #endif /* __IP_LOOKUP_H__ */
155