7.  The RPC Language

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 is used to describe the essence of the language.

7.1.  An Example Service Described in the RPC Language

Here is an example of the specification of a simple ping program.

/*
* Simple ping program
*/
program PING_PROG {
	/* Latest and greatest version */
	version PING_VERS_PINGBACK {
	void 
	PINGPROC_NULL(void) = 0;

	/*
	* 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;

const PING_VERS = 2;      /* latest version */

The first version described is PING_VERS_PINGBACK with two procedures, PINGPROC_NULL and PINGPROC_PINGBACK. PINGPROC_NULL takes no arguments and returns no results, but it is useful for 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 any kind of 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.

7.2.  The RPC Language Specification

The RPC language is identical to the XDR language, except for the added definition of a program-def described below.

program-def:
	"program" identifier "{"
		version-def 
		version-def *
	"}" "=" constant ";"

version-def:
	"version" identifier "{"
		procedure-def
		procedure-def *
	"}" "=" constant ";"

procedure-def:
	type-specifier identifier "(" type-specifier ")"
	"=" constant ";"

7.3.  Syntax Notes

1.
The following keywords are added and cannot be used as identifiers: "program" and "version";
2.
A version name cannot occur more than once within the scope of a program definition. Nor can a version number occur more than once within the scope of a program definition.
3.
A procedure name cannot occur more than once within the scope of a version definition. Nor can a procedure number occur more than once within the scope of version definition.
4.
Program identifiers are in the same name space as constant and type identifiers.
5.
Only unsigned constants can be assigned to programs, versions and procedures.