[Gd-chatter] r10860 - in trunk/libraries: flow gui-sniffer network-flow packetizer
hannes at gwydiondylan.org
hannes at gwydiondylan.org
Tue Aug 22 12:11:48 CEST 2006
Author: hannes
Date: Tue Aug 22 12:11:45 2006
New Revision: 10860
Modified:
trunk/libraries/flow/flow.dylan
trunk/libraries/flow/module.dylan
trunk/libraries/gui-sniffer/gui-sniffer.dylan
trunk/libraries/network-flow/module.dylan
trunk/libraries/network-flow/network-flow.dylan
trunk/libraries/packetizer/module.dylan
trunk/libraries/packetizer/packetizer.dylan
Log:
Bug: 7299
*implement disconnect in flow
*implement <malformed-packet-writer> which saves all packets which returned a <malformed-packet-error> during parsing in a pcap-file
*fix assembling of <unparsed-container-frames> that they don't need any parsing
*fix bug that gui-sniffer has each packet 2 times in network-frames slot
*use disconnect in gui-sniffer
Modified: trunk/libraries/flow/flow.dylan
==============================================================================
--- trunk/libraries/flow/flow.dylan (original)
+++ trunk/libraries/flow/flow.dylan Tue Aug 22 12:11:45 2006
@@ -49,16 +49,28 @@
define open generic connect (output, input);
+define open generic disconnect (output, input);
+
define method connect (output :: <push-output>, input :: <push-input>)
output.connected-input := input;
input.connected-output := output;
end;
+define method disconnect (output :: <push-output>, input :: <push-input>)
+ output.connected-input := #f;
+ input.connected-output := #f;
+end;
+
define method connect (output :: <pull-output>, input :: <pull-input>)
output.connected-input := input;
input.connected-output := output;
end;
+define method disconnect (output :: <pull-output>, input :: <pull-input>)
+ output.connected-input := #f;
+ input.connected-output := #f;
+end;
+
define open generic pull-data-aux (output :: <pull-output>, node :: <node>);
define method pull-data (input :: <pull-input>) => (data)
@@ -125,14 +137,26 @@
connect(node.the-output, input)
end;
+define method disconnect (node :: <single-output-node>, input :: <input>)
+ disconnect(node.the-output, input);
+end;
+
define method connect (output :: <output>, node :: <single-input-node>)
connect(output, node.the-input)
end;
+define method disconnect (output :: <output>, node :: <single-input-node>)
+ disconnect(output, node.the-input);
+end;
+
define method connect (output :: <single-output-node>, input :: <single-input-node>)
connect(output.the-output, input.the-input)
end;
+define method disconnect (output :: <single-output-node>, input :: <single-input-node>)
+ disconnect(output.the-output, input.the-input);
+end;
+
define open abstract class <filter> (<single-push-input-node>, <single-push-output-node>)
end;
Modified: trunk/libraries/flow/module.dylan
==============================================================================
--- trunk/libraries/flow/module.dylan (original)
+++ trunk/libraries/flow/module.dylan Tue Aug 22 12:11:45 2006
@@ -16,7 +16,7 @@
<push-output>, <pull-output>,
push-data, pull-data,
push-data-aux, pull-data-aux,
- connect, toplevel;
+ connect, disconnect, toplevel;
export
<single-push-input-node>, <single-pull-input-node>,
Modified: trunk/libraries/gui-sniffer/gui-sniffer.dylan
==============================================================================
--- trunk/libraries/gui-sniffer/gui-sniffer.dylan (original)
+++ trunk/libraries/gui-sniffer/gui-sniffer.dylan Tue Aug 22 12:11:45 2006
@@ -139,7 +139,7 @@
end;
define method print-protocol (frame :: <ethernet-frame>)
- next-method | frame.type-code
+ next-method() | frame.type-code
end;
define method print-protocol (frame :: <header-frame>)
@@ -382,6 +382,7 @@
let pcap-reader = make(<pcap-file-reader>, stream: file-stream);
connect(pcap-reader, frame);
toplevel(pcap-reader);
+ disconnect(pcap-reader, frame);
gadget-label(frame.sniffer-status-bar) := concatenate("Opened ", file);
close(file-stream);
end;
@@ -403,7 +404,7 @@
timestamp: make-unix-time(time-diff),
payload: x.real-frame)
end, frame.network-frames));
- //XXX: disconnect in flow graph, but disconnect is NYI
+ disconnect(frame, pcap-writer);
gadget-label(frame.sniffer-status-bar) := concatenate("Wrote ", file);
close(file-stream);
end;
@@ -426,7 +427,7 @@
define method close-interface (frame :: <gui-sniffer-frame>)
frame.ethernet-interface.running? := #f;
gadget-label(frame.sniffer-status-bar) := "Stopped capturing";
- //XXX: disconnect in flow graph, but disconnect is NYI
+ disconnect(frame.ethernet-interface, frame);
end;
define method prompt-for-interface
@@ -452,7 +453,7 @@
frame.first-packet-arrived := #f;
*count* := 0;
frame.network-frames := make(<stretchy-vector>);
- gadget-items(frame.packet-table) := frame.network-frames;
+ gadget-items(frame.packet-table) := #();
show-packet(frame);
end;
Modified: trunk/libraries/network-flow/module.dylan
==============================================================================
--- trunk/libraries/network-flow/module.dylan (original)
+++ trunk/libraries/network-flow/module.dylan Tue Aug 22 12:11:45 2006
@@ -12,6 +12,7 @@
use flow;
use packetizer;
use packet-filter;
+ use file-system;
export <summary-printer>, <verbose-printer>,
<decapsulator>, <demultiplexer>,
@@ -20,5 +21,6 @@
<frame-filter>,
<pcap-file-reader>,
<pcap-file-writer>,
+ <malformed-packet-writer>,
<fan-out>, <fan-in>;
end module network-flow;
Modified: trunk/libraries/network-flow/network-flow.dylan
==============================================================================
--- trunk/libraries/network-flow/network-flow.dylan (original)
+++ trunk/libraries/network-flow/network-flow.dylan Tue Aug 22 12:11:45 2006
@@ -54,6 +54,12 @@
connect(output, create-input(fan-in));
end;
+define method disconnect (output :: <object>, fan-in :: <fan-in>)
+ let in = output.connected-input;
+ disconnect(output, in);
+ remove!(fan-in.inputs, in);
+end;
+
define method push-data-aux (input :: <push-input>,
node :: <fan-in>,
frame :: <frame>)
@@ -74,6 +80,11 @@
connect(create-output(fan-out), input);
end;
+define method disconnect (fan-out :: <fan-out>, input :: <object>)
+ let out = input.connected-output;
+ disconnect(out, input);
+ remove!(fan-out.outputs, out);
+end;
define method push-data-aux (input :: <push-input>,
node :: <fan-out>,
frame :: <frame>)
@@ -177,6 +188,35 @@
force-output(node.file-stream);
end;
+define class <malformed-packet-writer> (<filter>)
+ slot file-stream, required-init-keyword: file:;
+ slot pcap-writer :: false-or(<pcap-file-writer>) = #f;
+end;
+
+define method make (class == <malformed-packet-writer>,
+ #rest rest, #key file, #all-keys) => (res :: <malformed-packet-writer>)
+ if (instance?(file, <string>))
+ let fs = make(<file-stream>, locator: file, direction: #"output", if-exists: #"replace");
+ make(class, file: fs);
+ else
+ next-method();
+ end;
+end;
+
+define method push-data-aux (input :: <push-input>,
+ node :: <malformed-packet-writer>,
+ frame :: <frame>)
+ block()
+ push-data(node.the-output, frame);
+ exception (e :: <malformed-packet-error>)
+ unless (node.pcap-writer)
+ node.pcap-writer := make(<pcap-file-writer>, stream: node.file-stream);
+ end;
+ //uh, we should somehow be connected to the pcap-writer
+ push-data-aux(node.pcap-writer.the-input, frame)
+ end;
+end;
+
define class <completer> (<filter>)
constant slot template-frame :: <frame>, required-init-keyword: template-frame:;
end;
Modified: trunk/libraries/packetizer/module.dylan
==============================================================================
--- trunk/libraries/packetizer/module.dylan (original)
+++ trunk/libraries/packetizer/module.dylan Tue Aug 22 12:11:45 2006
@@ -46,7 +46,11 @@
export <integer-or-unknown>, $unknown-at-compile-time;
+ export <malformed-packet-error>;
+
export <frame-field>,
+ <repeated-frame-field>,
+ frame-field-list,
start-offset,
length,
end-offset,
Modified: trunk/libraries/packetizer/packetizer.dylan
==============================================================================
--- trunk/libraries/packetizer/packetizer.dylan (original)
+++ trunk/libraries/packetizer/packetizer.dylan Tue Aug 22 12:11:45 2006
@@ -196,9 +196,11 @@
define method fixup!(frame :: <header-frame>,
packet :: type-union(<byte-vector>, <byte-vector-subsequence>))
- fixup!(frame.payload,
- subsequence(packet,
- start: byte-offset(start-offset(get-frame-field(#"payload", frame)))));
+ unless (instance?(frame.payload, <unparsed-container-frame>))
+ fixup!(frame.payload,
+ subsequence(packet,
+ start: byte-offset(start-offset(get-frame-field(#"payload", frame)))));
+ end;
end;
define generic frame-size (frame :: type-union(<frame>, subclass(<fixed-size-frame>)))
@@ -375,6 +377,9 @@
reduce1(\+, map(curry(get-field-size-aux, frame), frame.fields));
end;
+define method frame-size (frame :: <unparsed-container-frame>) => (size :: <integer>)
+ frame.packet.size * 8
+end;
define method assemble-frame (frame :: <container-frame>) => (packet :: <byte-vector>);
let result = make(<byte-vector>, size: byte-offset(frame-size(frame)), fill: 0);
@@ -418,6 +423,12 @@
end;
end;
+define method assemble-frame-into (frame :: <unparsed-container-frame>,
+ to-packet :: <byte-vector>,
+ start :: <integer>)
+ byte-aligned(start);
+ copy-bytes(frame.packet, 0, to-packet, byte-offset(start), frame.packet.size);
+end;
define method assemble-field-into(field :: <single-field>,
frame :: <container-frame>,
packet :: <byte-vector>,
More information about the chatter
mailing list