1*1d8d50afSkhorben /* $NetBSD: interror.c,v 1.4 2015/04/02 00:12:58 khorben Exp $ */
2bc4097aaSchristos
3bc4097aaSchristos /*
4c9d5dc6cSdarrenr * Copyright (C) 2012 by Darren Reed.
5bc4097aaSchristos *
6bc4097aaSchristos * See the IPFILTER.LICENCE file for details on licencing.
7bc4097aaSchristos *
813885a66Sdarrenr * Id: interror.c,v 1.1.1.2 2012/07/22 13:44:39 darrenr Exp $
9bc4097aaSchristos */
10bc4097aaSchristos
11bc4097aaSchristos #include "ipf.h"
12bc4097aaSchristos #include <fcntl.h>
13bc4097aaSchristos #include <sys/ioctl.h>
14bc4097aaSchristos
15bc4097aaSchristos typedef struct {
16bc4097aaSchristos int iee_number;
17bc4097aaSchristos char *iee_text;
18bc4097aaSchristos } ipf_error_entry_t;
19bc4097aaSchristos
20bc4097aaSchristos static ipf_error_entry_t *find_error __P((int));
21bc4097aaSchristos
22*1d8d50afSkhorben #define IPF_NUM_ERRORS 476
23bc4097aaSchristos
24bc4097aaSchristos /*
25bc4097aaSchristos * NO REUSE OF NUMBERS!
26bc4097aaSchristos *
27bc4097aaSchristos * IF YOU WANT TO ADD AN ERROR TO THIS TABLE, _ADD_ A NEW NUMBER.
28bc4097aaSchristos * DO _NOT_ USE AN EMPTY NUMBER OR FILL IN A GAP.
29bc4097aaSchristos */
30bc4097aaSchristos static ipf_error_entry_t ipf_errors[IPF_NUM_ERRORS] = {
31bc4097aaSchristos { 1, "auth table locked/full" },
32bc4097aaSchristos { 2, "" },
33bc4097aaSchristos { 3, "copyinptr received bad address" },
34bc4097aaSchristos { 4, "copyoutptr received bad address" },
35bc4097aaSchristos { 5, "" },
36bc4097aaSchristos { 6, "cannot load a rule with FR_T_BUILTIN flag set" },
37bc4097aaSchristos { 7, "internal rule without FR_T_BUILDINT flag set" },
38bc4097aaSchristos { 8, "no data provided with filter rule" },
39bc4097aaSchristos { 9, "invalid ioctl for rule" },
40bc4097aaSchristos { 10, "rule protocol is not 4 or 6" },
41bc4097aaSchristos { 11, "cannot find rule function" },
42bc4097aaSchristos { 12, "cannot find rule group" },
43bc4097aaSchristos { 13, "group in/out does not match rule in/out" },
44bc4097aaSchristos { 14, "rule without in/out does not belong to a group" },
45bc4097aaSchristos { 15, "cannot determine where to append rule" },
46bc4097aaSchristos { 16, "malloc for rule data failed" },
47bc4097aaSchristos { 17, "copyin for rule data failed" },
48bc4097aaSchristos { 18, "" },
49bc4097aaSchristos { 19, "zero data size for BPF rule" },
50bc4097aaSchristos { 20, "BPF validation failed" },
51bc4097aaSchristos { 21, "incorrect data size for IPF rule" },
52bc4097aaSchristos { 22, "'keep state' rule included 'with oow'" },
53bc4097aaSchristos { 23, "bad interface index with dynamic source address" },
54bc4097aaSchristos { 24, "bad interface index with dynamic dest. address" },
55bc4097aaSchristos { 25, "match array verif failed for filter rule" },
56bc4097aaSchristos { 26, "bad filter rule type" },
57bc4097aaSchristos { 27, "rule not found for zero'stats" },
58bc4097aaSchristos { 28, "copyout failed for zero'ing stats" },
59bc4097aaSchristos { 29, "rule not found for removing" },
60bc4097aaSchristos { 30, "cannot remove internal rule" },
61bc4097aaSchristos { 31, "rule in use" },
62bc4097aaSchristos { 32, "rule already exists" },
63bc4097aaSchristos { 33, "no memory for another rule" },
64bc4097aaSchristos { 34, "could not find function" },
65bc4097aaSchristos { 35, "copyout failed for resolving function name -> addr" },
66bc4097aaSchristos { 36, "copyout failed for resolving function addr -> name" },
67bc4097aaSchristos { 37, "function name/addr resolving search failed" },
68bc4097aaSchristos { 38, "group map cannot find it's hash table" },
69bc4097aaSchristos { 39, "group map hash-table in/out do not match rule" },
70bc4097aaSchristos { 40, "bcopyout failed for SIOCIPFINTERROR" },
71bc4097aaSchristos { 41, "" },
72bc4097aaSchristos { 42, "ipfilter not enabled for NAT ioctl" },
73bc4097aaSchristos { 43, "ipfilter not enabled for state ioctl" },
74bc4097aaSchristos { 44, "ipfilter not enabled for auth ioctl" },
75bc4097aaSchristos { 45, "ipfilter not enbaled for sync ioctl" },
76bc4097aaSchristos { 46, "ipfilter not enabled for scan ioctl" },
77bc4097aaSchristos { 47, "ipfilter not enabled for lookup ioctl" },
78bc4097aaSchristos { 48, "unrecognised device minor number for ioctl" },
79bc4097aaSchristos { 49, "unrecognised object type for copying in ipfobj" },
80bc4097aaSchristos { 50, "mismatching object type for copying in ipfobj" },
81bc4097aaSchristos { 51, "object size too small for copying in ipfobj" },
82bc4097aaSchristos { 52, "object size mismatch for copying in ipfobj" },
83bc4097aaSchristos { 53, "compat object size too small for copying in ipfobj" },
84bc4097aaSchristos { 54, "compat object size mismatch for copying in ipfobj" },
85bc4097aaSchristos { 55, "error doing copyin of data for in ipfobj" },
86bc4097aaSchristos { 56, "unrecognised object type for size copy in ipfobj" },
87bc4097aaSchristos { 57, "object size too small for size copy in ipfobj" },
88bc4097aaSchristos { 58, "mismatching object type for size copy in ipfobj" },
89bc4097aaSchristos { 59, "object size mismatch for size copy in ipfobj" },
90bc4097aaSchristos { 60, "compat object size mismatch for size copy in ipfobj" },
91bc4097aaSchristos { 61, "error doing size copyin of data for in ipfobj" },
92bc4097aaSchristos { 62, "bad object type for size copy out ipfobj" },
93bc4097aaSchristos { 63, "mismatching object type for size copy out ipfobj" },
94bc4097aaSchristos { 64, "object size mismatch for size copy out ipfobj" },
95bc4097aaSchristos { 65, "compat object size wrong for size copy out ipfobj" },
96bc4097aaSchristos { 66, "error doing size copyout of data for out ipfobj" },
97bc4097aaSchristos { 67, "unrecognised object type for copying out ipfobj" },
98bc4097aaSchristos { 68, "mismatching object type for copying out ipfobj" },
99bc4097aaSchristos { 69, "object size too small for copying out ipfobj" },
100bc4097aaSchristos { 70, "object size mismatch for copying out ipfobj" },
101bc4097aaSchristos { 71, "compat object size too small for copying out ipfobj" },
102bc4097aaSchristos { 72, "compat object size mismatch for copying out ipfobj" },
103bc4097aaSchristos { 73, "error doing copyout of data for out ipfobj" },
104bc4097aaSchristos { 74, "attempt to add existing tunable name" },
105bc4097aaSchristos { 75, "cannot find tunable name to delete" },
106bc4097aaSchristos { 76, "internal data too big for next tunable" },
107bc4097aaSchristos { 77, "could not find tunable" },
108bc4097aaSchristos { 78, "tunable can only be changed when ipfilter disabled" },
109bc4097aaSchristos { 79, "new tunable value outside accepted range" },
110bc4097aaSchristos { 80, "ipftune called for unrecognised ioctl" },
111bc4097aaSchristos { 81, "" },
112bc4097aaSchristos { 82, "could not find token to delete" },
113bc4097aaSchristos { 83, "" },
114bc4097aaSchristos { 84, "attempt to get next rule when no more exist" },
115bc4097aaSchristos { 85, "value for iri_inout outside accepted range" },
116bc4097aaSchristos { 86, "value for iri_active outside accepted range" },
117bc4097aaSchristos { 87, "value for iri_nrules is 0" },
118bc4097aaSchristos { 88, "NULL pointer specified for where to copy rule to" },
119bc4097aaSchristos { 89, "copyout of rule failed" },
120c9d5dc6cSdarrenr { 90, "" },
121bc4097aaSchristos { 91, "could not get token for rule iteration" },
122bc4097aaSchristos { 92, "unrecognised generic iterator" },
123bc4097aaSchristos { 93, "could not find token for generic iterator" },
124bc4097aaSchristos { 94, "need write permissions to disable/enable ipfilter" },
125bc4097aaSchristos { 95, "error copying in enable/disable value" },
126bc4097aaSchristos { 96, "need write permissions to set ipf tunable" },
127bc4097aaSchristos { 97, "need write permissions to set ipf flags" },
128bc4097aaSchristos { 98, "error doing copyin of ipf flags" },
129bc4097aaSchristos { 99, "error doing copyout of ipf flags" },
130bc4097aaSchristos { 100, "need write permissions to add another rule" },
131bc4097aaSchristos { 101, "need write permissions to insert another rule" },
132bc4097aaSchristos { 102, "need write permissions to swap active rule set" },
133bc4097aaSchristos { 103, "error copying out current active rule set" },
134bc4097aaSchristos { 104, "need write permissions to zero ipf stats" },
135bc4097aaSchristos { 105, "need write permissions to flush ipf v4 rules" },
136bc4097aaSchristos { 106, "error copying out v4 flush results" },
137bc4097aaSchristos { 107, "error copying in v4 flush command" },
138bc4097aaSchristos { 108, "need write permissions to flush ipf v6 rules" },
139bc4097aaSchristos { 109, "error copying out v6 flush results" },
140bc4097aaSchristos { 110, "error copying in v6 flush command" },
141bc4097aaSchristos { 111, "error copying in new lock state for ipfilter" },
142bc4097aaSchristos { 112, "need write permissions to flush ipf logs" },
143bc4097aaSchristos { 113, "error copying out results of log flush" },
144bc4097aaSchristos { 114, "need write permissions to resync ipf" },
145bc4097aaSchristos { 115, "unrecognised ipf ioctl" },
146bc4097aaSchristos { 116, "error copying in match array" },
147bc4097aaSchristos { 117, "match array type is not IPFOBJ_IPFEXPR" },
148bc4097aaSchristos { 118, "bad size for match array" },
149bc4097aaSchristos { 119, "cannot allocate memory for match aray" },
150bc4097aaSchristos { 120, "error copying in match array" },
151bc4097aaSchristos { 121, "error verifying contents of match array" },
152bc4097aaSchristos { 122, "need write permissions to set ipf lock status" },
153bc4097aaSchristos { 123, "error copying in data for function resolution" },
154bc4097aaSchristos { 124, "error copying in ipfobj structure" },
155bc4097aaSchristos { 125, "error copying in ipfobj structure" },
156bc4097aaSchristos { 126, "error copying in ipfobj structure" },
157bc4097aaSchristos { 127, "error copying in ipfobj structure" },
158bc4097aaSchristos { 128, "no memory for filter rule comment" },
159bc4097aaSchristos { 129, "error copying in filter rule comment" },
160bc4097aaSchristos { 130, "error copying out filter rule comment" },
161bc4097aaSchristos { 131, "no memory for new rule alloc buffer" },
162bc4097aaSchristos { 132, "cannot find source lookup pool" },
163bc4097aaSchristos { 133, "unknown source address type" },
164bc4097aaSchristos { 134, "cannot find destination lookup pool" },
165bc4097aaSchristos { 135, "unknown destination address type" },
166bc4097aaSchristos { 136, "icmp head group name index incorrect" },
167bc4097aaSchristos { 137, "group head name index incorrect" },
168bc4097aaSchristos { 138, "group name index incorrect" },
169bc4097aaSchristos { 139, "to interface name index incorrect" },
170bc4097aaSchristos { 140, "dup-to interface name index incorrect" },
171bc4097aaSchristos { 141, "reply-to interface name index incorrect" },
172bc4097aaSchristos { 142, "could not initialise call now function" },
173bc4097aaSchristos { 143, "could not initialise call function" },
174bc4097aaSchristos { 144, "could not find destination list" },
175bc4097aaSchristos { 145, "auth rules cannot have dup/to/fastroute" },
176bc4097aaSchristos { 146, "incorrect size for object to copy out" },
177bc4097aaSchristos { 147, "object type out of bounds for kernel copyout" },
178bc4097aaSchristos { 148, "object size too small for kernel copyout" },
179bc4097aaSchristos { 149, "object size validation failed for kernel copyout" },
180bc4097aaSchristos { 150, "error copying data out for kernel copyout" },
181bc4097aaSchristos { 151, "version mismatch for kernel copyout" },
182*1d8d50afSkhorben { 152, "direction does not match the group rule" },
183bc4097aaSchristos /* -------------------------------------------------------------------------- */
184bc4097aaSchristos { 10001, "could not find token for auth iterator" },
185bc4097aaSchristos { 10002, "write permissions require to add/remove auth rule" },
186bc4097aaSchristos { 10003, "need write permissions to set auth lock" },
187bc4097aaSchristos { 10004, "error copying out results of auth flush" },
188bc4097aaSchristos { 10005, "unknown auth ioctl" },
189bc4097aaSchristos { 10006, "can only append or remove preauth rules" },
190bc4097aaSchristos { 10007, "NULL pointers passed in for preauth remove" },
191bc4097aaSchristos { 10008, "preauth rule not found to remove" },
192bc4097aaSchristos { 10009, "could not malloc memory for preauth entry" },
193bc4097aaSchristos { 10010, "unrecognised preauth rule ioctl command" },
194bc4097aaSchristos { 10011, "iterator data supplied with NULL pointer" },
195bc4097aaSchristos { 10012, "unknown auth iterator type" },
196bc4097aaSchristos { 10013, "iterator error copying out auth data" },
197bc4097aaSchristos { 10014, "sleep waiting for auth packet interrupted" },
198bc4097aaSchristos { 10015, "bad index supplied in auth reply" },
199bc4097aaSchristos { 10016, "error injecting outbound packet back into kernel" },
200bc4097aaSchristos { 10017, "error injecting inbound packet back into kernel" },
201bc4097aaSchristos { 10018, "could not attempt to inject packet back into kernel" },
202bc4097aaSchristos { 10019, "packet id does not match" },
203bc4097aaSchristos /* -------------------------------------------------------------------------- */
204bc4097aaSchristos { 20001, "invalid frag token data pointer supplied" },
205bc4097aaSchristos { 20002, "error copying out frag token data" },
206bc4097aaSchristos { 20003, "can only copy one fragment state entry at a time" },
207bc4097aaSchristos /* -------------------------------------------------------------------------- */
208bc4097aaSchristos { 30001, "incorrect object size to get hash table stats" },
209bc4097aaSchristos { 30002, "could not malloc memory for new hash table" },
210bc4097aaSchristos { 30003, "error coping in hash table structure" },
211bc4097aaSchristos { 30004, "hash table already exists" },
212bc4097aaSchristos { 30005, "mismach between new hash table and operation unit" },
213bc4097aaSchristos { 30006, "could not malloc memory for hash table base" },
214bc4097aaSchristos { 30007, "could not find hash table" },
215bc4097aaSchristos { 30008, "mismatch between hash table and operation unit" },
216bc4097aaSchristos { 30009, "could not find hash table for iterators next node" },
217bc4097aaSchristos { 30010, "unknown iterator tpe" },
218bc4097aaSchristos { 30011, "iterator error copying out hash table" },
219bc4097aaSchristos { 30012, "iterator error copying out hash table entry" },
220bc4097aaSchristos { 30013, "error copying out hash table statistics" },
221bc4097aaSchristos { 30014, "table node delete structure wrong size" },
222bc4097aaSchristos { 30015, "error copying in node to delete" },
223bc4097aaSchristos { 30016, "table to delete node from does not exist" },
224bc4097aaSchristos { 30017, "could not find table to remove node from" },
225bc4097aaSchristos { 30018, "table node add structure wrong size" },
226bc4097aaSchristos { 30019, "error copying in node to add" },
227bc4097aaSchristos { 30020, "could not find table to add node to" },
228bc4097aaSchristos { 30021, "node already exists in the table" },
229bc4097aaSchristos { 30022, "could not find node to delete in table" },
230bc4097aaSchristos { 30023, "uid mismatch on node to delete" },
231c9d5dc6cSdarrenr { 30024, "object size incorrect for hash table" },
232c9d5dc6cSdarrenr { 30025, "hash table size must be at least 1"},
233c9d5dc6cSdarrenr { 30026, "cannot allocate memory for hash table context" },
234bc4097aaSchristos /* -------------------------------------------------------------------------- */
235bc4097aaSchristos { 40001, "invalid minor device numebr for log read" },
236bc4097aaSchristos { 40002, "read size too small" },
237bc4097aaSchristos { 40003, "interrupted waiting for log data to read" },
238bc4097aaSchristos { 40004, "interrupted waiting for log data to read" },
239bc4097aaSchristos { 40005, "read size too large" },
240bc4097aaSchristos { 40006, "uiomove for read operation failed" },
241bc4097aaSchristos /* -------------------------------------------------------------------------- */
242bc4097aaSchristos { 50001, "unknown lookup ioctl" },
243bc4097aaSchristos { 50002, "error copying in object data for add node" },
244bc4097aaSchristos { 50003, "invalid unit for lookup add node" },
245bc4097aaSchristos { 50004, "incorrect size for adding a pool node" },
246bc4097aaSchristos { 50005, "error copying in pool node structure" },
247bc4097aaSchristos { 50006, "mismatch in pool node address/mask families" },
248bc4097aaSchristos { 50007, "could not find pool name" },
249bc4097aaSchristos { 50008, "node already exists in pool" },
250bc4097aaSchristos { 50009, "incorrect size for adding a hash node" },
251bc4097aaSchristos { 50010, "error copying in hash node structure" },
252bc4097aaSchristos { 50011, "could not find hash table name" },
253bc4097aaSchristos { 50012, "unrecognised object type for lookup add node" },
254bc4097aaSchristos { 50013, "invalid unit for lookup delete node" },
255bc4097aaSchristos { 50014, "incorrect size for deleting a pool node" },
256bc4097aaSchristos { 50015, "error copying in pool node structure" },
257bc4097aaSchristos { 50016, "could not find pool name" },
258bc4097aaSchristos { 50017, "could not find pool node" },
259bc4097aaSchristos { 50018, "incorrect size for removing a hash node" },
260bc4097aaSchristos { 50019, "error copying in hash node structure" },
261bc4097aaSchristos { 50020, "could not find hash table name" },
262bc4097aaSchristos { 50021, "unrecognised object type for lookup delete node" },
263bc4097aaSchristos { 50022, "error copying in add table data" },
264bc4097aaSchristos { 50023, "invalid unit for lookup add table" },
265bc4097aaSchristos { 50024, "pool name already exists" },
266bc4097aaSchristos { 50025, "hash table name already exists" },
267bc4097aaSchristos { 50026, "unrecognised object type for lookup add table" },
268bc4097aaSchristos { 50027, "error copying table data back out" },
269bc4097aaSchristos { 50028, "error copying in remove table data" },
270bc4097aaSchristos { 50029, "invalid unit for lookup remove table" },
271bc4097aaSchristos { 50030, "unrecognised object type for lookup remove table" },
272bc4097aaSchristos { 50031, "error copying in lookup stats structure" },
273bc4097aaSchristos { 50032, "invalid unit for lookup stats" },
274bc4097aaSchristos { 50033, "unrecognised object type for lookup stats" },
275bc4097aaSchristos { 50034, "error copying in flush lookup data" },
276bc4097aaSchristos { 50035, "invalid unit for lookup flush" },
277bc4097aaSchristos { 50036, "incorrect table type for lookup flush" },
278bc4097aaSchristos { 50037, "error copying out lookup flush results" },
279bc4097aaSchristos { 50038, "invalid unit for lookup iterator" },
280bc4097aaSchristos { 50039, "invalid unit for lookup iterator" },
281bc4097aaSchristos { 50040, "could not find token for lookup iterator" },
282bc4097aaSchristos { 50041, "unrecognised object type for lookup interator" },
283bc4097aaSchristos { 50042, "error copying in lookup delete node operation" },
284bc4097aaSchristos /* -------------------------------------------------------------------------- */
285bc4097aaSchristos { 60001, "insufficient privilege for NAT write operation" },
286bc4097aaSchristos { 60002, "need write permissions to flush NAT logs" },
287bc4097aaSchristos { 60003, "need write permissions to turn NAT logging on/off" },
288bc4097aaSchristos { 60004, "error copying out current NAT log setting" },
289bc4097aaSchristos { 60005, "error copying out bytes waiting to be read in NAT \
290bc4097aaSchristos log" },
291bc4097aaSchristos { 60006, "need write permissions to add NAT rule" },
292bc4097aaSchristos { 60007, "NAT rule already exists" },
293bc4097aaSchristos { 60008, "could not allocate memory for NAT rule" },
294bc4097aaSchristos { 60009, "need write permissions to remove NAT rule" },
295bc4097aaSchristos { 60010, "NAT rule could not be found" },
296bc4097aaSchristos { 60011, "could not find NAT entry for redirect lookup" },
297bc4097aaSchristos { 60012, "need write permissions to flush NAT table" },
298bc4097aaSchristos { 60013, "error copying in NAT flush command" },
299bc4097aaSchristos { 60014, "need write permissions to do matching NAT flush" },
300bc4097aaSchristos { 60015, "need write permissions to set NAT lock" },
301bc4097aaSchristos { 60016, "need write permissions to add entry to NAT table" },
302bc4097aaSchristos { 60017, "NAT not locked for size retrieval" },
303bc4097aaSchristos { 60018, "NAT not locked for fetching NAT table entry" },
304bc4097aaSchristos { 60019, "error copying in NAT token data for deletion" },
305bc4097aaSchristos { 60020, "unknown NAT ioctl" },
306c9d5dc6cSdarrenr { 60021, "" },
307bc4097aaSchristos { 60022, "resolving proxy name in NAT rule failed" },
308bc4097aaSchristos { 60023, "only reply age specified in NAT rule" },
309bc4097aaSchristos { 60024, "error doing copyin to determine NAT entry size" },
310bc4097aaSchristos { 60025, "error copying out NAT size of 0" },
311bc4097aaSchristos { 60026, "NAT entry not found" },
312bc4097aaSchristos { 60027, "error doing copyout of NAT entry size" },
313bc4097aaSchristos { 60028, "invalid data size for getting NAT entry" },
314bc4097aaSchristos { 60029, "could not malloc temporary space for NAT entry" },
315bc4097aaSchristos { 60030, "no NAT table entries present" },
316bc4097aaSchristos { 60031, "NAT entry to get next from not found" },
317bc4097aaSchristos { 60032, "not enough space for proxy structure" },
318bc4097aaSchristos { 60033, "not enough space for private proxy data" },
319bc4097aaSchristos { 60034, "NAT entry size is too large" },
320bc4097aaSchristos { 60035, "could not malloc memory for NAT entry sratch space" },
321bc4097aaSchristos { 60036, "" },
322bc4097aaSchristos { 60037, "could not malloc memory for NAT entry" },
323bc4097aaSchristos { 60038, "could not malloc memory for NAT entry rule" },
324bc4097aaSchristos { 60039, "could not resolve NAT entry rule's proxy" },
325bc4097aaSchristos { 60040, "cannot add outbound duplicate NAT entry" },
326bc4097aaSchristos { 60041, "cannot add inbound duplicate NAT entry" },
327bc4097aaSchristos { 60042, "cannot add NAT entry that is neither IN nor OUT" },
328bc4097aaSchristos { 60043, "could not malloc memory for NAT proxy data" },
329bc4097aaSchristos { 60044, "proxy data size too big" },
330bc4097aaSchristos { 60045, "could not malloc proxy private data for NAT entry" },
331bc4097aaSchristos { 60046, "could not malloc memory for new NAT filter rule" },
332bc4097aaSchristos { 60047, "could not find existing filter rule for NAT entry" },
333bc4097aaSchristos { 60048, "insertion into NAT table failed" },
334bc4097aaSchristos { 60049, "iterator error copying out hostmap data" },
335bc4097aaSchristos { 60050, "iterator error copying out NAT rule data" },
336bc4097aaSchristos { 60051, "iterator error copying out NAT entry data" },
337bc4097aaSchristos { 60052, "iterator data supplied with NULL pointer" },
338bc4097aaSchristos { 60053, "unknown NAT iterator type" },
339bc4097aaSchristos { 60054, "unknwon next address type" },
340bc4097aaSchristos { 60055, "iterator suppled with unknown type for get-next" },
341bc4097aaSchristos { 60056, "unknown lookup group for next address" },
342bc4097aaSchristos { 60057, "error copying out NAT log flush results" },
343bc4097aaSchristos { 60058, "bucket table type is incorrect" },
344bc4097aaSchristos { 60059, "error copying out NAT bucket table" },
345bc4097aaSchristos { 60060, "function not found for lookup" },
346bc4097aaSchristos { 60061, "address family not supported with SIOCSTPUT" },
347bc4097aaSchristos { 60062, "unknown timeout name" },
348bc4097aaSchristos { 60063, "cannot allocate new inbound NAT entry table" },
349bc4097aaSchristos { 60064, "cannot allocate new outbound NAT entry table" },
350bc4097aaSchristos { 60065, "cannot allocate new inbound NAT bucketlen table" },
351bc4097aaSchristos { 60066, "cannot allocate new outbound NAT bucketlen table" },
352bc4097aaSchristos { 60067, "cannot allocate new NAT rules table" },
353bc4097aaSchristos { 60068, "cannot allocate new NAT hostmap table" },
354bc4097aaSchristos { 60069, "new source lookup type is not dstlist" },
355bc4097aaSchristos { 60070, "cannot allocate NAT rule scratch space" },
356bc4097aaSchristos { 60071, "new destination lookup type is not dstlist" },
357bc4097aaSchristos { 60072, "function not found for lookup (ipv6)" },
358bc4097aaSchristos { 60073, "unknown lookup group for next address (ipv6)" },
359bc4097aaSchristos { 60074, "unknown next address type (ipv6)" },
360bc4097aaSchristos { 60075, "one object at a time must be copied" },
361bc4097aaSchristos /* -------------------------------------------------------------------------- */
362bc4097aaSchristos { 70001, "incorrect object size to get pool stats" },
363bc4097aaSchristos { 70002, "could not malloc memory for new pool node" },
364bc4097aaSchristos { 70003, "invalid addresss length for new pool node" },
365bc4097aaSchristos { 70004, "invalid mask length for new pool node" },
366bc4097aaSchristos { 70005, "error adding node to pool" },
367bc4097aaSchristos { 70006, "pool already exists" },
368bc4097aaSchristos { 70007, "could not malloc memory for new pool" },
369bc4097aaSchristos { 70008, "could not allocate radix tree for new pool" },
370bc4097aaSchristos { 70009, "could not find pool" },
371bc4097aaSchristos { 70010, "unknown pool name for iteration" },
372bc4097aaSchristos { 70011, "unknown pool iterator" },
373bc4097aaSchristos { 70012, "error copying out pool head" },
374bc4097aaSchristos { 70013, "error copying out pool node" },
375bc4097aaSchristos { 70014, "add node size incorrect" },
376bc4097aaSchristos { 70015, "error copying in pool node" },
377c9d5dc6cSdarrenr { 70016, "" },
378bc4097aaSchristos { 70017, "cannot find pool for node" },
379bc4097aaSchristos { 70018, "node entry already present in pool" },
380bc4097aaSchristos { 70019, "delete node size incorrect" },
381bc4097aaSchristos { 70020, "error copying in node to delete" },
382bc4097aaSchristos { 70021, "cannot find pool to delete node from" },
383bc4097aaSchristos { 70022, "cannot find node to delete in pool" },
384bc4097aaSchristos { 70023, "pool name already exists" },
385bc4097aaSchristos { 70024, "uid mismatch for node removal" },
386bc4097aaSchristos { 70025, "stats device unit is invalid" },
387bc4097aaSchristos { 70026, "error copying out statistics" },
388c9d5dc6cSdarrenr { 70027, "could not remove node from radix tree" },
389c9d5dc6cSdarrenr { 70028, "incorrect address length in pool node add" },
390c9d5dc6cSdarrenr { 70029, "incorrect mask length in pool node add" },
391c9d5dc6cSdarrenr { 70030, "incorrect address length in pool node remove" },
392c9d5dc6cSdarrenr { 70031, "incorrect mask length in pool node remove" },
393c9d5dc6cSdarrenr { 70032, "cannot allocate memory for pool context" },
394c9d5dc6cSdarrenr { 70033, "cannot allocate memory for radix tree context" },
395c9d5dc6cSdarrenr { 70034, "adding IPv6 node with incorrect address length" },
396c9d5dc6cSdarrenr { 70035, "IPv4 address not masked" },
397c9d5dc6cSdarrenr { 70036, "IPv6 address not masked" },
398c9d5dc6cSdarrenr { 70037, "removing IPv6 node with incorrect address length" },
399bc4097aaSchristos /* -------------------------------------------------------------------------- */
400bc4097aaSchristos { 80001, "could not find proxy" },
401bc4097aaSchristos { 80002, "proxy does not support control operations" },
402bc4097aaSchristos { 80003, "could not allocate data to hold proxy operation" },
403bc4097aaSchristos { 80004, "unknown proxy ioctl" },
404bc4097aaSchristos { 80005, "could not copyin proxy control structure" },
405bc4097aaSchristos { 80006, "DNS proxy could not find rule to delete" },
406bc4097aaSchristos { 80007, "DNS proxy found existing matching rule" },
407bc4097aaSchristos { 80008, "DNS proxy could not allocate memory for new rule" },
408bc4097aaSchristos { 80009, "DNS proxy unknown command request" },
409bc4097aaSchristos /* -------------------------------------------------------------------------- */
410bc4097aaSchristos { 90001, "could not malloc space for new scan structure" },
411bc4097aaSchristos { 90002, "scan tag already exists" },
412bc4097aaSchristos { 90003, "scan structure in use" },
413bc4097aaSchristos { 90004, "could not find matching scan tag for filter rule" },
414bc4097aaSchristos { 90005, "could not copyout scan statistics" },
415bc4097aaSchristos /* -------------------------------------------------------------------------- */
416bc4097aaSchristos { 100001, "cannot find matching state entry to remove" },
417bc4097aaSchristos { 100002, "error copying in v4 state flush command" },
418bc4097aaSchristos { 100003, "error copying out v4 state flush results" },
419bc4097aaSchristos { 100004, "error copying in v6 state flush command" },
420bc4097aaSchristos { 100005, "error copying out v6 state flush results" },
421bc4097aaSchristos { 100006, "" },
422bc4097aaSchristos { 100007, "" },
423bc4097aaSchristos { 100008, "need write permissions to flush state log" },
424bc4097aaSchristos { 100009, "erorr copyout results of flushing state log" },
425bc4097aaSchristos { 100010, "need write permissions to turn state logging on/off" },
426bc4097aaSchristos { 100011, "error copying in new state logging state" },
427bc4097aaSchristos { 100012, "error copying out current state logging state" },
428bc4097aaSchristos { 100013, "error copying out bytes waiting to be read in state \
429bc4097aaSchristos log" },
430bc4097aaSchristos { 100014, "need write permissions to set state lock" },
431bc4097aaSchristos { 100015, "need write permissions to add entry to state table" },
432bc4097aaSchristos { 100016, "state not locked for size retrieval" },
433bc4097aaSchristos { 100017, "error copying out hash table bucket lengths" },
434bc4097aaSchristos { 100018, "could not find token for state iterator" },
435bc4097aaSchristos { 100019, "error copying in state token data for deletion" },
436bc4097aaSchristos { 100020, "unknown state ioctl" },
437bc4097aaSchristos { 100021, "no state table entries present" },
438bc4097aaSchristos { 100022, "state entry to get next from not found" },
439bc4097aaSchristos { 100023, "could not malloc memory for state entry" },
440bc4097aaSchristos { 100024, "could not malloc memory for state entry rule" },
441bc4097aaSchristos { 100025, "could not copy back state entry to user space" },
442bc4097aaSchristos { 100026, "iterator data supplied with NULL pointer" },
443bc4097aaSchristos { 100027, "iterator supplied with 0 item count" },
444bc4097aaSchristos { 100028, "iterator type is incorrect" },
445bc4097aaSchristos { 100029, "invalid state token data pointer supplied" },
446bc4097aaSchristos { 100030, "error copying out next state entry" },
447bc4097aaSchristos { 100031, "unrecognised table request" },
448bc4097aaSchristos { 100032, "error copying out bucket length data" },
449bc4097aaSchristos { 100033, "could not find existing filter rule for state entry" },
450bc4097aaSchristos { 100034, "could not find timeout name" },
451bc4097aaSchristos { 100035, "could not allocate new state table" },
452bc4097aaSchristos { 100036, "could not allocate new state bucket length table" },
453bc4097aaSchristos /* -------------------------------------------------------------------------- */
454bc4097aaSchristos { 110001, "sync write header magic number is incorrect" },
455bc4097aaSchristos { 110002, "sync write header protocol is incorrect" },
456bc4097aaSchristos { 110003, "sync write header command is incorrect" },
457bc4097aaSchristos { 110004, "sync write header table number is incorrect" },
458bc4097aaSchristos { 110005, "data structure too small for sync write operation" },
459bc4097aaSchristos { 110006, "zero length data with sync write header" },
460bc4097aaSchristos { 110007, "insufficient data for sync write" },
461bc4097aaSchristos { 110008, "bad sync read size" },
462bc4097aaSchristos { 110009, "interrupted sync read (solaris)" },
463bc4097aaSchristos { 110010, "interrupted sync read (hpux)" },
464bc4097aaSchristos { 110011, "interrupted sync read (osf)" },
465bc4097aaSchristos { 110012, "interrupted sync read" },
466bc4097aaSchristos { 110013, "could not malloc memory for sync'd state" },
467bc4097aaSchristos { 110014, "could not malloc memory for sync-state list item" },
468bc4097aaSchristos { 110015, "sync update could not find state" },
469bc4097aaSchristos { 110016, "unrecognised sync state command" },
470bc4097aaSchristos { 110017, "could not malloc memory for new sync'd NAT entry" },
471bc4097aaSchristos { 110018, "could not malloc memory for sync-NAT list item" },
472bc4097aaSchristos { 110019, "sync update could not find NAT entry" },
473bc4097aaSchristos { 110020, "unrecognised sync NAT command" },
474bc4097aaSchristos { 110021, "ioctls are not handled with sync" },
475bc4097aaSchristos /* -------------------------------------------------------------------------- */
476bc4097aaSchristos { 120001, "null data pointer for iterator" },
477bc4097aaSchristos { 120002, "unit outside of acceptable range" },
478bc4097aaSchristos { 120003, "unknown iterator subtype" },
479bc4097aaSchristos { 120004, "cannot find dest. list for iteration" },
480bc4097aaSchristos { 120005, "error copying out destination iteration list" },
481bc4097aaSchristos { 120006, "error copying out destination iteration node" },
482bc4097aaSchristos { 120007, "wrong size for frdest_t structure" },
483bc4097aaSchristos { 120008, "cannot allocate memory for new destination node" },
484bc4097aaSchristos { 120009, "error copying in destination node to add" },
485bc4097aaSchristos { 120010, "could not find destination list to add node to" },
486bc4097aaSchristos { 120011, "error copying in destination node to remove" },
487bc4097aaSchristos { 120012, "could not find dest. list to remove node from" },
488bc4097aaSchristos { 120013, "destination list already exists" },
489bc4097aaSchristos { 120014, "could not allocate new destination table" },
490bc4097aaSchristos { 120015, "could not find destination list to remove" },
491bc4097aaSchristos { 120016, "destination list cannot be removed - it is busy" },
492bc4097aaSchristos { 120017, "error copying in names for destination" },
493bc4097aaSchristos { 120018, "destination name is too long/short" },
494bc4097aaSchristos { 120019, "unrecognised address family in destination" },
495bc4097aaSchristos { 120020, "" },
496bc4097aaSchristos { 120021, "error copying in new destination table" },
497bc4097aaSchristos { 120022, "cannot allocate memory for node table" },
498bc4097aaSchristos { 120023, "stats object size is incorrect for dest. lists" },
499bc4097aaSchristos { 120024, "stats device unit is invalid for dest. lists" },
500bc4097aaSchristos { 120025, "error copying out dest. list statistics" },
501bc4097aaSchristos { 120026, "cannot allocate memory for destination node" },
502bc4097aaSchristos { 120027, "error copying in destination node" },
503c9d5dc6cSdarrenr { 120028, "cannot allocate memory for destination context " },
504bc4097aaSchristos /* -------------------------------------------------------------------------- */
505bc4097aaSchristos { 130001, "ioctl denied by system security level" },
506bc4097aaSchristos { 130002, "ioctl operation on invalid minor device" },
507eb1b7900Schristos { 130003, "ioctl on device denied, ipfilter is disabled" },
508bc4097aaSchristos { 130004, "ioctl command not allowed when disabled" },
509bc4097aaSchristos { 130005, "ioctl denied due to insufficient authorisation" },
510bc4097aaSchristos { 130006, "cannot read while ipfilter is disabled" },
511bc4097aaSchristos { 130007, "read on minor device not supported" },
512bc4097aaSchristos { 130008, "cannot write while ipfilter is disabled" },
513bc4097aaSchristos { 130009, "write on minor device not supported" },
514bc4097aaSchristos { 130010, "poll on minor device is not supported" },
515bc4097aaSchristos { 130011, "error removing IPv4 filter hooks" },
516bc4097aaSchristos { 130012, "error removing IPv6 filter hooks" },
517bc4097aaSchristos { 130013, "attaching IPv4 hook failed" },
518bc4097aaSchristos { 130014, "attaching IPv6 hook failed" },
519bc4097aaSchristos { 130015, "ipf_init_all failed" },
520bc4097aaSchristos { 130016, "finding pfil head failed" },
521bc4097aaSchristos { 130017, "ipfilter is already initialised and running" },
522bc4097aaSchristos };
523bc4097aaSchristos
524bc4097aaSchristos
525bc4097aaSchristos static ipf_error_entry_t *
find_error(errnum)526bc4097aaSchristos find_error(errnum)
527bc4097aaSchristos int errnum;
528bc4097aaSchristos {
529bc4097aaSchristos ipf_error_entry_t *ie;
530bc4097aaSchristos
531bc4097aaSchristos int l = -1, r = IPF_NUM_ERRORS + 1, step;
532bc4097aaSchristos step = (r - l) / 2;;
533bc4097aaSchristos
534bc4097aaSchristos while (step != 0) {
535bc4097aaSchristos ie = ipf_errors + l + step;
536bc4097aaSchristos if (ie->iee_number == errnum)
537bc4097aaSchristos return ie;
538bc4097aaSchristos step = l + step;
539bc4097aaSchristos if (ie->iee_number > errnum)
540bc4097aaSchristos r = step;
541bc4097aaSchristos else
542bc4097aaSchristos l = step;
543bc4097aaSchristos step = (r - l) / 2;;
544bc4097aaSchristos }
545bc4097aaSchristos
546bc4097aaSchristos return NULL;
547bc4097aaSchristos }
548bc4097aaSchristos
549bc4097aaSchristos char *
ipf_geterror(fd,func)550bc4097aaSchristos ipf_geterror(fd, func)
551bc4097aaSchristos int fd;
552bc4097aaSchristos ioctlfunc_t *func;
553bc4097aaSchristos {
554bc4097aaSchristos static char text[80];
555bc4097aaSchristos ipf_error_entry_t *ie;
556bc4097aaSchristos int errnum;
557bc4097aaSchristos
558bc4097aaSchristos if ((*func)(fd, SIOCIPFINTERROR, &errnum) == 0) {
559bc4097aaSchristos
560bc4097aaSchristos ie = find_error(errnum);
561bc4097aaSchristos if (ie != NULL)
562bc4097aaSchristos return ie->iee_text;
563bc4097aaSchristos sprintf(text, "unknown error %d", errnum);
564bc4097aaSchristos } else {
565bc4097aaSchristos sprintf(text, "retrieving error number failed (%d)", errno);
566bc4097aaSchristos }
567bc4097aaSchristos return text;
568bc4097aaSchristos }
569bc4097aaSchristos
570bc4097aaSchristos
571bc4097aaSchristos char *
ipf_strerror(errnum)572bc4097aaSchristos ipf_strerror(errnum)
573bc4097aaSchristos int errnum;
574bc4097aaSchristos {
575bc4097aaSchristos static char text[80];
576bc4097aaSchristos ipf_error_entry_t *ie;
577bc4097aaSchristos
578bc4097aaSchristos
579bc4097aaSchristos ie = find_error(errnum);
580bc4097aaSchristos if (ie != NULL)
581bc4097aaSchristos return ie->iee_text;
582bc4097aaSchristos
583bc4097aaSchristos sprintf(text, "unknown error %d", errnum);
584bc4097aaSchristos return text;
585bc4097aaSchristos }
586