Ethereal-dev: [Ethereal-dev] [PATCH] enable 'follow SSL stream' only on ssl packet

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Paolo Abeni <paolo.abeni@xxxxxxxx>
Date: Tue, 14 Feb 2006 11:37:43 +0100
hi,

The attached patch:
- enable the 'follow SSL stream' menu item only when a ssl packet is
selected.
- when 'following' an ssl stream, show ssl decrypted data only for
current conversation.
- fix a typo in ssl preference description.

Paolo

 
 
 --
 Email.it, the professional e-mail, gratis per te: http://www.email.it/f
 
 Sponsor:
 Logos Finanziaria SPA. Societ� di credito ad erogazione diretta. Fino a 30.000 euro in 24 ore! Clicca e scopri come
* 
 Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=2909&d=14-2
Index: gtk/ssl-dlg.c
===================================================================
--- gtk/ssl-dlg.c	(revision 17296)
+++ gtk/ssl-dlg.c	(working copy)
@@ -202,16 +202,6 @@
 
     follow_info = g_new0(follow_info_t, 1);
     
-    /* data will be passed via tap callback*/
-    msg = register_tap_listener("ssl", follow_info, NULL,
-	NULL, ssl_queue_packet_data, NULL);
-    if (msg)
-    {
-        simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
-            "Can't register ssl tap: %s\n",msg->str);
-        return;
-    }
-    
     /* Create a new filter that matches all packets in the SSL stream,
        and set the display filter entry accordingly */
     reset_tcp_reassembly();
@@ -242,7 +232,15 @@
         "!(%s)", follow_filter);
     }
 
-
+    /* data will be passed via tap callback*/
+    msg = register_tap_listener("ssl", follow_info, follow_filter,
+	NULL, ssl_queue_packet_data, NULL);
+    if (msg)
+    {
+        simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
+            "Can't register ssl tap: %s\n",msg->str);
+        return;
+    }
     gtk_entry_set_text(GTK_ENTRY(filter_te), follow_filter);
 
     /* Run the display filter so it goes in effect - even if it's the
Index: gtk/menu.c
===================================================================
--- gtk/menu.c	(revision 17296)
+++ gtk/menu.c	(working copy)
@@ -1959,9 +1959,26 @@
 	return node_data->enabled;
 }
 
+static int 
+packet_is_ssl(epan_dissect_t* edt)
+{
+  GPtrArray* array;
+  int ssl_id, is_ssl;
+  if (!edt || !edt->tree)
+      return 0;
+  ssl_id = proto_get_id_by_filter_name("ssl");
+  if (ssl_id < 0)
+      return 0;
+  array = proto_find_finfo(edt->tree, ssl_id);
+  is_ssl = array->len > 0;
+  g_ptr_array_free(array, FALSE);
+  return is_ssl;
+}
+
 void
 set_menus_for_selected_packet(capture_file *cf)
 {
+  int is_ssl = packet_is_ssl(cf->edt);
   set_menu_sensitivity(main_menu_factory, "/Edit/Mark Packet (toggle)",
       cf->current_frame != NULL);
   set_menu_sensitivity(packet_list_menu_factory, "/Mark Packet (toggle)",
@@ -1995,11 +2012,11 @@
   set_menu_sensitivity(tree_view_menu_factory, "/Follow TCP Stream",
       cf->current_frame != NULL ? (cf->edt->pi.ipproto == IP_PROTO_TCP) : FALSE);
   set_menu_sensitivity(main_menu_factory, "/Analyze/Follow SSL Stream",
-      cf->current_frame != NULL ? (cf->edt->pi.ipproto == IP_PROTO_TCP) : FALSE);
+      cf->current_frame != NULL ? is_ssl : FALSE);
   set_menu_sensitivity(packet_list_menu_factory, "/Follow SSL Stream",
-      cf->current_frame != NULL ? (cf->edt->pi.ipproto == IP_PROTO_TCP) : FALSE);
+      cf->current_frame != NULL ? is_ssl : FALSE);
   set_menu_sensitivity(tree_view_menu_factory, "/Follow SSL Stream",
-      cf->current_frame != NULL ? (cf->edt->pi.ipproto == IP_PROTO_TCP) : FALSE);
+      cf->current_frame != NULL ? is_ssl : FALSE);
   set_menu_sensitivity(main_menu_factory, "/Analyze/Decode As...",
       cf->current_frame != NULL && decode_as_ok());
   set_menu_sensitivity(packet_list_menu_factory, "/Decode As...",
Index: epan/dissectors/packet-ssl.c
===================================================================
--- epan/dissectors/packet-ssl.c	(revision 17296)
+++ epan/dissectors/packet-ssl.c	(working copy)
@@ -4317,7 +4317,7 @@
              (const char **)&ssl_ports_list);
         prefs_register_string_preference(ssl_module, "debug_file", "SSL debug file",
              "redirect ssl debug to file name; leave empty to disable debug, "
-             "use %s to redirect output to stderr\n",
+             "use \""SSL_DEBUG_USE_STDERR"\" to redirect output to stderr\n",
              (const char **)&ssl_debug_file_name);
     }