-- PacketStream.mesa (last edited by Garlick on: January 23, 1981  1:49 PM)
-- Function: The internal definitions module for Pliot Packet Streams.

DIRECTORY
  BufferDefs USING [BufferAccessHandle, GetFreeBuffer, SppBuffer],
  Environment USING [Byte],
  OISCPTypes USING [bytesPerPktHeader, bytesPerLevel2SppHeader, ConnectionID],
  NetworkStream USING [defaultWaitTime, FailureReason, SuspendReason, WaitTime, ClassOfService],
  SpecialSystem USING [NetworkAddress];

PacketStream: DEFINITIONS IMPORTS BufferDefs, NetworkStream =
  BEGIN

  --definitions

  Handle: TYPE = POINTER TO Object;
  Object: TYPE = RECORD [
    pool: BufferDefs.BufferAccessHandle,
    put: PROCEDURE [BufferDefs.SppBuffer],
    get: PROCEDURE RETURNS [BufferDefs.SppBuffer],
    waitForAttention: PROCEDURE RETURNS [BufferDefs.SppBuffer],
    setWaitTime: PROCEDURE [WaitTime],
    findAddresses: PROCEDURE RETURNS [local, remote: SpecialSystem.NetworkAddress],
    getSenderSizeLimit: PROCEDURE RETURNS [CARDINAL],
    returnGetSppDataBuffer: PROCEDURE [BufferDefs.SppBuffer]];

  Byte: TYPE = Environment.Byte;
  bytesPerSequencedPktHeader: CARDINAL =
    OISCPTypes.bytesPerLevel2SppHeader + OISCPTypes.bytesPerPktHeader;
  WaitTime: TYPE = NetworkStream.WaitTime;
  ClassOfService: TYPE = NetworkStream.ClassOfService;
  defaultWaitTime: WaitTime = NetworkStream.defaultWaitTime;
  infiniteWaitTime: READONLY WaitTime;

  State: TYPE = {
    unestablished, activeEstablish, waitEstablish, established, open, terminating,
    suspended};
  SuspendReason: TYPE = NetworkStream.SuspendReason;
  FailureReason: TYPE = NetworkStream.FailureReason;

  -- interface

  -- exported by PacketStreamMgr
  Make: PROCEDURE [
    local, remote: SpecialSystem.NetworkAddress, localConnID, remoteConnID: 
    OISCPTypes.ConnectionID, establishConnection: BOOLEAN, 
    timeout: WaitTime ← defaultWaitTime, classOfService: ClassOfService] 
    RETURNS [Handle];
  Destroy: PROCEDURE [Handle];
  -- these are INLINEs in order to make call Pilot procedure calls similar in style.
  Put: PROCEDURE [psH: Handle, b: BufferDefs.SppBuffer] = INLINE
    BEGIN psH.put[b]; END;

  Get: PROCEDURE [psH: Handle] RETURNS [BufferDefs.SppBuffer] = INLINE
    BEGIN RETURN[psH.get[]]; END;

  WaitForAttention: PROCEDURE [psH: Handle] RETURNS [BufferDefs.SppBuffer] = INLINE
    BEGIN RETURN[psH.waitForAttention[]]; END;

  SetWaitTime: PROCEDURE [psH: Handle, time: WaitTime] = INLINE
    BEGIN psH.setWaitTime[time]; END;

  FindAddresses: PROCEDURE [psH: Handle]
    RETURNS [local, remote: SpecialSystem.NetworkAddress] = INLINE
    BEGIN [local, remote] ← psH.findAddresses[]; END;

  GetSendSppBuffer: PROCEDURE [psH: Handle] RETURNS [BufferDefs.SppBuffer] = INLINE {
    RETURN[LOOPHOLE[BufferDefs.GetFreeBuffer[oisSpp, psH.pool, send], BufferDefs.SppBuffer]]};

  GetSenderSizeLimit: PROCEDURE [psH: Handle] RETURNS [CARDINAL] = INLINE
    BEGIN RETURN[psH.getSenderSizeLimit[]]; END;

  ReturnGetSppDataBuffer: PROCEDURE [psH: Handle, b: BufferDefs.SppBuffer] = INLINE
    BEGIN psH.returnGetSppDataBuffer[b]; END;
  -- connection table routines

  InsertIntoConnectionTable: PROCEDURE [
    remote: SpecialSystem.NetworkAddress, remoteConnID: OISCPTypes.ConnectionID];
  RemoveFromConnectionTable: PROCEDURE [
    remote: SpecialSystem.NetworkAddress, remoteConnID: OISCPTypes.ConnectionID];
  ConnectionAlreadyThere: PROCEDURE [
    remote: SpecialSystem.NetworkAddress, remoteConnID: OISCPTypes.ConnectionID] RETURNS [BOOLEAN];
  -- errors and signals
  ConnectionSuspended: ERROR [why: SuspendReason];
  ConnectionFailed: SIGNAL [why: FailureReason];

  END.

LOG

Time: May 9, 1978  12:03 PM  By: Dalal  Action: created file.
Time: January 26, 1980  1:52 PM  By: Dalal  Action: replaced SPPInternal.
Time: BLyon on: April 14, 1980  6:11 PM  By: BLyon  Action: Uses new level1 and queue level stuff.
Time: Garlick on: January 23, 1981  1:49 PM  By: BLyon  Action: Added type for ClassOfService, added infiniteWaitTime, added classOfService param and defaulted Make procedure, and removed ERROR AttentionTimeout.