source: rtems/c/src/lib/librpc/svc.c @ 6693a68

4.104.114.84.95
Last change on this file since 6693a68 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/* @(#)svc.c    2.4 88/08/11 4.0 RPCSRC; from 1.44 88/02/08 SMI */
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 !defined(lint) && defined(SCCSIDS)
31static char sccsid[] = "@(#)svc.c 1.41 87/10/13 Copyr 1984 Sun Micro";
32#endif
33
34/*
35 * svc.c, Server-side remote procedure call interface.
36 *
37 * There are two sets of procedures here.  The xprt routines are
38 * for handling transport handles.  The svc routines handle the
39 * list of service routines.
40 *
41 * Copyright (C) 1984, Sun Microsystems, Inc.
42 */
43
44#include <rpc/rpc.h>
45#include <stdio.h>
46#include <stdlib.h>
47
48#define RQCRED_SIZE     400             /* this size is excessive */
49
50/* ******************* REPLY GENERATION ROUTINES  ************ */
51
52/*
53 * Send a reply to an rpc request
54 */
55bool_t
56svc_sendreply(xprt, xdr_results, xdr_location)
57        register SVCXPRT *xprt;
58        xdrproc_t xdr_results;
59        caddr_t xdr_location;
60{
61        struct rpc_msg rply;
62       
63        rply.rm_direction = REPLY; 
64        rply.rm_reply.rp_stat = MSG_ACCEPTED;
65        rply.acpted_rply.ar_verf = xprt->xp_verf;
66        rply.acpted_rply.ar_stat = SUCCESS;
67        rply.acpted_rply.ar_results.where = xdr_location;
68        rply.acpted_rply.ar_results.proc = xdr_results;
69        return (SVC_REPLY(xprt, &rply));
70}
71
72/*
73 * No procedure error reply
74 */
75void
76svcerr_noproc(xprt)
77        register SVCXPRT *xprt;
78{
79        struct rpc_msg rply;
80
81        rply.rm_direction = REPLY;
82        rply.rm_reply.rp_stat = MSG_ACCEPTED;
83        rply.acpted_rply.ar_verf = xprt->xp_verf;
84        rply.acpted_rply.ar_stat = PROC_UNAVAIL;
85        SVC_REPLY(xprt, &rply);
86}
87
88/*
89 * Can't decode args error reply
90 */
91void
92svcerr_decode(xprt)
93        register SVCXPRT *xprt;
94{
95        struct rpc_msg rply;
96
97        rply.rm_direction = REPLY;
98        rply.rm_reply.rp_stat = MSG_ACCEPTED;
99        rply.acpted_rply.ar_verf = xprt->xp_verf;
100        rply.acpted_rply.ar_stat = GARBAGE_ARGS;
101        SVC_REPLY(xprt, &rply);
102}
103
104/*
105 * Some system error
106 */
107void
108svcerr_systemerr(xprt)
109        register SVCXPRT *xprt;
110{
111        struct rpc_msg rply;
112
113        rply.rm_direction = REPLY;
114        rply.rm_reply.rp_stat = MSG_ACCEPTED;
115        rply.acpted_rply.ar_verf = xprt->xp_verf;
116        rply.acpted_rply.ar_stat = SYSTEM_ERR;
117        SVC_REPLY(xprt, &rply);
118}
119
120/*
121 * Authentication error reply
122 */
123void
124svcerr_auth(xprt, why)
125        SVCXPRT *xprt;
126        enum auth_stat why;
127{
128        struct rpc_msg rply;
129
130        rply.rm_direction = REPLY;
131        rply.rm_reply.rp_stat = MSG_DENIED;
132        rply.rjcted_rply.rj_stat = AUTH_ERROR;
133        rply.rjcted_rply.rj_why = why;
134        SVC_REPLY(xprt, &rply);
135}
136
137/*
138 * Auth too weak error reply
139 */
140void
141svcerr_weakauth(xprt)
142        SVCXPRT *xprt;
143{
144
145        svcerr_auth(xprt, AUTH_TOOWEAK);
146}
147
148/*
149 * Program unavailable error reply
150 */
151void
152svcerr_noprog(xprt)
153        register SVCXPRT *xprt;
154{
155        struct rpc_msg rply; 
156
157        rply.rm_direction = REPLY;   
158        rply.rm_reply.rp_stat = MSG_ACCEPTED; 
159        rply.acpted_rply.ar_verf = xprt->xp_verf; 
160        rply.acpted_rply.ar_stat = PROG_UNAVAIL;
161        SVC_REPLY(xprt, &rply);
162}
163
164/*
165 * Program version mismatch error reply
166 */
167void 
168svcerr_progvers(xprt, low_vers, high_vers)
169        register SVCXPRT *xprt;
170        u_long low_vers;
171        u_long high_vers;
172{
173        struct rpc_msg rply;
174
175        rply.rm_direction = REPLY;
176        rply.rm_reply.rp_stat = MSG_ACCEPTED;
177        rply.acpted_rply.ar_verf = xprt->xp_verf;
178        rply.acpted_rply.ar_stat = PROG_MISMATCH;
179        rply.acpted_rply.ar_vers.low = low_vers;
180        rply.acpted_rply.ar_vers.high = high_vers;
181        SVC_REPLY(xprt, &rply);
182}
183
184    void
185svc_processrequest(xprt, prog, vers, dispatch)
186    SVCXPRT *xprt;
187    u_long prog;
188    u_long vers;
189    void (*dispatch)();
190{
191    struct rpc_msg msg;
192    int prog_found = FALSE;
193    u_long low_vers = 0;        /* dummy init */
194    u_long high_vers = 0;       /* dummy init */
195    struct svc_req r;
196    /*static char cred_area[2*MAX_AUTH_BYTES + RQCRED_SIZE];*/
197    char *cred_area;
198   
199    cred_area = (char *)malloc(2*MAX_AUTH_BYTES + RQCRED_SIZE);
200    msg.rm_call.cb_cred.oa_base = cred_area;
201    msg.rm_call.cb_verf.oa_base = &(cred_area[MAX_AUTH_BYTES]);
202    r.rq_clntcred = &(cred_area[2*MAX_AUTH_BYTES]);
203
204    if (SVC_RECV(xprt, &msg)) {
205               
206            /* now find the exported program and call it */
207        /* register struct svc_callout *s; */
208        enum auth_stat why;
209
210        r.rq_xprt = xprt;
211        r.rq_prog = msg.rm_call.cb_prog;
212        r.rq_vers = msg.rm_call.cb_vers;
213        r.rq_proc = msg.rm_call.cb_proc;
214        r.rq_cred = msg.rm_call.cb_cred;
215                   
216            /* first authenticate the message */
217        if ((why= _authenticate(&r, &msg)) != AUTH_OK) {
218            svcerr_auth(xprt, why);
219            free(cred_area);
220            return;
221        }
222       
223               /* now match message with a registered service*/
224        prog_found = FALSE;
225        low_vers = 0 - 1;
226        high_vers = 0;
227        if (prog == r.rq_prog) {
228            if (vers == r.rq_vers) {
229                (*dispatch)(&r, xprt);
230                free(cred_area);
231                return;
232            }  /* found correct version */
233            prog_found = TRUE;
234            if (vers < low_vers)
235                low_vers = vers;
236            if (vers > high_vers)
237                high_vers = vers;
238        }   /* found correct program */
239    }
240        /*
241         * if we got here, the program or version
242         * is not served ...
243         */
244    if (prog_found) {
245        svcerr_progvers(xprt,
246                        low_vers, high_vers);
247    } else {
248        svcerr_noprog(xprt);
249    }
250
251    free(cred_area);
252
253}
254
255/* stubs for solaris rpcgen */
256/*int _rpcsvccount;
257int _rpcsvcstate;
258int _SERVED;
259*/
Note: See TracBrowser for help on using the repository browser.