<> <> <<>> DIRECTORY Arpa USING [Address, Net, netMasks, nullAddress], ArpaExtras USING [AddressAnd, broadcastAddress, MaskNot], ArpaTranslation USING [GetNet, GetSubnetMask], CommDriver USING [GetNetworkChain, Network] ; ArpaImpl: CEDAR PROGRAM IMPORTS ArpaExtras, ArpaTranslation, CommDriver EXPORTS Arpa, ArpaExtras ~ { Address: TYPE ~ Arpa.Address; Class: TYPE ~ Arpa.Net; broadcastAddress: Address ~ ArpaExtras.broadcastAddress; nullAddress: Address ~ Arpa.nullAddress; NetClassInner: PROC [address: Address] RETURNS [Class] ~ INLINE { RETURN[SELECT address.a FROM < 080H => a, < 0C0H => b, ENDCASE => c] }; NetType, NetClass: PUBLIC PROC [address: Address] RETURNS [Class] ~ { RETURN[NetClassInner[address]] }; NetMask: PUBLIC PROC [address: Address] RETURNS [Address] ~ { RETURN[SELECT address.a FROM < 080H => Arpa.netMasks[a], < 0C0H => Arpa.netMasks[b], ENDCASE => Arpa.netMasks[c] ]; }; NetNumber: PUBLIC PROC [address: Address] RETURNS [Address] ~ { RETURN[SELECT address.a FROM < 080H => ArpaExtras.AddressAnd[address, Arpa.netMasks[a]], < 0C0H => ArpaExtras.AddressAnd[address, Arpa.netMasks[b]], ENDCASE => ArpaExtras.AddressAnd[address, Arpa.netMasks[c]] ]; }; SubnetAndHostNumber: PUBLIC PROC [address: Address] RETURNS [Address] ~ { RETURN[ ArpaExtras.AddressAnd[address, ArpaExtras.MaskNot[NetMask[address]]] ]; }; NetAndSubnetMask: PUBLIC PROC [address: Address] RETURNS [Address] ~ { net: Address _ NetNumber[address]; FOR n: CommDriver.Network _ CommDriver.GetNetworkChain[], n.next WHILE n # NIL DO IF n.arpa.host = nullAddress THEN LOOP; -- avoid NIL fault in GetNet below IF ArpaTranslation.GetNet[n] = net THEN RETURN [ArpaTranslation.GetSubnetMask[n]]; ENDLOOP; RETURN [NetMask[address]]; }; IsMyAddress: PUBLIC PROC [address: Address] RETURNS [BOOL] ~ { IF address # Arpa.nullAddress THEN { FOR n: CommDriver.Network _ CommDriver.GetNetworkChain[], n.next WHILE n # NIL DO IF n.arpa.host = address THEN RETURN [TRUE]; ENDLOOP; }; RETURN [FALSE]; }; MyAddress: PUBLIC PROC RETURNS [Address _ nullAddress] ~ { FOR n: CommDriver.Network _ CommDriver.GetNetworkChain[], n.next WHILE n # NIL DO IF n.arpa.host # nullAddress THEN RETURN [n.arpa.host]; ENDLOOP; }; MyAddresses: PUBLIC PROC RETURNS [addresses: LIST OF Address] ~ { GetOne: PROC [n: CommDriver.Network] RETURNS [list: LIST OF Address] ~ { IF n = NIL THEN RETURN [NIL]; list _ GetOne[n.next]; IF n.arpa.host # nullAddress THEN list _ CONS[n.arpa.host, list]; }; RETURN[GetOne[CommDriver.GetNetworkChain[]]]; }; }...