FreeBSD/Linux Kernel Cross Reference
sys/rpc/rpcm_subs.h
1 /* $FreeBSD: releng/5.2/sys/rpc/rpcm_subs.h 122698 2003-11-14 20:54:10Z alfred $ */
2 /* $OpenBSD: nfsm_subs.h,v 1.11 2000/01/05 20:50:52 millert Exp $ */
3 /* $NetBSD: nfsm_subs.h,v 1.10 1996/03/20 21:59:56 fvdl Exp $ */
4
5 /*
6 * copyright (c) 2003
7 * the regents of the university of michigan
8 * all rights reserved
9 *
10 * permission is granted to use, copy, create derivative works and redistribute
11 * this software and such derivative works for any purpose, so long as the name
12 * of the university of michigan is not used in any advertising or publicity
13 * pertaining to the use or distribution of this software without specific,
14 * written prior authorization. if the above copyright notice or any other
15 * identification of the university of michigan is included in any copy of any
16 * portion of this software, then the disclaimer below must also be included.
17 *
18 * this software is provided as is, without representation from the university
19 * of michigan as to its fitness for any purpose, and without warranty by the
20 * university of michigan of any kind, either express or implied, including
21 * without limitation the implied warranties of merchantability and fitness for
22 * a particular purpose. the regents of the university of michigan shall not be
23 * liable for any damages, including special, indirect, incidental, or
24 * consequential damages, with respect to any claim arising out of or in
25 * connection with the use of the software, even if it has been or is hereafter
26 * advised of the possibility of such damages.
27 */
28
29 /*
30 * Copyright (c) 1989, 1993
31 * The Regents of the University of California. All rights reserved.
32 *
33 * This code is derived from software contributed to Berkeley by
34 * Rick Macklem at The University of Guelph.
35 *
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
38 * are met:
39 * 1. Redistributions of source code must retain the above copyright
40 * notice, this list of conditions and the following disclaimer.
41 * 2. Redistributions in binary form must reproduce the above copyright
42 * notice, this list of conditions and the following disclaimer in the
43 * documentation and/or other materials provided with the distribution.
44 * 3. All advertising materials mentioning features or use of this software
45 * must display the following acknowledgement:
46 * This product includes software developed by the University of
47 * California, Berkeley and its contributors.
48 * 4. Neither the name of the University nor the names of its contributors
49 * may be used to endorse or promote products derived from this software
50 * without specific prior written permission.
51 *
52 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
53 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
54 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
55 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
56 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
57 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
58 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
59 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
60 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
61 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
62 * SUCH DAMAGE.
63 *
64 * @(#)nfsm_subs.h 8.2 (Berkeley) 3/30/95
65 */
66
67
68 #ifndef _RPC_RPCM_SUBS_H_
69 #define _RPC_RPCM_SUBS_H_
70
71
72 /*
73 * Now for the macros that do the simple stuff and call the functions
74 * for the hard stuff.
75 * These macros use several vars. declared in rpcm_reqhead and these
76 * vars. must not be used elsewhere unless you are careful not to corrupt
77 * them. The vars. starting with pN and tN (N=1,2,3,..) are temporaries
78 * that may be used so long as the value is not expected to retained
79 * after a macro.
80 * I know, this is kind of dorkey, but it makes the actual op functions
81 * fairly clean and deals with the mess caused by the xdr discriminating
82 * unions.
83 */
84
85 #define rpcm_build(a,c,s) \
86 { if ((s) > M_TRAILINGSPACE(mb)) { \
87 MGET(mb2, M_WAIT, MT_DATA); \
88 if ((s) > MLEN) \
89 panic("build > MLEN"); \
90 mb->m_next = mb2; \
91 mb = mb2; \
92 mb->m_len = 0; \
93 bpos = mtod(mb, caddr_t); \
94 } \
95 (a) = (c)(bpos); \
96 mb->m_len += (s); \
97 bpos += (s); }
98
99 #define rpcm_dissect(a, c, s) \
100 { t1 = mtod(md, caddr_t)+md->m_len-dpos; \
101 if (t1 >= (s)) { \
102 (a) = (c)(dpos); \
103 dpos += (s); \
104 } else if ((t1 = rpcm_disct(&md, &dpos, (s), t1, &cp2)) != 0){ \
105 error = t1; \
106 goto rpcmout; \
107 } else { \
108 (a) = (c)cp2; \
109 } }
110
111 #if 0
112 #define rpcm_mtouio(p,s) \
113 if ((s) > 0 && \
114 (t1 = rpcm_mbuftouio(&md,(p),(s),&dpos)) != 0) { \
115 error = t1; \
116 goto rpcmout; \
117 }
118 #endif
119
120 #define rpcm_rndup(a) (((a)+3)&(~0x3))
121
122 #define rpcm_adv(s) \
123 { t1 = mtod(md, caddr_t)+md->m_len-dpos; \
124 if (t1 >= (s)) { \
125 dpos += (s); \
126 } else if ((t1 = rpc_adv(&md, &dpos, (s), t1)) != 0) { \
127 error = t1; \
128 goto rpcmout; \
129 } }
130
131 #define RPCMADV(m, s) (m)->m_data += (s)
132
133 #endif /* _RPC_RPCM_SUBS_H_ */
Cache object: 6c9f5b0652f181c86ff64b6d12230bec
|