Programming with Remote Procedure Calls (RPC)

Low-level data structures

For reference, here are the client- and server-side RPC handles, as well as an authentication structure.

    * Client rpc handle.
    * Created by individual implementations
    * Client is responsible for initializing auth

typedef struct { AUTH *cl_auth; /* authenticator */ struct clnt_ops { enum clnt_stat (*cl_call)(); /* call remote procedure */ void (*cl_abort)(); /* abort a call */ void (*cl_geterr)(); /* get specific error code */ bool_t (*cl_freeres)(); /* frees results */ void (*cl_destroy)(); /* destroy this structure */ bool_t (*cl_control)(); /* the ioctl() of rpc */ } *cl_ops; caddr_t cl_private; /* private stuff */ char *cl_netid; /* network token */ char *cl_tp; /* device name */ } CLIENT;

The client-side handle contains an authentication structure. For a client program authenticate itself, it must initialize the cl_auth field to an appropriate authentication structure:
    * Auth handle, interface to client side authenticators.
   typedef struct {
       struct  opaque_auth     ah_cred;	/* credentials */
       struct  opaque_auth     ah_verf;	/* verifier */
       union   des_block       ah_key;	/* DES key */
       struct auth_ops {
           void    (*ah_nextverf)();
           int     (*ah_marshal)();    /* nextverf & serialize */
           int     (*ah_validate)();   /* validate verifier */
           int     (*ah_refresh)();    /* refresh credentials */
           void    (*ah_destroy)();    /* destroy this structure */
       } *ah_ops;
       caddr_t ah_private;				/* Private data */
   } AUTH;
Within the AUTH structure, ah_cred contains the caller's credentials, and ah_verf contains the information necessary to verify those credentials. (See ``Authentication'' for more details.)

This is the server-side transport handle:

    * Server side transport handle

typedef struct { int xp_fd; /* associated file descriptor */ ushort_t xp_port; /* associated port number (obsolete) */ struct xp_ops { bool_t (*xp_recv)(); /* receive incoming requests */ enum xprt_stat (*xp_stat)(); /* get transport status */ bool_t (*xp_getargs)(); /* get arguments */ bool_t (*xp_reply)(); /* send reply */ bool_t (*xp_freeargs)();/* free mem allocated for args */ void (*xp_destroy)(); /* destroy this struct */ } *xp_ops; int xp_addrlen; /* length of remote addr. Obsolete */ char *xp_tp; /* transport provider device name */ char *xp_netid; /* network token */ struct netbuf xp_ltaddr; /* local transport address */ struct netbuf xp_rtaddr; /* remote transport address */ char xp_raddr[16]; /* remote address. Obsolete */ struct opaque_auth xp_verf; /* raw response verifier */ caddr_t xp_p1; /* private: for use by svc ops */ caddr_t xp_p2; /* private: for use by svc ops */ caddr_t xp_p3; /* private: for use by svc lib */ } SVCXPRT;

xp_fd is the file descriptor associated with the handle. Two or more server handles can share the same file descriptor.

xp_netid is the network identifier (for example, udp) of the transport on which this handle was created and xp_tp is the device name associated with that transport.

xp_ltaddr is the server's own bind address, while xp_rtaddr is the address of the remote caller and hence may change from call to call.

xp_netid, xp_tp and xp_ltaddr are initialized by svc_tli_create and other expert-level routines.

The rest of the fields are initialized by the bottom-level server routines svc_dg_create and svc_vc_create.

© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005