-- File: ArpaInitImpl.mesa - last edit:
-- AOF                 12-Mar-87 18:38:01
-- JAV                 26-Feb-87 11:20:59

-- Copyright (C) 1987 by Xerox Corporation. All rights reserved.

DIRECTORY
  ArpaAddressTranslationPriv USING [StringToInternetAddressPriv],
  ArpaHostTable USING [ParseHostsFile],
  ArpaInit USING [],
  ArpaRouter USING [],
  ArpaTypes USING [InternetAddress],
  Stream USING [Handle];
  
ArpaInitImpl: PROGRAM
  IMPORTS ArpaAddressTranslationPriv, ArpaHostTable
  EXPORTS ArpaInit, ArpaRouter =
  BEGIN

  InternetAddress: PUBLIC TYPE <<ArpaRouter>> = ArpaTypes.InternetAddress;
  
  unknown: InternetAddress = [0, 0];

  myHostAddr, myGateWayAddr, mySubnetMask, myNameServer: 
    InternetAddress ← unknown;
  
    GetArpaInitInfo: PUBLIC <<ArpaInit>> PROCEDURE RETURNS 
      [hostAddr, gateWayAddr, subnetMask, nameServer: InternetAddress] =
      {RETURN[myHostAddr, myGateWayAddr, mySubnetMask, myNameServer]};
  
  SetArpaInitInfo: PUBLIC <<ArpaInit>> PROCEDURE 
    [hostFileStream: Stream.Handle,
    hostAddr, gateWayAddr, subnetMask, nameServer: LONG STRING]
    RETURNS[BOOLEAN ← TRUE] =
    BEGIN
    myHostAddr ← 
      ArpaAddressTranslationPriv.StringToInternetAddressPriv[hostAddr];
    myGateWayAddr ←
      ArpaAddressTranslationPriv.StringToInternetAddressPriv[gateWayAddr];
    mySubnetMask ← 
      ArpaAddressTranslationPriv.StringToInternetAddressPriv[subnetMask];
    myNameServer ← 
      ArpaAddressTranslationPriv.StringToInternetAddressPriv[nameServer];
    IF hostFileStream # NIL THEN
      RETURN[ArpaHostTable.ParseHostsFile[hostFileStream]];
    END;
    
    
  END.