source: rtems/c/src/lib/librpc/rpc_prot.c @ 08b5f55

4.104.114.84.95
Last change on this file since 08b5f55 was 4721cf1, checked in by Joel Sherrill <joel.sherrill@…>, on 12/03/98 at 23:54:14

Patch from Emmanuel Raguet <raguet@…> to add remote debug server
and RPC support to RTEMS. Thanks. :) Email follows:

Hello,

For Xmas, here is the Remote Debugger on RTEMS !

Here are 2 patches for the Remote Debugger on RTEMS for pc386 from Linux
host :

  • one for RTEMS it self,
  • one for GDB-4.17.

1/ RTEMS patch
--------------

This patch adds 2 libraries :

  • a simplified SUN RPC library
  • the Remote Debugger library

The configuration command is the following :
../rtems4/configure --target=i386-rtemself --enable-rtemsbsp=pc386
--enable-rdbg

The SUN RPC library is built only if networking is set.
The RDBG library is built if networking and enable-rdbg are set.

The function used to initialize the debugger is :

rtems_rdbg_initialize ();

A special function has been created to force a task to be
in a "debug" state : enterRdbg().
The use of this function is not mandatory.

2/ GDB-4.17 patch
-----------------

This patch create a new RTEMS target for GDB-4.17.

The configuration command is the following :
./configure --enable-shared --target=i386RTEMS

To connect to a target, use :

target rtems [your_site_address]

Then, attach the target using : attach 1

And... Debug ;)

You can obtain the original GDB-4.17 on
ftp://ftp.debian.org/debian/dists/stable/main/source/devel/gdb_4.17.orig.tar.gz

This has been tested from a Debian 2.0.1 linux host.

  • Property mode set to 100644
