require '_h2ph_pre.ph';

unless(defined(&_NETINET_IP6_H_)) {
    eval 'sub _NETINET_IP6_H_ () {1;}' unless defined(&_NETINET_IP6_H_);
    eval 'sub ip6_vfc () { ($ip6_ctlun->{ip6_un2_vfc});}' unless defined(&ip6_vfc);
    eval 'sub ip6_flow () { ($ip6_ctlun->{ip6_un1}->{ip6_un1_flow});}' unless defined(&ip6_flow);
    eval 'sub ip6_plen () { ($ip6_ctlun->{ip6_un1}->{ip6_un1_plen});}' unless defined(&ip6_plen);
    eval 'sub ip6_nxt () { ($ip6_ctlun->{ip6_un1}->{ip6_un1_nxt});}' unless defined(&ip6_nxt);
    eval 'sub ip6_hlim () { ($ip6_ctlun->{ip6_un1}->{ip6_un1_hlim});}' unless defined(&ip6_hlim);
    eval 'sub ip6_hops () { ($ip6_ctlun->{ip6_un1}->{ip6_un1_hlim});}' unless defined(&ip6_hops);
    eval 'sub IPV6_VERSION () {0x60;}' unless defined(&IPV6_VERSION);
    eval 'sub IPV6_VERSION_MASK () {0xf0;}' unless defined(&IPV6_VERSION_MASK);
    if((defined(&BYTE_ORDER) ? &BYTE_ORDER : 0) == (defined(&BIG_ENDIAN) ? &BIG_ENDIAN : 0)) {
	eval 'sub IPV6_FLOWINFO_MASK () {0x0fffffff;}' unless defined(&IPV6_FLOWINFO_MASK);
	eval 'sub IPV6_FLOWLABEL_MASK () {0x000fffff;}' unless defined(&IPV6_FLOWLABEL_MASK);
    } else {
	if((defined(&BYTE_ORDER) ? &BYTE_ORDER : 0) == (defined(&LITTLE_ENDIAN) ? &LITTLE_ENDIAN : 0)) {
	    eval 'sub IPV6_FLOWINFO_MASK () {0xffffff0f;}' unless defined(&IPV6_FLOWINFO_MASK);
	    eval 'sub IPV6_FLOWLABEL_MASK () {0xffff0f00;}' unless defined(&IPV6_FLOWLABEL_MASK);
	}
    }
    if(1) {
	eval 'sub IP6TOS_CE () {0x01;}' unless defined(&IP6TOS_CE);
	eval 'sub IP6TOS_ECT () {0x02;}' unless defined(&IP6TOS_ECT);
    }
    eval 'sub IP6OPT_PAD1 () {0x00;}' unless defined(&IP6OPT_PAD1);
    eval 'sub IP6OPT_PADN () {0x01;}' unless defined(&IP6OPT_PADN);
    eval 'sub IP6OPT_JUMBO () {0xc2;}' unless defined(&IP6OPT_JUMBO);
    eval 'sub IP6OPT_JUMBO_LEN () {6;}' unless defined(&IP6OPT_JUMBO_LEN);
    eval 'sub IP6OPT_RTALERT () {0x05;}' unless defined(&IP6OPT_RTALERT);
    eval 'sub IP6OPT_RTALERT_LEN () {4;}' unless defined(&IP6OPT_RTALERT_LEN);
    eval 'sub IP6OPT_RTALERT_MLD () {0;}' unless defined(&IP6OPT_RTALERT_MLD);
    eval 'sub IP6OPT_RTALERT_RSVP () {1;}' unless defined(&IP6OPT_RTALERT_RSVP);
    eval 'sub IP6OPT_RTALERT_ACTNET () {2;}' unless defined(&IP6OPT_RTALERT_ACTNET);
    eval 'sub IP6OPT_MINLEN () {2;}' unless defined(&IP6OPT_MINLEN);
    eval 'sub IP6OPT_TYPE {
        local($o) = @_;
	    eval q((($o) & 0xc0));
    }' unless defined(&IP6OPT_TYPE);
    eval 'sub IP6OPT_TYPE_SKIP () {0x00;}' unless defined(&IP6OPT_TYPE_SKIP);
    eval 'sub IP6OPT_TYPE_DISCARD () {0x40;}' unless defined(&IP6OPT_TYPE_DISCARD);
    eval 'sub IP6OPT_TYPE_FORCEICMP () {0x80;}' unless defined(&IP6OPT_TYPE_FORCEICMP);
    eval 'sub IP6OPT_TYPE_ICMP () {0xc0;}' unless defined(&IP6OPT_TYPE_ICMP);
    eval 'sub IP6OPT_MUTABLE () {0x20;}' unless defined(&IP6OPT_MUTABLE);
    if((defined(&BYTE_ORDER) ? &BYTE_ORDER : 0) == (defined(&BIG_ENDIAN) ? &BIG_ENDIAN : 0)) {
	eval 'sub IP6F_OFF_MASK () {0xfff8;}' unless defined(&IP6F_OFF_MASK);
	eval 'sub IP6F_RESERVED_MASK () {0x0006;}' unless defined(&IP6F_RESERVED_MASK);
	eval 'sub IP6F_MORE_FRAG () {0x0001;}' unless defined(&IP6F_MORE_FRAG);
    } else {
	eval 'sub IP6F_OFF_MASK () {0xf8ff;}' unless defined(&IP6F_OFF_MASK);
	eval 'sub IP6F_RESERVED_MASK () {0x0600;}' unless defined(&IP6F_RESERVED_MASK);
	eval 'sub IP6F_MORE_FRAG () {0x0100;}' unless defined(&IP6F_MORE_FRAG);
    }
    eval 'sub IPV6_MAXHLIM () {255;}' unless defined(&IPV6_MAXHLIM);
    eval 'sub IPV6_DEFHLIM () {64;}' unless defined(&IPV6_DEFHLIM);
    eval 'sub IPV6_FRAGTTL () {120;}' unless defined(&IPV6_FRAGTTL);
    eval 'sub IPV6_HLIMDEC () {1;}' unless defined(&IPV6_HLIMDEC);
    eval 'sub IPV6_MMTU () {1280;}' unless defined(&IPV6_MMTU);
    eval 'sub IPV6_MAXPACKET () {65535;}' unless defined(&IPV6_MAXPACKET);
    if(defined(&_KERNEL)) {
	eval 'sub IP6_EXTHDR_CHECK {
	    local($m, $off, $hlen, $ret) = @_;
    	    eval q( &do {  &if (($m)-> &m_next !=  &NULL) {  &if ((($m)-> &m_flags &  &M_LOOP)  && (($m)-> &m_len < ($off) + ($hlen))  && ((($m) =  &m_pullup(($m), ($off) + ($hlen))) ==  &NULL)) {  ($ip6stat->{ip6s_exthdrtoolong})++;  &return $ret; }  &else  &if (($m)-> &m_flags &  &M_EXT) {  &if (($m)-> &m_len < ($off) + ($hlen)) {  ($ip6stat->{ip6s_exthdrtoolong})++;  &m_freem($m);  &return $ret; } }  &else {  &if (($m)-> &m_len < ($off) + ($hlen)) {  ($ip6stat->{ip6s_exthdrtoolong})++;  &m_freem($m);  &return $ret; } } }  &else {  &if (($m)-> &m_len < ($off) + ($hlen)) {  ($ip6stat->{ip6s_tooshort})++;  &in6_ifstat_inc( ($m->{m_pkthdr}->{rcvif}),  &ifs6_in_truncated);  &m_freem($m);  &return $ret; } } }  &while (0));
	}' unless defined(&IP6_EXTHDR_CHECK);
	eval 'sub IP6_EXTHDR_GET {
	    local($val, $typ, $m, $off, $len) = @_;
    	    eval q( &do { \'struct mbuf\' * &t; \'int\'  &tmp;  &if (-> &m_len >= + ) = ( &mtod(, \'caddr_t\') + );  &else {  &t =  &m_pulldown(, , ,  &tmp);  &if {  &if ( ($t->{m_len}) <  &tmp + )  &panic(\\"m_pulldown malfunction\\"); = ( &mtod( &t, \'caddr_t\') +  &tmp); }  &else { =  &NULL; ($m) =  &NULL; } } }  &while (0));
	}' unless defined(&IP6_EXTHDR_GET);
	eval 'sub IP6_EXTHDR_GET0 {
	    local($val, $typ, $m, $off, $len) = @_;
    	    eval q( &do { \'struct mbuf\' * &t;  &if ( == 0) =  &mtod($m, \'caddr_t\');  &else {  &t =  &m_pulldown(, , ,  &NULL);  &if {  &if ( ($t->{m_len}) < )  &panic(\\"m_pulldown malfunction\\"); =  &mtod( &t, \'caddr_t\'); }  &else { =  &NULL; ($m) =  &NULL; } } }  &while (0));
	}' unless defined(&IP6_EXTHDR_GET0);
    }
}
1;
