require '_h2ph_pre.ph';

no warnings qw(redefine misc);

unless(defined(&_NETINET_IN_VAR_H_)) {
    eval 'sub _NETINET_IN_VAR_H_ () {1;}' unless defined(&_NETINET_IN_VAR_H_);
    require 'sys/queue.ph';
    eval 'sub IN_IFF_TENTATIVE () {0x1;}' unless defined(&IN_IFF_TENTATIVE);
    eval 'sub IN_IFF_DUPLICATED () {0x2;}' unless defined(&IN_IFF_DUPLICATED);
    eval 'sub IN_IFF_DETACHED () {0x4;}' unless defined(&IN_IFF_DETACHED);
    eval 'sub IN_IFF_TRYTENTATIVE () {0x8;}' unless defined(&IN_IFF_TRYTENTATIVE);
    eval 'sub IN_IFFBITS () {"\\020\\1TENTATIVE\\2DUPLICATED\\3DETACHED\\4TRYTENTATIVE";}' unless defined(&IN_IFFBITS);
    eval 'sub IN_IFF_NOTREADY () {( &IN_IFF_TRYTENTATIVE |  &IN_IFF_TENTATIVE |  &IN_IFF_DUPLICATED);}' unless defined(&IN_IFF_NOTREADY);
    eval 'sub ia_ifp () { ($ia_ifa->{ifa_ifp});}' unless defined(&ia_ifp);
    eval 'sub ia_flags () { ($ia_ifa->{ifa_flags});}' unless defined(&ia_flags);
    eval 'sub ia_broadaddr () { &ia_dstaddr;}' unless defined(&ia_broadaddr);
    if(defined(&_KERNEL)) {
    }
    if(defined(&_KERNEL)) {
	eval 'sub ia4_acquire {
	    my($ia,$psref) = @_;
    	    eval q({  &KASSERT($ia !=  &NULL);  &ifa_acquire( ($ia->{ia_ifa}), $psref); });
	}' unless defined(&ia4_acquire);
	eval 'sub ia4_release {
	    my($ia,$psref) = @_;
    	    eval q({  &if ($ia ==  &NULL) ;  &ifa_release( ($ia->{ia_ifa}), $psref); });
	}' unless defined(&ia4_release);
    }
    eval 'sub ifra_broadaddr () { &ifra_dstaddr;}' unless defined(&ifra_broadaddr);
    eval 'sub IA_SIN {
        my($ia) = @_;
	    eval q((((($ia))-> &ia_addr)));
    }' unless defined(&IA_SIN);
    if(defined(&_KERNEL)) {
	unless(defined(&IN_IFADDR_HASH_SIZE)) {
	    eval 'sub IN_IFADDR_HASH_SIZE () {509;}' unless defined(&IN_IFADDR_HASH_SIZE);
	}
	eval 'sub IN_IFADDR_HASH {
	    my($x) = @_;
    	    eval q( $in_ifaddrhashtbl[($x) %  &IN_IFADDR_HASH_SIZE]);
	}' unless defined(&IN_IFADDR_HASH);
	eval 'sub IN_IFADDR_HASH_PSLIST {
	    my($x) = @_;
    	    eval q( $in_ifaddrhashtbl_pslist[($x) %  &IN_IFADDR_HASH_SIZE]);
	}' unless defined(&IN_IFADDR_HASH_PSLIST);
	eval 'sub IN_ADDRHASH_READER_FOREACH {
	    my($__ia, $__addr) = @_;
    	    eval q( &PSLIST_READER_FOREACH(($__ia),  &IN_IFADDR_HASH_PSLIST($__addr), \'struct in_ifaddr\',  &ia_hash_pslist_entry));
	}' unless defined(&IN_ADDRHASH_READER_FOREACH);
	eval 'sub IN_ADDRHASH_WRITER_INSERT_HEAD {
	    my($__ia) = @_;
    	    eval q( &PSLIST_WRITER_INSERT_HEAD(  &IN_IFADDR_HASH_PSLIST(($__ia)-> ($ia_addr->{sin_addr}->{s_addr})), ($__ia),  &ia_hash_pslist_entry));
	}' unless defined(&IN_ADDRHASH_WRITER_INSERT_HEAD);
	eval 'sub IN_ADDRHASH_WRITER_REMOVE {
	    my($__ia) = @_;
    	    eval q( &PSLIST_WRITER_REMOVE(($__ia),  &ia_hash_pslist_entry));
	}' unless defined(&IN_ADDRHASH_WRITER_REMOVE);
	eval 'sub IN_ADDRHASH_ENTRY_INIT {
	    my($__ia) = @_;
    	    eval q( &PSLIST_ENTRY_INIT(($__ia),  &ia_hash_pslist_entry););
	}' unless defined(&IN_ADDRHASH_ENTRY_INIT);
	eval 'sub IN_ADDRHASH_ENTRY_DESTROY {
	    my($__ia) = @_;
    	    eval q( &PSLIST_ENTRY_DESTROY(($__ia),  &ia_hash_pslist_entry););
	}' unless defined(&IN_ADDRHASH_ENTRY_DESTROY);
	eval 'sub IN_ADDRHASH_READER_NEXT {
	    my($__ia) = @_;
    	    eval q( &PSLIST_READER_NEXT(($__ia), \'struct in_ifaddr\',  &ia_hash_pslist_entry));
	}' unless defined(&IN_ADDRHASH_READER_NEXT);
	eval 'sub IN_ADDRLIST_ENTRY_INIT {
	    my($__ia) = @_;
    	    eval q( &PSLIST_ENTRY_INIT(($__ia),  &ia_pslist_entry));
	}' unless defined(&IN_ADDRLIST_ENTRY_INIT);
	eval 'sub IN_ADDRLIST_ENTRY_DESTROY {
	    my($__ia) = @_;
    	    eval q( &PSLIST_ENTRY_DESTROY(($__ia),  &ia_pslist_entry););
	}' unless defined(&IN_ADDRLIST_ENTRY_DESTROY);
	eval 'sub IN_ADDRLIST_READER_EMPTY () {
	    eval q(( &PSLIST_READER_FIRST( &in_ifaddrhead_pslist, \'struct in_ifaddr\',  &ia_pslist_entry) ==  &NULL));
	}' unless defined(&IN_ADDRLIST_READER_EMPTY);
	eval 'sub IN_ADDRLIST_READER_FIRST () {
	    eval q( &PSLIST_READER_FIRST( &in_ifaddrhead_pslist, \'struct in_ifaddr\',  &ia_pslist_entry));
	}' unless defined(&IN_ADDRLIST_READER_FIRST);
	eval 'sub IN_ADDRLIST_READER_NEXT {
	    my($__ia) = @_;
    	    eval q( &PSLIST_READER_NEXT(($__ia), \'struct in_ifaddr\',  &ia_pslist_entry));
	}' unless defined(&IN_ADDRLIST_READER_NEXT);
	eval 'sub IN_ADDRLIST_READER_FOREACH {
	    my($__ia) = @_;
    	    eval q( &PSLIST_READER_FOREACH(($__ia),  &in_ifaddrhead_pslist, \'struct in_ifaddr\',  &ia_pslist_entry));
	}' unless defined(&IN_ADDRLIST_READER_FOREACH);
	eval 'sub IN_ADDRLIST_WRITER_INSERT_HEAD {
	    my($__ia) = @_;
    	    eval q( &PSLIST_WRITER_INSERT_HEAD( &in_ifaddrhead_pslist, ($__ia),  &ia_pslist_entry));
	}' unless defined(&IN_ADDRLIST_WRITER_INSERT_HEAD);
	eval 'sub IN_ADDRLIST_WRITER_REMOVE {
	    my($__ia) = @_;
    	    eval q( &PSLIST_WRITER_REMOVE(($__ia),  &ia_pslist_entry));
	}' unless defined(&IN_ADDRLIST_WRITER_REMOVE);
	eval 'sub IN_ADDRLIST_WRITER_FOREACH {
	    my($__ia) = @_;
    	    eval q( &PSLIST_WRITER_FOREACH(($__ia),  &in_ifaddrhead_pslist, \'struct in_ifaddr\',  &ia_pslist_entry));
	}' unless defined(&IN_ADDRLIST_WRITER_FOREACH);
	eval 'sub IN_ADDRLIST_WRITER_FIRST () {
	    eval q( &PSLIST_WRITER_FIRST( &in_ifaddrhead_pslist, \'struct in_ifaddr\',  &ia_pslist_entry));
	}' unless defined(&IN_ADDRLIST_WRITER_FIRST);
	eval 'sub IN_ADDRLIST_WRITER_NEXT {
	    my($__ia) = @_;
    	    eval q( &PSLIST_WRITER_NEXT(($__ia), \'struct in_ifaddr\',  &ia_pslist_entry));
	}' unless defined(&IN_ADDRLIST_WRITER_NEXT);
	eval 'sub IN_ADDRLIST_WRITER_INSERT_AFTER {
	    my($__ia, $__new) = @_;
    	    eval q( &PSLIST_WRITER_INSERT_AFTER(($__ia), ($__new),  &ia_pslist_entry));
	}' unless defined(&IN_ADDRLIST_WRITER_INSERT_AFTER);
	eval 'sub IN_ADDRLIST_WRITER_EMPTY () {
	    eval q(( &PSLIST_WRITER_FIRST( &in_ifaddrhead_pslist, \'struct in_ifaddr\',  &ia_pslist_entry) ==  &NULL));
	}' unless defined(&IN_ADDRLIST_WRITER_EMPTY);
	eval 'sub IN_ADDRLIST_WRITER_INSERT_TAIL {
	    my($__new) = @_;
    	    eval q( &do {  &if ( &IN_ADDRLIST_WRITER_EMPTY()) {  &IN_ADDRLIST_WRITER_INSERT_HEAD(($__new)); }  &else { \'struct in_ifaddr\' * &__ia;  &IN_ADDRLIST_WRITER_FOREACH( &__ia) {  &if ( &IN_ADDRLIST_WRITER_NEXT( &__ia) ==  &NULL) {  &IN_ADDRLIST_WRITER_INSERT_AFTER( &__ia, ($__new));  &break; } } } }  &while (0));
	}' unless defined(&IN_ADDRLIST_WRITER_INSERT_TAIL);
	eval 'sub in_get_ia_psref {
	    my($addr,$psref) = @_;
    	    eval q({ \'struct in_ifaddr\' * &ia; \'int\'  &s;  &s =  &pserialize_read_enter();  &ia =  &in_get_ia($addr);  &if ( &ia !=  &NULL)  &ia4_acquire( &ia, $psref);  &pserialize_read_exit( &s);  &ia; });
	}' unless defined(&in_get_ia_psref);
	eval 'sub in_get_ia_on_iface_psref {
	    my($addr,$ifp,$psref) = @_;
    	    eval q({ \'struct in_ifaddr\' * &ia; \'int\'  &s;  &s =  &pserialize_read_enter();  &ia =  &in_get_ia_on_iface($addr, $ifp);  &if ( &ia !=  &NULL)  &ia4_acquire( &ia, $psref);  &pserialize_read_exit( &s);  &ia; });
	}' unless defined(&in_get_ia_on_iface_psref);
	eval 'sub in_get_ia_from_ifp_psref {
	    my($ifp,$psref) = @_;
    	    eval q({ \'struct in_ifaddr\' * &ia; \'int\'  &s;  &s =  &pserialize_read_enter();  &ia =  &in_get_ia_from_ifp($ifp);  &if ( &ia !=  &NULL)  &ia4_acquire( &ia, $psref);  &pserialize_read_exit( &s);  &ia; });
	}' unless defined(&in_get_ia_from_ifp_psref);
	require 'netinet/in_selsrc.ph';
	if(defined(&MBUFTRACE)) {
	}
    }
    if(defined(&_KERNEL)) {
	require 'net/pktqueue.ph';
	require 'sys/cprng.ph';
# some #ifdef were dropped here -- fill in the blanks
	eval 'sub ip_dad_enabled {
	    my($void) = @_;
    	    eval q({ });
	}' unless defined(&ip_dad_enabled);
	if(defined(&INET)  && (defined(&NARP) ? &NARP : undef) > 0) {
	    eval 'sub ARPLOGADDR {
	        my($a) = @_;
    		eval q( &IN_PRINT( &_ipbuf, $a));
	    }' unless defined(&ARPLOGADDR);
	    eval 'sub ARPLOG () {( &level,  &fmt,  &args...)  &do { \'char\'  $_ipbuf[ &INET_ADDRSTRLEN]; ( &void) &_ipbuf;  &if ( &arp_debug)  &log( &level, "%s: "  &fmt,  &__func__,  &args); }  &while ( 0);}' unless defined(&ARPLOG);
	} else {
	    eval 'sub ARPLOG () {( &level,  &fmt,  &args...);}' unless defined(&ARPLOG);
	}
	eval 'sub ip_randomid {
	    my($void) = @_;
    	    eval q({  &uint16_t  &id = ( &uint16_t) &cprng_fast32();  &id ?  &id : 1; });
	}' unless defined(&ip_randomid);
	eval 'sub ip_newid {
	    my($void) = @_;
    	    eval q({  &ip_newid_range(1); });
	}' unless defined(&ip_newid);
	if(defined(&SYSCTLFN_PROTO)) {
	}
	eval 'sub LLTABLE {
	    my($ifp) = @_;
    	    eval q((($ifp)-> $if_afdata[ &AF_INET])-> &ii_llt);
	}' unless defined(&LLTABLE);
    }
    require 'netinet6/in6_var.ph';
}
1;
