SunPMapServerStub.mesa
Copyright Ó 1989, 1991, 1992 by Xerox Corporation. All rights reserved.
Demers, January 5, 1988 5:44:51 pm PST
Willie-Sue, March 16, 1989 6:56:33 pm PST
Chauser, January 3, 1992 10:54 am PST
DIRECTORY
ArpaUDP USING [Address],
Basics USING [HFromCard16],
SunPMap USING [callit, dump, getPort, ipProtocolUDP, MapEntry, null, program, programVersion, set, udpPort, unset],
SunPMapServer USING [Callit, Dump, GetPort, Null, Set, Unset],
SunRPC USING [Error, GetCard32, GetRefText, Handle, PutCard32, PutRefText, StartReply],
SunRPCOnUDP USING [CreateServer, Server, ServerProc],
SunRPCAuth USING [Conversation]
;
SunPMapServerStub: CEDAR PROGRAM
IMPORTS Basics, SunRPC, SunRPCOnUDP, SunPMapServer
~ {
Types
Address: TYPE ~ ArpaUDP.Address;
Handle: TYPE ~ SunRPC.Handle;
Conversation: TYPE ~ SunRPCAuth.Conversation;
MapEntry: TYPE ~ SunPMap.MapEntry;
Parameters
defaultReplyTTL: CARDINAL ¬ 2;
Procedures
Serve: SunRPCOnUDP.ServerProc -- [h: Handle, c: Conversation, proc: CARD, clientData: REF] RETURNS [doReply: BOOL, replyTimeToLive: CARDINAL] -- ~ {
doReply ¬ TRUE;
replyTimeToLive ¬ defaultReplyTTL;
SELECT proc FROM
SunPMap.null => ServeNull[h, c];
SunPMap.set => ServeSet[h, c];
SunPMap.unset => ServeUnset[h, c];
SunPMap.getPort => ServeGetPort[h, c];
SunPMap.dump => ServeDump[h, c];
SunPMap.callit => ServeCallit[h, c];
ENDCASE => ERROR SunRPC.Error[$wrongProc];
};
ServeNull: PROC [h: Handle, c: Conversation] ~ {
SunRPC.StartReply[h];
SunPMapServer.Null[h, c];
};
ServeSet: PROC [h: Handle, c: Conversation] ~ {
program, version, protocol, port: CARD32;
success: BOOL;
program ¬ SunRPC.GetCard32[h];
version ¬ SunRPC.GetCard32[h];
protocol ¬ SunRPC.GetCard32[h];
port ¬ SunRPC.GetCard32[h];
SunRPC.StartReply[h];
success ¬ SunPMapServer.Set[h, c, program, version, protocol, port];
SunRPC.PutCard32[h, IF success THEN 1 ELSE 0];
};
ServeUnset: PROC [h: Handle, c: Conversation]
~ {
program, version: CARD32;
success: BOOL;
program ¬ SunRPC.GetCard32[h];
version ¬ SunRPC.GetCard32[h];
SunRPC.StartReply[h];
success ¬ SunPMapServer.Unset[h, c, program, version];
SunRPC.PutCard32[h, IF success THEN 1 ELSE 0];
};
ServeGetPort: PROC [h: Handle, c: Conversation] ~ {
program, version, protocol: CARD32;
port: CARD32;
program ¬ SunRPC.GetCard32[h];
version ¬ SunRPC.GetCard32[h];
protocol ¬ SunRPC.GetCard32[h];
SunRPC.StartReply[h];
port ¬ SunPMapServer.GetPort[h, c, program, version, protocol];
SunRPC.PutCard32[h, port];
};
ServeDump: PROC [h: Handle, c: Conversation] ~ {
EachMapEntry: PROC [mapEntry: MapEntry] ~ {
SunRPC.PutCard32[h, 1];
SunRPC.PutCard32[h, mapEntry.program];
SunRPC.PutCard32[h, mapEntry.version];
SunRPC.PutCard32[h, mapEntry.protocol];
SunRPC.PutCard32[h, mapEntry.port];
};
SunRPC.StartReply[h];
SunPMapServer.Dump[h, c, EachMapEntry];
SunRPC.PutCard32[h, 0];
};
ServeCallit: PUBLIC PROC [h: Handle, c: Conversation] ~ {
program, version, proc: CARD32;
args: REF TEXT;
port: CARD32;
result: REF TEXT;
program ¬ SunRPC.GetCard32[h];
version ¬ SunRPC.GetCard32[h];
proc¬ SunRPC.GetCard32[h];
args ¬ SunRPC.GetRefText[h];
SunRPC.StartReply[h];
[port, result] ¬ SunPMapServer.Callit[h, c, program, version, proc, args];
SunRPC.PutCard32[h, port];
SunRPC.PutRefText[h, result];
};
theServer: SunRPCOnUDP.Server;
Init: PROC ~ {
theServer ¬ SunRPCOnUDP.CreateServer[SunPMap.program, SunPMap.programVersion, Serve, Basics.HFromCard16[SunPMap.udpPort], 3, NIL];
[] ¬ SunPMapServer.Set[NIL, NIL, SunPMap.program, SunPMap.programVersion, SunPMap.ipProtocolUDP, SunPMap.udpPort];
};
Init[];
}...