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