Home | History | Annotate | Line # | Download | only in nfs
nfsm_subs.h revision 1.14
      1  1.14      fvdl /*	$NetBSD: nfsm_subs.h,v 1.14 1997/02/24 23:26:20 fvdl Exp $	*/
      2   1.5       cgd 
      3   1.1   mycroft /*
      4   1.4   mycroft  * Copyright (c) 1989, 1993
      5   1.4   mycroft  *	The Regents of the University of California.  All rights reserved.
      6   1.1   mycroft  *
      7   1.1   mycroft  * This code is derived from software contributed to Berkeley by
      8   1.1   mycroft  * Rick Macklem at The University of Guelph.
      9   1.1   mycroft  *
     10   1.1   mycroft  * Redistribution and use in source and binary forms, with or without
     11   1.1   mycroft  * modification, are permitted provided that the following conditions
     12   1.1   mycroft  * are met:
     13   1.1   mycroft  * 1. Redistributions of source code must retain the above copyright
     14   1.1   mycroft  *    notice, this list of conditions and the following disclaimer.
     15   1.1   mycroft  * 2. Redistributions in binary form must reproduce the above copyright
     16   1.1   mycroft  *    notice, this list of conditions and the following disclaimer in the
     17   1.1   mycroft  *    documentation and/or other materials provided with the distribution.
     18   1.1   mycroft  * 3. All advertising materials mentioning features or use of this software
     19   1.1   mycroft  *    must display the following acknowledgement:
     20   1.1   mycroft  *	This product includes software developed by the University of
     21   1.1   mycroft  *	California, Berkeley and its contributors.
     22   1.1   mycroft  * 4. Neither the name of the University nor the names of its contributors
     23   1.1   mycroft  *    may be used to endorse or promote products derived from this software
     24   1.1   mycroft  *    without specific prior written permission.
     25   1.1   mycroft  *
     26   1.1   mycroft  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     27   1.1   mycroft  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     28   1.1   mycroft  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     29   1.1   mycroft  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     30   1.1   mycroft  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     31   1.1   mycroft  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     32   1.1   mycroft  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     33   1.1   mycroft  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     34   1.1   mycroft  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     35   1.1   mycroft  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     36   1.1   mycroft  * SUCH DAMAGE.
     37   1.1   mycroft  *
     38   1.9      fvdl  *	@(#)nfsm_subs.h	8.2 (Berkeley) 3/30/95
     39   1.1   mycroft  */
     40   1.1   mycroft 
     41   1.9      fvdl 
     42   1.9      fvdl #ifndef _NFS_NFSM_SUBS_H_
     43   1.9      fvdl #define _NFS_NFSM_SUBS_H_
     44   1.9      fvdl 
     45   1.9      fvdl 
     46   1.1   mycroft /*
     47   1.1   mycroft  * These macros do strange and peculiar things to mbuf chains for
     48   1.1   mycroft  * the assistance of the nfs code. To attempt to use them for any
     49   1.1   mycroft  * other purpose will be dangerous. (they make weird assumptions)
     50   1.1   mycroft  */
     51   1.1   mycroft 
     52   1.1   mycroft /*
     53   1.1   mycroft  * First define what the actual subs. return
     54   1.1   mycroft  */
     55   1.9      fvdl 
     56   1.1   mycroft #define	M_HASCL(m)	((m)->m_flags & M_EXT)
     57   1.1   mycroft #define	NFSMINOFF(m) \
     58   1.1   mycroft 		if (M_HASCL(m)) \
     59   1.1   mycroft 			(m)->m_data = (m)->m_ext.ext_buf; \
     60   1.4   mycroft 		else if ((m)->m_flags & M_PKTHDR) \
     61   1.4   mycroft 			(m)->m_data = (m)->m_pktdat; \
     62   1.1   mycroft 		else \
     63   1.1   mycroft 			(m)->m_data = (m)->m_dat
     64   1.1   mycroft #define	NFSMADV(m, s)	(m)->m_data += (s)
     65   1.1   mycroft #define	NFSMSIZ(m)	((M_HASCL(m))?MCLBYTES: \
     66   1.1   mycroft 				(((m)->m_flags & M_PKTHDR)?MHLEN:MLEN))
     67   1.1   mycroft 
     68   1.1   mycroft /*
     69   1.1   mycroft  * Now for the macros that do the simple stuff and call the functions
     70   1.1   mycroft  * for the hard stuff.
     71   1.1   mycroft  * These macros use several vars. declared in nfsm_reqhead and these
     72   1.1   mycroft  * vars. must not be used elsewhere unless you are careful not to corrupt
     73   1.1   mycroft  * them. The vars. starting with pN and tN (N=1,2,3,..) are temporaries
     74   1.1   mycroft  * that may be used so long as the value is not expected to retained
     75   1.1   mycroft  * after a macro.
     76   1.1   mycroft  * I know, this is kind of dorkey, but it makes the actual op functions
     77   1.1   mycroft  * fairly clean and deals with the mess caused by the xdr discriminating
     78   1.1   mycroft  * unions.
     79   1.1   mycroft  */
     80   1.1   mycroft 
     81   1.1   mycroft #define	nfsm_build(a,c,s) \
     82   1.4   mycroft 		{ if ((s) > M_TRAILINGSPACE(mb)) { \
     83   1.1   mycroft 			MGET(mb2, M_WAIT, MT_DATA); \
     84   1.1   mycroft 			if ((s) > MLEN) \
     85   1.1   mycroft 				panic("build > MLEN"); \
     86   1.1   mycroft 			mb->m_next = mb2; \
     87   1.1   mycroft 			mb = mb2; \
     88   1.1   mycroft 			mb->m_len = 0; \
     89   1.1   mycroft 			bpos = mtod(mb, caddr_t); \
     90   1.1   mycroft 		} \
     91   1.1   mycroft 		(a) = (c)(bpos); \
     92   1.1   mycroft 		mb->m_len += (s); \
     93   1.4   mycroft 		bpos += (s); }
     94   1.1   mycroft 
     95  1.14      fvdl #define nfsm_aligned(p) ALIGNED_POINTER(p,u_int32_t)
     96  1.12      fvdl 
     97   1.9      fvdl #define	nfsm_dissect(a, c, s) \
     98   1.4   mycroft 		{ t1 = mtod(md, caddr_t)+md->m_len-dpos; \
     99  1.12      fvdl 		if (t1 >= (s) && nfsm_aligned(dpos)) { \
    100   1.1   mycroft 			(a) = (c)(dpos); \
    101   1.1   mycroft 			dpos += (s); \
    102   1.9      fvdl 		} else if ((t1 = nfsm_disct(&md, &dpos, (s), t1, &cp2)) != 0){ \
    103   1.9      fvdl 			error = t1; \
    104   1.1   mycroft 			m_freem(mrep); \
    105   1.1   mycroft 			goto nfsmout; \
    106   1.1   mycroft 		} else { \
    107   1.1   mycroft 			(a) = (c)cp2; \
    108   1.4   mycroft 		} }
    109   1.1   mycroft 
    110   1.9      fvdl #define nfsm_fhtom(v, v3) \
    111   1.9      fvdl 	      { if (v3) { \
    112   1.9      fvdl 			t2 = nfsm_rndup(VTONFS(v)->n_fhsize) + NFSX_UNSIGNED; \
    113   1.9      fvdl 			if (t2 <= M_TRAILINGSPACE(mb)) { \
    114   1.9      fvdl 				nfsm_build(tl, u_int32_t *, t2); \
    115   1.9      fvdl 				*tl++ = txdr_unsigned(VTONFS(v)->n_fhsize); \
    116   1.9      fvdl 				*(tl + ((t2>>2) - 2)) = 0; \
    117   1.9      fvdl 				bcopy((caddr_t)VTONFS(v)->n_fhp,(caddr_t)tl, \
    118   1.9      fvdl 					VTONFS(v)->n_fhsize); \
    119   1.9      fvdl 			} else if ((t2 = nfsm_strtmbuf(&mb, &bpos, \
    120   1.9      fvdl 				(caddr_t)VTONFS(v)->n_fhp, \
    121   1.9      fvdl 				  VTONFS(v)->n_fhsize)) != 0) { \
    122   1.9      fvdl 				error = t2; \
    123   1.9      fvdl 				m_freem(mreq); \
    124   1.9      fvdl 				goto nfsmout; \
    125   1.9      fvdl 			} \
    126   1.9      fvdl 		} else { \
    127   1.9      fvdl 			nfsm_build(cp, caddr_t, NFSX_V2FH); \
    128   1.9      fvdl 			bcopy((caddr_t)VTONFS(v)->n_fhp, cp, NFSX_V2FH); \
    129   1.9      fvdl 		} }
    130   1.9      fvdl 
    131   1.9      fvdl #define nfsm_srvfhtom(f, v3) \
    132   1.9      fvdl 		{ if (v3) { \
    133   1.9      fvdl 			nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED + NFSX_V3FH); \
    134   1.9      fvdl 			*tl++ = txdr_unsigned(NFSX_V3FH); \
    135   1.9      fvdl 			bcopy((caddr_t)(f), (caddr_t)tl, NFSX_V3FH); \
    136   1.9      fvdl 		} else { \
    137   1.9      fvdl 			nfsm_build(cp, caddr_t, NFSX_V2FH); \
    138   1.9      fvdl 			bcopy((caddr_t)(f), cp, NFSX_V2FH); \
    139   1.9      fvdl 		} }
    140   1.9      fvdl 
    141   1.9      fvdl #define nfsm_srvpostop_fh(f) \
    142   1.9      fvdl 		{ nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED + NFSX_V3FH); \
    143   1.9      fvdl 		*tl++ = nfs_true; \
    144   1.9      fvdl 		*tl++ = txdr_unsigned(NFSX_V3FH); \
    145   1.9      fvdl 		bcopy((caddr_t)(f), (caddr_t)tl, NFSX_V3FH); \
    146   1.9      fvdl 		}
    147   1.9      fvdl 
    148   1.9      fvdl #define nfsm_mtofh(d, v, v3, f) \
    149   1.9      fvdl 		{ struct nfsnode *ttnp; nfsfh_t *ttfhp; int ttfhsize; \
    150   1.9      fvdl 		if (v3) { \
    151   1.9      fvdl 			nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
    152   1.9      fvdl 			(f) = fxdr_unsigned(int, *tl); \
    153   1.9      fvdl 		} else \
    154   1.9      fvdl 			(f) = 1; \
    155   1.9      fvdl 		if (f) { \
    156   1.9      fvdl 			nfsm_getfh(ttfhp, ttfhsize, (v3)); \
    157   1.9      fvdl 			if ((t1 = nfs_nget((d)->v_mount, ttfhp, ttfhsize, \
    158   1.9      fvdl 				&ttnp)) != 0) { \
    159   1.9      fvdl 				error = t1; \
    160   1.9      fvdl 				m_freem(mrep); \
    161   1.9      fvdl 				goto nfsmout; \
    162   1.9      fvdl 			} \
    163   1.9      fvdl 			(v) = NFSTOV(ttnp); \
    164   1.9      fvdl 		} \
    165   1.9      fvdl 		if (v3) { \
    166   1.9      fvdl 			nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
    167   1.9      fvdl 			if (f) \
    168   1.9      fvdl 				(f) = fxdr_unsigned(int, *tl); \
    169   1.9      fvdl 			else if (fxdr_unsigned(int, *tl)) \
    170   1.9      fvdl 				nfsm_adv(NFSX_V3FATTR); \
    171   1.1   mycroft 		} \
    172   1.9      fvdl 		if (f) \
    173   1.9      fvdl 			nfsm_loadattr((v), (struct vattr *)0); \
    174   1.1   mycroft 		}
    175   1.1   mycroft 
    176   1.9      fvdl #define nfsm_getfh(f, s, v3) \
    177   1.9      fvdl 		{ if (v3) { \
    178   1.9      fvdl 			nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
    179   1.9      fvdl 			if (((s) = fxdr_unsigned(int, *tl)) <= 0 || \
    180   1.9      fvdl 				(s) > NFSX_V3FHMAX) { \
    181   1.9      fvdl 				m_freem(mrep); \
    182   1.9      fvdl 				error = EBADRPC; \
    183   1.9      fvdl 				goto nfsmout; \
    184   1.9      fvdl 			} \
    185   1.9      fvdl 		} else \
    186   1.9      fvdl 			(s) = NFSX_V2FH; \
    187   1.9      fvdl 		nfsm_dissect((f), nfsfh_t *, nfsm_rndup(s)); }
    188   1.9      fvdl 
    189   1.9      fvdl #define	nfsm_loadattr(v, a) \
    190   1.9      fvdl 		{ struct vnode *ttvp = (v); \
    191   1.9      fvdl 		if ((t1 = nfs_loadattrcache(&ttvp, &md, &dpos, (a))) != 0) { \
    192   1.9      fvdl 			error = t1; \
    193   1.1   mycroft 			m_freem(mrep); \
    194   1.1   mycroft 			goto nfsmout; \
    195   1.1   mycroft 		} \
    196   1.9      fvdl 		(v) = ttvp; }
    197   1.9      fvdl 
    198   1.9      fvdl #define	nfsm_postop_attr(v, f) \
    199   1.9      fvdl 		{ struct vnode *ttvp = (v); \
    200   1.9      fvdl 		nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
    201   1.9      fvdl 		if (((f) = fxdr_unsigned(int, *tl)) != 0) { \
    202   1.9      fvdl 			if ((t1 = nfs_loadattrcache(&ttvp, &md, &dpos, \
    203   1.9      fvdl 				(struct vattr *)0)) != 0) { \
    204   1.9      fvdl 				error = t1; \
    205   1.9      fvdl 				(f) = 0; \
    206   1.9      fvdl 				m_freem(mrep); \
    207   1.9      fvdl 				goto nfsmout; \
    208   1.9      fvdl 			} \
    209   1.9      fvdl 			(v) = ttvp; \
    210   1.9      fvdl 		} }
    211   1.9      fvdl 
    212   1.9      fvdl /* Used as (f) for nfsm_wcc_data() */
    213   1.9      fvdl #define NFSV3_WCCRATTR	0
    214   1.9      fvdl #define NFSV3_WCCCHK	1
    215   1.9      fvdl 
    216   1.9      fvdl #define	nfsm_wcc_data(v, f) \
    217   1.9      fvdl 		{ int ttattrf, ttretf = 0; \
    218   1.9      fvdl 		nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
    219   1.9      fvdl 		if (*tl == nfs_true) { \
    220   1.9      fvdl 			nfsm_dissect(tl, u_int32_t *, 6 * NFSX_UNSIGNED); \
    221   1.9      fvdl 			if (f) \
    222   1.9      fvdl 				ttretf = (VTONFS(v)->n_mtime == \
    223   1.9      fvdl 					fxdr_unsigned(u_int32_t, *(tl + 2))); \
    224   1.9      fvdl 		} \
    225   1.9      fvdl 		nfsm_postop_attr((v), ttattrf); \
    226   1.9      fvdl 		if (f) { \
    227   1.9      fvdl 			(f) = ttretf; \
    228   1.9      fvdl 		} else { \
    229   1.9      fvdl 			(f) = ttattrf; \
    230   1.9      fvdl 		} }
    231   1.9      fvdl 
    232   1.9      fvdl #define nfsm_v3sattr(s, a) \
    233   1.9      fvdl 		{ (s)->sa_modetrue = nfs_true; \
    234   1.9      fvdl 		(s)->sa_mode = vtonfsv3_mode((a)->va_mode); \
    235   1.9      fvdl 		(s)->sa_uidfalse = nfs_false; \
    236   1.9      fvdl 		(s)->sa_gidfalse = nfs_false; \
    237   1.9      fvdl 		(s)->sa_sizefalse = nfs_false; \
    238   1.9      fvdl 		(s)->sa_atimetype = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT); \
    239   1.9      fvdl 		txdr_nfsv3time(&(a)->va_atime, &(s)->sa_atime); \
    240   1.9      fvdl 		(s)->sa_mtimetype = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT); \
    241   1.9      fvdl 		txdr_nfsv3time(&(a)->va_mtime, &(s)->sa_mtime); \
    242   1.9      fvdl 		}
    243   1.1   mycroft 
    244   1.1   mycroft #define	nfsm_strsiz(s,m) \
    245   1.7       cgd 		{ nfsm_dissect(tl,u_int32_t *,NFSX_UNSIGNED); \
    246   1.7       cgd 		if (((s) = fxdr_unsigned(int32_t,*tl)) > (m)) { \
    247   1.1   mycroft 			m_freem(mrep); \
    248   1.1   mycroft 			error = EBADRPC; \
    249   1.1   mycroft 			goto nfsmout; \
    250   1.4   mycroft 		} }
    251   1.1   mycroft 
    252   1.1   mycroft #define	nfsm_srvstrsiz(s,m) \
    253   1.7       cgd 		{ nfsm_dissect(tl,u_int32_t *,NFSX_UNSIGNED); \
    254   1.7       cgd 		if (((s) = fxdr_unsigned(int32_t,*tl)) > (m) || (s) <= 0) { \
    255   1.1   mycroft 			error = EBADRPC; \
    256   1.1   mycroft 			nfsm_reply(0); \
    257   1.4   mycroft 		} }
    258   1.1   mycroft 
    259   1.9      fvdl #define	nfsm_srvnamesiz(s) \
    260   1.9      fvdl 		{ nfsm_dissect(tl,u_int32_t *,NFSX_UNSIGNED); \
    261   1.9      fvdl 		if (((s) = fxdr_unsigned(int32_t,*tl)) > NFS_MAXNAMLEN) \
    262   1.9      fvdl 			error = NFSERR_NAMETOL; \
    263   1.9      fvdl 		if ((s) <= 0) \
    264   1.9      fvdl 			error = EBADRPC; \
    265   1.9      fvdl 		if (error) \
    266   1.9      fvdl 			nfsm_reply(0); \
    267   1.9      fvdl 		}
    268   1.9      fvdl 
    269   1.1   mycroft #define nfsm_mtouio(p,s) \
    270   1.1   mycroft 		if ((s) > 0 && \
    271   1.9      fvdl 		   (t1 = nfsm_mbuftouio(&md,(p),(s),&dpos)) != 0) { \
    272   1.9      fvdl 			error = t1; \
    273   1.1   mycroft 			m_freem(mrep); \
    274   1.1   mycroft 			goto nfsmout; \
    275   1.1   mycroft 		}
    276   1.1   mycroft 
    277   1.1   mycroft #define nfsm_uiotom(p,s) \
    278   1.9      fvdl 		if ((t1 = nfsm_uiotombuf((p),&mb,(s),&bpos)) != 0) { \
    279   1.9      fvdl 			error = t1; \
    280   1.1   mycroft 			m_freem(mreq); \
    281   1.1   mycroft 			goto nfsmout; \
    282   1.1   mycroft 		}
    283   1.1   mycroft 
    284   1.4   mycroft #define	nfsm_reqhead(v,a,s) \
    285   1.4   mycroft 		mb = mreq = nfsm_reqh((v),(a),(s),&bpos)
    286   1.1   mycroft 
    287   1.1   mycroft #define nfsm_reqdone	m_freem(mrep); \
    288   1.1   mycroft 		nfsmout:
    289   1.1   mycroft 
    290   1.1   mycroft #define nfsm_rndup(a)	(((a)+3)&(~0x3))
    291   1.1   mycroft 
    292   1.4   mycroft #define	nfsm_request(v, t, p, c)	\
    293   1.8  christos 		if ((error = nfs_request((v), mreq, (t), (p), \
    294   1.9      fvdl 		   (c), &mrep, &md, &dpos)) != 0) { \
    295   1.9      fvdl 			if (error & NFSERR_RETERR) \
    296   1.9      fvdl 				error &= ~NFSERR_RETERR; \
    297   1.9      fvdl 			else \
    298   1.9      fvdl 				goto nfsmout; \
    299   1.9      fvdl 		}
    300   1.1   mycroft 
    301   1.1   mycroft #define	nfsm_strtom(a,s,m) \
    302   1.1   mycroft 		if ((s) > (m)) { \
    303   1.1   mycroft 			m_freem(mreq); \
    304   1.1   mycroft 			error = ENAMETOOLONG; \
    305   1.1   mycroft 			goto nfsmout; \
    306   1.1   mycroft 		} \
    307   1.1   mycroft 		t2 = nfsm_rndup(s)+NFSX_UNSIGNED; \
    308   1.4   mycroft 		if (t2 <= M_TRAILINGSPACE(mb)) { \
    309   1.7       cgd 			nfsm_build(tl,u_int32_t *,t2); \
    310   1.1   mycroft 			*tl++ = txdr_unsigned(s); \
    311   1.1   mycroft 			*(tl+((t2>>2)-2)) = 0; \
    312  1.11       cgd 			bcopy((const char *)(a), (caddr_t)tl, (s)); \
    313   1.9      fvdl 		} else if ((t2 = nfsm_strtmbuf(&mb, &bpos, (a), (s))) != 0) { \
    314   1.9      fvdl 			error = t2; \
    315   1.1   mycroft 			m_freem(mreq); \
    316   1.1   mycroft 			goto nfsmout; \
    317   1.1   mycroft 		}
    318   1.1   mycroft 
    319   1.1   mycroft #define	nfsm_srvdone \
    320   1.1   mycroft 		nfsmout: \
    321   1.1   mycroft 		return(error)
    322   1.1   mycroft 
    323   1.1   mycroft #define	nfsm_reply(s) \
    324   1.1   mycroft 		{ \
    325   1.4   mycroft 		nfsd->nd_repstat = error; \
    326   1.9      fvdl 		if (error && !(nfsd->nd_flag & ND_NFSV3)) \
    327   1.9      fvdl 		   (void) nfs_rephead(0, nfsd, slp, error, cache, &frev, \
    328   1.4   mycroft 			mrq, &mb, &bpos); \
    329   1.1   mycroft 		else \
    330   1.9      fvdl 		   (void) nfs_rephead((s), nfsd, slp, error, cache, &frev, \
    331   1.4   mycroft 			mrq, &mb, &bpos); \
    332  1.10      fvdl 		if (mrep != NULL) { \
    333  1.10      fvdl 			m_freem(mrep); \
    334  1.10      fvdl 			mrep = NULL; \
    335  1.10      fvdl 		} \
    336   1.1   mycroft 		mreq = *mrq; \
    337   1.9      fvdl 		if (error && (!(nfsd->nd_flag & ND_NFSV3) || \
    338   1.9      fvdl 			error == EBADRPC)) \
    339   1.1   mycroft 			return(0); \
    340   1.1   mycroft 		}
    341   1.1   mycroft 
    342   1.9      fvdl #define	nfsm_writereply(s, v3) \
    343   1.9      fvdl 		{ \
    344   1.9      fvdl 		nfsd->nd_repstat = error; \
    345   1.9      fvdl 		if (error && !(v3)) \
    346   1.9      fvdl 		   (void) nfs_rephead(0, nfsd, slp, error, cache, &frev, \
    347   1.9      fvdl 			&mreq, &mb, &bpos); \
    348   1.9      fvdl 		else \
    349   1.9      fvdl 		   (void) nfs_rephead((s), nfsd, slp, error, cache, &frev, \
    350   1.9      fvdl 			&mreq, &mb, &bpos); \
    351   1.9      fvdl 		}
    352   1.9      fvdl 
    353   1.1   mycroft #define	nfsm_adv(s) \
    354   1.9      fvdl 		{ t1 = mtod(md, caddr_t)+md->m_len-dpos; \
    355   1.1   mycroft 		if (t1 >= (s)) { \
    356   1.1   mycroft 			dpos += (s); \
    357   1.9      fvdl 		} else if ((t1 = nfs_adv(&md, &dpos, (s), t1)) != 0) { \
    358   1.9      fvdl 			error = t1; \
    359   1.1   mycroft 			m_freem(mrep); \
    360   1.1   mycroft 			goto nfsmout; \
    361   1.9      fvdl 		} }
    362   1.1   mycroft 
    363   1.1   mycroft #define nfsm_srvmtofh(f) \
    364   1.9      fvdl 		{ if (nfsd->nd_flag & ND_NFSV3) { \
    365   1.9      fvdl 			nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
    366   1.9      fvdl 			if (fxdr_unsigned(int, *tl) != NFSX_V3FH) { \
    367   1.9      fvdl 				error = EBADRPC; \
    368   1.9      fvdl 				nfsm_reply(0); \
    369   1.9      fvdl 			} \
    370   1.9      fvdl 		} \
    371   1.9      fvdl 		nfsm_dissect(tl, u_int32_t *, NFSX_V3FH); \
    372   1.9      fvdl 		bcopy((caddr_t)tl, (caddr_t)(f), NFSX_V3FH); \
    373   1.9      fvdl 		if ((nfsd->nd_flag & ND_NFSV3) == 0) \
    374   1.9      fvdl 			nfsm_adv(NFSX_V2FH - NFSX_V3FH); \
    375   1.9      fvdl 		}
    376   1.1   mycroft 
    377   1.1   mycroft #define	nfsm_clget \
    378   1.1   mycroft 		if (bp >= be) { \
    379   1.4   mycroft 			if (mp == mb) \
    380   1.4   mycroft 				mp->m_len += bp-bpos; \
    381   1.1   mycroft 			MGET(mp, M_WAIT, MT_DATA); \
    382   1.1   mycroft 			MCLGET(mp, M_WAIT); \
    383   1.1   mycroft 			mp->m_len = NFSMSIZ(mp); \
    384   1.4   mycroft 			mp2->m_next = mp; \
    385   1.4   mycroft 			mp2 = mp; \
    386   1.1   mycroft 			bp = mtod(mp, caddr_t); \
    387   1.1   mycroft 			be = bp+mp->m_len; \
    388   1.1   mycroft 		} \
    389   1.7       cgd 		tl = (u_int32_t *)bp
    390   1.1   mycroft 
    391   1.9      fvdl #define	nfsm_srvfillattr(a, f) \
    392   1.9      fvdl 		nfsm_srvfattr(nfsd, (a), (f))
    393   1.9      fvdl 
    394   1.9      fvdl #define nfsm_srvwcc_data(br, b, ar, a) \
    395   1.9      fvdl 		nfsm_srvwcc(nfsd, (br), (b), (ar), (a), &mb, &bpos)
    396   1.9      fvdl 
    397   1.9      fvdl #define nfsm_srvpostop_attr(r, a) \
    398   1.9      fvdl 		nfsm_srvpostopattr(nfsd, (r), (a), &mb, &bpos)
    399   1.9      fvdl 
    400   1.9      fvdl #define nfsm_srvsattr(a) \
    401   1.9      fvdl 		{ nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
    402   1.9      fvdl 		if (*tl == nfs_true) { \
    403   1.9      fvdl 			nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
    404   1.9      fvdl 			(a)->va_mode = nfstov_mode(*tl); \
    405   1.9      fvdl 		} \
    406   1.9      fvdl 		nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
    407   1.9      fvdl 		if (*tl == nfs_true) { \
    408   1.9      fvdl 			nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
    409   1.9      fvdl 			(a)->va_uid = fxdr_unsigned(uid_t, *tl); \
    410   1.9      fvdl 		} \
    411   1.9      fvdl 		nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
    412   1.9      fvdl 		if (*tl == nfs_true) { \
    413   1.9      fvdl 			nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
    414   1.9      fvdl 			(a)->va_gid = fxdr_unsigned(gid_t, *tl); \
    415   1.9      fvdl 		} \
    416   1.9      fvdl 		nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
    417   1.9      fvdl 		if (*tl == nfs_true) { \
    418   1.9      fvdl 			nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \
    419   1.9      fvdl 			fxdr_hyper(tl, &(a)->va_size); \
    420   1.9      fvdl 		} \
    421   1.9      fvdl 		nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
    422   1.9      fvdl 		switch (fxdr_unsigned(int, *tl)) { \
    423   1.9      fvdl 		case NFSV3SATTRTIME_TOCLIENT: \
    424   1.9      fvdl 			nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \
    425   1.9      fvdl 			fxdr_nfsv3time(tl, &(a)->va_atime); \
    426   1.9      fvdl 			break; \
    427   1.9      fvdl 		case NFSV3SATTRTIME_TOSERVER: \
    428   1.9      fvdl 			(a)->va_atime.tv_sec = time.tv_sec; \
    429   1.9      fvdl 			(a)->va_atime.tv_nsec = time.tv_usec * 1000; \
    430   1.9      fvdl 			break; \
    431   1.9      fvdl 		}; \
    432   1.9      fvdl 		nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
    433   1.9      fvdl 		switch (fxdr_unsigned(int, *tl)) { \
    434   1.9      fvdl 		case NFSV3SATTRTIME_TOCLIENT: \
    435   1.9      fvdl 			nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \
    436   1.9      fvdl 			fxdr_nfsv3time(tl, &(a)->va_mtime); \
    437   1.9      fvdl 			break; \
    438   1.9      fvdl 		case NFSV3SATTRTIME_TOSERVER: \
    439   1.9      fvdl 			(a)->va_mtime.tv_sec = time.tv_sec; \
    440   1.9      fvdl 			(a)->va_mtime.tv_nsec = time.tv_usec * 1000; \
    441   1.9      fvdl 			break; \
    442   1.9      fvdl 		}; }
    443   1.1   mycroft 
    444   1.9      fvdl #endif
    445