source: rtems-libbsd/services/librpc/src/rpc/svc_raw.c @ 20ec9e6

4.1155-freebsd-126-freebsd-12freebsd-9.3
Last change on this file since 20ec9e6 was 20ec9e6, checked in by Joel Sherrill <joel.sherrill@…>, on 08/03/12 at 19:19:49

librpc: Initial addition

This does not currently compile. There is an include file
issue and int32_t is not defined even though stdint.h is included
before its use.

  • Property mode set to 100644
File size: 4.4 KB
Line 
1/*
2 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
3 * unrestricted use provided that this legend is included on all tape
4 * media and as a part of the software program in whole or part.  Users
5 * may copy or modify Sun RPC without charge, but are not authorized
6 * to license or distribute it to anyone else except as part of a product or
7 * program developed by the user.
8 *
9 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
10 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
11 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
12 *
13 * Sun RPC is provided with no support and without any obligation on the
14 * part of Sun Microsystems, Inc. to assist in its use, correction,
15 * modification or enhancement.
16 *
17 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
18 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
19 * OR ANY PART THEREOF.
20 *
21 * In no event will Sun Microsystems, Inc. be liable for any lost revenue
22 * or profits or other special, indirect and consequential damages, even if
23 * Sun has been advised of the possibility of such damages.
24 *
25 * Sun Microsystems, Inc.
26 * 2550 Garcia Avenue
27 * Mountain View, California  94043
28 */
29
30#if defined(LIBC_SCCS) && !defined(lint)
31/*static char *sccsid = "from: @(#)svc_raw.c 1.15 87/08/11 Copyr 1984 Sun Micro";*/
32/*static char *sccsid = "from: @(#)svc_raw.c    2.1 88/07/29 4.0 RPCSRC";*/
33static char *rcsid = "$FreeBSD: src/lib/libc/rpc/svc_raw.c,v 1.7 1999/08/28 00:00:49 peter Exp $";
34#endif
35
36/*
37 * svc_raw.c,   This a toy for simple testing and timing.
38 * Interface to create an rpc client and server in the same UNIX process.
39 * This lets us similate rpc and get rpc (round trip) overhead, without
40 * any interference from the kernal.
41 *
42 * Copyright (C) 1984, Sun Microsystems, Inc.
43 */
44
45#ifdef HAVE_CONFIG_H
46#include "config.h"
47#endif
48
49#include <rpc/rpc.h>
50#include <stdlib.h>
51
52/*
53 * This is the "network" that we will be moving data over
54 */
55struct svc_raw_private {
56        char    _raw_buf[UDPMSGSIZE];
57        SVCXPRT server;
58        XDR     xdr_stream;
59        char    verf_body[MAX_AUTH_BYTES];
60};
61#define svcraw_private ((struct svc_raw_private *)(rtems_rpc_task_variables)->svc_raw_private)
62
63static bool_t           svcraw_recv(SVCXPRT *xprt, struct rpc_msg *msg);
64static enum xprt_stat   svcraw_stat(SVCXPRT *xprt);
65static bool_t           svcraw_getargs(SVCXPRT *xprt, xdrproc_t xdr_args, caddr_t args_ptr);
66static bool_t           svcraw_reply(SVCXPRT *xprt, struct rpc_msg *msg);
67static bool_t           svcraw_freeargs(SVCXPRT *xprt, xdrproc_t xdr_args, caddr_t args_ptr);
68static void             svcraw_destroy(SVCXPRT *xprt);
69
70static struct xp_ops server_ops = {
71        svcraw_recv,
72        svcraw_stat,
73        svcraw_getargs,
74        svcraw_reply,
75        svcraw_freeargs,
76        svcraw_destroy
77};
78
79SVCXPRT *
80svcraw_create(void)
81{
82        register struct svc_raw_private *srp = svcraw_private;
83
84        if (srp == 0) {
85                srp = (struct svc_raw_private *)calloc(1, sizeof (*srp));
86                if (srp == 0)
87                        return (0);
88        }
89        srp->server.xp_sock = 0;
90        srp->server.xp_port = 0;
91        srp->server.xp_ops = &server_ops;
92        srp->server.xp_verf.oa_base = srp->verf_body;
93        xdrmem_create(&srp->xdr_stream, srp->_raw_buf, UDPMSGSIZE, XDR_FREE);
94        return (&srp->server);
95}
96
97static enum xprt_stat
98svcraw_stat(SVCXPRT *xprt)
99{
100
101        return (XPRT_IDLE);
102}
103
104static bool_t
105svcraw_recv(
106        SVCXPRT *xprt,
107        struct rpc_msg *msg)
108{
109        register struct svc_raw_private *srp = svcraw_private;
110        register XDR *xdrs;
111
112        if (srp == 0)
113                return (0);
114        xdrs = &srp->xdr_stream;
115        xdrs->x_op = XDR_DECODE;
116        XDR_SETPOS(xdrs, 0);
117        if (! xdr_callmsg(xdrs, msg))
118               return (FALSE);
119        return (TRUE);
120}
121
122static bool_t
123svcraw_reply(
124        SVCXPRT *xprt,
125        struct rpc_msg *msg)
126{
127        register struct svc_raw_private *srp = svcraw_private;
128        register XDR *xdrs;
129
130        if (srp == 0)
131                return (FALSE);
132        xdrs = &srp->xdr_stream;
133        xdrs->x_op = XDR_ENCODE;
134        XDR_SETPOS(xdrs, 0);
135        if (! xdr_replymsg(xdrs, msg))
136               return (FALSE);
137        (void)XDR_GETPOS(xdrs);  /* called just for overhead */
138        return (TRUE);
139}
140
141static bool_t
142svcraw_getargs(
143        SVCXPRT *xprt,
144        xdrproc_t xdr_args,
145        caddr_t args_ptr)
146{
147        register struct svc_raw_private *srp = svcraw_private;
148
149        if (srp == 0)
150                return (FALSE);
151        return ((*xdr_args)(&srp->xdr_stream, args_ptr));
152}
153
154static bool_t
155svcraw_freeargs(
156        SVCXPRT *xprt,
157        xdrproc_t xdr_args,
158        caddr_t args_ptr)
159{
160        register struct svc_raw_private *srp = svcraw_private;
161        register XDR *xdrs;
162
163        if (srp == 0)
164                return (FALSE);
165        xdrs = &srp->xdr_stream;
166        xdrs->x_op = XDR_FREE;
167        return ((*xdr_args)(xdrs, args_ptr));
168}
169
170static void
171svcraw_destroy(SVCXPRT *xprt)
172{
173}
Note: See TracBrowser for help on using the repository browser.