[Gd-chatter] r11041 - in trunk/libraries: gui-sniffer gui-sniffer/icons packetizer pcap protocols

andreas at gwydiondylan.org andreas at gwydiondylan.org
Sat Dec 9 02:04:02 CET 2006


Author: andreas
Date: Sat Dec  9 02:03:58 2006
New Revision: 11041

Added:
   trunk/libraries/gui-sniffer/icons/nnv.ico   (contents, props changed)
Modified:
   trunk/libraries/gui-sniffer/bitmaps.rc
   trunk/libraries/gui-sniffer/gui-sniffer.dylan
   trunk/libraries/gui-sniffer/gui-sniffer.hdp
   trunk/libraries/gui-sniffer/hex-view.dylan
   trunk/libraries/gui-sniffer/module.dylan
   trunk/libraries/packetizer/protocol-definer-macro.dylan
   trunk/libraries/pcap/pcap.dylan
   trunk/libraries/protocols/ethernet.dylan
   trunk/libraries/protocols/tcp.dylan
Log:
job: 7299

 * constructor for container frames
 * new name for GUI sniffer: "Network Night Vision"
 * added application icon


Modified: trunk/libraries/gui-sniffer/bitmaps.rc
==============================================================================
--- trunk/libraries/gui-sniffer/bitmaps.rc	(original)
+++ trunk/libraries/gui-sniffer/bitmaps.rc	Sat Dec  9 02:03:58 2006
@@ -2,3 +2,4 @@
 PLAY		ICON DISCARDABLE "play.ico"
 SAVE		ICON DISCARDABLE "save.ico"
 STOP		ICON DISCARDABLE "stop.ico"
+NNV		ICON DISCARDABLE "nnv.ico"

Modified: trunk/libraries/gui-sniffer/gui-sniffer.dylan
==============================================================================
--- trunk/libraries/gui-sniffer/gui-sniffer.dylan	(original)
+++ trunk/libraries/gui-sniffer/gui-sniffer.dylan	Sat Dec  9 02:03:58 2006
@@ -238,7 +238,8 @@
     filter-packet-table(frame);
   end;
 end;
