Have separate proto_construct_match_selected_string() and
[obnox/wireshark/wip.git] / epan / proto.h
index 50618acf98ffe065d71fdf810bb001d9628ce1f8..361d5ecd014fa741dd528bb46602f6292ab9491c 100644 (file)
@@ -3,8 +3,8 @@
  *
  * $Id$
  *
- * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@ethereal.com>
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
  * Copyright 1998 Gerald Combs
  *
  * This program is free software; you can redistribute it and/or
 
 #include <glib.h>
 
+#include "gnuc_format_check.h"
 #include "ipv4.h"
 #include "nstime.h"
 #include "tvbuff.h"
 #include "ftypes/ftypes.h"
 
-/** The header-field index for the special text pseudo-field. Exported by libethereal.dll */
-ETH_VAR_IMPORT int hf_text_only;
+/** The header-field index for the special text pseudo-field. Exported by libwireshark.dll */
+WS_VAR_IMPORT int hf_text_only;
 
 /** the maximum length of a protocol field string representation */
 #define ITEM_LABEL_LENGTH      240
@@ -83,13 +84,18 @@ typedef struct _protocol protocol_t;
  * as the message for the exception, so that it can show up in
  * the Info column and the protocol tree.
  *
- * That string should be allocated with g_malloc(); using
- * "g_strdup_printf()" would work.
+ * If that string is dynamically allocated, it should be allocated with
+ * ep_alloc(); using ep_strdup_printf() would work.
+ *
+ * If the WIRESHARK_ABORT_ON_DISSECTOR_BUG environment variable is set,
+ * it will call abort(), instead, to make it easier to get a stack trace.
  *
  * @param message string to use as the message
  */
 #define REPORT_DISSECTOR_BUG(message)  \
