DIRECTORY CommunicationInternal USING [], CommFlags USING [doDebug], DriverDefs USING [Glitch], NetworkStream USING [], OISCP USING [uniqueAddress, unknownConnID], OISCPTypes USING [ConnectionID, WaitTime], PacketStream USING [FailureReason, Handle, SuspendReason, ClassOfService, WaitTime, defaultWaitTime], PacketStreamInstance USING [Delete], PrincOpsUtils USING [GlobalFrame], Router USING [AssignDestinationRelativeOisAddress], NSAddress USING [NetworkAddress]; PacketStreamMgr: MONITOR IMPORTS PrincOpsUtils, DriverDefs, pktStrmInst: PacketStreamInstance, Router EXPORTS CommunicationInternal, NetworkStream, PacketStream = { OPEN Router, PacketStream; primaryMDS: PUBLIC BOOL _ TRUE; -- we are in the primary MDS. infiniteWaitTime: PUBLIC WaitTime _ LAST[WaitTime]; initialSpareConnectionID: OISCPTypes.ConnectionID = [500]; spareConnectionID: OISCPTypes.ConnectionID; ConnectionTable: REF ConnectionTableType _ NEW[ConnectionTableType]; ConnectionTableType: TYPE = ARRAY (0..maxConnectionNumber] OF ConnectionTableEntry; maxConnectionNumber: CARDINAL = 20; index: CARDINAL _ 0; ConnectionTableEntry: TYPE = RECORD [ rAddr: NSAddress.NetworkAddress, rConnID: OISCPTypes.ConnectionID]; ConnectionTableFull: ERROR = CODE; NotInConnectionTable: ERROR = CODE; ConnectionSuspended: PUBLIC ERROR [why: SuspendReason] = CODE; ConnectionFailed: PUBLIC SIGNAL [why: FailureReason] = CODE; AttentionTimeout: PUBLIC ERROR = CODE; Make: PUBLIC PROC [local, remote: NSAddress.NetworkAddress, localConnID, remoteConnID: OISCPTypes.ConnectionID, establishConnection: BOOL, timeout: OISCPTypes.WaitTime _ defaultWaitTime, classOfService: ClassOfService _ bulk] RETURNS [psH: PacketStream.Handle] = { estdRemoteAddr: NSAddress.NetworkAddress; estdRemoteConnID: OISCPTypes.ConnectionID; newPktStrmInst: POINTER TO FRAME[PacketStreamInstance] _ NEW pktStrmInst; { ENABLE UNWIND => newPktStrmInst.Delete[]; IF local = OISCP.uniqueAddress THEN local _ Router.AssignDestinationRelativeOisAddress[remote.net]; IF localConnID = OISCP.unknownConnID THEN localConnID _ GetUniqueConnectionID[]; [psH, estdRemoteAddr, estdRemoteConnID] _ START newPktStrmInst[ local, remote, localConnID, remoteConnID, establishConnection, timeout, classOfService]; InsertIntoConnectionTable[estdRemoteAddr, estdRemoteConnID]; }; }; Destroy: PUBLIC PROC [psH: PacketStream.Handle] = { oldPktStrmInst: POINTER TO FRAME[PacketStreamInstance] _ LOOPHOLE[PrincOpsUtils.GlobalFrame[LOOPHOLE[psH.get]], POINTER]; remote: NSAddress.NetworkAddress _ oldPktStrmInst.remoteAddr; remoteConnID: OISCPTypes.ConnectionID _ oldPktStrmInst.remoteConnectionID; oldPktStrmInst.Delete[]; RemoveFromConnectionTable[remote, remoteConnID]; }; GetUniqueConnectionID: ENTRY PROC RETURNS [iD: OISCPTypes.ConnectionID] = { iD _ spareConnectionID; IF (spareConnectionID _ [spareConnectionID + 1]) = OISCPTypes.ConnectionID[0] THEN spareConnectionID _ initialSpareConnectionID; }; InsertIntoConnectionTable: PUBLIC ENTRY PROC [remote: NSAddress.NetworkAddress, remoteConnID: OISCPTypes.ConnectionID] = { IF (index _ index + 1) > maxConnectionNumber THEN IF CommFlags.doDebug THEN DriverDefs.Glitch[ConnectionTableFull]; ConnectionTable[index] _ ConnectionTableEntry[remote, remoteConnID]; }; RemoveFromConnectionTable: PUBLIC ENTRY PROC [remote: NSAddress.NetworkAddress, remoteConnID: OISCPTypes.ConnectionID] = { FOR i: CARDINAL IN (0..index] DO IF ConnectionTable[i].rAddr.host = remote.host AND ConnectionTable[i].rAddr.socket = remote.socket AND ConnectionTable[i].rConnID = remoteConnID THEN { ConnectionTable[i] _ ConnectionTable[index]; index _ index - 1; RETURN; }; ENDLOOP; IF CommFlags.doDebug THEN DriverDefs.Glitch[NotInConnectionTable]; }; ConnectionAlreadyThere: PUBLIC ENTRY PROC [remote: NSAddress.NetworkAddress, remoteConnID: OISCPTypes.ConnectionID] RETURNS [BOOL] = { FOR i: CARDINAL IN (0..index] DO IF ConnectionTable[i].rAddr.host = remote.host AND ConnectionTable[i].rAddr.socket = remote.socket AND ConnectionTable[i].rConnID = remoteConnID THEN RETURN[TRUE]; ENDLOOP; RETURN[FALSE]; }; IF primaryMDS THEN spareConnectionID _ initialSpareConnectionID; }. LOG Time: January 23, 1981 4:17 PM By: Garlick Action: added classOfService to Make. άPacketStreamMgr.mesa - implementation module for the manager of Pilot Packet Streams Copyright c 1985 by Xerox Corporation. All rights reserved. Garlick on: January 23, 1981 4:17 PM Russ Atkinson (RRA) October 17, 1985 5:11:18 pm PDT These variables must eventually live in outerspace so that multiple MDSs access the same packet stream variables. The module in the primary MDS will perform the initialization of the "globals", while the others will not. This module is a monitor in order to protect the value of spareConnectionID and the ConnectionTable. Some day the connection IDs in use will be remembered across wrap around. monitor data connectionID parameters connectionTable parameters and types various Glitches. Cool Procedures This procedure creates a packet stream instance. The local and remote addresses must be correctly specified, or else we pick defaults when possible. If we do not have a local address we pick one with a network number that is a good way to get to the destinationand therefore a good way to get back to us! This procedure deletes the specified packet stream instance. This procedure returns a unique connection ID. Some day the active connection IDs in use will be kept around, so that on wrap around an unused ID will be assigned. This procedure inserts a connection into the connectionTable. This procedure removes a connection from the connectionTable. This procedure checks if there is a similar connection in the connectionTable. initialization Κη˜codešœT™TKšœ Οmœ1™Kšœžœžœžœ˜