home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 29 Fixes_o / 29-Fixes_o.zip / prgcsd.exe / SVC.H < prev    next >
Text File  |  1993-02-24  |  12KB  |  294 lines

  1. /********************************************************copyrite.xmc***/
  2. /*                                                                     */
  3. /*   Licensed Materials - Property of IBM                              */
  4. /*                                                                     */
  5. /*   This module is "Restricted Materials of IBM":                     */
  6. /*      Program Number:   5798RXW                                      */
  7. /*      Program Name:     IBM TCP/IP Version 1.2 for OS/2              */
  8. /*   (C) Copyright IBM Corporation. 1990, 1991.                        */
  9. /*                                                                     */
  10. /*   See IBM Copyright Instructions.                                   */
  11. /*                                                                     */
  12. /********************************************************copyrite.xmc***/
  13. /*
  14.  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  15.  * unrestricted use provided that this legend is included on all tape
  16.  * media and as a part of the software program in whole or part.  Users
  17.  * may copy or modify Sun RPC without charge, but are not authorized
  18.  * to license or distribute it to anyone else except as part of a product or
  19.  * program developed by the user.
  20.  *
  21.  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  22.  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  23.  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  24.  *
  25.  * Sun RPC is provided with no support and without any obligation on the
  26.  * part of Sun Microsystems, Inc. to assist in its use, correction,
  27.  * modification or enhancement.
  28.  *
  29.  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  30.  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  31.  * OR ANY PART THEREOF.
  32.  *
  33.  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  34.  * or profits or other special, indirect and consequential damages, even if
  35.  * Sun has been advised of the possibility of such damages.
  36.  *
  37.  * Sun Microsystems, Inc.
  38.  * 2550 Garcia Avenue
  39.  * Mountain View, California  94043
  40.  */
  41. /*      @(#)svc.h 1.1 86/02/03 SMI      *
  42.  
  43. /*
  44.  * svc.h, Server-side remote procedure call interface.
  45.  *
  46.  * Copyright (C) 1984, Sun Microsystems, Inc.
  47.  */
  48. #ifndef INCL_RPC_SVC_H
  49. #define INCL_RPC_SVC_H
  50. #ifndef __32BIT__
  51. #define _Packed
  52. #define _Seg16
  53. #define _Far16
  54. #define _Cdecl
  55. #endif
  56.  
  57. /*
  58.  * This interface must manage two items concerning remote procedure calling:
  59.  *
  60.  * 1) An arbitrary number of transport connections upon which rpc requests
  61.  * are received.  The two most notable transports are TCP and UDP;  they are
  62.  * created and registered by routines in svc_tcp.c and svc_udp.c, respectively;
  63.  * they in turn call xprt_register and xprt_unregister.
  64.  *
  65.  * 2) An arbitrary number of locally registered services.  Services are
  66.  * described by the following four data: program number, version number,
  67.  * "service dispatch" function, a transport handle, and a boolean that
  68.  * indicates whether or not the exported program should be registered with a
  69.  * local binder service;  if true the program's number and version and the
  70.  * port number from the transport handle are registered with the binder.
  71.  * These data are registered with the rpc svc system via svc_register.
  72.  *
  73.  * A service's dispatch function is called whenever an rpc request comes in
  74.  * on a transport.  The request's program and version numbers must match
  75.  * those of the registered service.  The dispatch function is passed two
  76.  * parameters, struct svc_req * and SVCXPRT *, defined below.
  77.  */
  78.  
  79. enum xprt_stat {
  80.         XPRT_DIED,
  81.         XPRT_MOREREQS,
  82.         XPRT_IDLE
  83. #ifdef __32BIT__
  84.         , XPRT_DUMMY=32767
  85. #endif
  86. };
  87.  
  88. /*
  89.  * Server side transport handle
  90.  */
  91. typedef _Packed struct {
  92.         short           xp_sock;
  93.         u_short         xp_port;         /* associated port number */
  94.         struct xp_ops {
  95.             bool_t      (* _Seg16 _Far16 _Cdecl xp_recv)(void * _Seg16,void * _Seg16);    /* receive incomming requests */
  96.             enum xprt_stat (* _Seg16 _Far16 _Cdecl xp_stat)(void * _Seg16); /* get transport status */
  97.             bool_t      (* _Seg16 _Far16 _Cdecl xp_getargs)(void * _Seg16,xdrproc_t,void * _Seg16); /* get arguments */
  98.             bool_t      (* _Seg16 _Far16 _Cdecl xp_reply)(void * _Seg16,void * _Seg16);   /* send reply */
  99.             bool_t      (* _Seg16 _Far16 _Cdecl xp_freeargs)(void * _Seg16,xdrproc_t,void * _Seg16);/* free mem allocated for args */
  100.             void        (* _Seg16 _Far16 _Cdecl xp_destroy)(void * _Seg16); /* destroy this struct */
  101.         } * _Seg16 xp_ops;
  102.         short           xp_addrlen;      /* length of remote address */
  103.         struct sockaddr_in xp_raddr;     /* remote address */
  104.         _Packed struct opaque_auth xp_verf;      /* raw response verifier */
  105.         char * _Seg16   xp_p1;           /* private */
  106.         char * _Seg16   xp_p2;           /* private */
  107. } SVCXPRT;
  108.  
  109. /*
  110.  *  Approved way of getting address of caller
  111.  */
  112. #define svc_getcaller(x) (&(x)->xp_raddr)
  113.  
  114. /*
  115.  * Operations defined on an SVCXPRT handle
  116.  *
  117.  * SVCXPRT              *xprt;
  118.  * struct rpc_msg       *msg;
  119.  * xdrproc_t             xargs;
  120.  * caddr_t               argsp;
  121.  */
  122. #define SVC_RECV(xprt, msg)                             \
  123.         (*(xprt)->xp_ops->xp_recv)((xprt), (msg))
  124. #define svc_recv(xprt, msg)                             \
  125.         (*(xprt)->xp_ops->xp_recv)((xprt), (msg))
  126.  
  127. #define SVC_STAT(xprt)                                  \
  128.         (*(xprt)->xp_ops->xp_stat)(xprt)
  129. #define svc_stat(xprt)                                  \
  130.         (*(xprt)->xp_ops->xp_stat)(xprt)
  131.  
  132. #define SVC_GETARGS(xprt, xargs, argsp)                 \
  133.         (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp))
  134. #define svc_getargs(xprt, xargs, argsp)                 \
  135.         (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp))
  136.  
  137. #define SVC_REPLY(xprt, msg)                            \
  138.         (*(xprt)->xp_ops->xp_reply) ((xprt), (msg))
  139. #define svc_reply(xprt, msg)                            \
  140.         (*(xprt)->xp_ops->xp_reply) ((xprt), (msg))
  141.  
  142. #define SVC_FREEARGS(xprt, xargs, argsp)                \
  143.         (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp))
  144. #define svc_freeargs(xprt, xargs, argsp)                \
  145.         (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp))
  146.  
  147. #define SVC_DESTROY(xprt)                               \
  148.         (*(xprt)->xp_ops->xp_destroy)(xprt)
  149. #define svc_destroy(xprt)                               \
  150.         (*(xprt)->xp_ops->xp_destroy)(xprt)
  151.  
  152.  
  153. /*
  154.  * Service request
  155.  */
  156. _Packed struct svc_req {
  157.         u_long          rq_prog;        /* service program number */
  158.         u_long          rq_vers;        /* service protocol version */
  159.         u_long          rq_proc;        /* the desired procedure */
  160.         _Packed struct opaque_auth rq_cred;     /* raw creds from the wire */
  161.         char * _Seg16   rq_clntcred;    /* read only cooked cred */
  162.         SVCXPRT * _Seg16 rq_xprt;               /* associated transport */
  163. };
  164.  
  165.  
  166. /*
  167.  * Service registration
  168.  *
  169.  * svc_register(xprt, prog, vers, dispatch, protocol)
  170.  *      SVCXPRT *xprt;
  171.  *      u_long prog;
  172.  *      u_long vers;
  173.  *      void (*dispatch)();
  174.  *      int protocol;  /* like TCP or UDP, zero means do not register
  175.  */
  176. extern bool_t   _Far16 _Cdecl svc_register(SVCXPRT * _Seg16,u_long,u_long,
  177.   void (* _Seg16 _Far16 _Cdecl)(_Packed struct svc_req * _Seg16, SVCXPRT * _Seg16),
  178.   short);
  179.  
  180. /*
  181.  * Service un-registration
  182.  *
  183.  * svc_unregister(prog, vers)
  184.  *      u_long prog;
  185.  *      u_long vers;
  186.  */
  187. extern void  _Far16 _Cdecl   svc_unregister(u_long,u_long);
  188.  
  189. /*
  190.  * Transport registration.
  191.  *
  192.  * xprt_register(xprt)
  193.  *      SVCXPRT *xprt;
  194.  */
  195. extern void _Far16 _Cdecl    xprt_register(SVCXPRT * _Seg16);
  196.  
  197. /*
  198.  * Transport un-register
  199.  *
  200.  * xprt_unregister(xprt)
  201.  *      SVCXPRT *xprt;
  202.  */
  203. extern void _Far16 _Cdecl    xprt_unregister(SVCXPRT * _Seg16);
  204.  
  205.  
  206. /*
  207.  * When the service routine is called, it must first check to see if it
  208.  * knows about the procedure;  if not, it should call svcerr_noproc
  209.  * and return.  If so, it should deserialize its arguments via
  210.  * SVC_GETARGS (defined above).  If the deserialization does not work,
  211.  * svcerr_decode should be called followed by a return.  Successful
  212.  * decoding of the arguments should be followed the execution of the
  213.  * procedure's code and a call to svc_sendreply.
  214.  *
  215.  * Also, if the service refuses to execute the procedure due to too-
  216.  * weak authentication parameters, svcerr_weakauth should be called.
  217.  * Note: do not confuse access-control failure with weak authentication!
  218.  *
  219.  * NB: In pure implementations of rpc, the caller always waits for a reply
  220.  * msg.  This message is sent when svc_sendreply is called.
  221.  * Therefore pure service implementations should always call
  222.  * svc_sendreply even if the function logically returns void;  use
  223.  * xdr.h - xdr_void for the xdr routine.  HOWEVER, tcp based rpc allows
  224.  * for the abuse of pure rpc via batched calling or pipelining.  In the
  225.  * case of a batched call, svc_sendreply should NOT be called since
  226.  * this would send a return message, which is what batching tries to avoid.
  227.  * It is the service/protocol writer's responsibility to know which calls are
  228.  * batched and which are not.  Warning: responding to batch calls may
  229.  * deadlock the caller and server processes!
  230.  */
  231.  
  232. extern bool_t _Far16 _Cdecl svc_sendreply(SVCXPRT * _Seg16,xdrproc_t,void * _Seg16);
  233. extern void _Far16 _Cdecl svcerr_decode(SVCXPRT * _Seg16);
  234. extern void _Far16 _Cdecl svcerr_weakauth(SVCXPRT * _Seg16);
  235. extern void _Far16 _Cdecl svcerr_noproc(SVCXPRT * _Seg16);
  236. extern void _Far16 _Cdecl svcerr_auth(SVCXPRT * _Seg16,enum auth_stat);
  237. extern void _Far16 _Cdecl svcerr_noprog(SVCXPRT * _Seg16);
  238. extern void _Far16 _Cdecl svcerr_progvers(SVCXPRT * _Seg16,u_long,u_long);
  239. extern void _Far16 _Cdecl svcerr_systemerr(SVCXPRT * _Seg16);
  240.  
  241. /*
  242.  * Lowest level dispatching -OR- who owns this process anyway.
  243.  * Somebody has to wait for incoming requests and then call the correct
  244.  * service routine.  The routine svc_run does infinite waiting; i.e.,
  245.  * svc_run never returns.
  246.  * Since another (co-existant) package may wish to selectively wait for
  247.  * incoming calls or other events outside of the rpc architecture, the
  248.  * routine svc_getreq is provided.  It must be passed readfds, the
  249.  * "in-place" results of a select system call (see select, section 2).
  250.  */
  251.  
  252. /* dynamic; must be inspected before each call to select */
  253. extern short svc_fds;
  254.  
  255. /*
  256.  * a small program implemented by the svc_rpc implementation itself;
  257.  * also see clnt.h for protocol numbers.
  258.  */
  259. extern void _Far16 _Cdecl rpctest_service(void);
  260. /* argument may not be void, but this is not implemented at present
  261.    in TCPIP for OS/2 10-13-92 */
  262.  
  263. extern void _Far16 _Cdecl svc_getreq(short * _Seg16,short);
  264. extern void _Far16 _Cdecl svc_run(void);       /* never returns */
  265.  
  266. /*
  267.  * Socket to use on svcxxx_create call to get default socket
  268.  */
  269. #define RPC_ANYSOCK     -1
  270.  
  271. /*
  272.  * These are the existing service side transport implementations
  273.  */
  274.  
  275. /*
  276.  * Memory based rpc for testing and timing.
  277.  */
  278. extern SVCXPRT * _Seg16 _Far16 _Cdecl svcraw_create(void);
  279.  
  280. /*
  281.  * Udp based rpc.
  282.  */
  283. extern SVCXPRT * _Seg16 _Far16 _Cdecl svcudp_create(short);
  284. extern SVCXPRT * _Seg16 _Far16 _Cdecl svcudp_bufcreate(short,unsigned short,unsigned short);
  285.  
  286. /*
  287.  * Tcp based rpc.
  288.  */
  289. extern SVCXPRT * _Seg16 _Far16 _Cdecl svctcp_create(short,u_short,u_short);
  290.  
  291. extern short * _Seg16 svc_socks;
  292. extern short noregistered;
  293. #endif
  294.