-- File: PupTypes.Mesa,  Last Edit: HGM  December 6, 1980  3:52 PM

PupTypes: DEFINITIONS =
  BEGIN

  Byte: TYPE = [0..377B];
  Pair: TYPE = MACHINE DEPENDENT RECORD [a, b: CARDINAL];

  PupHostID: TYPE = RECORD [Byte];
  PupNetID: TYPE = RECORD [Byte];
  PupSocketID: TYPE = RECORD [a, b: WORD];

  PupAddress: TYPE = MACHINE DEPENDENT RECORD [
    net: PupNetID, host: PupHostID, socket: PupSocketID];

  -- Addressing Constants
  fillInNetID: PupNetID = [377B];
  fillInHostID: PupHostID = [377B];
  fillInSocketID: PupSocketID = [0, 0];
  fillInPupAddress: PupAddress = [fillInNetID, fillInHostID, fillInSocketID];
  allNets: PupNetID = [0]; -- host must be allHosts too
  allHosts: PupHostID = [0]; -- can be directed to a specific network

  -- Buffer size Constants
  maxDataWordsPerGatewayPup: CARDINAL = 266;
  maxDataBytesPerGatewayPup: CARDINAL = 2*maxDataWordsPerGatewayPup;
  maxDataWordsPerRoutingPup: CARDINAL = 64;
  maxDataBytesPerRoutingPup: CARDINAL = 2*maxDataWordsPerRoutingPup;


  -- Well Known Sockets:  See [MAXC]<System>Pup-Network.txt
  telnetSoc: PupSocketID = [0, 1];
  gatewaySoc: PupSocketID = [0, 2];
  ftpSoc: PupSocketID = [0, 3];
  miscSrvSoc: PupSocketID = [0, 4];
  echoSoc: PupSocketID = [0, 5];
  bspTestSoc: PupSocketID = [0, 6];
  mailSoc: PupSocketID = [0, 7];
  eftpReceiveSoc: PupSocketID = [0, 20B];
  spruceStatusSoc: PupSocketID = [0, 21B];
  statSoc: PupSocketID = [0, 22B];
  oldCopyDiskSoc: PupSocketID = [0, 24B];
  copyDiskSoc: PupSocketID = [0, 25B];
  eventReportSoc: PupSocketID = [0, 30B];
  printerReportSoc: PupSocketID = [0, 31B];
  juniperpackConversionSoc: PupSocketID = [0, 34B];
  juniperEventSoc: PupSocketID = [0, 35B];
  rpcpSoc: PupSocketID = [0, 36B];
  clearinghouseSoc: PupSocketID = [0, 37B];
  librarianSoc: PupSocketID = [0, 41B];
  pineSoc: PupSocketID = [0, 100B];

  PupErrorCode: TYPE = MACHINE DEPENDENT{
    -- Pup got to the destination machine, but wasn't processed
    badChecksumPupErrorCode(1B), noProcessPupErrorCode(2B),
    resourceLimitsPupErrorCode(3B),
    -- Pup didn't get to the destination machine
    inconsistentPupErrorCode(1001B), cantGetTherePupErrorCode(1002B),
    hostDownPupErrorCode(1003B), eightHopsPupErrorCode(1004B),
    tooBigPupErrorCode(1005B), iAmNotAGatewayPupErrorCode(518),
    gatewayResourceLimitsPupErrorCode(519),

    -- used by ForwardBuffer for various hacks
    noErrorPupErrorCode(10000), connectionLimitPupErrorCode(10001),

    filler(LAST[WORD])};

  -- This is an attempt to get the TYPE checker to help us.
  -- Unfortunately, the values are a bit sparce.
  -- Be sure to have enough values to make it an 8 bit field.

  PupType: TYPE = MACHINE DEPENDENT{

    -- 000-077 OCTAL!	Registered Pup Types
    echoMe(1B), iAmEcho, badEcho, error(4B), rfc(10B), abort, end, endRep,
    data(20B), aData, ack, mark, int, intRep, aMark, eData(30B), eAck, eEnd,
    eAbort, rpp(40B),

    -- 200+		Unregistered Pup Types
    -- Socket 2 - Gateway info
    gatewayRequest(200B), gatewayInfo(201B),

    -- Socket 4 - Misc services
    dateTenexRequest(202B), dateTenexIs, dateAltoRequest(206B), dateAltoIs,

    mailCheck(210B), mailIsNew, mailNotNew, mailError, mailCheckLaurel,
    nameLookup(220B), nameIs, nameError, addressLookup, addressIs,
    whereIsUser(230B), userIs, userError, netDirVersion(240B), sendNetDir,
    bootFileSend(244B), kissOfDeath(247B),

    -- Pine  (save a few spares too)
    request(250B), result, unsolicited, custodian, sync, pineAck, noop,

    bootDirReq(257B), bootDirReply(260B),

    last(LAST[Byte])};



  -- see <PUP>Servers.EARS (Taft)

  -- Socket 4 Misc Services - these overlap with Gateway info
  dateTextRequest: PupType = gatewayRequest;
  dateTextIs: PupType = gatewayInfo;

  -- Socket 4 Misc Services - these overlap with Pine
  userAuthReq: PupType = request; -- 250
  userAuthOk: PupType = result; -- 251
  userAuthBad: PupType = unsolicited; -- 252

  -- Socket 22 Statistics - more overlap
  statisticsRequest: PupType = gatewayRequest;
  statisticsAre: PupType = gatewayInfo;

  -- Socket 30 Event Report - more overlap
  eventReport: PupType = netDirVersion;
  eventReportReply: PupType = sendNetDir;

  END.