1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ 27*7c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 28*7c478bd9Sstevel@tonic-gate /* 29*7c478bd9Sstevel@tonic-gate * Portions of this source code were derived from Berkeley 30*7c478bd9Sstevel@tonic-gate * 4.3 BSD under license from the Regents of the University of 31*7c478bd9Sstevel@tonic-gate * California. 32*7c478bd9Sstevel@tonic-gate */ 33*7c478bd9Sstevel@tonic-gate 34*7c478bd9Sstevel@tonic-gate #ifndef _RPC_RPC_MSG_H 35*7c478bd9Sstevel@tonic-gate #define _RPC_RPC_MSG_H 36*7c478bd9Sstevel@tonic-gate 37*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 38*7c478bd9Sstevel@tonic-gate 39*7c478bd9Sstevel@tonic-gate #include <rpc/clnt.h> 40*7c478bd9Sstevel@tonic-gate /* 41*7c478bd9Sstevel@tonic-gate * rpc_msg.h 42*7c478bd9Sstevel@tonic-gate * rpc message definition 43*7c478bd9Sstevel@tonic-gate */ 44*7c478bd9Sstevel@tonic-gate 45*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 46*7c478bd9Sstevel@tonic-gate extern "C" { 47*7c478bd9Sstevel@tonic-gate #endif 48*7c478bd9Sstevel@tonic-gate 49*7c478bd9Sstevel@tonic-gate #define RPC_MSG_VERSION ((uint32_t)2) 50*7c478bd9Sstevel@tonic-gate #define RPC_SERVICE_PORT ((ushort_t)2048) 51*7c478bd9Sstevel@tonic-gate 52*7c478bd9Sstevel@tonic-gate /* 53*7c478bd9Sstevel@tonic-gate * Bottom up definition of an rpc message. 54*7c478bd9Sstevel@tonic-gate * NOTE: call and reply use the same overall stuct but 55*7c478bd9Sstevel@tonic-gate * different parts of unions within it. 56*7c478bd9Sstevel@tonic-gate */ 57*7c478bd9Sstevel@tonic-gate 58*7c478bd9Sstevel@tonic-gate enum msg_type { 59*7c478bd9Sstevel@tonic-gate CALL = 0, 60*7c478bd9Sstevel@tonic-gate REPLY = 1 61*7c478bd9Sstevel@tonic-gate }; 62*7c478bd9Sstevel@tonic-gate 63*7c478bd9Sstevel@tonic-gate enum reply_stat { 64*7c478bd9Sstevel@tonic-gate MSG_ACCEPTED = 0, 65*7c478bd9Sstevel@tonic-gate MSG_DENIED = 1 66*7c478bd9Sstevel@tonic-gate }; 67*7c478bd9Sstevel@tonic-gate 68*7c478bd9Sstevel@tonic-gate enum accept_stat { 69*7c478bd9Sstevel@tonic-gate SUCCESS = 0, 70*7c478bd9Sstevel@tonic-gate PROG_UNAVAIL = 1, 71*7c478bd9Sstevel@tonic-gate PROG_MISMATCH = 2, 72*7c478bd9Sstevel@tonic-gate PROC_UNAVAIL = 3, 73*7c478bd9Sstevel@tonic-gate GARBAGE_ARGS = 4, 74*7c478bd9Sstevel@tonic-gate SYSTEM_ERR = 5 75*7c478bd9Sstevel@tonic-gate }; 76*7c478bd9Sstevel@tonic-gate 77*7c478bd9Sstevel@tonic-gate enum reject_stat { 78*7c478bd9Sstevel@tonic-gate RPC_MISMATCH = 0, 79*7c478bd9Sstevel@tonic-gate AUTH_ERROR = 1 80*7c478bd9Sstevel@tonic-gate }; 81*7c478bd9Sstevel@tonic-gate 82*7c478bd9Sstevel@tonic-gate /* 83*7c478bd9Sstevel@tonic-gate * Reply part of an rpc exchange 84*7c478bd9Sstevel@tonic-gate */ 85*7c478bd9Sstevel@tonic-gate 86*7c478bd9Sstevel@tonic-gate /* 87*7c478bd9Sstevel@tonic-gate * Reply to an rpc request that was accepted by the server. 88*7c478bd9Sstevel@tonic-gate * Note: there could be an error even though the request was 89*7c478bd9Sstevel@tonic-gate * accepted. 90*7c478bd9Sstevel@tonic-gate */ 91*7c478bd9Sstevel@tonic-gate struct accepted_reply { 92*7c478bd9Sstevel@tonic-gate struct opaque_auth ar_verf; 93*7c478bd9Sstevel@tonic-gate enum accept_stat ar_stat; 94*7c478bd9Sstevel@tonic-gate union { 95*7c478bd9Sstevel@tonic-gate struct { 96*7c478bd9Sstevel@tonic-gate rpcvers_t low; 97*7c478bd9Sstevel@tonic-gate rpcvers_t high; 98*7c478bd9Sstevel@tonic-gate } AR_versions; 99*7c478bd9Sstevel@tonic-gate struct { 100*7c478bd9Sstevel@tonic-gate caddr_t where; 101*7c478bd9Sstevel@tonic-gate xdrproc_t proc; 102*7c478bd9Sstevel@tonic-gate } AR_results; 103*7c478bd9Sstevel@tonic-gate /* and many other null cases */ 104*7c478bd9Sstevel@tonic-gate } ru; 105*7c478bd9Sstevel@tonic-gate #define ar_results ru.AR_results 106*7c478bd9Sstevel@tonic-gate #define ar_vers ru.AR_versions 107*7c478bd9Sstevel@tonic-gate }; 108*7c478bd9Sstevel@tonic-gate 109*7c478bd9Sstevel@tonic-gate /* 110*7c478bd9Sstevel@tonic-gate * Reply to an rpc request that was rejected by the server. 111*7c478bd9Sstevel@tonic-gate */ 112*7c478bd9Sstevel@tonic-gate struct rejected_reply { 113*7c478bd9Sstevel@tonic-gate enum reject_stat rj_stat; 114*7c478bd9Sstevel@tonic-gate union { 115*7c478bd9Sstevel@tonic-gate struct { 116*7c478bd9Sstevel@tonic-gate rpcvers_t low; 117*7c478bd9Sstevel@tonic-gate rpcvers_t high; 118*7c478bd9Sstevel@tonic-gate } RJ_versions; 119*7c478bd9Sstevel@tonic-gate enum auth_stat RJ_why; /* why authentication did not work */ 120*7c478bd9Sstevel@tonic-gate } ru; 121*7c478bd9Sstevel@tonic-gate #define rj_vers ru.RJ_versions 122*7c478bd9Sstevel@tonic-gate #define rj_why ru.RJ_why 123*7c478bd9Sstevel@tonic-gate }; 124*7c478bd9Sstevel@tonic-gate 125*7c478bd9Sstevel@tonic-gate /* 126*7c478bd9Sstevel@tonic-gate * Body of a reply to an rpc request. 127*7c478bd9Sstevel@tonic-gate */ 128*7c478bd9Sstevel@tonic-gate struct reply_body { 129*7c478bd9Sstevel@tonic-gate enum reply_stat rp_stat; 130*7c478bd9Sstevel@tonic-gate union { 131*7c478bd9Sstevel@tonic-gate struct accepted_reply RP_ar; 132*7c478bd9Sstevel@tonic-gate struct rejected_reply RP_dr; 133*7c478bd9Sstevel@tonic-gate } ru; 134*7c478bd9Sstevel@tonic-gate #define rp_acpt ru.RP_ar 135*7c478bd9Sstevel@tonic-gate #define rp_rjct ru.RP_dr 136*7c478bd9Sstevel@tonic-gate }; 137*7c478bd9Sstevel@tonic-gate 138*7c478bd9Sstevel@tonic-gate /* 139*7c478bd9Sstevel@tonic-gate * Body of an rpc request call. 140*7c478bd9Sstevel@tonic-gate */ 141*7c478bd9Sstevel@tonic-gate struct call_body { 142*7c478bd9Sstevel@tonic-gate rpcvers_t cb_rpcvers; /* must be equal to two */ 143*7c478bd9Sstevel@tonic-gate rpcprog_t cb_prog; 144*7c478bd9Sstevel@tonic-gate rpcvers_t cb_vers; 145*7c478bd9Sstevel@tonic-gate rpcproc_t cb_proc; 146*7c478bd9Sstevel@tonic-gate struct opaque_auth cb_cred; 147*7c478bd9Sstevel@tonic-gate struct opaque_auth cb_verf; /* protocol specific - provided by client */ 148*7c478bd9Sstevel@tonic-gate }; 149*7c478bd9Sstevel@tonic-gate 150*7c478bd9Sstevel@tonic-gate /* 151*7c478bd9Sstevel@tonic-gate * The rpc message 152*7c478bd9Sstevel@tonic-gate */ 153*7c478bd9Sstevel@tonic-gate struct rpc_msg { 154*7c478bd9Sstevel@tonic-gate uint32_t rm_xid; 155*7c478bd9Sstevel@tonic-gate enum msg_type rm_direction; 156*7c478bd9Sstevel@tonic-gate union { 157*7c478bd9Sstevel@tonic-gate struct call_body RM_cmb; 158*7c478bd9Sstevel@tonic-gate struct reply_body RM_rmb; 159*7c478bd9Sstevel@tonic-gate } ru; 160*7c478bd9Sstevel@tonic-gate #define rm_call ru.RM_cmb 161*7c478bd9Sstevel@tonic-gate #define rm_reply ru.RM_rmb 162*7c478bd9Sstevel@tonic-gate }; 163*7c478bd9Sstevel@tonic-gate #define acpted_rply ru.RM_rmb.ru.RP_ar 164*7c478bd9Sstevel@tonic-gate #define rjcted_rply ru.RM_rmb.ru.RP_dr 165*7c478bd9Sstevel@tonic-gate 166*7c478bd9Sstevel@tonic-gate 167*7c478bd9Sstevel@tonic-gate /* 168*7c478bd9Sstevel@tonic-gate * XDR routine to handle a rpc message. 169*7c478bd9Sstevel@tonic-gate * xdr_callmsg(xdrs, cmsg) 170*7c478bd9Sstevel@tonic-gate * XDR *xdrs; 171*7c478bd9Sstevel@tonic-gate * struct rpc_msg *cmsg; 172*7c478bd9Sstevel@tonic-gate */ 173*7c478bd9Sstevel@tonic-gate #ifdef __STDC__ 174*7c478bd9Sstevel@tonic-gate extern bool_t xdr_callmsg(XDR *, struct rpc_msg *); 175*7c478bd9Sstevel@tonic-gate #else 176*7c478bd9Sstevel@tonic-gate extern bool_t xdr_callmsg(); 177*7c478bd9Sstevel@tonic-gate #endif 178*7c478bd9Sstevel@tonic-gate 179*7c478bd9Sstevel@tonic-gate 180*7c478bd9Sstevel@tonic-gate /* 181*7c478bd9Sstevel@tonic-gate * XDR routine to pre-serialize the static part of a rpc message. 182*7c478bd9Sstevel@tonic-gate * xdr_callhdr(xdrs, cmsg) 183*7c478bd9Sstevel@tonic-gate * XDR *xdrs; 184*7c478bd9Sstevel@tonic-gate * struct rpc_msg *cmsg; 185*7c478bd9Sstevel@tonic-gate */ 186*7c478bd9Sstevel@tonic-gate #ifdef __STDC__ 187*7c478bd9Sstevel@tonic-gate extern bool_t xdr_callhdr(XDR *, struct rpc_msg *); 188*7c478bd9Sstevel@tonic-gate #else 189*7c478bd9Sstevel@tonic-gate extern bool_t xdr_callhdr(); 190*7c478bd9Sstevel@tonic-gate #endif 191*7c478bd9Sstevel@tonic-gate 192*7c478bd9Sstevel@tonic-gate 193*7c478bd9Sstevel@tonic-gate /* 194*7c478bd9Sstevel@tonic-gate * XDR routine to handle a rpc reply. 195*7c478bd9Sstevel@tonic-gate * xdr_replymsg(xdrs, rmsg) 196*7c478bd9Sstevel@tonic-gate * XDR *xdrs; 197*7c478bd9Sstevel@tonic-gate * struct rpc_msg *rmsg; 198*7c478bd9Sstevel@tonic-gate * 199*7c478bd9Sstevel@tonic-gate * xdr_accepted_reply(xdrs, ar) 200*7c478bd9Sstevel@tonic-gate * XDR *xdrs; 201*7c478bd9Sstevel@tonic-gate * const struct accepted_reply *ar; 202*7c478bd9Sstevel@tonic-gate * 203*7c478bd9Sstevel@tonic-gate * xdr_rejected_reply(xdrs, rr) 204*7c478bd9Sstevel@tonic-gate * XDR *xdrs; 205*7c478bd9Sstevel@tonic-gate * const struct rejected_reply *rr; 206*7c478bd9Sstevel@tonic-gate */ 207*7c478bd9Sstevel@tonic-gate #ifdef __STDC__ 208*7c478bd9Sstevel@tonic-gate extern bool_t xdr_replymsg(XDR *, struct rpc_msg *); 209*7c478bd9Sstevel@tonic-gate extern bool_t xdr_accepted_reply(XDR *, struct accepted_reply *); 210*7c478bd9Sstevel@tonic-gate extern bool_t xdr_rejected_reply(XDR *, struct rejected_reply *); 211*7c478bd9Sstevel@tonic-gate #else 212*7c478bd9Sstevel@tonic-gate extern bool_t xdr_replymsg(); 213*7c478bd9Sstevel@tonic-gate extern bool_t xdr_accepted_reply(); 214*7c478bd9Sstevel@tonic-gate extern bool_t xdr_rejected_reply(); 215*7c478bd9Sstevel@tonic-gate #endif 216*7c478bd9Sstevel@tonic-gate 217*7c478bd9Sstevel@tonic-gate 218*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL 219*7c478bd9Sstevel@tonic-gate /* 220*7c478bd9Sstevel@tonic-gate * Fills in the error part of a reply message. 221*7c478bd9Sstevel@tonic-gate * _seterr_reply(msg, error) 222*7c478bd9Sstevel@tonic-gate * struct rpc_msg *msg; 223*7c478bd9Sstevel@tonic-gate * struct rpc_err *error; 224*7c478bd9Sstevel@tonic-gate */ 225*7c478bd9Sstevel@tonic-gate #ifdef __STDC__ 226*7c478bd9Sstevel@tonic-gate extern void _seterr_reply(struct rpc_msg *, struct rpc_err *); 227*7c478bd9Sstevel@tonic-gate #else 228*7c478bd9Sstevel@tonic-gate extern void _seterr_reply(); 229*7c478bd9Sstevel@tonic-gate #endif 230*7c478bd9Sstevel@tonic-gate #else 231*7c478bd9Sstevel@tonic-gate /* 232*7c478bd9Sstevel@tonic-gate * Fills in the error part of a reply message. 233*7c478bd9Sstevel@tonic-gate * __seterr_reply(msg, error) 234*7c478bd9Sstevel@tonic-gate * struct rpc_msg *msg; 235*7c478bd9Sstevel@tonic-gate * struct rpc_err *error; 236*7c478bd9Sstevel@tonic-gate */ 237*7c478bd9Sstevel@tonic-gate #ifdef __STDC__ 238*7c478bd9Sstevel@tonic-gate extern void __seterr_reply(struct rpc_msg *, struct rpc_err *); 239*7c478bd9Sstevel@tonic-gate #else 240*7c478bd9Sstevel@tonic-gate extern void __seterr_reply(); 241*7c478bd9Sstevel@tonic-gate #endif 242*7c478bd9Sstevel@tonic-gate #endif 243*7c478bd9Sstevel@tonic-gate 244*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL 245*7c478bd9Sstevel@tonic-gate /* 246*7c478bd9Sstevel@tonic-gate * Frees any verifier that xdr_replymsg() (DECODE) allocated. 247*7c478bd9Sstevel@tonic-gate */ 248*7c478bd9Sstevel@tonic-gate bool_t xdr_rpc_free_verifier(register XDR *xdrs, register struct rpc_msg *msg); 249*7c478bd9Sstevel@tonic-gate 250*7c478bd9Sstevel@tonic-gate #endif 251*7c478bd9Sstevel@tonic-gate 252*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 253*7c478bd9Sstevel@tonic-gate } 254*7c478bd9Sstevel@tonic-gate #endif 255*7c478bd9Sstevel@tonic-gate 256*7c478bd9Sstevel@tonic-gate #endif /* _RPC_RPC_MSG_H */ 257