-  (THROW_MESSAGE(DissectorError, message))
+  ((getenv("WIRESHARK_ABORT_ON_DISSECTOR_BUG") != NULL) ? \
+    abort() : \
+    THROW_MESSAGE(DissectorError, message))
 
 /** Macro used for assertions in dissectors; it doesn't abort, it just
  * throws a DissectorError exception, with the assertion failure
@@ -113,29 +119,16 @@ typedef struct _protocol protocol_t;
  */
 #define DISSECTOR_ASSERT_NOT_REACHED()  \
   (REPORT_DISSECTOR_BUG( \
-    g_strdup_printf("%s:%u: failed assertion \"DISSECTOR_ASSERT_NOT_REACHED\"", \
+    ep_strdup_printf("%s:%u: failed assertion \"DISSECTOR_ASSERT_NOT_REACHED\"", \
      __FILE__, __LINE__)))
 
 #define __DISSECTOR_ASSERT_STRINGIFY(s)        # s
 
 #define __DISSECTOR_ASSERT(expression, file, lineno)  \
   (REPORT_DISSECTOR_BUG( \
-    g_strdup_printf("%s:%u: failed assertion \"%s\"", \
+    ep_strdup_printf("%s:%u: failed assertion \"%s\"", \
      file, lineno, __DISSECTOR_ASSERT_STRINGIFY(expression))))
 
-/** GNUC has the ability to check format strings that follow the syntax used in printf and others.
- Hide the differences between different compilers in this GNUC_FORMAT_CHECK macro.
- @param archetype one of: printf, scanf, strftime or strfmon
- @param string_index specifies which argument is the format string argument (starting from 1)
- @param first_to_check is the number of the first argument to check against the format string
- @todo as this check is also done at some other places too, move this macro to a more central place? */
-#if __GNUC__ >= 2
-       #define GNUC_FORMAT_CHECK(archetype, string_index, first_to_check) __attribute__((format (archetype, string_index, first_to_check)))
-#else
-       #define GNUC_FORMAT_CHECK(archetype, string_index, first_to_check)
-#endif
-
-
 /** radix for decimal values, used in header_field_info.display */
 typedef enum {
        BASE_NONE,      /**< none */
@@ -215,9 +208,11 @@ typedef struct field_info {
  * used in field_info.flags. */
 /* HIDING PROTOCOL FIELDS IS DEPRECATED, IT'S CONSIDERED TO BE BAD GUI DESIGN! */
 #define FI_HIDDEN                      0x0001
-/** The protocol field should be displayed as "generated by Ethereal",
+/** 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 */
@@ -230,6 +225,7 @@ typedef struct field_info {
 typedef struct {
     GHashTable  *interesting_hfids;
     gboolean    visible;
+    gint        count;
 } tree_data_t;
 
 /** Each proto_tree, proto_item is one of these. */
@@ -266,6 +262,8 @@ typedef proto_node proto_item;
 #define PI_SEQUENCE                    0x0200
 /** The protocol field indicates a bad application response code (e.g. HTTP 404), usually PI_NOTE */
 #define PI_RESPONSE_CODE       0x0400
+/** The protocol field indicates an application request (e.g. File Handle == xxxx), usually PI_CHAT */
+#define PI_REQUEST_CODE            0x0500
 /** The data is undecoded, the protocol dissection is incomplete here, usually PI_WARN */
 #define PI_UNDECODED           0x0800
 /** The protocol field indicates a reassemble (e.g. DCE/RPC defragmentation), usually PI_CHAT (or PI_ERROR) */
@@ -277,7 +275,7 @@ typedef proto_node proto_item;
 /** The protocol field indicates a security probem (e.g. unsecure implementation) */
 /*#define PI_SECURITY                  0x8000*/
 
-/* add more, see http://wiki.ethereal.com/Development/ExpertInfo */
+/* add more, see http://wiki.wireshark.org/Development/ExpertInfo */
 
 
 /** is this protocol field hidden from the protocol tree display (used for filtering only)? */
@@ -288,12 +286,18 @@ typedef proto_node proto_item;
 /* HIDING PROTOCOL FIELDS IS DEPRECATED, IT'S CONSIDERED TO BE BAD GUI DESIGN! */
 #define PROTO_ITEM_SET_HIDDEN(proto_item)       \
        ((proto_item) ? FI_SET_FLAG((proto_item)->finfo, FI_HIDDEN) : 0)
-/** is this protocol field generated by Ethereal (and not read from the packet data)? */
+/** is this protocol field generated by Wireshark (and not read from the packet data)? */
 #define PROTO_ITEM_IS_GENERATED(proto_item)    \
        ((proto_item) ? FI_GET_FLAG((proto_item)->finfo, FI_GENERATED) : 0)
-/** mark this protocol field as generated by Ethereal (and not read from the packet data) */
+/** 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);
 
@@ -325,7 +329,7 @@ extern void proto_cleanup(void);
     you will still need to call any subdissector with the original value of 
     tree or filtering will break.
 
-    The purpose of this is to optimize ethereal for speed and make it
+    The purpose of this is to optimize wireshark for speed and make it
     faster for when filters are being used.
 */
 extern gboolean proto_field_is_referenced(proto_tree *tree, int proto_id);
@@ -394,8 +398,8 @@ extern int proto_item_get_len(proto_item *ti);
 /**
  * Sets an expert info to the proto_item.
  @param ti the item to set the expert info
- @param group the group of this info (e.g. FI_CHECKSUM)
- @param severity of this info (e.g. FI_ERROR)
+ @param group the group of this info (e.g. PI_CHECKSUM)
+ @param severity of this info (e.g. PI_ERROR)
  @return TRUE if value was written
  */
 extern gboolean proto_item_set_expert_flags(proto_item *ti, int group, int severity);
@@ -432,6 +436,11 @@ proto_tree_prime_hfid(proto_tree *tree, int hfid);
  @return parent item */
 extern proto_item* proto_tree_get_parent(proto_tree *tree);
 
+/** Get the root tree from any subtree.
+ @param tree the tree to get the root from
+ @return root tree */
+extern proto_tree* proto_tree_get_root(proto_tree *tree);
+
 /** Move an existing item behind another existing item.
  @param tree the tree to which both items belong
  @param fixed_item the item which keeps it's position
@@ -531,7 +540,25 @@ extern proto_item *
 proto_tree_add_bytes_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
        gint length, const guint8* start_ptr);
 
-/** Add a formatted FT_BYTES to a proto_tree.
+/** Add a formatted FT_BYTES to a proto_tree, with the format generating
+    the string for the value and with the field name being included
+    automatically.
+ @param tree the tree to append this item to
+ @param hfindex field index
+ @param tvb the tv buffer of the current data
+ @param start start of data in tvb
+ @param length length of data in tvb
+ @param start_ptr pointer to the data to display
+ @param format printf like format string
+ @param ... printf like parameters
+ @return the newly created item */
+extern proto_item *
+proto_tree_add_bytes_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
+       gint start, gint length, const guint8* start_ptr, const char *format,
+       ...) GNUC_FORMAT_CHECK(printf,7,8);
+
+/** Add a formatted FT_BYTES to a proto_tree, with the format generating
+    the entire string for the entry, including any field name.
  @param tree the tree to append this item to
  @param hfindex field index
  @param tvb the tv buffer of the current data
@@ -563,7 +590,26 @@ extern proto_item *
 proto_tree_add_time_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
        gint length, nstime_t* value_ptr);
 
-/** Add a formatted FT_ABSOLUTE_TIME or FT_RELATIVE_TIME to a proto_tree.
+/** Add a formatted FT_ABSOLUTE_TIME or FT_RELATIVE_TIME to a proto_tree, with
+    the format generating the string for the value and with the field name
+    being included automatically.
+ @param tree the tree to append this item to
+ @param hfindex field index
+ @param tvb the tv buffer of the current data
+ @param start start of data in tvb
+ @param length length of data in tvb
+ @param value_ptr pointer to the data to display
+ @param format printf like format string
+ @param ... printf like parameters
+ @return the newly created item */
+extern proto_item *
+proto_tree_add_time_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
+       gint start, gint length, nstime_t* value_ptr, const char *format, ...)
+       GNUC_FORMAT_CHECK(printf,7,8);
+
+/** Add a formatted FT_ABSOLUTE_TIME or FT_RELATIVE_TIME to a proto_tree, with
+    the format generating the entire string for the entry, including any field
+    name.
  @param tree the tree to append this item to
  @param hfindex field index
  @param tvb the tv buffer of the current data
@@ -595,7 +641,25 @@ extern proto_item *
 proto_tree_add_ipxnet_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
        gint length, guint32 value);
 
-/** Add a formatted FT_IPXNET to a proto_tree.
+/** Add a formatted FT_IPXNET to a proto_tree, with the format generating
+    the string for the value and with the field name being included
+    automatically.
+ @param tree the tree to append this item to
+ @param hfindex field index
+ @param tvb the tv buffer of the current data
+ @param start start of data in tvb
+ @param length length of data in tvb
+ @param value data to display
+ @param format printf like format string
+ @param ... printf like parameters
+ @return the newly created item */
+extern proto_item *
+proto_tree_add_ipxnet_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
+       gint start, gint length, guint32 value, const char *format, ...)
+       GNUC_FORMAT_CHECK(printf,7,8);
+
+/** Add a formatted FT_IPXNET to a proto_tree, with the format generating
+    the entire string for the entry, including any field name.
  @param tree the tree to append this item to
  @param hfindex field index
  @param tvb the tv buffer of the current data
@@ -627,7 +691,25 @@ extern proto_item *
 proto_tree_add_ipv4_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
        gint length, guint32 value);
 
-/** Add a formatted FT_IPv4 to a proto_tree.
+/** Add a formatted FT_IPv4 to a proto_tree, with the format generating
+    the string for the value and with the field name being included
+    automatically.
+ @param tree the tree to append this item to
+ @param hfindex field index
+ @param tvb the tv buffer of the current data
+ @param start start of data in tvb
+ @param length length of data in tvb
+ @param value data to display
+ @param format printf like format string
+ @param ... printf like parameters
+ @return the newly created item */
+extern proto_item *
+proto_tree_add_ipv4_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
+       gint start, gint length, guint32 value, const char *format, ...)
+       GNUC_FORMAT_CHECK(printf,7,8);
+
+/** Add a formatted FT_IPv4 to a proto_tree, with the format generating
+    the entire string for the entry, including any field name.
  @param tree the tree to append this item to
  @param hfindex field index
  @param tvb the tv buffer of the current data
@@ -659,7 +741,25 @@ extern proto_item *
 proto_tree_add_ipv6_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
        gint length, const guint8* value_ptr);
 
-/** Add a formatted FT_IPv6 to a proto_tree.
+/** Add a formatted FT_IPv6 to a proto_tree, with the format generating
+    the string for the value and with the field name being included
+    automatically.
+ @param tree the tree to append this item to
+ @param hfindex field index
+ @param tvb the tv buffer of the current data
+ @param start start of data in tvb
+ @param length length of data in tvb
+ @param value_ptr data to display
+ @param format printf like format string
+ @param ... printf like parameters
+ @return the newly created item */
+extern proto_item *
+proto_tree_add_ipv6_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
+       gint start, gint length, const guint8* value_ptr, const char *format,
+       ...) GNUC_FORMAT_CHECK(printf,7,8);
+
+/** Add a formatted FT_IPv6 to a proto_tree, with the format generating
+    the entire string for the entry, including any field name.
  @param tree the tree to append this item to
  @param hfindex field index
  @param tvb the tv buffer of the current data
@@ -691,7 +791,25 @@ extern proto_item *
 proto_tree_add_ether_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
        gint length, const guint8* value);
 
-/** Add a formatted FT_ETHER to a proto_tree.
+/** Add a formatted FT_ETHER to a proto_tree, with the format generating
+    the string for the value and with the field name being included
+    automatically.
+ @param tree the tree to append this item to
+ @param hfindex field index
+ @param tvb the tv buffer of the current data
+ @param start start of data in tvb
+ @param length length of data in tvb
+ @param value data to display
+ @param format printf like format string
+ @param ... printf like parameters
+ @return the newly created item */
+extern proto_item *
+proto_tree_add_ether_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
+       gint start, gint length, const guint8* value, const char *format, ...)
+       GNUC_FORMAT_CHECK(printf,7,8);
+
+/** Add a formatted FT_ETHER to a proto_tree, with the format generating
+    the entire string for the entry, including any field name.
  @param tree the tree to append this item to
  @param hfindex field index
  @param tvb the tv buffer of the current data
@@ -715,15 +833,33 @@ proto_tree_add_ether_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint s
  @return the newly created item */
 extern proto_item *
 proto_tree_add_guid(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
-       gint length, const guint8* value_ptr);
+       gint length, const e_guid_t *value_ptr);
 
 /** Add a hidden FT_GUID to a proto_tree.
  @deprecated use proto_tree_add_guid() and a subsequent call to PROTO_ITEM_SET_HIDDEN() instead */
 extern proto_item *
 proto_tree_add_guid_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
