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