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[];
}...