require '_h2ph_pre.ph';

no warnings 'redefine';

unless(defined(&_NET_IF_H_)) {
    eval 'sub _NET_IF_H_ () {1;}' unless defined(&_NET_IF_H_);
    require 'sys/queue.ph';
    require 'altq/if_altq.ph';
    require 'sys/time.ph';
    eval 'sub IF_CLONE_INITIALIZER {
        my($name, $create, $destroy) = @_;
	    eval q({ { 0}, $name, $sizeof{$name} - 1, $create, $destroy });
    }' unless defined(&IF_CLONE_INITIALIZER);
    eval 'sub LINK_STATE_UNKNOWN () {0;}' unless defined(&LINK_STATE_UNKNOWN);
    eval 'sub LINK_STATE_DOWN () {1;}' unless defined(&LINK_STATE_DOWN);
    eval 'sub LINK_STATE_UP () {2;}' unless defined(&LINK_STATE_UP);
    eval 'sub LINK_STATE_HALF_DUPLEX () {3;}' unless defined(&LINK_STATE_HALF_DUPLEX);
    eval 'sub LINK_STATE_FULL_DUPLEX () {4;}' unless defined(&LINK_STATE_FULL_DUPLEX);
    eval 'sub LINK_STATE_IS_UP {
        my($_s) = @_;
	    eval q((($_s) >=  &LINK_STATE_UP));
    }' unless defined(&LINK_STATE_IS_UP);
    eval 'sub IFNAMSIZ () {16;}' unless defined(&IFNAMSIZ);
    eval 'sub IF_NAMESIZE () { &IFNAMSIZ;}' unless defined(&IF_NAMESIZE);
    eval 'sub IFDESCRSIZE () {64;}' unless defined(&IFDESCRSIZE);
    eval 'sub if_carp () { ($if_carp_ptr->{carp_s});}' unless defined(&if_carp);
    eval 'sub if_carpdev () { ($if_carp_ptr->{carp_d});}' unless defined(&if_carpdev);
    eval 'sub if_mtu () { ($if_data->{ifi_mtu});}' unless defined(&if_mtu);
    eval 'sub if_type () { ($if_data->{ifi_type});}' unless defined(&if_type);
    eval 'sub if_addrlen () { ($if_data->{ifi_addrlen});}' unless defined(&if_addrlen);
    eval 'sub if_hdrlen () { ($if_data->{ifi_hdrlen});}' unless defined(&if_hdrlen);
    eval 'sub if_metric () { ($if_data->{ifi_metric});}' unless defined(&if_metric);
    eval 'sub if_link_state () { ($if_data->{ifi_link_state});}' unless defined(&if_link_state);
    eval 'sub if_baudrate () { ($if_data->{ifi_baudrate});}' unless defined(&if_baudrate);
    eval 'sub if_ipackets () { ($if_data->{ifi_ipackets});}' unless defined(&if_ipackets);
    eval 'sub if_ierrors () { ($if_data->{ifi_ierrors});}' unless defined(&if_ierrors);
    eval 'sub if_opackets () { ($if_data->{ifi_opackets});}' unless defined(&if_opackets);
    eval 'sub if_oerrors () { ($if_data->{ifi_oerrors});}' unless defined(&if_oerrors);
    eval 'sub if_collisions () { ($if_data->{ifi_collisions});}' unless defined(&if_collisions);
    eval 'sub if_ibytes () { ($if_data->{ifi_ibytes});}' unless defined(&if_ibytes);
    eval 'sub if_obytes () { ($if_data->{ifi_obytes});}' unless defined(&if_obytes);
    eval 'sub if_imcasts () { ($if_data->{ifi_imcasts});}' unless defined(&if_imcasts);
    eval 'sub if_omcasts () { ($if_data->{ifi_omcasts});}' unless defined(&if_omcasts);
    eval 'sub if_iqdrops () { ($if_data->{ifi_iqdrops});}' unless defined(&if_iqdrops);
    eval 'sub if_noproto () { ($if_data->{ifi_noproto});}' unless defined(&if_noproto);
    eval 'sub if_lastchange () { ($if_data->{ifi_lastchange});}' unless defined(&if_lastchange);
    eval 'sub IFF_UP () {0x1;}' unless defined(&IFF_UP);
    eval 'sub IFF_BROADCAST () {0x2;}' unless defined(&IFF_BROADCAST);
    eval 'sub IFF_DEBUG () {0x4;}' unless defined(&IFF_DEBUG);
    eval 'sub IFF_LOOPBACK () {0x8;}' unless defined(&IFF_LOOPBACK);
    eval 'sub IFF_POINTOPOINT () {0x10;}' unless defined(&IFF_POINTOPOINT);
    eval 'sub IFF_NOTRAILERS () {0x20;}' unless defined(&IFF_NOTRAILERS);
    eval 'sub IFF_RUNNING () {0x40;}' unless defined(&IFF_RUNNING);
    eval 'sub IFF_NOARP () {0x80;}' unless defined(&IFF_NOARP);
    eval 'sub IFF_PROMISC () {0x100;}' unless defined(&IFF_PROMISC);
    eval 'sub IFF_ALLMULTI () {0x200;}' unless defined(&IFF_ALLMULTI);
    eval 'sub IFF_OACTIVE () {0x400;}' unless defined(&IFF_OACTIVE);
    eval 'sub IFF_SIMPLEX () {0x800;}' unless defined(&IFF_SIMPLEX);
    eval 'sub IFF_LINK0 () {0x1000;}' unless defined(&IFF_LINK0);
    eval 'sub IFF_LINK1 () {0x2000;}' unless defined(&IFF_LINK1);
    eval 'sub IFF_LINK2 () {0x4000;}' unless defined(&IFF_LINK2);
    eval 'sub IFF_MULTICAST () {0x8000;}' unless defined(&IFF_MULTICAST);
    eval 'sub IFF_CANTCHANGE () {( &IFF_BROADCAST| &IFF_POINTOPOINT| &IFF_RUNNING| &IFF_OACTIVE|  &IFF_SIMPLEX| &IFF_MULTICAST| &IFF_ALLMULTI);}' unless defined(&IFF_CANTCHANGE);
    eval 'sub IF_Kbps {
        my($x) = @_;
	    eval q((($x) * 1000));
    }' unless defined(&IF_Kbps);
    eval 'sub IF_Mbps {
        my($x) = @_;
	    eval q(( &IF_Kbps(($x) * 1000)));
    }' unless defined(&IF_Mbps);
    eval 'sub IF_Gbps {
        my($x) = @_;
	    eval q(( &IF_Mbps(($x) * 1000)));
    }' unless defined(&IF_Gbps);
    eval 'sub IFCAP_CSUM_IPv4 () {0x1;}' unless defined(&IFCAP_CSUM_IPv4);
    eval 'sub IFCAP_CSUM_TCPv4 () {0x2;}' unless defined(&IFCAP_CSUM_TCPv4);
    eval 'sub IFCAP_CSUM_UDPv4 () {0x4;}' unless defined(&IFCAP_CSUM_UDPv4);
    eval 'sub IFCAP_IPSEC () {0x8;}' unless defined(&IFCAP_IPSEC);
    eval 'sub IFCAP_VLAN_MTU () {0x10;}' unless defined(&IFCAP_VLAN_MTU);
    eval 'sub IFCAP_VLAN_HWTAGGING () {0x20;}' unless defined(&IFCAP_VLAN_HWTAGGING);
    eval 'sub IFCAP_IPCOMP () {0x40;}' unless defined(&IFCAP_IPCOMP);
    eval 'sub IFCAP_CSUM_TCPv6 () {0x80;}' unless defined(&IFCAP_CSUM_TCPv6);
    eval 'sub IFCAP_CSUM_UDPv6 () {0x100;}' unless defined(&IFCAP_CSUM_UDPv6);
    eval 'sub IFCAP_CSUM_TCPv4_Rx () {0x200;}' unless defined(&IFCAP_CSUM_TCPv4_Rx);
    eval 'sub IFCAP_CSUM_UDPv4_Rx () {0x400;}' unless defined(&IFCAP_CSUM_UDPv4_Rx);
    eval 'sub IF_QFULL {
        my($ifq) = @_;
	    eval q((($ifq)-> &ifq_len >= ($ifq)-> &ifq_maxlen));
    }' unless defined(&IF_QFULL);
    eval 'sub IF_DROP {
        my($ifq) = @_;
	    eval q((($ifq)-> &ifq_drops++));
    }' unless defined(&IF_DROP);
    eval 'sub IF_ENQUEUE {
        my($ifq, $m) = @_;
	    eval q({ ($m)-> &m_nextpkt = 0;  &if (($ifq)-> &ifq_tail == 0) ($ifq)-> &ifq_head = $m;  &else ($ifq)-> ($ifq_tail->{m_nextpkt}) = $m; ($ifq)-> &ifq_tail = $m; ($ifq)-> &ifq_len++; });
    }' unless defined(&IF_ENQUEUE);
    eval 'sub IF_PREPEND {
        my($ifq, $m) = @_;
	    eval q({ ($m)-> &m_nextpkt = ($ifq)-> &ifq_head;  &if (($ifq)-> &ifq_tail == 0) ($ifq)-> &ifq_tail = ($m); ($ifq)-> &ifq_head = ($m); ($ifq)-> &ifq_len++; });
    }' unless defined(&IF_PREPEND);
    eval 'sub IF_DEQUEUE {
        my($ifq, $m) = @_;
	    eval q({ ($m) = ($ifq)-> &ifq_head;  &if ($m) {  &if ((($ifq)-> &ifq_head = ($m)-> &m_nextpkt) == 0) ($ifq)-> &ifq_tail = 0; ($m)-> &m_nextpkt = 0; ($ifq)-> &ifq_len--; } });
    }' unless defined(&IF_DEQUEUE);
    eval 'sub IF_INPUT_ENQUEUE {
        my($ifq, $m) = @_;
	    eval q({  &if ( &IF_QFULL($ifq)) {  &IF_DROP($ifq);  &m_freem($m);  &if (!($ifq)-> &ifq_congestion)  &if_congestion($ifq); }  &else  &IF_ENQUEUE($ifq, $m); });
    }' unless defined(&IF_INPUT_ENQUEUE);
    eval 'sub IF_POLL {
        my($ifq, $m) = @_;
	    eval q((($m) = ($ifq)-> &ifq_head));
    }' unless defined(&IF_POLL);
    eval 'sub IF_PURGE {
        my($ifq) = @_;
	    eval q( &do { \'struct mbuf\' * &__m0;  &for (;;) {  &IF_DEQUEUE(($ifq),  &__m0);  &if ( &__m0 ==  &NULL)  &break;  &else  &m_freem( &__m0); } }  &while (0));
    }' unless defined(&IF_PURGE);
    eval 'sub IF_IS_EMPTY {
        my($ifq) = @_;
	    eval q((($ifq)-> &ifq_len == 0));
    }' unless defined(&IF_IS_EMPTY);
    eval 'sub IFQ_MAXLEN () {50;}' unless defined(&IFQ_MAXLEN);
    eval 'sub IFNET_SLOWHZ () {1;}' unless defined(&IFNET_SLOWHZ);
    eval 'sub IFQCTL_LEN () {1;}' unless defined(&IFQCTL_LEN);
    eval 'sub IFQCTL_MAXLEN () {2;}' unless defined(&IFQCTL_MAXLEN);
    eval 'sub IFQCTL_DROPS () {3;}' unless defined(&IFQCTL_DROPS);
    eval 'sub IFQCTL_CONGESTION () {4;}' unless defined(&IFQCTL_CONGESTION);
    eval 'sub IFQCTL_MAXID () {5;}' unless defined(&IFQCTL_MAXID);
    eval 'sub CTL_IFQ_NAMES () {{ { 0, 0}, { "len",  &CTLTYPE_INT }, { "maxlen",  &CTLTYPE_INT }, { "drops",  &CTLTYPE_INT }, { "congestion",  &CTLTYPE_INT }, };}' unless defined(&CTL_IFQ_NAMES);
    eval 'sub ifa_broadaddr () { &ifa_dstaddr;}' unless defined(&ifa_broadaddr);
    eval 'sub IFA_ROUTE () { &RTF_UP;}' unless defined(&IFA_ROUTE);
    eval 'sub IFAN_ARRIVAL () {0;}' unless defined(&IFAN_ARRIVAL);
    eval 'sub IFAN_DEPARTURE () {1;}' unless defined(&IFAN_DEPARTURE);
    eval 'sub IFG_ALL () {"all";}' unless defined(&IFG_ALL);
    eval 'sub IFG_EGRESS () {"egress";}' unless defined(&IFG_EGRESS);
    eval 'sub ifgrq_group () { ($ifgrq_ifgrqu->{ifgrqu_group});}' unless defined(&ifgrq_group);
    eval 'sub ifgrq_member () { ($ifgrq_ifgrqu->{ifgrqu_member});}' unless defined(&ifgrq_member);
    eval 'sub ifgr_group () { ($ifgr_ifgru->{ifgru_group});}' unless defined(&ifgr_group);
    eval 'sub ifgr_groups () { ($ifgr_ifgru->{ifgru_groups});}' unless defined(&ifgr_groups);
    eval 'sub ifgr_attrib () { ($ifgr_ifgru->{ifgru_attrib});}' unless defined(&ifgr_attrib);
    eval 'sub ifr_addr () { ($ifr_ifru->{ifru_addr});}' unless defined(&ifr_addr);
    eval 'sub ifr_dstaddr () { ($ifr_ifru->{ifru_dstaddr});}' unless defined(&ifr_dstaddr);
    eval 'sub ifr_broadaddr () { ($ifr_ifru->{ifru_broadaddr});}' unless defined(&ifr_broadaddr);
    eval 'sub ifr_flags () { ($ifr_ifru->{ifru_flags});}' unless defined(&ifr_flags);
    eval 'sub ifr_metric () { ($ifr_ifru->{ifru_metric});}' unless defined(&ifr_metric);
    eval 'sub ifr_mtu () { ($ifr_ifru->{ifru_metric});}' unless defined(&ifr_mtu);
    eval 'sub ifr_media () { ($ifr_ifru->{ifru_metric});}' unless defined(&ifr_media);
    eval 'sub ifr_data () { ($ifr_ifru->{ifru_data});}' unless defined(&ifr_data);
    eval 'sub ifra_broadaddr () { &ifra_dstaddr;}' unless defined(&ifra_broadaddr);
    eval 'sub ifc_buf () { ($ifc_ifcu->{ifcu_buf});}' unless defined(&ifc_buf);
    eval 'sub ifc_req () { ($ifc_ifcu->{ifcu_req});}' unless defined(&ifc_req);
    eval 'sub IFLR_PREFIX () {0x8000;}' unless defined(&IFLR_PREFIX);
    unless(defined(&_KERNEL)) {
	eval 'sub if_freenameindex {
	    my($x) = @_;
    	    eval q( &free($x));
	}' unless defined(&if_freenameindex);
    }
    require 'net/if_arp.ph';
    if(defined(&_KERNEL)) {
	eval 'sub IFAFREE {
	    my($ifa) = @_;
    	    eval q( &do {  &if (($ifa)-> &ifa_refcnt <= 0)  &ifafree($ifa);  &else ($ifa)-> &ifa_refcnt--; }  &while (0));
	}' unless defined(&IFAFREE);
	if(defined(&ALTQ)) {
	    eval 'sub ALTQ_DECL {
	        my($x) = @_;
    		eval q($x);
	    }' unless defined(&ALTQ_DECL);
	    eval 'sub IFQ_ENQUEUE {
	        my($ifq, $m, $pattr, $err) = @_;
    		eval q( &do {  &if ( &ALTQ_IS_ENABLED(($ifq)))  &ALTQ_ENQUEUE(($ifq), ($m), ($pattr), ($err));  &else {  &if ( &IF_QFULL(($ifq))) {  &m_freem(($m)); ($err) =  &ENOBUFS; }  &else {  &IF_ENQUEUE(($ifq), ($m)); ($err) = 0; } }  &if (($err)) ($ifq)-> &ifq_drops++; }  &while (0));
	    }' unless defined(&IFQ_ENQUEUE);
	    eval 'sub IFQ_DEQUEUE {
	        my($ifq, $m) = @_;
    		eval q( &do {  &if ( &TBR_IS_ENABLED(($ifq))) ($m) =  &tbr_dequeue(($ifq),  &ALTDQ_REMOVE);  &else  &if ( &ALTQ_IS_ENABLED(($ifq)))  &ALTQ_DEQUEUE(($ifq), ($m));  &else  &IF_DEQUEUE(($ifq), ($m)); }  &while (0));
	    }' unless defined(&IFQ_DEQUEUE);
	    eval 'sub IFQ_POLL {
	        my($ifq, $m) = @_;
    		eval q( &do {  &if ( &TBR_IS_ENABLED(($ifq))) ($m) =  &tbr_dequeue(($ifq),  &ALTDQ_POLL);  &else  &if ( &ALTQ_IS_ENABLED(($ifq)))  &ALTQ_POLL(($ifq), ($m));  &else  &IF_POLL(($ifq), ($m)); }  &while (0));
	    }' unless defined(&IFQ_POLL);
	    eval 'sub IFQ_PURGE {
	        my($ifq) = @_;
    		eval q( &do {  &if ( &ALTQ_IS_ENABLED(($ifq)))  &ALTQ_PURGE(($ifq));  &else  &IF_PURGE(($ifq)); }  &while (0));
	    }' unless defined(&IFQ_PURGE);
	    eval 'sub IFQ_SET_READY {
	        my($ifq) = @_;
    		eval q( &do { (($ifq)-> &altq_flags |=  &ALTQF_READY); }  &while (0));
	    }' unless defined(&IFQ_SET_READY);
	    eval 'sub IFQ_CLASSIFY {
	        my($ifq, $m, $af, $pa) = @_;
    		eval q( &do {  &if ( &ALTQ_IS_ENABLED(($ifq))) {  &if ( &ALTQ_NEEDS_CLASSIFY(($ifq))) ($pa)-> &pattr_class = (*($ifq)-> &altq_classify) (($ifq)-> &altq_clfier, ($m), ($af)); ($pa)-> &pattr_af = ($af); ($pa)-> &pattr_hdr =  &mtod(($m), \'caddr_t\'); } }  &while (0));
	    }' unless defined(&IFQ_CLASSIFY);
	} else {
	    eval 'sub ALTQ_DECL {
	        my($x) = @_;
    		eval q();
	    }' unless defined(&ALTQ_DECL);
	    eval 'sub IFQ_ENQUEUE {
	        my($ifq, $m, $pattr, $err) = @_;
    		eval q( &do {  &if ( &IF_QFULL(($ifq))) {  &m_freem(($m)); ($err) =  &ENOBUFS; }  &else {  &IF_ENQUEUE(($ifq), ($m)); ($err) = 0; }  &if (($err)) ($ifq)-> &ifq_drops++; }  &while (0));
	    }' unless defined(&IFQ_ENQUEUE);
	    eval 'sub IFQ_DEQUEUE {
	        my($ifq, $m) = @_;
    		eval q( &IF_DEQUEUE(($ifq), ($m)));
	    }' unless defined(&IFQ_DEQUEUE);
	    eval 'sub IFQ_POLL {
	        my($ifq, $m) = @_;
    		eval q( &IF_POLL(($ifq), ($m)));
	    }' unless defined(&IFQ_POLL);
	    eval 'sub IFQ_PURGE {
	        my($ifq) = @_;
    		eval q( &IF_PURGE(($ifq)));
	    }' unless defined(&IFQ_PURGE);
	    eval 'sub IFQ_SET_READY {
	        my($ifq) = @_;
    		eval q();
	    }' unless defined(&IFQ_SET_READY);
	    eval 'sub IFQ_CLASSIFY {
	        my($ifq, $m, $af, $pa) = @_;
    		eval q();
	    }' unless defined(&IFQ_CLASSIFY);
	}
	eval 'sub IFQ_IS_EMPTY {
	    my($ifq) = @_;
    	    eval q((($ifq)-> &ifq_len == 0));
	}' unless defined(&IFQ_IS_EMPTY);
	eval 'sub IFQ_INC_LEN {
	    my($ifq) = @_;
    	    eval q((($ifq)-> &ifq_len++));
	}' unless defined(&IFQ_INC_LEN);
	eval 'sub IFQ_DEC_LEN {
	    my($ifq) = @_;
    	    eval q((--($ifq)-> &ifq_len));
	}' unless defined(&IFQ_DEC_LEN);
	eval 'sub IFQ_INC_DROPS {
	    my($ifq) = @_;
    	    eval q((($ifq)-> &ifq_drops++));
	}' unless defined(&IFQ_INC_DROPS);
	eval 'sub IFQ_SET_MAXLEN {
	    my($ifq, $len) = @_;
    	    eval q((($ifq)-> &ifq_maxlen = ($len)));
	}' unless defined(&IFQ_SET_MAXLEN);
	eval 'sub ether_input_mbuf {
	    my($ifp, $m) = @_;
    	    eval q( &ether_input(($ifp),  &NULL, ($m)));
	}' unless defined(&ether_input_mbuf);
    }
}
1;
