OID Field Information

"Graeme Lunt" <[email protected]>
Newsgroups gmane.network.ethereal.devel
Message-ID <[email protected]>
Hi,

I have developed a patch so that if the user chooses "Field Information" (a
new context menu item) on a field type of FT_OID, a web page will be brought
up with their preferred reference page. (e.g.
http://www.alvestrand.no/objectid/2.5.18.5.html)

I just wanted to check that this is an appropriate way to go about it before
I check it in.
Specifically:
a) Is it architecturally correct to reference a dissector (packet-ber) from
the gtk\ portion of the tree?
b) Would a "link" style (like FT_FRAMENUM) be better than extending the
context menu?

There is a diff attached for the gtk/ files (packet-ber.[ch] patch not
included).

Comments?

Graeme

_______________________________________________
Ethereal-dev mailing list
[email protected]
http://www.ethereal.com/mailman/listinfo/ethereal-dev
fieldinfo.diff (application/octet-stream, 2.9 KB)
Index: gtk/menu.c
===================================================================
--- gtk/menu.c	(revision 18023)
+++ gtk/menu.c	(working copy)
@@ -519,6 +519,8 @@
                        0, ETHEREAL_STOCK_WIKI),
     ITEM_FACTORY_STOCK_ENTRY("/Filter Field Reference", NULL, selected_ptree_ref_cb,
                        0, ETHEREAL_STOCK_INTERNET),
+    ITEM_FACTORY_STOCK_ENTRY("/Field Information", NULL, selected_ptree_field_url_cb,
+                       0, ETHEREAL_STOCK_INTERNET),
     ITEM_FACTORY_ENTRY("/Protocol Preferences...", NULL, properties_cb,
                        0, NULL, NULL),
     ITEM_FACTORY_ENTRY("/<separator>", NULL, NULL, 0, "<Separator>", NULL),
@@ -2135,6 +2137,8 @@
 	  TRUE);
 	set_menu_sensitivity(tree_view_menu_factory, "/Filter Field Reference",
 	  TRUE);
+	set_menu_sensitivity(tree_view_menu_factory, "/Field Information",
+			     selected_ptree_has_field_url());
   } else {
 	set_menu_sensitivity(main_menu_factory,
 	    "/Go/Go to Corresponding Packet", FALSE);
@@ -2152,6 +2156,8 @@
 	  FALSE);
 	set_menu_sensitivity(tree_view_menu_factory, "/Filter Field Reference",
 	  FALSE);
+	set_menu_sensitivity(tree_view_menu_factory, "/Field Information",
+	  FALSE);
   }
 
   walk_menu_tree_for_selected_tree_row(tap_menu_tree_root, cf->finfo_selected);
Index: gtk/main.c
===================================================================
--- gtk/main.c	(revision 18023)
+++ gtk/main.c	(working copy)
@@ -89,6 +89,7 @@
 #include "cmdarg_err.h"
 #include "version_info.h"
 #include "merge.h"
+#include <epan/dissectors/packet-ber.h>
 
 #ifdef HAVE_LIBPCAP
 #include "capture-pcap-util.h"
@@ -379,7 +380,29 @@
     }
 }
 
+void
+selected_ptree_field_url_cb(GtkWidget *widget _U_, gpointer data _U_)
+{
+  gchar *selected_info_url;
 
+  /* only OIDs for now */
+  if(cfile.finfo_selected->hfinfo->type == FT_OID) {
+    if(ber_get_oid_url(cfile.finfo_selected, &selected_info_url)) {
+      browser_open_url(selected_info_url);
+      g_free(selected_info_url);
+    }
+  }
+}
+
+gboolean selected_ptree_has_field_url()
+{
+  /* only OIDs for now */
+  if(cfile.finfo_selected->hfinfo->type == FT_OID) 
+    return ber_get_oid_url(cfile.finfo_selected, NULL);
+
+  return FALSE;
+}
+
 static gchar *
 get_text_from_packet_list(gpointer data)
 {
Index: gtk/main.h
===================================================================
--- gtk/main.h	(revision 18023)
+++ gtk/main.h	(working copy)
@@ -105,7 +105,18 @@
  */
 extern void selected_ptree_ref_cb(GtkWidget *widget, gpointer data);
 
+/** User requested "Field Information" by ptree context menu.
+ *
+ * @param widget parent widget (unused)
+ * @param data unused
+ */
+extern void selected_ptree_field_url_cb(GtkWidget *widget, gpointer data);
 
+/** Determine if "Field Information" should be enabled in ptree context menu.
+ *
+ */
+extern gboolean selected_ptree_has_field_url();
+
 /** "Apply as Filter" / "Prepare a Filter" action type. */
 typedef enum {
     MATCH_SELECTED_REPLACE, /**< "Selected" */
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.