-- File: ArpaPortInternal.mesa - last edit:
-- JAV                 12-Nov-87 14:43:02
-- AOF                  9-Mar-87 20:05:45
-- SMA                 17-Feb-86 14:56:24
-- Copyright (C) 1985, 1986, 1987 by Xerox Corporation. All rights reserved.

DIRECTORY
  ArpaRouter USING [InternetAddress],
  ESCAlpha USING [aDAND, aDXOR],
  Inline USING [BITNOT],
  Mopcodes USING [zACD, zADD, zESC, zIOR],
  ArpaBuffer USING [Buffer];

ArpaPortInternal: DEFINITIONS
  IMPORTS Inline =
  BEGIN
  
  Checksum: PROC[cs: CARDINAL ← 0, nWords: CARDINAL, p: LONG POINTER]
    RETURNS [checksum: CARDINAL] = INLINE {
    OPEN Mopcodes;
    Push: PROC [CARDINAL] = MACHINE CODE BEGIN END;
    Pop: PROC RETURNS [CARDINAL] = MACHINE CODE BEGIN END;
    OnesAdd: PROC [
      --cs: CARDINAL,-- wd: CARDINAL, zero1: CARDINAL ← 0]
      --RETURNS [cs: CARDINAL]-- = MACHINE CODE {zACD; zADD};
    Push[cs];
    THROUGH [0..nWords) DO OnesAdd[wd: p↑]; p ← p + 1; ENDLOOP;
    RETURN Inline.BITNOT[Pop[]]};

  AddrMismatch: PROC[mask, test, target: ArpaRouter.InternetAddress]
    RETURNS[BOOLEAN] = INLINE {RETURN[zCompare[mask, test, target] # 0]}; 
     
  AddrMatch: PROC [mask, test, target: ArpaRouter.InternetAddress]
    RETURNS[BOOLEAN] = INLINE {RETURN[zCompare[mask, test, target] = 0]};

  zCompare: PROC[mask, test, target: ArpaRouter.InternetAddress]
    RETURNS[CARDINAL] = MACHINE CODE  --returns 0 iff they match.
    {Mopcodes.zESC, ESCAlpha.aDXOR;
     Mopcodes.zESC, ESCAlpha.aDAND;
     Mopcodes.zIOR};
     
  DestType: TYPE = {local, remote};   --Destined for local host or someone else.
  
  BuildMasks: PROC [addr: ArpaRouter.InternetAddress]
    RETURNS [hostMask, netMask: ArpaRouter.InternetAddress];
    
  SendPacket: PROC [b: ArpaBuffer.Buffer, destType: DestType];
    
  QueueForClient: PROC [b: ArpaBuffer.Buffer, copy: BOOLEAN] RETURNS [BOOLEAN];
  
  InitUniquePort: PROC;
  
  GetMyNullAddr: PROC RETURNS [ArpaRouter.InternetAddress];
  GetMyBroadcastAddr: PROC RETURNS [ArpaRouter.InternetAddress];
  GetArpaAddr: PROC RETURNS [ArpaRouter.InternetAddress];
  GetGatewayAddr: PROC RETURNS [ArpaRouter.InternetAddress];
  GetDomainNameServer: PROC RETURNS [ArpaRouter.InternetAddress]; 
  GetSubnetMask: PROC RETURNS[ArpaRouter.InternetAddress];
  
  SetGatewayAddr: PROC [addr: ArpaRouter.InternetAddress];
  SetDomainNameServer: PROC [addr: ArpaRouter.InternetAddress];

  END.

LOG

ALD/ISI dd-mmm-yy hh:mm:ss  added GetDomainNameServer
AOF   9-Mar-87 20:04:34  Funston changes
JAV   15-Jun-87 11:11:41  Added SetGatewayAddr & SetDomainNameServer