1/* IPFW backward compatibility */
2
3#ifndef _IP_FW_COMPAT_H_
4#define _IP_FW_COMPAT_H_
5
6/* prototypes */
7void	ipfw_convert_from_latest(struct ip_fw *curr_rule, void *old_rule, u_int32_t api_version, int is64user);
8int		ipfw_convert_to_latest(struct sockopt *sopt, struct ip_fw *rule, int api_version, int is64user);
9int	ipfw_get_command_and_version(struct sockopt *sopt, int *command, u_int32_t *api_version);
10
11
12/*
13 * ******************************
14 * ****** IPFW version one ******
15 * ******************************
16 */
17
18/*
19 * This union structure identifies an interface, either explicitly
20 * by name or implicitly by IP address. The flags IP_FW_F_IIFNAME
21 * and IP_FW_F_OIFNAME say how to interpret this structure. An
22 * interface unit number of -1 matches any unit number, while an
23 * IP address of 0.0.0.0 indicates matches any interface.
24 *
25 * The receive and transmit interfaces are only compared against the
26 * the packet if the corresponding bit (IP_FW_F_IIFACE or IP_FW_F_OIFACE)
27 * is set. Note some packets lack a receive or transmit interface
28 * (in which case the missing "interface" never matches).
29 */
30
31union ip_fw_if_compat {
32    struct in_addr fu_via_ip;	/* Specified by IP address */
33    struct {			/* Specified by interface name */
34#define FW_IFNLEN_COMPAT     10 /* need room ! was IFNAMSIZ */
35	    char  name[FW_IFNLEN_COMPAT];
36	    short unit;		/* -1 means match any unit */
37    } fu_via_if_compat;
38};
39
40/*
41 * Format of an IP firewall descriptor
42 *
43 * fw_src, fw_dst, fw_smsk, fw_dmsk are always stored in network byte order.
44 * fw_flg and fw_n*p are stored in host byte order (of course).
45 * Port numbers are stored in HOST byte order.
46 */
47
48
49struct ip_fw_compat {
50	u_int32_t version;		/* Version of this structure.  Should always be */
51							/* set to IP_FW_CURRENT_API_VERSION by clients. */
52	void *context;			/* Context that is usable by user processes to */
53							/* identify this rule. */
54    u_int64_t fw_pcnt,fw_bcnt;		/* Packet and byte counters */
55    struct in_addr fw_src, fw_dst;	/* Source and destination IP addr */
56    struct in_addr fw_smsk, fw_dmsk;	/* Mask for src and dest IP addr */
57    u_short fw_number;			/* Rule number */
58    u_int fw_flg;			/* Flags word */
59#define IP_FW_MAX_PORTS_COMPAT	10		/* A reasonable maximum */
60	union {
61		u_short fw_pts[IP_FW_MAX_PORTS_COMPAT];	/* Array of port numbers to match */
62#define IP_FW_ICMPTYPES_MAX_COMPAT	128
63#define IP_FW_ICMPTYPES_DIM_COMPAT	(IP_FW_ICMPTYPES_MAX_COMPAT / (sizeof(unsigned) * 8))
64		unsigned fw_icmptypes[IP_FW_ICMPTYPES_DIM_COMPAT]; /* ICMP types bitmap */
65	} fw_uar_compat;
66    u_int fw_ipflg;			/* IP flags word */
67    u_char fw_ipopt,fw_ipnopt;		/* IP options set/unset */
68    u_char fw_tcpopt,fw_tcpnopt;	/* TCP options set/unset */
69    u_char fw_tcpf,fw_tcpnf;		/* TCP flags set/unset */
70    long timestamp;			/* timestamp (tv_sec) of last match */
71    union ip_fw_if_compat fw_in_if, fw_out_if;	/* Incoming and outgoing interfaces */
72    union {
73		u_short fu_divert_port;		/* Divert/tee port (options IPDIVERT) */
74		u_short fu_pipe_nr;		/* queue number (option DUMMYNET) */
75		u_short fu_skipto_rule;		/* SKIPTO command rule number */
76		u_short fu_reject_code;		/* REJECT response code */
77		struct sockaddr_in fu_fwd_ip;
78    } fw_un_compat;
79    u_char fw_prot;			/* IP protocol */
80	/*
81	 * N'of src ports and # of dst ports in ports array (dst ports
82	 * follow src ports; max of 10 ports in all; count of 0 means
83	 * match all ports)
84	 */
85    u_char fw_nports;
86    void *pipe_ptr;                    /* flow_set ptr for dummynet pipe */
87    void *next_rule_ptr ;              /* next rule in case of match */
88    uid_t fw_uid;			/* uid to match */
89    int fw_logamount;			/* amount to log */
90    u_int64_t fw_loghighest;		/* highest number packet to log */
91};
92
93/*
94 * extended ipfw structure... some fields in the original struct
95 * can be used to pass parameters up/down, namely pointers
96 *     void *pipe_ptr
97 *     void *next_rule_ptr
98 * some others can be used to pass parameters down, namely counters etc.
99 *     u_int64_t fw_pcnt,fw_bcnt;
100 *     long timestamp;
101 */
102
103struct ip_fw_ext_compat {             /* extended structure */
104    struct ip_fw rule;      /* must be at offset 0 */
105    long    dont_match_prob;        /* 0x7fffffff means 1.0, always fail */
106    u_int   dyn_type;  /* type for dynamic rule */
107};
108
109struct ip_fw_chain_compat {
110	LIST_ENTRY(ip_fw_chain_compat) next;
111	struct ip_fw_compat *rule;
112};
113
114/*
115 * dynamic ipfw rule
116 */
117
118struct ipfw_dyn_rule_compat {
119    struct ipfw_dyn_rule *next ;
120
121    struct ipfw_flow_id id ;
122    struct ipfw_flow_id mask ;
123    struct ip_fw_chain_compat *chain ;		/* pointer to parent rule	*/
124    u_int32_t type ;			/* rule type			*/
125    u_int32_t expire ;			/* expire time			*/
126    u_int64_t pcnt, bcnt;		/* match counters		*/
127    u_int32_t bucket ;			/* which bucket in hash table	*/
128    u_int32_t state ;			/* state of this rule (typ. a   */
129					/* combination of TCP flags)	*/
130} ;
131
132#ifdef BSD_KERNEL_PRIVATE
133#pragma pack(4)
134
135struct ip_fw_compat_32 {
136	u_int32_t version;		/* Version of this structure.  Should always be */
137							/* set to IP_FW_CURRENT_API_VERSION by clients. */
138	user32_addr_t context;	/* Context that is usable by user processes to */
139							/* identify this rule. */
140    u_int64_t fw_pcnt,fw_bcnt;		/* Packet and byte counters */
141    struct in_addr fw_src, fw_dst;	/* Source and destination IP addr */
142    struct in_addr fw_smsk, fw_dmsk;/* Mask for src and dest IP addr */
143    u_short fw_number;		/* Rule number */
144    u_int fw_flg;			/* Flags word */
145#define IP_FW_MAX_PORTS_COMPAT	10		/* A reasonable maximum */
146	union {
147		u_short fw_pts[IP_FW_MAX_PORTS_COMPAT];	/* Array of port numbers to match */
148#define IP_FW_ICMPTYPES_MAX_COMPAT	128
149#define IP_FW_ICMPTYPES_DIM_COMPAT	(IP_FW_ICMPTYPES_MAX_COMPAT / (sizeof(unsigned) * 8))
150		unsigned fw_icmptypes[IP_FW_ICMPTYPES_DIM_COMPAT]; /* ICMP types bitmap */
151	} fw_uar_compat;
152    u_int fw_ipflg;			/* IP flags word */
153    u_char fw_ipopt,fw_ipnopt;		/* IP options set/unset */
154    u_char fw_tcpopt,fw_tcpnopt;	/* TCP options set/unset */
155    u_char fw_tcpf,fw_tcpnf;		/* TCP flags set/unset */
156    u_int32_t timestamp;			/* timestamp (tv_sec) of last match */
157    union ip_fw_if_compat fw_in_if, fw_out_if;	/* Incoming and outgoing interfaces */
158    union {
159		u_short fu_divert_port;		/* Divert/tee port (options IPDIVERT) */
160		u_short fu_pipe_nr;		/* queue number (option DUMMYNET) */
161		u_short fu_skipto_rule;		/* SKIPTO command rule number */
162		u_short fu_reject_code;		/* REJECT response code */
163		struct sockaddr_in fu_fwd_ip;
164    } fw_un_compat;
165    u_char fw_prot;			/* IP protocol */
166	/*
167	 * N'of src ports and # of dst ports in ports array (dst ports
168	 * follow src ports; max of 10 ports in all; count of 0 means
169	 * match all ports)
170	 */
171    u_char fw_nports;
172    user32_addr_t pipe_ptr;                    /* flow_set ptr for dummynet pipe */
173    user32_addr_t next_rule_ptr ;              /* next rule in case of match */
174    uid_t fw_uid;			/* uid to match */
175    int fw_logamount;			/* amount to log */
176    u_int64_t fw_loghighest;		/* highest number packet to log */
177};
178#pragma pack()
179
180struct ip_fw_compat_64 {
181	u_int32_t version;		/* Version of this structure.  Should always be */
182							/* set to IP_FW_CURRENT_API_VERSION by clients. */
183	user64_addr_t context;			/* Context that is usable by user processes to */
184									/* identify this rule. */
185    u_int64_t fw_pcnt,fw_bcnt;		/* Packet and byte counters */
186    struct in_addr fw_src, fw_dst;	/* Source and destination IP addr */
187    struct in_addr fw_smsk, fw_dmsk;/* Mask for src and dest IP addr */
188    u_short fw_number;				/* Rule number */
189    u_int fw_flg;					/* Flags word */
190#define IP_FW_MAX_PORTS_COMPAT	10		/* A reasonable maximum */
191	union {
192		u_short fw_pts[IP_FW_MAX_PORTS_COMPAT];	/* Array of port numbers to match */
193#define IP_FW_ICMPTYPES_MAX_COMPAT	128
194#define IP_FW_ICMPTYPES_DIM_COMPAT	(IP_FW_ICMPTYPES_MAX_COMPAT / (sizeof(unsigned) * 8))
195		unsigned fw_icmptypes[IP_FW_ICMPTYPES_DIM_COMPAT]; /* ICMP types bitmap */
196	} fw_uar_compat;
197    u_int fw_ipflg;					/* IP flags word */
198    u_char fw_ipopt,fw_ipnopt;		/* IP options set/unset */
199    u_char fw_tcpopt,fw_tcpnopt;	/* TCP options set/unset */
200    u_char fw_tcpf,fw_tcpnf;		/* TCP flags set/unset */
201    u_int64_t timestamp;			/* timestamp (tv_sec) of last match */
202    union ip_fw_if_compat fw_in_if, fw_out_if;	/* Incoming and outgoing interfaces */
203    union {
204		u_short fu_divert_port;		/* Divert/tee port (options IPDIVERT) */
205		u_short fu_pipe_nr;			/* queue number (option DUMMYNET) */
206		u_short fu_skipto_rule;		/* SKIPTO command rule number */
207		u_short fu_reject_code;		/* REJECT response code */
208		struct sockaddr_in fu_fwd_ip;
209    } fw_un_compat;
210    u_char fw_prot;			/* IP protocol */
211	/*
212	 * N'of src ports and # of dst ports in ports array (dst ports
213	 * follow src ports; max of 10 ports in all; count of 0 means
214	 * match all ports)
215	 */
216    u_char fw_nports;
217    user64_addr_t pipe_ptr;                    /* flow_set ptr for dummynet pipe */
218    user64_addr_t next_rule_ptr ;              /* next rule in case of match */
219    uid_t fw_uid;								/* uid to match */
220    int fw_logamount;							/* amount to log */
221    u_int64_t fw_loghighest;					/* highest number packet to log */
222};
223
224struct ipfw_dyn_rule_compat_32 {
225    user32_addr_t next ;
226
227    struct ipfw_flow_id id ;
228    struct ipfw_flow_id mask ;
229    user32_addr_t chain ;		/* pointer to parent rule	*/
230    u_int32_t type ;			/* rule type			*/
231    u_int32_t expire ;			/* expire time			*/
232    u_int64_t pcnt, bcnt;		/* match counters		*/
233    u_int32_t bucket ;			/* which bucket in hash table	*/
234    u_int32_t state ;			/* state of this rule (typ. a   */
235					/* combination of TCP flags)	*/
236} ;
237
238struct ipfw_dyn_rule_compat_64 {
239    user64_addr_t next ;
240
241    struct ipfw_flow_id id ;
242    struct ipfw_flow_id mask ;
243    user64_addr_t chain ;		/* pointer to parent rule	*/
244    u_int32_t type ;			/* rule type			*/
245    u_int32_t expire ;			/* expire time			*/
246    u_int64_t pcnt, bcnt;		/* match counters		*/
247    u_int32_t bucket ;			/* which bucket in hash table	*/
248    u_int32_t state ;			/* state of this rule (typ. a   */
249					/* combination of TCP flags)	*/
250} ;
251#endif /* BSD_KERNEL_PRIVATE */
252
253
254#define IP_FW_GETNSRCP_COMPAT(rule)		((rule)->fw_nports & 0x0f)
255#define IP_FW_SETNSRCP_COMPAT(rule, n)		do {				\
256					  (rule)->fw_nports &= ~0x0f;	\
257					  (rule)->fw_nports |= (n);	\
258					} while (0)
259#define IP_FW_GETNDSTP_COMPAT(rule)		((rule)->fw_nports >> 4)
260#define IP_FW_SETNDSTP_COMPAT(rule, n)		do {				\
261					  (rule)->fw_nports &= ~0xf0;	\
262					  (rule)->fw_nports |= (n) << 4;\
263					} while (0)
264
265#define fw_divert_port_compat	fw_un_compat.fu_divert_port
266#define fw_skipto_rule_compat	fw_un_compat.fu_skipto_rule
267#define fw_reject_code_compat	fw_un_compat.fu_reject_code
268#define fw_pipe_nr_compat	fw_un_compat.fu_pipe_nr
269#define fw_fwd_ip_compat	fw_un_compat.fu_fwd_ip
270
271/*
272 * Values for "flags" field .
273 */
274#define IP_FW_F_COMMAND_COMPAT 0x000000ff	/* Mask for type of chain entry:	*/
275#define IP_FW_F_DENY_COMPAT	0x00000000	/* This is a deny rule			*/
276#define IP_FW_F_REJECT_COMPAT	0x00000001	/* Deny and send a response packet	*/
277#define IP_FW_F_ACCEPT_COMPAT	0x00000002	/* This is an accept rule		*/
278#define IP_FW_F_COUNT_COMPAT	0x00000003	/* This is a count rule			*/
279#define IP_FW_F_DIVERT_COMPAT	0x00000004	/* This is a divert rule		*/
280#define IP_FW_F_TEE_COMPAT	0x00000005	/* This is a tee rule			*/
281#define IP_FW_F_SKIPTO_COMPAT	0x00000006	/* This is a skipto rule		*/
282#define IP_FW_F_FWD_COMPAT	0x00000007	/* This is a "change forwarding address" rule */
283#define IP_FW_F_PIPE_COMPAT	0x00000008	/* This is a dummynet rule */
284#define IP_FW_F_QUEUE_COMPAT	0x00000009	/* This is a dummynet queue */
285
286#define IP_FW_F_IN_COMPAT	0x00000100	/* Check inbound packets		*/
287#define IP_FW_F_OUT_COMPAT	0x00000200	/* Check outbound packets		*/
288#define IP_FW_F_IIFACE_COMPAT	0x00000400	/* Apply inbound interface test		*/
289#define IP_FW_F_OIFACE_COMPAT	0x00000800	/* Apply outbound interface test	*/
290
291#define IP_FW_F_PRN_COMPAT	0x00001000	/* Print if this rule matches		*/
292
293#define IP_FW_F_SRNG_COMPAT	0x00002000	/* The first two src ports are a min	*
294					 * and max range (stored in host byte	*
295					 * order).				*/
296
297#define IP_FW_F_DRNG_COMPAT	0x00004000	/* The first two dst ports are a min	*
298					 * and max range (stored in host byte	*
299					 * order).				*/
300
301#define IP_FW_F_FRAG_COMPAT	0x00008000	/* Fragment				*/
302
303#define IP_FW_F_IIFNAME_COMPAT	0x00010000	/* In interface by name/unit (not IP)	*/
304#define IP_FW_F_OIFNAME_COMPAT	0x00020000	/* Out interface by name/unit (not IP)	*/
305
306#define IP_FW_F_INVSRC_COMPAT	0x00040000	/* Invert sense of src check		*/
307#define IP_FW_F_INVDST_COMPAT	0x00080000	/* Invert sense of dst check		*/
308
309#define IP_FW_F_ICMPBIT_COMPAT 0x00100000	/* ICMP type bitmap is valid		*/
310
311#define IP_FW_F_UID_COMPAT	0x00200000	/* filter by uid			*/
312
313#define IP_FW_F_RND_MATCH_COMPAT 0x00800000	/* probabilistic rule match		*/
314#define IP_FW_F_SMSK_COMPAT	0x01000000	/* src-port + mask 			*/
315#define IP_FW_F_DMSK_COMPAT	0x02000000	/* dst-port + mask 			*/
316#define	IP_FW_BRIDGED_COMPAT	0x04000000	/* only match bridged packets		*/
317#define IP_FW_F_KEEP_S_COMPAT	0x08000000	/* keep state	 			*/
318#define IP_FW_F_CHECK_S_COMPAT	0x10000000	/* check state	 			*/
319
320#define IP_FW_F_SME_COMPAT	0x20000000	/* source = me				*/
321#define IP_FW_F_DME_COMPAT	0x40000000	/* destination = me			*/
322
323#define IP_FW_F_MASK_COMPAT	0x7FFFFFFF	/* All possible flag bits mask		*/
324
325/*
326 * Flags for the 'fw_ipflg' field, for comparing values of ip and its protocols.
327 */
328#define	IP_FW_IF_TCPEST_COMPAT	0x00000020	/* established TCP connection */
329#define	IP_FW_IF_TCPMSK_COMPAT	0x00000020	/* mask of all TCP values */
330
331/*
332 * Definitions for TCP flags.
333 */
334#define IP_FW_TCPF_FIN_COMPAT		TH_FIN
335#define IP_FW_TCPF_SYN_COMPAT		TH_SYN
336#define IP_FW_TCPF_RST_COMPAT		TH_RST
337#define IP_FW_TCPF_PSH_COMPAT		TH_PUSH
338#define IP_FW_TCPF_ACK_COMPAT		TH_ACK
339#define IP_FW_TCPF_URG_COMPAT		TH_URG
340
341/*
342 * For backwards compatibility with rules specifying "via iface" but
343 * not restricted to only "in" or "out" packets, we define this combination
344 * of bits to represent this configuration.
345 */
346
347#define IF_FW_F_VIAHACK_COMPAT	(IP_FW_F_IN_COMPAT|IP_FW_F_OUT_COMPAT|IP_FW_F_IIFACE_COMPAT|IP_FW_F_OIFACE_COMPAT)
348
349/*
350 * Definitions for REJECT response codes.
351 * Values less than 256 correspond to ICMP unreachable codes.
352 */
353#define IP_FW_REJECT_RST_COMPAT	0x0100		/* TCP packets: send RST */
354
355
356/*
357 * ******************************
358 * ****** IPFW version zero *****
359 * ******************************
360 */
361
362/*
363 * This union structure identifies an interface, either explicitly
364 * by name or implicitly by IP address. The flags IP_FW_F_IIFNAME
365 * and IP_FW_F_OIFNAME say how to interpret this structure. An
366 * interface unit number of -1 matches any unit number, while an
367 * IP address of 0.0.0.0 indicates matches any interface.
368 *
369 * The receive and transmit interfaces are only compared against the
370 * the packet if the corresponding bit (IP_FW_F_IIFACE or IP_FW_F_OIFACE)
371 * is set. Note some packets lack a receive or transmit interface
372 * (in which case the missing "interface" never matches).
373 */
374
375union ip_old_fw_if {
376    struct in_addr fu_via_ip;	/* Specified by IP address */
377    struct {			/* Specified by interface name */
378#define OLD_FW_IFNLEN     10 /* need room ! was IFNAMSIZ */
379	    char  name[OLD_FW_IFNLEN];
380	    short unit;		/* -1 means match any unit */
381    } fu_via_if;
382};
383
384/*
385 * Format of an IP firewall descriptor
386 *
387 * fw_src, fw_dst, fw_smsk, fw_dmsk are always stored in network byte order.
388 * fw_flg and fw_n*p are stored in host byte order (of course).
389 * Port numbers are stored in HOST byte order.
390 * Warning: setsockopt() will fail if sizeof(struct ip_fw) > MLEN (108)
391 */
392
393struct ip_old_fw {
394    u_int64_t fw_pcnt,fw_bcnt;		/* Packet and byte counters */
395    struct in_addr fw_src, fw_dst;	/* Source and destination IP addr */
396    struct in_addr fw_smsk, fw_dmsk;	/* Mask for src and dest IP addr */
397    u_short fw_number;			/* Rule number */
398    u_int fw_flg;			/* Flags word */
399#define IP_OLD_FW_MAX_PORTS	10		/* A reasonable maximum */
400	union {
401	u_short fw_pts[IP_OLD_FW_MAX_PORTS];	/* Array of port numbers to match */
402#define IP_OLD_FW_ICMPTYPES_MAX	128
403#define IP_OLD_FW_ICMPTYPES_DIM	(IP_OLD_FW_ICMPTYPES_MAX / (sizeof(unsigned) * 8))
404	unsigned fw_icmptypes[IP_OLD_FW_ICMPTYPES_DIM]; /* ICMP types bitmap */
405	} fw_uar;
406    u_char fw_ipopt,fw_ipnopt;		/* IP options set/unset */
407    u_char fw_tcpf,fw_tcpnf;		/* TCP flags set/unset */
408    long timestamp;			/* timestamp (tv_sec) of last match */
409    union ip_old_fw_if fw_in_if, fw_out_if;	/* Incoming and outgoing interfaces */
410    union {
411	u_short fu_divert_port;		/* Divert/tee port (options IPDIVERT) */
412	u_short fu_pipe_nr;		/* pipe number (option DUMMYNET) */
413	u_short fu_skipto_rule;		/* SKIPTO command rule number */
414	u_short fu_reject_code;		/* REJECT response code */
415	struct sockaddr_in fu_fwd_ip;
416    } fw_un;
417    u_char fw_prot;			/* IP protocol */
418    u_char fw_nports;			/* N'of src ports and # of dst ports */
419					/* in ports array (dst ports follow */
420					/* src ports; max of 10 ports in all; */
421					/* count of 0 means match all ports) */
422    void *pipe_ptr;                    /* Pipe ptr in case of dummynet pipe */
423    void *next_rule_ptr ;              /* next rule in case of match */
424};
425
426#define IP_OLD_FW_GETNSRCP(rule)		((rule)->fw_nports & 0x0f)
427#define IP_OLD_FW_SETNSRCP(rule, n)		do {				\
428					  (rule)->fw_nports &= ~0x0f;	\
429					  (rule)->fw_nports |= (n);	\
430					} while (0)
431#define IP_OLD_FW_GETNDSTP(rule)		((rule)->fw_nports >> 4)
432#define IP_OLD_FW_SETNDSTP(rule, n)		do {				\
433					  (rule)->fw_nports &= ~0xf0;	\
434					  (rule)->fw_nports |= (n) << 4;\
435					} while (0)
436
437#define old_fw_divert_port	fw_un.fu_divert_port
438#define old_fw_skipto_rule	fw_un.fu_skipto_rule
439#define old_fw_reject_code	fw_un.fu_reject_code
440#define old_fw_pipe_nr	fw_un.fu_pipe_nr
441#define old_fw_fwd_ip	fw_un.fu_fwd_ip
442
443/*
444 * Values for "flags" field .
445 */
446#define IP_OLD_FW_F_COMMAND 0x000000ff	/* Mask for type of chain entry:	*/
447#define IP_OLD_FW_F_DENY	0x00000000	/* This is a deny rule			*/
448#define IP_OLD_FW_F_REJECT	0x00000001	/* Deny and send a response packet	*/
449#define IP_OLD_FW_F_ACCEPT	0x00000002	/* This is an accept rule		*/
450#define IP_OLD_FW_F_COUNT	0x00000003	/* This is a count rule			*/
451#define IP_OLD_FW_F_DIVERT	0x00000004	/* This is a divert rule		*/
452#define IP_OLD_FW_F_TEE	0x00000005	/* This is a tee rule			*/
453#define IP_OLD_FW_F_SKIPTO	0x00000006	/* This is a skipto rule		*/
454#define IP_OLD_FW_F_FWD	0x00000007	/* This is a "change forwarding address" rule */
455#define IP_OLD_FW_F_PIPE	0x00000008	/* This is a dummynet rule */
456
457#define IP_OLD_FW_F_IN	0x00000100	/* Check inbound packets		*/
458#define IP_OLD_FW_F_OUT	0x00000200	/* Check outbound packets		*/
459#define IP_OLD_FW_F_IIFACE	0x00000400	/* Apply inbound interface test		*/
460#define IP_OLD_FW_F_OIFACE	0x00000800	/* Apply outbound interface test	*/
461
462#define IP_OLD_FW_F_PRN	0x00001000	/* Print if this rule matches		*/
463
464#define IP_OLD_FW_F_SRNG	0x00002000	/* The first two src ports are a min	*
465					 * and max range (stored in host byte	*
466					 * order).				*/
467
468#define IP_OLD_FW_F_DRNG	0x00004000	/* The first two dst ports are a min	*
469					 * and max range (stored in host byte	*
470					 * order).				*/
471
472#define IP_OLD_FW_F_FRAG	0x00008000	/* Fragment				*/
473
474#define IP_OLD_FW_F_IIFNAME	0x00010000	/* In interface by name/unit (not IP)	*/
475#define IP_OLD_FW_F_OIFNAME	0x00020000	/* Out interface by name/unit (not IP)	*/
476
477#define IP_OLD_FW_F_INVSRC	0x00040000	/* Invert sense of src check		*/
478#define IP_OLD_FW_F_INVDST	0x00080000	/* Invert sense of dst check		*/
479
480#define IP_OLD_FW_F_ICMPBIT 0x00100000	/* ICMP type bitmap is valid		*/
481
482#define IP_OLD_FW_F_MASK	0x001FFFFF	/* All possible flag bits mask		*/
483
484/*
485 * For backwards compatibility with rules specifying "via iface" but
486 * not restricted to only "in" or "out" packets, we define this combination
487 * of bits to represent this configuration.
488 */
489
490#define IF_OLD_FW_F_VIAHACK	(IP_OLD_FW_F_IN|IP_OLD_FW_F_OUT|IP_OLD_FW_F_IIFACE|IP_OLD_FW_F_OIFACE)
491
492/*
493 * Definitions for TCP flags - abridged
494 */
495#define IP_OLD_FW_TCPF_ESTAB	0x40
496
497#endif /* _IP_FW_COMPAT_H_ */
498