-- File: GCPrint.mesa, HGM August 19, 1978 7:10 PM -- Last Modified by Ly September 20, 1978 11:44 AM DIRECTORY GCDefs: FROM "GCDefs" USING [GCInterface], IODefs: FROM "IODefs" USING [ CR, ReadChar, WriteChar, WriteString, WriteLine, WriteOctal, WriteNumber], PupRouterDefs: FROM "PupRouterDefs" USING [ PupRoutingTableEntry, GetPupRoutingTable, PupGateInfo], DriverDefs: FROM "DriverDefs" USING [Network], PupDefs: FROM "PupDefs", PupTypes: FROM "PupTypes" USING [fillInSocketID, gatewaySoc]; GCPrint: PROGRAM [gc: GCDefs.GCInterface] IMPORTS GCDefs, IODefs, PupRouterDefs, PupDefs EXPORTS GCDefs = BEGIN OPEN gc, GCDefs, IODefs, PupDefs; GCPrintThings: PUBLIC PROCEDURE = BEGIN WriteString["Print "L]; SELECT ReadChar[] FROM 'L, 'l => BEGIN WriteLine["Local routing table."L]; LocalRoutingTable[]; END; 'R, 'r => BEGIN WriteString["Remote routing table from: "L]; RemoteRoutingTable[]; END; '? => WriteLine["L(ocal routing table), or R(emote routing table)."L]; ENDCASE => WriteLine["???"L]; END; LocalRoutingTable: PROCEDURE = BEGIN pupRt: DESCRIPTOR FOR ARRAY OF PupRouterDefs.PupRoutingTableEntry; pupRte: POINTER TO PupRouterDefs.PupRoutingTableEntry; network: DriverDefs.Network; i, k: CARDINAL; pupRt _ PupRouterDefs.GetPupRoutingTable[]; WriteChar[CR]; WriteLine["Local Routing Table:"L]; WriteLine["| Net Via Hops | Net Via Hops | Net Via Hops |"L]; WriteLine["|-------------------|-------------------|-------------------|"L]; k _ 0; FOR i IN [0..LENGTH[pupRt]) DO pupRte _ @pupRt[i]; network _ pupRte.network; IF network=NIL THEN LOOP; IF k=0 THEN WriteChar['|]; O4[i]; O4[network.netNumber]; WriteChar['#]; IF pupRte.hop#0 THEN O3Z[pupRte.route] ELSE O3Z[network.hostNumber]; WriteChar['#]; O4[pupRte.hop]; WriteString[" |"L]; IF (k_k+1)=3 THEN BEGIN WriteChar[CR]; k_0; END; ENDLOOP; IF k#0 THEN WriteChar[CR]; END; RemoteRoutingTable: PROCEDURE = BEGIN soc: PupSocket; b: PupBuffer; address: PupAddress _ [gc.remHost.net, gc.remHost.host, PupTypes.gatewaySoc]; PrintPupAddress[@address]; WriteChar[CR]; soc _ PupSocketMake[PupTypes.fillInSocketID,address,SecondsToTocks[2]]; THROUGH [0..2) DO -- try a few times b _ GetFreePupBuffer[]; b.pupType _ gatewayRequest; SetPupContentsBytes[b,0]; b.pupID _ [0,0]; soc.put[b]; b _ soc.get[]; -- 2 sec wait IF b#NIL THEN BEGIN WriteString["Reply from: "L]; PrintPupAddress[@b.source]; WriteChar[CR]; SELECT b.pupType FROM gatewayInfo => BEGIN length: CARDINAL = GetPupContentsBytes[b]; data: POINTER TO PupRouterDefs.PupGateInfo _ LOOPHOLE[@b.pupWords]; i, k, n: CARDINAL; n _ length/(2*SIZE[PupRouterDefs.PupGateInfo]); IF (length MOD (2*SIZE[PupRouterDefs.PupGateInfo]))#0 THEN WriteLine["***** Funny Length *****"L]; WriteLine["| Net Via Hops | Net Via Hops | Net Via Hops |"L]; WriteLine["|-------------------|-------------------|-------------------|"L]; k _ 0; FOR i IN [0..n) DO IF k=0 THEN WriteChar['|]; O4[data.net]; O4[data.viaNet]; WriteChar['#]; O3Z[data.viaHost]; WriteChar['#]; O4[data.hop]; WriteString[" |"L]; IF (k_k+1)=3 THEN BEGIN WriteChar[CR]; k_0; END; data _ data+SIZE[PupRouterDefs.PupGateInfo]; ENDLOOP; IF k#0 THEN WriteChar[CR]; END; ENDCASE => PrintErrorPup[b]; ReturnFreePupBuffer[b]; EXIT; END ELSE WriteLine["No Response that try."L]; ENDLOOP; PupSocketDestroy[soc]; EXITS Error => NULL; Reject => WriteLine["xxx"L]; END; PrintErrorPup: PUBLIC PROCEDURE [b: PupBuffer] = BEGIN i, len: CARDINAL; WriteChar[CR]; IF b.pupType=error THEN BEGIN WriteString["[Error Pup, code="L]; WriteOctal[b.errorCode]; WriteString["] "L]; len _ GetPupContentsBytes[b]; FOR i IN [0..len-2*(10+1+1)) DO WriteChar[b.errorText[i]]; ENDLOOP; END ELSE BEGIN WriteString["***** Funny PupType = "L]; WriteOctal[b.pupType]; WriteString[" *****"L]; END; WriteChar[CR]; END; PrintPupAddress: PUBLIC PROCEDURE [a: POINTER TO PupAddress] = BEGIN buffer: STRING _ [50]; AppendPupAddress[buffer,a]; WriteString[buffer]; END; O3: PROCEDURE [n: CARDINAL] = BEGIN WriteNumber[n,[8,FALSE,TRUE,4]]; END; O3Z: PROCEDURE [n: CARDINAL] = BEGIN WriteNumber[n,[8,TRUE,TRUE,3]]; END; O4: PROCEDURE [n: CARDINAL] = BEGIN WriteNumber[n,[8,FALSE,TRUE,4]]; END; O6: PROCEDURE [n: CARDINAL] = BEGIN WriteNumber[n,[8,FALSE,TRUE,7]]; END; -- initialization END.(2048)\171t2 8t0 12t2 1t0 486b13B419b17B31t10 24t0 46t10 11t0 186f8 158f0 454b18B993f8 78f0 9f8 78f0 717b13B473b15B142b2B75b3B74b2B75b2B