+
+int nfsm_rpchead(struct nfsreq *, mbuf_t, u_int64_t *, mbuf_t *);
+int nfsm_rpchead2(struct nfsmount *, int, int, int, int, int, kauth_cred_t, struct nfsreq *, mbuf_t, u_int64_t *, mbuf_t *);
+
+int nfsm_chain_new_mbuf(struct nfsm_chain *, size_t);
+int nfsm_chain_add_opaque_f(struct nfsm_chain *, const u_char *, uint32_t);
+int nfsm_chain_add_opaque_nopad_f(struct nfsm_chain *, const u_char *, uint32_t);
+int nfsm_chain_add_uio(struct nfsm_chain *, uio_t, uint32_t);
+int nfsm_chain_add_fattr4_f(struct nfsm_chain *, struct vnode_attr *, struct nfsmount *);
+int nfsm_chain_add_v2sattr_f(struct nfsm_chain *, struct vnode_attr *, uint32_t);
+int nfsm_chain_add_v3sattr_f(struct nfsm_chain *, struct vnode_attr *);
+int nfsm_chain_add_string_nfc(struct nfsm_chain *, const uint8_t *, uint32_t);
+
+int nfsm_chain_advance(struct nfsm_chain *, uint32_t);
+int nfsm_chain_offset(struct nfsm_chain *);
+int nfsm_chain_reverse(struct nfsm_chain *, uint32_t);
+int nfsm_chain_get_opaque_pointer_f(struct nfsm_chain *, uint32_t, u_char **);
+int nfsm_chain_get_opaque_f(struct nfsm_chain *, uint32_t, u_char *);
+int nfsm_chain_get_uio(struct nfsm_chain *, uint32_t, uio_t);
+int nfsm_chain_get_fh_attr(struct nfsm_chain *, nfsnode_t,
+ vfs_context_t, int, uint64_t *, fhandle_t *, struct nfs_vattr *);
+int nfsm_chain_get_wcc_data_f(struct nfsm_chain *, nfsnode_t, struct timespec *, int *, u_int64_t *);
+int nfsm_chain_get_secinfo(struct nfsm_chain *, uint32_t *, int *);
+
+#if NFSSERVER
+void nfsm_adj(mbuf_t, int, int);
+int nfsm_mbuf_get_list(size_t, mbuf_t *, int *);
+
+int nfsm_chain_add_fattr(struct nfsrv_descript *, struct nfsm_chain *, struct vnode_attr *);
+int nfsm_chain_add_wcc_data_f(struct nfsrv_descript *, struct nfsm_chain *, int,
+ struct vnode_attr *, int, struct vnode_attr *);
+int nfsm_chain_get_path_namei(struct nfsm_chain *, uint32_t, struct nameidata *);
+int nfsm_chain_get_sattr(struct nfsrv_descript *, struct nfsm_chain *, struct vnode_attr *);
+int nfsm_chain_trim_data(struct nfsm_chain *, int, int *);
+#endif /* NFSSERVER */
+
+/* check name length */
+#define nfsm_name_len_check(E, ND, LEN) \
+ do { \
+ if (E) break; \
+ if (((ND)->nd_vers == NFS_VER2) && ((LEN) > NFS_MAXNAMLEN)) \
+ (E) = NFSERR_NAMETOL; \
+ if ((LEN) <= 0) \
+ error = EBADRPC; \
+ } while (0)
+
+#define nfsm_assert(E, COND, ERR) \
+ do { \
+ if (E) break; \
+ if (!(COND)) \
+ (E) = (ERR); \
+ } while (0)
+
+/* Initialize a vnode_attr to retrieve attributes for the NFS server. */
+#define nfsm_srv_vattr_init(VAP, VERS) \
+ do { \
+ VATTR_INIT(VAP); \
+ VATTR_WANTED((VAP), va_type); \
+ VATTR_WANTED((VAP), va_mode); \
+ VATTR_WANTED((VAP), va_nlink); \
+ VATTR_WANTED((VAP), va_uid); \
+ VATTR_WANTED((VAP), va_gid); \
+ VATTR_WANTED((VAP), va_data_size); \
+ VATTR_WANTED((VAP), va_data_alloc); \
+ VATTR_WANTED((VAP), va_rdev); \
+ VATTR_WANTED((VAP), va_fsid); \
+ VATTR_WANTED((VAP), va_fileid); \
+ VATTR_WANTED((VAP), va_access_time); \
+ VATTR_WANTED((VAP), va_modify_time); \
+ VATTR_WANTED((VAP), va_change_time); \
+ if ((VERS) == NFS_VER2) \
+ VATTR_WANTED((VAP), va_iosize); \
+ } while (0)
+
+/* Initialize a vnode_attr to retrieve pre-operation attributes for the NFS server. */
+#define nfsm_srv_pre_vattr_init(VAP) \
+ do { \
+ VATTR_INIT(VAP); \
+ VATTR_WANTED((VAP), va_data_size); \
+ VATTR_WANTED((VAP), va_modify_time); \
+ VATTR_WANTED((VAP), va_change_time); \
+ } while (0)
+
+/* round up to a multiple of 4 */
+#define nfsm_rndup(a) (((a)+3)&(~0x3))
+
+#define nfsm_pad(a) (nfsm_rndup(a) - (a))
+