aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--epan/dissectors/packet-http-urlencoded.c52
-rw-r--r--epan/dissectors/packet-image-png.c410
-rw-r--r--epan/dissectors/packet-jpeg.c330
-rw-r--r--epan/dissectors/packet-udp.c294
4 files changed, 584 insertions, 502 deletions
diff --git a/epan/dissectors/packet-http-urlencoded.c b/epan/dissectors/packet-http-urlencoded.c
index e0e03e14a9..ad35cc4298 100644
--- a/epan/dissectors/packet-http-urlencoded.c
+++ b/epan/dissectors/packet-http-urlencoded.c
@@ -22,6 +22,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#define NEW_PROTO_TREE_API
+
#include "config.h"
#include <glib.h>
@@ -30,11 +32,20 @@
#include <epan/strutil.h>
#include <epan/wmem/wmem.h>
-static gint proto_urlencoded = -1;
+static dissector_handle_t form_urlencoded_handle;
+
+static header_field_info *hfi_urlencoded = NULL;
+
+#define URLENCODED_HFI_INIT HFI_INIT(proto_urlencoded)
+
+static header_field_info hfi_form_keyvalue URLENCODED_HFI_INIT =
+ { "Form item", "urlencoded-form", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL };
-static gint hf_form_keyvalue = -1;
-static gint hf_form_key = -1;
-static gint hf_form_value = -1;
+static header_field_info hfi_form_key URLENCODED_HFI_INIT =
+ { "Key", "urlencoded-form.key", FT_STRINGZ, BASE_NONE, NULL, 0x0, NULL, HFILL };
+
+static header_field_info hfi_form_value URLENCODED_HFI_INIT =
+ { "Value", "urlencoded-form.value", FT_STRINGZ, BASE_NONE, NULL, 0x0, NULL, HFILL };
static gint ett_form_urlencoded = -1;
static gint ett_form_keyvalue = -1;
@@ -148,7 +159,7 @@ dissect_form_urlencoded(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
if (data_name)
col_append_sep_fstr(pinfo->cinfo, COL_INFO, " ", "(%s)", data_name);
- ti = proto_tree_add_item(tree, proto_urlencoded, tvb, 0, -1, ENC_NA);
+ ti = proto_tree_add_item(tree, hfi_urlencoded, tvb, 0, -1, ENC_NA);
if (data_name)
proto_item_append_text(ti, ": %s", data_name);
url_tree = proto_item_add_subtree(ti, ett_form_urlencoded);
@@ -157,14 +168,14 @@ dissect_form_urlencoded(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
const int start_offset = offset;
char *key, *value;
- ti = proto_tree_add_item(url_tree, hf_form_keyvalue, tvb, offset, 0, ENC_NA);
+ ti = proto_tree_add_item(url_tree, &hfi_form_keyvalue, tvb, offset, 0, ENC_NA);
sub = proto_item_add_subtree(ti, ett_form_keyvalue);
next_offset = get_form_key_value(tvb, &key, offset, '=');
if (next_offset == -1)
break;
- proto_tree_add_string(sub, hf_form_key, tvb, offset, next_offset - offset, key);
+ proto_tree_add_string(sub, &hfi_form_key, tvb, offset, next_offset - offset, key);
proto_item_append_text(sub, ": \"%s\"", key);
offset = next_offset+1;
@@ -172,7 +183,7 @@ dissect_form_urlencoded(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
next_offset = get_form_key_value(tvb, &value, offset, '&');
if (next_offset == -1)
break;
- proto_tree_add_string(sub, hf_form_value, tvb, offset, next_offset - offset, value);
+ proto_tree_add_string(sub, &hfi_form_value, tvb, offset, next_offset - offset, value);
proto_item_append_text(sub, " = \"%s\"", value);
offset = next_offset+1;
@@ -184,16 +195,10 @@ dissect_form_urlencoded(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
void
proto_register_http_urlencoded(void)
{
- static hf_register_info hf[] = {
- { &hf_form_keyvalue,
- { "Form item", "urlencoded-form", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }
- },
- { &hf_form_key,
- { "Key", "urlencoded-form.key", FT_STRINGZ, BASE_NONE, NULL, 0x0, NULL, HFILL }
- },
- { &hf_form_value,
- { "Value", "urlencoded-form.value", FT_STRINGZ, BASE_NONE, NULL, 0x0, NULL, HFILL }
- },
+ static header_field_info *hfi[] = {
+ &hfi_form_keyvalue,
+ &hfi_form_key,
+ &hfi_form_value,
};
static gint *ett[] = {
@@ -201,21 +206,20 @@ proto_register_http_urlencoded(void)
&ett_form_keyvalue
};
+ int proto_urlencoded;
proto_urlencoded = proto_register_protocol("HTML Form URL Encoded", "URL Encoded Form Data", "urlencoded-form");
- register_dissector("urlencoded-form", dissect_form_urlencoded, proto_urlencoded);
+ hfi_urlencoded = proto_registrar_get_nth(proto_urlencoded);
+
+ form_urlencoded_handle = register_dissector("urlencoded-form", dissect_form_urlencoded, proto_urlencoded);
- proto_register_field_array(proto_urlencoded, hf, array_length(hf));
+ proto_register_fields(proto_urlencoded, hfi, array_length(hfi));
proto_register_subtree_array(ett, array_length(ett));
}
void
proto_reg_handoff_http_urlencoded(void)
{
- dissector_handle_t form_urlencoded_handle;
-
- form_urlencoded_handle = find_dissector("urlencoded-form");
-
dissector_add_string("media_type", "application/x-www-form-urlencoded", form_urlencoded_handle);
}
diff --git a/epan/dissectors/packet-image-png.c b/epan/dissectors/packet-image-png.c
index 3c638828fc..b9599cdbcf 100644
--- a/epan/dissectors/packet-image-png.c
+++ b/epan/dissectors/packet-image-png.c
@@ -27,50 +27,75 @@
/* See http://www.w3.org/TR/PNG for specification
*/
+#define NEW_PROTO_TREE_API
+
#include "config.h"
#include <glib.h>
#include <epan/packet.h>
-static int proto_png = -1;
-static int hf_png_signature = -1;
-static int hf_png_chunk_data = -1;
-static int hf_png_chunk_type = -1;
-static int hf_png_chunk_len = -1;
-static int hf_png_chunk_crc = -1;
-static int hf_png_chunk_flag_anc = -1;
-static int hf_png_chunk_flag_priv = -1;
-static int hf_png_chunk_flag_stc = -1;
-static int hf_png_ihdr_width = -1;
-static int hf_png_ihdr_height = -1;
-static int hf_png_ihdr_bitdepth = -1;
-static int hf_png_ihdr_colour_type = -1;
-static int hf_png_ihdr_compression_method = -1;
-static int hf_png_ihdr_filter_method = -1;
-static int hf_png_ihdr_interlace_method = -1;
-static int hf_png_text_keyword = -1;
-static int hf_png_text_string = -1;
-static int hf_png_time_year = -1;
-static int hf_png_time_month = -1;
-static int hf_png_time_day = -1;
-static int hf_png_time_hour = -1;
-static int hf_png_time_minute = -1;
-static int hf_png_time_second = -1;
-static int hf_png_phys_horiz = -1;
-static int hf_png_phys_vert = -1;
-static int hf_png_phys_unit = -1;
-static int hf_png_bkgd_palette_index = -1;
-static int hf_png_bkgd_greyscale = -1;
-static int hf_png_bkgd_red = -1;
-static int hf_png_bkgd_green = -1;
-static int hf_png_bkgd_blue = -1;
+static header_field_info *hfi_png = NULL;
-static gint ett_png = -1;
-static gint ett_png_chunk = -1;
-static gint ett_png_chunk_item = -1;
+#define PNG_HFI_INIT HFI_INIT(proto_png)
-static dissector_handle_t png_handle;
+static header_field_info hfi_png_signature PNG_HFI_INIT = {
+ "PNG Signature", "png.signature", FT_BYTES, BASE_NONE,
+ NULL, 0, NULL, HFILL };
+static header_field_info hfi_png_chunk_data PNG_HFI_INIT = {
+ "Data", "png.chunk.data", FT_NONE, BASE_NONE,
+ NULL, 0, NULL, HFILL };
+
+static header_field_info hfi_png_chunk_type PNG_HFI_INIT = {
+ "Chunk", "png.chunk.type", FT_STRING, BASE_NONE,
+ NULL, 0, NULL, HFILL };
+
+static header_field_info hfi_png_chunk_len PNG_HFI_INIT = {
+ "Len", "png.chunk.len", FT_UINT32, BASE_DEC,
+ NULL, 0, NULL, HFILL };
+
+static header_field_info hfi_png_chunk_crc PNG_HFI_INIT = {
+ "CRC", "png.chunk.crc", FT_UINT32, BASE_HEX,
+ NULL, 0, NULL, HFILL };
+
+static const true_false_string png_chunk_anc = {
+ "This is an ANCILLARY chunk",
+ "This is a CRITICAL chunk"
+};
+
+static header_field_info hfi_png_chunk_flag_anc PNG_HFI_INIT = {
+ "Ancillary", "png.chunk.flag.ancillary", FT_BOOLEAN, 32,
+ TFS(&png_chunk_anc), 0x20000000, NULL, HFILL };
+
+static const true_false_string png_chunk_priv = {
+ "This is a PRIVATE chunk",
+ "This is a PUBLIC chunk"
+};
+
+static header_field_info hfi_png_chunk_flag_priv PNG_HFI_INIT = {
+ "Private", "png.chunk.flag.private", FT_BOOLEAN, 32,
+ TFS(&png_chunk_priv), 0x00200000, NULL, HFILL };
+
+static const true_false_string png_chunk_stc = {
+ "This chunk is SAFE TO COPY",
+ "This chunk is NOT safe to copy"
+};
+
+static header_field_info hfi_png_chunk_flag_stc PNG_HFI_INIT = {
+ "Safe To Copy", "png.chunk.flag.stc", FT_BOOLEAN, 32,
+ TFS(&png_chunk_stc), 0x00000020, NULL, HFILL };
+
+static header_field_info hfi_png_ihdr_width PNG_HFI_INIT = {
+ "Width", "png.ihdr.width", FT_UINT32, BASE_DEC,
+ NULL, 0, NULL, HFILL };
+
+static header_field_info hfi_png_ihdr_height PNG_HFI_INIT = {
+ "Height", "png.ihdr.height", FT_UINT32, BASE_DEC,
+ NULL, 0, NULL, HFILL };
+
+static header_field_info hfi_png_ihdr_bitdepth PNG_HFI_INIT = {
+ "Bit Depth", "png.ihdr.bitdepth", FT_UINT8, BASE_DEC,
+ NULL, 0, NULL, HFILL };
static const value_string colour_type_vals[] = {
{ 0, "Greyscale"},
@@ -80,37 +105,132 @@ static const value_string colour_type_vals[] = {
{ 6, "Truecolour with alpha"},
{ 0, NULL }
};
+
+static header_field_info hfi_png_ihdr_colour_type PNG_HFI_INIT = {
+ "Colour Type", "png.ihdr.colour_type", FT_UINT8, BASE_DEC,
+ VALS(colour_type_vals), 0, NULL, HFILL };
+
static const value_string compression_method_vals[] = {
{ 0, "Deflate"},
{ 0, NULL }
};
+
+static header_field_info hfi_png_ihdr_compression_method PNG_HFI_INIT = {
+ "Compression Method", "png.ihdr.compression_method", FT_UINT8, BASE_DEC,
+ VALS(compression_method_vals), 0, NULL, HFILL };
+
static const value_string filter_method_vals[] = {
{ 0, "Adaptive"},
{ 0, NULL }
};
+
+static header_field_info hfi_png_ihdr_filter_method PNG_HFI_INIT = {
+ "Filter Method", "png.ihdr.filter_method", FT_UINT8, BASE_DEC,
+ VALS(filter_method_vals), 0, NULL, HFILL };
+
static const value_string interlace_method_vals[] = {
{ 0, "No interlace"},
{ 1, "Adam7"},
{ 0, NULL }
};
+static header_field_info hfi_png_ihdr_interlace_method PNG_HFI_INIT = {
+ "Interlace Method", "png.ihdr.interlace_method", FT_UINT8, BASE_DEC,
+ VALS(interlace_method_vals), 0, NULL, HFILL };
+
+static header_field_info hfi_png_text_keyword PNG_HFI_INIT = {
+ "Keyword", "png.text.keyword", FT_STRING, BASE_NONE,
+ NULL, 0, NULL, HFILL };
+
+static header_field_info hfi_png_text_string PNG_HFI_INIT = {
+ "String", "png.text.string", FT_STRING, BASE_NONE,
+ NULL, 0, NULL, HFILL };
+
+static header_field_info hfi_png_time_year PNG_HFI_INIT = {
+ "Year", "png.time.year", FT_UINT16, BASE_DEC,
+ NULL, 0, NULL, HFILL };
+
+static header_field_info hfi_png_time_month PNG_HFI_INIT = {
+ "Month", "png.time.month", FT_UINT8, BASE_DEC,
+ NULL, 0, NULL, HFILL };
+
+static header_field_info hfi_png_time_day PNG_HFI_INIT = {
+ "Day", "png.time.day", FT_UINT8, BASE_DEC,
+ NULL, 0, NULL, HFILL };
+
+static header_field_info hfi_png_time_hour PNG_HFI_INIT = {
+ "Hour", "png.time.hour", FT_UINT8, BASE_DEC,
+ NULL, 0, NULL, HFILL };
+
+static header_field_info hfi_png_time_minute PNG_HFI_INIT = {
+ "Minute", "png.time.minute", FT_UINT8, BASE_DEC,
+ NULL, 0, NULL, HFILL };
+
+static header_field_info hfi_png_time_second PNG_HFI_INIT = {
+ "Second", "png.time.second", FT_UINT8, BASE_DEC,
+ NULL, 0, NULL, HFILL };
+
+static header_field_info hfi_png_phys_horiz PNG_HFI_INIT = {
+ "Horizontal pixels per unit", "png.phys.horiz", FT_UINT32, BASE_DEC,
+ NULL, 0, NULL, HFILL };
+
+static header_field_info hfi_png_phys_vert PNG_HFI_INIT = {
+ "Vertical pixels per unit", "png.phys.vert", FT_UINT32, BASE_DEC,
+ NULL, 0, NULL, HFILL };
+
+static const value_string phys_unit_vals[] = {
+ { 0, "Unit is unknown"},
+ { 1, "Unit is METRE"},
+ { 0, NULL }
+};
+
+static header_field_info hfi_png_phys_unit PNG_HFI_INIT = {
+ "Unit", "png.phys.unit", FT_UINT8, BASE_DEC,
+ VALS(phys_unit_vals), 0, NULL, HFILL };
+
+static header_field_info hfi_png_bkgd_palette_index PNG_HFI_INIT = {
+ "Palette Index", "png.bkgd.palette_index", FT_UINT8, BASE_DEC,
+ NULL, 0, NULL, HFILL };
+
+static header_field_info hfi_png_bkgd_greyscale PNG_HFI_INIT = {
+ "Greyscale", "png.bkgd.greyscale", FT_UINT16, BASE_HEX,
+ NULL, 0, NULL, HFILL };
+
+static header_field_info hfi_png_bkgd_red PNG_HFI_INIT = {
+ "Red", "png.bkgd.red", FT_UINT16, BASE_HEX,
+ NULL, 0, NULL, HFILL };
+
+static header_field_info hfi_png_bkgd_green PNG_HFI_INIT = {
+ "Green", "png.bkgd.green", FT_UINT16, BASE_HEX,
+ NULL, 0, NULL, HFILL };
+
+static header_field_info hfi_png_bkgd_blue PNG_HFI_INIT = {
+ "Blue", "png.bkgd.blue", FT_UINT16, BASE_HEX,
+ NULL, 0, NULL, HFILL };
+
+static gint ett_png = -1;
+static gint ett_png_chunk = -1;
+static gint ett_png_chunk_item = -1;
+
+static dissector_handle_t png_handle;
+
static void
dissect_png_ihdr(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
{
- proto_tree_add_item(tree, hf_png_ihdr_width, tvb, 0, 4, ENC_BIG_ENDIAN);
+ proto_tree_add_item(tree, &hfi_png_ihdr_width, tvb, 0, 4, ENC_BIG_ENDIAN);
- proto_tree_add_item(tree, hf_png_ihdr_height, tvb, 4, 4, ENC_BIG_ENDIAN);
+ proto_tree_add_item(tree, &hfi_png_ihdr_height, tvb, 4, 4, ENC_BIG_ENDIAN);
- proto_tree_add_item(tree, hf_png_ihdr_bitdepth, tvb, 8, 1, ENC_BIG_ENDIAN);
+ proto_tree_add_item(tree, &hfi_png_ihdr_bitdepth, tvb, 8, 1, ENC_BIG_ENDIAN);
- proto_tree_add_item(tree, hf_png_ihdr_colour_type, tvb, 9, 1, ENC_BIG_ENDIAN);
+ proto_tree_add_item(tree, &hfi_png_ihdr_colour_type, tvb, 9, 1, ENC_BIG_ENDIAN);
- proto_tree_add_item(tree, hf_png_ihdr_compression_method, tvb, 10, 1, ENC_BIG_ENDIAN);
+ proto_tree_add_item(tree, &hfi_png_ihdr_compression_method, tvb, 10, 1, ENC_BIG_ENDIAN);
- proto_tree_add_item(tree, hf_png_ihdr_filter_method, tvb, 11, 1, ENC_BIG_ENDIAN);
+ proto_tree_add_item(tree, &hfi_png_ihdr_filter_method, tvb, 11, 1, ENC_BIG_ENDIAN);
- proto_tree_add_item(tree, hf_png_ihdr_interlace_method, tvb, 12, 1, ENC_BIG_ENDIAN);
+ proto_tree_add_item(tree, &hfi_png_ihdr_interlace_method, tvb, 12, 1, ENC_BIG_ENDIAN);
}
@@ -127,35 +247,30 @@ dissect_png_text(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
offset++;
}
- proto_tree_add_item(tree, hf_png_text_keyword, tvb, 0, offset, ENC_ASCII|ENC_NA);
+ proto_tree_add_item(tree, &hfi_png_text_keyword, tvb, 0, offset, ENC_ASCII|ENC_NA);
offset++;
- proto_tree_add_item(tree, hf_png_text_string, tvb, offset, tvb_length_remaining(tvb, offset), ENC_ASCII|ENC_NA);
+ proto_tree_add_item(tree, &hfi_png_text_string, tvb, offset, tvb_length_remaining(tvb, offset), ENC_ASCII|ENC_NA);
}
static void
dissect_png_time(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
{
- proto_tree_add_item(tree, hf_png_time_year, tvb, 0, 2, ENC_BIG_ENDIAN);
- proto_tree_add_item(tree, hf_png_time_month, tvb, 2, 1, ENC_BIG_ENDIAN);
- proto_tree_add_item(tree, hf_png_time_day, tvb, 3, 1, ENC_BIG_ENDIAN);
- proto_tree_add_item(tree, hf_png_time_hour, tvb, 4, 1, ENC_BIG_ENDIAN);
- proto_tree_add_item(tree, hf_png_time_minute, tvb, 5, 1, ENC_BIG_ENDIAN);
- proto_tree_add_item(tree, hf_png_time_second, tvb, 6, 1, ENC_BIG_ENDIAN);
+ proto_tree_add_item(tree, &hfi_png_time_year, tvb, 0, 2, ENC_BIG_ENDIAN);
+ proto_tree_add_item(tree, &hfi_png_time_month, tvb, 2, 1, ENC_BIG_ENDIAN);
+ proto_tree_add_item(tree, &hfi_png_time_day, tvb, 3, 1, ENC_BIG_ENDIAN);
+ proto_tree_add_item(tree, &hfi_png_time_hour, tvb, 4, 1, ENC_BIG_ENDIAN);
+ proto_tree_add_item(tree, &hfi_png_time_minute, tvb, 5, 1, ENC_BIG_ENDIAN);
+ proto_tree_add_item(tree, &hfi_png_time_second, tvb, 6, 1, ENC_BIG_ENDIAN);
}
-static const value_string phys_unit_vals[] = {
- { 0, "Unit is unknown"},
- { 1, "Unit is METRE"},
- { 0, NULL }
-};
static void
dissect_png_phys(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
{
- proto_tree_add_item(tree, hf_png_phys_horiz, tvb, 0, 4, ENC_BIG_ENDIAN);
- proto_tree_add_item(tree, hf_png_phys_vert, tvb, 4, 4, ENC_BIG_ENDIAN);
- proto_tree_add_item(tree, hf_png_phys_unit, tvb, 8, 1, ENC_BIG_ENDIAN);
+ proto_tree_add_item(tree, &hfi_png_phys_horiz, tvb, 0, 4, ENC_BIG_ENDIAN);
+ proto_tree_add_item(tree, &hfi_png_phys_vert, tvb, 4, 4, ENC_BIG_ENDIAN);
+ proto_tree_add_item(tree, &hfi_png_phys_unit, tvb, 8, 1, ENC_BIG_ENDIAN);
}
static void
@@ -163,15 +278,15 @@ dissect_png_bkgd(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
{
switch(tvb_reported_length(tvb)){
case 1: /* colour type 3 */
- proto_tree_add_item(tree, hf_png_bkgd_palette_index, tvb, 0, 1, ENC_BIG_ENDIAN);
+ proto_tree_add_item(tree, &hfi_png_bkgd_palette_index, tvb, 0, 1, ENC_BIG_ENDIAN);
break;
case 2: /* colour type 0, 4 */
- proto_tree_add_item(tree, hf_png_bkgd_greyscale, tvb, 0, 2, ENC_BIG_ENDIAN);
+ proto_tree_add_item(tree, &hfi_png_bkgd_greyscale, tvb, 0, 2, ENC_BIG_ENDIAN);
break;
case 6: /* colour type 2, 6 */
- proto_tree_add_item(tree, hf_png_bkgd_red, tvb, 0, 2, ENC_BIG_ENDIAN);
- proto_tree_add_item(tree, hf_png_bkgd_green, tvb, 2, 2, ENC_BIG_ENDIAN);
- proto_tree_add_item(tree, hf_png_bkgd_blue, tvb, 4, 2, ENC_BIG_ENDIAN);
+ proto_tree_add_item(tree, &hfi_png_bkgd_red, tvb, 0, 2, ENC_BIG_ENDIAN);
+ proto_tree_add_item(tree, &hfi_png_bkgd_green, tvb, 2, 2, ENC_BIG_ENDIAN);
+ proto_tree_add_item(tree, &hfi_png_bkgd_blue, tvb, 4, 2, ENC_BIG_ENDIAN);
break;
}
}
@@ -194,20 +309,6 @@ static chunk_dissector_t chunk_table[] = {
{ 0, NULL, NULL }
};
-static const true_false_string png_chunk_anc = {
- "This is an ANCILLARY chunk",
- "This is a CRITICAL chunk"
-};
-static const true_false_string png_chunk_priv = {
- "This is a PRIVATE chunk",
- "This is a PUBLIC chunk"
-};
-static const true_false_string png_chunk_stc = {
- "This chunk is SAFE TO COPY",
- "This chunk is NOT safe to copy"
-};
-
-
static gint
dissect_png(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void *data _U_)
{
@@ -226,11 +327,11 @@ dissect_png(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void *da
col_append_str(pinfo->cinfo, COL_INFO, " (PNG)");
if(parent_tree){
- ti=proto_tree_add_item(parent_tree, proto_png, tvb, offset, -1, ENC_NA);
+ ti=proto_tree_add_item(parent_tree, hfi_png, tvb, offset, -1, ENC_NA);
tree=proto_item_add_subtree(ti, ett_png);
}
- proto_tree_add_item(tree, hf_png_signature, tvb, offset, 8, ENC_NA);
+ proto_tree_add_item(tree, &hfi_png_signature, tvb, offset, 8, ENC_NA);
offset+=8;
while(tvb_reported_length_remaining(tvb, offset) > 0){
@@ -253,14 +354,14 @@ dissect_png(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void *da
chunk_tree=proto_item_add_subtree(it, ett_png_chunk);
}
- proto_tree_add_item(chunk_tree, hf_png_chunk_len, tvb, offset, 4, ENC_BIG_ENDIAN);
+ proto_tree_add_item(chunk_tree, &hfi_png_chunk_len, tvb, offset, 4, ENC_BIG_ENDIAN);
offset+=4;
- it=proto_tree_add_item(chunk_tree, hf_png_chunk_type, tvb, offset, 4, ENC_ASCII|ENC_NA);
- proto_tree_add_item(chunk_tree, hf_png_chunk_flag_anc, tvb, offset, 4, ENC_BIG_ENDIAN);
- proto_tree_add_item(chunk_tree, hf_png_chunk_flag_priv, tvb, offset, 4, ENC_BIG_ENDIAN);
- proto_tree_add_item(chunk_tree, hf_png_chunk_flag_stc, tvb, offset, 4, ENC_BIG_ENDIAN);
+ it=proto_tree_add_item(chunk_tree, &hfi_png_chunk_type, tvb, offset, 4, ENC_ASCII|ENC_NA);
+ proto_tree_add_item(chunk_tree, &hfi_png_chunk_flag_anc, tvb, offset, 4, ENC_BIG_ENDIAN);
+ proto_tree_add_item(chunk_tree, &hfi_png_chunk_flag_priv, tvb, offset, 4, ENC_BIG_ENDIAN);
+ proto_tree_add_item(chunk_tree, &hfi_png_chunk_flag_stc, tvb, offset, 4, ENC_BIG_ENDIAN);
offset+=4;
if (len >= 1000000000)
@@ -281,7 +382,7 @@ dissect_png(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void *da
}
if(!cd){
- proto_tree_add_item(chunk_tree, hf_png_chunk_data, tvb, offset, len, ENC_NA);
+ proto_tree_add_item(chunk_tree, &hfi_png_chunk_data, tvb, offset, len, ENC_NA);
} else {
if(cd->dissector){
tvbuff_t *next_tvb;
@@ -296,7 +397,7 @@ dissect_png(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void *da
}
offset+=len;
- proto_tree_add_item(chunk_tree, hf_png_chunk_crc, tvb, offset, 4, ENC_BIG_ENDIAN);
+ proto_tree_add_item(chunk_tree, &hfi_png_chunk_crc, tvb, offset, 4, ENC_BIG_ENDIAN);
offset+=4;
}
return offset;
@@ -305,101 +406,39 @@ dissect_png(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void *da
void
proto_register_png(void)
{
- static hf_register_info hf[] =
+ static header_field_info *hfi[] =
{
- { &hf_png_signature, {
- "PNG Signature", "png.signature", FT_BYTES, BASE_NONE,
- NULL, 0, NULL, HFILL }},
- { &hf_png_chunk_type, {
- "Chunk", "png.chunk.type", FT_STRING, BASE_NONE,
- NULL, 0, NULL, HFILL }},
- { &hf_png_chunk_data, {
- "Data", "png.chunk.data", FT_NONE, BASE_NONE,
- NULL, 0, NULL, HFILL }},
- { &hf_png_chunk_len, {
- "Len", "png.chunk.len", FT_UINT32, BASE_DEC,
- NULL, 0, NULL, HFILL }},
- { &hf_png_chunk_crc, {
- "CRC", "png.chunk.crc", FT_UINT32, BASE_HEX,
- NULL, 0, NULL, HFILL }},
- { &hf_png_chunk_flag_anc, {
- "Ancillary", "png.chunk.flag.ancillary", FT_BOOLEAN, 32,
- TFS(&png_chunk_anc), 0x20000000, NULL, HFILL }},
- { &hf_png_chunk_flag_priv, {
- "Private", "png.chunk.flag.private", FT_BOOLEAN, 32,
- TFS(&png_chunk_priv), 0x00200000, NULL, HFILL }},
- { &hf_png_chunk_flag_stc, {
- "Safe To Copy", "png.chunk.flag.stc", FT_BOOLEAN, 32,
- TFS(&png_chunk_stc), 0x00000020, NULL, HFILL }},
- { &hf_png_ihdr_width, {
- "Width", "png.ihdr.width", FT_UINT32, BASE_DEC,
- NULL, 0, NULL, HFILL }},
- { &hf_png_ihdr_height, {
- "Height", "png.ihdr.height", FT_UINT32, BASE_DEC,
- NULL, 0, NULL, HFILL }},
- { &hf_png_ihdr_bitdepth, {
- "Bit Depth", "png.ihdr.bitdepth", FT_UINT8, BASE_DEC,
- NULL, 0, NULL, HFILL }},
- { &hf_png_ihdr_colour_type, {
- "Colour Type", "png.ihdr.colour_type", FT_UINT8, BASE_DEC,
- VALS(colour_type_vals), 0, NULL, HFILL }},
- { &hf_png_ihdr_compression_method, {
- "Compression Method", "png.ihdr.compression_method", FT_UINT8, BASE_DEC,
- VALS(compression_method_vals), 0, NULL, HFILL }},
- { &hf_png_ihdr_filter_method, {
- "Filter Method", "png.ihdr.filter_method", FT_UINT8, BASE_DEC,
- VALS(filter_method_vals), 0, NULL, HFILL }},
- { &hf_png_ihdr_interlace_method, {
- "Interlace Method", "png.ihdr.interlace_method", FT_UINT8, BASE_DEC,
- VALS(interlace_method_vals), 0, NULL, HFILL }},
- { &hf_png_text_keyword, {
- "Keyword", "png.text.keyword", FT_STRING, BASE_NONE,
- NULL, 0, NULL, HFILL }},
- { &hf_png_text_string, {
- "String", "png.text.string", FT_STRING, BASE_NONE,
- NULL, 0, NULL, HFILL }},
- { &hf_png_time_year, {
- "Year", "png.time.year", FT_UINT16, BASE_DEC,
- NULL, 0, NULL, HFILL }},
- { &hf_png_time_month, {
- "Month", "png.time.month", FT_UINT8, BASE_DEC,
- NULL, 0, NULL, HFILL }},
- { &hf_png_time_day, {
- "Day", "png.time.day", FT_UINT8, BASE_DEC,
- NULL, 0, NULL, HFILL }},
- { &hf_png_time_hour, {
- "Hour", "png.time.hour", FT_UINT8, BASE_DEC,
- NULL, 0, NULL, HFILL }},
- { &hf_png_time_minute, {
- "Minute", "png.time.minute", FT_UINT8, BASE_DEC,
- NULL, 0, NULL, HFILL }},
- { &hf_png_time_second, {
- "Second", "png.time.second", FT_UINT8, BASE_DEC,
- NULL, 0, NULL, HFILL }},
- { &hf_png_phys_horiz, {
- "Horizontal pixels per unit", "png.phys.horiz", FT_UINT32, BASE_DEC,
- NULL, 0, NULL, HFILL }},
- { &hf_png_phys_vert, {
- "Vertical pixels per unit", "png.phys.vert", FT_UINT32, BASE_DEC,
- NULL, 0, NULL, HFILL }},
- { &hf_png_phys_unit, {
- "Unit", "png.phys.unit", FT_UINT8, BASE_DEC,
- VALS(phys_unit_vals), 0, NULL, HFILL }},
- { &hf_png_bkgd_palette_index, {
- "Palette Index", "png.bkgd.palette_index", FT_UINT8, BASE_DEC,
- NULL, 0, NULL, HFILL }},
- { &hf_png_bkgd_greyscale, {
- "Greyscale", "png.bkgd.greyscale", FT_UINT16, BASE_HEX,
- NULL, 0, NULL, HFILL }},
- { &hf_png_bkgd_red, {
- "Red", "png.bkgd.red", FT_UINT16, BASE_HEX,
- NULL, 0, NULL, HFILL }},
- { &hf_png_bkgd_green, {
- "Green", "png.bkgd.green", FT_UINT16, BASE_HEX,
- NULL, 0, NULL, HFILL }},
- { &hf_png_bkgd_blue, {
- "Blue", "png.bkgd.blue", FT_UINT16, BASE_HEX,
- NULL, 0, NULL, HFILL }},
+ &hfi_png_signature,
+ &hfi_png_chunk_type,
+ &hfi_png_chunk_data,
+ &hfi_png_chunk_len,
+ &hfi_png_chunk_crc,
+ &hfi_png_chunk_flag_anc,
+ &hfi_png_chunk_flag_priv,
+ &hfi_png_chunk_flag_stc,
+ &hfi_png_ihdr_width,
+ &hfi_png_ihdr_height,
+ &hfi_png_ihdr_bitdepth,
+ &hfi_png_ihdr_colour_type,
+ &hfi_png_ihdr_compression_method,
+ &hfi_png_ihdr_filter_method,
+ &hfi_png_ihdr_interlace_method,
+ &hfi_png_text_keyword,
+ &hfi_png_text_string,
+ &hfi_png_time_year,
+ &hfi_png_time_month,
+ &hfi_png_time_day,
+ &hfi_png_time_hour,
+ &hfi_png_time_minute,
+ &hfi_png_time_second,
+ &hfi_png_phys_horiz,
+ &hfi_png_phys_vert,
+ &hfi_png_phys_unit,
+ &hfi_png_bkgd_palette_index,
+ &hfi_png_bkgd_greyscale,
+ &hfi_png_bkgd_red,
+ &hfi_png_bkgd_green,
+ &hfi_png_bkgd_blue,
};
static gint *ett[] =
@@ -409,9 +448,12 @@ proto_register_png(void)
&ett_png_chunk_item,
};
+ int proto_png;
proto_png = proto_register_protocol("Portable Network Graphics","PNG","png");
- proto_register_field_array(proto_png, hf, array_length(hf));
+ hfi_png = proto_registrar_get_nth(proto_png);
+
+ proto_register_fields(proto_png, hfi, array_length(hfi));
proto_register_subtree_array(ett, array_length(ett));
png_handle = new_register_dissector("png", dissect_png, proto_png);
@@ -426,6 +468,6 @@ void
proto_reg_handoff_png(void)
{
dissector_add_string("media_type", "image/png", png_handle);
- heur_dissector_add("http", dissect_png_heur, proto_png);
- heur_dissector_add("wtap_file", dissect_png_heur, proto_png);
+ heur_dissector_add("http", dissect_png_heur, hfi_png->id);
+ heur_dissector_add("wtap_file", dissect_png_heur, hfi_png->id);
}
diff --git a/epan/dissectors/packet-jpeg.c b/epan/dissectors/packet-jpeg.c
index 11d3fd3fa5..b8f639f4dd 100644
--- a/epan/dissectors/packet-jpeg.c
+++ b/epan/dissectors/packet-jpeg.c
@@ -28,6 +28,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#define NEW_PROTO_TREE_API
+
#include "config.h"
#include <glib.h>
@@ -37,30 +39,140 @@
#include "packet-ber.h"
-/* JPEG header fields */
-static int hf_rtp_jpeg_main_hdr = -1;
-static int hf_rtp_jpeg_main_hdr_ts = -1;
-static int hf_rtp_jpeg_main_hdr_offs = -1;
-static int hf_rtp_jpeg_main_hdr_type = -1;
-static int hf_rtp_jpeg_main_hdr_q = -1;
-static int hf_rtp_jpeg_main_hdr_width = -1;
-static int hf_rtp_jpeg_main_hdr_height = -1;
+static dissector_handle_t jpeg_handle;
+
+static header_field_info *hfi_jpeg = NULL;
+
+#define JPEG_HFI_INIT HFI_INIT(proto_jpeg)
+
+/* JPEG header fields */
+static header_field_info hfi_rtp_jpeg_main_hdr JPEG_HFI_INIT = {
+ "Main Header",
+ "jpeg.main_hdr",
+ FT_NONE, BASE_NONE, NULL, 0,
+ NULL, HFILL
+};
+
+static header_field_info hfi_rtp_jpeg_main_hdr_ts JPEG_HFI_INIT = {
+ "Type Specific",
+ "jpeg.main_hdr.ts",
+ FT_UINT8, BASE_DEC, NULL, 0,
+ NULL, HFILL
+};
+
+static header_field_info hfi_rtp_jpeg_main_hdr_offs JPEG_HFI_INIT = {
+ "Fragment Offset",
+ "jpeg.main_hdr.offset",
+ FT_UINT24, BASE_DEC, NULL, 0,
+ NULL, HFILL
+};
+
+static header_field_info hfi_rtp_jpeg_main_hdr_type JPEG_HFI_INIT = {
+ "Type",
+ "jpeg.main_hdr.type",
+ FT_UINT8, BASE_DEC, NULL, 0,
+ NULL, HFILL
+};
+
+static header_field_info hfi_rtp_jpeg_main_hdr_q JPEG_HFI_INIT = {
+ "Q",
+ "jpeg.main_hdr.q",
+ FT_UINT8, BASE_DEC, NULL, 0,
+ NULL, HFILL
+};
+
+static header_field_info hfi_rtp_jpeg_main_hdr_width JPEG_HFI_INIT = {
+ "Width",
+ "jpeg.main_hdr.width",
+ FT_UINT8, BASE_DEC, NULL, 0,
+ NULL, HFILL
+};
+
+static header_field_info hfi_rtp_jpeg_main_hdr_height JPEG_HFI_INIT = {
+ "Height",
+ "jpeg.main_hdr.height",
+ FT_UINT8, BASE_DEC, NULL, 0,
+ NULL, HFILL
+};
+
+static header_field_info hfi_rtp_jpeg_restart_hdr JPEG_HFI_INIT = {
+ "Restart Marker Header",
+ "jpeg.restart_hdr",
+ FT_NONE, BASE_NONE, NULL, 0,
+ NULL, HFILL
+};
+
+static header_field_info hfi_rtp_jpeg_restart_hdr_interval JPEG_HFI_INIT = {
+ "Restart Interval",
+ "jpeg.restart_hdr.interval",
+ FT_UINT16, BASE_DEC, NULL, 0,
+ NULL, HFILL
+};
-static int hf_rtp_jpeg_restart_hdr = -1;
-static int hf_rtp_jpeg_restart_hdr_interval = -1;
-static int hf_rtp_jpeg_restart_hdr_f = -1;
-static int hf_rtp_jpeg_restart_hdr_l = -1;
-static int hf_rtp_jpeg_restart_hdr_count = -1;
+static header_field_info hfi_rtp_jpeg_restart_hdr_f JPEG_HFI_INIT = {
+ "F",
+ "jpeg.restart_hdr.f",
+ FT_UINT16, BASE_DEC, NULL, 0x8000,
+ NULL, HFILL
+};
-static int hf_rtp_jpeg_qtable_hdr = -1;
-static int hf_rtp_jpeg_qtable_hdr_mbz = -1;
-static int hf_rtp_jpeg_qtable_hdr_prec = -1;
-static int hf_rtp_jpeg_qtable_hdr_length = -1;
-static int hf_rtp_jpeg_qtable_hdr_data = -1;
+static header_field_info hfi_rtp_jpeg_restart_hdr_l JPEG_HFI_INIT = {
+ "L",
+ "jpeg.restart_hdr.l",
+ FT_UINT16, BASE_DEC, NULL, 0x4000,
+ NULL, HFILL
+};
-static int hf_rtp_jpeg_payload = -1;
+static header_field_info hfi_rtp_jpeg_restart_hdr_count JPEG_HFI_INIT = {
+ "Restart Count",
+ "jpeg.restart_hdr.count",
+ FT_UINT16, BASE_DEC, NULL, 0x3FFF,
+ NULL, HFILL
+};
+
+static header_field_info hfi_rtp_jpeg_qtable_hdr JPEG_HFI_INIT = {
+ "Quantization Table Header",
+ "jpeg.qtable_hdr",
+ FT_NONE, BASE_NONE, NULL, 0,
+ NULL, HFILL
+};
+
+static header_field_info hfi_rtp_jpeg_qtable_hdr_mbz JPEG_HFI_INIT = {
+ "MBZ",
+ "jpeg.qtable_hdr.mbz",
+ FT_UINT8, BASE_DEC, NULL, 0,
+ NULL, HFILL
+};
+
+static header_field_info hfi_rtp_jpeg_qtable_hdr_prec JPEG_HFI_INIT = {
+ "Precision",
+ "jpeg.qtable_hdr.precision",
+ FT_UINT8, BASE_DEC, NULL, 0,
+ NULL, HFILL
+};
+
+static header_field_info hfi_rtp_jpeg_qtable_hdr_length JPEG_HFI_INIT = {
+ "Length",
+ "jpeg.qtable_hdr.length",
+ FT_UINT16, BASE_DEC, NULL, 0,
+ NULL, HFILL
+};
+
+static header_field_info hfi_rtp_jpeg_qtable_hdr_data JPEG_HFI_INIT = {
+ "Quantization Table Data",
+ "jpeg.qtable_hdr.data",
+ FT_BYTES, BASE_NONE, NULL, 0,
+ NULL, HFILL
+};
+
+
+static header_field_info hfi_rtp_jpeg_payload JPEG_HFI_INIT = {
+ "Payload",
+ "jpeg.payload",
+ FT_BYTES, BASE_NONE, NULL, 0,
+ NULL, HFILL
+};
-static int proto_jpeg = -1;
/* JPEG fields defining a sub tree */
static gint ett_jpeg = -1;
@@ -87,60 +199,60 @@ dissect_jpeg( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree )
col_set_str(pinfo->cinfo, COL_INFO, "JPEG message");
if ( tree ) {
- ti = proto_tree_add_item( tree, proto_jpeg, tvb, offset, -1, ENC_NA );
+ ti = proto_tree_add_item( tree, hfi_jpeg, tvb, offset, -1, ENC_NA );
jpeg_tree = proto_item_add_subtree( ti, ett_jpeg );
- ti = proto_tree_add_item(jpeg_tree, hf_rtp_jpeg_main_hdr, tvb, offset, 8, ENC_NA);
+ ti = proto_tree_add_item(jpeg_tree, &hfi_rtp_jpeg_main_hdr, tvb, offset, 8, ENC_NA);
main_hdr_tree = proto_item_add_subtree(ti, ett_jpeg);
- proto_tree_add_item(main_hdr_tree, hf_rtp_jpeg_main_hdr_ts, tvb, offset, 1, ENC_BIG_ENDIAN);
+ proto_tree_add_item(main_hdr_tree, &hfi_rtp_jpeg_main_hdr_ts, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
- proto_tree_add_item(main_hdr_tree, hf_rtp_jpeg_main_hdr_offs, tvb, offset, 3, ENC_BIG_ENDIAN);
+ proto_tree_add_item(main_hdr_tree, &hfi_rtp_jpeg_main_hdr_offs, tvb, offset, 3, ENC_BIG_ENDIAN);
fragment_offset = tvb_get_ntoh24(tvb, offset);
offset += 3;
- proto_tree_add_item(main_hdr_tree, hf_rtp_jpeg_main_hdr_type, tvb, offset, 1, ENC_BIG_ENDIAN);
+ proto_tree_add_item(main_hdr_tree, &hfi_rtp_jpeg_main_hdr_type, tvb, offset, 1, ENC_BIG_ENDIAN);
type = tvb_get_guint8(tvb, offset);
offset += 1;
- proto_tree_add_item(main_hdr_tree, hf_rtp_jpeg_main_hdr_q, tvb, offset, 1, ENC_BIG_ENDIAN);
+ proto_tree_add_item(main_hdr_tree, &hfi_rtp_jpeg_main_hdr_q, tvb, offset, 1, ENC_BIG_ENDIAN);
q = tvb_get_guint8(tvb, offset);
offset += 1;
w = tvb_get_guint8(tvb, offset) * 8;
- proto_tree_add_uint(main_hdr_tree, hf_rtp_jpeg_main_hdr_width, tvb, offset, 1, w);
+ proto_tree_add_uint(main_hdr_tree, &hfi_rtp_jpeg_main_hdr_width, tvb, offset, 1, w);
offset += 1;
h = tvb_get_guint8(tvb, offset) * 8;
- proto_tree_add_uint(main_hdr_tree, hf_rtp_jpeg_main_hdr_height, tvb, offset, 1, h);
+ proto_tree_add_uint(main_hdr_tree, &hfi_rtp_jpeg_main_hdr_height, tvb, offset, 1, h);
offset += 1;
if (type >= 64 && type <= 127) {
- ti = proto_tree_add_item(jpeg_tree, hf_rtp_jpeg_restart_hdr, tvb, offset, 4, ENC_NA);
+ ti = proto_tree_add_item(jpeg_tree, &hfi_rtp_jpeg_restart_hdr, tvb, offset, 4, ENC_NA);
restart_hdr_tree = proto_item_add_subtree(ti, ett_jpeg);
- proto_tree_add_item(restart_hdr_tree, hf_rtp_jpeg_restart_hdr_interval, tvb, offset, 2, ENC_BIG_ENDIAN);
+ proto_tree_add_item(restart_hdr_tree, &hfi_rtp_jpeg_restart_hdr_interval, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
- proto_tree_add_item(restart_hdr_tree, hf_rtp_jpeg_restart_hdr_f, tvb, offset, 2, ENC_BIG_ENDIAN);
- proto_tree_add_item(restart_hdr_tree, hf_rtp_jpeg_restart_hdr_l, tvb, offset, 2, ENC_BIG_ENDIAN);
- proto_tree_add_item(restart_hdr_tree, hf_rtp_jpeg_restart_hdr_count, tvb, offset, 2, ENC_BIG_ENDIAN);
+ proto_tree_add_item(restart_hdr_tree, &hfi_rtp_jpeg_restart_hdr_f, tvb, offset, 2, ENC_BIG_ENDIAN);
+ proto_tree_add_item(restart_hdr_tree, &hfi_rtp_jpeg_restart_hdr_l, tvb, offset, 2, ENC_BIG_ENDIAN);
+ proto_tree_add_item(restart_hdr_tree, &hfi_rtp_jpeg_restart_hdr_count, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
}
if (q >= 128 && fragment_offset == 0) {
- ti = proto_tree_add_item(jpeg_tree, hf_rtp_jpeg_qtable_hdr, tvb, offset, -1, ENC_NA);
+ ti = proto_tree_add_item(jpeg_tree, &hfi_rtp_jpeg_qtable_hdr, tvb, offset, -1, ENC_NA);
qtable_hdr_tree = proto_item_add_subtree(ti, ett_jpeg);
- proto_tree_add_item(qtable_hdr_tree, hf_rtp_jpeg_qtable_hdr_mbz, tvb, offset, 1, ENC_BIG_ENDIAN);
+ proto_tree_add_item(qtable_hdr_tree, &hfi_rtp_jpeg_qtable_hdr_mbz, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
- proto_tree_add_item(qtable_hdr_tree, hf_rtp_jpeg_qtable_hdr_prec, tvb, offset, 1, ENC_BIG_ENDIAN);
+ proto_tree_add_item(qtable_hdr_tree, &hfi_rtp_jpeg_qtable_hdr_prec, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
- proto_tree_add_item(qtable_hdr_tree, hf_rtp_jpeg_qtable_hdr_length, tvb, offset, 2, ENC_BIG_ENDIAN);
+ proto_tree_add_item(qtable_hdr_tree, &hfi_rtp_jpeg_qtable_hdr_length, tvb, offset, 2, ENC_BIG_ENDIAN);
len = tvb_get_ntohs(tvb, offset);
offset += 2;
if (len > 0) {
- proto_tree_add_item(qtable_hdr_tree, hf_rtp_jpeg_qtable_hdr_data, tvb, offset, len, ENC_NA);
+ proto_tree_add_item(qtable_hdr_tree, &hfi_rtp_jpeg_qtable_hdr_data, tvb, offset, len, ENC_NA);
offset += len;
}
proto_item_set_len(ti, len + 4);
}
/* The rest of the packet is the JPEG data */
- proto_tree_add_item( jpeg_tree, hf_rtp_jpeg_payload, tvb, offset, -1, ENC_NA );
+ proto_tree_add_item( jpeg_tree, &hfi_rtp_jpeg_payload, tvb, offset, -1, ENC_NA );
}
}
@@ -148,116 +260,26 @@ void
proto_register_jpeg(void)
{
- static hf_register_info hf[] =
+ static header_field_info *hfi[] =
{
- { &hf_rtp_jpeg_main_hdr, {
- "Main Header",
- "jpeg.main_hdr",
- FT_NONE, BASE_NONE, NULL, 0,
- NULL, HFILL
- }},
- { &hf_rtp_jpeg_main_hdr_ts, {
- "Type Specific",
- "jpeg.main_hdr.ts",
- FT_UINT8, BASE_DEC, NULL, 0,
- NULL, HFILL
- }},
- { &hf_rtp_jpeg_main_hdr_offs, {
- "Fragment Offset",
- "jpeg.main_hdr.offset",
- FT_UINT24, BASE_DEC, NULL, 0,
- NULL, HFILL
- }},
- { &hf_rtp_jpeg_main_hdr_type, {
- "Type",
- "jpeg.main_hdr.type",
- FT_UINT8, BASE_DEC, NULL, 0,
- NULL, HFILL
- }},
- { &hf_rtp_jpeg_main_hdr_q, {
- "Q",
- "jpeg.main_hdr.q",
- FT_UINT8, BASE_DEC, NULL, 0,
- NULL, HFILL
- }},
- { &hf_rtp_jpeg_main_hdr_width, {
- "Width",
- "jpeg.main_hdr.width",
- FT_UINT8, BASE_DEC, NULL, 0,
- NULL, HFILL
- }},
- { &hf_rtp_jpeg_main_hdr_height, {
- "Height",
- "jpeg.main_hdr.height",
- FT_UINT8, BASE_DEC, NULL, 0,
- NULL, HFILL
- }},
- { &hf_rtp_jpeg_restart_hdr, {
- "Restart Marker Header",
- "jpeg.restart_hdr",
- FT_NONE, BASE_NONE, NULL, 0,
- NULL, HFILL
- }},
- { &hf_rtp_jpeg_restart_hdr_interval, {
- "Restart Interval",
- "jpeg.restart_hdr.interval",
- FT_UINT16, BASE_DEC, NULL, 0,
- NULL, HFILL
- }},
- { &hf_rtp_jpeg_restart_hdr_f, {
- "F",
- "jpeg.restart_hdr.f",
- FT_UINT16, BASE_DEC, NULL, 0x8000,
- NULL, HFILL
- }},
- { &hf_rtp_jpeg_restart_hdr_l, {
- "L",
- "jpeg.restart_hdr.l",
- FT_UINT16, BASE_DEC, NULL, 0x4000,
- NULL, HFILL
- }},
- { &hf_rtp_jpeg_restart_hdr_count, {
- "Restart Count",
- "jpeg.restart_hdr.count",
- FT_UINT16, BASE_DEC, NULL, 0x3FFF,
- NULL, HFILL
- }},
- { &hf_rtp_jpeg_qtable_hdr, {
- "Quantization Table Header",
- "jpeg.qtable_hdr",
- FT_NONE, BASE_NONE, NULL, 0,
- NULL, HFILL
- }},
- { &hf_rtp_jpeg_qtable_hdr_mbz, {
- "MBZ",
- "jpeg.qtable_hdr.mbz",
- FT_UINT8, BASE_DEC, NULL, 0,
- NULL, HFILL
- }},
- { &hf_rtp_jpeg_qtable_hdr_prec, {
- "Precision",
- "jpeg.qtable_hdr.precision",
- FT_UINT8, BASE_DEC, NULL, 0,
- NULL, HFILL
- }},
- { &hf_rtp_jpeg_qtable_hdr_length, {
- "Length",
- "jpeg.qtable_hdr.length",
- FT_UINT16, BASE_DEC, NULL, 0,
- NULL, HFILL
- }},
- { &hf_rtp_jpeg_qtable_hdr_data, {
- "Quantization Table Data",
- "jpeg.qtable_hdr.data",
- FT_BYTES, BASE_NONE, NULL, 0,
- NULL, HFILL
- }},
- { &hf_rtp_jpeg_payload, {
- "Payload",
- "jpeg.payload",
- FT_BYTES, BASE_NONE, NULL, 0,
- NULL, HFILL
- }},
+ &hfi_rtp_jpeg_main_hdr,
+ &hfi_rtp_jpeg_main_hdr_ts,
+ &hfi_rtp_jpeg_main_hdr_offs,
+ &hfi_rtp_jpeg_main_hdr_type,
+ &hfi_rtp_jpeg_main_hdr_q,
+ &hfi_rtp_jpeg_main_hdr_width,
+ &hfi_rtp_jpeg_main_hdr_height,
+ &hfi_rtp_jpeg_restart_hdr,
+ &hfi_rtp_jpeg_restart_hdr_interval,
+ &hfi_rtp_jpeg_restart_hdr_f,
+ &hfi_rtp_jpeg_restart_hdr_l,
+ &hfi_rtp_jpeg_restart_hdr_count,
+ &hfi_rtp_jpeg_qtable_hdr,
+ &hfi_rtp_jpeg_qtable_hdr_mbz,
+ &hfi_rtp_jpeg_qtable_hdr_prec,
+ &hfi_rtp_jpeg_qtable_hdr_length,
+ &hfi_rtp_jpeg_qtable_hdr_data,
+ &hfi_rtp_jpeg_payload,
};
static gint *ett[] =
@@ -265,20 +287,22 @@ proto_register_jpeg(void)
&ett_jpeg,
};
+ int proto_jpeg;
proto_jpeg = proto_register_protocol("RFC 2435 JPEG","JPEG","jpeg");
- proto_register_field_array(proto_jpeg, hf, array_length(hf));
+ hfi_jpeg = proto_registrar_get_nth(proto_jpeg);
+
+ proto_register_fields(proto_jpeg, hfi, array_length(hfi));
proto_register_subtree_array(ett, array_length(ett));
+ jpeg_handle = create_dissector_handle(dissect_jpeg, proto_jpeg);
+
/* RFC 2798 */
- register_ber_oid_dissector("0.9.2342.19200300.100.1.60", dissect_jpeg, proto_jpeg, "jpegPhoto");
+ register_ber_oid_dissector_handle("0.9.2342.19200300.100.1.60", jpeg_handle, proto_jpeg, "jpegPhoto");
}
void
proto_reg_handoff_jpeg(void)
{
- dissector_handle_t jpeg_handle;
-
- jpeg_handle = create_dissector_handle(dissect_jpeg, proto_jpeg);
dissector_add_uint("rtp.pt", PT_JPEG, jpeg_handle);
}
diff --git a/epan/dissectors/packet-udp.c b/epan/dissectors/packet-udp.c
index 88bb669b1a..443c319e1c 100644
--- a/epan/dissectors/packet-udp.c
+++ b/epan/dissectors/packet-udp.c
@@ -25,6 +25,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+#define NEW_PROTO_TREE_API
+
#include "config.h"
#include <string.h>
@@ -48,28 +50,85 @@
void proto_register_udp(void);
void proto_reg_handoff_udp(void);
+static dissector_handle_t udp_handle;
+static dissector_handle_t udplite_handle;
+
static int udp_tap = -1;
static int udp_follow_tap = -1;
-static int proto_udp = -1;
-static int proto_udplite = -1;
-static int hf_udp_srcport = -1;
-static int hf_udp_dstport = -1;
-static int hf_udp_port = -1;
-static int hf_udp_length = -1;
-static int hf_udplite_checksum_coverage = -1;
-static int hf_udplite_checksum_coverage_bad = -1;
-static int hf_udp_checksum = -1;
-static int hf_udp_checksum_good = -1;
-static int hf_udp_checksum_bad = -1;
-static int hf_udp_proc_src_uid = -1;
-static int hf_udp_proc_src_pid = -1;
-static int hf_udp_proc_src_uname = -1;
-static int hf_udp_proc_src_cmd = -1;
-static int hf_udp_proc_dst_uid = -1;
-static int hf_udp_proc_dst_pid = -1;
-static int hf_udp_proc_dst_uname = -1;
-static int hf_udp_proc_dst_cmd = -1;
+static header_field_info *hfi_udp = NULL;
+static header_field_info *hfi_udplite = NULL;
+
+#define UDP_HFI_INIT HFI_INIT(proto_udp)
+#define UDPLITE_HFI_INIT HFI_INIT(proto_udplite)
+
+static header_field_info hfi_udp_srcport UDP_HFI_INIT =
+ { "Source Port", "udp.srcport", FT_UINT16, BASE_DEC, NULL, 0x0,
+ NULL, HFILL };
+
+static header_field_info hfi_udp_dstport UDP_HFI_INIT =
+ { "Destination Port", "udp.dstport", FT_UINT16, BASE_DEC, NULL, 0x0,
+ NULL, HFILL };
+
+static header_field_info hfi_udp_port UDP_HFI_INIT =
+ { "Source or Destination Port", "udp.port", FT_UINT16, BASE_DEC, NULL, 0x0,
+ NULL, HFILL };
+
+static header_field_info hfi_udp_length UDP_HFI_INIT =
+ { "Length", "udp.length", FT_UINT16, BASE_DEC, NULL, 0x0,
+ NULL, HFILL };
+
+static header_field_info hfi_udp_checksum UDP_HFI_INIT =
+ { "Checksum", "udp.checksum", FT_UINT16, BASE_HEX, NULL, 0x0,
+ "Details at: http://www.wireshark.org/docs/wsug_html_chunked/ChAdvChecksums.html", HFILL };
+
+static header_field_info hfi_udp_checksum_good UDP_HFI_INIT =
+ { "Good Checksum", "udp.checksum_good", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
+ "True: checksum matches packet content; False: doesn't match content or not checked", HFILL };
+
+static header_field_info hfi_udp_checksum_bad UDP_HFI_INIT =
+ { "Bad Checksum", "udp.checksum_bad", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
+ "True: checksum doesn't match packet content; False: matches content or not checked", HFILL };
+
+static header_field_info hfi_udp_proc_src_uid UDP_HFI_INIT =
+ { "Source process user ID", "udp.proc.srcuid", FT_UINT32, BASE_DEC, NULL, 0x0,
+ NULL, HFILL};
+
+static header_field_info hfi_udp_proc_src_pid UDP_HFI_INIT =
+ { "Source process ID", "udp.proc.srcpid", FT_UINT32, BASE_DEC, NULL, 0x0,
+ NULL, HFILL};
+
+static header_field_info hfi_udp_proc_src_uname UDP_HFI_INIT =
+ { "Source process user name", "udp.proc.srcuname", FT_STRING, BASE_NONE, NULL, 0x0,
+ NULL, HFILL};
+
+static header_field_info hfi_udp_proc_src_cmd UDP_HFI_INIT =
+ { "Source process name", "udp.proc.srccmd", FT_STRING, BASE_NONE, NULL, 0x0,
+ "Source process command name", HFILL};
+
+static header_field_info hfi_udp_proc_dst_uid UDP_HFI_INIT =
+ { "Destination process user ID", "udp.proc.dstuid", FT_UINT32, BASE_DEC, NULL, 0x0,
+ NULL, HFILL};
+
+static header_field_info hfi_udp_proc_dst_pid UDP_HFI_INIT =
+ { "Destination process ID", "udp.proc.dstpid", FT_UINT32, BASE_DEC, NULL, 0x0,
+ NULL, HFILL};
+
+static header_field_info hfi_udp_proc_dst_uname UDP_HFI_INIT =
+ { "Destination process user name", "udp.proc.dstuname", FT_STRING, BASE_NONE, NULL, 0x0,
+ NULL, HFILL};
+
+static header_field_info hfi_udp_proc_dst_cmd UDP_HFI_INIT =
+ { "Destination process name", "udp.proc.dstcmd", FT_STRING, BASE_NONE, NULL, 0x0,
+ "Destination process command name", HFILL};
+
+static header_field_info hfi_udplite_checksum_coverage UDPLITE_HFI_INIT =
+ { "Checksum coverage", "udp.checksum_coverage", FT_UINT16, BASE_DEC, NULL, 0x0,
+ NULL, HFILL };
+
+static header_field_info hfi_udplite_checksum_coverage_bad UDPLITE_HFI_INIT =
+ { "Bad Checksum coverage", "udp.checksum_coverage_bad", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
+ NULL, HFILL };
static gint ett_udp = -1;
static gint ett_udp_checksum = -1;
@@ -138,7 +197,7 @@ get_udp_conversation_data(conversation_t *conv, packet_info *pinfo)
conv = find_or_create_conversation(pinfo);
/* Get the data for this conversation */
- udpd=(struct udp_analysis *)conversation_get_proto_data(conv, proto_udp);
+ udpd=(struct udp_analysis *)conversation_get_proto_data(conv, hfi_udp->id);
/* If the conversation was just created or it matched a
* conversation with template options, udpd will not
@@ -147,7 +206,7 @@ get_udp_conversation_data(conversation_t *conv, packet_info *pinfo)
*/
if (!udpd) {
udpd = init_udp_conversation_data();
- conversation_add_proto_data(conv, proto_udp, udpd);
+ conversation_add_proto_data(conv, hfi_udp->id, udpd);
}
if (!udpd) {
@@ -188,7 +247,7 @@ add_udp_process_info(guint32 frame_num, address *local_addr, address *remote_add
return;
}
- udpd = (struct udp_analysis *)conversation_get_proto_data(conv, proto_udp);
+ udpd = (struct udp_analysis *)conversation_get_proto_data(conv, hfi_udp->id);
if (!udpd) {
return;
}
@@ -327,20 +386,20 @@ dissect(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 ip_proto)
if (tree) {
if (udp_summary_in_tree) {
if (ip_proto == IP_PROTO_UDP) {
- ti = proto_tree_add_protocol_format(tree, proto_udp, tvb, offset, 8,
+ ti = proto_tree_add_protocol_format(tree, hfi_udp->id, tvb, offset, 8,
"User Datagram Protocol, Src Port: %s (%u), Dst Port: %s (%u)",
get_udp_port(udph->uh_sport), udph->uh_sport, get_udp_port(udph->uh_dport), udph->uh_dport);
} else {
- ti = proto_tree_add_protocol_format(tree, proto_udplite, tvb, offset, 8,
+ ti = proto_tree_add_protocol_format(tree, hfi_udplite->id, tvb, offset, 8,
"Lightweight User Datagram Protocol, Src Port: %s (%u), Dst Port: %s (%u)",
get_udp_port(udph->uh_sport), udph->uh_sport, get_udp_port(udph->uh_dport), udph->uh_dport);
}
} else {
- ti = proto_tree_add_item(tree, (ip_proto == IP_PROTO_UDP) ? proto_udp : proto_udplite, tvb, offset, 8, ENC_NA);
+ ti = proto_tree_add_item(tree, (ip_proto == IP_PROTO_UDP) ? hfi_udp : hfi_udplite, tvb, offset, 8, ENC_NA);
}
udp_tree = proto_item_add_subtree(ti, ett_udp);
- port_item = proto_tree_add_uint_format(udp_tree, hf_udp_srcport, tvb, offset, 2, udph->uh_sport,
+ port_item = proto_tree_add_uint_format(udp_tree, hfi_udp_srcport.id, tvb, offset, 2, udph->uh_sport,
"Source port: %s (%u)", get_udp_port(udph->uh_sport), udph->uh_sport);
/* The beginning port number, 32768 + 666 (33434), is from LBL's traceroute.c source code and this code
* further assumes that 3 attempts are made per hop */
@@ -350,7 +409,7 @@ dissect(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 ip_proto)
((udph->uh_sport - 32768 - 666 - 1) % 3) + 1
);
- port_item = proto_tree_add_uint_format(udp_tree, hf_udp_dstport, tvb, offset + 2, 2, udph->uh_dport,
+ port_item = proto_tree_add_uint_format(udp_tree, hfi_udp_dstport.id, tvb, offset + 2, 2, udph->uh_dport,
"Destination port: %s (%u)", get_udp_port(udph->uh_dport), udph->uh_dport);
if(udph->uh_dport > 32768 + 666 && udph->uh_dport <= 32768 + 666 + 30)
expert_add_info_format_text(pinfo, port_item, &ei_udp_possible_traceroute, "Possible traceroute: hop #%u, attempt #%u",
@@ -358,9 +417,9 @@ dissect(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 ip_proto)
((udph->uh_dport - 32768 - 666 - 1) % 3) + 1
);
- hidden_item = proto_tree_add_uint(udp_tree, hf_udp_port, tvb, offset, 2, udph->uh_sport);
+ hidden_item = proto_tree_add_uint(udp_tree, &hfi_udp_port, tvb, offset, 2, udph->uh_sport);
PROTO_ITEM_SET_HIDDEN(hidden_item);
- hidden_item = proto_tree_add_uint(udp_tree, hf_udp_port, tvb, offset+2, 2, udph->uh_dport);
+ hidden_item = proto_tree_add_uint(udp_tree, &hfi_udp_port, tvb, offset+2, 2, udph->uh_dport);
PROTO_ITEM_SET_HIDDEN(hidden_item);
}
@@ -369,7 +428,7 @@ dissect(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 ip_proto)
if (udph->uh_ulen < 8) {
/* Bogus length - it includes the header, so it must be >= 8. */
/* XXX - should handle IPv6 UDP jumbograms (RFC 2675), where the length is zero */
- item = proto_tree_add_uint_format(udp_tree, hf_udp_length, tvb, offset + 4, 2,
+ item = proto_tree_add_uint_format(udp_tree, hfi_udp_length.id, tvb, offset + 4, 2,
udph->uh_ulen, "Length: %u (bogus, must be >= 8)", udph->uh_ulen);
expert_add_info_format_text(pinfo, item, &ei_udp_length, "Bad length value %u < 8", udph->uh_ulen);
col_append_fstr(pinfo->cinfo, COL_INFO, " [BAD UDP LENGTH %u < 8]", udph->uh_ulen);
@@ -377,15 +436,15 @@ dissect(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 ip_proto)
}
if ((udph->uh_ulen > tvb_reported_length(tvb)) && ! pinfo->fragmented && ! pinfo->flags.in_error_pkt) {
/* Bogus length - it goes past the end of the IP payload */
- item = proto_tree_add_uint_format(udp_tree, hf_udp_length, tvb, offset + 4, 2,
+ item = proto_tree_add_uint_format(udp_tree, hfi_udp_length.id, tvb, offset + 4, 2,
udph->uh_ulen, "Length: %u (bogus, payload length %u)", udph->uh_ulen, tvb_reported_length(tvb));
expert_add_info_format_text(pinfo, item, &ei_udp_length, "Bad length value %u > IP payload length", udph->uh_ulen);
col_append_fstr(pinfo->cinfo, COL_INFO, " [BAD UDP LENGTH %u > IP PAYLOAD LENGTH]", udph->uh_ulen);
} else {
if (tree) {
- proto_tree_add_uint(udp_tree, hf_udp_length, tvb, offset + 4, 2, udph->uh_ulen);
+ proto_tree_add_uint(udp_tree, &hfi_udp_length, tvb, offset + 4, 2, udph->uh_ulen);
/* XXX - why is this here, given that this is UDP, not Lightweight UDP? */
- hidden_item = proto_tree_add_uint(udp_tree, hf_udplite_checksum_coverage, tvb, offset + 4,
+ hidden_item = proto_tree_add_uint(udp_tree, &hfi_udplite_checksum_coverage, tvb, offset + 4,
0, udph->uh_sum_cov);
PROTO_ITEM_SET_HIDDEN(hidden_item);
}
@@ -396,12 +455,12 @@ dissect(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 ip_proto)
if (((udph->uh_sum_cov > 0) && (udph->uh_sum_cov < 8)) || (udph->uh_sum_cov > udph->uh_ulen)) {
/* Bogus length - it includes the header, so it must be >= 8, and no larger then the IP payload size. */
if (tree) {
- hidden_item = proto_tree_add_boolean(udp_tree, hf_udplite_checksum_coverage_bad, tvb, offset + 4, 2, TRUE);
+ hidden_item = proto_tree_add_boolean(udp_tree, &hfi_udplite_checksum_coverage_bad, tvb, offset + 4, 2, TRUE);
PROTO_ITEM_SET_HIDDEN(hidden_item);
- hidden_item = proto_tree_add_uint(udp_tree, hf_udp_length, tvb, offset + 4, 0, udph->uh_ulen);
+ hidden_item = proto_tree_add_uint(udp_tree, &hfi_udp_length, tvb, offset + 4, 0, udph->uh_ulen);
PROTO_ITEM_SET_HIDDEN(hidden_item);
}
- item = proto_tree_add_uint_format(udp_tree, hf_udplite_checksum_coverage, tvb, offset + 4, 2,
+ item = proto_tree_add_uint_format(udp_tree, hfi_udplite_checksum_coverage.id, tvb, offset + 4, 2,
udph->uh_sum_cov, "Checksum coverage: %u (bogus, must be >= 8 and <= %u (ip.len-ip.hdr_len))",
udph->uh_sum_cov, udph->uh_ulen);
expert_add_info_format_text(pinfo, item, &ei_udplite_checksum_coverage, "Bad checksum coverage length value %u < 8 or > %u",
@@ -412,9 +471,9 @@ dissect(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 ip_proto)
return;
} else {
if (tree) {
- hidden_item = proto_tree_add_uint(udp_tree, hf_udp_length, tvb, offset + 4, 0, udph->uh_ulen);
+ hidden_item = proto_tree_add_uint(udp_tree, &hfi_udp_length, tvb, offset + 4, 0, udph->uh_ulen);
PROTO_ITEM_SET_HIDDEN(hidden_item);
- proto_tree_add_uint(udp_tree, hf_udplite_checksum_coverage, tvb, offset + 4, 2, udph->uh_sum_cov);
+ proto_tree_add_uint(udp_tree, &hfi_udplite_checksum_coverage, tvb, offset + 4, 2, udph->uh_sum_cov);
}
}
}
@@ -426,27 +485,27 @@ dissect(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 ip_proto)
if (udph->uh_sum == 0) {
/* No checksum supplied in the packet. */
if ((ip_proto == IP_PROTO_UDP) && (pinfo->src.type == AT_IPv4)) {
- item = proto_tree_add_uint_format(udp_tree, hf_udp_checksum, tvb, offset + 6, 2, 0,
+ item = proto_tree_add_uint_format(udp_tree, hfi_udp_checksum.id, tvb, offset + 6, 2, 0,
"Checksum: 0x%04x (none)", 0);
checksum_tree = proto_item_add_subtree(item, ett_udp_checksum);
- item = proto_tree_add_boolean(checksum_tree, hf_udp_checksum_good, tvb,
+ item = proto_tree_add_boolean(checksum_tree, &hfi_udp_checksum_good, tvb,
offset + 6, 2, FALSE);
PROTO_ITEM_SET_GENERATED(item);
- item = proto_tree_add_boolean(checksum_tree, hf_udp_checksum_bad, tvb,
+ item = proto_tree_add_boolean(checksum_tree, &hfi_udp_checksum_bad, tvb,
offset + 6, 2, FALSE);
PROTO_ITEM_SET_GENERATED(item);
} else {
- item = proto_tree_add_uint_format(udp_tree, hf_udp_checksum, tvb, offset + 6, 2, 0,
+ item = proto_tree_add_uint_format(udp_tree, hfi_udp_checksum.id, tvb, offset + 6, 2, 0,
"Checksum: 0x%04x (Illegal)", 0);
expert_add_info(pinfo, item, &ei_udp_checksum_zero);
col_append_fstr(pinfo->cinfo, COL_INFO, " [ILLEGAL CHECKSUM (0)]");
checksum_tree = proto_item_add_subtree(item, ett_udp_checksum);
- item = proto_tree_add_boolean(checksum_tree, hf_udp_checksum_good, tvb,
+ item = proto_tree_add_boolean(checksum_tree, &hfi_udp_checksum_good, tvb,
offset + 6, 2, FALSE);
PROTO_ITEM_SET_GENERATED(item);
- item = proto_tree_add_boolean(checksum_tree, hf_udp_checksum_bad, tvb,
+ item = proto_tree_add_boolean(checksum_tree, &hfi_udp_checksum_bad, tvb,
offset + 6, 2, TRUE);
PROTO_ITEM_SET_GENERATED(item);
}
@@ -494,27 +553,27 @@ dissect(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 ip_proto)
cksum_vec[3].len = udph->uh_sum_cov;
computed_cksum = in_cksum(&cksum_vec[0], 4);
if (computed_cksum == 0) {
- item = proto_tree_add_uint_format(udp_tree, hf_udp_checksum, tvb,
+ item = proto_tree_add_uint_format(udp_tree, hfi_udp_checksum.id, tvb,
offset + 6, 2, udph->uh_sum, "Checksum: 0x%04x [correct]", udph->uh_sum);
checksum_tree = proto_item_add_subtree(item, ett_udp_checksum);
- item = proto_tree_add_boolean(checksum_tree, hf_udp_checksum_good, tvb,
+ item = proto_tree_add_boolean(checksum_tree, &hfi_udp_checksum_good, tvb,
offset + 6, 2, TRUE);
PROTO_ITEM_SET_GENERATED(item);
- item = proto_tree_add_boolean(checksum_tree, hf_udp_checksum_bad, tvb,
+ item = proto_tree_add_boolean(checksum_tree, &hfi_udp_checksum_bad, tvb,
offset + 6, 2, FALSE);
PROTO_ITEM_SET_GENERATED(item);
} else {
- item = proto_tree_add_uint_format(udp_tree, hf_udp_checksum, tvb,
+ item = proto_tree_add_uint_format(udp_tree, hfi_udp_checksum.id, tvb,
offset + 6, 2, udph->uh_sum,
"Checksum: 0x%04x [incorrect, should be 0x%04x (maybe caused by \"UDP checksum offload\"?)]", udph->uh_sum,
in_cksum_shouldbe(udph->uh_sum, computed_cksum));
checksum_tree = proto_item_add_subtree(item, ett_udp_checksum);
- item = proto_tree_add_boolean(checksum_tree, hf_udp_checksum_good, tvb,
+ item = proto_tree_add_boolean(checksum_tree, &hfi_udp_checksum_good, tvb,
offset + 6, 2, FALSE);
PROTO_ITEM_SET_GENERATED(item);
- item = proto_tree_add_boolean(checksum_tree, hf_udp_checksum_bad, tvb,
+ item = proto_tree_add_boolean(checksum_tree, &hfi_udp_checksum_bad, tvb,
offset + 6, 2, TRUE);
PROTO_ITEM_SET_GENERATED(item);
expert_add_info(pinfo, item, &ei_udp_checksum_bad);
@@ -522,25 +581,25 @@ dissect(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 ip_proto)
col_append_fstr(pinfo->cinfo, COL_INFO, " [UDP CHECKSUM INCORRECT]");
}
} else {
- item = proto_tree_add_uint_format(udp_tree, hf_udp_checksum, tvb,
+ item = proto_tree_add_uint_format(udp_tree, hfi_udp_checksum.id, tvb,
offset + 6, 2, udph->uh_sum, "Checksum: 0x%04x [validation disabled]", udph->uh_sum);
checksum_tree = proto_item_add_subtree(item, ett_udp_checksum);
- item = proto_tree_add_boolean(checksum_tree, hf_udp_checksum_good, tvb,
+ item = proto_tree_add_boolean(checksum_tree, &hfi_udp_checksum_good, tvb,
offset + 6, 2, FALSE);
PROTO_ITEM_SET_GENERATED(item);
- item = proto_tree_add_boolean(checksum_tree, hf_udp_checksum_bad, tvb,
+ item = proto_tree_add_boolean(checksum_tree, &hfi_udp_checksum_bad, tvb,
offset + 6, 2, FALSE);
PROTO_ITEM_SET_GENERATED(item);
}
} else {
- item = proto_tree_add_uint_format(udp_tree, hf_udp_checksum, tvb,
+ item = proto_tree_add_uint_format(udp_tree, hfi_udp_checksum.id, tvb,
offset + 6, 2, udph->uh_sum, "Checksum: 0x%04x [unchecked, not all data available]", udph->uh_sum);
checksum_tree = proto_item_add_subtree(item, ett_udp_checksum);
- item = proto_tree_add_boolean(checksum_tree, hf_udp_checksum_good, tvb,
+ item = proto_tree_add_boolean(checksum_tree, &hfi_udp_checksum_good, tvb,
offset + 6, 2, FALSE);
PROTO_ITEM_SET_GENERATED(item);
- item = proto_tree_add_boolean(checksum_tree, hf_udp_checksum_bad, tvb,
+ item = proto_tree_add_boolean(checksum_tree, &hfi_udp_checksum_bad, tvb,
offset + 6, 2, FALSE);
PROTO_ITEM_SET_GENERATED(item);
}
@@ -565,23 +624,23 @@ dissect(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 ip_proto)
PROTO_ITEM_SET_GENERATED(ti);
process_tree = proto_item_add_subtree(ti, ett_udp_process_info);
if (udpd->fwd && udpd->fwd->command) {
- proto_tree_add_uint_format_value(process_tree, hf_udp_proc_dst_uid, tvb, 0, 0,
+ proto_tree_add_uint_format_value(process_tree, hfi_udp_proc_dst_uid.id, tvb, 0, 0,
udpd->fwd->process_uid, "%u", udpd->fwd->process_uid);
- proto_tree_add_uint_format_value(process_tree, hf_udp_proc_dst_pid, tvb, 0, 0,
+ proto_tree_add_uint_format_value(process_tree, hfi_udp_proc_dst_pid.id, tvb, 0, 0,
udpd->fwd->process_pid, "%u", udpd->fwd->process_pid);
- proto_tree_add_string_format_value(process_tree, hf_udp_proc_dst_uname, tvb, 0, 0,
+ proto_tree_add_string_format_value(process_tree, hfi_udp_proc_dst_uname.id, tvb, 0, 0,
udpd->fwd->username, "%s", udpd->fwd->username);
- proto_tree_add_string_format_value(process_tree, hf_udp_proc_dst_cmd, tvb, 0, 0,
+ proto_tree_add_string_format_value(process_tree, hfi_udp_proc_dst_cmd.id, tvb, 0, 0,
udpd->fwd->command, "%s", udpd->fwd->command);
}
if (udpd->rev->command) {
- proto_tree_add_uint_format_value(process_tree, hf_udp_proc_src_uid, tvb, 0, 0,
+ proto_tree_add_uint_format_value(process_tree, hfi_udp_proc_src_uid.id, tvb, 0, 0,
udpd->rev->process_uid, "%u", udpd->rev->process_uid);
- proto_tree_add_uint_format_value(process_tree, hf_udp_proc_src_pid, tvb, 0, 0,
+ proto_tree_add_uint_format_value(process_tree, hfi_udp_proc_src_pid.id, tvb, 0, 0,
udpd->rev->process_pid, "%u", udpd->rev->process_pid);
- proto_tree_add_string_format_value(process_tree, hf_udp_proc_src_uname, tvb, 0, 0,
+ proto_tree_add_string_format_value(process_tree, hfi_udp_proc_src_uname.id, tvb, 0, 0,
udpd->rev->username, "%s", udpd->rev->username);
- proto_tree_add_string_format_value(process_tree, hf_udp_proc_src_cmd, tvb, 0, 0,
+ proto_tree_add_string_format_value(process_tree, hfi_udp_proc_src_cmd.id, tvb, 0, 0,
udpd->rev->command, "%s", udpd->rev->command);
}
}
@@ -622,76 +681,27 @@ proto_register_udp(void)
module_t *udplite_module;
expert_module_t* expert_udp;
- static hf_register_info hf[] = {
- { &hf_udp_srcport,
- { "Source Port", "udp.srcport", FT_UINT16, BASE_DEC, NULL, 0x0,
- NULL, HFILL }},
-
- { &hf_udp_dstport,
- { "Destination Port", "udp.dstport", FT_UINT16, BASE_DEC, NULL, 0x0,
- NULL, HFILL }},
-
- { &hf_udp_port,
- { "Source or Destination Port", "udp.port", FT_UINT16, BASE_DEC, NULL, 0x0,
- NULL, HFILL }},
-
- { &hf_udp_length,
- { "Length", "udp.length", FT_UINT16, BASE_DEC, NULL, 0x0,
- NULL, HFILL }},
-
- { &hf_udp_checksum,
- { "Checksum", "udp.checksum", FT_UINT16, BASE_HEX, NULL, 0x0,
- "Details at: http://www.wireshark.org/docs/wsug_html_chunked/ChAdvChecksums.html", HFILL }},
-
- { &hf_udp_checksum_good,
- { "Good Checksum", "udp.checksum_good", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
- "True: checksum matches packet content; False: doesn't match content or not checked", HFILL }},
-
- { &hf_udp_checksum_bad,
- { "Bad Checksum", "udp.checksum_bad", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
- "True: checksum doesn't match packet content; False: matches content or not checked", HFILL }},
-
- { &hf_udp_proc_src_uid,
- { "Source process user ID", "udp.proc.srcuid", FT_UINT32, BASE_DEC, NULL, 0x0,
- NULL, HFILL}},
-
- { &hf_udp_proc_src_pid,
- { "Source process ID", "udp.proc.srcpid", FT_UINT32, BASE_DEC, NULL, 0x0,
- NULL, HFILL}},
-
- { &hf_udp_proc_src_uname,
- { "Source process user name", "udp.proc.srcuname", FT_STRING, BASE_NONE, NULL, 0x0,
- NULL, HFILL}},
-
- { &hf_udp_proc_src_cmd,
- { "Source process name", "udp.proc.srccmd", FT_STRING, BASE_NONE, NULL, 0x0,
- "Source process command name", HFILL}},
-
- { &hf_udp_proc_dst_uid,
- { "Destination process user ID", "udp.proc.dstuid", FT_UINT32, BASE_DEC, NULL, 0x0,
- NULL, HFILL}},
-
- { &hf_udp_proc_dst_pid,
- { "Destination process ID", "udp.proc.dstpid", FT_UINT32, BASE_DEC, NULL, 0x0,
- NULL, HFILL}},
-
- { &hf_udp_proc_dst_uname,
- { "Destination process user name", "udp.proc.dstuname", FT_STRING, BASE_NONE, NULL, 0x0,
- NULL, HFILL}},
-
- { &hf_udp_proc_dst_cmd,
- { "Destination process name", "udp.proc.dstcmd", FT_STRING, BASE_NONE, NULL, 0x0,
- "Destination process command name", HFILL}}
+ static header_field_info *hfi[] = {
+ &hfi_udp_srcport,
+ &hfi_udp_dstport,
+ &hfi_udp_port,
+ &hfi_udp_length,
+ &hfi_udp_checksum,
+ &hfi_udp_checksum_good,
+ &hfi_udp_checksum_bad,
+ &hfi_udp_proc_src_uid,
+ &hfi_udp_proc_src_pid,
+ &hfi_udp_proc_src_uname,
+ &hfi_udp_proc_src_cmd,
+ &hfi_udp_proc_dst_uid,
+ &hfi_udp_proc_dst_pid,
+ &hfi_udp_proc_dst_uname,
+ &hfi_udp_proc_dst_cmd,
};
- static hf_register_info hf_lite[] = {
- { &hf_udplite_checksum_coverage_bad,
- { "Bad Checksum coverage", "udp.checksum_coverage_bad", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
- NULL, HFILL }},
-
- { &hf_udplite_checksum_coverage,
- { "Checksum coverage", "udp.checksum_coverage", FT_UINT16, BASE_DEC, NULL, 0x0,
- NULL, HFILL }}
+ static header_field_info *hfi_lite[] = {
+ &hfi_udplite_checksum_coverage_bad,
+ &hfi_udplite_checksum_coverage,
};
static gint *ett[] = {
@@ -708,15 +718,22 @@ proto_register_udp(void)
{ &ei_udp_checksum_bad, { "udp.checksum_bad.expert", PI_CHECKSUM, PI_ERROR, "Bad checksum", EXPFILL }},
};
+ int proto_udp, proto_udplite;
+
proto_udp = proto_register_protocol("User Datagram Protocol",
"UDP", "udp");
- register_dissector("udp", dissect_udp, proto_udp);
+ hfi_udp = proto_registrar_get_nth(proto_udp);
+ udp_handle = register_dissector("udp", dissect_udp, proto_udp);
+ expert_udp = expert_register_protocol(proto_udp);
+ proto_register_fields(proto_udp, hfi, array_length(hfi));
+
proto_udplite = proto_register_protocol("Lightweight User Datagram Protocol",
"UDPlite", "udplite");
- proto_register_field_array(proto_udp, hf, array_length(hf));
- proto_register_field_array(proto_udplite, hf_lite, array_length(hf_lite));
+ udplite_handle = create_dissector_handle(dissect_udplite, proto_udplite);
+ hfi_udplite = proto_registrar_get_nth(proto_udplite);
+ proto_register_fields(proto_udplite, hfi_lite, array_length(hfi_lite));
+
proto_register_subtree_array(ett, array_length(ett));
- expert_udp = expert_register_protocol(proto_udp);
expert_register_field_array(expert_udp, ei, array_length(ei));
/* subdissector code */
@@ -758,12 +775,7 @@ proto_register_udp(void)
void
proto_reg_handoff_udp(void)
{
- dissector_handle_t udp_handle;
- dissector_handle_t udplite_handle;
-
- udp_handle = find_dissector("udp");
dissector_add_uint("ip.proto", IP_PROTO_UDP, udp_handle);
- udplite_handle = create_dissector_handle(dissect_udplite, proto_udplite);
dissector_add_uint("ip.proto", IP_PROTO_UDPLITE, udplite_handle);
data_handle = find_dissector("data");
udp_tap = register_tap("udp");