require '_h2ph_pre.ph';

unless(defined(&_NET_PFVAR_H_)) {
    eval 'sub _NET_PFVAR_H_ () {1;}' unless defined(&_NET_PFVAR_H_);
    require 'sys/types.ph';
    require 'sys/queue.ph';
    eval("sub PF_IN () { 0; }") unless defined(&PF_IN);
    eval("sub PF_OUT () { 1; }") unless defined(&PF_OUT);
    eval("sub PF_PASS () { 0; }") unless defined(&PF_PASS);
    eval("sub PF_DROP () { 1; }") unless defined(&PF_DROP);
    eval("sub PF_SCRUB () { 2; }") unless defined(&PF_SCRUB);
    eval("sub PF_OP_IRG () { 1; }") unless defined(&PF_OP_IRG);
    eval("sub PF_OP_EQ () { 2; }") unless defined(&PF_OP_EQ);
    eval("sub PF_OP_NE () { 3; }") unless defined(&PF_OP_NE);
    eval("sub PF_OP_LT () { 4; }") unless defined(&PF_OP_LT);
    eval("sub PF_OP_LE () { 5; }") unless defined(&PF_OP_LE);
    eval("sub PF_OP_GT () { 6; }") unless defined(&PF_OP_GT);
    eval("sub PF_OP_GE () { 7; }") unless defined(&PF_OP_GE);
    eval("sub PF_OP_XRG () { 8; }") unless defined(&PF_OP_XRG);
    eval("sub PF_DEBUG_NONE () { 0; }") unless defined(&PF_DEBUG_NONE);
    eval("sub PF_DEBUG_URGENT () { 1; }") unless defined(&PF_DEBUG_URGENT);
    eval("sub PF_DEBUG_MISC () { 2; }") unless defined(&PF_DEBUG_MISC);
    eval("sub PF_CHANGE_ADD_HEAD () { 1; }") unless defined(&PF_CHANGE_ADD_HEAD);
    eval("sub PF_CHANGE_ADD_TAIL () { 2; }") unless defined(&PF_CHANGE_ADD_TAIL);
    eval("sub PF_CHANGE_ADD_BEFORE () { 3; }") unless defined(&PF_CHANGE_ADD_BEFORE);
    eval("sub PF_CHANGE_ADD_AFTER () { 4; }") unless defined(&PF_CHANGE_ADD_AFTER);
    eval("sub PF_CHANGE_REMOVE () { 5; }") unless defined(&PF_CHANGE_REMOVE);
    eval("sub PFTM_TCP_FIRST_PACKET () { 0; }") unless defined(&PFTM_TCP_FIRST_PACKET);
    eval("sub PFTM_TCP_OPENING () { 1; }") unless defined(&PFTM_TCP_OPENING);
    eval("sub PFTM_TCP_ESTABLISHED () { 2; }") unless defined(&PFTM_TCP_ESTABLISHED);
    eval("sub PFTM_TCP_CLOSING () { 3; }") unless defined(&PFTM_TCP_CLOSING);
    eval("sub PFTM_TCP_FIN_WAIT () { 4; }") unless defined(&PFTM_TCP_FIN_WAIT);
    eval("sub PFTM_TCP_CLOSED () { 5; }") unless defined(&PFTM_TCP_CLOSED);
    eval("sub PFTM_UDP_FIRST_PACKET () { 6; }") unless defined(&PFTM_UDP_FIRST_PACKET);
    eval("sub PFTM_UDP_SINGLE () { 7; }") unless defined(&PFTM_UDP_SINGLE);
    eval("sub PFTM_UDP_MULTIPLE () { 8; }") unless defined(&PFTM_UDP_MULTIPLE);
    eval("sub PFTM_ICMP_FIRST_PACKET () { 9; }") unless defined(&PFTM_ICMP_FIRST_PACKET);
    eval("sub PFTM_ICMP_ERROR_REPLY () { 10; }") unless defined(&PFTM_ICMP_ERROR_REPLY);
    eval("sub PFTM_FRAG () { 11; }") unless defined(&PFTM_FRAG);
    eval("sub PFTM_INTERVAL () { 12; }") unless defined(&PFTM_INTERVAL);
    eval("sub PFTM_MAX () { 13; }") unless defined(&PFTM_MAX);
    eval 'sub v4 () { ($pfa->{v4});}' unless defined(&v4);
    eval 'sub v6 () { ($pfa->{v6});}' unless defined(&v6);
    eval 'sub addr8 () { ($pfa->{addr8});}' unless defined(&addr8);
    eval 'sub addr16 () { ($pfa->{addr16});}' unless defined(&addr16);
    eval 'sub addr32 () { ($pfa->{addr32});}' unless defined(&addr32);
    if(defined(&_KERNEL)) {
	if(defined(&INET)) {
	    unless(defined(&INET6)) {
		eval 'sub PF_INET_ONLY () {1;}' unless defined(&PF_INET_ONLY);
	    }
	}
	if(defined(&INET6)) {
	    unless(defined(&INET)) {
		eval 'sub PF_INET6_ONLY () {1;}' unless defined(&PF_INET6_ONLY);
	    }
	}
	if(defined(&INET)) {
	    if(defined(&INET6)) {
		eval 'sub PF_INET_INET6 () {1;}' unless defined(&PF_INET_INET6);
	    }
	}
    } else {
	eval 'sub PF_INET_INET6 () {1;}' unless defined(&PF_INET_INET6);
    }
    if(defined(&PF_INET_INET6)) {
	eval 'sub PF_AEQ {
	    local($a, $b, $c) = @_;
    	    eval q((($c ==  &AF_INET  && ($a)-> $addr32[0] == ($b)-> $addr32[0]) || ($c ==  &AF_INET6  && ($a)-> $addr32[0] == ($b)-> $addr32[0]  && ($a)-> $addr32[1] == ($b)-> $addr32[1]  && ($a)-> $addr32[2] == ($b)-> $addr32[2]  && ($a)-> $addr32[3] == ($b)-> $addr32[3])));
	}' unless defined(&PF_AEQ);
	eval 'sub PF_ANEQ {
	    local($a, $b, $c) = @_;
    	    eval q((($c ==  &AF_INET  && ($a)-> $addr32[0] != ($b)-> $addr32[0]) || ($c ==  &AF_INET6  && (($a)-> $addr32[0] != ($b)-> $addr32[0] || ($a)-> $addr32[1] != ($b)-> $addr32[1] || ($a)-> $addr32[2] != ($b)-> $addr32[2] || ($a)-> $addr32[3] != ($b)-> $addr32[3]))));
	}' unless defined(&PF_ANEQ);
	eval 'sub PF_AZERO {
	    local($a, $c) = @_;
    	    eval q((($c ==  &AF_INET  && !($a)-> $addr32[0]) || ($c ==  &AF_INET6  && !($a)-> $addr32[0]  && !($a)-> $addr32[1]  && !($a)-> $addr32[2]  && !($a)-> $addr32[3] )));
	}' unless defined(&PF_AZERO);
	eval 'sub PF_MATCHA {
	    local($n, $a, $m, $b, $f) = @_;
    	    eval q( &pf_match_addr($n, $a, $m, $b, $f));
	}' unless defined(&PF_MATCHA);
	eval 'sub PF_ACPY {
	    local($a, $b, $f) = @_;
    	    eval q( &pf_addrcpy($a, $b, $f));
	}' unless defined(&PF_ACPY);
    } else {
	if(defined(&PF_INET6_ONLY)) {
	    eval 'sub PF_AEQ {
	        local($a, $b, $c) = @_;
    		eval q((($a)-> $addr32[0] == ($b)-> $addr32[0]  && ($a)-> $addr32[1] == ($b)-> $addr32[1]  && ($a)-> $addr32[2] == ($b)-> $addr32[2]  && ($a)-> $addr32[3] == ($b)-> $addr32[3]));
	    }' unless defined(&PF_AEQ);
	    eval 'sub PF_ANEQ {
	        local($a, $b, $c) = @_;
    		eval q((($a)-> $addr32[0] != ($b)-> $addr32[0] || ($a)-> $addr32[1] != ($b)-> $addr32[1] || ($a)-> $addr32[2] != ($b)-> $addr32[2] || ($a)-> $addr32[3] != ($b)-> $addr32[3]));
	    }' unless defined(&PF_ANEQ);
	    eval 'sub PF_AZERO {
	        local($a, $c) = @_;
    		eval q((!($a)-> $addr32[0]  && !($a)-> $addr32[1]  && !($a)-> $addr32[2]  && !($a)-> $addr32[3] ));
	    }' unless defined(&PF_AZERO);
	    eval 'sub PF_MATCHA {
	        local($n, $a, $m, $b, $f) = @_;
    		eval q( &pf_match_addr($n, $a, $m, $b, $f));
	    }' unless defined(&PF_MATCHA);
	    eval 'sub PF_ACPY {
	        local($a, $b, $f) = @_;
    		eval q( &pf_addrcpy($a, $b, $f));
	    }' unless defined(&PF_ACPY);
	} else {
	    if(defined(&PF_INET_ONLY)) {
		eval 'sub PF_AEQ {
		    local($a, $b, $c) = @_;
    		    eval q((($a)-> $addr32[0] == ($b)-> $addr32[0]));
		}' unless defined(&PF_AEQ);
		eval 'sub PF_ANEQ {
		    local($a, $b, $c) = @_;
    		    eval q((($a)-> $addr32[0] != ($b)-> $addr32[0]));
		}' unless defined(&PF_ANEQ);
		eval 'sub PF_AZERO {
		    local($a, $c) = @_;
    		    eval q((!($a)-> $addr32[0]));
		}' unless defined(&PF_AZERO);
		eval 'sub PF_MATCHA {
		    local($n, $a, $m, $b, $f) = @_;
    		    eval q( &pf_match_addr($n, $a, $m, $b, $f));
		}' unless defined(&PF_MATCHA);
		eval 'sub PF_ACPY {
		    local($a, $b, $f) = @_;
    		    eval q(($a)-> ($v4->{s_addr}) = ($b)-> ($v4->{s_addr}));
		}' unless defined(&PF_ACPY);
	    }
	}
    }
    eval 'sub PF_STATE_NORMAL () {0x1;}' unless defined(&PF_STATE_NORMAL);
    eval 'sub PF_STATE_MODULATE () {0x2;}' unless defined(&PF_STATE_MODULATE);
    eval 'sub PFRULE_RETURNRST () {0x01;}' unless defined(&PFRULE_RETURNRST);
    eval 'sub PFRULE_NODF () {0x02;}' unless defined(&PFRULE_NODF);
    eval 'sub MATCH_TUPLE {
        local($h,$r,$d,$i,$a) = @_;
	    eval q(( ( ($r->{d$irection}) == $d)  && ( ($r->{ifp}) ==  &NULL ||  ($r->{ifp}) == $i)  && (! ($r->{p$roto}) ||  ($r->{p$roto}) ==  ($h->{ip_p}))  && (! ($r->{s$rc}->{m$ask}->{a$ddr32[0]}) ||  &pf_match_addr( ($r->{s$rc}->{not}), ($r)-> ($s$rc->{a$ddr}), ($r)-> ($s$rc->{m$ask}),  ($h->{ip_src}->{s_addr}), $a))  && (! ($r->{dst}->{m$ask}->{a$ddr32[0]}) ||  &pf_match_addr( ($r->{dst}->{not}), ($r)-> ($dst->{a$ddr}), ($r)-> ($dst->{m$ask}),  ($h->{ip_dst}->{s_addr}), $a)) ));
    }' unless defined(&MATCH_TUPLE);
    if(defined(&INET6)) {
    }
    eval 'sub PF_DPORT_RANGE () {0x01;}' unless defined(&PF_DPORT_RANGE);
    eval 'sub PF_RPORT_RANGE () {0x02;}' unless defined(&PF_RPORT_RANGE);
    eval 'sub PFRES_MATCH () {0;}' unless defined(&PFRES_MATCH);
    eval 'sub PFRES_BADOFF () {1;}' unless defined(&PFRES_BADOFF);
    eval 'sub PFRES_FRAG () {2;}' unless defined(&PFRES_FRAG);
    eval 'sub PFRES_SHORT () {3;}' unless defined(&PFRES_SHORT);
    eval 'sub PFRES_NORM () {4;}' unless defined(&PFRES_NORM);
    eval 'sub PFRES_MEMORY () {5;}' unless defined(&PFRES_MEMORY);
    eval 'sub PFRES_MAX () {6;}' unless defined(&PFRES_MAX);
    eval 'sub PFRES_NAMES () {{ "match", "bad-offset", "fragment", "short", "normalize", "memory",  &NULL };}' unless defined(&PFRES_NAMES);
    eval 'sub FCNT_STATE_SEARCH () {0;}' unless defined(&FCNT_STATE_SEARCH);
    eval 'sub FCNT_STATE_INSERT () {1;}' unless defined(&FCNT_STATE_INSERT);
    eval 'sub FCNT_STATE_REMOVALS () {2;}' unless defined(&FCNT_STATE_REMOVALS);
    eval 'sub FCNT_MAX () {3;}' unless defined(&FCNT_MAX);
    eval 'sub FCNT_NAMES () {{ "state searches", "state inserts", "state removals",  &NULL };}' unless defined(&FCNT_NAMES);
    eval 'sub ACTION_SET {
        local($a, $x) = @_;
	    eval q( &do {  &if (($a) !=  &NULL) *($a) = ($x); }  &while (0));
    }' unless defined(&ACTION_SET);
    eval 'sub REASON_SET {
        local($a, $x) = @_;
	    eval q( &do {  &if (($a) !=  &NULL) *($a) = ($x);  &if ($x <  &PFRES_MAX)  ($pf_status->{counters[$x]})++; }  &while (0));
    }' unless defined(&REASON_SET);
    eval 'sub ps_buf () { ($ps_u->{psu_buf});}' unless defined(&ps_buf);
    eval 'sub ps_states () { ($ps_u->{psu_states});}' unless defined(&ps_states);
    eval 'sub DIOCSTART () { &_IO (ord(\'D\'), 1);}' unless defined(&DIOCSTART);
    eval 'sub DIOCSTOP () { &_IO (ord(\'D\'), 2);}' unless defined(&DIOCSTOP);
    eval 'sub DIOCBEGINRULES () { &_IOWR(ord(\'D\'), 3,  &u_int32_t);}' unless defined(&DIOCBEGINRULES);
    eval 'sub DIOCADDRULE () { &_IOWR(ord(\'D\'), 4, \'struct pfioc_rule\');}' unless defined(&DIOCADDRULE);
    eval 'sub DIOCCOMMITRULES () { &_IOWR(ord(\'D\'), 5,  &u_int32_t);}' unless defined(&DIOCCOMMITRULES);
    eval 'sub DIOCGETRULES () { &_IOWR(ord(\'D\'), 6, \'struct pfioc_rule\');}' unless defined(&DIOCGETRULES);
    eval 'sub DIOCGETRULE () { &_IOWR(ord(\'D\'), 7, \'struct pfioc_rule\');}' unless defined(&DIOCGETRULE);
    eval 'sub DIOCBEGINNATS () { &_IOWR(ord(\'D\'), 8,  &u_int32_t);}' unless defined(&DIOCBEGINNATS);
    eval 'sub DIOCADDNAT () { &_IOWR(ord(\'D\'), 9, \'struct pfioc_nat\');}' unless defined(&DIOCADDNAT);
    eval 'sub DIOCCOMMITNATS () { &_IOWR(ord(\'D\'), 10,  &u_int32_t);}' unless defined(&DIOCCOMMITNATS);
    eval 'sub DIOCGETNATS () { &_IOWR(ord(\'D\'), 11, \'struct pfioc_nat\');}' unless defined(&DIOCGETNATS);
    eval 'sub DIOCGETNAT () { &_IOWR(ord(\'D\'), 12, \'struct pfioc_nat\');}' unless defined(&DIOCGETNAT);
    eval 'sub DIOCBEGINRDRS () { &_IOWR(ord(\'D\'), 13,  &u_int32_t);}' unless defined(&DIOCBEGINRDRS);
    eval 'sub DIOCADDRDR () { &_IOWR(ord(\'D\'), 14, \'struct pfioc_rdr\');}' unless defined(&DIOCADDRDR);
    eval 'sub DIOCCOMMITRDRS () { &_IOWR(ord(\'D\'), 15,  &u_int32_t);}' unless defined(&DIOCCOMMITRDRS);
    eval 'sub DIOCGETRDRS () { &_IOWR(ord(\'D\'), 16, \'struct pfioc_rdr\');}' unless defined(&DIOCGETRDRS);
    eval 'sub DIOCGETRDR () { &_IOWR(ord(\'D\'), 17, \'struct pfioc_rdr\');}' unless defined(&DIOCGETRDR);
    eval 'sub DIOCCLRSTATES () { &_IO (ord(\'D\'), 18);}' unless defined(&DIOCCLRSTATES);
    eval 'sub DIOCGETSTATE () { &_IOWR(ord(\'D\'), 19, \'struct pfioc_state\');}' unless defined(&DIOCGETSTATE);
    eval 'sub DIOCSETSTATUSIF () { &_IOWR(ord(\'D\'), 20, \'struct pfioc_if\');}' unless defined(&DIOCSETSTATUSIF);
    eval 'sub DIOCGETSTATUS () { &_IOWR(ord(\'D\'), 21, \'struct pf_status\');}' unless defined(&DIOCGETSTATUS);
    eval 'sub DIOCCLRSTATUS () { &_IO (ord(\'D\'), 22);}' unless defined(&DIOCCLRSTATUS);
    eval 'sub DIOCNATLOOK () { &_IOWR(ord(\'D\'), 23, \'struct pfioc_natlook\');}' unless defined(&DIOCNATLOOK);
    eval 'sub DIOCSETDEBUG () { &_IOWR(ord(\'D\'), 24,  &u_int32_t);}' unless defined(&DIOCSETDEBUG);
    eval 'sub DIOCGETSTATES () { &_IOWR(ord(\'D\'), 25, \'struct pfioc_states\');}' unless defined(&DIOCGETSTATES);
    eval 'sub DIOCCHANGERULE () { &_IOWR(ord(\'D\'), 26, \'struct pfioc_changerule\');}' unless defined(&DIOCCHANGERULE);
    eval 'sub DIOCCHANGENAT () { &_IOWR(ord(\'D\'), 27, \'struct pfioc_changenat\');}' unless defined(&DIOCCHANGENAT);
    eval 'sub DIOCCHANGERDR () { &_IOWR(ord(\'D\'), 28, \'struct pfioc_changerdr\');}' unless defined(&DIOCCHANGERDR);
    eval 'sub DIOCSETTIMEOUT () { &_IOWR(ord(\'D\'), 29, \'struct pfioc_tm\');}' unless defined(&DIOCSETTIMEOUT);
    eval 'sub DIOCGETTIMEOUT () { &_IOWR(ord(\'D\'), 30, \'struct pfioc_tm\');}' unless defined(&DIOCGETTIMEOUT);
    eval 'sub DIOCBEGINBINATS () { &_IOWR(ord(\'D\'), 31,  &u_int32_t);}' unless defined(&DIOCBEGINBINATS);
    eval 'sub DIOCADDBINAT () { &_IOWR(ord(\'D\'), 32, \'struct pfioc_binat\');}' unless defined(&DIOCADDBINAT);
    eval 'sub DIOCCOMMITBINATS () { &_IOWR(ord(\'D\'), 33,  &u_int32_t);}' unless defined(&DIOCCOMMITBINATS);
    eval 'sub DIOCGETBINATS () { &_IOWR(ord(\'D\'), 34, \'struct pfioc_binat\');}' unless defined(&DIOCGETBINATS);
    eval 'sub DIOCGETBINAT () { &_IOWR(ord(\'D\'), 35, \'struct pfioc_binat\');}' unless defined(&DIOCGETBINAT);
    eval 'sub DIOCCHANGEBINAT () { &_IOWR(ord(\'D\'), 36, \'struct pfioc_changebinat\');}' unless defined(&DIOCCHANGEBINAT);
    if(defined(&_KERNEL)) {
	if(defined(&INET)) {
	}
	if(defined(&INET6)) {
	}
    }
}
1;
