diff options
-rw-r--r-- | epan/dissectors/packet-dbus.c | 221 | ||||
-rw-r--r-- | epan/dissectors/packet-gadu-gadu.c | 805 | ||||
-rw-r--r-- | epan/dissectors/packet-json.c | 105 | ||||
-rw-r--r-- | epan/dissectors/packet-nflog.c | 157 | ||||
-rw-r--r-- | epan/dissectors/packet-yami.c | 218 |
5 files changed, 757 insertions, 749 deletions
diff --git a/epan/dissectors/packet-dbus.c b/epan/dissectors/packet-dbus.c index de09f029b7..58f17c4089 100644 --- a/epan/dissectors/packet-dbus.c +++ b/epan/dissectors/packet-dbus.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 <epan/packet.h> @@ -37,36 +39,6 @@ void proto_reg_handoff_dbus(void); static gboolean dbus_desegment = TRUE; -static int hf_dbus_hdr = -1; -static int hf_dbus_hdr_endianness = -1; -static int hf_dbus_hdr_type = -1; -static int hf_dbus_hdr_flags = -1; -static int hf_dbus_hdr_version = -1; -static int hf_dbus_hdr_body_length = -1; -static int hf_dbus_hdr_serial = -1; -static int hf_dbus_hdr_fields_length = -1; -static int hf_dbus_hdr_field = -1; -static int hf_dbus_hdr_field_code = -1; - -static int hf_dbus_value_bool = -1; -static int hf_dbus_value_int = -1; -static int hf_dbus_value_uint = -1; -static int hf_dbus_value_str = -1; -static int hf_dbus_value_double = -1; - -static int hf_dbus_body = -1; -static int hf_dbus_type_signature = -1; - -static int ett_dbus = -1; -static int ett_dbus_hdr = -1; -static int ett_dbus_body = -1; -static int ett_dbus_field = -1; - -static expert_field ei_dbus_value_bool_invalid = EI_INIT; -static expert_field ei_dbus_value_str_invalid = EI_INIT; -static expert_field ei_dbus_invalid_object_path = EI_INIT; -static expert_field ei_dbus_invalid_signature = EI_INIT; - static int proto_dbus = -1; #define DBUS_MESSAGE_TYPE_INVALID 0 @@ -109,6 +81,73 @@ static const value_string field_code_vals[] = { { 0, NULL } }; +/* XXX, FT_NONE -> FT_BYTES? */ + +/* Header */ +static header_field_info hfi_dbus_hdr HFI_INIT(proto_dbus) = + { "Header", "dbus.header", FT_NONE, BASE_NONE, NULL, 0x00, NULL, HFILL }; + +static header_field_info hfi_dbus_hdr_endianness HFI_INIT(proto_dbus) = + { "Endianness Flag", "dbus.endianness", FT_STRING, BASE_NONE, NULL, 0x00, NULL, HFILL }; + +static header_field_info hfi_dbus_hdr_type HFI_INIT(proto_dbus) = + { "Message Type", "dbus.type", FT_UINT8, BASE_DEC, VALS(message_type_vals), 0x00, NULL, HFILL }; + +static header_field_info hfi_dbus_hdr_flags HFI_INIT(proto_dbus) = + { "Message Flags", "dbus.flags", FT_UINT8, BASE_HEX, NULL, 0x00, NULL, HFILL }; + +static header_field_info hfi_dbus_hdr_version HFI_INIT(proto_dbus) = + { "Protocol Version", "dbus.version", FT_UINT8, BASE_DEC, NULL, 0x00, NULL, HFILL }; + +static header_field_info hfi_dbus_hdr_body_length HFI_INIT(proto_dbus) = + { "Message body Length", "dbus.length", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }; + +static header_field_info hfi_dbus_hdr_serial HFI_INIT(proto_dbus) = + { "Message Serial (cookie)", "dbus.serial", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }; + +static header_field_info hfi_dbus_hdr_fields_length HFI_INIT(proto_dbus) = + { "Header fields Length", "dbus.fields_length", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }; + +/* Header field */ +static header_field_info hfi_dbus_hdr_field HFI_INIT(proto_dbus) = + { "Header Field", "dbus.field", FT_NONE, BASE_NONE, NULL, 0x00, NULL, HFILL }; + +static header_field_info hfi_dbus_hdr_field_code HFI_INIT(proto_dbus) = + { "Field code", "dbus.field.code", FT_UINT8, BASE_DEC, VALS(field_code_vals), 0x00, NULL, HFILL }; + +static header_field_info hfi_dbus_type_signature HFI_INIT(proto_dbus) = + { "Type signature", "dbus.type_signature", FT_STRINGZ, BASE_NONE, NULL, 0x00, NULL, HFILL }; + +static header_field_info hfi_dbus_body HFI_INIT(proto_dbus) = + { "Body", "dbus.body", FT_NONE, BASE_NONE, NULL, 0x00, NULL, HFILL }; + +/* Values */ +static header_field_info hfi_dbus_value_bool HFI_INIT(proto_dbus) = + { "Value", "dbus.value.bool", FT_BOOLEAN, BASE_NONE, NULL, 0x00, NULL, HFILL }; + +static header_field_info hfi_dbus_value_int HFI_INIT(proto_dbus) = + { "Value", "dbus.value.int", FT_INT32, BASE_DEC, NULL, 0x00, NULL, HFILL }; + +static header_field_info hfi_dbus_value_uint HFI_INIT(proto_dbus) = + { "Value", "dbus.value.uint", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }; + +static header_field_info hfi_dbus_value_str HFI_INIT(proto_dbus) = + { "Value", "dbus.value.str", FT_STRING, BASE_NONE, NULL, 0x00, NULL, HFILL }; + +static header_field_info hfi_dbus_value_double HFI_INIT(proto_dbus) = + { "Value", "dbus.value.double", FT_DOUBLE, BASE_NONE, NULL, 0x00, NULL, HFILL }; + + +static int ett_dbus = -1; +static int ett_dbus_hdr = -1; +static int ett_dbus_body = -1; +static int ett_dbus_field = -1; + +static expert_field ei_dbus_value_bool_invalid = EI_INIT; +static expert_field ei_dbus_value_str_invalid = EI_INIT; +static expert_field ei_dbus_invalid_object_path = EI_INIT; +static expert_field ei_dbus_invalid_signature = EI_INIT; + typedef struct { packet_info *pinfo; @@ -173,7 +212,7 @@ dissect_dbus_sig(tvbuff_t *tvb, dbus_info_t *dinfo, proto_tree *tree, int offset val = tvb_get_guint8(tvb, offset); offset += 1; - proto_tree_add_uint_format(tree, hf_dbus_value_uint, tvb, org_offset, offset - org_offset, val, "BYTE: %u", val); + proto_tree_add_uint_format(tree, hfi_dbus_value_uint.id, tvb, org_offset, offset - org_offset, val, "BYTE: %u", val); ret->uint = val; return offset; } @@ -185,7 +224,7 @@ dissect_dbus_sig(tvbuff_t *tvb, dbus_info_t *dinfo, proto_tree *tree, int offset val = dinfo->get32(tvb, offset); offset += 4; - ti = proto_tree_add_boolean_format(tree, hf_dbus_value_bool, tvb, org_offset, offset - org_offset, val, "BOOLEAN: %s", val ? "True" : "False"); + ti = proto_tree_add_boolean_format(tree, hfi_dbus_value_bool.id, tvb, org_offset, offset - org_offset, val, "BOOLEAN: %s", val ? "True" : "False"); if (val != 0 && val != 1) { expert_add_info_format_text(dinfo->pinfo, ti, &ei_dbus_value_bool_invalid, "Invalid boolean value (must be 0 or 1 is: %u)", val); return -1; @@ -201,7 +240,7 @@ dissect_dbus_sig(tvbuff_t *tvb, dbus_info_t *dinfo, proto_tree *tree, int offset val = (gint16 )dinfo->get16(tvb, offset); offset += 2; - proto_tree_add_uint_format(tree, hf_dbus_value_int, tvb, org_offset, offset - org_offset, val, "INT16: %d", val); + proto_tree_add_uint_format(tree, hfi_dbus_value_int.id, tvb, org_offset, offset - org_offset, val, "INT16: %d", val); /* XXX ret */ return offset; } @@ -213,7 +252,7 @@ dissect_dbus_sig(tvbuff_t *tvb, dbus_info_t *dinfo, proto_tree *tree, int offset val = dinfo->get16(tvb, offset); offset += 2; - proto_tree_add_uint_format(tree, hf_dbus_value_uint, tvb, org_offset, offset - org_offset, val, "UINT16: %u", val); + proto_tree_add_uint_format(tree, hfi_dbus_value_uint.id, tvb, org_offset, offset - org_offset, val, "UINT16: %u", val); ret->uint = val; return offset; } @@ -225,7 +264,7 @@ dissect_dbus_sig(tvbuff_t *tvb, dbus_info_t *dinfo, proto_tree *tree, int offset val = (gint32) dinfo->get32(tvb, offset); offset += 4; - proto_tree_add_int_format(tree, hf_dbus_value_int, tvb, org_offset, offset - org_offset, val, "INT32: %d", val); + proto_tree_add_int_format(tree, hfi_dbus_value_int.id, tvb, org_offset, offset - org_offset, val, "INT32: %d", val); /* XXX ret */ return offset; } @@ -237,7 +276,7 @@ dissect_dbus_sig(tvbuff_t *tvb, dbus_info_t *dinfo, proto_tree *tree, int offset val = dinfo->get32(tvb, offset); offset += 4; - proto_tree_add_uint_format(tree, hf_dbus_value_uint, tvb, org_offset, offset - org_offset, val, "UINT32: %u", val); + proto_tree_add_uint_format(tree, hfi_dbus_value_uint.id, tvb, org_offset, offset - org_offset, val, "UINT32: %u", val); ret->uint = val; return offset; } @@ -253,7 +292,7 @@ dissect_dbus_sig(tvbuff_t *tvb, dbus_info_t *dinfo, proto_tree *tree, int offset val = dinfo->getdouble(tvb, offset); offset += 8; - proto_tree_add_double_format(tree, hf_dbus_value_double, tvb, org_offset, offset - org_offset, val, "DOUBLE: %." STRINGIFY(DBL_DIG) "g", val); + proto_tree_add_double_format(tree, hfi_dbus_value_double.id, tvb, org_offset, offset - org_offset, val, "DOUBLE: %." STRINGIFY(DBL_DIG) "g", val); /* XXX ret */ return offset; } @@ -271,13 +310,13 @@ dissect_dbus_sig(tvbuff_t *tvb, dbus_info_t *dinfo, proto_tree *tree, int offset offset += (len + 1 /* NUL-byte */ + 3) & ~3; if (sig == 's') { - ti = proto_tree_add_string_format(tree, hf_dbus_value_str, tvb, org_offset, offset - org_offset, val, "STRING: %s", val); + ti = proto_tree_add_string_format(tree, hfi_dbus_value_str.id, tvb, org_offset, offset - org_offset, val, "STRING: %s", val); if (!g_utf8_validate(val, -1, NULL)) { expert_add_info(dinfo->pinfo, ti, &ei_dbus_value_str_invalid); return -1; } } else { - ti = proto_tree_add_string_format(tree, hf_dbus_value_str, tvb, org_offset, offset - org_offset, val, "OBJECT_PATH: %s", val); + ti = proto_tree_add_string_format(tree, hfi_dbus_value_str.id, tvb, org_offset, offset - org_offset, val, "OBJECT_PATH: %s", val); if (!dbus_validate_object_path(val)) { expert_add_info(dinfo->pinfo, ti, &ei_dbus_invalid_object_path); return -1; @@ -298,7 +337,7 @@ dissect_dbus_sig(tvbuff_t *tvb, dbus_info_t *dinfo, proto_tree *tree, int offset val = tvb_get_ephemeral_string(tvb, offset, len); offset += (len + 1); - ti = proto_tree_add_string_format(tree, hf_dbus_value_str, tvb, org_offset, offset - org_offset, val, "SIGNATURE: %s", val); + ti = proto_tree_add_string_format(tree, hfi_dbus_value_str.id, tvb, org_offset, offset - org_offset, val, "SIGNATURE: %s", val); if (!dbus_validate_signature(val)) { expert_add_info(dinfo->pinfo, ti, &ei_dbus_invalid_signature); return -1; @@ -329,7 +368,7 @@ dissect_dbus_field_signature(tvbuff_t *tvb, dbus_info_t *dinfo, proto_tree *tree sig = tvb_get_ephemeral_string(tvb, offset, sig_len); offset += (sig_len + 1); - ti = proto_tree_add_string(tree, hf_dbus_type_signature, tvb, org_offset, offset - org_offset, sig); + ti = proto_tree_add_string(tree, hfi_dbus_type_signature.id, tvb, org_offset, offset - org_offset, sig); if (!dbus_validate_signature(sig)) { expert_add_info(dinfo->pinfo, ti, &ei_dbus_invalid_signature); return -1; @@ -396,11 +435,11 @@ dissect_dbus_hdr_fields(tvbuff_t *tvb, dbus_info_t *dinfo, proto_tree *tree, int guint8 field_code; - ti = proto_tree_add_item(tree, hf_dbus_hdr_field, tvb, offset, 0, ENC_NA); + ti = proto_tree_add_item(tree, &hfi_dbus_hdr_field, tvb, offset, 0, ENC_NA); field_tree = proto_item_add_subtree(ti, ett_dbus_field); field_code = tvb_get_guint8(tvb, offset); - proto_tree_add_item(field_tree, hf_dbus_hdr_field_code, tvb, offset, 1, dinfo->enc); + proto_tree_add_item(field_tree, &hfi_dbus_hdr_field_code, tvb, offset, 1, dinfo->enc); proto_item_append_text(ti, ": %s", val_to_str(field_code, field_code_vals, "Unknown: %d")); offset += 1; @@ -430,32 +469,32 @@ dissect_dbus_hdr(tvbuff_t *tvb, dbus_info_t *dinfo, proto_tree *tree, int offset guint8 type; - ti = proto_tree_add_item(tree, hf_dbus_hdr, tvb, offset, 0, ENC_NA); + ti = proto_tree_add_item(tree, &hfi_dbus_hdr, tvb, offset, 0, ENC_NA); hdr_tree = proto_item_add_subtree(ti, ett_dbus_hdr); - proto_tree_add_item(hdr_tree, hf_dbus_hdr_endianness, tvb, offset, 1, ENC_ASCII | ENC_NA); + proto_tree_add_item(hdr_tree, &hfi_dbus_hdr_endianness, tvb, offset, 1, ENC_ASCII | ENC_NA); offset += 1; type = tvb_get_guint8(tvb, offset); col_add_str(dinfo->pinfo->cinfo, COL_INFO, val_to_str_const(type, message_type_vals, "")); - proto_tree_add_item(hdr_tree, hf_dbus_hdr_type, tvb, offset, 1, dinfo->enc); + proto_tree_add_item(hdr_tree, &hfi_dbus_hdr_type, tvb, offset, 1, dinfo->enc); offset += 1; - proto_tree_add_item(hdr_tree, hf_dbus_hdr_flags, tvb, offset, 1, dinfo->enc); + proto_tree_add_item(hdr_tree, &hfi_dbus_hdr_flags, tvb, offset, 1, dinfo->enc); offset += 1; - proto_tree_add_item(hdr_tree, hf_dbus_hdr_version, tvb, offset, 1, dinfo->enc); + proto_tree_add_item(hdr_tree, &hfi_dbus_hdr_version, tvb, offset, 1, dinfo->enc); offset += 1; dinfo->body_len = dinfo->get32(tvb, offset); - proto_tree_add_item(hdr_tree, hf_dbus_hdr_body_length, tvb, offset, 4, dinfo->enc); + proto_tree_add_item(hdr_tree, &hfi_dbus_hdr_body_length, tvb, offset, 4, dinfo->enc); offset += 4; - proto_tree_add_item(hdr_tree, hf_dbus_hdr_serial, tvb, offset, 4, dinfo->enc); + proto_tree_add_item(hdr_tree, &hfi_dbus_hdr_serial, tvb, offset, 4, dinfo->enc); offset += 4; dinfo->fields_len = dinfo->get32(tvb, offset); - proto_tree_add_item(hdr_tree, hf_dbus_hdr_fields_length, tvb, offset, 4, dinfo->enc); + proto_tree_add_item(hdr_tree, &hfi_dbus_hdr_fields_length, tvb, offset, 4, dinfo->enc); offset += 4; return offset; @@ -470,7 +509,7 @@ dissect_dbus_body(tvbuff_t *tvb, dbus_info_t *dinfo, proto_tree *tree, int offse if (dinfo->body_len && dinfo->body_sig[0]) { const char *sig = dinfo->body_sig; - ti = proto_tree_add_item(tree, hf_dbus_body, tvb, offset, 0, ENC_NA); + ti = proto_tree_add_item(tree, &hfi_dbus_body, tvb, offset, 0, ENC_NA); body_tree = proto_item_add_subtree(ti, ett_dbus_body); while (*sig) { @@ -525,7 +564,7 @@ dissect_dbus(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_ } if (tree) { - proto_item *ti = proto_tree_add_item(tree, proto_dbus, tvb, 0, -1, ENC_NA); + proto_item *ti = proto_tree_add_item_old(tree, proto_dbus, tvb, 0, -1, ENC_NA); dbus_tree = proto_item_add_subtree(ti, ett_dbus); } @@ -585,65 +624,27 @@ dissect_dbus_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data void proto_register_dbus(void) { - /* XXX, FT_NONE -> FT_BYTES? */ - static hf_register_info hf[] = { + static header_field_info *hfi[] = { /* Header */ - { &hf_dbus_hdr, - { "Header", "dbus.header", FT_NONE, BASE_NONE, NULL, 0x00, NULL, HFILL } - }, - { &hf_dbus_hdr_endianness, - { "Endianness Flag", "dbus.endianness", FT_STRING, BASE_NONE, NULL, 0x00, NULL, HFILL } - }, - { &hf_dbus_hdr_type, - { "Message Type", "dbus.type", FT_UINT8, BASE_DEC, VALS(message_type_vals), 0x00, NULL, HFILL } - }, - { &hf_dbus_hdr_flags, - { "Message Flags", "dbus.flags", FT_UINT8, BASE_HEX, NULL, 0x00, NULL, HFILL } - }, - { &hf_dbus_hdr_version, - { "Protocol Version", "dbus.version", FT_UINT8, BASE_DEC, NULL, 0x00, NULL, HFILL } - }, - { &hf_dbus_hdr_body_length, - { "Message body Length", "dbus.length", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL } - }, - { &hf_dbus_hdr_serial, - { "Message Serial (cookie)", "dbus.serial", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL } - }, - { &hf_dbus_hdr_fields_length, - { "Header fields Length", "dbus.fields_length", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL } - }, + &hfi_dbus_hdr, + &hfi_dbus_hdr_endianness, + &hfi_dbus_hdr_type, + &hfi_dbus_hdr_flags, + &hfi_dbus_hdr_version, + &hfi_dbus_hdr_body_length, + &hfi_dbus_hdr_serial, + &hfi_dbus_hdr_fields_length, /* Header field */ - { &hf_dbus_hdr_field, - { "Header Field", "dbus.field", FT_NONE, BASE_NONE, NULL, 0x00, NULL, HFILL } - }, - { &hf_dbus_hdr_field_code, - { "Field code", "dbus.field.code", FT_UINT8, BASE_DEC, VALS(field_code_vals), 0x00, NULL, HFILL } - }, - - { &hf_dbus_type_signature, - { "Type signature", "dbus.type_signature", FT_STRINGZ, BASE_NONE, NULL, 0x00, NULL, HFILL } - }, - - { &hf_dbus_body, - { "Body", "dbus.body", FT_NONE, BASE_NONE, NULL, 0x00, NULL, HFILL } - }, - + &hfi_dbus_hdr_field, + &hfi_dbus_hdr_field_code, + &hfi_dbus_type_signature, + &hfi_dbus_body, /* Values */ - { &hf_dbus_value_bool, - { "Value", "dbus.value.bool", FT_BOOLEAN, BASE_NONE, NULL, 0x00, NULL, HFILL } - }, - { &hf_dbus_value_int, - { "Value", "dbus.value.int", FT_INT32, BASE_DEC, NULL, 0x00, NULL, HFILL } - }, - { &hf_dbus_value_uint, - { "Value", "dbus.value.uint", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL } - }, - { &hf_dbus_value_str, - { "Value", "dbus.value.str", FT_STRING, BASE_NONE, NULL, 0x00, NULL, HFILL } - }, - { &hf_dbus_value_double, - { "Value", "dbus.value.double", FT_DOUBLE, BASE_NONE, NULL, 0x00, NULL, HFILL } - } + &hfi_dbus_value_bool, + &hfi_dbus_value_int, + &hfi_dbus_value_uint, + &hfi_dbus_value_str, + &hfi_dbus_value_double, }; static gint *ett[] = { @@ -664,7 +665,7 @@ proto_register_dbus(void) proto_dbus = proto_register_protocol("D-Bus", "D-BUS", "dbus"); - proto_register_field_array(proto_dbus, hf, array_length(hf)); + proto_register_fields(proto_dbus, hfi, array_length(hfi)); proto_register_subtree_array(ett, array_length(ett)); expert_dbus = expert_register_protocol(proto_dbus); expert_register_field_array(expert_dbus, ei, array_length(ei)); diff --git a/epan/dissectors/packet-gadu-gadu.c b/epan/dissectors/packet-gadu-gadu.c index 504814cadc..2e58395909 100644 --- a/epan/dissectors/packet-gadu-gadu.c +++ b/epan/dissectors/packet-gadu-gadu.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 <glib.h> @@ -44,81 +46,6 @@ static int proto_gadu_gadu = -1; static int ett_gadu_gadu = -1; static int ett_gadu_gadu_contact = -1; -static int hf_gadu_gadu_header_type_recv = -1; -static int hf_gadu_gadu_header_type_send = -1; -static int hf_gadu_gadu_header_length = -1; - -static int hf_gadu_gadu_contact_uin = -1; -static int hf_gadu_gadu_contact_uin_str = -1; -static int hf_gadu_gadu_contact_type = -1; - -static int hf_gadu_gadu_login_uin = -1; -static int hf_gadu_gadu_login_hash_type = -1; -static int hf_gadu_gadu_login_hash = -1; -static int hf_gadu_gadu_login_status = -1; -static int hf_gadu_gadu_login_protocol = -1; -static int hf_gadu_gadu_login_version = -1; -static int hf_gadu_gadu_login80_lang = -1; -static int hf_gadu_gadu_login_local_ip = -1; -static int hf_gadu_gadu_login_local_port = -1; - -static int hf_gadu_gadu_userdata_uin = -1; -static int hf_gadu_gadu_userdata_attr_name = -1; -static int hf_gadu_gadu_userdata_attr_type = -1; -static int hf_gadu_gadu_userdata_attr_value = -1; - -static int hf_gadu_gadu_typing_notify_type = -1; -static int hf_gadu_gadu_typing_notify_uin = -1; - -static int hf_gadu_gadu_msg_uin = -1; -static int hf_gadu_gadu_msg_sender = -1; -static int hf_gadu_gadu_msg_recipient = -1; -static int hf_gadu_gadu_msg_seq = -1; -static int hf_gadu_gadu_msg_time = -1; -static int hf_gadu_gadu_msg_class = -1; -static int hf_gadu_gadu_msg_text = -1; -static int hf_gadu_gadu_msg80_offset_plain = -1; -static int hf_gadu_gadu_msg80_offset_attr = -1; - -static int hf_gadu_gadu_msg_ack_status = -1; -static int hf_gadu_gadu_msg_ack_recipient = -1; -static int hf_gadu_gadu_msg_ack_seq = -1; - -static int hf_gadu_gadu_status_uin = -1; -static int hf_gadu_gadu_status_status = -1; -static int hf_gadu_gadu_status_ip = -1; -static int hf_gadu_gadu_status_port = -1; -static int hf_gadu_gadu_status_version = -1; -static int hf_gadu_gadu_status_img_size = -1; -static int hf_gadu_gadu_status_descr = -1; - -static int hf_dcc_type = -1; -static int hf_dcc_id = -1; -static int hf_dcc_uin_to = -1; -static int hf_dcc_uin_from = -1; -static int hf_dcc_filename = -1; - -static int hf_gadu_gadu_new_status_status = -1; -static int hf_gadu_gadu_new_status_desc = -1; - -static int hf_gadu_gadu_userlist_request_type = -1; -static int hf_gadu_gadu_userlist_version = -1; -static int hf_gadu_gadu_userlist_format = -1; -static int hf_gadu_gadu_userlist_reply_type = -1; - -static int hf_gadu_gadu_pubdir_request_type = -1; -static int hf_gadu_gadu_pubdir_request_seq = -1; -static int hf_gadu_gadu_pubdir_request_str = -1; -static int hf_gadu_gadu_pubdir_reply_type = -1; -static int hf_gadu_gadu_pubdir_reply_seq = -1; -static int hf_gadu_gadu_pubdir_reply_str = -1; - -static int hf_gadu_gadu_welcome_seed = -1; - -static int hf_gadu_gadu_data = -1; - -static dissector_handle_t xml_handle; - #define GG_ERA_OMNIX_MASK 0x04000000 #define GG_HAS_AUDIO_MASK 0x40000000 @@ -408,6 +335,202 @@ static const value_string gadu_gadu_pubdir_type_vals[] = { { 0, NULL } }; +/* Header */ +static header_field_info hfi_gadu_gadu_header_type_recv HFI_INIT(proto_gadu_gadu) = + { "Packet Type", "gadu-gadu.recv", FT_UINT32, BASE_HEX, VALS(gadu_gadu_packets_type_recv), 0x0, "Packet Type (recv)", HFILL }; + +static header_field_info hfi_gadu_gadu_header_type_send HFI_INIT(proto_gadu_gadu) = + { "Packet Type", "gadu-gadu.send", FT_UINT32, BASE_HEX, VALS(gadu_gadu_packets_type_send), 0x0, "Packet Type (send)", HFILL }; + +static header_field_info hfi_gadu_gadu_header_length HFI_INIT(proto_gadu_gadu) = + { "Packet Length", "gadu-gadu.len", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }; + +/* Login common (gadu-gadu.login.*) */ +static header_field_info hfi_gadu_gadu_login_uin HFI_INIT(proto_gadu_gadu) = + { "Client UIN", "gadu-gadu.login.uin", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }; + +static header_field_info hfi_gadu_gadu_login_hash_type HFI_INIT(proto_gadu_gadu) = + { "Login hash type", "gadu-gadu.login.hash_type", FT_UINT8, BASE_HEX, gadu_gadu_hash_type_vals, 0x00, NULL, HFILL }; + +static header_field_info hfi_gadu_gadu_login_hash HFI_INIT(proto_gadu_gadu) = + { "Login hash", "gadu-gadu.login.hash", FT_BYTES, BASE_NONE, NULL, 0x00, NULL, HFILL }; + +static header_field_info hfi_gadu_gadu_login_status HFI_INIT(proto_gadu_gadu) = + { "Client status", "gadu-gadu.login.status", FT_UINT32, BASE_HEX, NULL, 0x00, NULL, HFILL }; + +static header_field_info hfi_gadu_gadu_login_protocol HFI_INIT(proto_gadu_gadu) = + { "Client protocol", "gadu-gadu.login.protocol", FT_UINT32, BASE_HEX, NULL, 0x00, NULL, HFILL }; + +static header_field_info hfi_gadu_gadu_login_version HFI_INIT(proto_gadu_gadu) = + { "Client version", "gadu-gadu.login.version", FT_STRING, BASE_NONE, NULL, 0x00, NULL, HFILL }; + +static header_field_info hfi_gadu_gadu_login_local_ip HFI_INIT(proto_gadu_gadu) = + { "Client local IP", "gadu-gadu.login.local_ip", FT_IPv4, BASE_NONE, NULL, 0x00, NULL, HFILL }; + +static header_field_info hfi_gadu_gadu_login_local_port HFI_INIT(proto_gadu_gadu) = + { "Client local port", "gadu-gadu.login.local_port", FT_UINT16, BASE_DEC, NULL, 0x00, NULL, HFILL }; + +/* GG_LOGIN80 (gadu-gadu.login80.*) */ +static header_field_info hfi_gadu_gadu_login80_lang HFI_INIT(proto_gadu_gadu) = + { "Client language", "gadu-gadu.login80.lang", FT_STRING, BASE_NONE, NULL, 0x00, NULL, HFILL }; + +/* Contacts details (gadu-gadu.user_data.*) */ +static header_field_info hfi_gadu_gadu_userdata_uin HFI_INIT(proto_gadu_gadu) = + { "UIN", "gadu-gadu.user_data.uin", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }; + +static header_field_info hfi_gadu_gadu_userdata_attr_name HFI_INIT(proto_gadu_gadu) = + { "Attribute name", "gadu-gadu.user_data.attr_name", FT_STRING, BASE_NONE, NULL, 0x00, NULL, HFILL }; + +static header_field_info hfi_gadu_gadu_userdata_attr_type HFI_INIT(proto_gadu_gadu) = + { "Attribute type", "gadu-gadu.user_data.attr_type", FT_UINT32, BASE_HEX, NULL, 0x00, NULL, HFILL }; + +static header_field_info hfi_gadu_gadu_userdata_attr_value HFI_INIT(proto_gadu_gadu) = + { "Attribute value", "gadu-gadu.user_data.attr_val", FT_STRING, BASE_NONE, NULL, 0x00, NULL, HFILL }; + +/* Typing notify (gadu-gadu.typing_notify.*) */ +static header_field_info hfi_gadu_gadu_typing_notify_type HFI_INIT(proto_gadu_gadu) = + { "Typing notify type", "gadu-gadu.typing_notify.type", FT_UINT16, BASE_HEX, gadu_gadu_typing_notify_type_vals, 0x00, NULL, HFILL }; + +static header_field_info hfi_gadu_gadu_typing_notify_uin HFI_INIT(proto_gadu_gadu) = + { "Typing notify recipient", "gadu-gadu.typing_notify.uin", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }; + +/* Message common (gadu-gadu.msg.*) */ +static header_field_info hfi_gadu_gadu_msg_uin HFI_INIT(proto_gadu_gadu) = + { "Message sender or recipient", "gadu-gadu.msg.uin", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }; + +static header_field_info hfi_gadu_gadu_msg_sender HFI_INIT(proto_gadu_gadu) = + { "Message sender", "gadu-gadu.msg.sender", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }; + +static header_field_info hfi_gadu_gadu_msg_recipient HFI_INIT(proto_gadu_gadu) = + { "Message recipient", "gadu-gadu.msg.recipient", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }; + +static header_field_info hfi_gadu_gadu_msg_seq HFI_INIT(proto_gadu_gadu) = + { "Message sequence number", "gadu-gadu.msg.seq", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }; + +static header_field_info hfi_gadu_gadu_msg_time HFI_INIT(proto_gadu_gadu) = + { "Message time", "gadu-gadu.msg.time", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0, NULL, HFILL }; + +static header_field_info hfi_gadu_gadu_msg_class HFI_INIT(proto_gadu_gadu) = + { "Message class", "gadu-gadu.msg.class", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }; + +static header_field_info hfi_gadu_gadu_msg_text HFI_INIT(proto_gadu_gadu) = + { "Message text", "gadu-gadu.msg.text", FT_STRINGZ, BASE_NONE, NULL, 0x0, NULL, HFILL }; + +/* GG_RECV_MSG80, GG_SEND_MSG80 (gadu-gadu.msg80.*) */ +static header_field_info hfi_gadu_gadu_msg80_offset_plain HFI_INIT(proto_gadu_gadu) = + { "Message plaintext offset", "gadu-gadu.msg80.offset_plain", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }; + +static header_field_info hfi_gadu_gadu_msg80_offset_attr HFI_INIT(proto_gadu_gadu) = + { "Message attribute offset", "gadu-gadu.msg80.offset_attributes", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }; + +/* GG_SEND_MSG_ACK (gadu-gadu.msg_ack.*) */ +static header_field_info hfi_gadu_gadu_msg_ack_status HFI_INIT(proto_gadu_gadu) = + { "Message status", "gadu-gadu.msg_ack.status", FT_UINT32, BASE_HEX, gadu_gadu_msg_ack_status_vals, 0x00, NULL, HFILL }; + +static header_field_info hfi_gadu_gadu_msg_ack_recipient HFI_INIT(proto_gadu_gadu) = + { "Message recipient", "gadu-gadu.msg_ack.recipient", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }; + +static header_field_info hfi_gadu_gadu_msg_ack_seq HFI_INIT(proto_gadu_gadu) = + { "Message sequence number", "gadu-gadu.msg_ack.seq", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }; + +/* Status common (gadu-gadu.status.*) */ +static header_field_info hfi_gadu_gadu_status_uin HFI_INIT(proto_gadu_gadu) = + { "UIN", "gadu-gadu.status.uin", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }; + +static header_field_info hfi_gadu_gadu_status_status HFI_INIT(proto_gadu_gadu) = + { "Status", "gadu-gadu.status.status", FT_UINT32, BASE_HEX, NULL, 0x00, NULL, HFILL }; + +static header_field_info hfi_gadu_gadu_status_ip HFI_INIT(proto_gadu_gadu) = + { "IP", "gadu-gadu.status.remote_ip", FT_IPv4, BASE_NONE, NULL, 0x00, NULL, HFILL }; + +static header_field_info hfi_gadu_gadu_status_port HFI_INIT(proto_gadu_gadu) = + { "Port", "gadu-gadu.status.remote_port", FT_UINT16, BASE_DEC, NULL, 0x00, NULL, HFILL }; + +static header_field_info hfi_gadu_gadu_status_version HFI_INIT(proto_gadu_gadu) = + { "Version", "gadu-gadu.status.version", FT_UINT8, BASE_HEX, NULL, 0x00, NULL, HFILL }; + +static header_field_info hfi_gadu_gadu_status_img_size HFI_INIT(proto_gadu_gadu) = + { "Image size", "gadu-gadu.status.image_size", FT_UINT8, BASE_DEC, NULL, 0x00, "Maximum image size in KB", HFILL }; + +static header_field_info hfi_gadu_gadu_status_descr HFI_INIT(proto_gadu_gadu) = + { "Description", "gadu-gadu.status.description", FT_STRINGZ, BASE_NONE, NULL, 0x00, NULL, HFILL }; + +/* Direct Connection (gadu-gadu.dcc.*) */ +static header_field_info hfi_dcc_type HFI_INIT(proto_gadu_gadu) = + { "Direct connection type", "gadu-gadu.dcc.type", FT_UINT32, BASE_HEX, gadu_gadu_dcc_type_vals, 0x00, NULL, HFILL }; + +static header_field_info hfi_dcc_id HFI_INIT(proto_gadu_gadu) = + { "Direct connection id", "gadu-gadu.dcc.id", FT_BYTES, BASE_NONE, NULL, 0x00, NULL, HFILL }; + +static header_field_info hfi_dcc_uin_to HFI_INIT(proto_gadu_gadu) = + { "Direct connection UIN target", "gadu-gadu.dcc.uin_to", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }; + +static header_field_info hfi_dcc_uin_from HFI_INIT(proto_gadu_gadu) = + { "Direct connection UIN initiator", "gadu-gadu.dcc.uin_from", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }; + +static header_field_info hfi_dcc_filename HFI_INIT(proto_gadu_gadu) = + { "Direct connection filename", "gadu-gadu.dcc.filename", FT_STRING, BASE_NONE, NULL, 0x00, NULL, HFILL }; + +/* New status (setting status) common (gadu-gadu.new_status.*) */ +static header_field_info hfi_gadu_gadu_new_status_status HFI_INIT(proto_gadu_gadu) = + { "Status", "gadu-gadu.new_status.status", FT_UINT32, BASE_HEX, NULL, 0x00, NULL, HFILL }; + +static header_field_info hfi_gadu_gadu_new_status_desc HFI_INIT(proto_gadu_gadu) = + { "Description", "gadu-gadu.new_status.description", FT_STRINGZ, BASE_NONE, NULL, 0x00, NULL, HFILL }; + +/* Userlist (gadu-gadu.userlist.*) */ +static header_field_info hfi_gadu_gadu_userlist_request_type HFI_INIT(proto_gadu_gadu) = + { "Request type", "gadu-gadu.userlist.request_type", FT_UINT32, BASE_HEX, gadu_gadu_userlist_request_type_vals, 0x00, NULL, HFILL }; + +static header_field_info hfi_gadu_gadu_userlist_version HFI_INIT(proto_gadu_gadu) = + { "Userlist version", "gadu-gadu.userlist.version", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }; + +static header_field_info hfi_gadu_gadu_userlist_format HFI_INIT(proto_gadu_gadu) = + { "Userlist format", "gadu-gadu.userlist.format", FT_UINT8, BASE_HEX, gadu_gadu_userlist_request_format_vals, 0x00, NULL, HFILL }; + +static header_field_info hfi_gadu_gadu_userlist_reply_type HFI_INIT(proto_gadu_gadu) = + { "Reply type", "gadu-gadu.userlist.reply_type", FT_UINT32, BASE_HEX, gadu_gadu_userlist_reply_type_vals, 0x00, NULL, HFILL }; + +/* Public Directory (gadu-gadu.pubdir.*) */ +static header_field_info hfi_gadu_gadu_pubdir_request_type HFI_INIT(proto_gadu_gadu) = + { "Request type", "gadu-gadu.pubdir.request_type", FT_UINT8, BASE_HEX, gadu_gadu_pubdir_type_vals, 0x00, NULL, HFILL }; + +static header_field_info hfi_gadu_gadu_pubdir_request_seq HFI_INIT(proto_gadu_gadu) = + { "Request sequence", "gadu-gadu.pubdir.request_seq", FT_UINT32, BASE_HEX, NULL, 0x00, NULL, HFILL }; + +static header_field_info hfi_gadu_gadu_pubdir_request_str HFI_INIT(proto_gadu_gadu) = + { "Request string", "gadu-gadu.pubdir.request_str", FT_STRINGZ, BASE_NONE, NULL, 0x00, NULL, HFILL }; + +static header_field_info hfi_gadu_gadu_pubdir_reply_type HFI_INIT(proto_gadu_gadu) = + { "Reply type", "gadu-gadu.pubdir.reply_type", FT_UINT8, BASE_HEX, gadu_gadu_pubdir_type_vals, 0x00, NULL, HFILL }; + +static header_field_info hfi_gadu_gadu_pubdir_reply_seq HFI_INIT(proto_gadu_gadu) = + { "Reply sequence", "gadu-gadu.pubdir.reply_seq", FT_UINT32, BASE_HEX, NULL, 0x00, NULL, HFILL }; + +static header_field_info hfi_gadu_gadu_pubdir_reply_str HFI_INIT(proto_gadu_gadu) = + { "Reply string", "gadu-gadu.pubdir.request_str", FT_STRINGZ, BASE_NONE, NULL, 0x00, NULL, HFILL }; + +/* Contact (notify) common (gadu-gadu.contact.*) */ +static header_field_info hfi_gadu_gadu_contact_uin HFI_INIT(proto_gadu_gadu) = + { "UIN", "gadu-gadu.contact.uin", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }; + +static header_field_info hfi_gadu_gadu_contact_uin_str HFI_INIT(proto_gadu_gadu) = + { "UIN", "gadu-gadu.contact.uin_str", FT_STRING, BASE_NONE, NULL, 0x00, NULL, HFILL }; + +static header_field_info hfi_gadu_gadu_contact_type HFI_INIT(proto_gadu_gadu) = + { "Type", "gadu-gadu.contact.type", FT_UINT8, BASE_HEX, NULL, 0x00, NULL, HFILL }; + +/* GG_WELCOME */ +static header_field_info hfi_gadu_gadu_welcome_seed HFI_INIT(proto_gadu_gadu) = + { "Seed", "gadu-gadu.welcome.seed", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }; + +/* Not dissected data */ +static header_field_info hfi_gadu_gadu_data HFI_INIT(proto_gadu_gadu) = + { "Packet Data", "gadu-gadu.data", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }; + + +static dissector_handle_t xml_handle; + struct gadu_gadu_conv_data { guint32 uin; /* uin from login packet */ }; @@ -454,7 +577,7 @@ gadu_gadu_status_has_descr(int status) } static int -dissect_gadu_gadu_stringz_cp1250(tvbuff_t *tvb, int hfindex, proto_tree *tree, int offset) +dissect_gadu_gadu_stringz_cp1250(tvbuff_t *tvb, const header_field_info *hfi, proto_tree *tree, int offset) { static const gunichar2 table_cp1250[] = { 0x20ac, 0xFFFD, 0x201a, 0xFFFD, 0x201e, 0x2026, 0x2020, 0x2021, /* 0x80 - */ @@ -496,13 +619,13 @@ dissect_gadu_gadu_stringz_cp1250(tvbuff_t *tvb, int hfindex, proto_tree *tree, i if (len > 0) offset++; /* NUL */ - proto_tree_add_unicode_string(tree, hfindex, tvb, org_offset, offset - org_offset, str->str); + proto_tree_add_unicode_string(tree, hfi->id, tvb, org_offset, offset - org_offset, str->str); return offset; } static int -dissect_gadu_gadu_uint32_string_utf8(tvbuff_t *tvb, int hfindex, proto_tree *tree, int offset) +dissect_gadu_gadu_uint32_string_utf8(tvbuff_t *tvb, const header_field_info *hfi, proto_tree *tree, int offset) { const int org_offset = offset; @@ -526,7 +649,7 @@ dissect_gadu_gadu_uint32_string_utf8(tvbuff_t *tvb, int hfindex, proto_tree *tre offset += len; - proto_tree_add_unicode_string(tree, hfindex, tvb, org_offset, offset - org_offset, str); + proto_tree_add_unicode_string(tree, hfi->id, tvb, org_offset, offset - org_offset, str); return offset; } @@ -573,8 +696,8 @@ dissect_gadu_gadu_login_protocol(tvbuff_t *tvb, proto_tree *tree, int offset) guint32 protocol; protocol = tvb_get_letohl(tvb, offset) & 0xff; - proto_tree_add_item(tree, hf_gadu_gadu_login_protocol, tvb, offset, 4, ENC_LITTLE_ENDIAN); - ti = proto_tree_add_string(tree, hf_gadu_gadu_login_version, tvb, offset, 4, val_to_str(protocol, gadu_gadu_version_vals, "Unknown (0x%x)")); + proto_tree_add_item(tree, &hfi_gadu_gadu_login_protocol, tvb, offset, 4, ENC_LITTLE_ENDIAN); + ti = proto_tree_add_string(tree, hfi_gadu_gadu_login_version.id, tvb, offset, 4, val_to_str(protocol, gadu_gadu_version_vals, "Unknown (0x%x)")); PROTO_ITEM_SET_GENERATED(ti); offset += 4; @@ -594,26 +717,26 @@ dissect_gadu_gadu_login(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int uin = tvb_get_letohl(tvb, offset); gadu_gadu_create_conversation(pinfo, uin); - proto_tree_add_uint(tree, hf_gadu_gadu_login_uin, tvb, offset, 4, uin); + proto_tree_add_uint(tree, hfi_gadu_gadu_login_uin.id, tvb, offset, 4, uin); offset += 4; - ti = proto_tree_add_uint(tree, hf_gadu_gadu_login_hash_type, tvb, 0, 0, GG_LOGIN_HASH_GG32); + ti = proto_tree_add_uint(tree, hfi_gadu_gadu_login_hash_type.id, tvb, 0, 0, GG_LOGIN_HASH_GG32); PROTO_ITEM_SET_GENERATED(ti); /* hash is 32-bit number written in LE */ _tvb_memcpy_reverse(tvb, hash, offset, 4); - proto_tree_add_bytes_format_value(tree, hf_gadu_gadu_login_hash, tvb, offset, 4, hash, "0x%.8x", tvb_get_letohl(tvb, offset)); + proto_tree_add_bytes_format_value(tree, hfi_gadu_gadu_login_hash.id, tvb, offset, 4, hash, "0x%.8x", tvb_get_letohl(tvb, offset)); offset += 4; - proto_tree_add_item(tree, hf_gadu_gadu_login_status, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_login_status, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; offset = dissect_gadu_gadu_login_protocol(tvb, tree, offset); - proto_tree_add_item(tree, hf_gadu_gadu_login_local_ip, tvb, offset, 4, ENC_BIG_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_login_local_ip, tvb, offset, 4, ENC_BIG_ENDIAN); offset += 4; - proto_tree_add_item(tree, hf_gadu_gadu_login_local_port, tvb, offset, 2, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_login_local_port, tvb, offset, 2, ENC_LITTLE_ENDIAN); offset += 2; return offset; @@ -628,34 +751,34 @@ dissect_gadu_gadu_login_hash(tvbuff_t *tvb, proto_tree *tree, int offset) int i; hash_type = tvb_get_guint8(tvb, offset); - proto_tree_add_item(tree, hf_gadu_gadu_login_hash_type, tvb, offset, 1, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_login_hash_type, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset += 1; switch (hash_type) { case GG_LOGIN_HASH_GG32: /* hash is 32-bit number written in LE */ _tvb_memcpy_reverse(tvb, hash, offset, 4); - proto_tree_add_bytes_format_value(tree, hf_gadu_gadu_login_hash, tvb, offset, 4, hash, "0x%.8x", tvb_get_letohl(tvb, offset)); + proto_tree_add_bytes_format_value(tree, hfi_gadu_gadu_login_hash.id, tvb, offset, 4, hash, "0x%.8x", tvb_get_letohl(tvb, offset)); for (i = 4; i < 64; i++) { if (tvb_get_guint8(tvb, offset+i)) { - proto_tree_add_item(tree, hf_gadu_gadu_data, tvb, offset + 4, 64-4, ENC_NA); + proto_tree_add_item(tree, &hfi_gadu_gadu_data, tvb, offset + 4, 64-4, ENC_NA); break; } } break; case GG_LOGIN_HASH_SHA1: - proto_tree_add_item(tree, hf_gadu_gadu_login_hash, tvb, offset, 20, ENC_NA); + proto_tree_add_item(tree, &hfi_gadu_gadu_login_hash, tvb, offset, 20, ENC_NA); for (i = 20; i < 64; i++) { if (tvb_get_guint8(tvb, offset+i)) { - proto_tree_add_item(tree, hf_gadu_gadu_data, tvb, offset + 20, 64-20, ENC_NA); + proto_tree_add_item(tree, &hfi_gadu_gadu_data, tvb, offset + 20, 64-20, ENC_NA); break; } } break; default: - proto_tree_add_item(tree, hf_gadu_gadu_data, tvb, offset, 64, ENC_NA); + proto_tree_add_item(tree, &hfi_gadu_gadu_data, tvb, offset, 64, ENC_NA); break; } offset += 64; @@ -673,23 +796,23 @@ dissect_gadu_gadu_login70(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, i uin = tvb_get_letohl(tvb, offset) & ~(GG_ERA_OMNIX_MASK | GG_HAS_AUDIO_MASK); gadu_gadu_create_conversation(pinfo, uin); - proto_tree_add_uint(tree, hf_gadu_gadu_login_uin, tvb, offset, 4, uin); + proto_tree_add_uint(tree, hfi_gadu_gadu_login_uin.id, tvb, offset, 4, uin); offset += 4; offset = dissect_gadu_gadu_login_hash(tvb, tree, offset); - proto_tree_add_item(tree, hf_gadu_gadu_login_status, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_login_status, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; offset = dissect_gadu_gadu_login_protocol(tvb, tree, offset); - proto_tree_add_item(tree, hf_gadu_gadu_data, tvb, offset, 1, ENC_NA); /* 00 */ + proto_tree_add_item(tree, &hfi_gadu_gadu_data, tvb, offset, 1, ENC_NA); /* 00 */ offset += 1; - proto_tree_add_item(tree, hf_gadu_gadu_login_local_ip, tvb, offset, 4, ENC_BIG_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_login_local_ip, tvb, offset, 4, ENC_BIG_ENDIAN); offset += 4; - proto_tree_add_item(tree, hf_gadu_gadu_login_local_port, tvb, offset, 2, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_login_local_port, tvb, offset, 2, ENC_LITTLE_ENDIAN); offset += 2; /* XXX packet not fully dissected */ @@ -707,15 +830,15 @@ dissect_gadu_gadu_login80(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, i uin = tvb_get_letohl(tvb, offset); gadu_gadu_create_conversation(pinfo, uin); - proto_tree_add_item(tree, hf_gadu_gadu_login_uin, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_login_uin, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; - proto_tree_add_item(tree, hf_gadu_gadu_login80_lang, tvb, offset, 2, ENC_ASCII | ENC_NA); + proto_tree_add_item(tree, &hfi_gadu_gadu_login80_lang, tvb, offset, 2, ENC_ASCII | ENC_NA); offset += 2; offset = dissect_gadu_gadu_login_hash(tvb, tree, offset); - proto_tree_add_item(tree, hf_gadu_gadu_login_status, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_login_status, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; /* XXX packet not fully dissected */ @@ -748,7 +871,7 @@ dissect_gadu_gadu_login_ok80(tvbuff_t *tvb _U_, packet_info *pinfo, proto_tree * { col_set_str(pinfo->cinfo, COL_INFO, "Login success (8.0)"); - proto_tree_add_item(tree, hf_gadu_gadu_data, tvb, offset, 4, ENC_NA); /* 01 00 00 00 */ + proto_tree_add_item(tree, &hfi_gadu_gadu_data, tvb, offset, 4, ENC_NA); /* 01 00 00 00 */ offset += 4; return offset; @@ -759,7 +882,7 @@ dissect_gadu_gadu_login80_failed(tvbuff_t *tvb, packet_info *pinfo, proto_tree * { col_set_str(pinfo->cinfo, COL_INFO, "Login fail (8.0)"); - proto_tree_add_item(tree, hf_gadu_gadu_data, tvb, offset, 4, ENC_NA); /* 01 00 00 00 */ + proto_tree_add_item(tree, &hfi_gadu_gadu_data, tvb, offset, 4, ENC_NA); /* 01 00 00 00 */ offset += 4; return offset; @@ -782,7 +905,7 @@ dissect_gadu_gadu_user_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, while (users_num--) { guint32 attr_num; - proto_tree_add_item(tree, hf_gadu_gadu_userdata_uin, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_userdata_uin, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; attr_num = tvb_get_letohl(tvb, offset); @@ -796,17 +919,17 @@ dissect_gadu_gadu_user_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, offset += 4; name = tvb_get_ephemeral_string_enc(tvb, offset, name_size, ENC_ASCII | ENC_NA); - proto_tree_add_string(tree, hf_gadu_gadu_userdata_attr_name, tvb, offset - 4, 4 + name_size, name); + proto_tree_add_string(tree, hfi_gadu_gadu_userdata_attr_name.id, tvb, offset - 4, 4 + name_size, name); offset += name_size; /* type */ - proto_tree_add_item(tree, hf_gadu_gadu_userdata_attr_type, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_userdata_attr_type, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; /* value */ val_size = tvb_get_letohl(tvb, offset); offset += 4; val = tvb_get_ephemeral_string_enc(tvb, offset, val_size, ENC_ASCII | ENC_NA); - proto_tree_add_string(tree, hf_gadu_gadu_userdata_attr_value, tvb, offset - 4, 4 + val_size, val); + proto_tree_add_string(tree, hfi_gadu_gadu_userdata_attr_value.id, tvb, offset - 4, 4 + val_size, val); offset += val_size; } } @@ -820,10 +943,10 @@ dissect_gadu_gadu_typing_notify(tvbuff_t *tvb, packet_info *pinfo, proto_tree *t col_set_str(pinfo->cinfo, COL_INFO, "Typing notify"); /* XXX, when type > 1, it's length not type ! */ - proto_tree_add_item(tree, hf_gadu_gadu_typing_notify_type, tvb, offset, 2, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_typing_notify_type, tvb, offset, 2, ENC_LITTLE_ENDIAN); offset += 2; - proto_tree_add_item(tree, hf_gadu_gadu_typing_notify_uin, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_typing_notify_uin, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; return offset; @@ -846,29 +969,29 @@ dissect_gadu_gadu_recv_msg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, col_set_str(pinfo->cinfo, COL_INFO, "Receive message (< 8.0)"); if ((conv = gadu_gadu_get_conversation_data(pinfo))) { - ti = proto_tree_add_uint(tree, hf_gadu_gadu_msg_recipient, tvb, 0, 0, conv->uin); + ti = proto_tree_add_uint(tree, hfi_gadu_gadu_msg_recipient.id, tvb, 0, 0, conv->uin); PROTO_ITEM_SET_GENERATED(ti); - ti = proto_tree_add_uint(tree, hf_gadu_gadu_msg_uin, tvb, 0, 0, conv->uin); + ti = proto_tree_add_uint(tree, hfi_gadu_gadu_msg_uin.id, tvb, 0, 0, conv->uin); PROTO_ITEM_SET_GENERATED(ti); PROTO_ITEM_SET_HIDDEN(ti); } - ti = proto_tree_add_item(tree, hf_gadu_gadu_msg_uin, tvb, offset, 4, ENC_LITTLE_ENDIAN); + ti = proto_tree_add_item(tree, &hfi_gadu_gadu_msg_uin, tvb, offset, 4, ENC_LITTLE_ENDIAN); PROTO_ITEM_SET_HIDDEN(ti); - proto_tree_add_item(tree, hf_gadu_gadu_msg_sender, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_msg_sender, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; - proto_tree_add_item(tree, hf_gadu_gadu_msg_seq, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_msg_seq, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; - proto_tree_add_item(tree, hf_gadu_gadu_msg_time, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_msg_time, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; - proto_tree_add_item(tree, hf_gadu_gadu_msg_class, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_msg_class, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; - offset = dissect_gadu_gadu_stringz_cp1250(tvb, hf_gadu_gadu_msg_text, tree, offset); + offset = dissect_gadu_gadu_stringz_cp1250(tvb, &hfi_gadu_gadu_msg_text, tree, offset); offset = dissect_gadu_gadu_msg_attr(tvb, tree, offset); @@ -883,30 +1006,30 @@ dissect_gadu_gadu_send_msg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, col_set_str(pinfo->cinfo, COL_INFO, "Send message (< 8.0)"); - ti = proto_tree_add_item(tree, hf_gadu_gadu_msg_uin, tvb, offset, 4, ENC_LITTLE_ENDIAN); + ti = proto_tree_add_item(tree, &hfi_gadu_gadu_msg_uin, tvb, offset, 4, ENC_LITTLE_ENDIAN); PROTO_ITEM_SET_HIDDEN(ti); - proto_tree_add_item(tree, hf_gadu_gadu_msg_recipient, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_msg_recipient, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; if ((conv = gadu_gadu_get_conversation_data(pinfo))) { - ti = proto_tree_add_uint(tree, hf_gadu_gadu_msg_sender, tvb, 0, 0, conv->uin); + ti = proto_tree_add_uint(tree, hfi_gadu_gadu_msg_sender.id, tvb, 0, 0, conv->uin); PROTO_ITEM_SET_GENERATED(ti); - ti = proto_tree_add_uint(tree, hf_gadu_gadu_msg_uin, tvb, 0, 0, conv->uin); + ti = proto_tree_add_uint(tree, hfi_gadu_gadu_msg_uin.id, tvb, 0, 0, conv->uin); PROTO_ITEM_SET_GENERATED(ti); PROTO_ITEM_SET_HIDDEN(ti); } - proto_tree_add_item(tree, hf_gadu_gadu_msg_seq, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_msg_seq, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; - ti = proto_tree_add_time(tree, hf_gadu_gadu_msg_time, tvb, 0, 0, &(pinfo->fd->abs_ts)); + ti = proto_tree_add_time(tree, hfi_gadu_gadu_msg_time.id, tvb, 0, 0, &(pinfo->fd->abs_ts)); PROTO_ITEM_SET_GENERATED(ti); - proto_tree_add_item(tree, hf_gadu_gadu_msg_class, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_msg_class, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; - offset = dissect_gadu_gadu_stringz_cp1250(tvb, hf_gadu_gadu_msg_text, tree, offset); + offset = dissect_gadu_gadu_stringz_cp1250(tvb, &hfi_gadu_gadu_msg_text, tree, offset); offset = dissect_gadu_gadu_msg_attr(tvb, tree, offset); @@ -922,32 +1045,32 @@ dissect_gadu_gadu_recv_msg80(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree col_set_str(pinfo->cinfo, COL_INFO, "Receive message (8.0)"); if ((conv = gadu_gadu_get_conversation_data(pinfo))) { - ti = proto_tree_add_uint(tree, hf_gadu_gadu_msg_recipient, tvb, 0, 0, conv->uin); + ti = proto_tree_add_uint(tree, hfi_gadu_gadu_msg_recipient.id, tvb, 0, 0, conv->uin); PROTO_ITEM_SET_GENERATED(ti); - ti = proto_tree_add_uint(tree, hf_gadu_gadu_msg_uin, tvb, 0, 0, conv->uin); + ti = proto_tree_add_uint(tree, hfi_gadu_gadu_msg_uin.id, tvb, 0, 0, conv->uin); PROTO_ITEM_SET_GENERATED(ti); PROTO_ITEM_SET_HIDDEN(ti); } - ti = proto_tree_add_item(tree, hf_gadu_gadu_msg_uin, tvb, offset, 4, ENC_LITTLE_ENDIAN); + ti = proto_tree_add_item(tree, &hfi_gadu_gadu_msg_uin, tvb, offset, 4, ENC_LITTLE_ENDIAN); PROTO_ITEM_SET_HIDDEN(ti); - proto_tree_add_item(tree, hf_gadu_gadu_msg_sender, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_msg_sender, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; - proto_tree_add_item(tree, hf_gadu_gadu_msg_seq, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_msg_seq, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; - proto_tree_add_item(tree, hf_gadu_gadu_msg_time, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_msg_time, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; - proto_tree_add_item(tree, hf_gadu_gadu_msg_class, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_msg_class, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; - proto_tree_add_item(tree, hf_gadu_gadu_msg80_offset_plain, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_msg80_offset_plain, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; - proto_tree_add_item(tree, hf_gadu_gadu_msg80_offset_attr, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_msg80_offset_attr, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; /* XXX packet not fully dissected */ @@ -963,33 +1086,33 @@ dissect_gadu_gadu_send_msg80(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree col_set_str(pinfo->cinfo, COL_INFO, "Send message (8.0)"); - ti = proto_tree_add_item(tree, hf_gadu_gadu_msg_uin, tvb, offset, 4, ENC_LITTLE_ENDIAN); + ti = proto_tree_add_item(tree, &hfi_gadu_gadu_msg_uin, tvb, offset, 4, ENC_LITTLE_ENDIAN); PROTO_ITEM_SET_HIDDEN(ti); - proto_tree_add_item(tree, hf_gadu_gadu_msg_recipient, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_msg_recipient, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; if ((conv = gadu_gadu_get_conversation_data(pinfo))) { - ti = proto_tree_add_uint(tree, hf_gadu_gadu_msg_sender, tvb, 0, 0, conv->uin); + ti = proto_tree_add_uint(tree, hfi_gadu_gadu_msg_sender.id, tvb, 0, 0, conv->uin); PROTO_ITEM_SET_GENERATED(ti); - ti = proto_tree_add_uint(tree, hf_gadu_gadu_msg_uin, tvb, 0, 0, conv->uin); + ti = proto_tree_add_uint(tree, hfi_gadu_gadu_msg_uin.id, tvb, 0, 0, conv->uin); PROTO_ITEM_SET_GENERATED(ti); PROTO_ITEM_SET_HIDDEN(ti); } - proto_tree_add_item(tree, hf_gadu_gadu_msg_seq, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_msg_seq, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; - ti = proto_tree_add_time(tree, hf_gadu_gadu_msg_time, tvb, 0, 0, &(pinfo->fd->abs_ts)); + ti = proto_tree_add_time(tree, hfi_gadu_gadu_msg_time.id, tvb, 0, 0, &(pinfo->fd->abs_ts)); PROTO_ITEM_SET_GENERATED(ti); - proto_tree_add_item(tree, hf_gadu_gadu_msg_class, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_msg_class, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; - proto_tree_add_item(tree, hf_gadu_gadu_msg80_offset_plain, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_msg80_offset_plain, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; - proto_tree_add_item(tree, hf_gadu_gadu_msg80_offset_attr, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_msg80_offset_attr, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; /* XXX packet not fully dissected */ @@ -1002,13 +1125,13 @@ dissect_gadu_gadu_send_msg_ack(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tr { col_set_str(pinfo->cinfo, COL_INFO, "Message acknowledge (server)"); - proto_tree_add_item(tree, hf_gadu_gadu_msg_ack_status, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_msg_ack_status, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; - proto_tree_add_item(tree, hf_gadu_gadu_msg_ack_recipient, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_msg_ack_recipient, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; - proto_tree_add_item(tree, hf_gadu_gadu_msg_ack_seq, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_msg_ack_seq, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; return offset; @@ -1019,7 +1142,7 @@ dissect_gadu_gadu_recv_msg_ack(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tr { col_set_str(pinfo->cinfo, COL_INFO, "Message acknowledge (client)"); - proto_tree_add_item(tree, hf_gadu_gadu_msg_ack_seq, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_msg_ack_seq, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; return offset; @@ -1034,30 +1157,30 @@ dissect_gadu_gadu_status60(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, col_set_str(pinfo->cinfo, COL_INFO, "Receive status (6.0)"); uin = tvb_get_letohl(tvb, offset) & ~(GG_ERA_OMNIX_MASK | GG_HAS_AUDIO_MASK); - proto_tree_add_uint(tree, hf_gadu_gadu_status_uin, tvb, offset, 4, uin); + proto_tree_add_uint(tree, hfi_gadu_gadu_status_uin.id, tvb, offset, 4, uin); offset += 4; status = tvb_get_guint8(tvb, offset); - proto_tree_add_item(tree, hf_gadu_gadu_status_status, tvb, offset, 1, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_status_status, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset += 1; - proto_tree_add_item(tree, hf_gadu_gadu_status_ip, tvb, offset, 4, ENC_BIG_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_status_ip, tvb, offset, 4, ENC_BIG_ENDIAN); offset += 4; - proto_tree_add_item(tree, hf_gadu_gadu_status_port, tvb, offset, 2, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_status_port, tvb, offset, 2, ENC_LITTLE_ENDIAN); offset += 2; - proto_tree_add_item(tree, hf_gadu_gadu_status_version, tvb, offset, 1, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_status_version, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset += 1; - proto_tree_add_item(tree, hf_gadu_gadu_status_img_size, tvb, offset, 1, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_status_img_size, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset += 1; - proto_tree_add_item(tree, hf_gadu_gadu_data, tvb, offset, 1, ENC_NA); /* 00 */ + proto_tree_add_item(tree, &hfi_gadu_gadu_data, tvb, offset, 1, ENC_NA); /* 00 */ offset += 1; if (gadu_gadu_status_has_descr(status)) - offset = dissect_gadu_gadu_stringz_cp1250(tvb, hf_gadu_gadu_status_descr, tree, offset); + offset = dissect_gadu_gadu_stringz_cp1250(tvb, &hfi_gadu_gadu_status_descr, tree, offset); return offset; } @@ -1071,33 +1194,33 @@ dissect_gadu_gadu_status77(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, col_set_str(pinfo->cinfo, COL_INFO, "Receive status (7.7)"); uin = tvb_get_letohl(tvb, offset) & ~(GG_ERA_OMNIX_MASK | GG_HAS_AUDIO_MASK); - proto_tree_add_uint(tree, hf_gadu_gadu_status_uin, tvb, offset, 4, uin); + proto_tree_add_uint(tree, hfi_gadu_gadu_status_uin.id, tvb, offset, 4, uin); offset += 4; status = tvb_get_guint8(tvb, offset); - proto_tree_add_item(tree, hf_gadu_gadu_status_status, tvb, offset, 1, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_status_status, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset += 1; - proto_tree_add_item(tree, hf_gadu_gadu_status_ip, tvb, offset, 4, ENC_BIG_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_status_ip, tvb, offset, 4, ENC_BIG_ENDIAN); offset += 4; - proto_tree_add_item(tree, hf_gadu_gadu_status_port, tvb, offset, 2, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_status_port, tvb, offset, 2, ENC_LITTLE_ENDIAN); offset += 2; - proto_tree_add_item(tree, hf_gadu_gadu_status_version, tvb, offset, 1, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_status_version, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset += 1; - proto_tree_add_item(tree, hf_gadu_gadu_status_img_size, tvb, offset, 1, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_status_img_size, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset += 1; - proto_tree_add_item(tree, hf_gadu_gadu_data, tvb, offset, 1, ENC_NA); /* 00 */ + proto_tree_add_item(tree, &hfi_gadu_gadu_data, tvb, offset, 1, ENC_NA); /* 00 */ offset += 1; - proto_tree_add_item(tree, hf_gadu_gadu_data, tvb, offset, 4, ENC_NA); + proto_tree_add_item(tree, &hfi_gadu_gadu_data, tvb, offset, 4, ENC_NA); offset += 4; if (gadu_gadu_status_has_descr(status)) - offset = dissect_gadu_gadu_stringz_cp1250(tvb, hf_gadu_gadu_status_descr, tree, offset); + offset = dissect_gadu_gadu_stringz_cp1250(tvb, &hfi_gadu_gadu_status_descr, tree, offset); return offset; } @@ -1107,31 +1230,31 @@ dissect_gadu_gadu_status80(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, { col_set_str(pinfo->cinfo, COL_INFO, "Receive status (8.0)"); - proto_tree_add_item(tree, hf_gadu_gadu_status_uin, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_status_uin, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; - proto_tree_add_item(tree, hf_gadu_gadu_status_status, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_status_status, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; - proto_tree_add_item(tree, hf_gadu_gadu_data, tvb, offset, 4, ENC_NA); + proto_tree_add_item(tree, &hfi_gadu_gadu_data, tvb, offset, 4, ENC_NA); offset += 4; - proto_tree_add_item(tree, hf_gadu_gadu_status_ip, tvb, offset, 4, ENC_BIG_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_status_ip, tvb, offset, 4, ENC_BIG_ENDIAN); offset += 4; - proto_tree_add_item(tree, hf_gadu_gadu_status_port, tvb, offset, 2, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_status_port, tvb, offset, 2, ENC_LITTLE_ENDIAN); offset += 2; - proto_tree_add_item(tree, hf_gadu_gadu_status_img_size, tvb, offset, 1, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_status_img_size, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset += 1; - proto_tree_add_item(tree, hf_gadu_gadu_data, tvb, offset, 1, ENC_NA); + proto_tree_add_item(tree, &hfi_gadu_gadu_data, tvb, offset, 1, ENC_NA); offset += 1; - proto_tree_add_item(tree, hf_gadu_gadu_data, tvb, offset, 4, ENC_NA); + proto_tree_add_item(tree, &hfi_gadu_gadu_data, tvb, offset, 4, ENC_NA); offset += 4; - offset = dissect_gadu_gadu_uint32_string_utf8(tvb, hf_gadu_gadu_status_descr, tree, offset); + offset = dissect_gadu_gadu_uint32_string_utf8(tvb, &hfi_gadu_gadu_status_descr, tree, offset); return offset; } @@ -1154,11 +1277,11 @@ dissect_gadu_gadu_new_status(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree col_set_str(pinfo->cinfo, COL_INFO, "New status (< 8.0)"); status = tvb_get_letohl(tvb, offset); - proto_tree_add_item(tree, hf_gadu_gadu_new_status_status, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_new_status_status, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; if (gadu_gadu_status_has_descr(status & 0xff)) - offset = dissect_gadu_gadu_stringz_cp1250(tvb, hf_gadu_gadu_status_descr, tree, offset); + offset = dissect_gadu_gadu_stringz_cp1250(tvb, &hfi_gadu_gadu_status_descr, tree, offset); return offset; } @@ -1168,13 +1291,13 @@ dissect_gadu_gadu_new_status80(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tr { col_set_str(pinfo->cinfo, COL_INFO, "New status (8.0)"); - proto_tree_add_item(tree, hf_gadu_gadu_new_status_status, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_new_status_status, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; - proto_tree_add_item(tree, hf_gadu_gadu_data, tvb, offset, 4, ENC_NA); + proto_tree_add_item(tree, &hfi_gadu_gadu_data, tvb, offset, 4, ENC_NA); offset += 4; - offset = dissect_gadu_gadu_uint32_string_utf8(tvb, hf_gadu_gadu_new_status_desc, tree, offset); + offset = dissect_gadu_gadu_uint32_string_utf8(tvb, &hfi_gadu_gadu_new_status_desc, tree, offset); return offset; } @@ -1194,10 +1317,10 @@ dissect_gadu_gadu_add_notify(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree { col_set_str(pinfo->cinfo, COL_INFO, "Notify list add"); - proto_tree_add_item(tree, hf_gadu_gadu_contact_uin, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_contact_uin, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; - proto_tree_add_item(tree, hf_gadu_gadu_contact_type, tvb, offset, 1, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_contact_type, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset += 1; return offset; @@ -1209,18 +1332,18 @@ dissect_gadu_gadu_notify105_common(tvbuff_t *tvb, proto_tree *tree, int offset, guint16 uin_len; char *uin; - proto_tree_add_item(tree, hf_gadu_gadu_data, tvb, offset, 1, ENC_NA); /* unknown 00 */ + proto_tree_add_item(tree, &hfi_gadu_gadu_data, tvb, offset, 1, ENC_NA); /* unknown 00 */ offset += 1; uin_len = tvb_get_guint8(tvb, offset); offset += 1; uin = tvb_get_ephemeral_string_enc(tvb, offset, uin_len, ENC_ASCII | ENC_NA); - proto_tree_add_string(tree, hf_gadu_gadu_contact_uin_str, tvb, offset - 1, 1 + uin_len, uin); + proto_tree_add_string(tree, hfi_gadu_gadu_contact_uin_str.id, tvb, offset - 1, 1 + uin_len, uin); offset += uin_len; if (puin) *puin = uin; - proto_tree_add_item(tree, hf_gadu_gadu_contact_type, tvb, offset, 1, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_contact_type, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset += 1; return offset; @@ -1239,10 +1362,10 @@ dissect_gadu_gadu_remove_notify(tvbuff_t *tvb, packet_info *pinfo, proto_tree *t { col_set_str(pinfo->cinfo, COL_INFO, "Notify list remove"); - proto_tree_add_item(tree, hf_gadu_gadu_contact_uin, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_contact_uin, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; - proto_tree_add_item(tree, hf_gadu_gadu_contact_type, tvb, offset, 1, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_contact_type, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset += 1; return offset; @@ -1268,10 +1391,10 @@ dissect_gadu_gadu_notify_common(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tre ti = proto_tree_add_text(tree, tvb, offset, 5, "Contact: %u", uin); contact_tree = proto_item_add_subtree(ti, ett_gadu_gadu_contact); - proto_tree_add_item(contact_tree, hf_gadu_gadu_contact_uin, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(contact_tree, &hfi_gadu_gadu_contact_uin, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; - proto_tree_add_item(contact_tree, hf_gadu_gadu_contact_type, tvb, offset, 1, ENC_LITTLE_ENDIAN); + proto_tree_add_item(contact_tree, &hfi_gadu_gadu_contact_type, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset += 1; } @@ -1334,7 +1457,7 @@ dissect_gadu_gadu_welcome(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, i { col_set_str(pinfo->cinfo, COL_INFO, "Welcome"); - proto_tree_add_item(tree, hf_gadu_gadu_welcome_seed, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_welcome_seed, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; return offset; @@ -1373,10 +1496,10 @@ dissect_gadu_gadu_userlist_request80(tvbuff_t *tvb, packet_info *pinfo, proto_tr col_set_str(pinfo->cinfo, COL_INFO, "Userlist request (8.0)"); type = tvb_get_guint8(tvb, offset); - proto_tree_add_item(tree, hf_gadu_gadu_userlist_request_type, tvb, offset, 1, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_userlist_request_type, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset += 1; - ti = proto_tree_add_uint(tree, hf_gadu_gadu_userlist_format, tvb, 0, 0, GG_USERLIST100_FORMAT_TYPE_GG100); + ti = proto_tree_add_uint(tree, hfi_gadu_gadu_userlist_format.id, tvb, 0, 0, GG_USERLIST100_FORMAT_TYPE_GG100); PROTO_ITEM_SET_GENERATED(ti); switch (type) { @@ -1396,17 +1519,17 @@ dissect_gadu_gadu_userlist_request100(tvbuff_t *tvb, packet_info *pinfo, proto_t col_set_str(pinfo->cinfo, COL_INFO, "Userlist request (10.0)"); type = tvb_get_guint8(tvb, offset); - proto_tree_add_item(tree, hf_gadu_gadu_userlist_request_type, tvb, offset, 1, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_userlist_request_type, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset += 1; - proto_tree_add_item(tree, hf_gadu_gadu_userlist_version, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_userlist_version, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; format = tvb_get_guint8(tvb, offset); - proto_tree_add_item(tree, hf_gadu_gadu_userlist_format, tvb, offset, 1, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_userlist_format, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset += 1; - proto_tree_add_item(tree, hf_gadu_gadu_data, tvb, offset, 1, ENC_NA); /* 01 */ + proto_tree_add_item(tree, &hfi_gadu_gadu_data, tvb, offset, 1, ENC_NA); /* 01 */ offset += 1; switch (type) { @@ -1427,7 +1550,7 @@ dissect_gadu_gadu_userlist_reply80(tvbuff_t *tvb, packet_info *pinfo, proto_tree col_set_str(pinfo->cinfo, COL_INFO, "Userlist reply (8.0)"); type = tvb_get_guint8(tvb, offset); - proto_tree_add_item(tree, hf_gadu_gadu_userlist_reply_type, tvb, offset, 1, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_userlist_reply_type, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset += 1; switch (type) { @@ -1447,17 +1570,17 @@ dissect_gadu_gadu_userlist_reply100(tvbuff_t *tvb, packet_info *pinfo, proto_tre col_set_str(pinfo->cinfo, COL_INFO, "Userlist reply (10.0)"); type = tvb_get_guint8(tvb, offset); - proto_tree_add_item(tree, hf_gadu_gadu_userlist_reply_type, tvb, offset, 1, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_userlist_reply_type, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset += 1; - proto_tree_add_item(tree, hf_gadu_gadu_userlist_version, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_userlist_version, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; format = tvb_get_guint8(tvb, offset); - proto_tree_add_item(tree, hf_gadu_gadu_userlist_format, tvb, offset, 1, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_userlist_format, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset += 1; - proto_tree_add_item(tree, hf_gadu_gadu_data, tvb, offset, 1, ENC_NA); /* 01 */ + proto_tree_add_item(tree, &hfi_gadu_gadu_data, tvb, offset, 1, ENC_NA); /* 01 */ offset += 1; switch (type) { @@ -1475,7 +1598,7 @@ dissect_gadu_gadu_userlist_version100(tvbuff_t *tvb, packet_info *pinfo, proto_t { col_set_str(pinfo->cinfo, COL_INFO, "Userlist version (10.0)"); - proto_tree_add_item(tree, hf_gadu_gadu_userlist_version, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_userlist_version, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; return offset; @@ -1486,7 +1609,7 @@ dissect_gadu_gadu_dcc7_id_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree { col_set_str(pinfo->cinfo, COL_INFO, "Direct connection id request"); - proto_tree_add_item(tree, hf_dcc_type, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_dcc_type, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; return offset; @@ -1497,10 +1620,10 @@ dissect_gadu_gadu_dcc7_id_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *t { col_set_str(pinfo->cinfo, COL_INFO, "Direct connection id reply"); - proto_tree_add_item(tree, hf_dcc_type, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_dcc_type, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; - proto_tree_add_item(tree, hf_dcc_id, tvb, offset, 8, ENC_NA); + proto_tree_add_item(tree, &hfi_dcc_id, tvb, offset, 8, ENC_NA); offset += 8; return offset; @@ -1511,19 +1634,19 @@ dissect_gadu_gadu_dcc7_new(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, { col_set_str(pinfo->cinfo, COL_INFO, "Direct connection new"); - proto_tree_add_item(tree, hf_dcc_id, tvb, offset, 8, ENC_NA); + proto_tree_add_item(tree, &hfi_dcc_id, tvb, offset, 8, ENC_NA); offset += 8; - proto_tree_add_item(tree, hf_dcc_uin_from, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_dcc_uin_from, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; - proto_tree_add_item(tree, hf_dcc_uin_to, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_dcc_uin_to, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; - proto_tree_add_item(tree, hf_dcc_type, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_dcc_type, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; - proto_tree_add_item(tree, hf_dcc_filename, tvb, offset, 255, ENC_ASCII | ENC_NA); + proto_tree_add_item(tree, &hfi_dcc_filename, tvb, offset, 255, ENC_ASCII | ENC_NA); offset += 255; return offset; @@ -1534,13 +1657,13 @@ dissect_gadu_gadu_dcc7_id_abort(tvbuff_t *tvb, packet_info *pinfo, proto_tree *t { col_set_str(pinfo->cinfo, COL_INFO, "Direct connection abort"); - proto_tree_add_item(tree, hf_dcc_id, tvb, offset, 8, ENC_NA); + proto_tree_add_item(tree, &hfi_dcc_id, tvb, offset, 8, ENC_NA); offset += 8; - proto_tree_add_item(tree, hf_dcc_uin_from, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_dcc_uin_from, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; - proto_tree_add_item(tree, hf_dcc_uin_to, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_dcc_uin_to, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; return offset; @@ -1553,16 +1676,16 @@ dissect_gadu_gadu_pubdir50_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree col_set_str(pinfo->cinfo, COL_INFO, "Public directory request"); - proto_tree_add_item(tree, hf_gadu_gadu_pubdir_request_type, tvb, offset, 1, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_pubdir_request_type, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset += 1; - proto_tree_add_item(tree, hf_gadu_gadu_pubdir_request_seq, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_pubdir_request_seq, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; /* XXX, link request sequence with reply sequence */ while ((pos = tvb_find_guint8(tvb, offset, -1, '\0')) > 0) { /* XXX, display it better, field=value */ - dissect_gadu_gadu_stringz_cp1250(tvb, hf_gadu_gadu_pubdir_request_str, tree, offset); + dissect_gadu_gadu_stringz_cp1250(tvb, &hfi_gadu_gadu_pubdir_request_str, tree, offset); offset = pos + 1; } @@ -1576,16 +1699,16 @@ dissect_gadu_gadu_pubdir50_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree * col_set_str(pinfo->cinfo, COL_INFO, "Public directory reply"); - proto_tree_add_item(tree, hf_gadu_gadu_pubdir_reply_type, tvb, offset, 1, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_pubdir_reply_type, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset += 1; - proto_tree_add_item(tree, hf_gadu_gadu_pubdir_reply_seq, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, &hfi_gadu_gadu_pubdir_reply_seq, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; /* XXX, link reply sequence with request sequence */ while ((pos = tvb_find_guint8(tvb, offset, -1, '\0')) > 0) { /* XXX, display it better, field=value */ - dissect_gadu_gadu_stringz_cp1250(tvb, hf_gadu_gadu_pubdir_reply_str, tree, offset); + dissect_gadu_gadu_stringz_cp1250(tvb, &hfi_gadu_gadu_pubdir_reply_str, tree, offset); offset = pos + 1; } @@ -1619,14 +1742,14 @@ dissect_gadu_gadu_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) col_clear(pinfo->cinfo, COL_INFO); /* XXX, remove, add separator when multiple PDU */ if (tree) { - proto_item *ti = proto_tree_add_item(tree, proto_gadu_gadu, tvb, 0, -1, ENC_NA); + proto_item *ti = proto_tree_add_item_old(tree, proto_gadu_gadu, tvb, 0, -1, ENC_NA); gadu_gadu_tree = proto_item_add_subtree(ti, ett_gadu_gadu); } pkt_type = tvb_get_letohl(tvb, offset); - proto_tree_add_item(gadu_gadu_tree, (pinfo->p2p_dir == P2P_DIR_RECV) ? hf_gadu_gadu_header_type_recv : hf_gadu_gadu_header_type_send, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(gadu_gadu_tree, (pinfo->p2p_dir == P2P_DIR_RECV) ? &hfi_gadu_gadu_header_type_recv : &hfi_gadu_gadu_header_type_send, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; - proto_tree_add_item(gadu_gadu_tree, hf_gadu_gadu_header_length, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(gadu_gadu_tree, &hfi_gadu_gadu_header_length, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; if (pinfo->p2p_dir == P2P_DIR_RECV) { @@ -1878,7 +2001,7 @@ dissect_gadu_gadu_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) /* for now display rest of data as FT_BYTES. */ if (tvb_reported_length_remaining(tvb, offset) > 0) { - proto_tree_add_item(gadu_gadu_tree, hf_gadu_gadu_data, tvb, offset, -1, ENC_NA); + proto_tree_add_item(gadu_gadu_tree, &hfi_gadu_gadu_data, tvb, offset, -1, ENC_NA); } } @@ -1910,199 +2033,81 @@ dissect_gadu_gadu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat void proto_register_gadu_gadu(void) { - static hf_register_info hf[] = { + static header_field_info *hfi[] = { /* Header */ - { &hf_gadu_gadu_header_type_recv, - { "Packet Type", "gadu-gadu.recv", FT_UINT32, BASE_HEX, VALS(gadu_gadu_packets_type_recv), 0x0, "Packet Type (recv)", HFILL } - }, - { &hf_gadu_gadu_header_type_send, - { "Packet Type", "gadu-gadu.send", FT_UINT32, BASE_HEX, VALS(gadu_gadu_packets_type_send), 0x0, "Packet Type (send)", HFILL } - }, - { &hf_gadu_gadu_header_length, - { "Packet Length", "gadu-gadu.len", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } - }, + &hfi_gadu_gadu_header_type_recv, + &hfi_gadu_gadu_header_type_send, + &hfi_gadu_gadu_header_length, /* Login common */ - { &hf_gadu_gadu_login_uin, - { "Client UIN", "gadu-gadu.login.uin", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL } - }, - { &hf_gadu_gadu_login_hash_type, - { "Login hash type", "gadu-gadu.login.hash_type", FT_UINT8, BASE_HEX, gadu_gadu_hash_type_vals, 0x00, NULL, HFILL } - }, - { &hf_gadu_gadu_login_hash, - { "Login hash", "gadu-gadu.login.hash", FT_BYTES, BASE_NONE, NULL, 0x00, NULL, HFILL } - }, - { &hf_gadu_gadu_login_status, - { "Client status", "gadu-gadu.login.status", FT_UINT32, BASE_HEX, NULL, 0x00, NULL, HFILL } - }, - { &hf_gadu_gadu_login_protocol, - { "Client protocol", "gadu-gadu.login.protocol", FT_UINT32, BASE_HEX, NULL, 0x00, NULL, HFILL } - }, - { &hf_gadu_gadu_login_version, - { "Client version", "gadu-gadu.login.version", FT_STRING, BASE_NONE, NULL, 0x00, NULL, HFILL } - }, - { &hf_gadu_gadu_login_local_ip, - { "Client local IP", "gadu-gadu.login.local_ip", FT_IPv4, BASE_NONE, NULL, 0x00, NULL, HFILL } - }, - { &hf_gadu_gadu_login_local_port, - { "Client local port", "gadu-gadu.login.local_port", FT_UINT16, BASE_DEC, NULL, 0x00, NULL, HFILL } - }, + &hfi_gadu_gadu_login_uin, + &hfi_gadu_gadu_login_hash_type, + &hfi_gadu_gadu_login_hash, + &hfi_gadu_gadu_login_status, + &hfi_gadu_gadu_login_protocol, + &hfi_gadu_gadu_login_version, + &hfi_gadu_gadu_login_local_ip, + &hfi_gadu_gadu_login_local_port, /* GG_LOGIN80 */ - { &hf_gadu_gadu_login80_lang, - { "Client language", "gadu-gadu.login80.lang", FT_STRING, BASE_NONE, NULL, 0x00, NULL, HFILL } - }, + &hfi_gadu_gadu_login80_lang, /* Contacts details */ - { &hf_gadu_gadu_userdata_uin, - { "UIN", "gadu-gadu.user_data.uin", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL } - }, - { &hf_gadu_gadu_userdata_attr_name, - { "Attribute name", "gadu-gadu.user_data.attr_name", FT_STRING, BASE_NONE, NULL, 0x00, NULL, HFILL } - }, - { &hf_gadu_gadu_userdata_attr_type, - { "Attribute type", "gadu-gadu.user_data.attr_type", FT_UINT32, BASE_HEX, NULL, 0x00, NULL, HFILL } - }, - { &hf_gadu_gadu_userdata_attr_value, - { "Attribute value", "gadu-gadu.user_data.attr_val", FT_STRING, BASE_NONE, NULL, 0x00, NULL, HFILL } - }, - { &hf_gadu_gadu_typing_notify_type, - { "Typing notify type", "gadu-gadu.typing_notify.type", FT_UINT16, BASE_HEX, gadu_gadu_typing_notify_type_vals, 0x00, NULL, HFILL } - }, - { &hf_gadu_gadu_typing_notify_uin, - { "Typing notify recipient", "gadu-gadu.typing_notify.uin", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL } - }, + &hfi_gadu_gadu_userdata_uin, + &hfi_gadu_gadu_userdata_attr_name, + &hfi_gadu_gadu_userdata_attr_type, + &hfi_gadu_gadu_userdata_attr_value, + &hfi_gadu_gadu_typing_notify_type, + &hfi_gadu_gadu_typing_notify_uin, /* Message common */ - { &hf_gadu_gadu_msg_uin, - { "Message sender or recipient", "gadu-gadu.msg.uin", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL } - }, - { &hf_gadu_gadu_msg_sender, - { "Message sender", "gadu-gadu.msg.sender", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL } - }, - { &hf_gadu_gadu_msg_recipient, - { "Message recipient", "gadu-gadu.msg.recipient", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL } - }, - { &hf_gadu_gadu_msg_seq, - { "Message sequence number", "gadu-gadu.msg.seq", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL } - }, - { &hf_gadu_gadu_msg_time, - { "Message time", "gadu-gadu.msg.time", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0, NULL, HFILL } - }, - { &hf_gadu_gadu_msg_class, - { "Message class", "gadu-gadu.msg.class", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL } - }, - { &hf_gadu_gadu_msg_text, - { "Message text", "gadu-gadu.msg.text", FT_STRINGZ, BASE_NONE, NULL, 0x0, NULL, HFILL } - }, + &hfi_gadu_gadu_msg_uin, + &hfi_gadu_gadu_msg_sender, + &hfi_gadu_gadu_msg_recipient, + &hfi_gadu_gadu_msg_seq, + &hfi_gadu_gadu_msg_time, + &hfi_gadu_gadu_msg_class, + &hfi_gadu_gadu_msg_text, /* GG_RECV_MSG80, GG_SEND_MSG80 */ - { &hf_gadu_gadu_msg80_offset_plain, - { "Message plaintext offset", "gadu-gadu.msg80.offset_plain", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL } - }, - { &hf_gadu_gadu_msg80_offset_attr, - { "Message attribute offset", "gadu-gadu.msg80.offset_attributes", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL } - }, + &hfi_gadu_gadu_msg80_offset_plain, + &hfi_gadu_gadu_msg80_offset_attr, /* Contact (notify) common */ - { &hf_gadu_gadu_contact_uin, - { "UIN", "gadu-gadu.contact.uin", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL } - }, - { &hf_gadu_gadu_contact_uin_str, - { "UIN", "gadu-gadu.contact.uin_str", FT_STRING, BASE_NONE, NULL, 0x00, NULL, HFILL } - }, - { &hf_gadu_gadu_contact_type, - { "Type", "gadu-gadu.contact.type", FT_UINT8, BASE_HEX, NULL, 0x00, NULL, HFILL } - }, + &hfi_gadu_gadu_contact_uin, + &hfi_gadu_gadu_contact_uin_str, + &hfi_gadu_gadu_contact_type, /* Status common */ - { &hf_gadu_gadu_status_uin, - { "UIN", "gadu-gadu.status.uin", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL } - }, - { &hf_gadu_gadu_status_status, - { "Status", "gadu-gadu.status.status", FT_UINT32, BASE_HEX, NULL, 0x00, NULL, HFILL } - }, - { &hf_gadu_gadu_status_ip, - { "IP", "gadu-gadu.status.remote_ip", FT_IPv4, BASE_NONE, NULL, 0x00, NULL, HFILL } - }, - { &hf_gadu_gadu_status_port, - { "Port", "gadu-gadu.status.remote_port", FT_UINT16, BASE_DEC, NULL, 0x00, NULL, HFILL } - }, - { &hf_gadu_gadu_status_version, - { "Version", "gadu-gadu.status.version", FT_UINT8, BASE_HEX, NULL, 0x00, NULL, HFILL } - }, - { &hf_gadu_gadu_status_img_size, - { "Image size", "gadu-gadu.status.image_size", FT_UINT8, BASE_DEC, NULL, 0x00, "Maximum image size in KB", HFILL } - }, - { &hf_gadu_gadu_status_descr, - { "Description", "gadu-gadu.status.description", FT_STRINGZ, BASE_NONE, NULL, 0x00, NULL, HFILL } - }, + &hfi_gadu_gadu_status_uin, + &hfi_gadu_gadu_status_status, + &hfi_gadu_gadu_status_ip, + &hfi_gadu_gadu_status_port, + &hfi_gadu_gadu_status_version, + &hfi_gadu_gadu_status_img_size, + &hfi_gadu_gadu_status_descr, /* New status (setting status) common */ - { &hf_gadu_gadu_new_status_status, - { "Status", "gadu-gadu.new_status.status", FT_UINT32, BASE_HEX, NULL, 0x00, NULL, HFILL } - }, - { &hf_gadu_gadu_new_status_desc, - { "Description", "gadu-gadu.new_status.description", FT_STRINGZ, BASE_NONE, NULL, 0x00, NULL, HFILL } - }, + &hfi_gadu_gadu_new_status_status, + &hfi_gadu_gadu_new_status_desc, /* Userlist */ - { &hf_gadu_gadu_userlist_request_type, - { "Request type", "gadu-gadu.userlist.request_type", FT_UINT32, BASE_HEX, gadu_gadu_userlist_request_type_vals, 0x00, NULL, HFILL } - }, - { &hf_gadu_gadu_userlist_version, - { "Userlist version", "gadu-gadu.userlist.version", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL } - }, - { &hf_gadu_gadu_userlist_format, - { "Userlist format", "gadu-gadu.userlist.format", FT_UINT8, BASE_HEX, gadu_gadu_userlist_request_format_vals, 0x00, NULL, HFILL } - }, - { &hf_gadu_gadu_userlist_reply_type, - { "Reply type", "gadu-gadu.userlist.reply_type", FT_UINT32, BASE_HEX, gadu_gadu_userlist_reply_type_vals, 0x00, NULL, HFILL } - }, + &hfi_gadu_gadu_userlist_request_type, + &hfi_gadu_gadu_userlist_version, + &hfi_gadu_gadu_userlist_format, + &hfi_gadu_gadu_userlist_reply_type, /* Direct Connection */ - { &hf_dcc_type, - { "Direct connection type", "gadu-gadu.dcc.type", FT_UINT32, BASE_HEX, gadu_gadu_dcc_type_vals, 0x00, NULL, HFILL } - }, - { &hf_dcc_id, - { "Direct connection id", "gadu-gadu.dcc.id", FT_BYTES, BASE_NONE, NULL, 0x00, NULL, HFILL } - }, - { &hf_dcc_uin_to, - { "Direct connection UIN target", "gadu-gadu.dcc.uin_to", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL } - }, - { &hf_dcc_uin_from, - { "Direct connection UIN initiator", "gadu-gadu.dcc.uin_from", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL } - }, - { &hf_dcc_filename, - { "Direct connection filename", "gadu-gadu.dcc.filename", FT_STRING, BASE_NONE, NULL, 0x00, NULL, HFILL } - }, + &hfi_dcc_type, + &hfi_dcc_id, + &hfi_dcc_uin_to, + &hfi_dcc_uin_from, + &hfi_dcc_filename, /* Public Directory */ - { &hf_gadu_gadu_pubdir_request_type, - { "Request type", "gadu-gadu.pubdir.request_type", FT_UINT8, BASE_HEX, gadu_gadu_pubdir_type_vals, 0x00, NULL, HFILL } - }, - { &hf_gadu_gadu_pubdir_request_seq, - { "Request sequence", "gadu-gadu.pubdir.request_seq", FT_UINT32, BASE_HEX, NULL, 0x00, NULL, HFILL } - }, - { &hf_gadu_gadu_pubdir_request_str, - { "Request string", "gadu-gadu.pubdir.request_str", FT_STRINGZ, BASE_NONE, NULL, 0x00, NULL, HFILL } - }, - { &hf_gadu_gadu_pubdir_reply_type, - { "Reply type", "gadu-gadu.pubdir.reply_type", FT_UINT8, BASE_HEX, gadu_gadu_pubdir_type_vals, 0x00, NULL, HFILL } - }, - { &hf_gadu_gadu_pubdir_reply_seq, - { "Reply sequence", "gadu-gadu.pubdir.reply_seq", FT_UINT32, BASE_HEX, NULL, 0x00, NULL, HFILL } - }, - { &hf_gadu_gadu_pubdir_reply_str, - { "Reply string", "gadu-gadu.pubdir.request_str", FT_STRINGZ, BASE_NONE, NULL, 0x00, NULL, HFILL } - }, + &hfi_gadu_gadu_pubdir_request_type, + &hfi_gadu_gadu_pubdir_request_seq, + &hfi_gadu_gadu_pubdir_request_str, + &hfi_gadu_gadu_pubdir_reply_type, + &hfi_gadu_gadu_pubdir_reply_seq, + &hfi_gadu_gadu_pubdir_reply_str, /* GG_WELCOME */ - { &hf_gadu_gadu_welcome_seed, - { "Seed", "gadu-gadu.welcome.seed", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL } - }, + &hfi_gadu_gadu_welcome_seed, /* GG_SEND_MSG_ACK */ - { &hf_gadu_gadu_msg_ack_status, - { "Message status", "gadu-gadu.msg_ack.status", FT_UINT32, BASE_HEX, gadu_gadu_msg_ack_status_vals, 0x00, NULL, HFILL } - }, - { &hf_gadu_gadu_msg_ack_recipient, - { "Message recipient", "gadu-gadu.msg_ack.recipient", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL } - }, - { &hf_gadu_gadu_msg_ack_seq, - { "Message sequence number", "gadu-gadu.msg_ack.seq", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL } - }, + &hfi_gadu_gadu_msg_ack_status, + &hfi_gadu_gadu_msg_ack_recipient, + &hfi_gadu_gadu_msg_ack_seq, /* Not dissected data */ - { &hf_gadu_gadu_data, - { "Packet Data", "gadu-gadu.data", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } - }, + &hfi_gadu_gadu_data, }; static gint *ett[] = { @@ -2121,7 +2126,7 @@ proto_register_gadu_gadu(void) "To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.", &gadu_gadu_desegment); - proto_register_field_array(proto_gadu_gadu, hf, array_length(hf)); + proto_register_fields(proto_gadu_gadu, hfi, array_length(hfi)); proto_register_subtree_array(ett, array_length(ett)); } diff --git a/epan/dissectors/packet-json.c b/epan/dissectors/packet-json.c index 83cdf28a15..fe72b24ce3 100644 --- a/epan/dissectors/packet-json.c +++ b/epan/dissectors/packet-json.c @@ -27,6 +27,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#define NEW_PROTO_TREE_API + #include "config.h" #include <glib.h> @@ -42,16 +44,36 @@ static gint ett_json_array = -1; static gint ett_json_object = -1; static gint ett_json_member = -1; -static gint hf_json_array = -1; -static gint hf_json_object = -1; -static gint hf_json_member = -1; -/* XXX, static gint hf_json_member_key = -1; */ +static header_field_info hfi_json_array HFI_INIT(proto_json) = + { "Array", "json.array", FT_NONE, BASE_NONE, NULL, 0x00, "JSON array", HFILL }; + +static header_field_info hfi_json_object HFI_INIT(proto_json) = + { "Object", "json.object", FT_NONE, BASE_NONE, NULL, 0x00, "JSON object", HFILL }; + +static header_field_info hfi_json_member HFI_INIT(proto_json) = + { "Member", "json.member", FT_NONE, BASE_NONE, NULL, 0x00, "JSON object member", HFILL }; + +#if 0 +/* XXX */ +static header_field_info hfi_json_member_key HFI_INIT(proto_json) = + { "Key", "json.member.key", FT_NONE, BASE_NONE, NULL, 0x00, NULL, HFILL }; +#endif + +static header_field_info hfi_json_value_string HFI_INIT(proto_json) = /* FT_STRINGZ? */ + { "String value", "json.value.string", FT_STRING, BASE_NONE, NULL, 0x00, "JSON string value", HFILL }; + +static header_field_info hfi_json_value_number HFI_INIT(proto_json) = /* FT_DOUBLE/ FT_INT64? */ + { "Number value", "json.value.number", FT_STRING, BASE_NONE, NULL, 0x00, "JSON number value", HFILL }; + +static header_field_info hfi_json_value_false HFI_INIT(proto_json) = + { "False value", "json.value.false", FT_NONE, BASE_NONE, NULL, 0x00, "JSON false value", HFILL }; + +static header_field_info hfi_json_value_null HFI_INIT(proto_json) = + { "Null value", "json.value.null", FT_NONE, BASE_NONE, NULL, 0x00, "JSON null value", HFILL }; + +static header_field_info hfi_json_value_true HFI_INIT(proto_json) = + { "True value", "json.value.true", FT_NONE, BASE_NONE, NULL, 0x00, "JSON true value", HFILL }; -static gint hf_json_value_string = -1; -static gint hf_json_value_number = -1; -static gint hf_json_value_false = -1; -static gint hf_json_value_null = -1; -static gint hf_json_value_true = -1; static tvbparse_wanted_t* want; static tvbparse_wanted_t* want_ignore; @@ -104,7 +126,7 @@ dissect_json(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) } if (tree) { - ti = proto_tree_add_item(tree, proto_json, tvb, 0, -1, ENC_NA); + ti = proto_tree_add_item_old(tree, proto_json, tvb, 0, -1, ENC_NA); json_tree = proto_item_add_subtree(ti, ett_json); if (data_name) @@ -149,7 +171,7 @@ static void before_object(void *tvbparse_data, const void *wanted_data _U_, tvbp proto_tree *subtree; proto_item *ti; - ti = proto_tree_add_item(tree, hf_json_object, tok->tvb, tok->offset, tok->len, ENC_NA); + ti = proto_tree_add_item(tree, &hfi_json_object, tok->tvb, tok->offset, tok->len, ENC_NA); subtree = proto_item_add_subtree(ti, ett_json_object); ep_stack_push(data->stack, subtree); @@ -168,7 +190,7 @@ static void before_member(void *tvbparse_data, const void *wanted_data _U_, tvbp proto_tree *subtree; proto_item *ti; - ti = proto_tree_add_item(tree, hf_json_member, tok->tvb, tok->offset, tok->len, ENC_NA); + ti = proto_tree_add_item(tree, &hfi_json_member, tok->tvb, tok->offset, tok->len, ENC_NA); subtree = proto_item_add_subtree(ti, ett_json_member); ep_stack_push(data->stack, subtree); @@ -187,7 +209,7 @@ static void after_member(void *tvbparse_data, const void *wanted_data _U_, tvbpa proto_item_append_text(tree, " Key: %s", key); } - /* XXX, hf_json_member_key */ + /* XXX, &hfi_json_member_key */ } } @@ -198,7 +220,7 @@ static void before_array(void *tvbparse_data, const void *wanted_data _U_, tvbpa proto_tree *subtree; proto_item *ti; - ti = proto_tree_add_item(tree, hf_json_array, tok->tvb, tok->offset, tok->len, ENC_NA); + ti = proto_tree_add_item(tree, &hfi_json_array, tok->tvb, tok->offset, tok->len, ENC_NA); subtree = proto_item_add_subtree(ti, ett_json_array); ep_stack_push(data->stack, subtree); @@ -359,26 +381,26 @@ static void after_value(void *tvbparse_data, const void *wanted_data _U_, tvbpar switch (value_id) { case JSON_TOKEN_STRING: if (tok->len >= 2) - proto_tree_add_unicode_string(tree, hf_json_value_string, tok->tvb, tok->offset, tok->len, json_string_unescape(tok)); + proto_tree_add_unicode_string(tree, hfi_json_value_string.id, tok->tvb, tok->offset, tok->len, json_string_unescape(tok)); else - proto_tree_add_item(tree, hf_json_value_string, tok->tvb, tok->offset, tok->len, ENC_ASCII|ENC_NA); + proto_tree_add_item(tree, &hfi_json_value_string, tok->tvb, tok->offset, tok->len, ENC_ASCII|ENC_NA); break; case JSON_TOKEN_NUMBER: /* XXX, convert to number */ - proto_tree_add_item(tree, hf_json_value_number, tok->tvb, tok->offset, tok->len, ENC_ASCII|ENC_NA); + proto_tree_add_item(tree, &hfi_json_value_number, tok->tvb, tok->offset, tok->len, ENC_ASCII|ENC_NA); break; case JSON_TOKEN_FALSE: - proto_tree_add_item(tree, hf_json_value_false, tok->tvb, tok->offset, tok->len, ENC_NA); + proto_tree_add_item(tree, &hfi_json_value_false, tok->tvb, tok->offset, tok->len, ENC_NA); break; case JSON_TOKEN_NULL: - proto_tree_add_item(tree, hf_json_value_null, tok->tvb, tok->offset, tok->len, ENC_NA); + proto_tree_add_item(tree, &hfi_json_value_null, tok->tvb, tok->offset, tok->len, ENC_NA); break; case JSON_TOKEN_TRUE: - proto_tree_add_item(tree, hf_json_value_true, tok->tvb, tok->offset, tok->len, ENC_NA); + proto_tree_add_item(tree, &hfi_json_value_true, tok->tvb, tok->offset, tok->len, ENC_NA); break; case JSON_OBJECT: @@ -534,42 +556,21 @@ proto_register_json(void) { &ett_json_member }; - static hf_register_info hf[] = { - { &hf_json_array, - { "Array", "json.array", FT_NONE, BASE_NONE, NULL, 0x00, "JSON array", HFILL } - }, - { &hf_json_object, - { "Object", "json.object", FT_NONE, BASE_NONE, NULL, 0x00, "JSON object", HFILL } - }, - { &hf_json_member, - { "Member", "json.member", FT_NONE, BASE_NONE, NULL, 0x00, "JSON object member", HFILL }, - }, -/* XXX - { &hf_json_member_key, - { "Key", "json.member.key", FT_NONE, BASE_NONE, NULL, 0x00, NULL, HFILL }, - }, -*/ - { &hf_json_value_string, /* FT_STRINGZ? */ - { "String value", "json.value.string", FT_STRING, BASE_NONE, NULL, 0x00, "JSON string value", HFILL }, - }, - { &hf_json_value_number, /* FT_DOUBLE/ FT_INT64? */ - { "Number value", "json.value.number", FT_STRING, BASE_NONE, NULL, 0x00, "JSON number value", HFILL }, - }, - { &hf_json_value_false, - { "False value", "json.value.false", FT_NONE, BASE_NONE, NULL, 0x00, "JSON false value", HFILL }, - }, - { &hf_json_value_null, - { "Null value", "json.value.null", FT_NONE, BASE_NONE, NULL, 0x00, "JSON null value", HFILL }, - }, - { &hf_json_value_true, - { "True value", "json.value.true", FT_NONE, BASE_NONE, NULL, 0x00, "JSON true value", HFILL }, - }, - + static header_field_info *hfi[] = { + &hfi_json_array, + &hfi_json_object, + &hfi_json_member, + /* &hfi_json_member_key, */ + &hfi_json_value_string, + &hfi_json_value_number, + &hfi_json_value_false, + &hfi_json_value_null, + &hfi_json_value_true, }; proto_json = proto_register_protocol("JavaScript Object Notation", "JSON", "json"); - proto_register_field_array(proto_json, hf, array_length(hf)); + proto_register_fields(proto_json, hfi, array_length(hfi)); proto_register_subtree_array(ett, array_length(ett)); register_dissector("json", dissect_json, proto_json); diff --git a/epan/dissectors/packet-nflog.c b/epan/dissectors/packet-nflog.c index 4d47f834d0..19864cadf9 100644 --- a/epan/dissectors/packet-nflog.c +++ b/epan/dissectors/packet-nflog.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> @@ -65,31 +67,6 @@ static const enum_val_t byte_order_types[] = { { NULL, NULL, 0 } }; -static gint nflog_byte_order = BYTE_ORDER_AUTO; - -static int proto_nflog = -1; - -static int ett_nflog = -1; -static int ett_nflog_tlv = -1; - -static int hf_nflog_family = -1; -static int hf_nflog_version = -1; -static int hf_nflog_resid = -1; -static int hf_nflog_encoding = -1; - -static int hf_nflog_tlv = -1; -static int hf_nflog_tlv_length = -1; -static int hf_nflog_tlv_type = -1; -static int hf_nflog_tlv_prefix = -1; -static int hf_nflog_tlv_uid = -1; -static int hf_nflog_tlv_gid = -1; -static int hf_nflog_tlv_timestamp = -1; -static int hf_nflog_tlv_unknown = -1; - -static dissector_handle_t ip_handle; -static dissector_handle_t ip6_handle; -static dissector_handle_t data_handle; - static const value_string _linux_family_vals[] = { { LINUX_AF_INET, "IP" }, { LINUX_AF_INET6, "IPv6" }, @@ -125,6 +102,56 @@ static const value_string nflog_tlv_vals[] = { { 0, NULL } }; +static gint nflog_byte_order = BYTE_ORDER_AUTO; + +static int proto_nflog = -1; + +static int ett_nflog = -1; +static int ett_nflog_tlv = -1; + +/* Header */ +static header_field_info hfi_nflog_family HFI_INIT(proto_nflog) = + { "Family", "nflog.family", FT_UINT8, BASE_DEC, VALS(_linux_family_vals), 0x00, NULL, HFILL }; + +static header_field_info hfi_nflog_version HFI_INIT(proto_nflog) = + { "Version", "nflog.version", FT_UINT8, BASE_DEC, NULL, 0x00, NULL, HFILL }; + +static header_field_info hfi_nflog_resid HFI_INIT(proto_nflog) = + { "Resource id", "nflog.res_id", FT_UINT16, BASE_DEC, NULL, 0x00, NULL, HFILL }; + +static header_field_info hfi_nflog_encoding HFI_INIT(proto_nflog) = + { "Encoding", "nflog.encoding", FT_UINT32, BASE_HEX, VALS(_encoding_vals), 0x00, NULL, HFILL }; + +/* TLV */ +static header_field_info hfi_nflog_tlv HFI_INIT(proto_nflog) = + { "TLV", "nflog.tlv", FT_BYTES, BASE_NONE, NULL, 0x00, NULL, HFILL }; + +static header_field_info hfi_nflog_tlv_length HFI_INIT(proto_nflog) = + { "Length", "nflog.tlv_length", FT_UINT16, BASE_DEC, NULL, 0x00, "TLV Length", HFILL }; + +static header_field_info hfi_nflog_tlv_type HFI_INIT(proto_nflog) = + { "Type", "nflog.tlv_type", FT_UINT16, BASE_DEC, VALS(nflog_tlv_vals), 0x7fff, "TLV Type", HFILL }; + +/* TLV values */ +static header_field_info hfi_nflog_tlv_prefix HFI_INIT(proto_nflog) = + { "Prefix", "nflog.prefix", FT_STRINGZ, BASE_NONE, NULL, 0x00, "TLV Prefix Value", HFILL }; + +static header_field_info hfi_nflog_tlv_uid HFI_INIT(proto_nflog) = + { "UID", "nflog.uid", FT_INT32, BASE_DEC, NULL, 0x00, "TLV UID Value", HFILL }; + +static header_field_info hfi_nflog_tlv_gid HFI_INIT(proto_nflog) = + { "GID", "nflog.gid", FT_INT32, BASE_DEC, NULL, 0x00, "TLV GID Value", HFILL }; + +static header_field_info hfi_nflog_tlv_timestamp HFI_INIT(proto_nflog) = + { "Timestamp", "nflog.timestamp", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x00, "TLV Timestamp Value", HFILL }; + +static header_field_info hfi_nflog_tlv_unknown HFI_INIT(proto_nflog) = + { "Value", "nflog.tlv_value", FT_BYTES, BASE_NONE, NULL, 0x00, "TLV Value", HFILL }; + +static dissector_handle_t ip_handle; +static dissector_handle_t ip6_handle; +static dissector_handle_t data_handle; + static int nflog_tvb_test_order(tvbuff_t *tvb, int offset, guint16 (*val16_get)(tvbuff_t *, int)) { @@ -208,19 +235,19 @@ dissect_nflog(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) /* Header */ if (proto_field_is_referenced(tree, proto_nflog)) { - ti = proto_tree_add_item(tree, proto_nflog, tvb, 0, -1, ENC_NA); + ti = proto_tree_add_item_old(tree, proto_nflog, tvb, 0, -1, ENC_NA); nflog_tree = proto_item_add_subtree(ti, ett_nflog); - proto_tree_add_item(nflog_tree, hf_nflog_family, tvb, offset, 1, ENC_NA); + proto_tree_add_item(nflog_tree, &hfi_nflog_family, tvb, offset, 1, ENC_NA); offset += 1; - proto_tree_add_item(nflog_tree, hf_nflog_version, tvb, offset, 1, ENC_NA); + proto_tree_add_item(nflog_tree, &hfi_nflog_version, tvb, offset, 1, ENC_NA); offset += 1; - proto_tree_add_item(nflog_tree, hf_nflog_resid, tvb, offset, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(nflog_tree, &hfi_nflog_resid, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; - ti = proto_tree_add_uint(nflog_tree, hf_nflog_encoding, + ti = proto_tree_add_uint(nflog_tree, hfi_nflog_encoding.id, tvb, offset, tvb_length_remaining(tvb, offset), enc); PROTO_ITEM_SET_GENERATED(ti); } @@ -244,15 +271,15 @@ dissect_nflog(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) if (nflog_tree) { gboolean handled = FALSE; - ti = proto_tree_add_bytes_format(nflog_tree, hf_nflog_tlv, + ti = proto_tree_add_bytes_format(nflog_tree, hfi_nflog_tlv.id, tvb, offset, tlv_len, NULL, "TLV Type: %s (%u), Length: %u", val_to_str_const(tlv_type, nflog_tlv_vals, "Unknown"), tlv_type, tlv_len); tlv_tree = proto_item_add_subtree(ti, ett_nflog_tlv); - proto_tree_add_item(tlv_tree, hf_nflog_tlv_length, tvb, offset + 0, 2, enc); - proto_tree_add_item(tlv_tree, hf_nflog_tlv_type, tvb, offset + 2, 2, enc); + proto_tree_add_item(tlv_tree, &hfi_nflog_tlv_length, tvb, offset + 0, 2, enc); + proto_tree_add_item(tlv_tree, &hfi_nflog_tlv_type, tvb, offset + 2, 2, enc); switch (tlv_type) { case WS_NFULA_PAYLOAD: handled = TRUE; @@ -260,7 +287,7 @@ dissect_nflog(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) case WS_NFULA_PREFIX: if (value_len >= 1) { - proto_tree_add_item(tlv_tree, hf_nflog_tlv_prefix, + proto_tree_add_item(tlv_tree, &hfi_nflog_tlv_prefix, tvb, offset + 4, value_len, ENC_NA); handled = TRUE; } @@ -268,7 +295,7 @@ dissect_nflog(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) case WS_NFULA_UID: if (value_len == 4) { - proto_tree_add_item(tlv_tree, hf_nflog_tlv_uid, + proto_tree_add_item(tlv_tree, &hfi_nflog_tlv_uid, tvb, offset + 4, value_len, ENC_BIG_ENDIAN); handled = TRUE; } @@ -276,7 +303,7 @@ dissect_nflog(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) case WS_NFULA_GID: if (value_len == 4) { - proto_tree_add_item(tlv_tree, hf_nflog_tlv_gid, + proto_tree_add_item(tlv_tree, &hfi_nflog_tlv_gid, tvb, offset + 4, value_len, ENC_BIG_ENDIAN); handled = TRUE; } @@ -289,7 +316,7 @@ dissect_nflog(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) ts.secs = (time_t)tvb_get_ntoh64(tvb, offset + 4); /* XXX - add an "expert info" warning if this is >= 10^9? */ ts.nsecs = (int)tvb_get_ntoh64(tvb, offset + 12); - proto_tree_add_time(tlv_tree, hf_nflog_tlv_timestamp, + proto_tree_add_time(tlv_tree, hfi_nflog_tlv_timestamp.id, tvb, offset + 4, value_len, &ts); handled = TRUE; } @@ -297,7 +324,7 @@ dissect_nflog(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) } if (!handled) - proto_tree_add_item(tlv_tree, hf_nflog_tlv_unknown, + proto_tree_add_item(tlv_tree, &hfi_nflog_tlv_unknown, tvb, offset + 4, value_len, ENC_NA); } @@ -325,48 +352,22 @@ dissect_nflog(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) void proto_register_nflog(void) { - static hf_register_info hf[] = { + static header_field_info *hfi[] = { /* Header */ - { &hf_nflog_family, - { "Family", "nflog.family", FT_UINT8, BASE_DEC, VALS(_linux_family_vals), 0x00, NULL, HFILL } - }, - { &hf_nflog_version, - { "Version", "nflog.version", FT_UINT8, BASE_DEC, NULL, 0x00, NULL, HFILL } - }, - { &hf_nflog_resid, - { "Resource id", "nflog.res_id", FT_UINT16, BASE_DEC, NULL, 0x00, NULL, HFILL } - }, - - { &hf_nflog_encoding, - { "Encoding", "nflog.encoding", FT_UINT32, BASE_HEX, VALS(_encoding_vals), 0x00, NULL, HFILL } - }, - + &hfi_nflog_family, + &hfi_nflog_version, + &hfi_nflog_resid, + &hfi_nflog_encoding, /* TLV */ - { &hf_nflog_tlv, - { "TLV", "nflog.tlv", FT_BYTES, BASE_NONE, NULL, 0x00, NULL, HFILL } - }, - { &hf_nflog_tlv_length, - { "Length", "nflog.tlv_length", FT_UINT16, BASE_DEC, NULL, 0x00, "TLV Length", HFILL } - }, - { &hf_nflog_tlv_type, - { "Type", "nflog.tlv_type", FT_UINT16, BASE_DEC, VALS(nflog_tlv_vals), 0x7fff, "TLV Type", HFILL } - }, + &hfi_nflog_tlv, + &hfi_nflog_tlv_length, + &hfi_nflog_tlv_type, /* TLV values */ - { &hf_nflog_tlv_prefix, - { "Prefix", "nflog.prefix", FT_STRINGZ, BASE_NONE, NULL, 0x00, "TLV Prefix Value", HFILL } - }, - { &hf_nflog_tlv_uid, - { "UID", "nflog.uid", FT_INT32, BASE_DEC, NULL, 0x00, "TLV UID Value", HFILL } - }, - { &hf_nflog_tlv_gid, - { "GID", "nflog.gid", FT_INT32, BASE_DEC, NULL, 0x00, "TLV GID Value", HFILL } - }, - { &hf_nflog_tlv_timestamp, - { "Timestamp", "nflog.timestamp", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x00, "TLV Timestamp Value", HFILL } - }, - { &hf_nflog_tlv_unknown, - { "Value", "nflog.tlv_value", FT_BYTES, BASE_NONE, NULL, 0x00, "TLV Value", HFILL } - }, + &hfi_nflog_tlv_prefix, + &hfi_nflog_tlv_uid, + &hfi_nflog_tlv_gid, + &hfi_nflog_tlv_timestamp, + &hfi_nflog_tlv_unknown, }; static gint *ett[] = { @@ -384,7 +385,7 @@ proto_register_nflog(void) register_dissector("nflog", dissect_nflog, proto_nflog); - proto_register_field_array(proto_nflog, hf, array_length(hf)); + proto_register_fields(proto_nflog, hfi, array_length(hfi)); proto_register_subtree_array(ett, array_length(ett)); } diff --git a/epan/dissectors/packet-yami.c b/epan/dissectors/packet-yami.c index e02161d5a5..c61dbc423d 100644 --- a/epan/dissectors/packet-yami.c +++ b/epan/dissectors/packet-yami.c @@ -26,6 +26,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#define NEW_PROTO_TREE_API + #include "config.h" #include <epan/packet.h> @@ -40,32 +42,6 @@ static gboolean yami_desegment = TRUE; static guint global_yami_config_tcp_port = 0; static guint global_yami_config_udp_port = 0; -static int hf_yami_message_id = -1; -static int hf_yami_frame_number = -1; -static int hf_yami_message_header_size = -1; -static int hf_yami_frame_payload_size = -1; - -static int hf_yami_message_hdr = -1; -static int hf_yami_message_data = -1; - -static int hf_yami_param = -1; -static int hf_yami_param_name = -1; -static int hf_yami_param_type = -1; -static int hf_yami_param_value_bool = -1; -static int hf_yami_param_value_int = -1; -static int hf_yami_param_value_long = -1; -static int hf_yami_param_value_double = -1; -static int hf_yami_param_value_str = -1; -static int hf_yami_param_value_bin = -1; - -static int hf_yami_params_count = -1; -static int hf_yami_items_count = -1; - -static int ett_yami = -1; -static int ett_yami_msg_hdr = -1; -static int ett_yami_msg_data = -1; -static int ett_yami_param = -1; - static int proto_yami = -1; #define YAMI_TYPE_BOOLEAN 1 @@ -99,6 +75,64 @@ static const value_string yami_param_type_vals[] = { { 0, NULL } }; +/* Header */ +static header_field_info hfi_yami_message_id HFI_INIT(proto_yami) = + { "Message ID", "yami.message_id", FT_INT32, BASE_DEC, NULL, 0x00, NULL, HFILL }; + +static header_field_info hfi_yami_frame_number HFI_INIT(proto_yami) = + { "Frame Number", "yami.frame_number", FT_INT32, BASE_DEC, NULL, 0x00, NULL, HFILL }; + +static header_field_info hfi_yami_message_header_size HFI_INIT(proto_yami) = + { "Message Header Size", "yami.message_header_size", FT_INT32, BASE_DEC, NULL, 0x00, NULL, HFILL }; + +static header_field_info hfi_yami_frame_payload_size HFI_INIT(proto_yami) = + { "Frame Payload Size", "yami.frame_payload_size", FT_INT32, BASE_DEC, NULL, 0x00, NULL, HFILL }; + +static header_field_info hfi_yami_message_hdr HFI_INIT(proto_yami) = + { "Header message", "yami.msg_hdr", FT_NONE, BASE_NONE, NULL, 0x00, NULL, HFILL }; + +static header_field_info hfi_yami_message_data HFI_INIT(proto_yami) = + { "Data message", "yami.msg_data", FT_NONE, BASE_NONE, NULL, 0x00, NULL, HFILL }; + +/* Parameter */ +static header_field_info hfi_yami_param HFI_INIT(proto_yami) = + { "Parameter", "yami.param", FT_NONE, BASE_NONE, NULL, 0x00, NULL, HFILL }; + +static header_field_info hfi_yami_param_name HFI_INIT(proto_yami) = + { "Name", "yami.param.name", FT_STRING, BASE_NONE, NULL, 0x00, "Parameter name", HFILL }; + +static header_field_info hfi_yami_param_type HFI_INIT(proto_yami) = + { "Type", "yami.param.type", FT_INT32, BASE_DEC, VALS(yami_param_type_vals), 0x00, "Parameter type", HFILL }; + +static header_field_info hfi_yami_param_value_bool HFI_INIT(proto_yami) = + { "Value", "yami.param.value_bool", FT_BOOLEAN, BASE_NONE, NULL, 0x00, "Parameter value (bool)", HFILL }; + +static header_field_info hfi_yami_param_value_int HFI_INIT(proto_yami) = + { "Value", "yami.param.value_int", FT_INT32, BASE_DEC, NULL, 0x00, "Parameter value (int)", HFILL }; + +static header_field_info hfi_yami_param_value_long HFI_INIT(proto_yami) = + { "Value", "yami.param.value_long", FT_INT64, BASE_DEC, NULL, 0x00, "Parameter value (long)", HFILL }; + +static header_field_info hfi_yami_param_value_double HFI_INIT(proto_yami) = + { "Value", "yami.param.value_double", FT_DOUBLE, BASE_NONE, NULL, 0x00, "Parameter value (double)", HFILL }; + +static header_field_info hfi_yami_param_value_str HFI_INIT(proto_yami) = + { "Value", "yami.param.value_str", FT_STRING, BASE_NONE, NULL, 0x00, "Parameter value (string)", HFILL }; + +static header_field_info hfi_yami_param_value_bin HFI_INIT(proto_yami) = + { "Value", "yami.param.value_bin", FT_BYTES, BASE_NONE, NULL, 0x00, "Parameter value (binary)", HFILL }; + +static header_field_info hfi_yami_params_count HFI_INIT(proto_yami) = + { "Parameters count", "yami.params_count", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }; + +static header_field_info hfi_yami_items_count HFI_INIT(proto_yami) = + { "Items count", "yami.items_count", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }; + +static int ett_yami = -1; +static int ett_yami_msg_hdr = -1; +static int ett_yami_msg_data = -1; +static int ett_yami_param = -1; + static int dissect_yami_parameter(tvbuff_t *tvb, proto_tree *tree, int offset, proto_item *par_ti) { @@ -113,7 +147,7 @@ dissect_yami_parameter(tvbuff_t *tvb, proto_tree *tree, int offset, proto_item * guint32 type; - ti = proto_tree_add_item(tree, hf_yami_param, tvb, offset, 0, ENC_NA); + ti = proto_tree_add_item(tree, &hfi_yami_param, tvb, offset, 0, ENC_NA); yami_param = proto_item_add_subtree(ti, ett_yami_param); name_offset = offset; @@ -124,10 +158,10 @@ dissect_yami_parameter(tvbuff_t *tvb, proto_tree *tree, int offset, proto_item * proto_item_append_text(ti, ": %s", name); proto_item_append_text(par_ti, "%s, ", name); offset += (name_len + 3) & ~3; - proto_tree_add_string(yami_param, hf_yami_param_name, tvb, name_offset, offset - name_offset, name); + proto_tree_add_string(yami_param, hfi_yami_param_name.id, tvb, name_offset, offset - name_offset, name); type = tvb_get_letohl(tvb, offset); - proto_tree_add_item(yami_param, hf_yami_param_type, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(yami_param, &hfi_yami_param_type, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; switch (type) { @@ -135,7 +169,7 @@ dissect_yami_parameter(tvbuff_t *tvb, proto_tree *tree, int offset, proto_item * { guint32 val = tvb_get_letohl(tvb, offset); proto_item_append_text(ti, ", Type: boolean, Value: %s", val ? "True" : "False"); - proto_tree_add_item(yami_param, hf_yami_param_value_bool, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(yami_param, &hfi_yami_param_value_bool, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; break; } @@ -144,7 +178,7 @@ dissect_yami_parameter(tvbuff_t *tvb, proto_tree *tree, int offset, proto_item * { gint32 val = tvb_get_letohl(tvb, offset); proto_item_append_text(ti, ", Type: integer, Value: %d", val); - proto_tree_add_item(yami_param, hf_yami_param_value_int, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(yami_param, &hfi_yami_param_value_int, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; break; } @@ -153,7 +187,7 @@ dissect_yami_parameter(tvbuff_t *tvb, proto_tree *tree, int offset, proto_item * { gint64 val = tvb_get_letoh64(tvb, offset); proto_item_append_text(ti, ", Type: long, Value: %" G_GINT64_MODIFIER "d", val); - proto_tree_add_item(yami_param, hf_yami_param_value_long, tvb, offset, 8, ENC_LITTLE_ENDIAN); + proto_tree_add_item(yami_param, &hfi_yami_param_value_long, tvb, offset, 8, ENC_LITTLE_ENDIAN); offset += 8; break; } @@ -162,7 +196,7 @@ dissect_yami_parameter(tvbuff_t *tvb, proto_tree *tree, int offset, proto_item * { gdouble val = tvb_get_letohieee_double(tvb, offset); proto_item_append_text(ti, ", Type: double, Value: %g", val); - proto_tree_add_item(yami_param, hf_yami_param_value_double, tvb, offset, 8, ENC_LITTLE_ENDIAN); + proto_tree_add_item(yami_param, &hfi_yami_param_value_double, tvb, offset, 8, ENC_LITTLE_ENDIAN); offset += 8; break; } @@ -180,7 +214,7 @@ dissect_yami_parameter(tvbuff_t *tvb, proto_tree *tree, int offset, proto_item * proto_item_append_text(ti, ", Type: string, Value: \"%s\"", val); offset += (val_len + 3) & ~3; - proto_tree_add_string(yami_param, hf_yami_param_value_str, tvb, val_offset, offset - val_offset, val); + proto_tree_add_string(yami_param, hfi_yami_param_value_str.id, tvb, val_offset, offset - val_offset, val); break; } @@ -199,7 +233,7 @@ dissect_yami_parameter(tvbuff_t *tvb, proto_tree *tree, int offset, proto_item * proto_item_append_text(ti, ", Type: binary, Value: %s", repr); offset += (val_len + 3) & ~3; - proto_tree_add_bytes_format_value(yami_param, hf_yami_param_value_bin, tvb, val_offset, offset - val_offset, val, "%s", repr); + proto_tree_add_bytes_format_value(yami_param, hfi_yami_param_value_bin.id, tvb, val_offset, offset - val_offset, val, "%s", repr); break; } @@ -210,7 +244,7 @@ dissect_yami_parameter(tvbuff_t *tvb, proto_tree *tree, int offset, proto_item * int j; count = tvb_get_letohl(tvb, offset); - proto_tree_add_item(yami_param, hf_yami_items_count, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(yami_param, &hfi_yami_items_count, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; proto_item_append_text(ti, ", Type: boolean[], %u items: {", count); @@ -222,7 +256,7 @@ dissect_yami_parameter(tvbuff_t *tvb, proto_tree *tree, int offset, proto_item * int r = !!(val & (1 << j)); proto_item_append_text(ti, "%s, ", r ? "T" : "F"); - proto_tree_add_boolean(yami_param, hf_yami_param_value_bool, tvb, offset+(j/8), 1, r); + proto_tree_add_boolean(yami_param, hfi_yami_param_value_bool.id, tvb, offset+(j/8), 1, r); } offset += 4; } @@ -235,7 +269,7 @@ dissect_yami_parameter(tvbuff_t *tvb, proto_tree *tree, int offset, proto_item * int r = !!(val & (1 << j)); proto_item_append_text(ti, "%s, ", r ? "T" : "F"); - proto_tree_add_boolean(yami_param, hf_yami_param_value_bool, tvb, offset+(j/8), 1, r); + proto_tree_add_boolean(yami_param, hfi_yami_param_value_bool.id, tvb, offset+(j/8), 1, r); } offset += 4; } @@ -250,7 +284,7 @@ dissect_yami_parameter(tvbuff_t *tvb, proto_tree *tree, int offset, proto_item * guint i; count = tvb_get_letohl(tvb, offset); - proto_tree_add_item(yami_param, hf_yami_items_count, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(yami_param, &hfi_yami_items_count, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; proto_item_append_text(ti, ", Type: integer[], %u items: {", count); @@ -258,7 +292,7 @@ dissect_yami_parameter(tvbuff_t *tvb, proto_tree *tree, int offset, proto_item * gint32 val = tvb_get_letohl(tvb, offset); proto_item_append_text(ti, "%d, ", val); - proto_tree_add_item(yami_param, hf_yami_param_value_int, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(yami_param, &hfi_yami_param_value_int, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; } proto_item_append_text(ti, "}"); @@ -271,7 +305,7 @@ dissect_yami_parameter(tvbuff_t *tvb, proto_tree *tree, int offset, proto_item * guint i; count = tvb_get_letohl(tvb, offset); - proto_tree_add_item(yami_param, hf_yami_items_count, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(yami_param, &hfi_yami_items_count, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; proto_item_append_text(ti, ", Type: long long[], %u items: {", count); @@ -280,7 +314,7 @@ dissect_yami_parameter(tvbuff_t *tvb, proto_tree *tree, int offset, proto_item * gint64 val = tvb_get_letoh64(tvb, offset); proto_item_append_text(ti, "%" G_GINT64_MODIFIER "d, ", val); - proto_tree_add_item(yami_param, hf_yami_param_value_long, tvb, offset, 8, ENC_LITTLE_ENDIAN); + proto_tree_add_item(yami_param, &hfi_yami_param_value_long, tvb, offset, 8, ENC_LITTLE_ENDIAN); offset += 8; } proto_item_append_text(ti, "}"); @@ -293,7 +327,7 @@ dissect_yami_parameter(tvbuff_t *tvb, proto_tree *tree, int offset, proto_item * guint i; count = tvb_get_letohl(tvb, offset); - proto_tree_add_item(yami_param, hf_yami_items_count, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(yami_param, &hfi_yami_items_count, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; proto_item_append_text(ti, ", Type: double[], %u items: {", count); @@ -302,7 +336,7 @@ dissect_yami_parameter(tvbuff_t *tvb, proto_tree *tree, int offset, proto_item * gdouble val = tvb_get_letohieee_double(tvb, offset); proto_item_append_text(ti, "%g, ", val); - proto_tree_add_item(yami_param, hf_yami_param_value_double, tvb, offset, 8, ENC_LITTLE_ENDIAN); + proto_tree_add_item(yami_param, &hfi_yami_param_value_double, tvb, offset, 8, ENC_LITTLE_ENDIAN); offset += 8; } proto_item_append_text(ti, "}"); @@ -315,7 +349,7 @@ dissect_yami_parameter(tvbuff_t *tvb, proto_tree *tree, int offset, proto_item * guint i; count = tvb_get_letohl(tvb, offset); - proto_tree_add_item(yami_param, hf_yami_items_count, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(yami_param, &hfi_yami_items_count, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; proto_item_append_text(ti, ", Type: string[], %u items: {", count); @@ -331,7 +365,7 @@ dissect_yami_parameter(tvbuff_t *tvb, proto_tree *tree, int offset, proto_item * val = tvb_get_ephemeral_string_enc(tvb, offset, val_len, ENC_ASCII | ENC_NA); proto_item_append_text(ti, "\"%s\", ", val); - proto_tree_add_string(yami_param, hf_yami_param_value_str, tvb, val_offset, offset - val_offset, val); + proto_tree_add_string(yami_param, hfi_yami_param_value_str.id, tvb, val_offset, offset - val_offset, val); offset += (val_len + 3) & ~3; } proto_item_append_text(ti, "}"); @@ -344,7 +378,7 @@ dissect_yami_parameter(tvbuff_t *tvb, proto_tree *tree, int offset, proto_item * guint i; count = tvb_get_letohl(tvb, offset); - proto_tree_add_item(yami_param, hf_yami_items_count, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(yami_param, &hfi_yami_items_count, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; proto_item_append_text(ti, ", Type: binary[], %u items: {", count); @@ -363,7 +397,7 @@ dissect_yami_parameter(tvbuff_t *tvb, proto_tree *tree, int offset, proto_item * proto_item_append_text(ti, "%s, ", repr); offset += (val_len + 3) & ~3; - proto_tree_add_bytes_format_value(yami_param, hf_yami_param_value_bin, tvb, val_offset, offset - val_offset, val, "%s", repr); + proto_tree_add_bytes_format_value(yami_param, hfi_yami_param_value_bin.id, tvb, val_offset, offset - val_offset, val, "%s", repr); } proto_item_append_text(ti, "}"); break; @@ -375,7 +409,7 @@ dissect_yami_parameter(tvbuff_t *tvb, proto_tree *tree, int offset, proto_item * guint i; count = tvb_get_letohl(tvb, offset); - proto_tree_add_item(yami_param, hf_yami_params_count, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(yami_param, &hfi_yami_params_count, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; proto_item_append_text(ti, ", Type: nested, %u parameters: ", count); @@ -409,11 +443,11 @@ dissect_yami_data(tvbuff_t *tvb, gboolean data, proto_tree *tree, int offset) guint32 count; guint i; - ti = proto_tree_add_item(tree, (data) ? hf_yami_message_data : hf_yami_message_hdr, tvb, offset, 0, ENC_NA); + ti = proto_tree_add_item(tree, (data) ? &hfi_yami_message_data : &hfi_yami_message_hdr, tvb, offset, 0, ENC_NA); yami_data_tree = proto_item_add_subtree(ti, (data) ? ett_yami_msg_data : ett_yami_msg_hdr); count = tvb_get_letohl(tvb, offset); - proto_tree_add_item(yami_data_tree, hf_yami_params_count, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(yami_data_tree, &hfi_yami_params_count, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; proto_item_append_text(ti, ", %u parameters: ", count); @@ -446,30 +480,30 @@ dissect_yami_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) col_clear(pinfo->cinfo, COL_INFO); if (tree) { - ti = proto_tree_add_item(tree, proto_yami, tvb, 0, -1, ENC_NA); + ti = proto_tree_add_item_old(tree, proto_yami, tvb, 0, -1, ENC_NA); yami_tree = proto_item_add_subtree(ti, ett_yami); } offset = 0; - proto_tree_add_item(yami_tree, hf_yami_message_id, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(yami_tree, &hfi_yami_message_id, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; frame_number = tvb_get_letohl(tvb, offset); - ti = proto_tree_add_item(yami_tree, hf_yami_frame_number, tvb, offset, 4, ENC_LITTLE_ENDIAN); + ti = proto_tree_add_item(yami_tree, &hfi_yami_frame_number, tvb, offset, 4, ENC_LITTLE_ENDIAN); if(frame_number < 0) proto_item_append_text(ti, "%s", " (last frame)"); offset += 4; message_header_size = tvb_get_letohl(tvb, offset); - proto_tree_add_item(yami_tree, hf_yami_message_header_size, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(yami_tree, &hfi_yami_message_header_size, tvb, offset, 4, ENC_LITTLE_ENDIAN); if (message_header_size < 4) { /* XXX, expert info */ } offset += 4; frame_payload_size = tvb_get_letohl(tvb, offset); - ti = proto_tree_add_item(yami_tree, hf_yami_frame_payload_size, tvb, offset, 4, ENC_LITTLE_ENDIAN); + ti = proto_tree_add_item(yami_tree, &hfi_yami_frame_payload_size, tvb, offset, 4, ENC_LITTLE_ENDIAN); frame_size = frame_payload_size + 16; proto_item_append_text(ti, ", (YAMI Frame Size: %d)", frame_size); offset += 4; @@ -509,60 +543,26 @@ dissect_yami(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_ void proto_register_yami(void) { - static hf_register_info hf[] = { + static header_field_info *hfi[] = { /* Header */ - { &hf_yami_message_id, - { "Message ID", "yami.message_id", FT_INT32, BASE_DEC, NULL, 0x00, NULL, HFILL } - }, - { &hf_yami_frame_number, - { "Frame Number", "yami.frame_number", FT_INT32, BASE_DEC, NULL, 0x00, NULL, HFILL } - }, - { &hf_yami_message_header_size, - { "Message Header Size", "yami.message_header_size", FT_INT32, BASE_DEC, NULL, 0x00, NULL, HFILL } - }, - { &hf_yami_frame_payload_size, - { "Frame Payload Size", "yami.frame_payload_size", FT_INT32, BASE_DEC, NULL, 0x00, NULL, HFILL } - }, - { &hf_yami_message_hdr, - { "Header message", "yami.msg_hdr", FT_NONE, BASE_NONE, NULL, 0x00, NULL, HFILL } - }, - { &hf_yami_message_data, - { "Data message", "yami.msg_data", FT_NONE, BASE_NONE, NULL, 0x00, NULL, HFILL } - }, + &hfi_yami_message_id, + &hfi_yami_frame_number, + &hfi_yami_message_header_size, + &hfi_yami_frame_payload_size, + &hfi_yami_message_hdr, + &hfi_yami_message_data, /* Parameter */ - { &hf_yami_param, - { "Parameter", "yami.param", FT_NONE, BASE_NONE, NULL, 0x00, NULL, HFILL } - }, - { &hf_yami_param_name, - { "Name", "yami.param.name", FT_STRING, BASE_NONE, NULL, 0x00, "Parameter name", HFILL } - }, - { &hf_yami_param_type, - { "Type", "yami.param.type", FT_INT32, BASE_DEC, VALS(yami_param_type_vals), 0x00, "Parameter type", HFILL } - }, - { &hf_yami_param_value_bool, - { "Value", "yami.param.value_bool", FT_BOOLEAN, BASE_NONE, NULL, 0x00, "Parameter value (bool)", HFILL } - }, - { &hf_yami_param_value_int, - { "Value", "yami.param.value_int", FT_INT32, BASE_DEC, NULL, 0x00, "Parameter value (int)", HFILL } - }, - { &hf_yami_param_value_long, - { "Value", "yami.param.value_long", FT_INT64, BASE_DEC, NULL, 0x00, "Parameter value (long)", HFILL } - }, - { &hf_yami_param_value_double, - { "Value", "yami.param.value_double", FT_DOUBLE, BASE_NONE, NULL, 0x00, "Parameter value (double)", HFILL } - }, - { &hf_yami_param_value_str, - { "Value", "yami.param.value_str", FT_STRING, BASE_NONE, NULL, 0x00, "Parameter value (string)", HFILL } - }, - { &hf_yami_param_value_bin, - { "Value", "yami.param.value_bin", FT_BYTES, BASE_NONE, NULL, 0x00, "Parameter value (binary)", HFILL } - }, - { &hf_yami_params_count, - { "Parameters count", "yami.params_count", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL } - }, - { &hf_yami_items_count, - { "Items count", "yami.items_count", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL } - } + &hfi_yami_param, + &hfi_yami_param_name, + &hfi_yami_param_type, + &hfi_yami_param_value_bool, + &hfi_yami_param_value_int, + &hfi_yami_param_value_long, + &hfi_yami_param_value_double, + &hfi_yami_param_value_str, + &hfi_yami_param_value_bin, + &hfi_yami_params_count, + &hfi_yami_items_count, }; static gint *ett[] = { @@ -576,7 +576,7 @@ proto_register_yami(void) proto_yami = proto_register_protocol("YAMI Protocol", "YAMI", "yami"); - proto_register_field_array(proto_yami, hf, array_length(hf)); + proto_register_fields(proto_yami, hfi, array_length(hfi)); proto_register_subtree_array(ett, array_length(ett)); yami_module = prefs_register_protocol(proto_yami, proto_reg_handoff_yami); |