require '_h2ph_pre.ph';

require 'sys/queue.ph';
unless(defined(&ia_ifp)) {
    sub ia_ifp () {	 ($ia_ifa->{ifa_ifp});}
}
unless(defined(&ia_flags)) {
    sub ia_flags () {	 ($ia_ifa->{ifa_flags});}
}
unless(defined(&ia_broadaddr)) {
    sub ia_broadaddr () {	 &ia_dstaddr;}
}
unless(defined(&ifra_broadaddr)) {
    sub ifra_broadaddr () {	 &ifra_dstaddr;}
}
unless(defined(&IA_SIN)) {
    sub IA_SIN {
	local($ia) = @_;
	eval q((((($ia))-> &ia_addr)));
    }
}
if(defined(&_KERNEL)) {
    eval 'sub INADDR_TO_IFP {
        local($addr, $ifp) = @_;
	    eval q({  &register \'struct in_ifaddr\' * &ia;  &for ( &ia =  ($in_ifaddr->{tqh_first});  &ia !=  &NULL  &&  ($ia->{ia_addr}->{sin_addr}->{s_addr}) != ($addr). &s_addr;  &ia =  ($ia->{ia_list}->{tqe_next}))  &continue; ($ifp) = ( &ia ==  &NULL) ?  &NULL :  ($ia->{ia_ifp}); });
    }' unless defined(&INADDR_TO_IFP);
    eval 'sub IFP_TO_IA {
        local($ifp, $ia) = @_;
	    eval q({  &for (($ia) =  ($in_ifaddr->{tqh_first}); ($ia) !=  &NULL  && ($ia)-> &ia_ifp != ($ifp); ($ia) = ($ia)-> ($ia_list->{tqe_next}))  &continue; });
    }' unless defined(&IFP_TO_IA);
}
if(defined(&_KERNEL)) {
    eval 'sub IN_LOOKUP_MULTI {
        local($addr, $ifp, $inm) = @_;
	    eval q({  &register \'struct in_ifaddr\' * &ia;  &IFP_TO_IA(($ifp),  &ia);  &if ( &ia ==  &NULL) ($inm) =  &NULL;  &else  &for (($inm) =  ($ia->{ia_multiaddrs}->{lh_first}); ($inm) !=  &NULL  && ($inm)-> ($inm_addr->{s_addr}) != ($addr). &s_addr; ($inm) =  ($inm->{inm_list}->{le_next}))  &continue; });
    }' unless defined(&IN_LOOKUP_MULTI);
    eval 'sub IN_NEXT_MULTI {
        local($step, $inm) = @_;
	    eval q({  &if ((($inm) = ($step). &i_inm) !=  &NULL) ($step). &i_inm = ($inm)-> ($inm_list->{le_next});  &else  &while (($step). &i_ia !=  &NULL) { ($inm) = ($step). ($i_ia->{ia_multiaddrs}->{lh_first}); ($step). &i_ia = ($step). ($i_ia->{ia_list}->{tqe_next});  &if (($inm) !=  &NULL) { ($step). &i_inm = ($inm)-> ($inm_list->{le_next});  &break; } } });
    }' unless defined(&IN_NEXT_MULTI);
    eval 'sub IN_FIRST_MULTI {
        local($step, $inm) = @_;
	    eval q({ ($step). &i_ia =  ($in_ifaddr->{tqh_first}); ($step). &i_inm =  &NULL;  &IN_NEXT_MULTI(($step), ($inm)); });
    }' unless defined(&IN_FIRST_MULTI);
}
require 'netinet6/in6_var.ph';
1;
