"Field Information" context menu item that will bring up a web page reference to a field type of FT_OID
svn path=/trunk/; revision=18125
This commit is contained in:
parent
30fc91887c
commit
ab19b927c8
|
@ -138,7 +138,7 @@ void proto_register_cms(void) {
|
|||
static hf_register_info hf[] = {
|
||||
{ &hf_cms_ci_contentType,
|
||||
{ "contentType", "cms.contentInfo.contentType",
|
||||
FT_STRING, BASE_NONE, NULL, 0,
|
||||
FT_OID, BASE_NONE, NULL, 0,
|
||||
"ContentType", HFILL }},
|
||||
#include "packet-cms-hfarr.c"
|
||||
};
|
||||
|
|
|
@ -2331,7 +2331,7 @@ proto_register_ber(void)
|
|||
"OCTETSTRING", "ber.unknown.OCTETSTRING", FT_BYTES, BASE_HEX,
|
||||
NULL, 0, "This is an unknown OCTETSTRING", HFILL }},
|
||||
{ &hf_ber_unknown_OID, {
|
||||
"OID", "ber.unknown.OID", FT_STRING, BASE_NONE,
|
||||
"OID", "ber.unknown.OID", FT_OID, BASE_NONE,
|
||||
NULL, 0, "This is an unknown Object Identifier", HFILL }},
|
||||
{ &hf_ber_unknown_GraphicString, {
|
||||
"GRAPHICSTRING", "ber.unknown.GRAPHICSTRING", FT_STRING, BASE_HEX,
|
||||
|
|
|
@ -1599,7 +1599,7 @@ void proto_register_cms(void) {
|
|||
static hf_register_info hf[] = {
|
||||
{ &hf_cms_ci_contentType,
|
||||
{ "contentType", "cms.contentInfo.contentType",
|
||||
FT_STRING, BASE_NONE, NULL, 0,
|
||||
FT_OID, BASE_NONE, NULL, 0,
|
||||
"ContentType", HFILL }},
|
||||
|
||||
/*--- Included file: packet-cms-hfarr.c ---*/
|
||||
|
|
|
@ -411,6 +411,7 @@ nt_cmd_vals DATA
|
|||
num_tap_filters DATA
|
||||
num_tree_types DATA
|
||||
offset_from_real_beginning
|
||||
oid_get_url
|
||||
other_decode_bitfield_value
|
||||
plugin_list DATA
|
||||
postseq_cleanup_all_protocols
|
||||
|
|
|
@ -35,6 +35,9 @@
|
|||
|
||||
static GHashTable *oid_table = NULL;
|
||||
|
||||
/* this should be configurable - but where ? */
|
||||
static const gchar *oid_url_template = "http://www.alvestrand.no/objectid/%s.html";
|
||||
|
||||
void oid_resolv_init(void) {
|
||||
oid_table = g_hash_table_new(g_str_hash, g_str_equal);
|
||||
}
|
||||
|
@ -95,3 +98,29 @@ extern void add_oid_name(const guint8 *oid, gint oid_len, const gchar *name) {
|
|||
extern void add_oid_str_name(const gchar *oid_str, const gchar *name) {
|
||||
g_hash_table_insert(oid_table, (gpointer)g_strdup(oid_str), (gpointer)name);
|
||||
}
|
||||
|
||||
gboolean get_oid_url(field_info *finfo, gchar **ret_url)
|
||||
{
|
||||
const char *oid;
|
||||
|
||||
if(finfo && (finfo->hfinfo->type == FT_OID) &&
|
||||
(oid_url_template != NULL) && (*oid_url_template != NULL)) {
|
||||
if(ret_url) {
|
||||
/* return the URL */
|
||||
oid = oid_to_str(tvb_get_ptr(finfo->ds_tvb, finfo->start, finfo->length),
|
||||
finfo->length);
|
||||
|
||||
/* the URL will be freed */
|
||||
*ret_url = g_strdup_printf(oid_url_template, oid);
|
||||
return TRUE;
|
||||
} else {
|
||||
/* return TRUE if we are configured to return URLs */
|
||||
|
||||
if((oid_url_template != NULL) && (*oid_url_template != NULL))
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
#ifndef __OID_RESOLV_H__
|
||||
#define __OID_RESOLV_H__
|
||||
|
||||
#include <epan/proto.h>
|
||||
|
||||
/* init and clenup funcions called from epan.h */
|
||||
extern void oid_resolv_init(void);
|
||||
extern void oid_resolv_cleanup(void);
|
||||
|
@ -46,5 +48,8 @@ extern const gchar *get_oid_str_name(const gchar *oid_str);
|
|||
extern void add_oid_name(const guint8 *oid, gint oid_len, const gchar *name);
|
||||
extern void add_oid_str_name(const gchar *oid_str, const gchar *name);
|
||||
|
||||
/* get a URL for an OID in the given field */
|
||||
/* if ret_url is NULL, just return TRUE if we are configured to provide one */
|
||||
extern gboolean get_oid_url(field_info *finfo, gchar **ret_url);
|
||||
|
||||
#endif /* __OID_RESOLV_H__ */
|
||||
|
|
23
gtk/main.c
23
gtk/main.c
|
@ -89,6 +89,7 @@
|
|||
#include "cmdarg_err.h"
|
||||
#include "version_info.h"
|
||||
#include "merge.h"
|
||||
#include <epan/oid_resolv.h>
|
||||
|
||||
#ifdef HAVE_LIBPCAP
|
||||
#include "capture-pcap-util.h"
|
||||
|
@ -382,6 +383,28 @@ selected_ptree_ref_cb(GtkWidget *widget _U_, gpointer data _U_)
|
|||
}
|
||||
}
|
||||
|
||||
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(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 get_oid_url(cfile.finfo_selected, NULL);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gchar *
|
||||
get_text_from_packet_list(gpointer data)
|
||||
|
|
11
gtk/main.h
11
gtk/main.h
|
@ -105,6 +105,17 @@ extern void selected_ptree_info_cb(GtkWidget *widget, gpointer data);
|
|||
*/
|
||||
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 {
|
||||
|
|
|
@ -519,6 +519,8 @@ static GtkItemFactoryEntry tree_view_menu_items[] =
|
|||
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 @@ set_menus_for_selected_tree_row(capture_file *cf)
|
|||
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 @@ set_menus_for_selected_tree_row(capture_file *cf)
|
|||
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);
|
||||
|
|
Loading…
Reference in New Issue