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