-- Transport Mechanism - public DEFS for info about other servers --

-- [juniper]<DMS>MS>ServerDefs.mesa

-- Andrew Birrell   4-Aug-80 18:02:03 --

DIRECTORY
BodyDefs	USING[ RName ],
HeapDefs	USING[ WriterHandle ],
PupTypes	USING[ PupAddress ];


ServerDefs:	DEFINITIONS = BEGIN

ServerName:	TYPE = RECORD[ SELECT type:* FROM
		    rName =>   [value: BodyDefs.RName],
		    connect => [value: STRING],
		    netAddr => [value: PupTypes.PupAddress],
                    ENDCASE ];

ServerHandle:	TYPE = POINTER TO ServerData;

ServerData:	TYPE = MONITORED RECORD[
		    next:      PRIVATE ServerHandle,
		    name:      ServerName,
		    up:        PRIVATE BOOLEAN,
		    inUse:     PRIVATE BOOLEAN,
		    addrKnown: PRIVATE BOOLEAN,
		    type:      ServerType,
		    addr:      PRIVATE PupTypes.PupAddress,
		    SL:        HeapDefs.WriterHandle ];
		    -- The "SL" field is initialised to NIL by the
		    -- "ServerAlloc" module, and is accessed and altered
		    -- only by the "ReadInput" module.  All other fields are
		    -- initialised, accessed and altered only by the
		    -- "ServerInfo" and "ServerAlloc" modules.

ServerType:	TYPE = {mail,--MTP--foreign};

GetServer:	PROCEDURE[name: ServerName, type: ServerType]
		    RETURNS[ ServerHandle ];
		    -- creates ServerData if necessary.  The name may
		    -- define the server by R-Name, by connect site,
		    -- or by net address (including socket).  Several
		    -- ServerHandle's, defined by different names, may map
		    -- to the same net address. --

EnumerateAll:	PROCEDURE[ work: PROCEDURE[ServerHandle] ];
		    -- enumerates all servers --

ServerUp:	PROCEDURE[ handle: ServerHandle ]
		    RETURNS[ BOOLEAN ];
		    -- known state of the server --

UpServer:	PROCEDURE[ handle: ServerHandle ];
		    -- notification that server is believed to be up. --

DownServer:	PROCEDURE[ handle: ServerHandle ];
		    -- notification that server is believed to be down.
		    -- Also ceases to cache the server's net address. --

ServerAddr:	PROCEDURE[ handle: ServerHandle ]
		    RETURNS[ PupTypes.PupAddress ];
		    -- the probable address of the server. May signal
		    -- NoSuchServer or ServerNotUp  --

ServerIsLocal:	PROCEDURE[ handle: ServerHandle ]
		    RETURNS[ BOOLEAN ];
		    -- Returns whether the present address of the server
		    -- is the local host --

NoSuchServer:	ERROR;
		    -- Raised by ServerAddr if the server cannot be located.
		    -- The server is now believed to be down. --

ServerNotUp:	ERROR;
		    -- Raised by ServerAddr if no route exists to the
		    -- server.  The server is now believed to be down. --

END.