diff options
Diffstat (limited to 'epan/dissectors/packet-http-urlencoded.c')
-rw-r--r-- | epan/dissectors/packet-http-urlencoded.c | 52 |
1 files changed, 28 insertions, 24 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); } |