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