require '_h2ph_pre.ph';

no warnings qw(redefine misc);

unless(defined(&_NETINET_IN_H_)) {
    eval 'sub _NETINET_IN_H_ () {1;}' unless defined(&_NETINET_IN_H_);
    require 'sys/featuretest.ph';
    require 'machine/int_types.ph';
    unless(defined(&_BSD_UINT8_T_)) {
	eval 'sub _BSD_UINT8_T_ () {1;}' unless defined(&_BSD_UINT8_T_);
    }
    unless(defined(&_BSD_UINT32_T_)) {
	eval 'sub _BSD_UINT32_T_ () {1;}' unless defined(&_BSD_UINT32_T_);
    }
    require 'sys/ansi.ph';
    unless(defined(&in_addr_t)) {
	eval 'sub in_addr_t () { &__in_addr_t;}' unless defined(&in_addr_t);
    }
    unless(defined(&in_port_t)) {
	eval 'sub in_port_t () { &__in_port_t;}' unless defined(&in_port_t);
    }
    unless(defined(&sa_family_t)) {
	eval 'sub sa_family_t () { &__sa_family_t;}' unless defined(&sa_family_t);
    }
    eval 'sub IPPROTO_IP () {0;}' unless defined(&IPPROTO_IP);
    eval 'sub IPPROTO_HOPOPTS () {0;}' unless defined(&IPPROTO_HOPOPTS);
    eval 'sub IPPROTO_ICMP () {1;}' unless defined(&IPPROTO_ICMP);
    eval 'sub IPPROTO_IGMP () {2;}' unless defined(&IPPROTO_IGMP);
    eval 'sub IPPROTO_GGP () {3;}' unless defined(&IPPROTO_GGP);
    eval 'sub IPPROTO_IPV4 () {4;}' unless defined(&IPPROTO_IPV4);
    eval 'sub IPPROTO_IPIP () {4;}' unless defined(&IPPROTO_IPIP);
    eval 'sub IPPROTO_TCP () {6;}' unless defined(&IPPROTO_TCP);
    eval 'sub IPPROTO_EGP () {8;}' unless defined(&IPPROTO_EGP);
    eval 'sub IPPROTO_PUP () {12;}' unless defined(&IPPROTO_PUP);
    eval 'sub IPPROTO_UDP () {17;}' unless defined(&IPPROTO_UDP);
    eval 'sub IPPROTO_IDP () {22;}' unless defined(&IPPROTO_IDP);
    eval 'sub IPPROTO_TP () {29;}' unless defined(&IPPROTO_TP);
    eval 'sub IPPROTO_DCCP () {33;}' unless defined(&IPPROTO_DCCP);
    eval 'sub IPPROTO_IPV6 () {41;}' unless defined(&IPPROTO_IPV6);
    eval 'sub IPPROTO_ROUTING () {43;}' unless defined(&IPPROTO_ROUTING);
    eval 'sub IPPROTO_FRAGMENT () {44;}' unless defined(&IPPROTO_FRAGMENT);
    eval 'sub IPPROTO_RSVP () {46;}' unless defined(&IPPROTO_RSVP);
    eval 'sub IPPROTO_GRE () {47;}' unless defined(&IPPROTO_GRE);
    eval 'sub IPPROTO_ESP () {50;}' unless defined(&IPPROTO_ESP);
    eval 'sub IPPROTO_AH () {51;}' unless defined(&IPPROTO_AH);
    eval 'sub IPPROTO_MOBILE () {55;}' unless defined(&IPPROTO_MOBILE);
    eval 'sub IPPROTO_IPV6_ICMP () {58;}' unless defined(&IPPROTO_IPV6_ICMP);
    eval 'sub IPPROTO_ICMPV6 () {58;}' unless defined(&IPPROTO_ICMPV6);
    eval 'sub IPPROTO_NONE () {59;}' unless defined(&IPPROTO_NONE);
    eval 'sub IPPROTO_DSTOPTS () {60;}' unless defined(&IPPROTO_DSTOPTS);
    eval 'sub IPPROTO_EON () {80;}' unless defined(&IPPROTO_EON);
    eval 'sub IPPROTO_ETHERIP () {97;}' unless defined(&IPPROTO_ETHERIP);
    eval 'sub IPPROTO_ENCAP () {98;}' unless defined(&IPPROTO_ENCAP);
    eval 'sub IPPROTO_PIM () {103;}' unless defined(&IPPROTO_PIM);
    eval 'sub IPPROTO_IPCOMP () {108;}' unless defined(&IPPROTO_IPCOMP);
    eval 'sub IPPROTO_VRRP () {112;}' unless defined(&IPPROTO_VRRP);
    eval 'sub IPPROTO_CARP () {112;}' unless defined(&IPPROTO_CARP);
    eval 'sub IPPROTO_L2TP () {115;}' unless defined(&IPPROTO_L2TP);
    eval 'sub IPPROTO_SCTP () {132;}' unless defined(&IPPROTO_SCTP);
    eval 'sub IPPROTO_PFSYNC () {240;}' unless defined(&IPPROTO_PFSYNC);
    eval 'sub IPPROTO_RAW () {255;}' unless defined(&IPPROTO_RAW);
    eval 'sub IPPROTO_MAX () {256;}' unless defined(&IPPROTO_MAX);
    eval 'sub IPPROTO_DONE () {257;}' unless defined(&IPPROTO_DONE);
    eval 'sub CTL_IPPROTO_IPSEC () {258;}' unless defined(&CTL_IPPROTO_IPSEC);
    eval 'sub IPPORT_RESERVED () {1024;}' unless defined(&IPPORT_RESERVED);
    eval 'sub IPPORT_ANONMIN () {49152;}' unless defined(&IPPORT_ANONMIN);
    eval 'sub IPPORT_ANONMAX () {65535;}' unless defined(&IPPORT_ANONMAX);
    eval 'sub IPPORT_RESERVEDMIN () {600;}' unless defined(&IPPORT_RESERVEDMIN);
    eval 'sub IPPORT_RESERVEDMAX () {( &IPPORT_RESERVED-1);}' unless defined(&IPPORT_RESERVEDMAX);
    if(defined(&__CTASSERT)) {
    }
    if(defined(&_KERNEL)) {
	eval 'sub __IPADDR {
	    my($x) = @_;
    	    eval q((( &uint32_t)  &htonl(( &uint32_t)($x))));
	}' unless defined(&__IPADDR);
    } else {
	eval 'sub __IPADDR {
	    my($x) = @_;
    	    eval q((( &uint32_t)($x)));
	}' unless defined(&__IPADDR);
    }
    eval 'sub IN_CLASSA {
        my($i) = @_;
	    eval q(((( &uint32_t)($i) &  &__IPADDR(0x80000000)) ==  &__IPADDR(0x)));
    }' unless defined(&IN_CLASSA);
    eval 'sub IN_CLASSA_NET () { &__IPADDR(0xff000000);}' unless defined(&IN_CLASSA_NET);
    eval 'sub IN_CLASSA_NSHIFT () {24;}' unless defined(&IN_CLASSA_NSHIFT);
    eval 'sub IN_CLASSA_HOST () { &__IPADDR(0xffffff);}' unless defined(&IN_CLASSA_HOST);
    eval 'sub IN_CLASSA_MAX () {128;}' unless defined(&IN_CLASSA_MAX);
    eval 'sub IN_CLASSB {
        my($i) = @_;
	    eval q(((( &uint32_t)($i) &  &__IPADDR(0xc0000000)) ==  &__IPADDR(0x80000000)));
    }' unless defined(&IN_CLASSB);
    eval 'sub IN_CLASSB_NET () { &__IPADDR(0xffff0000);}' unless defined(&IN_CLASSB_NET);
    eval 'sub IN_CLASSB_NSHIFT () {16;}' unless defined(&IN_CLASSB_NSHIFT);
    eval 'sub IN_CLASSB_HOST () { &__IPADDR(0xffff);}' unless defined(&IN_CLASSB_HOST);
    eval 'sub IN_CLASSB_MAX () {65536;}' unless defined(&IN_CLASSB_MAX);
    eval 'sub IN_CLASSC {
        my($i) = @_;
	    eval q(((( &uint32_t)($i) &  &__IPADDR(0xe0000000)) ==  &__IPADDR(0xc0000000)));
    }' unless defined(&IN_CLASSC);
    eval 'sub IN_CLASSC_NET () { &__IPADDR(0xffffff00);}' unless defined(&IN_CLASSC_NET);
    eval 'sub IN_CLASSC_NSHIFT () {8;}' unless defined(&IN_CLASSC_NSHIFT);
    eval 'sub IN_CLASSC_HOST () { &__IPADDR(0xff);}' unless defined(&IN_CLASSC_HOST);
    eval 'sub IN_CLASSD {
        my($i) = @_;
	    eval q(((( &uint32_t)($i) &  &__IPADDR(0xf0000000)) ==  &__IPADDR(0xe0000000)));
    }' unless defined(&IN_CLASSD);
    eval 'sub IN_CLASSD_NET () { &__IPADDR(0xf0000000);}' unless defined(&IN_CLASSD_NET);
    eval 'sub IN_CLASSD_NSHIFT () {28;}' unless defined(&IN_CLASSD_NSHIFT);
    eval 'sub IN_CLASSD_HOST () { &__IPADDR(0xfffffff);}' unless defined(&IN_CLASSD_HOST);
    eval 'sub IN_MULTICAST {
        my($i) = @_;
	    eval q( &IN_CLASSD($i));
    }' unless defined(&IN_MULTICAST);
    eval 'sub IN_EXPERIMENTAL {
        my($i) = @_;
	    eval q(((( &uint32_t)($i) &  &__IPADDR(0xf0000000)) ==  &__IPADDR(0xf0000000)));
    }' unless defined(&IN_EXPERIMENTAL);
    eval 'sub IN_BADCLASS {
        my($i) = @_;
	    eval q(((( &uint32_t)($i) &  &__IPADDR(0xf0000000)) ==  &__IPADDR(0xf0000000)));
    }' unless defined(&IN_BADCLASS);
    eval 'sub IN_LINKLOCAL {
        my($i) = @_;
	    eval q(((( &uint32_t)($i) &  &__IPADDR(0xffff0000)) ==  &__IPADDR(0xa9fe0000)));
    }' unless defined(&IN_LINKLOCAL);
    eval 'sub IN_PRIVATE {
        my($i) = @_;
	    eval q((((( &uint32_t)($i) &  &__IPADDR(0xff000000)) ==  &__IPADDR(0xa000000)) || ((( &uint32_t)($i) &  &__IPADDR(0xfff00000)) ==  &__IPADDR(0xac100000)) || ((( &uint32_t)($i) &  &__IPADDR(0xffff0000)) ==  &__IPADDR(0xc0a80000))));
    }' unless defined(&IN_PRIVATE);
    eval 'sub IN_LOCAL_GROUP {
        my($i) = @_;
	    eval q(((( &uint32_t)($i) &  &__IPADDR(0xffffff00)) ==  &__IPADDR(0xe0000000)));
    }' unless defined(&IN_LOCAL_GROUP);
    eval 'sub IN_ANY_LOCAL {
        my($i) = @_;
	    eval q(( &IN_LINKLOCAL($i) ||  &IN_LOCAL_GROUP($i)));
    }' unless defined(&IN_ANY_LOCAL);
    eval 'sub INADDR_ANY () { &__IPADDR(0x);}' unless defined(&INADDR_ANY);
    eval 'sub INADDR_LOOPBACK () { &__IPADDR(0x7f000001);}' unless defined(&INADDR_LOOPBACK);
    eval 'sub INADDR_BROADCAST () { &__IPADDR(0xffffffff);}' unless defined(&INADDR_BROADCAST);
    eval 'sub INADDR_NONE () { &__IPADDR(0xffffffff);}' unless defined(&INADDR_NONE);
    eval 'sub INADDR_UNSPEC_GROUP () { &__IPADDR(0xe0000000);}' unless defined(&INADDR_UNSPEC_GROUP);
    eval 'sub INADDR_ALLHOSTS_GROUP () { &__IPADDR(0xe0000001);}' unless defined(&INADDR_ALLHOSTS_GROUP);
    eval 'sub INADDR_ALLRTRS_GROUP () { &__IPADDR(0xe0000002);}' unless defined(&INADDR_ALLRTRS_GROUP);
    eval 'sub INADDR_CARP_GROUP () { &__IPADDR(0xe0000012);}' unless defined(&INADDR_CARP_GROUP);
    eval 'sub INADDR_MAX_LOCAL_GROUP () { &__IPADDR(0xe00000ff);}' unless defined(&INADDR_MAX_LOCAL_GROUP);
    eval 'sub IN_LOOPBACKNET () {127;}' unless defined(&IN_LOOPBACKNET);
    eval 'sub IN_RFC3021_MASK () { &__IPADDR(0xfffffffe);}' unless defined(&IN_RFC3021_MASK);
    eval 'sub INET_ADDRSTRLEN () {16;}' unless defined(&INET_ADDRSTRLEN);
    if(defined(&__cplusplus)) {
    } else {
    }
    eval 'sub IP_OPTIONS () {1;}' unless defined(&IP_OPTIONS);
    eval 'sub IP_HDRINCL () {2;}' unless defined(&IP_HDRINCL);
    eval 'sub IP_TOS () {3;}' unless defined(&IP_TOS);
    eval 'sub IP_TTL () {4;}' unless defined(&IP_TTL);
    eval 'sub IP_RECVOPTS () {5;}' unless defined(&IP_RECVOPTS);
    eval 'sub IP_RECVRETOPTS () {6;}' unless defined(&IP_RECVRETOPTS);
    eval 'sub IP_RECVDSTADDR () {7;}' unless defined(&IP_RECVDSTADDR);
    eval 'sub IP_RETOPTS () {8;}' unless defined(&IP_RETOPTS);
    eval 'sub IP_MULTICAST_IF () {9;}' unless defined(&IP_MULTICAST_IF);
    eval 'sub IP_MULTICAST_TTL () {10;}' unless defined(&IP_MULTICAST_TTL);
    eval 'sub IP_MULTICAST_LOOP () {11;}' unless defined(&IP_MULTICAST_LOOP);
    eval 'sub IP_ADD_MEMBERSHIP () {12;}' unless defined(&IP_ADD_MEMBERSHIP);
    eval 'sub IP_DROP_MEMBERSHIP () {13;}' unless defined(&IP_DROP_MEMBERSHIP);
    eval 'sub IP_PORTALGO () {18;}' unless defined(&IP_PORTALGO);
    eval 'sub IP_PORTRANGE () {19;}' unless defined(&IP_PORTRANGE);
    eval 'sub IP_RECVIF () {20;}' unless defined(&IP_RECVIF);
    eval 'sub IP_ERRORMTU () {21;}' unless defined(&IP_ERRORMTU);
    eval 'sub IP_IPSEC_POLICY () {22;}' unless defined(&IP_IPSEC_POLICY);
    eval 'sub IP_RECVTTL () {23;}' unless defined(&IP_RECVTTL);
    eval 'sub IP_MINTTL () {24;}' unless defined(&IP_MINTTL);
    eval 'sub IP_PKTINFO () {25;}' unless defined(&IP_PKTINFO);
    eval 'sub IP_RECVPKTINFO () {26;}' unless defined(&IP_RECVPKTINFO);
    eval 'sub IP_BINDANY () {27;}' unless defined(&IP_BINDANY);
    eval 'sub IP_SENDSRCADDR () { &IP_RECVDSTADDR;}' unless defined(&IP_SENDSRCADDR);
    eval 'sub ipi_spec_dst () { &ipi_addr;}' unless defined(&ipi_spec_dst);
    eval 'sub IP_DEFAULT_MULTICAST_TTL () {1;}' unless defined(&IP_DEFAULT_MULTICAST_TTL);
    eval 'sub IP_DEFAULT_MULTICAST_LOOP () {1;}' unless defined(&IP_DEFAULT_MULTICAST_LOOP);
    eval 'sub IP_MAX_MEMBERSHIPS () {20;}' unless defined(&IP_MAX_MEMBERSHIPS);
    eval 'sub IP_PORTRANGE_DEFAULT () {0;}' unless defined(&IP_PORTRANGE_DEFAULT);
    eval 'sub IP_PORTRANGE_HIGH () {1;}' unless defined(&IP_PORTRANGE_HIGH);
    eval 'sub IP_PORTRANGE_LOW () {2;}' unless defined(&IP_PORTRANGE_LOW);
    if(defined(&_NETBSD_SOURCE)) {
	eval 'sub IPCTL_FORWARDING () {1;}' unless defined(&IPCTL_FORWARDING);
	eval 'sub IPCTL_SENDREDIRECTS () {2;}' unless defined(&IPCTL_SENDREDIRECTS);
	eval 'sub IPCTL_DEFTTL () {3;}' unless defined(&IPCTL_DEFTTL);
	eval 'sub IPCTL_FORWSRCRT () {5;}' unless defined(&IPCTL_FORWSRCRT);
	eval 'sub IPCTL_DIRECTEDBCAST () {6;}' unless defined(&IPCTL_DIRECTEDBCAST);
	eval 'sub IPCTL_ALLOWSRCRT () {7;}' unless defined(&IPCTL_ALLOWSRCRT);
	eval 'sub IPCTL_SUBNETSARELOCAL () {8;}' unless defined(&IPCTL_SUBNETSARELOCAL);
	eval 'sub IPCTL_MTUDISC () {9;}' unless defined(&IPCTL_MTUDISC);
	eval 'sub IPCTL_ANONPORTMIN () {10;}' unless defined(&IPCTL_ANONPORTMIN);
	eval 'sub IPCTL_ANONPORTMAX () {11;}' unless defined(&IPCTL_ANONPORTMAX);
	eval 'sub IPCTL_MTUDISCTIMEOUT () {12;}' unless defined(&IPCTL_MTUDISCTIMEOUT);
	eval 'sub IPCTL_MAXFLOWS () {13;}' unless defined(&IPCTL_MAXFLOWS);
	eval 'sub IPCTL_HOSTZEROBROADCAST () {14;}' unless defined(&IPCTL_HOSTZEROBROADCAST);
	eval 'sub IPCTL_GIF_TTL () {15;}' unless defined(&IPCTL_GIF_TTL);
	eval 'sub IPCTL_LOWPORTMIN () {16;}' unless defined(&IPCTL_LOWPORTMIN);
	eval 'sub IPCTL_LOWPORTMAX () {17;}' unless defined(&IPCTL_LOWPORTMAX);
	eval 'sub IPCTL_MAXFRAGPACKETS () {18;}' unless defined(&IPCTL_MAXFRAGPACKETS);
	eval 'sub IPCTL_GRE_TTL () {19;}' unless defined(&IPCTL_GRE_TTL);
	eval 'sub IPCTL_CHECKINTERFACE () {20;}' unless defined(&IPCTL_CHECKINTERFACE);
	eval 'sub IPCTL_IFQ () {21;}' unless defined(&IPCTL_IFQ);
	eval 'sub IPCTL_RANDOMID () {22;}' unless defined(&IPCTL_RANDOMID);
	eval 'sub IPCTL_LOOPBACKCKSUM () {23;}' unless defined(&IPCTL_LOOPBACKCKSUM);
	eval 'sub IPCTL_STATS () {24;}' unless defined(&IPCTL_STATS);
	eval 'sub IPCTL_DAD_COUNT () {25;}' unless defined(&IPCTL_DAD_COUNT);
    }
    eval 'sub __KAME_NETINET_IN_H_INCLUDED_ () {1;}' unless defined(&__KAME_NETINET_IN_H_INCLUDED_);
    require 'netinet6/in6.ph';
    undef(&__KAME_NETINET_IN_H_INCLUDED_) if defined(&__KAME_NETINET_IN_H_INCLUDED_);
    if(defined(&_KERNEL)) {
	require 'sys/psref.ph';
	eval 'sub in_hosteq {
	    my($s,$t) = @_;
    	    eval q((($s). &s_addr == ($t). &s_addr));
	}' unless defined(&in_hosteq);
	eval 'sub in_nullhost {
	    my($x) = @_;
    	    eval q((($x). &s_addr ==  &INADDR_ANY));
	}' unless defined(&in_nullhost);
	eval 'sub satosin {
	    my($sa) = @_;
    	    eval q((($sa)));
	}' unless defined(&satosin);
	eval 'sub satocsin {
	    my($sa) = @_;
    	    eval q((( &const \'struct sockaddr_in\' *)($sa)));
	}' unless defined(&satocsin);
	eval 'sub sintosa {
	    my($sin) = @_;
    	    eval q((($sin)));
	}' unless defined(&sintosa);
	eval 'sub sintocsa {
	    my($sin) = @_;
    	    eval q((( &const \'struct sockaddr\' *)($sin)));
	}' unless defined(&sintocsa);
	eval 'sub ifatoia {
	    my($ifa) = @_;
    	    eval q((($ifa)));
	}' unless defined(&ifatoia);
	eval 'sub sockaddr_in_init1 {
	    my($sin,$addr,$port) = @_;
    	    eval q({  ($sin->{sin_port}) = $port;  ($sin->{sin_addr}) = *$addr;  &memset( ($sin->{sin_zero}), 0, $sizeof{ ($sin->{sin_zero})}); });
	}' unless defined(&sockaddr_in_init1);
	eval 'sub sockaddr_in_init {
	    my($sin,$addr,$port) = @_;
    	    eval q({  ($sin->{sin_family}) =  &AF_INET;  ($sin->{sin_len}) = $sizeof{$sin};  &sockaddr_in_init1($sin, $addr, $port); });
	}' unless defined(&sockaddr_in_init);
	eval 'sub sockaddr_in_alloc {
	    my($addr,$port,$flags) = @_;
    	    eval q({ \'struct sockaddr\' * &sa;  &sa =  &sockaddr_alloc( &AF_INET, $sizeof{\'struct sockaddr_in\'}, $flags);  &if ( &sa ==  &NULL)  &NULL;  &sockaddr_in_init1( &satosin( &sa), $addr, $port);  &sa; });
	}' unless defined(&sockaddr_in_alloc);
    }
    if(defined(&_KERNEL) || defined(&_TEST)) {
	eval 'sub IN_PRINT {
	    my($b, $a) = @_;
    	    eval q(( &in_print(($b), $sizeof{$b}, $a), ($b)));
	}' unless defined(&IN_PRINT);
    }
}
1;
