1*f52ace7aSdarrenr /* $NetBSD: ip_lookup.h,v 1.2 2012/07/22 14:27:35 darrenr Exp $ */ 226945a25Schristos 326945a25Schristos /* 4c50c2f6fSdarrenr * Copyright (C) 2012 by Darren Reed. 526945a25Schristos * 626945a25Schristos * See the IPFILTER.LICENCE file for details on licencing. 726945a25Schristos * 8*f52ace7aSdarrenr * Id: ip_lookup.h,v 1.1.1.2 2012/07/22 13:44:19 darrenr Exp $ 926945a25Schristos */ 1026945a25Schristos #ifndef __IP_LOOKUP_H__ 1126945a25Schristos #define __IP_LOOKUP_H__ 1226945a25Schristos 1326945a25Schristos #if defined(__STDC__) || defined(__GNUC__) || defined(_AIX51) 1426945a25Schristos # define SIOCLOOKUPADDTABLE _IOWR('r', 60, struct iplookupop) 1526945a25Schristos # define SIOCLOOKUPDELTABLE _IOWR('r', 61, struct iplookupop) 1626945a25Schristos # define SIOCLOOKUPSTAT _IOWR('r', 64, struct iplookupop) 1726945a25Schristos # define SIOCLOOKUPSTATW _IOW('r', 64, struct iplookupop) 1826945a25Schristos # define SIOCLOOKUPFLUSH _IOWR('r', 65, struct iplookupflush) 1926945a25Schristos # define SIOCLOOKUPADDNODE _IOWR('r', 67, struct iplookupop) 2026945a25Schristos # define SIOCLOOKUPADDNODEW _IOW('r', 67, struct iplookupop) 2126945a25Schristos # define SIOCLOOKUPDELNODE _IOWR('r', 68, struct iplookupop) 2226945a25Schristos # define SIOCLOOKUPDELNODEW _IOW('r', 68, struct iplookupop) 2326945a25Schristos #else 2426945a25Schristos # define SIOCLOOKUPADDTABLE _IOWR(r, 60, struct iplookupop) 2526945a25Schristos # define SIOCLOOKUPDELTABLE _IOWR(r, 61, struct iplookupop) 2626945a25Schristos # define SIOCLOOKUPSTAT _IOWR(r, 64, struct iplookupop) 2726945a25Schristos # define SIOCLOOKUPSTATW _IOW(r, 64, struct iplookupop) 2826945a25Schristos # define SIOCLOOKUPFLUSH _IOWR(r, 65, struct iplookupflush) 2926945a25Schristos # define SIOCLOOKUPADDNODE _IOWR(r, 67, struct iplookupop) 3026945a25Schristos # define SIOCLOOKUPADDNODEW _IOW(r, 67, struct iplookupop) 3126945a25Schristos # define SIOCLOOKUPDELNODE _IOWR(r, 68, struct iplookupop) 3226945a25Schristos # define SIOCLOOKUPDELNODEW _IOW(r, 68, struct iplookupop) 3326945a25Schristos #endif 3426945a25Schristos 3526945a25Schristos #define LOOKUP_POOL_MAX (IPL_LOGSIZE) 3626945a25Schristos #define LOOKUP_POOL_SZ (IPL_LOGSIZE + 1) 3726945a25Schristos 3826945a25Schristos typedef struct iplookupop { 3926945a25Schristos int iplo_type; /* IPLT_* */ 4026945a25Schristos int iplo_unit; /* IPL_LOG* */ 4126945a25Schristos u_int iplo_arg; 4226945a25Schristos char iplo_name[FR_GROUPLEN]; 4326945a25Schristos size_t iplo_size; /* sizeof struct at iplo_struct */ 4426945a25Schristos void *iplo_struct; 4526945a25Schristos } iplookupop_t; 4626945a25Schristos 4726945a25Schristos #define LOOKUP_ANON 0x80000000 4826945a25Schristos 4926945a25Schristos 5026945a25Schristos typedef struct iplookupflush { 5126945a25Schristos int iplf_type; /* IPLT_* */ 5226945a25Schristos int iplf_unit; /* IPL_LOG* */ 5326945a25Schristos u_int iplf_arg; 5426945a25Schristos u_int iplf_count; 5526945a25Schristos char iplf_name[FR_GROUPLEN]; 5626945a25Schristos } iplookupflush_t; 5726945a25Schristos 5826945a25Schristos typedef struct iplookuplink { 5926945a25Schristos int ipll_type; /* IPLT_* */ 6026945a25Schristos int ipll_unit; /* IPL_LOG* */ 6126945a25Schristos u_int ipll_num; 6226945a25Schristos char ipll_group[FR_GROUPLEN]; 6326945a25Schristos } iplookuplink_t; 6426945a25Schristos 6526945a25Schristos #define IPLT_ALL -1 6626945a25Schristos #define IPLT_NONE 0 6726945a25Schristos #define IPLT_POOL 1 6826945a25Schristos #define IPLT_HASH 2 6926945a25Schristos #define IPLT_DSTLIST 3 7026945a25Schristos 7126945a25Schristos 7226945a25Schristos #define IPLT_ANON 0x80000000 7326945a25Schristos 7426945a25Schristos 7526945a25Schristos typedef union { 7626945a25Schristos struct iplookupiterkey { 7726945a25Schristos u_char ilik_ival; 7826945a25Schristos u_char ilik_type; /* IPLT_* */ 7926945a25Schristos u_char ilik_otype; 8026945a25Schristos signed char ilik_unit; /* IPL_LOG* */ 8126945a25Schristos } ilik_unstr; 8226945a25Schristos u_32_t ilik_key; 8326945a25Schristos } iplookupiterkey_t; 8426945a25Schristos 8526945a25Schristos typedef struct ipflookupiter { 8626945a25Schristos int ili_nitems; 8726945a25Schristos iplookupiterkey_t ili_lkey; 8826945a25Schristos char ili_name[FR_GROUPLEN]; 8926945a25Schristos void *ili_data; 9026945a25Schristos } ipflookupiter_t; 9126945a25Schristos 9226945a25Schristos #define ili_key ili_lkey.ilik_key 9326945a25Schristos #define ili_ival ili_lkey.ilik_unstr.ilik_ival 9426945a25Schristos #define ili_unit ili_lkey.ilik_unstr.ilik_unit 9526945a25Schristos #define ili_type ili_lkey.ilik_unstr.ilik_type 9626945a25Schristos #define ili_otype ili_lkey.ilik_unstr.ilik_otype 9726945a25Schristos 9826945a25Schristos #define IPFLOOKUPITER_LIST 0 9926945a25Schristos #define IPFLOOKUPITER_NODE 1 10026945a25Schristos 10126945a25Schristos 10226945a25Schristos typedef struct ipf_lookup { 10326945a25Schristos int ipfl_type; 10426945a25Schristos void *(*ipfl_create) __P((ipf_main_softc_t *)); 10526945a25Schristos void (*ipfl_destroy) __P((ipf_main_softc_t *, void *)); 10626945a25Schristos int (*ipfl_init) __P((ipf_main_softc_t *, void *)); 10726945a25Schristos void (*ipfl_fini) __P((ipf_main_softc_t *, void *)); 10826945a25Schristos int (*ipfl_addr_find) __P((ipf_main_softc_t *, void *, 10926945a25Schristos int, void *, u_int)); 11026945a25Schristos size_t (*ipfl_flush) __P((ipf_main_softc_t *, void *, 11126945a25Schristos iplookupflush_t *)); 11226945a25Schristos int (*ipfl_iter_deref) __P((ipf_main_softc_t *, void *, 11326945a25Schristos int, int, void *)); 11426945a25Schristos int (*ipfl_iter_next) __P((ipf_main_softc_t *, void *, 11526945a25Schristos ipftoken_t *, ipflookupiter_t *)); 11626945a25Schristos int (*ipfl_node_add) __P((ipf_main_softc_t *, void *, 11726945a25Schristos iplookupop_t *, int)); 11826945a25Schristos int (*ipfl_node_del) __P((ipf_main_softc_t *, void *, 11926945a25Schristos iplookupop_t *, int)); 12026945a25Schristos int (*ipfl_stats_get) __P((ipf_main_softc_t *, void *, 12126945a25Schristos iplookupop_t *)); 12226945a25Schristos int (*ipfl_table_add) __P((ipf_main_softc_t *, void *, 12326945a25Schristos iplookupop_t *)); 12426945a25Schristos int (*ipfl_table_del) __P((ipf_main_softc_t *, void *, 12526945a25Schristos iplookupop_t *)); 12626945a25Schristos int (*ipfl_table_deref) __P((ipf_main_softc_t *, void *, void *)); 12726945a25Schristos void *(*ipfl_table_find) __P((void *, int, char *)); 12826945a25Schristos void *(*ipfl_select_add_ref) __P((void *, int, char *)); 12926945a25Schristos int (*ipfl_select_node) __P((fr_info_t *, void *, u_32_t *, 13026945a25Schristos frdest_t *)); 13126945a25Schristos void (*ipfl_expire) __P((ipf_main_softc_t *, void *)); 13226945a25Schristos void (*ipfl_sync) __P((ipf_main_softc_t *, void *)); 13326945a25Schristos } ipf_lookup_t; 13426945a25Schristos 13526945a25Schristos extern int ipf_lookup_init __P((void)); 13626945a25Schristos extern int ipf_lookup_ioctl __P((ipf_main_softc_t *, caddr_t, ioctlcmd_t, int, int, void *)); 13726945a25Schristos extern void ipf_lookup_main_unload __P((void)); 13826945a25Schristos extern void ipf_lookup_deref __P((ipf_main_softc_t *, int, void *)); 13926945a25Schristos extern void ipf_lookup_iterderef __P((ipf_main_softc_t *, u_32_t, void *)); 14026945a25Schristos extern void *ipf_lookup_res_name __P((ipf_main_softc_t *, int, u_int, char *, 14126945a25Schristos lookupfunc_t *)); 14226945a25Schristos extern void *ipf_lookup_res_num __P((ipf_main_softc_t *, int, u_int, u_int, 14326945a25Schristos lookupfunc_t *)); 14426945a25Schristos extern void ipf_lookup_soft_destroy __P((ipf_main_softc_t *, void *)); 14526945a25Schristos extern void *ipf_lookup_soft_create __P((ipf_main_softc_t *)); 14626945a25Schristos extern int ipf_lookup_soft_init __P((ipf_main_softc_t *, void *)); 14726945a25Schristos extern int ipf_lookup_soft_fini __P((ipf_main_softc_t *, void *)); 14826945a25Schristos extern void *ipf_lookup_find_htable __P((ipf_main_softc_t *, int, char *)); 14926945a25Schristos extern void ipf_lookup_expire __P((ipf_main_softc_t *)); 15026945a25Schristos extern void ipf_lookup_sync __P((ipf_main_softc_t *, void *)); 15126945a25Schristos #ifndef _KERNEL 15226945a25Schristos extern void ipf_lookup_dump __P((ipf_main_softc_t *, void *)); 15326945a25Schristos #endif 15426945a25Schristos #endif /* __IP_LOOKUP_H__ */ 155