OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [uClibc/] [libc/] [inet/] [rpc/] [rpc_callmsg.c] - Blame information for rev 1325

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.