require '_h2ph_pre.ph';

no warnings 'redefine';

unless(defined(&_NFS_NFSM_SUBS_H_)) {
    eval 'sub _NFS_NFSM_SUBS_H_ () {1;}' unless defined(&_NFS_NFSM_SUBS_H_);
    eval 'sub M_HASCL {
        my($m) = @_;
	    eval q((($m)-> &m_flags &  &M_EXT));
    }' unless defined(&M_HASCL);
    eval 'sub NFSMINOFF {
        my($m) = @_;
	    eval q( &if ( &M_HASCL($m)) ($m)-> &m_data = ($m)-> ($m_ext->{ext_buf});  &else  &if (($m)-> &m_flags &  &M_PKTHDR) ($m)-> &m_data = ($m)-> &m_pktdat;  &else ($m)-> &m_data = ($m)-> &m_dat);
    }' unless defined(&NFSMINOFF);
    eval 'sub NFSMADV {
        my($m, $s) = @_;
	    eval q(($m)-> &m_data += ($s));
    }' unless defined(&NFSMADV);
    eval 'sub NFSMSIZ {
        my($m) = @_;
	    eval q((( &M_HASCL($m)) ? ($m)-> ($m_ext->{ext_size}) : ((($m)-> &m_flags &  &M_PKTHDR) ?  &MHLEN :  &MLEN)));
    }' unless defined(&NFSMSIZ);
    eval 'sub nfsm_build {
        my($a,$c,$s) = @_;
	    eval q({  &if (($s) >  &M_TRAILINGSPACE( &mb)) {  &MGET( &mb2,  &M_WAIT,  &MT_DATA);  &if (($s) >  &MLEN)  &panic(\\"build > MLEN\\");  ($mb->{m_next}) =  &mb2;  &mb =  &mb2;  ($mb->{m_len}) = 0;  &bpos =  &mtod( &mb, \'caddr_t\'); } ($a) = ($c)( &bpos);  ($mb->{m_len}) += ($s);  &bpos += ($s); });
    }' unless defined(&nfsm_build);
    eval 'sub nfsm_dissect {
        my($a, $c, $s) = @_;
	    eval q({  &t1 =  &mtod( &md, \'caddr_t\')+ ($md->{m_len})- &dpos;  &if ( &t1 >= ($s)) { ($a) = ($c)( &dpos);  &dpos += ($s); }  &else  &if (( &t1 =  &nfsm_disct( &md,  &dpos, ($s),  &t1,  &cp2)) != 0){  &error =  &t1;  &m_freem( &mrep);  &goto  &nfsmout; }  &else { ($a) = ($c) &cp2; } });
    }' unless defined(&nfsm_dissect);
    eval 'sub nfsm_fhtom {
        my($v, $v3) = @_;
	    eval q({  &if {  &t2 =  &nfsm_rndup( ($VTONFS->{n_fhsize})) +  &NFSX_UNSIGNED;  &if ( &t2 <=  &M_TRAILINGSPACE) {  &nfsm_build( &tl,  &u_int32_t *,  &t2); * &tl++ =  &txdr_unsigned( ($VTONFS->{n_fhsize})); *( &tl + (( &t2>>2) - 2)) = 0;  &bcopy( ($VTONFS->{n_fhp}), &tl,  ($VTONFS->{n_fhsize})); }  &else  &if (( &t2 =  &nfsm_strtmbuf( &mb,  &bpos,  ($VTONFS->{n_fhp}),  ($VTONFS->{n_fhsize}))) != 0) {  &error =  &t2;  &m_freem;  &goto  &nfsmout; } }  &else {  &nfsm_build( &cp, \'caddr_t\',  &NFSX_V2FH);  &bcopy( &VTONFS($v)-> &n_fhp,  &cp,  &NFSX_V2FH); } });
    }' unless defined(&nfsm_fhtom);
    eval 'sub nfsm_srvfhtom {
        my($f, $v3) = @_;
	    eval q({  &if {  &nfsm_build( &tl,  &u_int32_t *,  &NFSX_UNSIGNED +  &NFSX_V3FH); * &tl++ =  &txdr_unsigned;  &bcopy(,  &tl,  &NFSX_V3FH); }  &else {  &nfsm_build( &cp, \'caddr_t\',  &NFSX_V2FH);  &bcopy(($f),  &cp,  &NFSX_V2FH); } });
    }' unless defined(&nfsm_srvfhtom);
    eval 'sub nfsm_srvpostop_fh {
        my($f) = @_;
	    eval q({  &nfsm_build( &tl,  &u_int32_t *, 2*  &NFSX_UNSIGNED +  &NFSX_V3FH); * &tl++ =  &nfs_true; * &tl++ =  &txdr_unsigned;  &bcopy(,  &tl,  &NFSX_V3FH); });
    }' unless defined(&nfsm_srvpostop_fh);
    eval 'sub nfsm_mtofh {
        my($d, $v, $v3, $f) = @_;
	    eval q({ \'struct nfsnode\' * &ttnp;  &nfsfh_t * &ttfhp; \'int\'  &ttfhsize;  &if ($v3) {  &nfsm_dissect( &tl,  &u_int32_t *,  &NFSX_UNSIGNED); ($f) =  &fxdr_unsigned(\'int\', * &tl); }  &else ($f) = 1;  &if ($f) {  &nfsm_getfh( &ttfhp,  &ttfhsize, ($v3));  &if (( &t1 =  &nfs_nget(($d)-> &v_mount,  &ttfhp,  &ttfhsize,  &ttnp)) != 0) {  &error =  &t1;  &m_freem( &mrep);  &goto  &nfsmout; } ($v) =  &NFSTOV( &ttnp); }  &if ($v3) {  &nfsm_dissect( &tl,  &u_int32_t *,  &NFSX_UNSIGNED);  &if ($f) ($f) =  &fxdr_unsigned(\'int\', * &tl);  &else  &if ( &fxdr_unsigned(\'int\', * &tl))  &nfsm_adv( &NFSX_V3FATTR); }  &if ($f)  &nfsm_loadattr(($v), 0); });
    }' unless defined(&nfsm_mtofh);
    eval 'sub nfsm_getfh {
        my($f, $s, $v3) = @_;
	    eval q({  &if ($v3) {  &nfsm_dissect( &tl,  &u_int32_t *,  &NFSX_UNSIGNED);  &if ((($s) =  &fxdr_unsigned(\'int\', * &tl)) <= 0|| ($s) >  &NFSX_V3FHMAX) {  &m_freem( &mrep);  &error =  &EBADRPC;  &goto  &nfsmout; } }  &else ($s) =  &NFSX_V2FH;  &nfsm_dissect(($f),  &nfsfh_t *,  &nfsm_rndup($s)); });
    }' unless defined(&nfsm_getfh);
    eval 'sub nfsm_loadattr {
        my($v, $a) = @_;
	    eval q({ \'struct vnode\' * &ttvp = ($v);  &if (( &t1 =  &nfs_loadattrcache( &ttvp,  &md,  &dpos, ($a))) != 0) {  &error =  &t1;  &m_freem( &mrep);  &goto  &nfsmout; } ($v) =  &ttvp; });
    }' unless defined(&nfsm_loadattr);
    eval 'sub nfsm_postop_attr {
        my($v, $f) = @_;
	    eval q({ \'struct vnode\' * &ttvp = ($v);  &nfsm_dissect( &tl,  &u_int32_t *,  &NFSX_UNSIGNED);  &if ((($f) =  &fxdr_unsigned(\'int\', * &tl)) != 0) {  &if (( &t1 =  &nfs_loadattrcache( &ttvp,  &md,  &dpos, 0)) != 0) {  &error =  &t1; ($f) = 0;  &m_freem( &mrep);  &goto  &nfsmout; } ($v) =  &ttvp; } });
    }' unless defined(&nfsm_postop_attr);
    eval 'sub NFSV3_WCCRATTR () {0;}' unless defined(&NFSV3_WCCRATTR);
    eval 'sub NFSV3_WCCCHK () {1;}' unless defined(&NFSV3_WCCCHK);
    eval 'sub nfsm_wcc_data {
        my($v, $f) = @_;
	    eval q({ \'int\'  &ttattrf,  &ttretf = 0;  &nfsm_dissect( &tl,  &u_int32_t *,  &NFSX_UNSIGNED);  &if (* &tl ==  &nfs_true) {  &nfsm_dissect( &tl,  &u_int32_t *, 6*  &NFSX_UNSIGNED);  &if ($f)  &ttretf = ( &VTONFS($v)-> &n_mtime ==  &fxdr_unsigned( &u_int32_t, *( &tl + 2))); }  &nfsm_postop_attr(($v),  &ttattrf);  &if ($f) { ($f) =  &ttretf; }  &else { ($f) =  &ttattrf; } });
    }' unless defined(&nfsm_wcc_data);
    eval 'sub nfsm_v3attrbuild {
        my($a, $full) = @_;
	    eval q({  &if (($a)-> &va_mode != ( &mode_t) &VNOVAL) {  &nfsm_build( &tl,  &u_int32_t *, 2*  &NFSX_UNSIGNED); * &tl++ =  &nfs_true; * &tl =  &txdr_unsigned(($a)-> &va_mode); }  &else {  &nfsm_build( &tl,  &u_int32_t *,  &NFSX_UNSIGNED); * &tl =  &nfs_false; }  &if (($full)  && ($a)-> &va_uid != ( &uid_t) &VNOVAL) {  &nfsm_build( &tl,  &u_int32_t *, 2*  &NFSX_UNSIGNED); * &tl++ =  &nfs_true; * &tl =  &txdr_unsigned(($a)-> &va_uid); }  &else {  &nfsm_build( &tl,  &u_int32_t *,  &NFSX_UNSIGNED); * &tl =  &nfs_false; }  &if (($full)  && ($a)-> &va_gid != ( &gid_t) &VNOVAL) {  &nfsm_build( &tl,  &u_int32_t *, 2*  &NFSX_UNSIGNED); * &tl++ =  &nfs_true; * &tl =  &txdr_unsigned(($a)-> &va_gid); }  &else {  &nfsm_build( &tl,  &u_int32_t *,  &NFSX_UNSIGNED); * &tl =  &nfs_false; }  &if (($full)  && ($a)-> &va_size !=  &VNOVAL) {  &nfsm_build( &tl,  &u_int32_t *, 3*  &NFSX_UNSIGNED); * &tl++ =  &nfs_true;  &txdr_hyper(($a)-> &va_size,  &tl); }  &else {  &nfsm_build( &tl,  &u_int32_t *,  &NFSX_UNSIGNED); * &tl =  &nfs_false; }  &if (($a)-> ($v$a_atime->{tv_sec}) !=  &VNOVAL) {  &if (($a)-> ($v$a_atime->{tv_sec}) !=  &time_second) {  &nfsm_build( &tl,  &u_int32_t *, 3*  &NFSX_UNSIGNED); * &tl++ =  &txdr_unsigned( &NFSV3SATTRTIME_TOCLIENT);  &txdr_nfsv3time(($a)-> &va_atime,  &tl); }  &else {  &nfsm_build( &tl,  &u_int32_t *,  &NFSX_UNSIGNED); * &tl =  &txdr_unsigned( &NFSV3SATTRTIME_TOSERVER); } }  &else {  &nfsm_build( &tl,  &u_int32_t *,  &NFSX_UNSIGNED); * &tl =  &txdr_unsigned( &NFSV3SATTRTIME_DONTCHANGE); }  &if (($a)-> ($v$a_mtime->{tv_sec}) !=  &VNOVAL) {  &if (($a)-> ($v$a_mtime->{tv_sec}) !=  &time_second) {  &nfsm_build( &tl,  &u_int32_t *, 3*  &NFSX_UNSIGNED); * &tl++ =  &txdr_unsigned( &NFSV3SATTRTIME_TOCLIENT);  &txdr_nfsv3time(($a)-> &va_mtime,  &tl); }  &else {  &nfsm_build( &tl,  &u_int32_t *,  &NFSX_UNSIGNED); * &tl =  &txdr_unsigned( &NFSV3SATTRTIME_TOSERVER); } }  &else {  &nfsm_build( &tl,  &u_int32_t *,  &NFSX_UNSIGNED); * &tl =  &txdr_unsigned( &NFSV3SATTRTIME_DONTCHANGE); } });
    }' unless defined(&nfsm_v3attrbuild);
    eval 'sub nfsm_strsiz {
        my($s,$m) = @_;
	    eval q({  &nfsm_dissect( &tl, &u_int32_t *, &NFSX_UNSIGNED);  &if ((($s) =  &fxdr_unsigned( &int32_t,* &tl)) > ($m)) {  &m_freem( &mrep);  &error =  &EBADRPC;  &goto  &nfsmout; } });
    }' unless defined(&nfsm_strsiz);
    eval 'sub nfsm_srvstrsiz {
        my($s,$m) = @_;
	    eval q({  &nfsm_dissect( &tl, &u_int32_t *, &NFSX_UNSIGNED);  &if ((($s) =  &fxdr_unsigned( &int32_t,* &tl)) > ($m) || ($s) <= 0) {  &error =  &EBADRPC;  &nfsm_reply(0); } });
    }' unless defined(&nfsm_srvstrsiz);
    eval 'sub nfsm_srvnamesiz {
        my($s) = @_;
	    eval q({  &nfsm_dissect( &tl, &u_int32_t *, &NFSX_UNSIGNED);  &if ((($s) =  &fxdr_unsigned( &int32_t,* &tl)) >  &NFS_MAXNAMLEN)  &error =  &NFSERR_NAMETOL;  &if (($s) <= 0)  &error =  &EBADRPC;  &if ( &error)  &nfsm_reply(0); });
    }' unless defined(&nfsm_srvnamesiz);
    eval 'sub nfsm_mtouio {
        my($p,$s) = @_;
	    eval q( &if (($s) > 0 && ( &t1 =  &nfsm_mbuftouio( &md,($p),($s), &dpos)) != 0) {  &error =  &t1;  &m_freem( &mrep);  &goto  &nfsmout; });
    }' unless defined(&nfsm_mtouio);
    eval 'sub nfsm_uiotom {
        my($p,$s) = @_;
	    eval q( &if (( &t1 =  &nfsm_uiotombuf(($p), &mb,($s), &bpos)) != 0) {  &error =  &t1;  &m_freem( &mreq);  &goto  &nfsmout; });
    }' unless defined(&nfsm_uiotom);
    eval 'sub nfsm_reqhead {
        my($v,$a,$s) = @_;
	    eval q( &mb =  &mreq =  &nfsm_reqh(($v),($a),($s), &bpos));
    }' unless defined(&nfsm_reqhead);
    eval 'sub nfsm_reqdone () { &m_freem( &mrep);  &nfsmout:;}' unless defined(&nfsm_reqdone);
    eval 'sub nfsm_rndup {
        my($a) = @_;
	    eval q(((($a)+3)(~0x3)));
    }' unless defined(&nfsm_rndup);
    eval 'sub nfsm_request {
        my($v, $t, $p, $c) = @_;
	    eval q( &if (( &error =  &nfs_request(($v),  &mreq, ($t), ($p), ($c),  &mrep,  &md,  &dpos)) != 0) {  &if ( &error &  &NFSERR_RETERR)  &error &= ~ &NFSERR_RETERR;  &else  &goto  &nfsmout; });
    }' unless defined(&nfsm_request);
    eval 'sub nfsm_strtom {
        my($a,$s,$m) = @_;
	    eval q( &if ( > ) {  &m_freem;  &error =  &ENAMETOOLONG;  &goto  &nfsmout; }  &t2 =  &nfsm_rndup+ &NFSX_UNSIGNED;  &if ( &t2 <=  &M_TRAILINGSPACE) {  &nfsm_build( &tl, &u_int32_t *, &t2); * &tl++ =  &txdr_unsigned; *( &tl+(( &t2>>2)-2)) = 0;  &bcopy(,  &tl, ($s)); }  &else  &if (( &t2 =  &nfsm_strtmbuf( &mb,  &bpos, ($a), ($s))) != 0) {  &error =  &t2;  &m_freem( &mreq);  &goto  &nfsmout; });
    }' unless defined(&nfsm_strtom);
    eval 'sub nfsm_srvdone () { &nfsmout:  &return( &error);}' unless defined(&nfsm_srvdone);
    eval 'sub nfsm_reply {
        my($s) = @_;
	    eval q({  ($nfsd->{nd_repstat}) =  &error;  &if ( &error  && !( ($nfsd->{nd_flag}) &  &ND_NFSV3)) ( &void)  &nfs_rephead(0,  &nfsd,  &slp,  &error,  &frev,  &mrq,  &mb,  &bpos);  &else ( &void)  &nfs_rephead(($s),  &nfsd,  &slp,  &error,  &frev,  &mrq,  &mb,  &bpos);  &if ( &mrep !=  &NULL) {  &m_freem( &mrep);  &mrep =  &NULL; }  &mreq = * &mrq;  &if ( &error  && (!( ($nfsd->{nd_flag}) &  &ND_NFSV3) ||  &error ==  &EBADRPC))  &return(0); });
    }' unless defined(&nfsm_reply);
    eval 'sub nfsm_writereply {
        my($s, $v3) = @_;
	    eval q({  ($nfsd->{nd_repstat}) =  &error;  &if ( &error  && !($v3)) ( &void)  &nfs_rephead(0,  &nfsd,  &slp,  &error,  &frev,  &mreq,  &mb,  &bpos);  &else ( &void)  &nfs_rephead(($s),  &nfsd,  &slp,  &error,  &frev,  &mreq,  &mb,  &bpos); });
    }' unless defined(&nfsm_writereply);
    eval 'sub nfsm_adv {
        my($s) = @_;
	    eval q({  &t1 =  &mtod( &md, \'caddr_t\')+ ($md->{m_len})- &dpos;  &if ( &t1 >= ($s)) {  &dpos += ($s); }  &else  &if (( &t1 =  &nfs_adv( &md,  &dpos, ($s),  &t1)) != 0) {  &error =  &t1;  &m_freem( &mrep);  &goto  &nfsmout; } });
    }' unless defined(&nfsm_adv);
    eval 'sub nfsm_srvmtofh {
        my($f) = @_;
	    eval q({  &if ( ($n$fsd->{nd_flag}) &  &ND_NFSV3) {  &nfsm_dissect( &tl,  &u_int32_t *,  &NFSX_UNSIGNED);  &if ( &fxdr_unsigned(\'int\', * &tl) !=  &NFSX_V3FH) {  &error =  &EBADRPC;  &nfsm_reply; } }  &nfsm_dissect( &tl,  &u_int32_t *,  &NFSX_V3FH);  &bcopy( &tl, ($f),  &NFSX_V3FH);  &if (( ($n$fsd->{nd_flag}) &  &ND_NFSV3) == 0)  &nfsm_adv( &NFSX_V2FH -  &NFSX_V3FH); });
    }' unless defined(&nfsm_srvmtofh);
    eval 'sub nfsm_clget () { &if ( &bp >=  &be) {  &if ( &mp ==  &mb)  ($mp->{m_len}) +=  &bp- &bpos;  &MGET( &mp,  &M_WAIT,  &MT_DATA);  &MCLGET( &mp,  &M_WAIT);  ($mp->{m_len}) =  &NFSMSIZ( &mp);  ($mp2->{m_next}) =  &mp;  &mp2 =  &mp;  &bp =  &mtod( &mp, \'caddr_t\');  &be =  &bp+ ($mp->{m_len}); }  &tl = ( &u_int32_t *) &bp;}' unless defined(&nfsm_clget);
    eval 'sub nfsm_srvfillattr {
        my($a, $f) = @_;
	    eval q( &nfsm_srvfattr( &nfsd, ($a), ($f)));
    }' unless defined(&nfsm_srvfillattr);
    eval 'sub nfsm_srvwcc_data {
        my($br, $b, $ar, $a) = @_;
	    eval q( &nfsm_srvwcc( &nfsd, ($br), ($b), ($ar), ($a),  &mb,  &bpos));
    }' unless defined(&nfsm_srvwcc_data);
    eval 'sub nfsm_srvpostop_attr {
        my($r, $a) = @_;
	    eval q( &nfsm_srvpostopattr( &nfsd, ($r), ($a),  &mb,  &bpos));
    }' unless defined(&nfsm_srvpostop_attr);
    eval 'sub nfsm_srvsattr {
        my($a) = @_;
	    eval q({  &nfsm_dissect( &tl,  &u_int32_t *,  &NFSX_UNSIGNED);  &if (* &tl ==  &nfs_true) {  &nfsm_dissect( &tl,  &u_int32_t *,  &NFSX_UNSIGNED); ($a)-> &va_mode =  &nfstov_mode(* &tl); }  &nfsm_dissect( &tl,  &u_int32_t *,  &NFSX_UNSIGNED);  &if (* &tl ==  &nfs_true) {  &nfsm_dissect( &tl,  &u_int32_t *,  &NFSX_UNSIGNED); ($a)-> &va_uid =  &fxdr_unsigned( &uid_t, * &tl); }  &nfsm_dissect( &tl,  &u_int32_t *,  &NFSX_UNSIGNED);  &if (* &tl ==  &nfs_true) {  &nfsm_dissect( &tl,  &u_int32_t *,  &NFSX_UNSIGNED); ($a)-> &va_gid =  &fxdr_unsigned( &gid_t, * &tl); }  &nfsm_dissect( &tl,  &u_int32_t *,  &NFSX_UNSIGNED);  &if (* &tl ==  &nfs_true) {  &nfsm_dissect( &tl,  &u_int32_t *, 2*  &NFSX_UNSIGNED); ($a)-> &va_size =  &fxdr_hyper( &tl); }  &nfsm_dissect( &tl,  &u_int32_t *,  &NFSX_UNSIGNED);  &switch ( &fxdr_unsigned(\'int\', * &tl)) {  &case  &NFSV3SATTRTIME_TOCLIENT: ($a)-> &va_vaflags &= ~ &VA_UTIMES_NULL;  &nfsm_dissect( &tl,  &u_int32_t *, 2*  &NFSX_UNSIGNED);  &fxdr_nfsv3time( &tl, ($a)-> &va_atime);  &break;  &case  &NFSV3SATTRTIME_TOSERVER:  &getnanotime(($a)-> &va_atime);  &break; };  &nfsm_dissect( &tl,  &u_int32_t *,  &NFSX_UNSIGNED);  &switch ( &fxdr_unsigned(\'int\', * &tl)) {  &case  &NFSV3SATTRTIME_TOCLIENT: ($a)-> &va_vaflags &= ~ &VA_UTIMES_NULL;  &nfsm_dissect( &tl,  &u_int32_t *, 2*  &NFSX_UNSIGNED);  &fxdr_nfsv3time( &tl, ($a)-> &va_mtime);  &break;  &case  &NFSV3SATTRTIME_TOSERVER:  &getnanotime(($a)-> &va_mtime);  &break; }; });
    }' unless defined(&nfsm_srvsattr);
}
1;
