A new field information flag, FI_URL, to indicate a field contains a URL.

This is used to display the field underlined and to allow the user to double-click on it (like FT_FRAMENUM) to open the URL in the configured browser. 
Example usage in the x509ce and logotype certificate extensions. 


svn path=/trunk/; revision=19383
This commit is contained in:
Graeme Lunt 2006-09-30 14:37:09 +00:00
parent 3da46255fe
commit 23937f82c7
7 changed files with 40 additions and 4 deletions

View File

@ -14,6 +14,11 @@ LogotypeExtn B "1.3.6.1.5.5.7.1.12" "id-pe-logotype"
LogotypeExtn B "1.3.6.1.5.5.7.20.1" "id-pe-logo-loyalty"
LogotypeExtn B "1.3.6.1.5.5.7.20.2" "id-pe-logo-background"
#.FN_FTR IA5String
if((hf_index == hf_logotypecertextn_logotypeURI_item) ||
(hf_index == hf_logotypecertextn_refStructURI_item))
PROTO_ITEM_SET_URL(get_ber_last_created_item());
#.NO_EMIT
#.TYPE_RENAME

View File

@ -1,6 +1,6 @@
# Do not modify this file.
# It is created automatically by the ASN.1 to Wireshark dissector compiler
# .\x509ce-exp.cnf
# ./x509ce-exp.cnf
# ../../tools/asn2wrs.py -b -e -p x509ce -c x509ce.cnf -s packet-x509ce-template CertificateExtensions.asn
#.MODULE

View File

@ -119,6 +119,10 @@ CertificatePairExactAssertion/issuedByThisCAAssertion cpea_issuedByThisCAAsserti
#.FN_BODY OtherNameValue
offset=call_ber_oid_callback(object_identifier_id, tvb, offset, pinfo, tree);
#.FN_FTR IA5String
if(hf_index == hf_x509ce_uniformResourceIdentifier)
PROTO_ITEM_SET_URL(get_ber_last_created_item());
#.END

View File

@ -1,6 +1,6 @@
/* Do not modify this file. */
/* It is created automatically by the ASN.1 to Wireshark dissector compiler */
/* .\packet-logotypecertextn.c */
/* ./packet-logotypecertextn.c */
/* ../../tools/asn2wrs.py -b -e -p logotypecertextn -c logotype-cert-extn.cnf -s packet-logotype-cert-extn-template LogotypeCertExtn.asn */
/* Input file: packet-logotype-cert-extn-template.c */
@ -144,6 +144,12 @@ dissect_logotypecertextn_IA5String(gboolean implicit_tag _U_, tvbuff_t *tvb, int
pinfo, tree, tvb, offset, hf_index,
NULL);
#line 18 "logotype-cert-extn.cnf"
if((hf_index == hf_logotypecertextn_logotypeURI_item) ||
(hf_index == hf_logotypecertextn_refStructURI_item))
PROTO_ITEM_SET_URL(get_ber_last_created_item());
return offset;
}
static int dissect_mediaType(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {

View File

@ -1,6 +1,6 @@
/* Do not modify this file. */
/* It is created automatically by the ASN.1 to Wireshark dissector compiler */
/* .\packet-x509ce.c */
/* ./packet-x509ce.c */
/* ../../tools/asn2wrs.py -b -e -p x509ce -c x509ce.cnf -s packet-x509ce-template CertificateExtensions.asn */
/* Input file: packet-x509ce-template.c */
@ -386,6 +386,11 @@ dissect_x509ce_IA5String(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, p
pinfo, tree, tvb, offset, hf_index,
NULL);
#line 123 "x509ce.cnf"
if(hf_index == hf_x509ce_uniformResourceIdentifier)
PROTO_ITEM_SET_URL(get_ber_last_created_item());
return offset;
}
static int dissect_rfc822Name_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {

View File

@ -211,6 +211,8 @@ typedef struct field_info {
/** The protocol field should be displayed as "generated by Wireshark",
* used in field_info.flags. */
#define FI_GENERATED 0x0002
/* The protocol field is actually a URL */
#define FI_URL 0x0004
/** convenience macro to get field_info.flags */
@ -290,6 +292,12 @@ typedef proto_node proto_item;
/** mark this protocol field as generated by Wireshark (and not read from the packet data) */
#define PROTO_ITEM_SET_GENERATED(proto_item) \
((proto_item) ? FI_SET_FLAG((proto_item)->finfo, FI_GENERATED) : 0)
/* is this protocol field actually a URL */
#define PROTO_ITEM_IS_URL(proto_item) \
((proto_item) ? FI_GET_FLAG((proto_item)->finfo, FI_URL) : 0)
/* mark this protocol field as a URL */
#define PROTO_ITEM_SET_URL(proto_item) \
((proto_item) ? FI_SET_FLAG((proto_item)->finfo, FI_URL) : 0)
typedef void (*proto_tree_foreach_func)(proto_node *, gpointer);

View File

@ -1721,7 +1721,8 @@ static void tree_cell_renderer(GtkTreeViewColumn *tree_column _U_,
g_object_set (cell, "weight-set", TRUE, NULL);*/
}
if(fi->hfinfo->type == FT_FRAMENUM) {
if((fi->hfinfo->type == FT_FRAMENUM) ||
(FI_GET_FLAG(fi, FI_URL) && IS_FT_STRING(fi->hfinfo->type))) {
g_object_set (cell, "foreground", "blue", NULL);
g_object_set (cell, "foreground-set", TRUE, NULL);
@ -1939,9 +1940,16 @@ main_proto_tree_draw(proto_tree *protocol_tree)
static void
tree_view_follow_link(field_info *fi)
{
gchar *url;
if(fi->hfinfo->type == FT_FRAMENUM) {
cf_goto_frame(&cfile, fi->value.value.integer);
}
if(FI_GET_FLAG(fi, FI_URL) && IS_FT_STRING(fi->hfinfo->type)) {
url = g_strndup(tvb_get_ptr(fi->ds_tvb, fi->start, fi->length), fi->length);
browser_open_url(url);
g_free(url);
}
}