-       gint length, const guint8* value_ptr);
+       gint length, const e_guid_t *value_ptr);
+
+/** Add a formatted FT_GUID to a proto_tree, with the format generating
+    the string for the value and with the field name being included
+    automatically.
+ @param tree the tree to append this item to
+ @param hfindex field index
+ @param tvb the tv buffer of the current data
+ @param start start of data in tvb
+ @param length length of data in tvb
+ @param value_ptr data to display
+ @param format printf like format string
+ @param ... printf like parameters
+ @return the newly created item */
+extern proto_item *
+proto_tree_add_guid_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
+       gint start, gint length, const e_guid_t *value_ptr, const char *format,
+       ...) GNUC_FORMAT_CHECK(printf,7,8);
 
-/** Add a formatted FT_GUID to a proto_tree.
+/** Add a formatted FT_GUID to a proto_tree, with the format generating
+    the entire string for the entry, including any field name.
  @param tree the tree to append this item to
  @param hfindex field index
  @param tvb the tv buffer of the current data
@@ -735,6 +871,56 @@ proto_tree_add_guid_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint st
  @return the newly created item */
 extern proto_item *
 proto_tree_add_guid_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
+       gint length, const e_guid_t *value_ptr, const char *format, ...) GNUC_FORMAT_CHECK(printf,7,8);
+
+/** Add a FT_OID to a proto_tree.
+ @param tree the tree to append this item to
+ @param hfindex field index
+ @param tvb the tv buffer of the current data
+ @param start start of data in tvb
+ @param length length of data in tvb
+ @param value_ptr data to display
+ @return the newly created item */
+extern proto_item *
+proto_tree_add_oid(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
+       gint length, const guint8* value_ptr);
+
+/** Add a hidden FT_OID to a proto_tree.
+ @deprecated use proto_tree_add_oid() and a subsequent call to PROTO_ITEM_SET_HIDDEN() instead */
+extern proto_item *
+proto_tree_add_oid_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
+       gint length, const guint8* value_ptr);
+
+/** Add a formatted FT_OID to a proto_tree, with the format generating
+    the string for the value and with the field name being included
+    automatically.
+ @param tree the tree to append this item to
+ @param hfindex field index
+ @param tvb the tv buffer of the current data
+ @param start start of data in tvb
+ @param length length of data in tvb
+ @param value_ptr data to display
+ @param format printf like format string
+ @param ... printf like parameters
+ @return the newly created item */
+extern proto_item *
+proto_tree_add_oid_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
+       gint start, gint length, const guint8* value_ptr, const char *format,
+       ...) GNUC_FORMAT_CHECK(printf,7,8);
+
+/** Add a formatted FT_OID to a proto_tree, with the format generating
+    the entire string for the entry, including any field name.
+ @param tree the tree to append this item to
+ @param hfindex field index
+ @param tvb the tv buffer of the current data
+ @param start start of data in tvb
+ @param length length of data in tvb
+ @param value_ptr data to display
+ @param format printf like format string
+ @param ... printf like parameters
+ @return the newly created item */
+extern proto_item *
+proto_tree_add_oid_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
        gint length, const guint8* value_ptr, const char *format, ...) GNUC_FORMAT_CHECK(printf,7,8);
 
 /** Add a FT_STRING to a proto_tree.
@@ -755,7 +941,25 @@ extern proto_item *
 proto_tree_add_string_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
        gint length, const char* value);
 
-/** Add a formatted FT_STRING to a proto_tree.
+/** Add a formatted FT_STRING to a proto_tree, with the format generating
+    the string for the value and with the field name being included
+    automatically.
+ @param tree the tree to append this item to
+ @param hfindex field index
+ @param tvb the tv buffer of the current data
+ @param start start of data in tvb
+ @param length length of data in tvb
+ @param value data to display
+ @param format printf like format string
+ @param ... printf like parameters
+ @return the newly created item */
+extern proto_item *
+proto_tree_add_string_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
+       gint start, gint length, const char* value, const char *format, ...)
+       GNUC_FORMAT_CHECK(printf,7,8);
+
+/** Add a formatted FT_STRING to a proto_tree, with the format generating
+    the entire string for the entry, including any field name.
  @param tree the tree to append this item to
  @param hfindex field index
  @param tvb the tv buffer of the current data
@@ -787,7 +991,25 @@ extern proto_item *
 proto_tree_add_boolean_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
        gint length, guint32 value);
 
-/** Add a formatted FT_BOOLEAN to a proto_tree.
+/** Add a formatted FT_BOOLEAN to a proto_tree, with the format generating
+    the string for the value and with the field name being included
+    automatically.
+ @param tree the tree to append this item to
+ @param hfindex field index
+ @param tvb the tv buffer of the current data
+ @param start start of data in tvb
+ @param length length of data in tvb
+ @param value data to display
+ @param format printf like format string
+ @param ... printf like parameters
+ @return the newly created item */
+extern proto_item *
+proto_tree_add_boolean_format_value(proto_tree *tree, int hfindex,
+       tvbuff_t *tvb, gint start, gint length, guint32 value,
+       const char *format, ...) GNUC_FORMAT_CHECK(printf,7,8);
+
+/** Add a formatted FT_BOOLEAN to a proto_tree, with the format generating
+    the entire string for the entry, including any field name.
  @param tree the tree to append this item to
  @param hfindex field index
  @param tvb the tv buffer of the current data
@@ -819,7 +1041,25 @@ extern proto_item *
 proto_tree_add_float_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
        gint length, float value);
 
-/** Add a formatted FT_FLOAT to a proto_tree.
+/** Add a formatted FT_FLOAT to a proto_tree, with the format generating
+    the string for the value and with the field name being included
+    automatically.
+ @param tree the tree to append this item to
+ @param hfindex field index
+ @param tvb the tv buffer of the current data
+ @param start start of data in tvb
+ @param length length of data in tvb
+ @param value data to display
+ @param format printf like format string
+ @param ... printf like parameters
+ @return the newly created item */
+extern proto_item *
+proto_tree_add_float_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
+       gint start, gint length, float value, const char *format, ...)
+       GNUC_FORMAT_CHECK(printf,7,8);
+
+/** Add a formatted FT_FLOAT to a proto_tree, with the format generating
+    the entire string for the entry, including any field name.
  @param tree the tree to append this item to
  @param hfindex field index
  @param tvb the tv buffer of the current data
@@ -851,7 +1091,25 @@ extern proto_item *
 proto_tree_add_double_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
        gint length, double value);
 
-/** Add a formatted FT_DOUBLE to a proto_tree.
+/** Add a formatted FT_DOUBLE to a proto_tree, with the format generating
+    the string for the value and with the field name being included
+    automatically.
+ @param tree the tree to append this item to
+ @param hfindex field index
+ @param tvb the tv buffer of the current data
+ @param start start of data in tvb
+ @param length length of data in tvb
+ @param value data to display
+ @param format printf like format string
+ @param ... printf like parameters
+ @return the newly created item */
+extern proto_item *
+proto_tree_add_double_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
+       gint start, gint length, double value, const char *format, ...)
+       GNUC_FORMAT_CHECK(printf,7,8);
+
+/** Add a formatted FT_DOUBLE to a proto_tree, with the format generating
+    the entire string for the entry, including any field name.
  @param tree the tree to append this item to
  @param hfindex field index
  @param tvb the tv buffer of the current data
@@ -877,13 +1135,32 @@ extern proto_item *
 proto_tree_add_uint(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
        gint length, guint32 value);
 
-/** Add a hidden of one of FT_UINT8, FT_UINT16, FT_UINT24 or FT_UINT32 to a proto_tree.
+/** Add a hidden FT_UINT8, FT_UINT16, FT_UINT24 or FT_UINT32 to a proto_tree.
  @deprecated use proto_tree_add_uint() and a subsequent call to PROTO_ITEM_SET_HIDDEN() instead */
 extern proto_item *
 proto_tree_add_uint_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
        gint length, guint32 value);
 
