DIRECTORY
Basics USING [Card16FromH],
SunPMapLocal USING [ipProtocolUDP, SetLocal],
SunRPC USING [CreateServer, Error, GetCard32, GetF, GetRope, GetServerPort, Handle, PutCard32, PutF, Server, ServerProc, StartReply],
SunRPCAuth USING [Conversation],
SunYPBind USING [domain, DomainName, null, program, programVersion, RequestDomainBinding, ResponseBinding, ResponseCode, setdom],
SunYPBindServer USING [Domain, Null, Setdom]
;
SunYPBindServerStub:
CEDAR
PROGRAM
IMPORTS Basics, SunPMapLocal, SunRPC, SunYPBindServer
~ {
Types
Handle: TYPE ~ SunRPC.Handle;
Conversation: TYPE ~ SunRPCAuth.Conversation;
Parameters
fastTimeout: CARD ← 200;
slowTimeout: CARD ← 2500;
defaultRetries: CARD ← 4;
noRetries: CARD ← 0;
Procedures
Serve: SunRPC.ServerProc
-- [h: Handle, c: Conservation, proc: CARD, clientData: REF] -- ~ {
SELECT proc
FROM
SunYPBind.null => ServeNull[h, c];
SunYPBind.domain => ServeDomain[h, c];
SunYPBind.setdom => ServeSetdom[h, c];
ENDCASE => ERROR SunRPC.Error[$wrongProc];
};
ServeNull:
PROC [h: Handle, c: Conversation] ~ {
SunRPC.StartReply[h];
SunYPBindServer.Null[h, c];
};
ServeDomain:
PROC [h: Handle, c: Conversation] ~ {
domainName: SunYPBind.DomainName;
resp: SunYPBind.ResponseBinding;
domainName ← SunRPC.GetRope[h];
SunRPC.StartReply[h];
TRUSTED { resp ← SunYPBindServer.Domain[h, c, domainName] };
WITH r: resp
SELECT
FROM
success => {
SunRPC.PutCard32[h, SunYPBind.ResponseCode.success.ORD];
SunRPC.PutF[h, LOOPHOLE[r.binding.address]];
SunRPC.PutCard32[h, r.binding.port];
};
failure => {
SunRPC.PutCard32[h, SunYPBind.ResponseCode.failure.ORD];
SunRPC.PutCard32[h, ORD[r.errorCode]];
};
ENDCASE => ERROR;
};
ServeSetdom:
PROC [h: Handle, c: Conversation] ~ {
req: SunYPBind.RequestDomainBinding;
req.domainName ← SunRPC.GetRope[h];
req.binding.address ← LOOPHOLE[SunRPC.GetF[h]];
req.binding.port ← SunRPC.GetCard32[h];
req.version ← SunRPC.GetCard32[h];
SunRPC.StartReply[h];
SunYPBindServer.Setdom[h, c, req];
};
theServer: SunRPC.Server;
Init:
PROC ~ {
theServer ← SunRPC.CreateServer[pgm~SunYPBind.program, version~SunYPBind.programVersion, serverProc~Serve, concurrency~3];
[] ← SunPMapLocal.SetLocal[SunYPBind.program, SunYPBind.programVersion, SunPMapLocal.ipProtocolUDP, Basics.Card16FromH[SunRPC.GetServerPort[theServer]]];
};
}...