require '_h2ph_pre.ph';

no warnings qw(redefine misc);

unless(defined(&_SYS_PROTOSW_H_)) {
    eval 'sub _SYS_PROTOSW_H_ () {1;}' unless defined(&_SYS_PROTOSW_H_);
    eval 'sub PR_SLOWHZ () {2;}' unless defined(&PR_SLOWHZ);
    eval 'sub PR_FASTHZ () {5;}' unless defined(&PR_FASTHZ);
    eval 'sub PR_ATOMIC () {0x1;}' unless defined(&PR_ATOMIC);
    eval 'sub PR_ADDR () {0x2;}' unless defined(&PR_ADDR);
    eval 'sub PR_CONNREQUIRED () {0x4;}' unless defined(&PR_CONNREQUIRED);
    eval 'sub PR_WANTRCVD () {0x8;}' unless defined(&PR_WANTRCVD);
    eval 'sub PR_RIGHTS () {0x10;}' unless defined(&PR_RIGHTS);
    eval 'sub PR_LISTEN () {0x20;}' unless defined(&PR_LISTEN);
    eval 'sub PR_LASTHDR () {0x40;}' unless defined(&PR_LASTHDR);
    eval 'sub PR_ABRTACPTDIS () {0x80;}' unless defined(&PR_ABRTACPTDIS);
    eval 'sub PR_PURGEIF () {0x100;}' unless defined(&PR_PURGEIF);
    eval 'sub PR_ADDR_OPT () {0x200;}' unless defined(&PR_ADDR_OPT);
    eval 'sub PRU_ATTACH () {0;}' unless defined(&PRU_ATTACH);
    eval 'sub PRU_DETACH () {1;}' unless defined(&PRU_DETACH);
    eval 'sub PRU_BIND () {2;}' unless defined(&PRU_BIND);
    eval 'sub PRU_LISTEN () {3;}' unless defined(&PRU_LISTEN);
    eval 'sub PRU_CONNECT () {4;}' unless defined(&PRU_CONNECT);
    eval 'sub PRU_ACCEPT () {5;}' unless defined(&PRU_ACCEPT);
    eval 'sub PRU_DISCONNECT () {6;}' unless defined(&PRU_DISCONNECT);
    eval 'sub PRU_SHUTDOWN () {7;}' unless defined(&PRU_SHUTDOWN);
    eval 'sub PRU_RCVD () {8;}' unless defined(&PRU_RCVD);
    eval 'sub PRU_SEND () {9;}' unless defined(&PRU_SEND);
    eval 'sub PRU_ABORT () {10;}' unless defined(&PRU_ABORT);
    eval 'sub PRU_CONTROL () {11;}' unless defined(&PRU_CONTROL);
    eval 'sub PRU_SENSE () {12;}' unless defined(&PRU_SENSE);
    eval 'sub PRU_RCVOOB () {13;}' unless defined(&PRU_RCVOOB);
    eval 'sub PRU_SENDOOB () {14;}' unless defined(&PRU_SENDOOB);
    eval 'sub PRU_SOCKADDR () {15;}' unless defined(&PRU_SOCKADDR);
    eval 'sub PRU_PEERADDR () {16;}' unless defined(&PRU_PEERADDR);
    eval 'sub PRU_CONNECT2 () {17;}' unless defined(&PRU_CONNECT2);
    eval 'sub PRU_FASTTIMO () {18;}' unless defined(&PRU_FASTTIMO);
    eval 'sub PRU_SLOWTIMO () {19;}' unless defined(&PRU_SLOWTIMO);
    eval 'sub PRU_PROTORCV () {20;}' unless defined(&PRU_PROTORCV);
    eval 'sub PRU_PROTOSEND () {21;}' unless defined(&PRU_PROTOSEND);
    eval 'sub PRU_PURGEIF () {22;}' unless defined(&PRU_PURGEIF);
    eval 'sub PRU_NREQ () {23;}' unless defined(&PRU_NREQ);
    if(defined(&PRUREQUESTS)) {
    }
    eval 'sub PRC_IFDOWN () {0;}' unless defined(&PRC_IFDOWN);
    eval 'sub PRC_ROUTEDEAD () {1;}' unless defined(&PRC_ROUTEDEAD);
    eval 'sub PRC_QUENCH2 () {3;}' unless defined(&PRC_QUENCH2);
    eval 'sub PRC_QUENCH () {4;}' unless defined(&PRC_QUENCH);
    eval 'sub PRC_MSGSIZE () {5;}' unless defined(&PRC_MSGSIZE);
    eval 'sub PRC_HOSTDEAD () {6;}' unless defined(&PRC_HOSTDEAD);
    eval 'sub PRC_HOSTUNREACH () {7;}' unless defined(&PRC_HOSTUNREACH);
    eval 'sub PRC_UNREACH_NET () {8;}' unless defined(&PRC_UNREACH_NET);
    eval 'sub PRC_UNREACH_HOST () {9;}' unless defined(&PRC_UNREACH_HOST);
    eval 'sub PRC_UNREACH_PROTOCOL () {10;}' unless defined(&PRC_UNREACH_PROTOCOL);
    eval 'sub PRC_UNREACH_PORT () {11;}' unless defined(&PRC_UNREACH_PORT);
    eval 'sub PRC_UNREACH_SRCFAIL () {13;}' unless defined(&PRC_UNREACH_SRCFAIL);
    eval 'sub PRC_REDIRECT_NET () {14;}' unless defined(&PRC_REDIRECT_NET);
    eval 'sub PRC_REDIRECT_HOST () {15;}' unless defined(&PRC_REDIRECT_HOST);
    eval 'sub PRC_REDIRECT_TOSNET () {16;}' unless defined(&PRC_REDIRECT_TOSNET);
    eval 'sub PRC_REDIRECT_TOSHOST () {17;}' unless defined(&PRC_REDIRECT_TOSHOST);
    eval 'sub PRC_TIMXCEED_INTRANS () {18;}' unless defined(&PRC_TIMXCEED_INTRANS);
    eval 'sub PRC_TIMXCEED_REASS () {19;}' unless defined(&PRC_TIMXCEED_REASS);
    eval 'sub PRC_PARAMPROB () {20;}' unless defined(&PRC_PARAMPROB);
    eval 'sub PRC_NCMDS () {21;}' unless defined(&PRC_NCMDS);
    eval 'sub PRC_IS_REDIRECT {
        my($cmd) = @_;
	    eval q((($cmd) >=  &PRC_REDIRECT_NET  && ($cmd) <=  &PRC_REDIRECT_TOSHOST));
    }' unless defined(&PRC_IS_REDIRECT);
    if(defined(&PRCREQUESTS)) {
    }
    eval 'sub PRCO_GETOPT () {0;}' unless defined(&PRCO_GETOPT);
    eval 'sub PRCO_SETOPT () {1;}' unless defined(&PRCO_SETOPT);
    eval 'sub PRCO_NCMDS () {2;}' unless defined(&PRCO_NCMDS);
    if(defined(&PRCOREQUESTS)) {
    }
    if(defined(&_KERNEL)) {
	eval 'sub PRT_SLOW_ARM {
	    my($t, $nticks) = @_;
    	    eval q(($t) = ( &pfslowtimo_now + ($nticks)));
	}' unless defined(&PRT_SLOW_ARM);
	eval 'sub PRT_FAST_ARM {
	    my($t, $nticks) = @_;
    	    eval q(($t) = ( &pffasttimo_now + ($nticks)));
	}' unless defined(&PRT_FAST_ARM);
	eval 'sub PRT_SLOW_DISARM {
	    my($t) = @_;
    	    eval q(($t) = 0);
	}' unless defined(&PRT_SLOW_DISARM);
	eval 'sub PRT_FAST_DISARM {
	    my($t) = @_;
    	    eval q(($t) = 0);
	}' unless defined(&PRT_FAST_DISARM);
	eval 'sub PRT_SLOW_ISARMED {
	    my($t) = @_;
    	    eval q((($t) != 0));
	}' unless defined(&PRT_SLOW_ISARMED);
	eval 'sub PRT_FAST_ISARMED {
	    my($t) = @_;
    	    eval q((($t) != 0));
	}' unless defined(&PRT_FAST_ISARMED);
	eval 'sub PRT_SLOW_ISEXPIRED {
	    my($t) = @_;
    	    eval q(( &PRT_SLOW_ISARMED(($t))  && ($t) <=  &pfslowtimo_now));
	}' unless defined(&PRT_SLOW_ISEXPIRED);
	eval 'sub PRT_FAST_ISEXPIRED {
	    my($t) = @_;
    	    eval q(( &PRT_FAST_ISARMED(($t))  && ($t) <=  &pffasttimo_now));
	}' unless defined(&PRT_FAST_ISEXPIRED);
	require 'sys/systm.ph';
	eval 'sub PR_WRAP_USRREQS {
	    my($name) = @_;
    	    eval q( &static \'int\' $name &_attach_wrapper(\'struct socket\' * &a, \'int\'  &b) { \'int\'  &rv;  &KERNEL_LOCK(1,  &NULL);  &rv = $name &_attach( &a,  &b);  &KERNEL_UNLOCK_ONE( &NULL);  &return  &rv; }  &static  &void $name &_detach_wrapper(\'struct socket\' * &a) {  &KERNEL_LOCK(1,  &NULL); $name &_detach( &a);  &KERNEL_UNLOCK_ONE( &NULL); }  &static \'int\' $name &_accept_wrapper(\'struct socket\' * &a, \'struct sockaddr\' * &b) { \'int\'  &rv;  &KERNEL_LOCK(1,  &NULL);  &rv = $name &_accept( &a,  &b);  &KERNEL_UNLOCK_ONE( &NULL);  &return  &rv; }  &static \'int\' $name &_bind_wrapper(\'struct socket\' * &a, \'struct sockaddr\' * &b, \'struct lwp\' * &c) { \'int\'  &rv;  &KERNEL_LOCK(1,  &NULL);  &rv = $name &_bind( &a,  &b,  &c);  &KERNEL_UNLOCK_ONE( &NULL);  &return  &rv; }  &static \'int\' $name &_connect_wrapper(\'struct socket\' * &a, \'struct sockaddr\' * &b, \'struct lwp\' * &c) { \'int\'  &rv;  &KERNEL_LOCK(1,  &NULL);  &rv = $name &_connect( &a,  &b,  &c);  &KERNEL_UNLOCK_ONE( &NULL);  &return  &rv; }  &static \'int\' $name &_connect2_wrapper(\'struct socket\' * &a, \'struct socket\' * &b) { \'int\'  &rv;  &KERNEL_LOCK(1,  &NULL);  &rv = $name &_connect2( &a,  &b);  &KERNEL_UNLOCK_ONE( &NULL);  &return  &rv; }  &static \'int\' $name &_listen_wrapper(\'struct socket\' * &a, \'struct lwp\' * &b) { \'int\'  &rv;  &KERNEL_LOCK(1,  &NULL);  &rv = $name &_listen( &a,  &b);  &KERNEL_UNLOCK_ONE( &NULL);  &return  &rv; }  &static \'int\' $name &_disconnect_wrapper(\'struct socket\' * &a) { \'int\'  &rv;  &KERNEL_LOCK(1,  &NULL);  &rv = $name &_disconnect( &a);  &KERNEL_UNLOCK_ONE( &NULL);  &return  &rv; }  &static \'int\' $name &_shutdown_wrapper(\'struct socket\' * &a) { \'int\'  &rv;  &KERNEL_LOCK(1,  &NULL);  &rv = $name &_shutdown( &a);  &KERNEL_UNLOCK_ONE( &NULL);  &return  &rv; }  &static \'int\' $name &_abort_wrapper(\'struct socket\' * &a) { \'int\'  &rv;  &KERNEL_LOCK(1,  &NULL);  &rv = $name &_abort( &a);  &KERNEL_UNLOCK_ONE( &NULL);  &return  &rv; }  &static \'int\' $name &_ioctl_wrapper(\'struct socket\' * &a, \'u_long b\',  &void * &c, \'struct ifnet\' * &d) { \'int\'  &rv;  &KERNEL_LOCK(1,  &NULL);  &rv = $name &_ioctl( &a,  &b,  &c,  &d);  &KERNEL_UNLOCK_ONE( &NULL);  &return  &rv; }  &static \'int\' $name &_stat_wrapper(\'struct socket\' * &a, \'struct stat\' * &b) { \'int\'  &rv;  &KERNEL_LOCK(1,  &NULL);  &rv = $name &_stat( &a,  &b);  &KERNEL_UNLOCK_ONE( &NULL);  &return  &rv; }  &static \'int\' $name &_peeraddr_wrapper(\'struct socket\' * &a, \'struct sockaddr\' * &b) { \'int\'  &rv;  &KERNEL_LOCK(1,  &NULL);  &rv = $name &_peeraddr( &a,  &b);  &KERNEL_UNLOCK_ONE( &NULL);  &return  &rv; }  &static \'int\' $name &_sockaddr_wrapper(\'struct socket\' * &a, \'struct sockaddr\' * &b) { \'int\'  &rv;  &KERNEL_LOCK(1,  &NULL);  &rv = $name &_sockaddr( &a,  &b);  &KERNEL_UNLOCK_ONE( &NULL);  &return  &rv; }  &static \'int\' $name &_rcvd_wrapper(\'struct socket\' * &a, \'int\'  &b, \'struct lwp\' * &c) { \'int\'  &rv;  &KERNEL_LOCK(1,  &NULL);  &rv = $name &_rcvd( &a,  &b,  &c);  &KERNEL_UNLOCK_ONE( &NULL);  &return  &rv; }  &static \'int\' $name &_recvoob_wrapper(\'struct socket\' * &a, \'struct mbuf\' * &b, \'int\'  &c) { \'int\'  &rv;  &KERNEL_LOCK(1,  &NULL);  &rv = $name &_recvoob( &a,  &b,  &c);  &KERNEL_UNLOCK_ONE( &NULL);  &return  &rv; }  &static \'int\' $name &_send_wrapper(\'struct socket\' * &a, \'struct mbuf\' * &b, \'struct sockaddr\' * &c, \'struct mbuf\' * &d, \'struct lwp\' * &e) { \'int\'  &rv;  &KERNEL_LOCK(1,  &NULL);  &rv = $name &_send( &a,  &b,  &c,  &d,  &e);  &KERNEL_UNLOCK_ONE( &NULL);  &return  &rv; }  &static \'int\' $name &_sendoob_wrapper(\'struct socket\' * &a, \'struct mbuf\' * &b, \'struct mbuf\' * &c) { \'int\'  &rv;  &KERNEL_LOCK(1,  &NULL);  &rv = $name &_sendoob( &a,  &b,  &c);  &KERNEL_UNLOCK_ONE( &NULL);  &return  &rv; }  &static \'int\' $name &_purgeif_wrapper(\'struct socket\' * &a, \'struct ifnet\' * &b) { \'int\'  &rv;  &KERNEL_LOCK(1,  &NULL);  &rv = $name &_purgeif( &a,  &b);  &KERNEL_UNLOCK_ONE( &NULL);  &return  &rv; });
	}' unless defined(&PR_WRAP_USRREQS);
	eval 'sub PR_WRAP_CTLOUTPUT {
	    my($name) = @_;
    	    eval q( &static \'int\' $name &_wrapper(\'int\'  &a, \'struct socket\' * &b, \'struct sockopt\' * &c) { \'int\'  &rv;  &KERNEL_LOCK(1,  &NULL);  &rv = $name( &a,  &b,  &c);  &KERNEL_UNLOCK_ONE( &NULL);  &return  &rv; });
	}' unless defined(&PR_WRAP_CTLOUTPUT);
	eval 'sub PR_WRAP_CTLINPUT {
	    my($name) = @_;
    	    eval q( &static  &void * $name &_wrapper(\'int\'  &a,  &const \'struct sockaddr\' * &b,  &void * &c){  &void * &rv;  &KERNEL_LOCK(1,  &NULL);  &rv = $name( &a,  &b,  &c);  &KERNEL_UNLOCK_ONE( &NULL);  &return  &rv; });
	}' unless defined(&PR_WRAP_CTLINPUT);
	require 'sys/socketvar.ph';
	eval 'sub PR_WRAP_INPUT {
	    my($name) = @_;
    	    eval q( &static  &void $name &_wrapper(\'struct mbuf\' * &m, \'int\'  &off, \'int\'  &proto) {  &mutex_enter( &softnet_lock); $name( &m,  &off,  &proto);  &mutex_exit( &softnet_lock); });
	}' unless defined(&PR_WRAP_INPUT);
    }
}
1;