-define method filter-packet-table (frame :: <gui-sniffer-frame>)
+
+define function filter-packet-table (frame :: <gui-sniffer-frame>)
   let shown-packets
     = if (frame.filter-expression)
         choose-by(rcurry(matches?, frame.filter-expression),
@@ -256,7 +257,7 @@
   end;
 end;
 
-define method show-packet (frame :: <gui-sniffer-frame>)
+define function show-packet (frame :: <gui-sniffer-frame>)
   let current-packet = current-packet(frame);
   show-packet-tree(frame, current-packet);
   current-packet & show-hexdump(frame, current-packet.packet);
@@ -265,7 +266,7 @@
 //  note-gadget-value-changed(window);
 end;
 
-define method show-packet-tree (frame :: <gui-sniffer-frame>, packet)
+define function show-packet-tree (frame :: <gui-sniffer-frame>, packet)
   frame.packet-tree-view.tree-control-roots
     := if (packet)
          add!(frame-root-generator(packet), packet);
@@ -364,7 +365,7 @@
   frame;
 end;
 
-define method highlight-hex-dump (mframe :: <gui-sniffer-frame>)
+define function highlight-hex-dump (mframe :: <gui-sniffer-frame>)
   let packet = mframe.packet-table.gadget-value;
   let tree = mframe.packet-tree-view;
   let selected-packet = tree.gadget-items[tree.gadget-selection[0]];
@@ -469,7 +470,7 @@
 
 
   pane sniffer-status-bar (frame)
-    make(<status-bar>, label: "GUI Sniffer");
+    make(<status-bar>, label: "Network Night Vision");
 
   pane open-button (frame)
     make(<push-button>, label: $icons["open"],
@@ -509,7 +510,8 @@
   tool-bar (frame) frame.sniffer-tool-bar;
   command-table (frame) *gui-sniffer-command-table*;
   status-bar (frame) frame.sniffer-status-bar;
-  keyword title: = "GUI Sniffer"
+  keyword title: = "Network Night Vision";
+  keyword icon: = $icons["nnv-small"];
 end;
 
 define command-table *file-command-table* (*global-command-table*)
@@ -534,28 +536,53 @@
 define constant $transform-from-bv = compose(byte-vector-to-float-be, data);
 define constant $transform-to-bv = compose(big-endian-unsigned-integer-4byte, float-to-byte-vector-be);
 
+define inline function stack (#rest frames)
+  for (i from 1 below frames.size)
+    frames[i - 1].payload := frames[i]
+  end;
+  frames[0]
+end;
+
+define inline function ethernet-frame (#rest args)
+  apply(make, <ethernet-frame>, args)
+end;
+
+define inline function ipv4-frame (#rest args)
+  apply(make, <ipv4-frame>, args)
+end;
+
+define inline function tcp-frame (#rest args)
+  apply(make, <tcp-frame>, args)
+end;
+
 define method tcpkill (node :: <gui-sniffer-frame>);
   let data = current-packet(node);
   let incoming-ip = data.payload;
   let incoming-tcp = incoming-ip.payload;
   let sequence = $transform-from-bv(incoming-tcp.acknowledgement-number);
-  let tcp-frame = make(<tcp-frame>,
-                       source-port: incoming-tcp.destination-port,
-                       destination-port: incoming-tcp.source-port,
-                       rst: 1,
-                       sequence-number: $transform-to-bv(sequence),
-                       acknowledgement-number: $transform-to-bv(0.0s0));
-  let ip-frame = make(<ipv4-frame>,
-                      source-address: incoming-ip.destination-address,
-                      destination-address: incoming-ip.source-address,
-                      protocol: 6,
-                      payload: tcp-frame);
-  let ethernet-frame = make(<ethernet-frame>,
-                            source-address: data.destination-address,
-                            destination-address: data.source-address,
-                            type-code: #x800,
-                            payload: ip-frame);
-  push-data(node.the-output, ethernet-frame);
+  push-data
+    (node.the-output,
+     stack(ethernet-frame(source-address: data.destination-address,
+                          destination-address: data.source-address),
+           ipv4-frame(source-address: incoming-ip.destination-address,
+                        destination-address: incoming-ip.source-address),
+           tcp-frame(source-port: incoming-tcp.destination-port,
+                     destination-port: incoming-tcp.source-port,
+                     rst: 1,
+                     sequence-number: $transform-to-bv(sequence),
+                     acknowledgement-number: $transform-to-bv(0.0s0))));
+  push-data
+    (node.the-output,
+     stack(ethernet-frame(source-address: data.source-address,
+                          destination-address: data.destination-address),
+           ipv4-frame(source-address: incoming-ip.source-address,
+                        destination-address: incoming-ip.destination-address),
+           tcp-frame(source-port: incoming-tcp.source-port,
+                     destination-port: incoming-tcp.destination-port,
+                     rst: 1,
+                     sequence-number: $transform-to-bv($transform-from-bv(incoming-tcp.sequence-number) 
+                                                        + byte-offset(incoming-tcp.payload.frame-size)),
+                     acknowledgement-number: $transform-to-bv(0.0s0))));
 end;
 
 define command-table *popup-menu-command-table* (*global-command-table*)
@@ -829,14 +856,17 @@
 define constant $icons = make(<string-table>);
 
 define function initialize-icons ()
-  local method load-and-register-item (name)
+  local method load-and-register-item (name, size)
     $icons[as-lowercase(name)]
-      := read-image-as(<win32-icon>, as(<byte-string>, name), #"icon", width: 16, height: 16);
+      := read-image-as(<win32-icon>, as(<byte-string>, name), #"icon", width: size, height: size);
   end;
-  load-and-register-item("PLAY");
-  load-and-register-item("OPEN");
-  load-and-register-item("SAVE");
-  load-and-register-item("STOP");
+  load-and-register-item("PLAY", 16);
+  load-and-register-item("OPEN", 16);
+  load-and-register-item("SAVE", 16);
+  load-and-register-item("STOP", 16);
+  load-and-register-item("NNV", 32);
+  $icons["nnv-small"]
+    := read-image-as(<win32-icon>, as(<byte-string>, "NNV"), #"small-icon");
 end;
 
 begin

Modified: trunk/libraries/gui-sniffer/gui-sniffer.hdp
==============================================================================
--- trunk/libraries/gui-sniffer/gui-sniffer.hdp	(original)
+++ trunk/libraries/gui-sniffer/gui-sniffer.hdp	Sat Dec  9 02:03:58 2006
@@ -12,6 +12,7 @@
 	icons\save.ico
 	icons\play.ico
 	icons\stop.ico
+	icons\nnv.ico
 rc-files:	bitmaps.rc
 major-version:	1
 minor-version:	0

Modified: trunk/libraries/gui-sniffer/hex-view.dylan
==============================================================================
--- trunk/libraries/gui-sniffer/hex-view.dylan	(original)
+++ trunk/libraries/gui-sniffer/hex-view.dylan	Sat Dec  9 02:03:58 2006
@@ -49,7 +49,7 @@
 
 define method set-highlight (frame, start-offset, end-offset)
   let window :: <basic-window> = frame-window(frame);
-  let name = "hex view";
+  let name = "Network Night Vision";
   let editor = frame-editor(frame);
   let buffer = find-buffer(editor, name);
   if (buffer)
@@ -120,7 +120,7 @@
   end;
 
   let window :: <basic-window> = frame-window(frame);
-  let name = "hex view";
+  let name = "Network Night Vision";
   let editor = frame-editor(frame);
   let buffer = find-buffer(editor, name)
                | make-empty-buffer(<simple-display-buffer>,

Added: trunk/libraries/gui-sniffer/icons/nnv.ico
==============================================================================
Binary file. No diff available.

Modified: trunk/libraries/gui-sniffer/module.dylan
==============================================================================
--- trunk/libraries/gui-sniffer/module.dylan	(original)
+++ trunk/libraries/gui-sniffer/module.dylan	Sat Dec  9 02:03:58 2006
@@ -35,7 +35,7 @@
   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>, <tcp-frame>, <udp-frame>, source-port, destination-port, acknowledgement-number };
+  use ipv4, import: { <ipv4-frame>, <tcp-frame>, <udp-frame>, source-port, destination-port, acknowledgement-number, sequence-number };
   // Add binding exports here.
   use deuce-internals, prefix: "deuce/";
   use interfaces;

Modified: trunk/libraries/packetizer/protocol-definer-macro.dylan
==============================================================================
--- trunk/libraries/packetizer/protocol-definer-macro.dylan	(original)
+++ trunk/libraries/packetizer/protocol-definer-macro.dylan	Sat Dec  9 02:03:58 2006
@@ -462,6 +462,15 @@
          end; }
 end;
 
+define macro container-frame-constructor
+  { container-frame-constructor(?:name) }
+ =>
+  { define inline method ?name (#rest args)
+      apply(make, "<" ## ?name ## ">", args)
+    end
+  }
+end;
+
 define macro protocol-definer
     { define protocol ?:name (?superprotocol:name)
         summary ?summary:* ;
@@ -512,6 +521,7 @@
         frame-field-generator("<unparsed-" ## ?name ## ">";
                               field-count("<unparsed-" ## ?superprotocol ## ">");
                               ?fields);
+        container-frame-constructor(?name);
       }
 end;
 

Modified: trunk/libraries/pcap/pcap.dylan
==============================================================================
--- trunk/libraries/pcap/pcap.dylan	(original)
+++ trunk/libraries/pcap/pcap.dylan	Sat Dec  9 02:03:58 2006
@@ -129,7 +129,7 @@
   for (device = devices then device.next, while: device ~= null-pointer(<pcap-if*>))
     let cidrs = make(<stretchy-vector>);
     for (ele = device.addresses then ele.next, while: ele ~= null-pointer(<pcap-addr*>))
-      format-out("GOT as address %= ", ele.address.sa-family-value);
+//      format-out("GOT as address %= ", ele.address.sa-family-value);
       local method printme (x)
               for (f from 2 below 6)
                 format-out("%X ", sa-data-array(x, f));
@@ -161,7 +161,7 @@
               netmask-from-byte-vector(res);
             end;
 
-      format-out("\n");
+      //format-out("\n");
       add!(cidrs, concatenate(as(<string>, get-address(ele)), "/", integer-to-string(get-netmask(ele))));
     end;
 

Modified: trunk/libraries/protocols/ethernet.dylan
==============================================================================
--- trunk/libraries/protocols/ethernet.dylan	(original)
+++ trunk/libraries/protocols/ethernet.dylan	Sat Dec  9 02:03:58 2006
@@ -132,7 +132,7 @@
   summary "ID: %=", cdp-value;
 end;
 
-define protocol cdp-address (container-frame)
+define protocol cdp-address-frame (container-frame)
   field cdp-protocol-type :: <unsigned-byte>;
   field cdp-protocol-length :: <unsigned-byte>;
   field cdp-protocol :: <raw-frame>, length: frame.cdp-protocol-length * 8;
@@ -140,10 +140,10 @@
   field cdp-address :: <raw-frame>, length: frame.cdp-address-length * 8;
 end; 
 
-define protocol cdp-addresses (cdp-record)
+define protocol cdp-addresses-frame (cdp-record)
   over <cdp-record> #x2;
   field address-count :: <unsigned-byte>;
-  repeated field cdp-addresses :: <cdp-address>,
+  repeated field cdp-addresses :: <cdp-address-frame>,
     count: frame.address-count;
 end;
 
@@ -198,7 +198,7 @@
   field cdp-native-vlan-id :: <2byte-big-endian-unsigned-integer>;
 end;
 
-define protocol cdp-duplex (cdp-record)
+define protocol cdp-duplex-frame (cdp-record)
   over <cdp-record> #xb;
   summary "Duplex: %s", method(x) if (x.cdp-duplex = 0) "half" else "full" end end;
   field cdp-duplex :: <unsigned-byte>;
@@ -224,7 +224,7 @@
   summary "Power: %=", cdp-value;
 end;
 
-define protocol cdp-mtu (cdp-record)
+define protocol cdp-mtu-frame (cdp-record)
   over <cdp-record> #x11;
   summary "MTU: %=", cdp-mtu;
   field cdp-mtu :: <big-endian-unsigned-integer-4byte>;

Modified: trunk/libraries/protocols/tcp.dylan
==============================================================================
--- trunk/libraries/protocols/tcp.dylan	(original)
+++ trunk/libraries/protocols/tcp.dylan	Sat Dec  9 02:03:58 2006
@@ -73,7 +73,7 @@
     fixup: byte-offset(frame-size(frame));
 end;
 
-define protocol maximum-segment-size (tcp-option-with-data)
+define protocol maximum-segment-size-option (tcp-option-with-data)
   over <tcp-option> 2;
   field maximum-segment-size :: <2byte-big-endian-unsigned-integer>;
 end;



More information about the chatter mailing list