require '_h2ph_pre.ph';

no warnings qw(redefine misc);

unless(defined(&_NETINET_IN_PCB_H_)) {
    eval 'sub _NETINET_IN_PCB_H_ () {1;}' unless defined(&_NETINET_IN_PCB_H_);
    require 'sys/types.ph';
    require 'net/route.ph';
    require 'netinet/in.ph';
    require 'netinet/ip.ph';
    require 'netinet/ip6.ph';
    eval 'sub INP_ATTACHED () {0;}' unless defined(&INP_ATTACHED);
    eval 'sub INP_BOUND () {1;}' unless defined(&INP_BOUND);
    eval 'sub INP_CONNECTED () {2;}' unless defined(&INP_CONNECTED);
    eval 'sub in4p_faddr {
        my($inpcb) = @_;
	    eval q(((($inpcb))-> ($in4p_ip->{ip_dst})));
    }' unless defined(&in4p_faddr);
    eval 'sub in4p_laddr {
        my($inpcb) = @_;
	    eval q(((($inpcb))-> ($in4p_ip->{ip_src})));
    }' unless defined(&in4p_laddr);
    eval 'sub const_in4p_faddr {
        my($inpcb) = @_;
	    eval q(((( &const \'struct in4pcb\' *)($inpcb))-> ($in4p_ip->{ip_dst})));
    }' unless defined(&const_in4p_faddr);
    eval 'sub const_in4p_laddr {
        my($inpcb) = @_;
	    eval q(((( &const \'struct in4pcb\' *)($inpcb))-> ($in4p_ip->{ip_src})));
    }' unless defined(&const_in4p_laddr);
    eval 'sub in4p_ip {
        my($inpcb) = @_;
	    eval q(((($inpcb))-> &in4p_ip));
    }' unless defined(&in4p_ip);
    eval 'sub in4p_errormtu {
        my($inpcb) = @_;
	    eval q(((($inpcb))-> &in4p_errormtu));
    }' unless defined(&in4p_errormtu);
    eval 'sub in4p_ip_minttl {
        my($inpcb) = @_;
	    eval q(((($inpcb))-> &in4p_ip_minttl));
    }' unless defined(&in4p_ip_minttl);
    eval 'sub in4p_prefsrcip {
        my($inpcb) = @_;
	    eval q(((($inpcb))-> &in4p_prefsrcip));
    }' unless defined(&in4p_prefsrcip);
    eval 'sub in6p_faddr {
        my($inpcb) = @_;
	    eval q(((($inpcb))-> ($in6p_ip6->{ip6_dst})));
    }' unless defined(&in6p_faddr);
    eval 'sub in6p_laddr {
        my($inpcb) = @_;
	    eval q(((($inpcb))-> ($in6p_ip6->{ip6_src})));
    }' unless defined(&in6p_laddr);
    eval 'sub const_in6p_faddr {
        my($inpcb) = @_;
	    eval q(((( &const \'struct in6pcb\' *)($inpcb))-> ($in6p_ip6->{ip6_dst})));
    }' unless defined(&const_in6p_faddr);
    eval 'sub const_in6p_laddr {
        my($inpcb) = @_;
	    eval q(((( &const \'struct in6pcb\' *)($inpcb))-> ($in6p_ip6->{ip6_src})));
    }' unless defined(&const_in6p_laddr);
    eval 'sub in6p_ip6 {
        my($inpcb) = @_;
	    eval q(((($inpcb))-> &in6p_ip6));
    }' unless defined(&in6p_ip6);
    eval 'sub in6p_flowinfo {
        my($inpcb) = @_;
	    eval q(((($inpcb))-> ($in6p_ip6->{ip6_flow})));
    }' unless defined(&in6p_flowinfo);
    eval 'sub const_in6p_flowinfo {
        my($inpcb) = @_;
	    eval q(((( &const \'struct in6pcb\' *)($inpcb))-> ($in6p_ip6->{ip6_flow})));
    }' unless defined(&const_in6p_flowinfo);
    eval 'sub in6p_hops6 {
        my($inpcb) = @_;
	    eval q(((($inpcb))-> &in6p_hops));
    }' unless defined(&in6p_hops6);
    eval 'sub in6p_cksum {
        my($inpcb) = @_;
	    eval q(((($inpcb))-> &in6p_cksum));
    }' unless defined(&in6p_cksum);
    eval 'sub in6p_icmp6filt {
        my($inpcb) = @_;
	    eval q(((($inpcb))-> &in6p_icmp6filt));
    }' unless defined(&in6p_icmp6filt);
    eval 'sub in6p_outputopts {
        my($inpcb) = @_;
	    eval q(((($inpcb))-> &in6p_outputopts));
    }' unless defined(&in6p_outputopts);
    eval 'sub in6p_moptions {
        my($inpcb) = @_;
	    eval q(((($inpcb))-> &in6p_moptions));
    }' unless defined(&in6p_moptions);
    eval 'sub INP_RECVOPTS () {0x1;}' unless defined(&INP_RECVOPTS);
    eval 'sub INP_RECVRETOPTS () {0x2;}' unless defined(&INP_RECVRETOPTS);
    eval 'sub INP_RECVDSTADDR () {0x4;}' unless defined(&INP_RECVDSTADDR);
    eval 'sub INP_HDRINCL () {0x8;}' unless defined(&INP_HDRINCL);
    eval 'sub INP_HIGHPORT () {0x10;}' unless defined(&INP_HIGHPORT);
    eval 'sub INP_LOWPORT () {0x20;}' unless defined(&INP_LOWPORT);
    eval 'sub INP_ANONPORT () {0x40;}' unless defined(&INP_ANONPORT);
    eval 'sub INP_RECVIF () {0x80;}' unless defined(&INP_RECVIF);
    eval 'sub INP_ESPINUDP () {0x100;}' unless defined(&INP_ESPINUDP);
    eval 'sub INP_ESPINUDP_NON_IKE () {0x200;}' unless defined(&INP_ESPINUDP_NON_IKE);
    eval 'sub INP_NOHEADER () {0x400;}' unless defined(&INP_NOHEADER);
    eval 'sub INP_RECVTTL () {0x800;}' unless defined(&INP_RECVTTL);
    eval 'sub INP_RECVPKTINFO () {0x1000;}' unless defined(&INP_RECVPKTINFO);
    eval 'sub INP_BINDANY () {0x2000;}' unless defined(&INP_BINDANY);
    eval 'sub INP_CONTROLOPTS () {( &INP_RECVOPTS| &INP_RECVRETOPTS| &INP_RECVDSTADDR|  &INP_RECVIF| &INP_RECVTTL| &INP_RECVPKTINFO);}' unless defined(&INP_CONTROLOPTS);
    eval 'sub IN6P_RECVOPTS () {0x1000;}' unless defined(&IN6P_RECVOPTS);
    eval 'sub IN6P_RECVRETOPTS () {0x2000;}' unless defined(&IN6P_RECVRETOPTS);
    eval 'sub IN6P_RECVDSTADDR () {0x4000;}' unless defined(&IN6P_RECVDSTADDR);
    eval 'sub IN6P_IPV6_V6ONLY () {0x8000;}' unless defined(&IN6P_IPV6_V6ONLY);
    eval 'sub IN6P_PKTINFO () {0x10000;}' unless defined(&IN6P_PKTINFO);
    eval 'sub IN6P_HOPLIMIT () {0x20000;}' unless defined(&IN6P_HOPLIMIT);
    eval 'sub IN6P_HOPOPTS () {0x40000;}' unless defined(&IN6P_HOPOPTS);
    eval 'sub IN6P_DSTOPTS () {0x80000;}' unless defined(&IN6P_DSTOPTS);
    eval 'sub IN6P_RTHDR () {0x100000;}' unless defined(&IN6P_RTHDR);
    eval 'sub IN6P_RTHDRDSTOPTS () {0x200000;}' unless defined(&IN6P_RTHDRDSTOPTS);
    eval 'sub IN6P_TCLASS () {0x400000;}' unless defined(&IN6P_TCLASS);
    eval 'sub IN6P_BINDANY () {0x800000;}' unless defined(&IN6P_BINDANY);
    eval 'sub IN6P_HIGHPORT () {0x1000000;}' unless defined(&IN6P_HIGHPORT);
    eval 'sub IN6P_LOWPORT () {0x2000000;}' unless defined(&IN6P_LOWPORT);
    eval 'sub IN6P_ANONPORT () {0x4000000;}' unless defined(&IN6P_ANONPORT);
    eval 'sub IN6P_FAITH () {0x8000000;}' unless defined(&IN6P_FAITH);
    eval 'sub IN6P_ESPINUDP () { &INP_ESPINUDP;}' unless defined(&IN6P_ESPINUDP);
    eval 'sub IN6P_RFC2292 () {0x40000000;}' unless defined(&IN6P_RFC2292);
    eval 'sub IN6P_MTU () {0x80000000;}' unless defined(&IN6P_MTU);
    eval 'sub IN6P_CONTROLOPTS () {( &IN6P_PKTINFO| &IN6P_HOPLIMIT| &IN6P_HOPOPTS|  &IN6P_DSTOPTS| &IN6P_RTHDR| &IN6P_RTHDRDSTOPTS|  &IN6P_TCLASS| &IN6P_RFC2292|  &IN6P_MTU);}' unless defined(&IN6P_CONTROLOPTS);
    eval 'sub sotoinpcb {
        my($so) = @_;
	    eval q((($so)-> &so_pcb));
    }' unless defined(&sotoinpcb);
    eval 'sub soaf {
        my($so) = @_;
	    eval q(( ($so->{so_proto}->{pr_domain}->{dom_family})));
    }' unless defined(&soaf);
    eval 'sub inp_lock {
        my($inp) = @_;
	    eval q( &solock(($inp)-> &inp_socket));
    }' unless defined(&inp_lock);
    eval 'sub inp_unlock {
        my($inp) = @_;
	    eval q( &sounlock(($inp)-> &inp_socket));
    }' unless defined(&inp_unlock);
    eval 'sub inp_locked {
        my($inp) = @_;
	    eval q( &solocked(($inp)-> &inp_socket));
    }' unless defined(&inp_locked);
    eval 'sub inpt_lasthi () { &inpt_lastport;}' unless defined(&inpt_lasthi);
    if(defined(&_KERNEL)) {
	require 'sys/kauth.ph';
	require 'sys/queue.ph';
	eval 'sub inpcb_register_overudp_cb {
	    my($inp,$cb,$arg) = @_;
    	    eval q({  ($inp->{inp_overudp_cb}) = $cb;  ($inp->{inp_overudp_arg}) = $arg; });
	}' unless defined(&inpcb_register_overudp_cb);
	eval 'sub IN6_HASH {
	    my($faddr, $fport, $laddr, $lport) = @_;
    	    eval q(((($faddr)-> $s6_addr32[0] ^ ($faddr)-> $s6_addr32[1] ^ ($faddr)-> $s6_addr32[2] ^ ($faddr)-> $s6_addr32[3] ^ ($laddr)-> $s6_addr32[0] ^ ($laddr)-> $s6_addr32[1] ^ ($laddr)-> $s6_addr32[2] ^ ($laddr)-> $s6_addr32[3]) + ($fport) + ($lport)));
	}' unless defined(&IN6_HASH);
    }
}
1;
