|
|
Just as there was a need to describe the XDR data-types in a formal language, there is also need to describe the procedures that operate on these XDR data-types in a formal language as well. We use the RPC Language for this purpose. It is an extension to the XDR language. The following example specification of a simple ping program describes the essence of the language.
/* * Simple ping program */ program PING_PROG { /* Latest and greatest version */ version PING_VERS_PINGBACK { void PINGPROC_NULL(void) = 0;The first version described is PING_VERS_PINGBACK with two procedures, PINGPROC_NULL and PINGPROC_PINGBACK./* * Ping the caller, return the round-trip time * (in microseconds). Returns -1 if the operation * timed out. */ int PINGPROC_PINGBACK(void) = 1; } = 2;
/* * Original version */ version PING_VERS_ORIG { void PINGPROC_NULL(void) = 0; } = 1; } = 1; } = 200000;
const PING_VERS = 2; /* latest version */
PINGPROC_NULL takes no arguments and returns no results, but it is useful for such things as computing round-trip times from the client to the server and back again. By convention, procedure 0 of any RPC protocol should have the same semantics, and never require authentication.
The second procedure is used for the client to have the server do a reverse ping operation back to the client, and it returns the amount of time (in microseconds) that the operation used.
The next version, PING_VERS_ORIG, is the original version of the protocol and it does not contain PINGPROC_PINGBACK procedure. It is useful for compatibility with old client programs, and as this program matures it may be dropped from the protocol entirely.
The RPC language is identical to the XDR language, except for the added definitions described below.
program-definition: program program-ident { version-list } = valueversion-list: version ; version ; version-list
version: version version-ident { procedure-list } = value
procedure-list: procedure ; procedure ; procedure-list
procedure: type-ident procedure-ident ( type-ident ) = value
program version