Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-03-13 09:28:11

0001 /*  $NetBSD: rpc_msg.h,v 1.11 2000/06/02 22:57:56 fvdl Exp $    */
0002 
0003 /*
0004  * Copyright (c) 2009, Sun Microsystems, Inc.
0005  * All rights reserved.
0006  *
0007  * Redistribution and use in source and binary forms, with or without
0008  * modification, are permitted provided that the following conditions are met:
0009  * - Redistributions of source code must retain the above copyright notice,
0010  *   this list of conditions and the following disclaimer.
0011  * - Redistributions in binary form must reproduce the above copyright notice,
0012  *   this list of conditions and the following disclaimer in the documentation
0013  *   and/or other materials provided with the distribution.
0014  * - Neither the name of Sun Microsystems, Inc. nor the names of its
0015  *   contributors may be used to endorse or promote products derived
0016  *   from this software without specific prior written permission.
0017  *
0018  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0019  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0020  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0021  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
0022  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0023  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0024  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0025  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0026  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0027  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0028  * POSSIBILITY OF SUCH DAMAGE.
0029  *
0030  *  from: @(#)rpc_msg.h 1.7 86/07/16 SMI
0031  *  from: @(#)rpc_msg.h 2.1 88/07/29 4.0 RPCSRC
0032  * $FreeBSD: src/include/rpc/rpc_msg.h,v 1.15 2003/01/01 18:48:42 schweikh Exp $
0033  */
0034 
0035 /*
0036  * rpc_msg.h
0037  * rpc message definition
0038  *
0039  * Copyright (C) 1984, Sun Microsystems, Inc.
0040  */
0041 
0042 #ifndef _TIRPC_RPC_MSG_H
0043 #define _TIRPC_RPC_MSG_H
0044 
0045 #define RPC_MSG_VERSION     ((u_int32_t) 2)
0046 #define RPC_SERVICE_PORT    ((u_short) 2048)
0047 
0048 #include <rpc/auth.h>
0049 
0050 /*
0051  * Bottom up definition of an rpc message.
0052  * NOTE: call and reply use the same overall stuct but
0053  * different parts of unions within it.
0054  */
0055 
0056 enum msg_type {
0057     CALL=0,
0058     REPLY=1
0059 };
0060 
0061 enum reply_stat {
0062     MSG_ACCEPTED=0,
0063     MSG_DENIED=1
0064 };
0065 
0066 enum accept_stat {
0067     SUCCESS=0,
0068     PROG_UNAVAIL=1,
0069     PROG_MISMATCH=2,
0070     PROC_UNAVAIL=3,
0071     GARBAGE_ARGS=4,
0072     SYSTEM_ERR=5
0073 };
0074 
0075 enum reject_stat {
0076     RPC_MISMATCH=0,
0077     AUTH_ERROR=1
0078 };
0079 
0080 /*
0081  * Reply part of an rpc exchange
0082  */
0083 
0084 /*
0085  * Reply to an rpc request that was accepted by the server.
0086  * Note: there could be an error even though the request was
0087  * accepted.
0088  */
0089 struct accepted_reply {
0090     struct opaque_auth  ar_verf;
0091     enum accept_stat    ar_stat;
0092     union {
0093         struct {
0094             rpcvers_t low;
0095             rpcvers_t high;
0096         } AR_versions;
0097         struct {
0098             caddr_t where;
0099             xdrproc_t proc;
0100         } AR_results;
0101         /* and many other null cases */
0102     } ru;
0103 #define ar_results  ru.AR_results
0104 #define ar_vers     ru.AR_versions
0105 };
0106 
0107 /*
0108  * Reply to an rpc request that was rejected by the server.
0109  */
0110 struct rejected_reply {
0111     enum reject_stat rj_stat;
0112     union {
0113         struct {
0114             rpcvers_t low;
0115             rpcvers_t high;
0116         } RJ_versions;
0117         enum auth_stat RJ_why;  /* why authentication did not work */
0118     } ru;
0119 #define rj_vers ru.RJ_versions
0120 #define rj_why  ru.RJ_why
0121 };
0122 
0123 /*
0124  * Body of a reply to an rpc request.
0125  */
0126 struct reply_body {
0127     enum reply_stat rp_stat;
0128     union {
0129         struct accepted_reply RP_ar;
0130         struct rejected_reply RP_dr;
0131     } ru;
0132 #define rp_acpt ru.RP_ar
0133 #define rp_rjct ru.RP_dr
0134 };
0135 
0136 /*
0137  * Body of an rpc request call.
0138  */
0139 struct call_body {
0140     rpcvers_t cb_rpcvers;   /* must be equal to two */
0141     rpcprog_t cb_prog;
0142     rpcvers_t cb_vers;
0143     rpcproc_t cb_proc;
0144     struct opaque_auth cb_cred;
0145     struct opaque_auth cb_verf; /* protocol specific - provided by client */
0146 };
0147 
0148 /*
0149  * The rpc message
0150  */
0151 struct rpc_msg {
0152     u_int32_t       rm_xid;
0153     enum msg_type       rm_direction;
0154     union {
0155         struct call_body RM_cmb;
0156         struct reply_body RM_rmb;
0157     } ru;
0158 #define rm_call     ru.RM_cmb
0159 #define rm_reply    ru.RM_rmb
0160 };
0161 #define acpted_rply ru.RM_rmb.ru.RP_ar
0162 #define rjcted_rply ru.RM_rmb.ru.RP_dr
0163 
0164 #ifdef __cplusplus
0165 extern "C" {
0166 #endif
0167 /*
0168  * XDR routine to handle a rpc message.
0169  * xdr_callmsg(xdrs, cmsg)
0170  *  XDR *xdrs;
0171  *  struct rpc_msg *cmsg;
0172  */
0173 extern bool_t   xdr_callmsg(XDR *, struct rpc_msg *);
0174 
0175 /*
0176  * XDR routine to pre-serialize the static part of a rpc message.
0177  * xdr_callhdr(xdrs, cmsg)
0178  *  XDR *xdrs;
0179  *  struct rpc_msg *cmsg;
0180  */
0181 extern bool_t   xdr_callhdr(XDR *, struct rpc_msg *);
0182 
0183 /*
0184  * XDR routine to handle a rpc reply.
0185  * xdr_replymsg(xdrs, rmsg)
0186  *  XDR *xdrs;
0187  *  struct rpc_msg *rmsg;
0188  */
0189 extern bool_t   xdr_replymsg(XDR *, struct rpc_msg *);
0190 
0191 
0192 /*
0193  * XDR routine to handle an accepted rpc reply.
0194  * xdr_accepted_reply(xdrs, rej)
0195  *  XDR *xdrs;
0196  *  struct accepted_reply *rej;
0197  */
0198 extern bool_t   xdr_accepted_reply(XDR *, struct accepted_reply *);
0199 
0200 /*
0201  * XDR routine to handle a rejected rpc reply.
0202  * xdr_rejected_reply(xdrs, rej)
0203  *  XDR *xdrs;
0204  *  struct rejected_reply *rej;
0205  */
0206 extern bool_t   xdr_rejected_reply(XDR *, struct rejected_reply *);
0207 
0208 /*
0209  * Fills in the error part of a reply message.
0210  * _seterr_reply(msg, error)
0211  *  struct rpc_msg *msg;
0212  *  struct rpc_err *error;
0213  */
0214 extern void _seterr_reply(struct rpc_msg *, struct rpc_err *);
0215 #ifdef __cplusplus
0216 }
0217 #endif
0218 
0219 #endif /* !_TIRPC_RPC_MSG_H */