require '_h2ph_pre.ph';

no warnings 'redefine';

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 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);
    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)) {
	eval 'sub INADDR_TO_IFP {
	    my($addr, $ifp) = @_;
    	    eval q({ \'struct in_ifaddr\' * &ia;  &for ( &ia =  &TAILQ_FIRST( &in_ifaddr);  &ia !=  &TAILQ_END( &in_ifaddr)  &&  ($ia->{ia_addr}->{sin_addr}->{s_addr}) != ($addr). &s_addr;  &ia =  &TAILQ_NEXT( &ia,  &ia_list))  &continue; ($ifp) = ( &ia ==  &NULL) ?  &NULL :  ($ia->{ia_ifp}); });
	}' unless defined(&INADDR_TO_IFP);
	eval 'sub IFP_TO_IA {
	    my($ifp, $ia) = @_;
    	    eval q({  &for (($ia) =  &TAILQ_FIRST( &in_ifaddr); ($ia) !=  &TAILQ_END( &in_ifaddr)  && ($ia)-> &ia_ifp != ($ifp); ($ia) =  &TAILQ_NEXT(($ia),  &ia_list))  &continue; });
	}' unless defined(&IFP_TO_IA);
    }
    if(defined(&_KERNEL)) {
	eval 'sub IN_LOOKUP_MULTI {
	    my($addr, $ifp, $inm) = @_;
    	    eval q({ \'struct in_ifaddr\' * &ia;  &IFP_TO_IA(($ifp),  &ia);  &if ( &ia ==  &NULL) ($inm) =  &NULL;  &else  &for (($inm) =  &LIST_FIRST( ($ia->{ia_multiaddrs})); ($inm) !=  &LIST_END( ($ia->{ia_multiaddrs}))  && ($inm)-> ($inm_addr->{s_addr}) != ($addr). &s_addr; ($inm) =  &LIST_NEXT($inm,  &inm_list))  &continue; });
	}' unless defined(&IN_LOOKUP_MULTI);
	eval 'sub IN_NEXT_MULTI {
	    my($step, $inm) = @_;
    	    eval q({  &if ((($inm) = ($step). &i_inm) !=  &NULL) ($step). &i_inm =  &LIST_NEXT(($inm),  &inm_list);  &else  &while (($step). &i_ia !=  &NULL) { ($inm) =  &LIST_FIRST(($step). ($i_ia->{ia_multiaddrs})); ($step). &i_ia =  &TAILQ_NEXT(($step). &i_ia,  &ia_list);  &if (($inm) !=  &NULL) { ($step). &i_inm =  &LIST_NEXT(($inm),  &inm_list);  &break; } } });
	}' unless defined(&IN_NEXT_MULTI);
	eval 'sub IN_FIRST_MULTI {
	    my($step, $inm) = @_;
    	    eval q({ ($step). &i_ia =  &TAILQ_FIRST( &in_ifaddr); ($step). &i_inm =  &NULL;  &IN_NEXT_MULTI(($step), ($inm)); });
	}' unless defined(&IN_FIRST_MULTI);
    }
    require 'netinet6/in6_var.ph';
}
1;
