DIRECTORY Arpa USING [Address, NetNumber, nullAddress], ArpaTranslation USING [NetAndSubnetMask, NetAndSubnetMaskObject], Basics USING [HighByte, LowByte], CommDriver USING [Network], ConvertExtras USING [ArpaAddressFromRope, RopeFromArpaAddress], EditedStream USING [Create, Rubout], IO USING [GetLineRope, PutRope, STREAM], Rope USING [ROPE, SkipOver, Substr], SimpleTerminal USING [TurnOff, TurnOn] ; ArpaTranslationImpl: CEDAR MONITOR IMPORTS Arpa, Basics, ConvertExtras, EditedStream, IO, Rope, SimpleTerminal EXPORTS ArpaTranslation ~ { Address: TYPE ~ Arpa.Address; Network: TYPE ~ CommDriver.Network; xeroxSubnetMask: Arpa.Address ~ [0FFH, 0FFH, 0FCH, 000H]; xeroxClassANetworkNumber: BYTE ~ 13; alwaysAskUser: BOOL _ FALSE; -- DEBUG DetermineAddressAndSubnetMaskForInterface: PUBLIC PROC [n: Network] RETURNS [ok: BOOL _ FALSE] ~ { p: ArpaTranslation.NetAndSubnetMask _ NEW[ArpaTranslation.NetAndSubnetMaskObject]; n.arpa.translation _ p; IF NOT alwaysAskUser THEN { SELECT n.type FROM ethernet => ok _ DoEthernet[n, p]; ethernetOne => ok _ DoEthernetOne[n, p]; ENDCASE; }; IF NOT ok THEN ok _ DoByAskingUser[n, p] }; DoEthernetOne: PROC [n: Network, p: ArpaTranslation.NetAndSubnetMask] RETURNS [ok: BOOL] ~ { RETURN[DoByMappingPupNet[n, p]]; }; DoEthernet: PROC [n: Network, p: ArpaTranslation.NetAndSubnetMask] RETURNS [ok: BOOL] ~ { RETURN[DoByMappingPupNet[n, p]]; }; DoByMappingPupNet: PROC [n: Network, p: ArpaTranslation.NetAndSubnetMask] RETURNS [ok: BOOL] ~ { arpaAddress, mask: Address; temp: CARD16; IF (temp _ 4*CARD16[n.pup.net]) = 0 THEN RETURN[ok~FALSE]; SELECT n.pup.net FROM 3B, 64B => { -- CONNECTATHON ONLY - this should be in ENDCASE! arpaAddress _ [xeroxClassANetworkNumber, Basics.HighByte[temp], Basics.LowByte[temp], n.pup.host]; mask _ xeroxSubnetMask; }; 44B => { arpaAddress _ [1, 0, 1, n.pup.host]; mask _ [255, 255, 255, 0]; }; ENDCASE => RETURN[ok~FALSE]; n.arpa.host _ arpaAddress; p.net _ Arpa.NetNumber[arpaAddress]; p.subnetMask _ mask; RETURN[ok~TRUE]; }; DoByAskingUser: ENTRY PROC [n: Network, p: ArpaTranslation.NetAndSubnetMask] RETURNS [ok: BOOL _ TRUE] ~ { in, out: IO.STREAM; GetAddressFromUser: PROC [msg: Rope.ROPE, eg: Address] RETURNS [ans: Address] ~ { r: Rope.ROPE _ NIL; IO.PutRope[out, msg]; IO.PutRope[out, " (e.g. "]; IO.PutRope[out, ConvertExtras.RopeFromArpaAddress[eg]]; IO.PutRope[out, "): "]; r _ IO.GetLineRope[in ! EditedStream.Rubout => CONTINUE]; -- r = NIL gives nullAddress r _ Rope.Substr[r, Rope.SkipOver[r, 0, " "]]; ans _ ConvertExtras.ArpaAddressFromRope[r]; }; [in, out] _ SimpleTerminal.TurnOn["Arpa Address Determination"]; in _ EditedStream.Create[in, out]; DO ENABLE ABORTED => { IO.PutRope[out, "XXX"]; LOOP }; address, subnetMask: Address; thisHost: BYTE ~ IF n # NIL THEN n.pup.host ELSE 0; address _ GetAddressFromUser["Enter ARPA address", [0, 0, 0, thisHost]]; IF address = Arpa.nullAddress THEN { IO.PutRope[out, "???\n"]; LOOP }; subnetMask _ GetAddressFromUser["Enter subnet mask", xeroxSubnetMask]; IF subnetMask = Arpa.nullAddress THEN { IO.PutRope[out, "???\n"]; LOOP }; IF n # NIL THEN n.arpa.host _ address; IF p # NIL THEN { p.net _ Arpa.NetNumber[address]; p.subnetMask _ subnetMask }; EXIT; ENDLOOP; SimpleTerminal.TurnOff[]; }; }... ØArpaTranslationImpl.mesa Demers, January 9, 1988 10:35:20 am PST A crude temporary hack for filling in Arpa host numbers and subnet masks. This has a compiled-in list of known hosts/networks. This looks stupid, since the two algorithms below are exactly the same Hope that PUP has installed itself and knows its host/net number. Simple algorithm: 8 bit network number = 13 (decimal) 14-bit subnet number = pup network number 10-bit host number = pup host number Êì˜code™K™'K™K™K™—šÏk ˜ Kšœœ#˜-Kšœœ,˜AKšœœ˜!Kšœ œ ˜Kšœœ,˜?Kšœ œ˜$Kšœœœ˜(Kšœœœ˜$Kšœœ˜&K˜K˜—šÏnœœ˜"Kšœ,œ˜KKšœ˜K˜K˜Kšœ œ˜Kšœ œ˜#K˜Kšœ9˜9Kšœœ˜$K˜KšœœœÏc˜%K˜š ž)œœœœœœ˜bKšœ&œ)˜RKšœ˜šœœœ˜šœ˜K™FK˜"Kšœ(˜(Kšœ˜—K˜—Kšœœœ˜(K˜K˜—šž œœ3œœ˜\Jšœ˜ K˜K˜—šž œœ3œœ˜YJšœ˜ K˜K˜—šžœœ3œœ˜`K™A™K™#K™)K™$—K˜Kšœœ˜ Kš œ œœœœ˜:šœ ˜šœ Ÿ1˜>Kšœb˜bKšœ˜K˜—šœ˜Kšœ$˜$K˜K˜—Kšœœœ˜—K˜Kšœ$˜$Kšœ˜Jšœœ˜K˜K˜—š žœ œ3œœœ˜jKšœ œœ˜šžœœ œœ˜QKšœœœ˜Kšœ˜Kšœ˜Kšœ5˜7Kšœ˜Kšœœ)œŸ˜VK˜-Kšœ+˜+K˜—K˜@K˜"š˜Kšœœœœ˜3K˜Kš œ œœœœ œ˜3KšœH˜HKšœœœœ˜FKšœF˜FKšœœœœ˜IKšœœœ˜&Kšœœœ@˜OKšœ˜Kšœ˜—K˜K˜K˜—K˜—J˜—…— ®r