13b9b51feSCy Schubert /* 23b9b51feSCy Schubert * Copyright (C) 2012 by Darren Reed. 33b9b51feSCy Schubert * 43b9b51feSCy Schubert * See the IPFILTER.LICENCE file for details on licencing. 53b9b51feSCy Schubert * 63b9b51feSCy Schubert * $Id$ 73b9b51feSCy Schubert */ 83b9b51feSCy Schubert #ifndef __IP_LOOKUP_H__ 93b9b51feSCy Schubert #define __IP_LOOKUP_H__ 103b9b51feSCy Schubert 113b9b51feSCy Schubert # define SIOCLOOKUPADDTABLE _IOWR('r', 60, struct iplookupop) 123b9b51feSCy Schubert # define SIOCLOOKUPDELTABLE _IOWR('r', 61, struct iplookupop) 133b9b51feSCy Schubert # define SIOCLOOKUPSTAT _IOWR('r', 64, struct iplookupop) 143b9b51feSCy Schubert # define SIOCLOOKUPSTATW _IOW('r', 64, struct iplookupop) 153b9b51feSCy Schubert # define SIOCLOOKUPFLUSH _IOWR('r', 65, struct iplookupflush) 163b9b51feSCy Schubert # define SIOCLOOKUPADDNODE _IOWR('r', 67, struct iplookupop) 173b9b51feSCy Schubert # define SIOCLOOKUPADDNODEW _IOW('r', 67, struct iplookupop) 183b9b51feSCy Schubert # define SIOCLOOKUPDELNODE _IOWR('r', 68, struct iplookupop) 193b9b51feSCy Schubert # define SIOCLOOKUPDELNODEW _IOW('r', 68, struct iplookupop) 203b9b51feSCy Schubert 213b9b51feSCy Schubert #define LOOKUP_POOL_MAX (IPL_LOGSIZE) 223b9b51feSCy Schubert #define LOOKUP_POOL_SZ (IPL_LOGSIZE + 1) 233b9b51feSCy Schubert 243b9b51feSCy Schubert typedef struct iplookupop { 253b9b51feSCy Schubert int iplo_type; /* IPLT_* */ 263b9b51feSCy Schubert int iplo_unit; /* IPL_LOG* */ 273b9b51feSCy Schubert u_int iplo_arg; 283b9b51feSCy Schubert char iplo_name[FR_GROUPLEN]; 293b9b51feSCy Schubert size_t iplo_size; /* sizeof struct at iplo_struct */ 303b9b51feSCy Schubert void *iplo_struct; 313b9b51feSCy Schubert } iplookupop_t; 323b9b51feSCy Schubert 333b9b51feSCy Schubert #define LOOKUP_ANON 0x80000000 343b9b51feSCy Schubert 353b9b51feSCy Schubert 363b9b51feSCy Schubert typedef struct iplookupflush { 373b9b51feSCy Schubert int iplf_type; /* IPLT_* */ 383b9b51feSCy Schubert int iplf_unit; /* IPL_LOG* */ 393b9b51feSCy Schubert u_int iplf_arg; 403b9b51feSCy Schubert u_int iplf_count; 413b9b51feSCy Schubert char iplf_name[FR_GROUPLEN]; 423b9b51feSCy Schubert } iplookupflush_t; 433b9b51feSCy Schubert 443b9b51feSCy Schubert typedef struct iplookuplink { 453b9b51feSCy Schubert int ipll_type; /* IPLT_* */ 463b9b51feSCy Schubert int ipll_unit; /* IPL_LOG* */ 473b9b51feSCy Schubert u_int ipll_num; 483b9b51feSCy Schubert char ipll_group[FR_GROUPLEN]; 493b9b51feSCy Schubert } iplookuplink_t; 503b9b51feSCy Schubert 513b9b51feSCy Schubert #define IPLT_ALL -1 523b9b51feSCy Schubert #define IPLT_NONE 0 533b9b51feSCy Schubert #define IPLT_POOL 1 543b9b51feSCy Schubert #define IPLT_HASH 2 553b9b51feSCy Schubert #define IPLT_DSTLIST 3 563b9b51feSCy Schubert 573b9b51feSCy Schubert 583b9b51feSCy Schubert #define IPLT_ANON 0x80000000 593b9b51feSCy Schubert 603b9b51feSCy Schubert 613b9b51feSCy Schubert typedef union { 623b9b51feSCy Schubert struct iplookupiterkey { 633b9b51feSCy Schubert u_char ilik_ival; 643b9b51feSCy Schubert u_char ilik_type; /* IPLT_* */ 653b9b51feSCy Schubert u_char ilik_otype; 663b9b51feSCy Schubert signed char ilik_unit; /* IPL_LOG* */ 673b9b51feSCy Schubert } ilik_unstr; 683b9b51feSCy Schubert u_32_t ilik_key; 693b9b51feSCy Schubert } iplookupiterkey_t; 703b9b51feSCy Schubert 713b9b51feSCy Schubert typedef struct ipflookupiter { 723b9b51feSCy Schubert int ili_nitems; 733b9b51feSCy Schubert iplookupiterkey_t ili_lkey; 743b9b51feSCy Schubert char ili_name[FR_GROUPLEN]; 753b9b51feSCy Schubert void *ili_data; 763b9b51feSCy Schubert } ipflookupiter_t; 773b9b51feSCy Schubert 783b9b51feSCy Schubert #define ili_key ili_lkey.ilik_key 793b9b51feSCy Schubert #define ili_ival ili_lkey.ilik_unstr.ilik_ival 803b9b51feSCy Schubert #define ili_unit ili_lkey.ilik_unstr.ilik_unit 813b9b51feSCy Schubert #define ili_type ili_lkey.ilik_unstr.ilik_type 823b9b51feSCy Schubert #define ili_otype ili_lkey.ilik_unstr.ilik_otype 833b9b51feSCy Schubert 843b9b51feSCy Schubert #define IPFLOOKUPITER_LIST 0 853b9b51feSCy Schubert #define IPFLOOKUPITER_NODE 1 863b9b51feSCy Schubert 873b9b51feSCy Schubert 883b9b51feSCy Schubert typedef struct ipf_lookup { 893b9b51feSCy Schubert int ipfl_type; 903b9b51feSCy Schubert void *(*ipfl_create)(ipf_main_softc_t *); 913b9b51feSCy Schubert void (*ipfl_destroy)(ipf_main_softc_t *, void *); 923b9b51feSCy Schubert int (*ipfl_init)(ipf_main_softc_t *, void *); 933b9b51feSCy Schubert void (*ipfl_fini)(ipf_main_softc_t *, void *); 943b9b51feSCy Schubert int (*ipfl_addr_find)(ipf_main_softc_t *, void *, 953b9b51feSCy Schubert int, void *, u_int); 963b9b51feSCy Schubert size_t (*ipfl_flush)(ipf_main_softc_t *, void *, 973b9b51feSCy Schubert iplookupflush_t *); 983b9b51feSCy Schubert int (*ipfl_iter_deref)(ipf_main_softc_t *, void *, 993b9b51feSCy Schubert int, int, void *); 1003b9b51feSCy Schubert int (*ipfl_iter_next)(ipf_main_softc_t *, void *, 1013b9b51feSCy Schubert ipftoken_t *, ipflookupiter_t *); 1023b9b51feSCy Schubert int (*ipfl_node_add)(ipf_main_softc_t *, void *, 1033b9b51feSCy Schubert iplookupop_t *, int); 1043b9b51feSCy Schubert int (*ipfl_node_del)(ipf_main_softc_t *, void *, 1053b9b51feSCy Schubert iplookupop_t *, int); 1063b9b51feSCy Schubert int (*ipfl_stats_get)(ipf_main_softc_t *, void *, 1073b9b51feSCy Schubert iplookupop_t *); 1083b9b51feSCy Schubert int (*ipfl_table_add)(ipf_main_softc_t *, void *, 1093b9b51feSCy Schubert iplookupop_t *); 1103b9b51feSCy Schubert int (*ipfl_table_del)(ipf_main_softc_t *, void *, 1113b9b51feSCy Schubert iplookupop_t *); 1123b9b51feSCy Schubert int (*ipfl_table_deref)(ipf_main_softc_t *, void *, void *); 1133b9b51feSCy Schubert void *(*ipfl_table_find)(void *, int, char *); 1143b9b51feSCy Schubert void *(*ipfl_select_add_ref)(void *, int, char *); 1153b9b51feSCy Schubert int (*ipfl_select_node)(fr_info_t *, void *, u_32_t *, 1163b9b51feSCy Schubert frdest_t *); 1173b9b51feSCy Schubert void (*ipfl_expire)(ipf_main_softc_t *, void *); 1183b9b51feSCy Schubert void (*ipfl_sync)(ipf_main_softc_t *, void *); 1193b9b51feSCy Schubert } ipf_lookup_t; 1203b9b51feSCy Schubert 1213b9b51feSCy Schubert extern int ipf_lookup_init(void); 1223b9b51feSCy Schubert extern int ipf_lookup_ioctl(ipf_main_softc_t *, caddr_t, ioctlcmd_t, int, int, void *); 1233b9b51feSCy Schubert extern void ipf_lookup_main_unload(void); 1243b9b51feSCy Schubert extern void ipf_lookup_deref(ipf_main_softc_t *, int, void *); 1253b9b51feSCy Schubert extern void ipf_lookup_iterderef(ipf_main_softc_t *, u_32_t, void *); 1263b9b51feSCy Schubert extern void *ipf_lookup_res_name(ipf_main_softc_t *, int, u_int, char *, 1273b9b51feSCy Schubert lookupfunc_t *); 1283b9b51feSCy Schubert extern void *ipf_lookup_res_num(ipf_main_softc_t *, int, u_int, u_int, 1293b9b51feSCy Schubert lookupfunc_t *); 1303b9b51feSCy Schubert extern void ipf_lookup_soft_destroy(ipf_main_softc_t *, void *); 1313b9b51feSCy Schubert extern void *ipf_lookup_soft_create(ipf_main_softc_t *); 1323b9b51feSCy Schubert extern int ipf_lookup_soft_init(ipf_main_softc_t *, void *); 1333b9b51feSCy Schubert extern int ipf_lookup_soft_fini(ipf_main_softc_t *, void *); 1343b9b51feSCy Schubert extern void *ipf_lookup_find_htable(ipf_main_softc_t *, int, char *); 1353b9b51feSCy Schubert extern void ipf_lookup_expire(ipf_main_softc_t *); 1363b9b51feSCy Schubert extern void ipf_lookup_sync(ipf_main_softc_t *, void *); 1373b9b51feSCy Schubert #ifndef _KERNEL 1383b9b51feSCy Schubert extern void ipf_lookup_dump(ipf_main_softc_t *, void *); 1393b9b51feSCy Schubert #endif 1403b9b51feSCy Schubert #endif /* __IP_LOOKUP_H__ */ 141