The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/rpc/rpc_callmsg.c

Version: -  FREEBSD  -  FREEBSD11  -  FREEBSD10  -  FREEBSD9  -  FREEBSD92  -  FREEBSD91  -  FREEBSD90  -  FREEBSD8  -  FREEBSD82  -  FREEBSD81  -  FREEBSD80  -  FREEBSD7  -  FREEBSD74  -  FREEBSD73  -  FREEBSD72  -  FREEBSD71  -  FREEBSD70  -  FREEBSD6  -  FREEBSD64  -  FREEBSD63  -  FREEBSD62  -  FREEBSD61  -  FREEBSD60  -  FREEBSD5  -  FREEBSD55  -  FREEBSD54  -  FREEBSD53  -  FREEBSD52  -  FREEBSD51  -  FREEBSD50  -  FREEBSD4  -  FREEBSD3  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: rpc_callmsg.c,v 1.16 2000/07/14 08:40:42 fvdl Exp $    */
    2 
    3 /*
    4  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
    5  * unrestricted use provided that this legend is included on all tape
    6  * media and as a part of the software program in whole or part.  Users
    7  * may copy or modify Sun RPC without charge, but are not authorized
    8  * to license or distribute it to anyone else except as part of a product or
    9  * program developed by the user.
   10  *
   11  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
   12  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
   13  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
   14  *
   15  * Sun RPC is provided with no support and without any obligation on the
   16  * part of Sun Microsystems, Inc. to assist in its use, correction,
   17  * modification or enhancement.
   18  *
   19  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
   20  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
   21  * OR ANY PART THEREOF.
   22  *
   23  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
   24  * or profits or other special, indirect and consequential damages, even if
   25  * Sun has been advised of the possibility of such damages.
   26  *
   27  * Sun Microsystems, Inc.
   28  * 2550 Garcia Avenue
   29  * Mountain View, California  94043
   30  */
   31 
   32 #if defined(LIBC_SCCS) && !defined(lint)
   33 static char *sccsid2 = "@(#)rpc_callmsg.c 1.4 87/08/11 Copyr 1984 Sun Micro";
   34 static char *sccsid = "@(#)rpc_callmsg.c        2.1 88/07/29 4.0 RPCSRC";
   35 #endif
   36 #include <sys/cdefs.h>
   37 __FBSDID("$FreeBSD$");
   38 
   39 /*
   40  * rpc_callmsg.c
   41  *
   42  * Copyright (C) 1984, Sun Microsystems, Inc.
   43  *
   44  */
   45 
   46 #include <sys/param.h>
   47 #include <sys/systm.h>
   48 #include <sys/malloc.h>
   49 
   50 #include <rpc/rpc.h>
   51 
   52 /*
   53  * XDR a call message
   54  */
   55 bool_t
   56 xdr_callmsg(XDR *xdrs, struct rpc_msg *cmsg)
   57 {
   58         enum msg_type *prm_direction;
   59         int32_t *buf;
   60         struct opaque_auth *oa;
   61 
   62         if (xdrs->x_op == XDR_ENCODE) {
   63                 if (cmsg->rm_call.cb_cred.oa_length > MAX_AUTH_BYTES) {
   64                         return (FALSE);
   65                 }
   66                 if (cmsg->rm_call.cb_verf.oa_length > MAX_AUTH_BYTES) {
   67                         return (FALSE);
   68                 }
   69                 buf = XDR_INLINE(xdrs, 8 * BYTES_PER_XDR_UNIT
   70                         + RNDUP(cmsg->rm_call.cb_cred.oa_length)
   71                         + 2 * BYTES_PER_XDR_UNIT
   72                         + RNDUP(cmsg->rm_call.cb_verf.oa_length));
   73                 if (buf != NULL) {
   74                         IXDR_PUT_INT32(buf, cmsg->rm_xid);
   75                         IXDR_PUT_ENUM(buf, cmsg->rm_direction);
   76                         if (cmsg->rm_direction != CALL) {
   77                                 return (FALSE);
   78                         }
   79                         IXDR_PUT_INT32(buf, cmsg->rm_call.cb_rpcvers);
   80                         if (cmsg->rm_call.cb_rpcvers != RPC_MSG_VERSION) {
   81                                 return (FALSE);
   82                         }
   83                         IXDR_PUT_INT32(buf, cmsg->rm_call.cb_prog);
   84                         IXDR_PUT_INT32(buf, cmsg->rm_call.cb_vers);
   85                         IXDR_PUT_INT32(buf, cmsg->rm_call.cb_proc);
   86                         oa = &cmsg->rm_call.cb_cred;
   87                         IXDR_PUT_ENUM(buf, oa->oa_flavor);
   88                         IXDR_PUT_INT32(buf, oa->oa_length);
   89                         if (oa->oa_length) {
   90                                 memcpy(buf, oa->oa_base, oa->oa_length);
   91                                 buf += RNDUP(oa->oa_length) / sizeof (int32_t);
   92                         }
   93                         oa = &cmsg->rm_call.cb_verf;
   94                         IXDR_PUT_ENUM(buf, oa->oa_flavor);
   95                         IXDR_PUT_INT32(buf, oa->oa_length);
   96                         if (oa->oa_length) {
   97                                 memcpy(buf, oa->oa_base, oa->oa_length);
   98                                 /* no real need....
   99                                 buf += RNDUP(oa->oa_length) / sizeof (int32_t);
  100                                 */
  101                         }
  102                         return (TRUE);
  103                 }
  104         }
  105         if (xdrs->x_op == XDR_DECODE) {
  106                 buf = XDR_INLINE(xdrs, 8 * BYTES_PER_XDR_UNIT);
  107                 if (buf != NULL) {
  108                         cmsg->rm_xid = IXDR_GET_UINT32(buf);
  109                         cmsg->rm_direction = IXDR_GET_ENUM(buf, enum msg_type);
  110                         if (cmsg->rm_direction != CALL) {
  111                                 return (FALSE);
  112                         }
  113                         cmsg->rm_call.cb_rpcvers = IXDR_GET_UINT32(buf);
  114                         if (cmsg->rm_call.cb_rpcvers != RPC_MSG_VERSION) {
  115                                 return (FALSE);
  116                         }
  117                         cmsg->rm_call.cb_prog = IXDR_GET_UINT32(buf);
  118                         cmsg->rm_call.cb_vers = IXDR_GET_UINT32(buf);
  119                         cmsg->rm_call.cb_proc = IXDR_GET_UINT32(buf);
  120                         oa = &cmsg->rm_call.cb_cred;
  121                         oa->oa_flavor = IXDR_GET_ENUM(buf, enum_t);
  122                         oa->oa_length = (u_int)IXDR_GET_UINT32(buf);
  123                         if (oa->oa_length) {
  124                                 if (oa->oa_length > MAX_AUTH_BYTES) {
  125                                         return (FALSE);
  126                                 }
  127                                 if (oa->oa_base == NULL) {
  128                                         oa->oa_base = (caddr_t)
  129                                             mem_alloc(oa->oa_length);
  130                                         if (oa->oa_base == NULL)
  131                                                 return (FALSE);
  132                                 }
  133                                 buf = XDR_INLINE(xdrs, RNDUP(oa->oa_length));
  134                                 if (buf == NULL) {
  135                                         if (xdr_opaque(xdrs, oa->oa_base,
  136                                             oa->oa_length) == FALSE) {
  137                                                 return (FALSE);
  138                                         }
  139                                 } else {
  140                                         memcpy(oa->oa_base, buf,
  141                                             oa->oa_length);
  142                                         /* no real need....
  143                                         buf += RNDUP(oa->oa_length) /
  144                                                 sizeof (int32_t);
  145                                         */
  146                                 }
  147                         }
  148                         oa = &cmsg->rm_call.cb_verf;
  149                         buf = XDR_INLINE(xdrs, 2 * BYTES_PER_XDR_UNIT);
  150                         if (buf == NULL) {
  151                                 if (xdr_enum(xdrs, &oa->oa_flavor) == FALSE ||
  152                                     xdr_u_int(xdrs, &oa->oa_length) == FALSE) {
  153                                         return (FALSE);
  154                                 }
  155                         } else {
  156                                 oa->oa_flavor = IXDR_GET_ENUM(buf, enum_t);
  157                                 oa->oa_length = (u_int)IXDR_GET_UINT32(buf);
  158                         }
  159                         if (oa->oa_length) {
  160                                 if (oa->oa_length > MAX_AUTH_BYTES) {
  161                                         return (FALSE);
  162                                 }
  163                                 if (oa->oa_base == NULL) {
  164                                         oa->oa_base = (caddr_t)
  165                                             mem_alloc(oa->oa_length);
  166                                         if (oa->oa_base == NULL)
  167                                                 return (FALSE);
  168                                 }
  169                                 buf = XDR_INLINE(xdrs, RNDUP(oa->oa_length));
  170                                 if (buf == NULL) {
  171                                         if (xdr_opaque(xdrs, oa->oa_base,
  172                                             oa->oa_length) == FALSE) {
  173                                                 return (FALSE);
  174                                         }
  175                                 } else {
  176                                         memcpy(oa->oa_base, buf,
  177                                             oa->oa_length);
  178                                         /* no real need...
  179                                         buf += RNDUP(oa->oa_length) /
  180                                                 sizeof (int32_t);
  181                                         */
  182                                 }
  183                         }
  184                         return (TRUE);
  185                 }
  186         }
  187         prm_direction = &cmsg->rm_direction;
  188         if (
  189             xdr_uint32_t(xdrs, &(cmsg->rm_xid)) &&
  190             xdr_enum(xdrs, (enum_t *) prm_direction) &&
  191             (cmsg->rm_direction == CALL) &&
  192             xdr_uint32_t(xdrs, &(cmsg->rm_call.cb_rpcvers)) &&
  193             (cmsg->rm_call.cb_rpcvers == RPC_MSG_VERSION) &&
  194             xdr_uint32_t(xdrs, &(cmsg->rm_call.cb_prog)) &&
  195             xdr_uint32_t(xdrs, &(cmsg->rm_call.cb_vers)) &&
  196             xdr_uint32_t(xdrs, &(cmsg->rm_call.cb_proc)) &&
  197             xdr_opaque_auth(xdrs, &(cmsg->rm_call.cb_cred)) )
  198                 return (xdr_opaque_auth(xdrs, &(cmsg->rm_call.cb_verf)));
  199         return (FALSE);
  200 }

Cache object: 96dd0bd556092470b1fec3543094937a


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.