-- Router.mesa
-- last edited by: BLyon on: January 28, 1981  6:41 PM
-- Function: The internal definitions module for the Pilot OISCP Router.

DIRECTORY
  BufferDefs USING [OisBuffer],
  DriverDefs USING [DriverXmitStatus, Network],
  OISCPTypes USING [OISErrorCode],
  SocketInternal USING [SocketHandle],
  SpecialCommunication USING [RoutersFunction],
  NSAddress USING [HostNumber, NetworkAddress, NetworkNumber];

Router: DEFINITIONS =
  BEGIN

  -- TYPEs and definitions

  SocketTable: TYPE = RECORD [
    length: CARDINAL, first: SocketInternal.SocketHandle];
  Nibble: TYPE = [0..17B];
  RoutingTableEntry: TYPE = REF RoutingTableObject;
  RoutingTableObject: TYPE = RECORD [
    next: RoutingTableEntry,
    destNetwork: NSAddress.NetworkNumber, -- ultimate destination network num.
    delay: Nibble,
    timeUnits: Nibble, -- if zero then this entry is discarded
    route: NSAddress.HostNumber,
    -- if =unknownHostID then the ultimate destination network is local.
    network: DriverDefs.Network]; -- use this network driver to reach route.
  XmitStatus: TYPE = DriverDefs.DriverXmitStatus;

  -- variables
  socketRouterLock: MONITORLOCK; -- lock shared by SocketImpl and RouterImpl.
  primaryMDS: BOOLEAN; -- whether the router is in the primary MDS or not.
  routersFunction: SpecialCommunication.RoutersFunction;
  -- whether the router is an internet router or not.
  checkIt: BOOLEAN; -- whether checksums are on or not.

  -- interface
  -- Procedures from RouterImpl
  OisRouterOn: PROCEDURE;
  OisRouterOff: PROCEDURE;
  AssignOisAddress: PROCEDURE RETURNS [NSAddress.NetworkAddress];
  AssignDestinationRelativeOisAddress: PROCEDURE [NSAddress.NetworkNumber] RETURNS [NSAddress.NetworkAddress];
  AddSocket: PROCEDURE [SocketInternal.SocketHandle];
  RemoveSocket: PROCEDURE [SocketInternal.SocketHandle];
  SendPacket: PROCEDURE [BufferDefs.OisBuffer];
  ReceivePacket: PROCEDURE [BufferDefs.OisBuffer];
  BroadcastThisPacket: PROCEDURE [BufferDefs.OisBuffer];  -- called from a user (like INR)
  SendBroadcastPacket: PROCEDURE [BufferDefs.OisBuffer];  -- called from dispatcher
  SendErrorPacket: PROCEDURE [offendingPkt: BufferDefs.OisBuffer,
    errCode: OISCPTypes.OISErrorCode, errParm: CARDINAL ← 0];  -- sends error pkt back to offender's source; do not call from inside router's lock.
  FindMyHostID: PROCEDURE RETURNS [NSAddress.HostNumber];
  -- debugging
  SetOisCheckit: PROCEDURE [BOOLEAN];
  SetOisStormy: PROCEDURE [BOOLEAN];
  SetOisDriverLoopback: PROCEDURE [BOOLEAN];
  SetOisShowit: PROCEDURE [BOOLEAN];
  InspectOutgoingOiss: PROCEDURE [PROCEDURE [BufferDefs.OisBuffer]];
  InspectIncommingOiss: PROCEDURE [PROCEDURE [BufferDefs.OisBuffer]];
  CaptureErrors: PROCEDURE [PROCEDURE [UNSPECIFIED]];
  EnumerateRoutingTable: PROCEDURE [proc: PROCEDURE [RoutingTableEntry]];
  -- Procedures from RoutingTableImpl
  RoutingTableOn: PROCEDURE;
  RoutingTableOff: PROCEDURE;
  FindDestinationRelativeNetID: PROCEDURE [NSAddress.NetworkNumber] RETURNS [NSAddress.NetworkNumber];
  AddNetwork: PROCEDURE [DriverDefs.Network];
  RemoveNetwork: PROCEDURE [DriverDefs.Network];
  StateChanged: PROCEDURE [DriverDefs.Network];
  FindNetworkAndTransmit: PROCEDURE [BufferDefs.OisBuffer] RETURNS [XmitStatus];
  ForwardPacket: PROCEDURE [BufferDefs.OisBuffer];
  RoutingInformationPacket: PROCEDURE [BufferDefs.OisBuffer];

  END. -- Router

LOG

Time: January 19, 1980  4:01 PM By: Dalal  Action: Created interface.
Time: August 1, 1980  6:51 PM By: BLyon  Action: replaced internetRouter by routersFunction and moved checksums stuff to Checksums Interface.
Time: August 4, 1980  6:51 PM By: BLyon  Action: added destNetwork to RoutingTableEntry and made the routingTable a linked list.
Time: September 13, 1980  6:09 PM By: HGM  Action: added StateChanged.
Time: September 18, 1980  3:31 PM By: BLyon  Action: deleted FindPrimaryNetID.
Time: January 5, 1981  4:00 PM By: BLyon  Action: added EnumerateRoutingTable.