/* $OpenBSD: nfsm_subs.h,v 1.11 2000/01/05 20:50:52 millert Exp $ */1/* $NetBSD: nfsm_subs.h,v 1.10 1996/03/20 21:59:56 fvdl Exp $ */23/*-4* SPDX-License-Identifier: BSD-3-Clause5*6* copyright (c) 20037* the regents of the university of michigan8* all rights reserved9*10* permission is granted to use, copy, create derivative works and redistribute11* this software and such derivative works for any purpose, so long as the name12* of the university of michigan is not used in any advertising or publicity13* pertaining to the use or distribution of this software without specific,14* written prior authorization. if the above copyright notice or any other15* identification of the university of michigan is included in any copy of any16* portion of this software, then the disclaimer below must also be included.17*18* this software is provided as is, without representation from the university19* of michigan as to its fitness for any purpose, and without warranty by the20* university of michigan of any kind, either express or implied, including21* without limitation the implied warranties of merchantability and fitness for22* a particular purpose. the regents of the university of michigan shall not be23* liable for any damages, including special, indirect, incidental, or24* consequential damages, with respect to any claim arising out of or in25* connection with the use of the software, even if it has been or is hereafter26* advised of the possibility of such damages.27*/2829/*-30* Copyright (c) 1989, 199331* The Regents of the University of California. All rights reserved.32*33* This code is derived from software contributed to Berkeley by34* Rick Macklem at The University of Guelph.35*36* Redistribution and use in source and binary forms, with or without37* modification, are permitted provided that the following conditions38* are met:39* 1. Redistributions of source code must retain the above copyright40* notice, this list of conditions and the following disclaimer.41* 2. Redistributions in binary form must reproduce the above copyright42* notice, this list of conditions and the following disclaimer in the43* documentation and/or other materials provided with the distribution.44* 3. Neither the name of the University nor the names of its contributors45* may be used to endorse or promote products derived from this software46* without specific prior written permission.47*48* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND49* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE50* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE51* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE52* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL53* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS54* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)55* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT56* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY57* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF58* SUCH DAMAGE.59*/606162#ifndef _RPC_RPCM_SUBS_H_63#define _RPC_RPCM_SUBS_H_646566/*67* Now for the macros that do the simple stuff and call the functions68* for the hard stuff.69* These macros use several vars. declared in rpcm_reqhead and these70* vars. must not be used elsewhere unless you are careful not to corrupt71* them. The vars. starting with pN and tN (N=1,2,3,..) are temporaries72* that may be used so long as the value is not expected to retained73* after a macro.74* I know, this is kind of dorkey, but it makes the actual op functions75* fairly clean and deals with the mess caused by the xdr discriminating76* unions.77*/7879#define rpcm_build(a,c,s) \80{ if ((s) > M_TRAILINGSPACE(mb)) { \81mb2 = m_get(M_WAITOK, MT_DATA); \82if ((s) > MLEN) \83panic("build > MLEN"); \84mb->m_next = mb2; \85mb = mb2; \86mb->m_len = 0; \87bpos = mtod(mb, caddr_t); \88} \89(a) = (c)(bpos); \90mb->m_len += (s); \91bpos += (s); }9293#define rpcm_dissect(a, c, s) \94{ t1 = mtod(md, caddr_t)+md->m_len-dpos; \95if (t1 >= (s)) { \96(a) = (c)(dpos); \97dpos += (s); \98} else if ((t1 = rpcm_disct(&md, &dpos, (s), t1, &cp2)) != 0){ \99error = t1; \100goto rpcmout; \101} else { \102(a) = (c)cp2; \103} }104105#if 0106#define rpcm_mtouio(p,s) \107if ((s) > 0 && \108(t1 = rpcm_mbuftouio(&md,(p),(s),&dpos)) != 0) { \109error = t1; \110goto rpcmout; \111}112#endif113114#define rpcm_rndup(a) (((a)+3)&(~0x3))115116#define rpcm_adv(s) \117{ t1 = mtod(md, caddr_t)+md->m_len-dpos; \118if (t1 >= (s)) { \119dpos += (s); \120} else if ((t1 = rpc_adv(&md, &dpos, (s), t1)) != 0) { \121error = t1; \122goto rpcmout; \123} }124125#define RPCMADV(m, s) (m)->m_data += (s)126127#endif /* _RPC_RPCM_SUBS_H_ */128129130