Dr Andrew Scott G7VAV

My photo
 
June 2025
Mo Tu We Th Fr Sa Su
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 1 2 3 4 5 6


rpc_msg.h
001: /*
002:  * rpc_msg.h
003:  * rpc message definition
004:  *
005:  * Copyright (c) 2010, Oracle America, Inc.
006:  *
007:  * Redistribution and use in source and binary forms, with or without
008:  * modification, are permitted provided that the following conditions are
009:  * met:
010:  *
011:  *     * Redistributions of source code must retain the above copyright
012:  *       notice, this list of conditions and the following disclaimer.
013:  *     * Redistributions in binary form must reproduce the above
014:  *       copyright notice, this list of conditions and the following
015:  *       disclaimer in the documentation and/or other materials
016:  *       provided with the distribution.
017:  *     * Neither the name of the "Oracle America, Inc." nor the names of its
018:  *       contributors may be used to endorse or promote products derived
019:  *       from this software without specific prior written permission.
020:  *
021:  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
022:  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
023:  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
024:  *   FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
025:  *   COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
026:  *   INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
027:  *   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
028:  *   GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
029:  *   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
030:  *   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
031:  *   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
032:  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
033:  */
034: 
035: #ifndef _RPC_MSG_H
036: #define _RPC_MSG_H 1
037: 
038: #include <sys/cdefs.h>
039: 
040: #include <rpc/xdr.h>
041: #include <rpc/clnt.h>
042: 
043: #define RPC_MSG_VERSION         ((u_long) 2)
044: #define RPC_SERVICE_PORT        ((u_short) 2048)
045: 
046: __BEGIN_DECLS
047: 
048: /*
049:  * Bottom up definition of an rpc message.
050:  * NOTE: call and reply use the same overall struct but
051:  * different parts of unions within it.
052:  */
053: 
054: enum msg_type {
055:         CALL=0,
056:         REPLY=1
057: };
058: 
059: enum reply_stat {
060:         MSG_ACCEPTED=0,
061:         MSG_DENIED=1
062: };
063: 
064: enum accept_stat {
065:         SUCCESS=0,
066:         PROG_UNAVAIL=1,
067:         PROG_MISMATCH=2,
068:         PROC_UNAVAIL=3,
069:         GARBAGE_ARGS=4,
070:         SYSTEM_ERR=5
071: };
072: 
073: enum reject_stat {
074:         RPC_MISMATCH=0,
075:         AUTH_ERROR=1
076: };
077: 
078: /*
079:  * Reply part of an rpc exchange
080:  */
081: 
082: /*
083:  * Reply to an rpc request that was accepted by the server.
084:  * Note: there could be an error even though the request was
085:  * accepted.
086:  */
087: struct accepted_reply {
088:         struct opaque_auth      ar_verf;
089:         enum accept_stat        ar_stat;
090:         union {
091:                 struct {
092:                         u_long  low;
093:                         u_long  high;
094:                 } AR_versions;
095:                 struct {
096:                         caddr_t where;
097:                         xdrproc_t proc;
098:                 } AR_results;
099:                 /* and many other null cases */
100:         } ru;
101: #define ar_results      ru.AR_results
102: #define ar_vers         ru.AR_versions
103: };
104: 
105: /*
106:  * Reply to an rpc request that was rejected by the server.
107:  */
108: struct rejected_reply {
109:         enum reject_stat rj_stat;
110:         union {
111:                 struct {
112:                         u_long low;
113:                         u_long high;
114:                 } RJ_versions;
115:                 enum auth_stat RJ_why;  /* why authentication did not work */
116:         } ru;
117: #define rj_vers ru.RJ_versions
118: #define rj_why  ru.RJ_why
119: };
120: 
121: /*
122:  * Body of a reply to an rpc request.
123:  */
124: struct reply_body {
125:         enum reply_stat rp_stat;
126:         union {
127:                 struct accepted_reply RP_ar;
128:                 struct rejected_reply RP_dr;
129:         } ru;
130: #define rp_acpt ru.RP_ar
131: #define rp_rjct ru.RP_dr
132: };
133: 
134: /*
135:  * Body of an rpc request call.
136:  */
137: struct call_body {
138:         u_long cb_rpcvers;      /* must be equal to two */
139:         u_long cb_prog;
140:         u_long cb_vers;
141:         u_long cb_proc;
142:         struct opaque_auth cb_cred;
143:         struct opaque_auth cb_verf; /* protocol specific - provided by client */
144: };
145: 
146: /*
147:  * The rpc message
148:  */
149: struct rpc_msg {
150:         u_long                  rm_xid;
151:         enum msg_type           rm_direction;
152:         union {
153:                 struct call_body RM_cmb;
154:                 struct reply_body RM_rmb;
155:         } ru;
156: #define rm_call         ru.RM_cmb
157: #define rm_reply        ru.RM_rmb
158: };
159: #define acpted_rply     ru.RM_rmb.ru.RP_ar
160: #define rjcted_rply     ru.RM_rmb.ru.RP_dr
161: 
162: 
163: /*
164:  * XDR routine to handle a rpc message.
165:  * xdr_callmsg(xdrs, cmsg)
166:  *      XDR *xdrs;
167:  *      struct rpc_msg *cmsg;
168:  */
169: extern bool_t   xdr_callmsg (XDR *__xdrs, struct rpc_msg *__cmsg) __THROW;
170: 
171: /*
172:  * XDR routine to pre-serialize the static part of a rpc message.
173:  * xdr_callhdr(xdrs, cmsg)
174:  *      XDR *xdrs;
175:  *      struct rpc_msg *cmsg;
176:  */
177: extern bool_t   xdr_callhdr (XDR *__xdrs, struct rpc_msg *__cmsg) __THROW;
178: 
179: /*
180:  * XDR routine to handle a rpc reply.
181:  * xdr_replymsg(xdrs, rmsg)
182:  *      XDR *xdrs;
183:  *      struct rpc_msg *rmsg;
184:  */
185: extern bool_t   xdr_replymsg (XDR *__xdrs, struct rpc_msg *__rmsg) __THROW;
186: 
187: /*
188:  * Fills in the error part of a reply message.
189:  * _seterr_reply(msg, error)
190:  *      struct rpc_msg *msg;
191:  *      struct rpc_err *error;
192:  */
193: extern void     _seterr_reply (struct rpc_msg *__msg, struct rpc_err *__error)
194:      __THROW;
195: 
196: __END_DECLS
197: 
198: #endif /* rpc/rpc_msg.h */
199: 


for client (none)
© Andrew Scott 2006 - 2025,
All Rights Reserved
http://www.andrew-scott.uk/
Andrew Scott
http://www.andrew-scott.co.uk/