DIRECTORY Arpa USING [Address, Net], Basics USING [DoubleAnd, DoubleNot, DoubleOr] ; ArpaExtras: CEDAR DEFINITIONS IMPORTS Basics ~ { Address: TYPE ~ Arpa.Address; broadcastAddress: Address = [255, 255, 255, 255]; Class: TYPE ~ Arpa.Net; -- Net was poor name choice; don't use it! NetClass: PROC [address: Address] RETURNS [Class]; NetMask: PROC [address: Address] RETURNS [Address]; SubnetAndHostNumber: PROC [address: Address] RETURNS [Address]; IsSpecificNet: PROC [address: Address] RETURNS [BOOL] ~ INLINE { RETURN[SELECT address.a FROM 0 => FALSE, >=224 => FALSE, ENDCASE => TRUE] }; NetAndSubnetMask: PROC [address: Address] RETURNS [Address]; NetAndSubnetNumber: PROC [address: Address] RETURNS [Address] ~ INLINE { RETURN[LOOPHOLE[Basics.DoubleAnd[LOOPHOLE[address], LOOPHOLE[NetAndSubnetMask[address]]]]] }; HostNumber: PROC [address: Address] RETURNS [Address] ~ INLINE { RETURN[LOOPHOLE[Basics.DoubleAnd[LOOPHOLE[address], Basics.DoubleNot[LOOPHOLE[NetAndSubnetMask[address]]]]]] }; IsBroadcast: PROC [address: Address] RETURNS [BOOL] ~ INLINE { RETURN[(LOOPHOLE[Basics.DoubleOr[LOOPHOLE[address], LOOPHOLE[NetAndSubnetMask[address]]], Address] = broadcastAddress)] }; IsMyAddress: PROC [address: Address] RETURNS [BOOL]; NetAndSubnetNumberWithMask: PROC [address: Address, mask: Address] RETURNS [Address] ~ INLINE { RETURN [LOOPHOLE[Basics.DoubleAnd[LOOPHOLE[address], LOOPHOLE[mask]]]] }; HostNumberWithMask: PROC [address: Address, mask: Address] RETURNS [Address] ~ INLINE { RETURN [LOOPHOLE[Basics.DoubleAnd[LOOPHOLE[address], Basics.DoubleNot[LOOPHOLE[mask]]]]] }; IsBroadcastWithMask: PROC [address: Address, mask: Address] RETURNS [BOOL] ~ INLINE { RETURN [ (LOOPHOLE[Basics.DoubleOr[LOOPHOLE[address], LOOPHOLE[mask]], Address] = broadcastAddress) ]; }; BroadcastAddressOnSubnetWithMask: PROC [address: Address, mask: Address] RETURNS [Address] ~ INLINE { RETURN [ LOOPHOLE[Basics.DoubleOr[LOOPHOLE[address], Basics.DoubleNot[LOOPHOLE[mask]]], Address] ]; }; AddressAnd: PROC [address: Address, mask: Address] RETURNS [Address] ~ INLINE { RETURN[LOOPHOLE[Basics.DoubleAnd[LOOPHOLE[address], LOOPHOLE[mask]]]] }; AddressOr: PROC [address: Address, mask: Address] RETURNS [Address] ~ INLINE { RETURN[LOOPHOLE[Basics.DoubleOr[LOOPHOLE[address], LOOPHOLE[mask]]]] }; MaskNot: PROC [address: Address] RETURNS [Address] ~ INLINE { RETURN[LOOPHOLE[Basics.DoubleNot[LOOPHOLE[address]]]] }; MyAddress: PROC RETURNS [Address]; MyAddresses: PROC RETURNS [LIST OF Address]; }... vArpaExtras.mesa Demers, August 26, 1987 4:11:03 pm PDT This stuff should be folded into Arpa.mesa at the next opportunity. Address Manipulations BEWARE: nullAddress looks like a class A net, and broadcastAddress looks like a class C net. Use IsSpecificNet[address] if this matters to you. Generic ones NetNumber: PROC [address: Address] RETURNS [Address]; (in Arpa.mesa) Quick test that net is not unknown (net 0) or broadcast. Note the address may be a broadcast address on some specific net. Expensive ones  check subnet masks of all connected interfaces (hence not all that expensive unless there are several connected interfaces). Cheap ones  subnet-specific Utilities  for rolling your own This machine Return an address for this machine. May return nullAddress if no address is known. Return all known addresses for this machine. Return NIL if no address is known. ΚΆ˜code™K™&K™K™CK™—šΟk ˜ Kšœœ˜Kšœœ!˜-K˜K˜—šΟn œœ ˜Kšœ˜Kšœ˜K˜Kšœ œ˜Kšœ1˜1K˜head™Iblockšœ™™ Kšœœ Οc*˜BK˜Kšžœœœ ˜2K˜Kšžœœœ ˜3K˜Kšž œœœ™DK™Kšžœœœ ˜?K˜š ž œœœœœ˜@K™{Kšœœ œœ œœœ˜JK˜——šœOΟeœ:™Kšžœœœ ˜Kšœœœ œ>˜z—K˜Kšž œœœœ˜4—™šžœœ#œ œ˜_Kšœœœ œ ˜I—K˜šžœœ#œ œ˜WKšœœœœ ˜[K˜—šžœœ#œœ˜Jšœœœ˜Kšœœœ œ%˜ZK˜—K˜K˜—šž œœ#œ ˜Zšœœœ˜Kšœœœ˜WK˜—K˜——™ šž œœ#œ œ˜OKšœœœ œ ˜HK˜—šž œœ#œ œ˜NKšœœœ œ ˜GK˜—šžœœœ œ˜=Kšœœœ˜8———™ šž œœœ ˜"K™#K™.K˜—š ž œœœœœ ˜,K™,K™"—K˜—K˜——…— Ξϊ