Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/sys/rpc/rpc_msg.h
39475 views
1
/* $NetBSD: rpc_msg.h,v 1.11 2000/06/02 22:57:56 fvdl Exp $ */
2
3
/*-
4
* SPDX-License-Identifier: BSD-3-Clause
5
*
6
* Copyright (c) 2009, Sun Microsystems, Inc.
7
* All rights reserved.
8
*
9
* Redistribution and use in source and binary forms, with or without
10
* modification, are permitted provided that the following conditions are met:
11
* - Redistributions of source code must retain the above copyright notice,
12
* this list of conditions and the following disclaimer.
13
* - Redistributions in binary form must reproduce the above copyright notice,
14
* this list of conditions and the following disclaimer in the documentation
15
* and/or other materials provided with the distribution.
16
* - Neither the name of Sun Microsystems, Inc. nor the names of its
17
* contributors may be used to endorse or promote products derived
18
* from this software without specific prior written permission.
19
*
20
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
24
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
* POSSIBILITY OF SUCH DAMAGE.
31
*/
32
33
/*
34
* rpc_msg.h
35
* rpc message definition
36
*
37
* Copyright (C) 1984, Sun Microsystems, Inc.
38
*/
39
40
#ifndef _RPC_RPC_MSG_H
41
#define _RPC_RPC_MSG_H
42
43
#define RPC_MSG_VERSION ((uint32_t) 2)
44
#define RPC_SERVICE_PORT ((u_short) 2048)
45
46
/*
47
* Bottom up definition of an rpc message.
48
* NOTE: call and reply use the same overall stuct but
49
* different parts of unions within it.
50
*/
51
52
enum msg_type {
53
CALL=0,
54
REPLY=1
55
};
56
57
enum reply_stat {
58
MSG_ACCEPTED=0,
59
MSG_DENIED=1
60
};
61
62
enum accept_stat {
63
SUCCESS=0,
64
PROG_UNAVAIL=1,
65
PROG_MISMATCH=2,
66
PROC_UNAVAIL=3,
67
GARBAGE_ARGS=4,
68
SYSTEM_ERR=5
69
};
70
71
enum reject_stat {
72
RPC_MISMATCH=0,
73
AUTH_ERROR=1
74
};
75
76
/*
77
* Reply part of an rpc exchange
78
*/
79
80
/*
81
* Reply to an rpc request that was accepted by the server.
82
* Note: there could be an error even though the request was
83
* accepted.
84
*/
85
struct accepted_reply {
86
struct opaque_auth ar_verf;
87
enum accept_stat ar_stat;
88
union {
89
struct {
90
rpcvers_t low;
91
rpcvers_t high;
92
} AR_versions;
93
struct {
94
caddr_t where;
95
xdrproc_t proc;
96
} AR_results;
97
/* and many other null cases */
98
} ru;
99
#define ar_results ru.AR_results
100
#define ar_vers ru.AR_versions
101
};
102
103
/*
104
* Reply to an rpc request that was rejected by the server.
105
*/
106
struct rejected_reply {
107
enum reject_stat rj_stat;
108
union {
109
struct {
110
rpcvers_t low;
111
rpcvers_t high;
112
} RJ_versions;
113
enum auth_stat RJ_why; /* why authentication did not work */
114
} ru;
115
#define rj_vers ru.RJ_versions
116
#define rj_why ru.RJ_why
117
};
118
119
/*
120
* Body of a reply to an rpc request.
121
*/
122
struct reply_body {
123
enum reply_stat rp_stat;
124
union {
125
struct accepted_reply RP_ar;
126
struct rejected_reply RP_dr;
127
} ru;
128
#define rp_acpt ru.RP_ar
129
#define rp_rjct ru.RP_dr
130
};
131
132
/*
133
* Body of an rpc request call.
134
*/
135
struct call_body {
136
rpcvers_t cb_rpcvers; /* must be equal to two */
137
rpcprog_t cb_prog;
138
rpcvers_t cb_vers;
139
rpcproc_t cb_proc;
140
struct opaque_auth cb_cred;
141
struct opaque_auth cb_verf; /* protocol specific - provided by client */
142
};
143
144
/*
145
* The rpc message
146
*/
147
struct rpc_msg {
148
uint32_t rm_xid;
149
enum msg_type rm_direction;
150
union {
151
struct call_body RM_cmb;
152
struct reply_body RM_rmb;
153
} ru;
154
#define rm_call ru.RM_cmb
155
#define rm_reply ru.RM_rmb
156
};
157
#define acpted_rply ru.RM_rmb.ru.RP_ar
158
#define rjcted_rply ru.RM_rmb.ru.RP_dr
159
160
__BEGIN_DECLS
161
/*
162
* XDR routine to handle a rpc message.
163
* xdr_callmsg(xdrs, cmsg)
164
* XDR *xdrs;
165
* struct rpc_msg *cmsg;
166
*/
167
extern bool_t xdr_callmsg(XDR *, struct rpc_msg *);
168
169
/*
170
* XDR routine to pre-serialize the static part of a rpc message.
171
* xdr_callhdr(xdrs, cmsg)
172
* XDR *xdrs;
173
* struct rpc_msg *cmsg;
174
*/
175
extern bool_t xdr_callhdr(XDR *, struct rpc_msg *);
176
177
/*
178
* XDR routine to handle a rpc reply.
179
* xdr_replymsg(xdrs, rmsg)
180
* XDR *xdrs;
181
* struct rpc_msg *rmsg;
182
*/
183
extern bool_t xdr_replymsg(XDR *, struct rpc_msg *);
184
185
186
/*
187
* XDR routine to handle an accepted rpc reply.
188
* xdr_accepted_reply(xdrs, rej)
189
* XDR *xdrs;
190
* struct accepted_reply *rej;
191
*/
192
extern bool_t xdr_accepted_reply(XDR *, struct accepted_reply *);
193
194
/*
195
* XDR routine to handle a rejected rpc reply.
196
* xdr_rejected_reply(xdrs, rej)
197
* XDR *xdrs;
198
* struct rejected_reply *rej;
199
*/
200
extern bool_t xdr_rejected_reply(XDR *, struct rejected_reply *);
201
202
/*
203
* Fills in the error part of a reply message.
204
* _seterr_reply(msg, error)
205
* struct rpc_msg *msg;
206
* struct rpc_err *error;
207
*/
208
extern enum clnt_stat _seterr_reply(struct rpc_msg *, struct rpc_err *);
209
__END_DECLS
210
211
#endif /* !_RPC_RPC_MSG_H */
212
213