-/** Add a formatted of one of FT_UINT8, FT_UINT16, FT_UINT24 or FT_UINT32 to a proto_tree.
+/** Add a formatted FT_UINT8, FT_UINT16, FT_UINT24 or FT_UINT32 to a proto_tree,
+    with the format generating the string for the value and with the field
+    name being included automatically.
+ @param tree the tree to append this item to
+ @param hfindex field index
+ @param tvb the tv buffer of the current data
+ @param start start of data in tvb
+ @param length length of data in tvb
+ @param value data to display
+ @param format printf like format string
+ @param ... printf like parameters
+ @return the newly created item */
+extern proto_item *
+proto_tree_add_uint_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
+       gint start, gint length, guint32 value, const char *format, ...)
+       GNUC_FORMAT_CHECK(printf,7,8);
+
+/** Add a formatted FT_UINT8, FT_UINT16, FT_UINT24 or FT_UINT32 to a proto_tree,
+    with the format generating the entire string for the entry, including any
+    field name.
  @param tree the tree to append this item to
  @param hfindex field index
  @param tvb the tv buffer of the current data
@@ -909,7 +1186,25 @@ extern proto_item *
 proto_tree_add_uint64(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
        gint length, guint64 value);
 
-/** Add a formatted FT_UINT64 to a proto_tree.
+/** Add a formatted FT_UINT64 to a proto_tree, with the format generating
+    the string for the value and with the field name being included
+    automatically.
+ @param tree the tree to append this item to
+ @param hfindex field index
+ @param tvb the tv buffer of the current data
+ @param start start of data in tvb
+ @param length length of data in tvb
+ @param value data to display
+ @param format printf like format string
+ @param ... printf like parameters
+ @return the newly created item */
+extern proto_item *
+proto_tree_add_uint64_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
+       gint start, gint length, guint64 value, const char *format, ...)
+       GNUC_FORMAT_CHECK(printf,7,8);
+
+/** Add a formatted FT_UINT64 to a proto_tree, with the format generating
+    the entire string for the entry, including any field name.
  @param tree the tree to append this item to
  @param hfindex field index
  @param tvb the tv buffer of the current data
@@ -935,13 +1230,32 @@ extern proto_item *
 proto_tree_add_int(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
        gint length, gint32 value);
 
-/** Add a hidden of one of FT_INT8, FT_INT16, FT_INT24 or FT_INT32 to a proto_tree.
+/** Add a hidden FT_INT8, FT_INT16, FT_INT24 or FT_INT32 to a proto_tree.
  @deprecated use proto_tree_add_int() and a subsequent call to PROTO_ITEM_SET_HIDDEN() instead */
 extern proto_item *
 proto_tree_add_int_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
        gint length, gint32 value);
 
