DIRECTORY Basics32 USING [BITAND, BITNOT, BITOR] ; Arpa: CEDAR DEFINITIONS IMPORTS Basics32 = BEGIN Address: TYPE = PACKED RECORD [a, b, c, d: BYTE]; nullAddress: Address = [0, 0, 0, 0]; broadcastAddress: Address = [255, 255, 255, 255]; Net: TYPE = {a, b, c}; netMasks: ARRAY Net OF Address = [ a: [0FF, 0, 0, 0], b: [0FF, 0FFH, 0, 0], c: [0FF, 0FFH, 0FFH, 0] ]; NetType: PROC [address: Address] RETURNS [Net]; NetNumber: PROC [address: Address] RETURNS [Address]; 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[Basics32.BITAND[LOOPHOLE[address], LOOPHOLE[NetAndSubnetMask[address]]]]] }; HostNumber: PROC [address: Address] RETURNS [Address] ~ INLINE { RETURN[LOOPHOLE[Basics32.BITAND[LOOPHOLE[address], Basics32.BITNOT[LOOPHOLE[NetAndSubnetMask[address]]]]]] }; IsBroadcast: PROC [address: Address] RETURNS [BOOL] ~ INLINE { RETURN[(LOOPHOLE[Basics32.BITOR[LOOPHOLE[address], LOOPHOLE[NetAndSubnetMask[address]]], Address] = broadcastAddress)] }; IsMyAddress: PROC [address: Address] RETURNS [BOOL]; NetAndSubnetNumberWithMask: PROC [address: Address, mask: Address] RETURNS [Address] ~ INLINE { RETURN [LOOPHOLE[Basics32.BITAND[LOOPHOLE[address], LOOPHOLE[mask]]]] }; HostNumberWithMask: PROC [address: Address, mask: Address] RETURNS [Address] ~ INLINE { RETURN [LOOPHOLE[Basics32.BITAND[LOOPHOLE[address], Basics32.BITNOT[LOOPHOLE[mask]]]]] }; IsBroadcastWithMask: PROC [address: Address, mask: Address] RETURNS [BOOL] ~ INLINE { RETURN [ (LOOPHOLE[Basics32.BITOR[LOOPHOLE[address], LOOPHOLE[mask]], Address] = broadcastAddress) ]; }; BroadcastAddressOnSubnetWithMask: PROC [address: Address, mask: Address] RETURNS [Address] ~ INLINE { RETURN [ LOOPHOLE[Basics32.BITOR[LOOPHOLE[address], Basics32.BITNOT[LOOPHOLE[mask]]], Address] ]; }; AddressAnd: PROC [address: Address, mask: Address] RETURNS [Address] ~ INLINE { RETURN[LOOPHOLE[Basics32.BITAND[LOOPHOLE[address], LOOPHOLE[mask]]]] }; AddressOr: PROC [address: Address, mask: Address] RETURNS [Address] ~ INLINE { RETURN[LOOPHOLE[Basics32.BITOR[LOOPHOLE[address], LOOPHOLE[mask]]]] }; MaskNot: PROC [address: Address] RETURNS [Address] ~ INLINE { RETURN[LOOPHOLE[Basics32.BITNOT[LOOPHOLE[address]]]] }; MyAddress: PROC RETURNS [Address]; MyAddresses: PROC RETURNS [LIST OF Address]; END. Θ Arpa.mesa Copyright Σ 1986, 1991 by Xerox Corporation. All rights reserved. Hal Murray, April 5, 1986 4:22:42 pm PST Doug Wyatt, December 11, 1986 11:52:44 am PST JKF October 25, 1988 4:50:45 pm PDT Arpa IP (Internet Protocol) Addresses are a combination of net and host numbers. There are 3 cases. If the first bit is a 0, the next 7 are a type A net number, and the remaining 24 are the host number within that net. If the first two bits are 10, the next 14 are a type B net number, and the remaining 16 are the host number within that net. If the first two bits are 11, the next 22 are a type C net number, and the remaining 8 are the host number within that net. Willie-s, August 13, 1991 4:04 pm PDT Addressing 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. Κ―•NewlineDelimiter –(cedarcode) style™codešœ ™ Kšœ Οeœ7™BK™(K™-K™#K™K™cK™vK™|K™{K™%K™—šΟk ˜ Kš œ žœžœžœžœ˜&K˜K˜—šΠlnœžœž ˜Kšžœ ˜Kšœž˜—head™ Kšœ žœž œžœ˜1K˜K˜$Kšœ1˜1K˜Kšœžœ ˜šœ žœžœ ˜"Kšœ˜Kšœ˜Kšœ˜Kšœ˜—K˜KšΟnœžœžœ˜/Kš  œžœžœ ˜5K˜—™Iblockšœ™™ Kšœžœ Οc*˜BK˜Kš œžœžœ ˜2K˜Kš œžœžœ ˜3K˜Kš  œžœžœ™DK™Kš œžœžœ ˜?K˜š   œžœžœžœžœ˜@K™{Kšžœžœ žœžœ žœžœžœ˜JK˜——šœOœ:™Kš œžœžœ ˜Kš žœžœ žœžœ žœ>˜y—K˜Kš  œžœžœžœ˜4—™š œžœ#žœ žœ˜_Kš žœžœ žœžœ žœ ˜H—K˜š œžœ#žœ žœ˜WKš žœžœ žœžœžœžœ ˜YK˜—š œžœ#žœžœ˜Jšœžœžœ˜Kš œžœ žœžœ žœ%˜YK˜—K˜K˜—š  œžœ#žœ ˜Zšœžœžœ˜Kš žœ žœžœžœžœ˜UK˜—K˜——™ š  œžœ#žœ žœ˜OKš žœžœ žœžœ žœ ˜GK˜—š  œžœ#žœ žœ˜NKš žœžœ žœžœ žœ ˜FK˜—š œžœžœ žœ˜=Kšžœžœ žœžœ˜7———™ š  œžœžœ ˜"K™#K™.K˜—š   œžœžœžœžœ ˜,K™,K™"—K˜K˜—Kšžœ˜—…— Ύ5