Back to index

glibc  2.9
rpc_msg.h
Go to the documentation of this file.
00001 /* @(#)rpc_msg.h     2.1 88/07/29 4.0 RPCSRC */
00002 /*
00003  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
00004  * unrestricted use provided that this legend is included on all tape
00005  * media and as a part of the software program in whole or part.  Users
00006  * may copy or modify Sun RPC without charge, but are not authorized
00007  * to license or distribute it to anyone else except as part of a product or
00008  * program developed by the user.
00009  *
00010  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
00011  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
00012  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
00013  *
00014  * Sun RPC is provided with no support and without any obligation on the
00015  * part of Sun Microsystems, Inc. to assist in its use, correction,
00016  * modification or enhancement.
00017  *
00018  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
00019  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
00020  * OR ANY PART THEREOF.
00021  *
00022  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
00023  * or profits or other special, indirect and consequential damages, even if
00024  * Sun has been advised of the possibility of such damages.
00025  *
00026  * Sun Microsystems, Inc.
00027  * 2550 Garcia Avenue
00028  * Mountain View, California  94043
00029  */
00030 /*      @(#)rpc_msg.h 1.7 86/07/16 SMI      */
00031 
00032 #ifndef _RPC_MSG_H
00033 #define _RPC_MSG_H 1
00034 
00035 #include <sys/cdefs.h>
00036 
00037 #include <rpc/xdr.h>
00038 #include <rpc/clnt.h>
00039 
00040 /*
00041  * rpc_msg.h
00042  * rpc message definition
00043  *
00044  * Copyright (C) 1984, Sun Microsystems, Inc.
00045  */
00046 
00047 #define RPC_MSG_VERSION            ((u_long) 2)
00048 #define RPC_SERVICE_PORT    ((u_short) 2048)
00049 
00050 __BEGIN_DECLS
00051 
00052 /*
00053  * Bottom up definition of an rpc message.
00054  * NOTE: call and reply use the same overall struct but
00055  * different parts of unions within it.
00056  */
00057 
00058 enum msg_type {
00059        CALL=0,
00060        REPLY=1
00061 };
00062 
00063 enum reply_stat {
00064        MSG_ACCEPTED=0,
00065        MSG_DENIED=1
00066 };
00067 
00068 enum accept_stat {
00069        SUCCESS=0,
00070        PROG_UNAVAIL=1,
00071        PROG_MISMATCH=2,
00072        PROC_UNAVAIL=3,
00073        GARBAGE_ARGS=4,
00074        SYSTEM_ERR=5
00075 };
00076 
00077 enum reject_stat {
00078        RPC_MISMATCH=0,
00079        AUTH_ERROR=1
00080 };
00081 
00082 /*
00083  * Reply part of an rpc exchange
00084  */
00085 
00086 /*
00087  * Reply to an rpc request that was accepted by the server.
00088  * Note: there could be an error even though the request was
00089  * accepted.
00090  */
00091 struct accepted_reply {
00092        struct opaque_auth   ar_verf;
00093        enum accept_stat     ar_stat;
00094        union {
00095               struct {
00096                      u_long low;
00097                      u_long high;
00098               } AR_versions;
00099               struct {
00100                      caddr_t       where;
00101                      xdrproc_t proc;
00102               } AR_results;
00103               /* and many other null cases */
00104        } ru;
00105 #define       ar_results    ru.AR_results
00106 #define       ar_vers              ru.AR_versions
00107 };
00108 
00109 /*
00110  * Reply to an rpc request that was rejected by the server.
00111  */
00112 struct rejected_reply {
00113        enum reject_stat rj_stat;
00114        union {
00115               struct {
00116                      u_long low;
00117                      u_long high;
00118               } RJ_versions;
00119               enum auth_stat RJ_why;  /* why authentication did not work */
00120        } ru;
00121 #define       rj_vers       ru.RJ_versions
00122 #define       rj_why ru.RJ_why
00123 };
00124 
00125 /*
00126  * Body of a reply to an rpc request.
00127  */
00128 struct reply_body {
00129        enum reply_stat rp_stat;
00130        union {
00131               struct accepted_reply RP_ar;
00132               struct rejected_reply RP_dr;
00133        } ru;
00134 #define       rp_acpt       ru.RP_ar
00135 #define       rp_rjct       ru.RP_dr
00136 };
00137 
00138 /*
00139  * Body of an rpc request call.
00140  */
00141 struct call_body {
00142        u_long cb_rpcvers;   /* must be equal to two */
00143        u_long cb_prog;
00144        u_long cb_vers;
00145        u_long cb_proc;
00146        struct opaque_auth cb_cred;
00147        struct opaque_auth cb_verf; /* protocol specific - provided by client */
00148 };
00149 
00150 /*
00151  * The rpc message
00152  */
00153 struct rpc_msg {
00154        u_long               rm_xid;
00155        enum msg_type        rm_direction;
00156        union {
00157               struct call_body RM_cmb;
00158               struct reply_body RM_rmb;
00159        } ru;
00160 #define       rm_call              ru.RM_cmb
00161 #define       rm_reply      ru.RM_rmb
00162 };
00163 #define       acpted_rply   ru.RM_rmb.ru.RP_ar
00164 #define       rjcted_rply   ru.RM_rmb.ru.RP_dr
00165 
00166 
00167 /*
00168  * XDR routine to handle a rpc message.
00169  * xdr_callmsg(xdrs, cmsg)
00170  *     XDR *xdrs;
00171  *     struct rpc_msg *cmsg;
00172  */
00173 extern bool_t xdr_callmsg (XDR *__xdrs, struct rpc_msg *__cmsg) __THROW;
00174 
00175 /*
00176  * XDR routine to pre-serialize the static part of a rpc message.
00177  * xdr_callhdr(xdrs, cmsg)
00178  *     XDR *xdrs;
00179  *     struct rpc_msg *cmsg;
00180  */
00181 extern bool_t xdr_callhdr (XDR *__xdrs, struct rpc_msg *__cmsg) __THROW;
00182 
00183 /*
00184  * XDR routine to handle a rpc reply.
00185  * xdr_replymsg(xdrs, rmsg)
00186  *     XDR *xdrs;
00187  *     struct rpc_msg *rmsg;
00188  */
00189 extern bool_t xdr_replymsg (XDR *__xdrs, struct rpc_msg *__rmsg) __THROW;
00190 
00191 /*
00192  * Fills in the error part of a reply message.
00193  * _seterr_reply(msg, error)
00194  *     struct rpc_msg *msg;
00195  *     struct rpc_err *error;
00196  */
00197 extern void   _seterr_reply (struct rpc_msg *__msg, struct rpc_err *__error)
00198      __THROW;
00199 
00200 __END_DECLS
00201 
00202 #endif /* rpc/rpc_msg.h */