u_int16_t *, u_int32_t, u_int16_t); void			 pf_change_a(u_int32_t *, u_int16_t *, u_int32_t);
u_int16_t *, u_int32_t, u_int16_t, u_int8_t); void			 pf_change_a(u_int32_t *, u_int16_t *, u_int32_t, u_int8_t);
TAILQ_HEAD(pf_natqueue, pf_nat)		pf_nats[2];TAILQ_HEAD(pf_rdrqueue, pf_rdr)		pf_rdrs[2];struct pf_rulequeue	 pf_rules[2];struct pf_rulequeue	*pf_rules_active;struct pf_rulequeue	*pf_rules_inactive;struct pf_natqueue	*pf_nats_active;struct pf_natqueue	*pf_nats_inactive;struct pf_rdrqueue	*pf_rdrs_active;struct pf_rdrqueue	*pf_rdrs_inactive;struct pf_tree_node	*tree_lan_ext, *tree_ext_gwy;struct timeval		 pftv;struct pf_status	 pf_status;struct ifnet		*status_ifp;u_int32_t		 pf_last_purge;u_int32_t		 ticket_rules_active;u_int32_t		 ticket_rules_inactive;u_int32_t		 ticket_nats_active;u_int32_t		 ticket_nats_inactive;u_int32_t		 ticket_rdrs_active;u_int32_t		 ticket_rdrs_inactive;struct pf_port_list	 pf_tcp_ports;struct pf_port_list	 pf_udp_ports;/* Timeouts */int			 pftm_tcp_first_packet = 60;	/* First TCP packet */int			 pftm_tcp_opening = 30;		/* No response yet */int			 pftm_tcp_established = 24*60*60;  /* established  */int			 pftm_tcp_closing = 5 * 60;	/* Got a FIN */int			 pftm_tcp_fin_wait = 2 * 60;	/* Got both FINs */int			 pftm_tcp_closed = 1 * 60;	/* Got a RST */int			 pftm_udp_first_packet = 60;	/* First UDP packet */int			 pftm_udp_single = 30;		/* Unidirectional */int			 pftm_udp_multiple = 60;	/* Bidirectional */int			 pftm_icmp_first_packet = 20;	/* First ICMP packet */int			 pftm_icmp_error_reply = 10;	/* Got error response */int			 pftm_frag = 30;		/* Fragment expire */int			 pftm_interval = 10;		/* expire interval */int			*pftm_timeouts[PFTM_MAX] = { &pftm_tcp_first_packet,				&pftm_tcp_opening, &pftm_tcp_established,				&pftm_tcp_closing, &pftm_tcp_fin_wait,				&pftm_tcp_closed, &pftm_udp_first_packet,				&pftm_udp_single, &pftm_udp_multiple,				&pftm_icmp_first_packet, &pftm_icmp_error_reply,				&pftm_frag, &pftm_interval };struct pool		 pf_tree_pl, pf_rule_pl, pf_nat_pl, pf_sport_pl;struct pool		 pf_rdr_pl, pf_state_pl;int			 pf_tree_key_compare(struct pf_tree_key *,			    struct pf_tree_key *);int			 pf_compare_rules(struct pf_rule *,			    struct pf_rule *);int			 pf_compare_nats(struct pf_nat *, struct pf_nat *);int			 pf_compare_rdrs(struct pf_rdr *, struct pf_rdr *);void			 pf_tree_rotate_left(struct pf_tree_node **);void			 pf_tree_rotate_right(struct pf_tree_node **);struct pf_tree_node	*pf_tree_first(struct pf_tree_node *);struct pf_tree_node	*pf_tree_next(struct pf_tree_node *);struct pf_tree_node	*pf_tree_search(struct pf_tree_node *,			    struct pf_tree_key *);void			 pf_insert_state(struct pf_state *);void			 pf_purge_expired_states(void);void			 pf_print_host(u_int32_t, u_int16_t);void			 pf_print_state(struct pf_state *);void			 pf_print_flags(u_int8_t);void			 pfattach(int);int			 pfopen(dev_t, int, int, struct proc *);int			 pfclose(dev_t, int, int, struct proc *);int			 pfioctl(dev_t, u_long, caddr_t, int, struct proc *);u_int16_t		 pf_cksum_fixup(u_int16_t, u_int16_t, u_int16_t);void			 pf_change_ap(u_int32_t *, u_int16_t *, u_int16_t *,			    u_int16_t *, u_int32_t, u_int16_t);void			 pf_change_a(u_int32_t *, u_int16_t *, u_int32_t);void			 pf_change_icmp(u_int32_t *, u_int16_t *, u_int32_t *,			    u_int32_t, u_int16_t, u_int16_t *, u_int16_t *,			    u_int16_t *, u_int16_t *);void			 pf_send_reset(struct ip *, int, struct tcphdr *);void			 pf_send_icmp(struct mbuf *, u_int8_t, u_int8_t);u_int16_t		 pf_map_port_range(struct pf_rdr *, u_int16_t);struct pf_nat		*pf_get_nat(struct ifnet *, u_int8_t, u_int32_t,			    u_int32_t);struct pf_rdr		*pf_get_rdr(struct ifnet *, u_int8_t, u_int32_t,			    u_int32_t, u_int16_t);int			 pf_test_tcp(int, struct ifnet *, struct mbuf *,			    int, int, struct ip *, struct tcphdr *);int			 pf_test_udp(int, struct ifnet *, struct mbuf *,			    int, int, struct ip *, struct udphdr *);int			 pf_test_icmp(int, struct ifnet *, struct mbuf *,			    int, int, struct ip *, struct icmp *);int			 pf_test_other(int, struct ifnet *, struct mbuf *,			    struct ip *);int			 pf_test_state_tcp(struct pf_state **, int,			    struct ifnet *, struct mbuf *, int, int,			    struct ip *, struct tcphdr *);int			 pf_test_state_udp(struct pf_state **, int,			    struct ifnet *, struct mbuf *, int, int,			    struct ip *, struct udphdr *);int			 pf_test_state_icmp(struct pf_state **, int,			    struct ifnet *, struct mbuf *, int, int,			    struct ip *, struct icmp *);void			*pf_pull_hdr(struct mbuf *, int, void *, int,			    u_short *, u_short *);void			 pf_calc_skip_steps(struct pf_rulequeue *);int			 pf_get_sport(u_int8_t, u_int16_t, u_int16_t,			    u_int16_t *);void			 pf_put_sport(u_int8_t, u_int16_t);int			 pf_add_sport(struct pf_port_list *, u_int16_t);int			 pf_chk_sport(struct pf_port_list *, u_int16_t);int			 pf_normalize_tcp(int, struct ifnet *, struct mbuf *,			     int, int, struct ip *, struct tcphdr *);#if NPFLOG > 0#define	PFLOG_PACKET(x,a,b,c,d,e) \	do { \		HTONS((x)->ip_len); \		HTONS((x)->ip_off); \		pflog_packet(a,b,c,d,e); \		NTOHS((x)->ip_len); \		NTOHS((x)->ip_off); \	} while (0)#else#define	PFLOG_PACKET(x,a,b,c,d,e)	((void)0)#endif#define	STATE_TRANSLATE(s) \	((s)->lan.addr != (s)->gwy.addr || (s)->lan.port != (s)->gwy.port)intpf_tree_key_compare(struct pf_tree_key *a, struct pf_tree_key *b){	register int diff;	/*	 * could use memcmp(), but with the best manual order, we can	 * minimize the number of average compares. what is faster?	 */	if ((diff = a->proto - b->proto) != 0)		return (diff);	if (a->addr[0].s_addr > b->addr[0].s_addr)		return 1;	if (a->addr[0].s_addr < b->addr[0].s_addr)		return -1;	if (a->addr[1].s_addr > b->addr[1].s_addr)		return 1;	if (a->addr[1].s_addr < b->addr[1].s_addr)		return -1;	if ((diff = a->port[0] - b->port[0]) != 0)		return (diff);	if ((diff = a->port[1] - b->port[1]) != 0)		return (diff);	return (0);}