diff options
author | Jakub Zawadzki <darkjames-ws@darkjames.pl> | 2013-08-17 07:16:12 +0000 |
---|---|---|
committer | Jakub Zawadzki <darkjames-ws@darkjames.pl> | 2013-08-17 07:16:12 +0000 |
commit | 4e870dd24078cd7b1631d3d6452a7c32d69f077b (patch) | |
tree | 5520123263fe3394486a9f6f32dd136ce6c6f2a7 /epan/dissectors | |
parent | 68f9abdc8793453468733700bd70560d6973f048 (diff) |
Fix few concept of new api tree:
- (for now) keep ABI, restore prototype of old proto_tree_add_item, add new proto_tree_add_item_new
- add few helpers for boolean, time, string which will do ->id
- don't use HFI_INIT directly, use it by another macro (MSVC has very small limit for section name)
svn path=/trunk/; revision=51401
Diffstat (limited to 'epan/dissectors')
-rw-r--r-- | epan/dissectors/packet-dbus.c | 56 | ||||
-rw-r--r-- | epan/dissectors/packet-gadu-gadu.c | 179 | ||||
-rw-r--r-- | epan/dissectors/packet-json.c | 29 | ||||
-rw-r--r-- | epan/dissectors/packet-nflog.c | 41 | ||||
-rw-r--r-- | epan/dissectors/packet-yami.c | 59 |
5 files changed, 198 insertions, 166 deletions
diff --git a/epan/dissectors/packet-dbus.c b/epan/dissectors/packet-dbus.c index 58f17c4089..621fd6b32d 100644 --- a/epan/dissectors/packet-dbus.c +++ b/epan/dissectors/packet-dbus.c @@ -39,7 +39,8 @@ void proto_reg_handoff_dbus(void); static gboolean dbus_desegment = TRUE; -static int proto_dbus = -1; +static dissector_handle_t dbus_handle; +static dissector_handle_t dbus_handle_tcp; #define DBUS_MESSAGE_TYPE_INVALID 0 #define DBUS_MESSAGE_TYPE_METHOD_CALL 1 @@ -81,60 +82,64 @@ static const value_string field_code_vals[] = { { 0, NULL } }; +static header_field_info *hfi_dbus = NULL; + +#define DBUS_HFI_INIT HFI_INIT(proto_dbus) + /* XXX, FT_NONE -> FT_BYTES? */ /* Header */ -static header_field_info hfi_dbus_hdr HFI_INIT(proto_dbus) = +static header_field_info hfi_dbus_hdr DBUS_HFI_INIT = { "Header", "dbus.header", FT_NONE, BASE_NONE, NULL, 0x00, NULL, HFILL }; -static header_field_info hfi_dbus_hdr_endianness HFI_INIT(proto_dbus) = +static header_field_info hfi_dbus_hdr_endianness DBUS_HFI_INIT = { "Endianness Flag", "dbus.endianness", FT_STRING, BASE_NONE, NULL, 0x00, NULL, HFILL }; -static header_field_info hfi_dbus_hdr_type HFI_INIT(proto_dbus) = +static header_field_info hfi_dbus_hdr_type DBUS_HFI_INIT = { "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) = +static header_field_info hfi_dbus_hdr_flags DBUS_HFI_INIT = { "Message Flags", "dbus.flags", FT_UINT8, BASE_HEX, NULL, 0x00, NULL, HFILL }; -static header_field_info hfi_dbus_hdr_version HFI_INIT(proto_dbus) = +static header_field_info hfi_dbus_hdr_version DBUS_HFI_INIT = { "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) = +static header_field_info hfi_dbus_hdr_body_length DBUS_HFI_INIT = { "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) = +static header_field_info hfi_dbus_hdr_serial DBUS_HFI_INIT = { "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) = +static header_field_info hfi_dbus_hdr_fields_length DBUS_HFI_INIT = { "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) = +static header_field_info hfi_dbus_hdr_field DBUS_HFI_INIT = { "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) = +static header_field_info hfi_dbus_hdr_field_code DBUS_HFI_INIT = { "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) = +static header_field_info hfi_dbus_type_signature DBUS_HFI_INIT = { "Type signature", "dbus.type_signature", FT_STRINGZ, BASE_NONE, NULL, 0x00, NULL, HFILL }; -static header_field_info hfi_dbus_body HFI_INIT(proto_dbus) = +static header_field_info hfi_dbus_body DBUS_HFI_INIT = { "Body", "dbus.body", FT_NONE, BASE_NONE, NULL, 0x00, NULL, HFILL }; /* Values */ -static header_field_info hfi_dbus_value_bool HFI_INIT(proto_dbus) = +static header_field_info hfi_dbus_value_bool DBUS_HFI_INIT = { "Value", "dbus.value.bool", FT_BOOLEAN, BASE_NONE, NULL, 0x00, NULL, HFILL }; -static header_field_info hfi_dbus_value_int HFI_INIT(proto_dbus) = +static header_field_info hfi_dbus_value_int DBUS_HFI_INIT = { "Value", "dbus.value.int", FT_INT32, BASE_DEC, NULL, 0x00, NULL, HFILL }; -static header_field_info hfi_dbus_value_uint HFI_INIT(proto_dbus) = +static header_field_info hfi_dbus_value_uint DBUS_HFI_INIT = { "Value", "dbus.value.uint", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }; -static header_field_info hfi_dbus_value_str HFI_INIT(proto_dbus) = +static header_field_info hfi_dbus_value_str DBUS_HFI_INIT = { "Value", "dbus.value.str", FT_STRING, BASE_NONE, NULL, 0x00, NULL, HFILL }; -static header_field_info hfi_dbus_value_double HFI_INIT(proto_dbus) = +static header_field_info hfi_dbus_value_double DBUS_HFI_INIT = { "Value", "dbus.value.double", FT_DOUBLE, BASE_NONE, NULL, 0x00, NULL, HFILL }; @@ -368,7 +373,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, hfi_dbus_type_signature.id, tvb, org_offset, offset - org_offset, sig); + ti = proto_tree_add_string(tree, &hfi_dbus_type_signature, tvb, org_offset, offset - org_offset, sig); if (!dbus_validate_signature(sig)) { expert_add_info(dinfo->pinfo, ti, &ei_dbus_invalid_signature); return -1; @@ -564,7 +569,7 @@ dissect_dbus(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_ } if (tree) { - proto_item *ti = proto_tree_add_item_old(tree, proto_dbus, tvb, 0, -1, ENC_NA); + proto_item *ti = proto_tree_add_item(tree, hfi_dbus, tvb, 0, -1, ENC_NA); dbus_tree = proto_item_add_subtree(ti, ett_dbus); } @@ -661,22 +666,25 @@ proto_register_dbus(void) { &ei_dbus_invalid_signature, { "dbus.invalid_signature", PI_PROTOCOL, PI_WARN, "Invalid signature", EXPFILL }}, }; - expert_module_t* expert_dbus; + expert_module_t *expert_dbus; + + int proto_dbus; proto_dbus = proto_register_protocol("D-Bus", "D-BUS", "dbus"); + hfi_dbus = proto_registrar_get_nth(proto_dbus); 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)); + + dbus_handle = new_create_dissector_handle(dissect_dbus, proto_dbus); + dbus_handle_tcp = new_create_dissector_handle(dissect_dbus_tcp, proto_dbus); } void proto_reg_handoff_dbus(void) { - dissector_handle_t dbus_handle = new_create_dissector_handle(dissect_dbus, proto_dbus); - dissector_handle_t dbus_handle_tcp = new_create_dissector_handle(dissect_dbus_tcp, proto_dbus); - dissector_add_uint("wtap_encap", WTAP_ENCAP_DBUS, dbus_handle); dissector_add_handle("tcp.port", dbus_handle_tcp); } diff --git a/epan/dissectors/packet-gadu-gadu.c b/epan/dissectors/packet-gadu-gadu.c index 2e58395909..bf34ebfde5 100644 --- a/epan/dissectors/packet-gadu-gadu.c +++ b/epan/dissectors/packet-gadu-gadu.c @@ -41,7 +41,7 @@ /* desegmentation of Gadu-Gadu over TCP */ static gboolean gadu_gadu_desegment = TRUE; -static int proto_gadu_gadu = -1; +static dissector_handle_t gadu_gadu_handle; static int ett_gadu_gadu = -1; static int ett_gadu_gadu_contact = -1; @@ -335,197 +335,201 @@ static const value_string gadu_gadu_pubdir_type_vals[] = { { 0, NULL } }; +static header_field_info *hfi_gadu_gadu = NULL; + +#define GADU_GADU_HFI_INIT HFI_INIT(proto_gadu_gadu) + /* Header */ -static header_field_info hfi_gadu_gadu_header_type_recv HFI_INIT(proto_gadu_gadu) = +static header_field_info hfi_gadu_gadu_header_type_recv GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_gadu_gadu_header_type_send GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_gadu_gadu_header_length GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_gadu_gadu_login_uin GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_gadu_gadu_login_hash_type GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_gadu_gadu_login_hash GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_gadu_gadu_login_status GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_gadu_gadu_login_protocol GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_gadu_gadu_login_version GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_gadu_gadu_login_local_ip GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_gadu_gadu_login_local_port GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_gadu_gadu_login80_lang GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_gadu_gadu_userdata_uin GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_gadu_gadu_userdata_attr_name GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_gadu_gadu_userdata_attr_type GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_gadu_gadu_userdata_attr_value GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_gadu_gadu_typing_notify_type GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_gadu_gadu_typing_notify_uin GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_gadu_gadu_msg_uin GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_gadu_gadu_msg_sender GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_gadu_gadu_msg_recipient GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_gadu_gadu_msg_seq GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_gadu_gadu_msg_time GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_gadu_gadu_msg_class GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_gadu_gadu_msg_text GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_gadu_gadu_msg80_offset_plain GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_gadu_gadu_msg80_offset_attr GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_gadu_gadu_msg_ack_status GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_gadu_gadu_msg_ack_recipient GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_gadu_gadu_msg_ack_seq GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_gadu_gadu_status_uin GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_gadu_gadu_status_status GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_gadu_gadu_status_ip GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_gadu_gadu_status_port GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_gadu_gadu_status_version GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_gadu_gadu_status_img_size GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_gadu_gadu_status_descr GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_dcc_type GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_dcc_id GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_dcc_uin_to GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_dcc_uin_from GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_dcc_filename GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_gadu_gadu_new_status_status GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_gadu_gadu_new_status_desc GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_gadu_gadu_userlist_request_type GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_gadu_gadu_userlist_version GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_gadu_gadu_userlist_format GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_gadu_gadu_userlist_reply_type GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_gadu_gadu_pubdir_request_type GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_gadu_gadu_pubdir_request_seq GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_gadu_gadu_pubdir_request_str GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_gadu_gadu_pubdir_reply_type GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_gadu_gadu_pubdir_reply_seq GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_gadu_gadu_pubdir_reply_str GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_gadu_gadu_contact_uin GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_gadu_gadu_contact_uin_str GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_gadu_gadu_contact_type GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_gadu_gadu_welcome_seed GADU_GADU_HFI_INIT = { "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) = +static header_field_info hfi_gadu_gadu_data GADU_GADU_HFI_INIT = { "Packet Data", "gadu-gadu.data", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }; @@ -542,12 +546,12 @@ gadu_gadu_create_conversation(packet_info *pinfo, guint32 uin) struct gadu_gadu_conv_data *gg_conv; conv = find_or_create_conversation(pinfo); - gg_conv = (struct gadu_gadu_conv_data *)conversation_get_proto_data(conv, proto_gadu_gadu); + gg_conv = (struct gadu_gadu_conv_data *)conversation_get_proto_data(conv, hfi_gadu_gadu->id); if (!gg_conv) { gg_conv = se_new(struct gadu_gadu_conv_data); gg_conv->uin = uin; - conversation_add_proto_data(conv, proto_gadu_gadu, gg_conv); + conversation_add_proto_data(conv, hfi_gadu_gadu->id, gg_conv); } /* assert(gg_conv->uin == uin); */ return gg_conv; @@ -560,7 +564,7 @@ gadu_gadu_get_conversation_data(packet_info *pinfo) conv = find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst, pinfo->ptype, pinfo->srcport, pinfo->destport, 0); if (conv) - return (struct gadu_gadu_conv_data *)conversation_get_proto_data(conv, proto_gadu_gadu); + return (struct gadu_gadu_conv_data *)conversation_get_proto_data(conv, hfi_gadu_gadu->id); return NULL; } @@ -697,7 +701,7 @@ dissect_gadu_gadu_login_protocol(tvbuff_t *tvb, proto_tree *tree, int offset) protocol = tvb_get_letohl(tvb, offset) & 0xff; 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)")); + ti = proto_tree_add_string(tree, &hfi_gadu_gadu_login_version, tvb, offset, 4, val_to_str(protocol, gadu_gadu_version_vals, "Unknown (0x%x)")); PROTO_ITEM_SET_GENERATED(ti); offset += 4; @@ -717,10 +721,10 @@ 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, hfi_gadu_gadu_login_uin.id, tvb, offset, 4, uin); + proto_tree_add_uint(tree, &hfi_gadu_gadu_login_uin, tvb, offset, 4, uin); offset += 4; - ti = proto_tree_add_uint(tree, hfi_gadu_gadu_login_hash_type.id, tvb, 0, 0, GG_LOGIN_HASH_GG32); + ti = proto_tree_add_uint(tree, &hfi_gadu_gadu_login_hash_type, tvb, 0, 0, GG_LOGIN_HASH_GG32); PROTO_ITEM_SET_GENERATED(ti); /* hash is 32-bit number written in LE */ @@ -796,7 +800,7 @@ 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, hfi_gadu_gadu_login_uin.id, tvb, offset, 4, uin); + proto_tree_add_uint(tree, &hfi_gadu_gadu_login_uin, tvb, offset, 4, uin); offset += 4; offset = dissect_gadu_gadu_login_hash(tvb, tree, offset); @@ -919,7 +923,7 @@ 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, hfi_gadu_gadu_userdata_attr_name.id, tvb, offset - 4, 4 + name_size, name); + proto_tree_add_string(tree, &hfi_gadu_gadu_userdata_attr_name, tvb, offset - 4, 4 + name_size, name); offset += name_size; /* type */ proto_tree_add_item(tree, &hfi_gadu_gadu_userdata_attr_type, tvb, offset, 4, ENC_LITTLE_ENDIAN); @@ -929,7 +933,7 @@ dissect_gadu_gadu_user_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, offset += 4; val = tvb_get_ephemeral_string_enc(tvb, offset, val_size, ENC_ASCII | ENC_NA); - proto_tree_add_string(tree, hfi_gadu_gadu_userdata_attr_value.id, tvb, offset - 4, 4 + val_size, val); + proto_tree_add_string(tree, &hfi_gadu_gadu_userdata_attr_value, tvb, offset - 4, 4 + val_size, val); offset += val_size; } } @@ -969,10 +973,10 @@ 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, hfi_gadu_gadu_msg_recipient.id, tvb, 0, 0, conv->uin); + ti = proto_tree_add_uint(tree, &hfi_gadu_gadu_msg_recipient, tvb, 0, 0, conv->uin); PROTO_ITEM_SET_GENERATED(ti); - ti = proto_tree_add_uint(tree, hfi_gadu_gadu_msg_uin.id, tvb, 0, 0, conv->uin); + ti = proto_tree_add_uint(tree, &hfi_gadu_gadu_msg_uin, tvb, 0, 0, conv->uin); PROTO_ITEM_SET_GENERATED(ti); PROTO_ITEM_SET_HIDDEN(ti); } @@ -1012,10 +1016,10 @@ dissect_gadu_gadu_send_msg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, offset += 4; if ((conv = gadu_gadu_get_conversation_data(pinfo))) { - ti = proto_tree_add_uint(tree, hfi_gadu_gadu_msg_sender.id, tvb, 0, 0, conv->uin); + ti = proto_tree_add_uint(tree, &hfi_gadu_gadu_msg_sender, tvb, 0, 0, conv->uin); PROTO_ITEM_SET_GENERATED(ti); - ti = proto_tree_add_uint(tree, hfi_gadu_gadu_msg_uin.id, tvb, 0, 0, conv->uin); + ti = proto_tree_add_uint(tree, &hfi_gadu_gadu_msg_uin, tvb, 0, 0, conv->uin); PROTO_ITEM_SET_GENERATED(ti); PROTO_ITEM_SET_HIDDEN(ti); } @@ -1023,7 +1027,7 @@ dissect_gadu_gadu_send_msg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_tree_add_item(tree, &hfi_gadu_gadu_msg_seq, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; - ti = proto_tree_add_time(tree, hfi_gadu_gadu_msg_time.id, tvb, 0, 0, &(pinfo->fd->abs_ts)); + ti = proto_tree_add_time(tree, &hfi_gadu_gadu_msg_time, tvb, 0, 0, &(pinfo->fd->abs_ts)); PROTO_ITEM_SET_GENERATED(ti); proto_tree_add_item(tree, &hfi_gadu_gadu_msg_class, tvb, offset, 4, ENC_LITTLE_ENDIAN); @@ -1045,10 +1049,10 @@ 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, hfi_gadu_gadu_msg_recipient.id, tvb, 0, 0, conv->uin); + ti = proto_tree_add_uint(tree, &hfi_gadu_gadu_msg_recipient, tvb, 0, 0, conv->uin); PROTO_ITEM_SET_GENERATED(ti); - ti = proto_tree_add_uint(tree, hfi_gadu_gadu_msg_uin.id, tvb, 0, 0, conv->uin); + ti = proto_tree_add_uint(tree, &hfi_gadu_gadu_msg_uin, tvb, 0, 0, conv->uin); PROTO_ITEM_SET_GENERATED(ti); PROTO_ITEM_SET_HIDDEN(ti); } @@ -1092,10 +1096,10 @@ dissect_gadu_gadu_send_msg80(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree offset += 4; if ((conv = gadu_gadu_get_conversation_data(pinfo))) { - ti = proto_tree_add_uint(tree, hfi_gadu_gadu_msg_sender.id, tvb, 0, 0, conv->uin); + ti = proto_tree_add_uint(tree, &hfi_gadu_gadu_msg_sender, tvb, 0, 0, conv->uin); PROTO_ITEM_SET_GENERATED(ti); - ti = proto_tree_add_uint(tree, hfi_gadu_gadu_msg_uin.id, tvb, 0, 0, conv->uin); + ti = proto_tree_add_uint(tree, &hfi_gadu_gadu_msg_uin, tvb, 0, 0, conv->uin); PROTO_ITEM_SET_GENERATED(ti); PROTO_ITEM_SET_HIDDEN(ti); } @@ -1103,7 +1107,7 @@ dissect_gadu_gadu_send_msg80(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree proto_tree_add_item(tree, &hfi_gadu_gadu_msg_seq, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; - ti = proto_tree_add_time(tree, hfi_gadu_gadu_msg_time.id, tvb, 0, 0, &(pinfo->fd->abs_ts)); + ti = proto_tree_add_time(tree, &hfi_gadu_gadu_msg_time, tvb, 0, 0, &(pinfo->fd->abs_ts)); PROTO_ITEM_SET_GENERATED(ti); proto_tree_add_item(tree, &hfi_gadu_gadu_msg_class, tvb, offset, 4, ENC_LITTLE_ENDIAN); @@ -1157,7 +1161,7 @@ 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, hfi_gadu_gadu_status_uin.id, tvb, offset, 4, uin); + proto_tree_add_uint(tree, &hfi_gadu_gadu_status_uin, tvb, offset, 4, uin); offset += 4; status = tvb_get_guint8(tvb, offset); @@ -1194,7 +1198,7 @@ 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, hfi_gadu_gadu_status_uin.id, tvb, offset, 4, uin); + proto_tree_add_uint(tree, &hfi_gadu_gadu_status_uin, tvb, offset, 4, uin); offset += 4; status = tvb_get_guint8(tvb, offset); @@ -1338,7 +1342,7 @@ dissect_gadu_gadu_notify105_common(tvbuff_t *tvb, proto_tree *tree, int offset, 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, hfi_gadu_gadu_contact_uin_str.id, tvb, offset - 1, 1 + uin_len, uin); + proto_tree_add_string(tree, &hfi_gadu_gadu_contact_uin_str, tvb, offset - 1, 1 + uin_len, uin); offset += uin_len; if (puin) *puin = uin; @@ -1499,7 +1503,7 @@ dissect_gadu_gadu_userlist_request80(tvbuff_t *tvb, packet_info *pinfo, proto_tr 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, hfi_gadu_gadu_userlist_format.id, tvb, 0, 0, GG_USERLIST100_FORMAT_TYPE_GG100); + ti = proto_tree_add_uint(tree, &hfi_gadu_gadu_userlist_format, tvb, 0, 0, GG_USERLIST100_FORMAT_TYPE_GG100); PROTO_ITEM_SET_GENERATED(ti); switch (type) { @@ -1742,7 +1746,7 @@ 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_old(tree, proto_gadu_gadu, tvb, 0, -1, ENC_NA); + proto_item *ti = proto_tree_add_item(tree, hfi_gadu_gadu, tvb, 0, -1, ENC_NA); gadu_gadu_tree = proto_item_add_subtree(ti, ett_gadu_gadu); } @@ -2117,7 +2121,10 @@ proto_register_gadu_gadu(void) module_t *gadu_gadu_module; + int proto_gadu_gadu; + proto_gadu_gadu = proto_register_protocol("Gadu-Gadu Protocol", "Gadu-Gadu", "gadu-gadu"); + hfi_gadu_gadu = proto_registrar_get_nth(proto_gadu_gadu); gadu_gadu_module = prefs_register_protocol(proto_gadu_gadu, NULL); prefs_register_bool_preference(gadu_gadu_module, "desegment", @@ -2128,13 +2135,13 @@ proto_register_gadu_gadu(void) proto_register_fields(proto_gadu_gadu, hfi, array_length(hfi)); proto_register_subtree_array(ett, array_length(ett)); + + gadu_gadu_handle = new_create_dissector_handle(dissect_gadu_gadu, proto_gadu_gadu); } void proto_reg_handoff_gadu_gadu(void) { - dissector_handle_t gadu_gadu_handle = new_create_dissector_handle(dissect_gadu_gadu, proto_gadu_gadu); - dissector_add_uint("tcp.port", TCP_PORT_GADU_GADU, gadu_gadu_handle); xml_handle = find_dissector("xml"); diff --git a/epan/dissectors/packet-json.c b/epan/dissectors/packet-json.c index fe72b24ce3..a31d9c30be 100644 --- a/epan/dissectors/packet-json.c +++ b/epan/dissectors/packet-json.c @@ -37,41 +37,43 @@ #include <epan/packet.h> #include <epan/tvbparse.h> -static gint proto_json = -1; - static gint ett_json = -1; static gint ett_json_array = -1; static gint ett_json_object = -1; static gint ett_json_member = -1; -static header_field_info hfi_json_array HFI_INIT(proto_json) = +static header_field_info *hfi_json = NULL; + +#define JSON_HFI_INIT HFI_INIT(proto_json) + +static header_field_info hfi_json_array JSON_HFI_INIT = { "Array", "json.array", FT_NONE, BASE_NONE, NULL, 0x00, "JSON array", HFILL }; -static header_field_info hfi_json_object HFI_INIT(proto_json) = +static header_field_info hfi_json_object JSON_HFI_INIT = { "Object", "json.object", FT_NONE, BASE_NONE, NULL, 0x00, "JSON object", HFILL }; -static header_field_info hfi_json_member HFI_INIT(proto_json) = +static header_field_info hfi_json_member JSON_HFI_INIT = { "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) = +static header_field_info hfi_json_member_key JSON_HFI_INIT = { "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? */ +static header_field_info hfi_json_value_string JSON_HFI_INIT = /* 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? */ +static header_field_info hfi_json_value_number JSON_HFI_INIT = /* 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) = +static header_field_info hfi_json_value_false JSON_HFI_INIT = { "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) = +static header_field_info hfi_json_value_null JSON_HFI_INIT = { "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) = +static header_field_info hfi_json_value_true JSON_HFI_INIT = { "True value", "json.value.true", FT_NONE, BASE_NONE, NULL, 0x00, "JSON true value", HFILL }; @@ -126,7 +128,7 @@ dissect_json(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) } if (tree) { - ti = proto_tree_add_item_old(tree, proto_json, tvb, 0, -1, ENC_NA); + ti = proto_tree_add_item(tree, hfi_json, tvb, 0, -1, ENC_NA); json_tree = proto_item_add_subtree(ti, ett_json); if (data_name) @@ -568,7 +570,10 @@ proto_register_json(void) { &hfi_json_value_true, }; + int proto_json; + proto_json = proto_register_protocol("JavaScript Object Notation", "JSON", "json"); + hfi_json = proto_registrar_get_nth(proto_json); proto_register_fields(proto_json, hfi, array_length(hfi)); proto_register_subtree_array(ett, array_length(ett)); diff --git a/epan/dissectors/packet-nflog.c b/epan/dissectors/packet-nflog.c index 19864cadf9..3f1fe286ab 100644 --- a/epan/dissectors/packet-nflog.c +++ b/epan/dissectors/packet-nflog.c @@ -104,48 +104,50 @@ static const value_string nflog_tlv_vals[] = { 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 header_field_info *hfi_nflog = NULL; + +#define NFLOG_HFI_INIT HFI_INIT(proto_nflog) + /* Header */ -static header_field_info hfi_nflog_family HFI_INIT(proto_nflog) = +static header_field_info hfi_nflog_family NFLOG_HFI_INIT = { "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) = +static header_field_info hfi_nflog_version NFLOG_HFI_INIT = { "Version", "nflog.version", FT_UINT8, BASE_DEC, NULL, 0x00, NULL, HFILL }; -static header_field_info hfi_nflog_resid HFI_INIT(proto_nflog) = +static header_field_info hfi_nflog_resid NFLOG_HFI_INIT = { "Resource id", "nflog.res_id", FT_UINT16, BASE_DEC, NULL, 0x00, NULL, HFILL }; -static header_field_info hfi_nflog_encoding HFI_INIT(proto_nflog) = +static header_field_info hfi_nflog_encoding NFLOG_HFI_INIT = { "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) = +static header_field_info hfi_nflog_tlv NFLOG_HFI_INIT = { "TLV", "nflog.tlv", FT_BYTES, BASE_NONE, NULL, 0x00, NULL, HFILL }; -static header_field_info hfi_nflog_tlv_length HFI_INIT(proto_nflog) = +static header_field_info hfi_nflog_tlv_length NFLOG_HFI_INIT = { "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) = +static header_field_info hfi_nflog_tlv_type NFLOG_HFI_INIT = { "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) = +static header_field_info hfi_nflog_tlv_prefix NFLOG_HFI_INIT = { "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) = +static header_field_info hfi_nflog_tlv_uid NFLOG_HFI_INIT = { "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) = +static header_field_info hfi_nflog_tlv_gid NFLOG_HFI_INIT = { "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) = +static header_field_info hfi_nflog_tlv_timestamp NFLOG_HFI_INIT = { "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) = +static header_field_info hfi_nflog_tlv_unknown NFLOG_HFI_INIT = { "Value", "nflog.tlv_value", FT_BYTES, BASE_NONE, NULL, 0x00, "TLV Value", HFILL }; static dissector_handle_t ip_handle; @@ -234,8 +236,8 @@ 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_old(tree, proto_nflog, tvb, 0, -1, ENC_NA); + if (proto_field_is_referenced(tree, hfi_nflog->id)) { + ti = proto_tree_add_item(tree, hfi_nflog, tvb, 0, -1, ENC_NA); nflog_tree = proto_item_add_subtree(ti, ett_nflog); proto_tree_add_item(nflog_tree, &hfi_nflog_family, tvb, offset, 1, ENC_NA); @@ -247,7 +249,7 @@ dissect_nflog(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_tree_add_item(nflog_tree, &hfi_nflog_resid, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; - ti = proto_tree_add_uint(nflog_tree, hfi_nflog_encoding.id, + ti = proto_tree_add_uint(nflog_tree, &hfi_nflog_encoding, tvb, offset, tvb_length_remaining(tvb, offset), enc); PROTO_ITEM_SET_GENERATED(ti); } @@ -316,7 +318,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, hfi_nflog_tlv_timestamp.id, + proto_tree_add_time(tlv_tree, &hfi_nflog_tlv_timestamp, tvb, offset + 4, value_len, &ts); handled = TRUE; } @@ -377,7 +379,10 @@ proto_register_nflog(void) module_t *pref; + int proto_nflog; + proto_nflog = proto_register_protocol("Linux Netfilter NFLOG", "NFLOG", "nflog"); + hfi_nflog = proto_registrar_get_nth(proto_nflog); pref = prefs_register_protocol(proto_nflog, NULL); prefs_register_enum_preference(pref, "byte_order_type", "Byte Order", "Byte Order", diff --git a/epan/dissectors/packet-yami.c b/epan/dissectors/packet-yami.c index c61dbc423d..347381fdb0 100644 --- a/epan/dissectors/packet-yami.c +++ b/epan/dissectors/packet-yami.c @@ -42,7 +42,7 @@ static gboolean yami_desegment = TRUE; static guint global_yami_config_tcp_port = 0; static guint global_yami_config_udp_port = 0; -static int proto_yami = -1; +static dissector_handle_t yami_handle; #define YAMI_TYPE_BOOLEAN 1 #define YAMI_TYPE_INTEGER 2 @@ -75,57 +75,61 @@ static const value_string yami_param_type_vals[] = { { 0, NULL } }; +static header_field_info *hfi_yami = NULL; + +#define YAMI_HFI_INIT HFI_INIT(proto_yami) + /* Header */ -static header_field_info hfi_yami_message_id HFI_INIT(proto_yami) = +static header_field_info hfi_yami_message_id YAMI_HFI_INIT = { "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) = +static header_field_info hfi_yami_frame_number YAMI_HFI_INIT = { "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) = +static header_field_info hfi_yami_message_header_size YAMI_HFI_INIT = { "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) = +static header_field_info hfi_yami_frame_payload_size YAMI_HFI_INIT = { "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) = +static header_field_info hfi_yami_message_hdr YAMI_HFI_INIT = { "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) = +static header_field_info hfi_yami_message_data YAMI_HFI_INIT = { "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) = +static header_field_info hfi_yami_param YAMI_HFI_INIT = { "Parameter", "yami.param", FT_NONE, BASE_NONE, NULL, 0x00, NULL, HFILL }; -static header_field_info hfi_yami_param_name HFI_INIT(proto_yami) = +static header_field_info hfi_yami_param_name YAMI_HFI_INIT = { "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) = +static header_field_info hfi_yami_param_type YAMI_HFI_INIT = { "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) = +static header_field_info hfi_yami_param_value_bool YAMI_HFI_INIT = { "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) = +static header_field_info hfi_yami_param_value_int YAMI_HFI_INIT = { "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) = +static header_field_info hfi_yami_param_value_long YAMI_HFI_INIT = { "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) = +static header_field_info hfi_yami_param_value_double YAMI_HFI_INIT = { "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) = +static header_field_info hfi_yami_param_value_str YAMI_HFI_INIT = { "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) = +static header_field_info hfi_yami_param_value_bin YAMI_HFI_INIT = { "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) = +static header_field_info hfi_yami_params_count YAMI_HFI_INIT = { "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) = +static header_field_info hfi_yami_items_count YAMI_HFI_INIT = { "Items count", "yami.items_count", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }; static int ett_yami = -1; @@ -158,7 +162,7 @@ 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, hfi_yami_param_name.id, tvb, name_offset, offset - name_offset, name); + proto_tree_add_string(yami_param, &hfi_yami_param_name, tvb, name_offset, offset - name_offset, name); type = tvb_get_letohl(tvb, offset); proto_tree_add_item(yami_param, &hfi_yami_param_type, tvb, offset, 4, ENC_LITTLE_ENDIAN); @@ -214,7 +218,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, hfi_yami_param_value_str.id, tvb, val_offset, offset - val_offset, val); + proto_tree_add_string(yami_param, &hfi_yami_param_value_str, tvb, val_offset, offset - val_offset, val); break; } @@ -256,7 +260,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, hfi_yami_param_value_bool.id, tvb, offset+(j/8), 1, r); + proto_tree_add_boolean(yami_param, &hfi_yami_param_value_bool, tvb, offset+(j/8), 1, r); } offset += 4; } @@ -269,7 +273,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, hfi_yami_param_value_bool.id, tvb, offset+(j/8), 1, r); + proto_tree_add_boolean(yami_param, &hfi_yami_param_value_bool, tvb, offset+(j/8), 1, r); } offset += 4; } @@ -365,7 +369,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, hfi_yami_param_value_str.id, tvb, val_offset, offset - val_offset, val); + proto_tree_add_string(yami_param, &hfi_yami_param_value_str, tvb, val_offset, offset - val_offset, val); offset += (val_len + 3) & ~3; } proto_item_append_text(ti, "}"); @@ -480,7 +484,7 @@ 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_old(tree, proto_yami, tvb, 0, -1, ENC_NA); + ti = proto_tree_add_item(tree, hfi_yami, tvb, 0, -1, ENC_NA); yami_tree = proto_item_add_subtree(ti, ett_yami); } @@ -574,7 +578,10 @@ proto_register_yami(void) module_t *yami_module; + int proto_yami; + proto_yami = proto_register_protocol("YAMI Protocol", "YAMI", "yami"); + hfi_yami = proto_registrar_get_nth(proto_yami); proto_register_fields(proto_yami, hfi, array_length(hfi)); proto_register_subtree_array(ett, array_length(ett)); @@ -587,17 +594,17 @@ proto_register_yami(void) "Whether the YAMI dissector should reassemble messages spanning multiple TCP segments." "To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.", &yami_desegment); + + yami_handle = new_create_dissector_handle(dissect_yami, proto_yami); } void proto_reg_handoff_yami(void) { static int yami_prefs_initialized = FALSE; - static dissector_handle_t yami_handle = NULL; static guint yami_tcp_port, yami_udp_port; if(yami_prefs_initialized == FALSE){ - yami_handle = new_create_dissector_handle(dissect_yami, proto_yami); yami_prefs_initialized = TRUE; yami_tcp_port = global_yami_config_tcp_port; yami_udp_port = global_yami_config_udp_port; |