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