xref: /freebsd/sys/netpfil/ipfilter/netinet/ip_scan.h (revision 29363fb446372cb3f10bc98664e9767c53fbb457)
1 /*
2  * Copyright (C) 2012 by Darren Reed.
3  *
4  * See the IPFILTER.LICENCE file for details on licencing.
5  * $Id$
6  */
7 
8 #ifndef __IP_SCAN_H__
9 #define __IP_SCAN_H__ 1
10 
11 #ifdef sun
12 # include <sys/ioccom.h>
13 #endif
14 
15 #define	IPSCAN_NAME	"/dev/ipscan"
16 #define	IPL_SCAN	IPSCAN_NAME
17 #define	ISC_TLEN	16
18 
19 
20 struct fr_info;
21 struct frentry;
22 struct ip;
23 struct ipstate;
24 
25 
26 # define	SIOCADSCA	_IOWR('r', 60, struct ipscan *)
27 # define	SIOCRMSCA	_IOWR('r', 61, struct ipscan *)
28 # define	SIOCGSCST	_IOWR('r', 62, struct ipscan *)
29 
30 struct	action	{
31 	int		act_val;	/* what to do */
32 	struct	in_addr	act_ip;		/* redirect IP# */
33 	u_short		act_port;	/* redirect port number */
34 	int		act_else;	/* what to do */
35 	struct	in_addr	act_eip;	/* redirect IP# */
36 	u_short		act_eport;	/* redirect port number */
37 };
38 
39 
40 typedef	struct	sinfo {
41 	char	s_txt[ISC_TLEN];	/* text to match */
42 	char	s_msk[ISC_TLEN];	/* mask of the above to check */
43 	int	s_len;			/* length of server text */
44 } sinfo_t;
45 
46 
47 typedef	struct	ipscan	{
48 	struct	ipscan	*ipsc_next;
49 	struct	ipscan	**ipsc_pnext;
50 	char		ipsc_tag[ISC_TLEN];	/* table entry protocol tag */
51 	sinfo_t		ipsc_si[2];	/* client/server side information */
52 	int		ipsc_hits;	/* times this has been matched */
53 	int		ipsc_active;	/* # of active matches */
54 	int		ipsc_fref;	/* # of references from filter rules */
55 	int		ipsc_sref;	/* # of references from state entries */
56 	struct	action	ipsc_act;
57 } ipscan_t;
58 
59 
60 #define	ipsc_cl		ipsc_si[0]
61 #define	ipsc_sl		ipsc_si[1]
62 #define	ipsc_ctxt	ipsc_cl.s_txt
63 #define	ipsc_cmsk	ipsc_cl.s_msk
64 #define	ipsc_clen	ipsc_cl.s_len
65 #define	ipsc_stxt	ipsc_sl.s_txt
66 #define	ipsc_smsk	ipsc_sl.s_msk
67 #define	ipsc_slen	ipsc_sl.s_len
68 #define	ipsc_action	ipsc_act.act_val
69 #define	ipsc_ip		ipsc_act.act_ip
70 #define	ipsc_port	ipsc_act.act_port
71 #define	ipsc_else	ipsc_act.act_else
72 #define	ipsc_eip	ipsc_act.act_eip
73 #define	ipsc_eport	ipsc_act.act_eport
74 
75 #define	ISC_A_NONE	0
76 #define	ISC_A_TRACK	1
77 #define	ISC_A_CLOSE	2
78 #define	ISC_A_REDIRECT	3
79 
80 
81 typedef	struct	ipscanstat	{
82 	struct	ipscan	*iscs_list;
83 	u_long		iscs_acted;
84 	u_long		iscs_else;
85 	int		iscs_entries;
86 } ipscanstat_t;
87 
88 
89 extern	int ipf_scan_ioctl(ipf_main_softc_t *, caddr_t, ioctlcmd_t, int, int, void *);
90 extern	int ipf_scan_init(void);
91 extern	int ipf_scan_attachis(struct ipstate *);
92 extern	int ipf_scan_attachfr(struct frentry *);
93 extern	int ipf_scan_detachis(struct ipstate *);
94 extern	int ipf_scan_detachfr(struct frentry *);
95 extern	int ipf_scan_packet(struct fr_info *, struct ipstate *);
96 extern	void ipf_scan_unload(ipf_main_softc_t *);
97 
98 #endif /* __IP_SCAN_H__ */
99