-/** Add a formatted of one of FT_INT8, FT_INT16, FT_INT24 or FT_INT32 to a proto_tree.
+/** Add a formatted FT_INT8, FT_INT16, FT_INT24 or FT_INT32 to a proto_tree,
+    with the format generating the string for the value and with the field
+    name being included automatically.
+ @param tree the tree to append this item to
+ @param hfindex field index
+ @param tvb the tv buffer of the current data
+ @param start start of data in tvb
+ @param length length of data in tvb
+ @param value data to display
+ @param format printf like format string
+ @param ... printf like parameters
+ @return the newly created item */
+extern proto_item *
+proto_tree_add_int_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
+       gint start, gint length, gint32 value, const char *format, ...)
+       GNUC_FORMAT_CHECK(printf,7,8);
+
+/** Add a formatted FT_INT8, FT_INT16, FT_INT24 or FT_INT32 to a proto_tree,
+    with the format generating the entire string for the entry, including
+    any field name.
  @param tree the tree to append this item to
  @param hfindex field index
  @param tvb the tv buffer of the current data
@@ -967,7 +1281,25 @@ extern proto_item *
 proto_tree_add_int64(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
        gint length, gint64 value);
 
-/** Add a formatted FT_INT64 to a proto_tree.
+/** Add a formatted FT_INT64 to a proto_tree, with the format generating
+    the string for the value and with the field name being included
+    automatically.
+ @param tree the tree to append this item to
+ @param hfindex field index
+ @param tvb the tv buffer of the current data
+ @param start start of data in tvb
+ @param length length of data in tvb
+ @param value data to display
+ @param format printf like format string
+ @param ... printf like parameters
+ @return the newly created item */
+extern proto_item *
+proto_tree_add_int64_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
+       gint start, gint length, gint64 value, const char *format, ...)
+       GNUC_FORMAT_CHECK(printf,7,8);
+
+/** Add a formatted FT_INT64 to a proto_tree, with the format generating
+    the entire string for the entry, including any field name.
  @param tree the tree to append this item to
  @param hfindex field index
  @param tvb the tv buffer of the current data
@@ -1157,6 +1489,10 @@ extern GPtrArray* proto_get_finfo_ptr_array(proto_tree *tree, int hfindex);
  * proto_get_finfo_ptr_array because it has to search through the tree. */
 extern GPtrArray* proto_find_finfo(proto_tree *tree, int hfindex);
 
