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