File size: 6.1 KB
Line 
1/* @(#)rpc_prot.c       2.3 88/08/07 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
19/*
20 * rpc_prot.c
21 */
22
23#include <rpc/rpc.h>
24
25/* * * * * * * * * * * * * * XDR Authentication * * * * * * * * * * * */
26
27struct opaque_auth _null_auth;
28
29/*
30 * XDR an opaque authentication struct
31 * (see auth.h)
32 */
33bool_t
34xdr_opaque_auth(xdrs, ap)
35        register XDR *xdrs;
36        register struct opaque_auth *ap;
37{
38
39        if (xdr_enum(xdrs, &(ap->oa_flavor)))
40                return (xdr_bytes(xdrs, &ap->oa_base,
41                        &ap->oa_length, MAX_AUTH_BYTES));
42        return (FALSE);
43}
44
45/*
46 * XDR a DES block
47 */
48bool_t
49xdr_des_block(xdrs, blkp)
50        register XDR *xdrs;
51        register des_block *blkp;
52{
53        return (xdr_opaque(xdrs, (caddr_t)blkp, sizeof(des_block)));
54}
55
56/* * * * * * * * * * * * * * XDR RPC MESSAGE * * * * * * * * * * * * * * * */
57
58/*
59 * XDR the MSG_ACCEPTED part of a reply message union
60 */
61bool_t
62xdr_accepted_reply(xdrs, ar)
63        register XDR *xdrs;   
64        register struct accepted_reply *ar;
65{
66
67        /* personalized union, rather than calling xdr_union */
68        if (! xdr_opaque_auth(xdrs, &(ar->ar_verf)))
69                return (FALSE);
70        if (! xdr_enum(xdrs, (enum_t *)&(ar->ar_stat)))
71                return (FALSE);
72        switch (ar->ar_stat) {
73
74        case SUCCESS:
75                return ((*(ar->ar_results.proc))(xdrs, ar->ar_results.where));
76
77        case PROG_MISMATCH:
78                if (! xdr_u_long(xdrs, &(ar->ar_vers.low)))
79                        return (FALSE);
80                return (xdr_u_long(xdrs, &(ar->ar_vers.high)));
81        default:
82                break;
83        }
84        return (TRUE);  /* TRUE => open ended set of problems */
85}
86
87/*
88 * XDR the MSG_DENIED part of a reply message union
89 */
90bool_t
91xdr_rejected_reply(xdrs, rr)
92        register XDR *xdrs;
93        register struct rejected_reply *rr;
94{
95
96        /* personalized union, rather than calling xdr_union */
97        if (! xdr_enum(xdrs, (enum_t *)&(rr->rj_stat)))
98                return (FALSE);
99        switch (rr->rj_stat) {
100
101        case RPC_MISMATCH:
102                if (! xdr_u_long(xdrs, &(rr->rj_vers.low)))
103                        return (FALSE);
104                return (xdr_u_long(xdrs, &(rr->rj_vers.high)));
105
106        case AUTH_ERROR:
107                return (xdr_enum(xdrs, (enum_t *)&(rr->rj_why)));
108        }
109        return (FALSE);
110}
111
112static struct xdr_discrim reply_dscrm[3] = {
113        { (int)MSG_ACCEPTED, xdr_accepted_reply },
114        { (int)MSG_DENIED, xdr_rejected_reply },
115        { __dontcare__, NULL_xdrproc_t } };
116
117/*
118 * XDR a reply message
119 */
120bool_t
121xdr_replymsg(xdrs, rmsg)
122        register XDR *xdrs;
123        register struct rpc_msg *rmsg;
124{
125        if (
126            xdr_u_long(xdrs, &(rmsg->rm_xid)) &&
127            xdr_enum(xdrs, (enum_t *)&(rmsg->rm_direction)) &&
128            (rmsg->rm_direction == REPLY) )
129                return (xdr_union(xdrs, (enum_t *)&(rmsg->rm_reply.rp_stat),
130                   (caddr_t)&(rmsg->rm_reply.ru), reply_dscrm, NULL_xdrproc_t));
131        return (FALSE);
132}
133
134
135/*
136 * Serializes the "static part" of a call message header.
137 * The fields include: rm_xid, rm_direction, rpcvers, prog, and vers.
138 * The rm_xid is not really static, but the user can easily munge on the fly.
139 */
140bool_t
141xdr_callhdr(xdrs, cmsg)
142        register XDR *xdrs;
143        register struct rpc_msg *cmsg;
144{
145
146        cmsg->rm_direction = CALL;
147        cmsg->rm_call.cb_rpcvers = RPC_MSG_VERSION;
148        if (
149            (xdrs->x_op == XDR_ENCODE) &&
150            xdr_u_long(xdrs, &(cmsg->rm_xid)) &&
151            xdr_enum(xdrs, (enum_t *)&(cmsg->rm_direction)) &&
152            xdr_u_long(xdrs, &(cmsg->rm_call.cb_rpcvers)) &&
153            xdr_u_long(xdrs, &(cmsg->rm_call.cb_prog)) )
154            return (xdr_u_long(xdrs, &(cmsg->rm_call.cb_vers)));
155        return (FALSE);
156}
157
158/* ************************** Client utility routine ************* */
159
160static void
161accepted(acpt_stat, error)
162        register enum accept_stat acpt_stat;
163        register struct rpc_err *error;
164{
165
166        switch (acpt_stat) {
167
168        case PROG_UNAVAIL:
169                error->re_status = RPC_PROGUNAVAIL;
170                return;
171
172        case PROG_MISMATCH:
173                error->re_status = RPC_PROGVERSMISMATCH;
174                return;
175
176        case PROC_UNAVAIL:
177                error->re_status = RPC_PROCUNAVAIL;
178                return;
179
180        case GARBAGE_ARGS:
181                error->re_status = RPC_CANTDECODEARGS;
182                return;
183
184        case SYSTEM_ERR:
185                error->re_status = RPC_SYSTEMERROR;
186                return;
187
188        case SUCCESS:
189                error->re_status = RPC_SUCCESS;
190                return;
191        }
192        /* something's wrong, but we don't know what ... */
193        error->re_status = RPC_FAILED;
194        error->re_lb.s1 = (long)MSG_ACCEPTED;
195        error->re_lb.s2 = (long)acpt_stat;
196}
197
198static void
199rejected(rjct_stat, error)
200        register enum reject_stat rjct_stat;
201        register struct rpc_err *error;
202{
203
204        switch (rjct_stat) {
205
206        case RPC_VERSMISMATCH:
207                error->re_status = RPC_VERSMISMATCH;
208                return;
209
210        case AUTH_ERROR:
211                error->re_status = RPC_AUTHERROR;
212                return;
213
214        default:
215                break;
216        }
217        /* something's wrong, but we don't know what ... */
218        error->re_status = RPC_FAILED;
219        error->re_lb.s1 = (long)MSG_DENIED;
220        error->re_lb.s2 = (long)rjct_stat;
221}
222
223/*
224 * given a reply message, fills in the error
225 */
226void
227_seterr_reply(msg, error)
228        register struct rpc_msg *msg;
229        register struct rpc_err *error;
230{
231
232        /* optimized for normal, SUCCESSful case */
233        switch (msg->rm_reply.rp_stat) {
234
235        case MSG_ACCEPTED:
236                if (msg->acpted_rply.ar_stat == SUCCESS) {
237                        error->re_status = RPC_SUCCESS;
238                        return;
239                };
240                accepted(msg->acpted_rply.ar_stat, error);
241                break;
242
243        case MSG_DENIED:
244                rejected(msg->rjcted_rply.rj_stat, error);
245                break;
246
247        default:
248                error->re_status = RPC_FAILED;
249                error->re_lb.s1 = (long)(msg->rm_reply.rp_stat);
250                break;
251        }
252        switch (error->re_status) {
253
254        case RPC_VERSMISMATCH:
255                error->re_vers.low = msg->rjcted_rply.rj_vers.low;
256                error->re_vers.high = msg->rjcted_rply.rj_vers.high;
257                break;
258
259        case RPC_AUTHERROR:
260                error->re_why = msg->rjcted_rply.rj_why;
261                break;
262
263        case RPC_PROGVERSMISMATCH:
264                error->re_vers.low = msg->acpted_rply.ar_vers.low;
265                error->re_vers.high = msg->acpted_rply.ar_vers.high;
266                break;
267
268        default:
269                break;
270        }
271}
Note: See TracBrowser for help on using the repository browser.