+/* Return GPtrArray* of field_info pointers containg all hfindexes that appear in
+* tree. */
+extern GPtrArray* proto_all_finfos(proto_tree *tree);
+
 /** Dumps a glossary of the protocol registrations to STDOUT */
 extern void proto_registrar_dump_protocols(void);
 
@@ -1173,12 +1509,12 @@ extern void proto_registrar_dump_fields(int format);
 /** Points to the first element of an array of Booleans, indexed by
    a subtree item type. That array element is TRUE if subtrees of
    an item of that type are to be expanded. With MSVC and a 
-   libethereal.dll, we need a special declaration. */
-ETH_VAR_IMPORT gboolean             *tree_is_expanded;
+   libwireshark.dll, we need a special declaration. */
+WS_VAR_IMPORT gboolean      *tree_is_expanded;
 
 /** Number of elements in the tree_is_expanded array. With MSVC and a 
- * libethereal.dll, we need a special declaration. */
-ETH_VAR_IMPORT int           num_tree_types;
+ * libwireshark.dll, we need a special declaration. */
+WS_VAR_IMPORT int           num_tree_types;
 
 /** glib doesn't have g_ptr_array_len of all things!*/
 #ifndef g_ptr_array_len
@@ -1203,12 +1539,12 @@ hfinfo_bitwidth(header_field_info *hfinfo);
 extern gboolean
 proto_can_match_selected(field_info *finfo, epan_dissect_t *edt);
 
-/** Construct a display filter string.
+/** Construct a "match selected" display filter string.
  @param finfo field_info
  @param edt epan dissecting
  @return the display filter string */
 extern char*
-proto_construct_dfilter_string(field_info *finfo, epan_dissect_t *edt);
+proto_construct_match_selected_string(field_info *finfo, epan_dissect_t *edt);
 
 /** Find field from offset in tvb.
  @param tree