[Gd-chatter] r11445 - trunk/libraries/gui-sniffer
andreas at gwydiondylan.org
andreas at gwydiondylan.org
Tue Sep 11 03:15:00 CEST 2007
Author: andreas
Date: Tue Sep 11 03:14:59 2007
New Revision: 11445
Modified:
trunk/libraries/gui-sniffer/command-line.dylan
trunk/libraries/gui-sniffer/gui-sniffer.dylan
trunk/libraries/gui-sniffer/module.dylan
Log:
job: 7299
Make ping command work for real
Modified: trunk/libraries/gui-sniffer/command-line.dylan
==============================================================================
--- trunk/libraries/gui-sniffer/command-line.dylan (original)
+++ trunk/libraries/gui-sniffer/command-line.dylan Tue Sep 11 03:14:59 2007
@@ -106,7 +106,8 @@
define class <nnv-context> (<server-context>)
- keyword banner: = "Network Night Vision"
+ keyword banner: = "Network Night Vision";
+ slot nnv-context;
end;
define method make-command-line-server
@@ -126,74 +127,13 @@
end method make-command-line-server;
-define class <nnvhelp-command> (<basic-command>)
-end;
-
-
-define command-line nnvhelp => <nnvhelp-command>
- (summary: "Help",
- documentation: "You expected more help, right?")
-end;
-define method do-execute-command (context :: <nnv-context>, command :: <nnvhelp-command>)
- => ()
- let stream = context.context-server.server-output-stream;
- format(stream, "Yeah, right!\n");
-end;
-
-define constant <ipv4-address> = <string>;
-define constant ipv4-address = identity;
-define method parse-next-argument
- (context :: <nnv-context>, type == <ipv4-address>,
- text :: <string>,
- #key start :: <integer> = 0, end: stop = #f)
- => (value :: <ipv4-address>, next-index :: <integer>)
- let (name, next-index)
- = parse-next-word(text, start: start, end: stop);
- if (name)
- values(ipv4-address(name), next-index)
- else
- parse-error("Missing argument.")
- end
-end;
-define class <ping-command> (<basic-command>)
- constant slot %target :: <ipv4-address>, required-init-keyword: target:;
-end;
-
-define command-line ping => <ping-command>
- (summary: "Ping host.",
- documentation: "Sends an ICMP Echo Request to the specified target address.")
- argument target :: <ipv4-address> = "target host address";
-end;
-
-define method do-execute-command (context :: <nnv-context>, command :: <ping-command>)
- let target = command.%target;
- // ping!!1!
-end;
-
-define command-group nnv
- (summary: "Network Night Vision commands",
- documentation: "The set of commands provided by Network Night Vision.")
- command nnvhelp;
- command ping;
- group basic;
-end command-group;
-
-define method context-command-group
- (context :: <nnv-context>) => (group :: <command-group>)
- $nnv-command-group
-end method context-command-group;
-
-define method context-command-prefix
- (context :: <nnv-context>) => (prefix :: <character>)
- '>'
-end method context-command-prefix;
+
-
Modified: trunk/libraries/gui-sniffer/gui-sniffer.dylan
==============================================================================
--- trunk/libraries/gui-sniffer/gui-sniffer.dylan (original)
+++ trunk/libraries/gui-sniffer/gui-sniffer.dylan Tue Sep 11 03:14:59 2007
@@ -938,9 +938,78 @@
*/
end;
+define class <nnvhelp-command> (<basic-command>)
+end;
+
+
+define command-line nnvhelp => <nnvhelp-command>
+ (summary: "Help",
+ documentation: "You expected more help, right?")
+end;
+
+define method do-execute-command (context :: <nnv-context>, command :: <nnvhelp-command>)
+ => ()
+ let stream = context.context-server.server-output-stream;
+ format(stream, "Yeah, right!\n");
+end;
+
+define method parse-next-argument
+ (context :: <nnv-context>, type == <ipv4-address>,
+ text :: <string>,
+ #key start :: <integer> = 0, end: stop = #f)
+ => (value :: <ipv4-address>, next-index :: <integer>)
+ block (return)
+ let (name, next-index)
+ = parse-next-word(text, start: start, end: stop);
+ if (name)
+ values(ipv4-address(name), next-index)
+ else
+ parse-error("Missing argument.")
+ end
+ exception (e :: <condition>)
+ parse-error("Not a valid target.")
+ end;
+end;
+
+define class <ping-command> (<basic-command>)
+ constant slot %target :: <ipv4-address>, required-init-keyword: target:;
+end;
+
+define command-line ping => <ping-command>
+ (summary: "Ping host.",
+ documentation: "Sends an ICMP Echo Request to the specified target address.")
+ argument target :: <ipv4-address> = "target host address";
+end;
+
+define method do-execute-command (context :: <nnv-context>, command :: <ping-command>)
+ let target = command.%target;
+ let icmp = icmp-frame(code: 0, icmp-type: 8,
+ payload: read-frame(<raw-frame>, "123412341234123412341234123412341234123412341234"));
+ send(context.nnv-context.ip-layer, target, icmp);
+end;
+
+define command-group nnv
+ (summary: "Network Night Vision commands",
+ documentation: "The set of commands provided by Network Night Vision.")
+ command nnvhelp;
+ command ping;
+ group basic;
+end command-group;
+
+define method context-command-group
+ (context :: <nnv-context>) => (group :: <command-group>)
+ $nnv-command-group
+end method context-command-group;
+
+define method context-command-prefix
+ (context :: <nnv-context>) => (prefix :: <character>)
+ '>'
+end method context-command-prefix;
+
define function main()
initialize-icons();
let gui-sniffer = make(<gui-sniffer-frame>);
+ gui-sniffer.nnv-shell.command-line-server.server-context.nnv-context := gui-sniffer;
set-frame-size(gui-sniffer, 1024, 768);
// deuce/frame-window(gui-sniffer) := gui-sniffer.packet-hex-dump;
// deuce/*editor-frame* := gui-sniffer;
Modified: trunk/libraries/gui-sniffer/module.dylan
==============================================================================
--- trunk/libraries/gui-sniffer/module.dylan (original)
+++ trunk/libraries/gui-sniffer/module.dylan Tue Sep 11 03:14:59 2007
@@ -25,7 +25,7 @@
use commands;
use command-lines;
- export make-nnv-shell-pane;
+ export make-nnv-shell-pane, command-line-server, nnv-context, nnv-context-setter, <nnv-context>;
end;
define module gui-sniffer
@@ -47,11 +47,14 @@
use network-flow;
use flow;
use command-line;
+ use commands;
+ use command-lines;
use hex-view;
use ethernet, import: { <ethernet-frame> };
use pcap, import: { make-unix-time, <pcap-packet>, decode-unix-time, timestamp };
use prism2, import: { <prism2-frame> };
- use ipv4, import: { <ipv4-frame>, <udp-frame>, source-port, destination-port, acknowledgement-number, sequence-number };
+ use ipv4, import: { <ipv4-frame>, <udp-frame>, source-port, destination-port,
+ acknowledgement-number, sequence-number, ipv4-address, <ipv4-address> };
use icmp, import: { <icmp-frame>, icmp-frame };
use tcp;
use ipv6;
More information about the chatter
mailing list