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