PrintArpaRoutes.mesa
John Larson, November 30, 1987 8:55:05 pm PST
DIRECTORY
Arpa USING[Address],
ArpaRouter,
Convert,
ConvertExtras,
Commander USING[CommandProc, Register],
CommandTool USING[NextArgument],
IO,
Rope;
PrintArpaRoutes: CEDAR PROGRAM
IMPORTS ArpaRouter, Convert, ConvertExtras, Commander, CommandTool, IO, Rope =
BEGIN
docRope: Rope.ROPE ← "Usage: PrintArpaRoutes <low> <high>; low defaults to 0, high defaults to unreachable.";
PAR: Commander.CommandProc = {
printRouteProc: PROC [addr: Arpa.Address, entry: ArpaRouter.RoutingTableEntry] = {
cmd.out.PutF["%-20g%-18g%-7g%-10g\n", IO.rope[ConvertExtras.RopeFromArpaAddress[addr]], IO.rope[ConvertExtras.RopeFromArpaAddress[entry.immediate]], IO.rope[Convert.RopeFromCard[entry.hops]], IO.rope[Convert.RopeFromCard[entry.time]]];
};
low: CARDINAL ← 0;
high: CARDINAL ← ArpaRouter.unreachable;
rope: Rope.ROPE ← CommandTool.NextArgument[cmd];
IF ~Rope.IsEmpty[rope] THEN {
low ← Convert.CardFromRope[rope];
rope ← CommandTool.NextArgument[cmd];
IF ~Rope.IsEmpty[rope] THEN high ← Convert.CardFromRope[rope];
};
cmd.out.PutF["%l", IO.rope["f"]];
cmd.out.PutF["\nArpa Routing Table:\n"];
cmd.out.PutF["\n%-20g%-18g%-7g%-10g\n\n", IO.rope["Entry"], IO.rope["Via"], IO.rope["Hops"], IO.rope["Time"]];
ArpaRouter.Enumerate[low,high,printRouteProc];
cmd.out.PutRope["\n"];
cmd.out.PutF["%l", IO.rope["F"]];
};
Commander.Register["PrintArpaRoutes", PAR, docRope];
END.