*mbp = mb;
*mrq = mreq; *mbp = mb;
nfs_rephead(siz, nd, slp, err, cache, frev, mrq, mbp, bposp)	int siz;	struct nfsrv_descript *nd;	struct nfssvc_sock *slp;	int err;	int cache;	u_quad_t *frev;	struct mbuf **mrq;	struct mbuf **mbp;	caddr_t *bposp;{	register u_int32_t *tl;	register struct mbuf *mreq;	caddr_t bpos;	struct mbuf *mb, *mb2;	MGETHDR(mreq, M_WAIT, MT_DATA);	mb = mreq;	/*	 * If this is a big reply, use a cluster else	 * try and leave leading space for the lower level headers.	 */	siz += RPC_REPLYSIZ;	if (siz >= max_datalen) {		MCLGET(mreq, M_WAIT);	} else		mreq->m_data += max_hdr;	tl = mtod(mreq, u_int32_t *);	mreq->m_len = 6 * NFSX_UNSIGNED;	bpos = ((caddr_t)tl) + mreq->m_len;	*tl++ = txdr_unsigned(nd->nd_retxid);	*tl++ = rpc_reply;	if (err == ERPCMISMATCH || (err & NFSERR_AUTHERR)) {		*tl++ = rpc_msgdenied;		if (err & NFSERR_AUTHERR) {			*tl++ = rpc_autherr;			*tl = txdr_unsigned(err & ~NFSERR_AUTHERR);			mreq->m_len -= NFSX_UNSIGNED;			bpos -= NFSX_UNSIGNED;		} else {			*tl++ = rpc_mismatch;			*tl++ = txdr_unsigned(RPC_VER2);			*tl = txdr_unsigned(RPC_VER2);		}	} else {		*tl++ = rpc_msgaccepted;		/*		 * For Kerberos authentication, we must send the nickname		 * verifier back, otherwise just RPCAUTH_NULL.		 */		if (nd->nd_flag & ND_KERBFULL) {		    register struct nfsuid *nuidp;		    struct timeval ktvin, ktvout;		    for (nuidp = NUIDHASH(slp, nd->nd_cr.cr_uid)->lh_first;			nuidp != 0; nuidp = nuidp->nu_hash.le_next) {			if (nuidp->nu_cr.cr_uid == nd->nd_cr.cr_uid &&			    (!nd->nd_nam2 || netaddr_match(NU_NETFAM(nuidp),			     &nuidp->nu_haddr, nd->nd_nam2)))			    break;		    }		    if (nuidp) {			ktvin.tv_sec =			    txdr_unsigned(nuidp->nu_timestamp.tv_sec - 1);			ktvin.tv_usec =			    txdr_unsigned(nuidp->nu_timestamp.tv_usec);			/*			 * Encrypt the timestamp in ecb mode using the			 * session key.			 */#ifdef NFSKERB			XXX#endif			*tl++ = rpc_auth_kerb;			*tl++ = txdr_unsigned(3 * NFSX_UNSIGNED);			*tl = ktvout.tv_sec;			nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED);			*tl++ = ktvout.tv_usec;			*tl++ = txdr_unsigned(nuidp->nu_cr.cr_uid);		    } else {			*tl++ = 0;			*tl++ = 0;		    }		} else {			*tl++ = 0;			*tl++ = 0;		}		switch (err) {		case EPROGUNAVAIL:			*tl = txdr_unsigned(RPC_PROGUNAVAIL);			break;		case EPROGMISMATCH:			*tl = txdr_unsigned(RPC_PROGMISMATCH);			nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED);			if (nd->nd_flag & ND_NQNFS) {				*tl++ = txdr_unsigned(3);				*tl = txdr_unsigned(3);			} else {				*tl++ = txdr_unsigned(2);				*tl = txdr_unsigned(3);			}			break;		case EPROCUNAVAIL:			*tl = txdr_unsigned(RPC_PROCUNAVAIL);			break;		case EBADRPC:			*tl = txdr_unsigned(RPC_GARBAGE);			break;		default:			*tl = 0;			if (err != NFSERR_RETVOID) {				nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);				if (err)				    *tl = txdr_unsigned(nfsrv_errmap(nd, err));				else				    *tl = 0;			}			break;		};	}	/*	 * For nqnfs, piggyback lease as requested.	 */	if ((nd->nd_flag & ND_NQNFS) && err == 0) {		if (nd->nd_flag & ND_LEASE) {			nfsm_build(tl, u_int32_t *, 5 * NFSX_UNSIGNED);			*tl++ = txdr_unsigned(nd->nd_flag & ND_LEASE);			*tl++ = txdr_unsigned(cache);			*tl++ = txdr_unsigned(nd->nd_duration);			txdr_hyper(*frev, tl);		} else {			nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);			*tl = 0;		}	}	*mrq = mreq;	if (mrq != NULL)		*mbp = mb;	*bposp = bpos;	if (err != 0 && err != NFSERR_RETVOID)		nfsstats.srvrpc_errs++;	return (0);}