ArpaTCPWatcher.mesa
Copyright (C) 1983 by Xerox Corporation. All rights reserved. The following program was created in 1983 but has not been published within the meaning of the copyright law, is furnished under license, and may not be used, copied and/or disclosed except in accordance with the terms of said license.
Last Edited by: HGM, March 22, 1984 9:04:57 pm PST
Doug Terry, October 16, 1987 4:01:20 pm PDT
John Larson, April 14, 1986 11:35:22 pm PST
DIRECTORY
Arpa USING [nullAddress, Address],
Commander USING [CommandProc, Register],
CommandTool USING [NextArgument],
ConvertExtras USING [ArpaAddressFromRope],
IO USING [STREAM],
Rope USING [ROPE, IsEmpty],
TypeScript USING [ChangeLooks],
ViewerEvents USING [EventProc, RegisterEventProc],
ViewerIO USING [CreateViewerStreams, GetViewerFromStream, Viewer],
ArpaTCPLogging USING [addrToWatch, logFile];
ArpaTCPWatcher:
CEDAR
PROGRAM
IMPORTS ConvertExtras, Commander, CommandTool, Rope, TypeScript, ViewerEvents, ViewerIO, ArpaTCPLogging =
BEGIN
StartWatcher: Commander.CommandProc = {
[cmd: Commander.Handle] RETURNS [result: REF ANY ← NIL, msg: ROPE ← NIL]
out: IO.STREAM;
viewer: ViewerIO.Viewer;
inRope: Rope.ROPE ← CommandTool.NextArgument[cmd];
addr: Arpa.Address ← [255,255,255,255]; -- Default to all addreses
IF ~Rope.IsEmpty[inRope] THEN addr ← ConvertExtras.ArpaAddressFromRope[inRope];
IF ArpaTCPLogging.logFile#NIL THEN RETURN[msg: "ArpaTCPWatcher already started."];
out ← ViewerIO.CreateViewerStreams[
name: "ArpaTCP.log", viewer: NIL, backingFile: "ArpaTCP.log", editedStream: FALSE].out;
viewer ← ViewerIO.GetViewerFromStream[out];
TypeScript.ChangeLooks[viewer, 'f];
[] ← ViewerEvents.RegisterEventProc[proc: DestroyProc, event: destroy, filter: viewer];
ArpaTCPLogging.logFile ← out;
ArpaTCPLogging.addrToWatch ← addr;
};
DestroyProc: ViewerEvents.EventProc = {
[viewer: ViewerClasses.Viewer, event: ViewerEvents.ViewerEvent, before: BOOL] RETURNS [abort: BOOL ← FALSE]
ArpaTCPLogging.addrToWatch ← Arpa.nullAddress;
ArpaTCPLogging.logFile ← NIL;
};
Commander.Register["ArpaTCPWatcher", StartWatcher, "Start up a typescript to watch TCP packets."];
END.