Annotation of 43BSDReno/lib/librpc/svc_raw.c, revision 1.1.1.1

1.1       root        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: #ifndef lint
                     30: static char sccsid[] = "@(#)svc_raw.c 1.3 85/03/14 Copyr 1984 Sun Micro";
                     31: #endif
                     32: 
                     33: /*
                     34:  * svc_raw.c,   This a toy for simple testing and timing.
                     35:  * Interface to create an rpc client and server in the same UNIX process.
                     36:  * This lets us similate rpc and get rpc (round trip) overhead, without
                     37:  * any interference from the kernal.
                     38:  *
                     39:  * Copyright (C) 1984, Sun Microsystems, Inc.
                     40:  */
                     41: 
                     42: #include "types.h"
                     43: #include <netinet/in.h>
                     44: #include "xdr.h"
                     45: #include "auth.h"
                     46: #include "clnt.h"
                     47: #include "rpc_msg.h"
                     48: #include "svc.h"
                     49: 
                     50: #define NULL ((caddr_t)0)
                     51: 
                     52: /*
                     53:  * This is the "network" that we will be moving data over
                     54:  */
                     55: extern char _raw_buf[UDPMSGSIZE];
                     56: 
                     57: static bool_t          svcraw_recv();
                     58: static enum xprt_stat  svcraw_stat();
                     59: static bool_t          svcraw_getargs();
                     60: static bool_t          svcraw_reply();
                     61: static bool_t          svcraw_freeargs();
                     62: static void            svcraw_destroy();
                     63: 
                     64: static struct xp_ops server_ops = {
                     65:        svcraw_recv,
                     66:        svcraw_stat,
                     67:        svcraw_getargs,
                     68:        svcraw_reply,
                     69:        svcraw_freeargs,
                     70:        svcraw_destroy
                     71: };
                     72: 
                     73: static SVCXPRT server;
                     74: static XDR xdr_stream;
                     75: static char verf_body[MAX_AUTH_BYTES];
                     76: 
                     77: SVCXPRT *
                     78: svcraw_create()
                     79: {
                     80: 
                     81:        server.xp_sock = 0;
                     82:        server.xp_port = 0;
                     83:        server.xp_ops = &server_ops;
                     84:        server.xp_verf.oa_base = verf_body;
                     85:        xdrmem_create(&xdr_stream, _raw_buf, UDPMSGSIZE, XDR_FREE);
                     86:        return (&server);
                     87: }
                     88: 
                     89: static enum xprt_stat
                     90: svcraw_stat()
                     91: {
                     92: 
                     93:        return (XPRT_IDLE);
                     94: }
                     95: 
                     96: static bool_t
                     97: svcraw_recv(xprt, msg)
                     98:        SVCXPRT *xprt;
                     99:        struct rpc_msg *msg;
                    100: {
                    101:        register XDR *xdrs = &xdr_stream;
                    102: 
                    103:        xdrs->x_op = XDR_DECODE;
                    104:        XDR_SETPOS(xdrs, 0);
                    105:        if (! xdr_callmsg(xdrs, msg))
                    106:               return (FALSE);
                    107:        return (TRUE);
                    108: }
                    109: 
                    110: static bool_t
                    111: svcraw_reply(xprt, msg)
                    112:        SVCXPRT *xprt;
                    113:        struct rpc_msg *msg;
                    114: {
                    115:        register XDR *xdrs = &xdr_stream;
                    116: 
                    117:        xdrs->x_op = XDR_ENCODE;
                    118:        XDR_SETPOS(xdrs, 0);
                    119:        if (! xdr_replymsg(xdrs, msg))
                    120:               return (FALSE);
                    121:        (void)XDR_GETPOS(xdrs);  /* called just for overhead */
                    122:        return (TRUE);
                    123: }
                    124: 
                    125: static bool_t
                    126: svcraw_getargs(xprt, xdr_args, args_ptr)
                    127:        SVCXPRT *xprt;
                    128:        xdrproc_t xdr_args;
                    129:        caddr_t args_ptr;
                    130: {
                    131: 
                    132:        return ((*xdr_args)(&xdr_stream, args_ptr));
                    133: }
                    134: 
                    135: static bool_t
                    136: svcraw_freeargs(xprt, xdr_args, args_ptr)
                    137:        SVCXPRT *xprt;
                    138:        xdrproc_t xdr_args;
                    139:        caddr_t args_ptr;
                    140: { 
                    141:        register XDR *xdrs = &xdr_stream;
                    142: 
                    143:        xdrs->x_op = XDR_FREE;
                    144:        return ((*xdr_args)(xdrs, args_ptr));
                    145: } 
                    146: 
                    147: static void
                    148: svcraw_destroy()
                    149: {
                    150: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.