diff options
author | Gerald Combs <gerald@wireshark.org> | 2006-07-07 00:45:54 +0000 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2006-07-07 00:45:54 +0000 |
commit | 7976c442db7d58ee9be01679597952074f5c5b46 (patch) | |
tree | 7510059331b05daa1e1a8109aa7e8f686aef3949 /epan/dissectors | |
parent | 1f4873db0be82e0e119204532ee40be433cdc805 (diff) |
Fix a few format string bugs found by Ilja van Sprundel.
svn path=/trunk/; revision=18677
Diffstat (limited to 'epan/dissectors')
-rw-r--r-- | epan/dissectors/packet-ansi_map.c | 24 | ||||
-rw-r--r-- | epan/dissectors/packet-fw1.c | 14 | ||||
-rw-r--r-- | epan/dissectors/packet-mq.c | 354 | ||||
-rw-r--r-- | epan/dissectors/packet-xml.c | 376 |
4 files changed, 384 insertions, 384 deletions
diff --git a/epan/dissectors/packet-ansi_map.c b/epan/dissectors/packet-ansi_map.c index de87778671..a0d8b83850 100644 --- a/epan/dissectors/packet-ansi_map.c +++ b/epan/dissectors/packet-ansi_map.c @@ -12703,7 +12703,7 @@ dissect_ansi_param(ASN1_SCK *asn1, proto_tree *tree) if (ansi_map_add_string[0] != '\0') { - proto_item_append_text(item, ansi_map_add_string); + proto_item_append_text(item, "%s", ansi_map_add_string); } } } @@ -12766,7 +12766,7 @@ dissect_ansi_params(ASN1_SCK *asn1, proto_tree *tree) if (ansi_map_add_string[0] != '\0') { - proto_item_append_text(item, ansi_map_add_string); + proto_item_append_text(item, "%s", ansi_map_add_string); } } @@ -13033,23 +13033,23 @@ dissect_ansi_map(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) add_itu_tcap_subdissector(ssn , ansi_map_handle); } } - - - + + + static void range_add_callback(guint32 ssn) { if (ssn) { add_ansi_tcap_subdissector(ssn , ansi_map_handle); } } - - + + void proto_reg_handoff_ansi_map(void) { static int ansi_map_prefs_initialized = FALSE; data_handle = find_dissector("data"); - + if(!ansi_map_prefs_initialized) { ansi_map_prefs_initialized = TRUE; @@ -13059,13 +13059,13 @@ dissect_ansi_map(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { range_foreach(ssn_range, range_delete_callback); } - + g_free(ssn_range); ssn_range = range_copy(global_ssn_range); - + range_foreach(ssn_range, range_add_callback); } - + /* Register the protocol with Wireshark */ @@ -13198,7 +13198,7 @@ proto_register_ansi_map(void) ansi_map_module = prefs_register_protocol(proto_ansi_map, proto_reg_handoff_ansi_map); - + prefs_register_range_preference(ansi_map_module, "map.ssn", "GSM MAP SSNs", "GSM MAP SSNs to decode as ANSI MAP", &global_ssn_range, MAX_SSN); diff --git a/epan/dissectors/packet-fw1.c b/epan/dissectors/packet-fw1.c index b14e1847bc..d7f1fe5569 100644 --- a/epan/dissectors/packet-fw1.c +++ b/epan/dissectors/packet-fw1.c @@ -63,7 +63,7 @@ * 11.8.2003 * Additional interpretation of field Chain Position. * Show the chain position in the interface list. - * Support for new format of fw monitor file + * Support for new format of fw monitor file * writen by option -u | -s for UUID/SUUID. * NOTICE: First paket will have UUID == 0 ! * @@ -139,7 +139,7 @@ dissect_fw1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) char *interface_name; guint32 iface_len = 10; guint16 etype; - char *header; + char *header; char *p_header; int i; gboolean found; @@ -168,7 +168,7 @@ dissect_fw1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) if (fw1_with_uuid) iface_len = 6; - + interface_name=ep_alloc(iface_len+1); tvb_get_nstringz0(tvb, 2, iface_len, interface_name); @@ -207,9 +207,9 @@ dissect_fw1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) if (tree) { if (!fw1_summary_in_tree) /* Do not show the summary in Protocol Tree */ - ti = proto_tree_add_protocol_format(tree, proto_fw1, tvb, 0, ETH_HEADER_SIZE, fw1_header); + ti = proto_tree_add_protocol_format(tree, proto_fw1, tvb, 0, ETH_HEADER_SIZE, "%s", fw1_header); else - ti = proto_tree_add_protocol_format(tree, proto_fw1, tvb, 0, ETH_HEADER_SIZE, header); + ti = proto_tree_add_protocol_format(tree, proto_fw1, tvb, 0, ETH_HEADER_SIZE, "%s", header); /* create display subtree for the protocol */ fh_tree = proto_item_add_subtree(ti, ett_fw1); @@ -220,8 +220,8 @@ dissect_fw1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_tree_add_item(fh_tree, hf_fw1_chain, tvb, 1, 1, FALSE); proto_tree_add_string_format(fh_tree, hf_fw1_interface, tvb, 2, iface_len, "Interface: %s", interface_name); - - if (fw1_with_uuid) + + if (fw1_with_uuid) proto_tree_add_item(fh_tree, hf_fw1_uuid, tvb, 8, 4, FALSE); } diff --git a/epan/dissectors/packet-mq.c b/epan/dissectors/packet-mq.c index d0b3d2660c..87f996e937 100644 --- a/epan/dissectors/packet-mq.c +++ b/epan/dissectors/packet-mq.c @@ -31,15 +31,15 @@ * MQ can be transported on top of TCP, UDP, HTTP, NetBIOS, SPX, SNA LU 6.2, DECnet. * MQ has language bindings for C, C++, Java, .NET, COBOL, PL/I, OS/390 assembler, TAL, Visual Basic. * -* The basic MQ topology is on one side the queue manager which hosts the queues. On the other side the +* The basic MQ topology is on one side the queue manager which hosts the queues. On the other side the * applications connect to the queue manager, open a queue, and put or get messages to/from that queue. * -* The MQ middleware allows very generic operations (send, receive) and can be compared to the +* The MQ middleware allows very generic operations (send, receive) and can be compared to the * socket API in terms of genericity, but it is more abstract and offers higher-level functionalities * (eg transactions, ...) * * The MQ middleware is not really intended to be run over public networks between parties -* that do not know each other in advance, but is rather used on private corporate networks +* that do not know each other in advance, but is rather used on private corporate networks * between business applications (it can be compared to a database server for that aspect). * * The wire format of an MQ segment is a sequence of structures. Most structures start with a 4-letter struct identifier. @@ -57,7 +57,7 @@ * TSH [ XA ] [ XINFO | XID ] * where PAYLOAD = [ DH ] [ DLH ] [ MDE ] BUFF * -* This dissector is a beta version. To be improved +* This dissector is a beta version. To be improved * - Translate the integers/flags into their descriptions * - Find the semantics of the unknown fields * - Display EBCDIC strings as ASCII @@ -403,18 +403,18 @@ static GHashTable *mq_reassembled_table = NULL; #define MQ_STRUCTID_DH_EBCDIC 0xC4C84040 #define MQ_STRUCTID_DLH_EBCDIC 0xC4D3C840 #define MQ_STRUCTID_GMO_EBCDIC 0xC7D4D640 -#define MQ_STRUCTID_ID_EBCDIC 0xC9C44040 -#define MQ_STRUCTID_IIH_EBCDIC 0xC9C9C840 +#define MQ_STRUCTID_ID_EBCDIC 0xC9C44040 +#define MQ_STRUCTID_IIH_EBCDIC 0xC9C9C840 #define MQ_STRUCTID_MD_EBCDIC 0xD4C44040 #define MQ_STRUCTID_MDE_EBCDIC 0xD4C4C540 -#define MQ_STRUCTID_MSH_EBCDIC 0xD4E2C840 +#define MQ_STRUCTID_MSH_EBCDIC 0xD4E2C840 #define MQ_STRUCTID_OD_EBCDIC 0xD6C44040 #define MQ_STRUCTID_PMO_EBCDIC 0xD7D4D640 #define MQ_STRUCTID_RFH_EBCDIC 0xD9C6C840 #define MQ_STRUCTID_RMH_EBCDIC 0xD9D4C840 #define MQ_STRUCTID_TM_EBCDIC 0xE3D44040 #define MQ_STRUCTID_TMC2_EBCDIC 0xE3D4C3F2 -#define MQ_STRUCTID_TSH_EBCDIC 0xE3E2C840 +#define MQ_STRUCTID_TSH_EBCDIC 0xE3E2C840 #define MQ_STRUCTID_UID_EBCDIC 0xE4C9C440 #define MQ_STRUCTID_WIH_EBCDIC 0xE6C9C840 #define MQ_STRUCTID_XQH_EBCDIC 0xE7D8C840 @@ -541,20 +541,20 @@ static GHashTable *mq_reassembled_table = NULL; #define MQ_CONN_VERSION 0x01 #define MQ_CONNX_VERSION 0x03 -#define MQ_STATUS_E_REMOTE_CHANNEL_NOT_FOUND 0x01 -#define MQ_STATUS_E_BAD_REMOTE_CHANNEL_TYPE 0x02 -#define MQ_STATUS_E_REMOTE_QM_UNAVAILABLE 0x03 -#define MQ_STATUS_E_MSG_SEQUENCE_ERROR 0x04 -#define MQ_STATUS_E_REMOTE_QM_TERMINATING 0x05 -#define MQ_STATUS_E_MSG_NOT_RECEIVED 0x06 -#define MQ_STATUS_I_CHANNEL_CLOSED 0x07 -#define MQ_STATUS_I_DISCINTERVAL_EXPIRED 0x08 -#define MQ_STATUS_E_REMOTE_PROTOCOL_ERROR 0x0A -#define MQ_STATUS_E_BIND_FAILED 0x14 -#define MQ_STATUS_E_MSGWRAP_DIFFERENT 0x15 -#define MQ_STATUS_E_REMOTE_CHANNEL_UNAVAILABLE 0x16 -#define MQ_STATUS_E_TERMINATED_BY_REMOTE_EXIT 0x17 -#define MQ_STATUS_E_SSL_REMOTE_BAD_CIPHER 0x18 +#define MQ_STATUS_E_REMOTE_CHANNEL_NOT_FOUND 0x01 +#define MQ_STATUS_E_BAD_REMOTE_CHANNEL_TYPE 0x02 +#define MQ_STATUS_E_REMOTE_QM_UNAVAILABLE 0x03 +#define MQ_STATUS_E_MSG_SEQUENCE_ERROR 0x04 +#define MQ_STATUS_E_REMOTE_QM_TERMINATING 0x05 +#define MQ_STATUS_E_MSG_NOT_RECEIVED 0x06 +#define MQ_STATUS_I_CHANNEL_CLOSED 0x07 +#define MQ_STATUS_I_DISCINTERVAL_EXPIRED 0x08 +#define MQ_STATUS_E_REMOTE_PROTOCOL_ERROR 0x0A +#define MQ_STATUS_E_BIND_FAILED 0x14 +#define MQ_STATUS_E_MSGWRAP_DIFFERENT 0x15 +#define MQ_STATUS_E_REMOTE_CHANNEL_UNAVAILABLE 0x16 +#define MQ_STATUS_E_TERMINATED_BY_REMOTE_EXIT 0x17 +#define MQ_STATUS_E_SSL_REMOTE_BAD_CIPHER 0x18 /* These errors codes are documented in javax.transaction.xa.XAException */ #define MQ_XA_RBROLLBACK 100 @@ -568,7 +568,7 @@ static GHashTable *mq_reassembled_table = NULL; #define MQ_XA_NOMIGRATE 9 #define MQ_XA_HEURHAZ 8 #define MQ_XA_HEURCOM 7 -#define MQ_XA_HEURRB 6 +#define MQ_XA_HEURRB 6 #define MQ_XA_HEURMIX 5 #define MQ_XA_RETRY 4 #define MQ_XA_RDONLY 3 @@ -593,12 +593,12 @@ static GHashTable *mq_reassembled_table = NULL; #define MQ_XA_TMFAIL 0x20000000 #define MQ_XA_TMONEPHASE 0x40000000 -#define MQ_PMRF_NONE 0x00 -#define MQ_PMRF_MSG_ID 0x01 -#define MQ_PMRF_CORREL_ID 0x02 -#define MQ_PMRF_GROUP_ID 0x04 -#define MQ_PMRF_FEEDBACK 0x08 -#define MQ_PMRF_ACCOUNTING_TOKEN 0x10 +#define MQ_PMRF_NONE 0x00 +#define MQ_PMRF_MSG_ID 0x01 +#define MQ_PMRF_CORREL_ID 0x02 +#define MQ_PMRF_GROUP_ID 0x04 +#define MQ_PMRF_FEEDBACK 0x08 +#define MQ_PMRF_ACCOUNTING_TOKEN 0x10 /* MQ structures */ /* Undocumented structures */ @@ -833,7 +833,7 @@ static gint strip_trailing_blanks(guint8* a_string, gint a_size) { for (i = 0; i < a_size; i++) { - if (a_string[i] == ' ' || a_string[i] == '\0') + if (a_string[i] == ' ' || a_string[i] == '\0') { a_string[i] = '\0'; break; @@ -858,7 +858,7 @@ dissect_mq_md(tvbuff_t *tvb, proto_tree *tree, gboolean bLittleEndian, gint offs guint32 iVersionMD = 0; iVersionMD = tvb_get_guint32_endian(tvb, offset + 4, bLittleEndian); /* Compute length according to version */ - switch (iVersionMD) + switch (iVersionMD) { case 1: iSizeMD = 324; break; case 2: iSizeMD = 364; break; @@ -874,7 +874,7 @@ dissect_mq_md(tvbuff_t *tvb, proto_tree *tree, gboolean bLittleEndian, gint offs proto_item *ti = NULL; ti = proto_tree_add_text(tree, tvb, offset, iSizeMD, MQ_TEXT_MD); mq_tree = proto_item_add_subtree(ti, ett_mq_md); - + proto_tree_add_item(mq_tree, hf_mq_md_structid, tvb, offset, 4, FALSE); proto_tree_add_item(mq_tree, hf_mq_md_version, tvb, offset + 4, 4, bLittleEndian); proto_tree_add_item(mq_tree, hf_mq_md_report, tvb, offset + 8, 4, bLittleEndian); @@ -899,7 +899,7 @@ dissect_mq_md(tvbuff_t *tvb, proto_tree *tree, gboolean bLittleEndian, gint offs proto_tree_add_item(mq_tree, hf_mq_md_putdate, tvb, offset + 304, 8, FALSE); proto_tree_add_item(mq_tree, hf_mq_md_puttime, tvb, offset + 312, 8, FALSE); proto_tree_add_item(mq_tree, hf_mq_md_applorigindata, tvb, offset + 320, 4, FALSE); - + if (iVersionMD >= 2) { proto_tree_add_item(mq_tree, hf_mq_md_groupid, tvb, offset + 324, 24, FALSE); @@ -931,7 +931,7 @@ dissect_mq_or(tvbuff_t *tvb, proto_tree *tree, gint offset, gint iNbrRecords, gi { gint iOffsetOR = 0; gint iRecord = 0; - for (iRecord = 0; iRecord < iNbrRecords ; iRecord++) + for (iRecord = 0; iRecord < iNbrRecords ; iRecord++) { ti = proto_tree_add_text(tree, tvb, offset + iOffsetOR, 96, MQ_TEXT_OR); mq_tree = proto_item_add_subtree(ti, ett_mq_or); @@ -961,7 +961,7 @@ dissect_mq_rr(tvbuff_t *tvb, proto_tree *tree, gboolean bLittleEndian, gint offs { gint iOffsetRR = 0; gint iRecord = 0; - for (iRecord = 0; iRecord < iNbrRecords; iRecord++) + for (iRecord = 0; iRecord < iNbrRecords; iRecord++) { ti = proto_tree_add_text(tree, tvb, offset + iOffsetRR, 8, MQ_TEXT_RR); mq_tree = proto_item_add_subtree(ti, ett_mq_rr); @@ -998,7 +998,7 @@ dissect_mq_pmr(tvbuff_t *tvb, proto_tree *tree, gboolean bLittleEndian, gint off { gint iOffsetPMR = 0; gint iRecord = 0; - for (iRecord = 0; iRecord < iNbrRecords; iRecord++) + for (iRecord = 0; iRecord < iNbrRecords; iRecord++) { ti = proto_tree_add_text(tree, tvb, offset + iOffsetPMR, iSizePMR1, MQ_TEXT_PMR); mq_tree = proto_item_add_subtree(ti, ett_mq_pmr); @@ -1051,7 +1051,7 @@ dissect_mq_gmo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean bLi guint32 iVersionGMO = 0; iVersionGMO = tvb_get_guint32_endian(tvb, offset + 4, bLittleEndian); /* Compute length according to version */ - switch (iVersionGMO) + switch (iVersionGMO) { case 1: iSizeGMO = 72; break; case 2: iSizeGMO = 80; break; @@ -1060,7 +1060,7 @@ dissect_mq_gmo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean bLi if (iSizeGMO != 0 && tvb_length_remaining(tvb, offset) >= iSizeGMO) { - if (check_col(pinfo->cinfo, COL_INFO)) + if (check_col(pinfo->cinfo, COL_INFO)) { guint8* sQueue; sQueue = tvb_get_ephemeral_string(tvb, offset + 24, 48); @@ -1069,12 +1069,12 @@ dissect_mq_gmo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean bLi col_append_fstr(pinfo->cinfo, COL_INFO, " Q=%s", sQueue); } } - + if (tree) { ti = proto_tree_add_text(tree, tvb, offset, iSizeGMO, MQ_TEXT_GMO); mq_tree = proto_item_add_subtree(ti, ett_mq_gmo); - + proto_tree_add_item(mq_tree, hf_mq_gmo_structid, tvb, offset, 4, FALSE); proto_tree_add_item(mq_tree, hf_mq_gmo_version, tvb, offset + 4, 4, bLittleEndian); proto_tree_add_item(mq_tree, hf_mq_gmo_options, tvb, offset + 8, 4, bLittleEndian); @@ -1082,7 +1082,7 @@ dissect_mq_gmo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean bLi proto_tree_add_item(mq_tree, hf_mq_gmo_signal1, tvb, offset + 16, 4, bLittleEndian); proto_tree_add_item(mq_tree, hf_mq_gmo_signal2, tvb, offset + 20, 4, bLittleEndian); proto_tree_add_item(mq_tree, hf_mq_gmo_resolvedqname, tvb, offset + 24, 48, FALSE); - + if (iVersionGMO >= 2) { proto_tree_add_item(mq_tree, hf_mq_gmo_matchoptions, tvb, offset + 72, 4, FALSE); @@ -1091,7 +1091,7 @@ dissect_mq_gmo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean bLi proto_tree_add_item(mq_tree, hf_mq_gmo_segmentation, tvb, offset + 78, 1, FALSE); proto_tree_add_item(mq_tree, hf_mq_gmo_reserved, tvb, offset + 79, 1, FALSE); } - + if (iVersionGMO >= 3) { proto_tree_add_item(mq_tree, hf_mq_gmo_msgtoken, tvb, offset + 80, 16, FALSE); @@ -1120,7 +1120,7 @@ dissect_mq_pmo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean bLi guint32 iVersionPMO = 0; iVersionPMO = tvb_get_guint32_endian(tvb, offset + 4, bLittleEndian); /* Compute length according to version */ - switch (iVersionPMO) + switch (iVersionPMO) { case 1: iSizePMO = 128; break; case 2: iSizePMO = 152;break; @@ -1135,8 +1135,8 @@ dissect_mq_pmo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean bLi iNbrRecords = tvb_get_guint32_endian(tvb, offset + 128, bLittleEndian); iRecFlags = tvb_get_guint32_endian(tvb, offset + 132, bLittleEndian); } - - if (check_col(pinfo->cinfo, COL_INFO)) + + if (check_col(pinfo->cinfo, COL_INFO)) { guint8* sQueue; sQueue = tvb_get_ephemeral_string(tvb, offset + 32, 48); @@ -1145,7 +1145,7 @@ dissect_mq_pmo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean bLi col_append_fstr(pinfo->cinfo, COL_INFO, " Q=%s", sQueue); } } - + if (tree) { ti = proto_tree_add_text(tree, tvb, offset, iSizePMO, MQ_TEXT_PMO); @@ -1160,7 +1160,7 @@ dissect_mq_pmo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean bLi proto_tree_add_item(mq_tree, hf_mq_pmo_invaliddestcount, tvb, offset + 28, 4, bLittleEndian); proto_tree_add_item(mq_tree, hf_mq_pmo_resolvedqname, tvb, offset + 32, 48, FALSE); proto_tree_add_item(mq_tree, hf_mq_pmo_resolvedqmgrname, tvb, offset + 80, 48, FALSE); - + if (iVersionPMO >= 2) { proto_tree_add_item(mq_tree, hf_mq_pmo_recspresent, tvb, offset + 128, 4, bLittleEndian); @@ -1170,14 +1170,14 @@ dissect_mq_pmo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean bLi proto_tree_add_item(mq_tree, hf_mq_pmo_putmsgrecptr, tvb, offset + 144, 4, bLittleEndian); proto_tree_add_item(mq_tree, hf_mq_pmo_responserecptr, tvb, offset + 148, 4, bLittleEndian); } - + } if (iNbrRecords > 0) { gint iOffsetPMR = 0; gint iOffsetRR = 0; gint iSizePMRRR = 0; - + *iDistributionListSize = iNbrRecords; iOffsetPMR = tvb_get_guint32_endian(tvb, offset + 136, bLittleEndian); iOffsetRR = tvb_get_guint32_endian(tvb, offset + 140, bLittleEndian); @@ -1205,24 +1205,24 @@ dissect_mq_xid(tvbuff_t *tvb, proto_tree *tree, gboolean bLittleEndian, gint off iXidLength = tvb_get_guint8(tvb, offset + 4); iBqLength = tvb_get_guint8(tvb, offset + 5); iSizeXid = 6 + iXidLength + iBqLength; - - if (tvb_length_remaining(tvb, offset) >= iSizeXid) + + if (tvb_length_remaining(tvb, offset) >= iSizeXid) { if (tree) { ti = proto_tree_add_text(tree, tvb, offset, iSizeXid, MQ_TEXT_XID); mq_tree = proto_item_add_subtree(ti, ett_mq_xa_xid); - + proto_tree_add_item(mq_tree, hf_mq_xa_xid_formatid, tvb, offset, 4, bLittleEndian); proto_tree_add_item(mq_tree, hf_mq_xa_xid_globalxid_length, tvb, offset + 4, 1, FALSE); proto_tree_add_item(mq_tree, hf_mq_xa_xid_brq_length, tvb, offset + 5, 1, FALSE); proto_tree_add_item(mq_tree, hf_mq_xa_xid_globalxid, tvb, offset + 6, iXidLength, FALSE); - proto_tree_add_item(mq_tree, hf_mq_xa_xid_brq, tvb, offset + 6 + iXidLength, iBqLength, FALSE); + proto_tree_add_item(mq_tree, hf_mq_xa_xid_brq, tvb, offset + 6 + iXidLength, iBqLength, FALSE); } iSizeXid += (4 - (iSizeXid % 4)) % 4; /* Pad for alignment with 4 byte word boundary */ if (tvb_length_remaining(tvb, offset) < iSizeXid) iSizeXid = 0; } - else iSizeXid = 0; + else iSizeXid = 0; } return iSizeXid; } @@ -1246,12 +1246,12 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) struct mq_msg_properties tMsgProps; static gint iPreviousFrameNumber = -1; - if (check_col(pinfo->cinfo, COL_PROTOCOL)) col_set_str(pinfo->cinfo, COL_PROTOCOL, "MQ"); + if (check_col(pinfo->cinfo, COL_PROTOCOL)) col_set_str(pinfo->cinfo, COL_PROTOCOL, "MQ"); if (check_col(pinfo->cinfo, COL_INFO)) { - /* This is a trick to know whether this is the first PDU in this packet or not */ + /* This is a trick to know whether this is the first PDU in this packet or not */ if (iPreviousFrameNumber != (gint) pinfo->fd->num) - col_clear(pinfo->cinfo, COL_INFO); + col_clear(pinfo->cinfo, COL_INFO); else col_append_str(pinfo->cinfo, COL_INFO, " | "); } @@ -1270,7 +1270,7 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) iSegmentLength = tvb_get_ntohl(tvb, offset + 4); iControlFlags = tvb_get_guint8(tvb, offset + 10); - if (check_col(pinfo->cinfo, COL_INFO)) + if (check_col(pinfo->cinfo, COL_INFO)) { col_append_fstr(pinfo->cinfo, COL_INFO, "%s", val_to_str(opcode, mq_opcode_vals, "Unknown (0x%02x)")); } @@ -1313,12 +1313,12 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_tree_add_item(mq_tree, hf_mq_tsh_luwid, tvb, offset + 12, 8, FALSE); proto_tree_add_item(mq_tree, hf_mq_tsh_encoding, tvb, offset + 20, 4, bLittleEndian); proto_tree_add_item(mq_tree, hf_mq_tsh_ccsid, tvb, offset + 24, 2, bLittleEndian); - proto_tree_add_item(mq_tree, hf_mq_tsh_padding, tvb, offset + 26, 2, FALSE); + proto_tree_add_item(mq_tree, hf_mq_tsh_padding, tvb, offset + 26, 2, FALSE); } offset += iSizeTSH; /* Now dissect the embedded structures */ - if (tvb_length_remaining(tvb, offset) >= 4) + if (tvb_length_remaining(tvb, offset) >= 4) { structId = tvb_get_ntohl(tvb, offset); if (((iControlFlags & MQ_TCF_FIRST) != 0) || opcode < 0x80) @@ -1329,7 +1329,7 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { guint32 iReturnCode = 0; iReturnCode = tvb_get_guint32_endian(tvb, offset + 8, bLittleEndian); - if (check_col(pinfo->cinfo, COL_INFO)) + if (check_col(pinfo->cinfo, COL_INFO)) { if (iReturnCode != 0) col_append_fstr(pinfo->cinfo, COL_INFO, " [RC=%d]", iReturnCode); @@ -1339,7 +1339,7 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { ti = proto_tree_add_text(mqroot_tree, tvb, offset, iSizeAPI, MQ_TEXT_API); mq_tree = proto_item_add_subtree(ti, ett_mq_api); - + proto_tree_add_item(mq_tree, hf_mq_api_replylength, tvb, offset, 4, FALSE); proto_tree_add_item(mq_tree, hf_mq_api_completioncode, tvb, offset + 4, 4, bLittleEndian); proto_tree_add_item(mq_tree, hf_mq_api_reasoncode, tvb, offset + 8, 4, bLittleEndian); @@ -1357,7 +1357,7 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { ti = proto_tree_add_text(mqroot_tree, tvb, offset, iSizeMSH, MQ_TEXT_MSH); mq_tree = proto_item_add_subtree(ti, ett_mq_msh); - + proto_tree_add_item(mq_tree, hf_mq_msh_structid, tvb, offset + 0, 4, FALSE); proto_tree_add_item(mq_tree, hf_mq_msh_seqnum, tvb, offset + 4, 4, bLittleEndian); proto_tree_add_item(mq_tree, hf_mq_msh_datalength, tvb, offset + 8, 4, bLittleEndian); @@ -1376,7 +1376,7 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) if (tvb_length_remaining(tvb, offset) >= iStatusLength) { - if (check_col(pinfo->cinfo, COL_INFO)) + if (check_col(pinfo->cinfo, COL_INFO)) { if (iStatus != 0) col_append_fstr(pinfo->cinfo, COL_INFO, ": Code=%s", val_to_str(iStatus, mq_status_vals, "Unknown (0x%08x)")); @@ -1385,10 +1385,10 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { ti = proto_tree_add_text(mqroot_tree, tvb, offset, 8, MQ_TEXT_STAT); mq_tree = proto_item_add_subtree(ti, ett_mq_status); - + proto_tree_add_item(mq_tree, hf_mq_status_length, tvb, offset, 4, bLittleEndian); proto_tree_add_item(mq_tree, hf_mq_status_code, tvb, offset + 4, 4, bLittleEndian); - + if (iStatusLength >= 12) proto_tree_add_item(mq_tree, hf_mq_status_value, tvb, offset + 8, 4, bLittleEndian); } @@ -1401,7 +1401,7 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { ti = proto_tree_add_text(mqroot_tree, tvb, offset, -1, MQ_TEXT_PING); mq_tree = proto_item_add_subtree(ti, ett_mq_ping); - + proto_tree_add_item(mq_tree, hf_mq_ping_length, tvb, offset, 4, bLittleEndian); proto_tree_add_item(mq_tree, hf_mq_ping_buffer, tvb, offset + 4, -1, FALSE); } @@ -1413,7 +1413,7 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { ti = proto_tree_add_text(mqroot_tree, tvb, offset, -1, MQ_TEXT_RESET); mq_tree = proto_item_add_subtree(ti, ett_mq_reset); - + proto_tree_add_item(mq_tree, hf_mq_reset_length, tvb, offset, 4, bLittleEndian); proto_tree_add_item(mq_tree, hf_mq_reset_seqnum, tvb, offset + 4, 4, bLittleEndian); } @@ -1423,15 +1423,15 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { gint iSizeCONN = 0; /*iSizeCONN = ((iVersionID == 4 || iVersionID == 6) ? 120 : 112);*/ /* guess */ - /* The iVersionID is available in the previous ID segment, we should keep a state + /* The iVersionID is available in the previous ID segment, we should keep a state * Instead we rely on the segment length announced in the TSH */ /* The MQCONN structure is special because it does not start with a structid */ iSizeCONN = iSegmentLength - iSizeTSH - iSizeAPI; if (iSizeCONN != 112 && iSizeCONN != 120) iSizeCONN = 0; - + if (iSizeCONN != 0 && tvb_length_remaining(tvb, offset) >= iSizeCONN) { - if (check_col(pinfo->cinfo, COL_INFO)) + if (check_col(pinfo->cinfo, COL_INFO)) { guint8* sApplicationName; guint8* sQueueManager; @@ -1446,24 +1446,24 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) col_append_fstr(pinfo->cinfo, COL_INFO, " QM=%s", sQueueManager); } } - - + + if (tree) { ti = proto_tree_add_text(mqroot_tree, tvb, offset, iSizeCONN, MQ_TEXT_CONN); mq_tree = proto_item_add_subtree(ti, ett_mq_conn); - + proto_tree_add_item(mq_tree, hf_mq_conn_queuemanager, tvb, offset, 48, FALSE); proto_tree_add_item(mq_tree, hf_mq_conn_appname, tvb, offset + 48, 28, FALSE); proto_tree_add_item(mq_tree, hf_mq_conn_apptype, tvb, offset + 76, 4, bLittleEndian); proto_tree_add_item(mq_tree, hf_mq_conn_acttoken, tvb, offset + 80, 32, FALSE); - + if (iSizeCONN >= 120) { proto_tree_add_item(mq_tree, hf_mq_conn_version, tvb, offset + 112, 4, bLittleEndian); proto_tree_add_item(mq_tree, hf_mq_conn_options, tvb, offset + 116, 4, bLittleEndian); } - } + } offset += iSizeCONN; } } @@ -1475,21 +1475,21 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) gint iCharLen = 0; gint iOffsetINQ = 0; gint iSelector = 0; - + iNbSelectors = tvb_get_guint32_endian(tvb, offset, bLittleEndian); iNbIntegers = tvb_get_guint32_endian(tvb, offset + 4, bLittleEndian); iCharLen = tvb_get_guint32_endian(tvb, offset + 8, bLittleEndian); - + if (tree) { ti = proto_tree_add_text(mqroot_tree, tvb, offset, -1, MQ_TEXT_INQ); mq_tree = proto_item_add_subtree(ti, ett_mq_inq); - + proto_tree_add_item(mq_tree, hf_mq_inq_nbsel, tvb, offset, 4, bLittleEndian); proto_tree_add_item(mq_tree, hf_mq_inq_nbint, tvb, offset + 4, 4, bLittleEndian); proto_tree_add_item(mq_tree, hf_mq_inq_charlen, tvb, offset + 8, 4, bLittleEndian); } - iOffsetINQ = 12; + iOffsetINQ = 12; if (tvb_length_remaining(tvb, offset + iOffsetINQ) >= iNbSelectors * 4) { if (tree) @@ -1531,23 +1531,23 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { gint iOffsetSPI = 0; guint32 iSpiVerb = 0; - + iSpiVerb = tvb_get_guint32_endian(tvb, offset, bLittleEndian); - if (check_col(pinfo->cinfo, COL_INFO)) + if (check_col(pinfo->cinfo, COL_INFO)) { col_append_fstr(pinfo->cinfo, COL_INFO, " (%s)", val_to_str(iSpiVerb, mq_spi_verbs_vals, "Unknown (0x%08x)")); } - + if (tree) { ti = proto_tree_add_text(mqroot_tree, tvb, offset, 12, MQ_TEXT_SPI); mq_tree = proto_item_add_subtree(ti, ett_mq_spi); - + proto_tree_add_item(mq_tree, hf_mq_spi_verb, tvb, offset, 4, bLittleEndian); proto_tree_add_item(mq_tree, hf_mq_spi_version, tvb, offset + 4, 4, bLittleEndian); proto_tree_add_item(mq_tree, hf_mq_spi_length, tvb, offset + 8, 4, bLittleEndian); } - + offset += 12; structId = (tvb_length_remaining(tvb, offset) >= 4) ? tvb_get_ntohl(tvb, offset) : MQ_STRUCTID_NULL; if ((structId == MQ_STRUCTID_SPQU || structId == MQ_STRUCTID_SPAU_EBCDIC @@ -1561,22 +1561,22 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { guint8* sStructId; sStructId = tvb_get_ephemeral_string(tvb, offset, 4); - ti = proto_tree_add_text(mqroot_tree, tvb, offset, 12, (const char*)sStructId); + ti = proto_tree_add_text(mqroot_tree, tvb, offset, 12, "%s", sStructId); mq_tree = proto_item_add_subtree(ti, ett_mq_spi_base); - + proto_tree_add_item(mq_tree, hf_mq_spi_base_structid, tvb, offset, 4, FALSE); proto_tree_add_item(mq_tree, hf_mq_spi_base_version, tvb, offset + 4, 4, bLittleEndian); proto_tree_add_item(mq_tree, hf_mq_spi_base_length, tvb, offset + 8, 4, bLittleEndian); } offset += 12; structId = (tvb_length_remaining(tvb, offset) >= 4) ? tvb_get_ntohl(tvb, offset) : MQ_STRUCTID_NULL; - + if ((iSizeSPIMD = dissect_mq_md(tvb, mqroot_tree, bLittleEndian, offset, &tMsgProps)) != 0) { gint iSizeGMO = 0; gint iSizePMO = 0; offset += iSizeSPIMD; - + if ((iSizeGMO = dissect_mq_gmo(tvb, pinfo, mqroot_tree, bLittleEndian, offset)) != 0) { offset += iSizeGMO; @@ -1587,7 +1587,7 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) } structId = (tvb_length_remaining(tvb, offset) >= 4) ? tvb_get_ntohl(tvb, offset) : MQ_STRUCTID_NULL; } - + if ((structId == MQ_STRUCTID_SPQO || structId == MQ_STRUCTID_SPQO_EBCDIC || structId == MQ_STRUCTID_SPQI || structId == MQ_STRUCTID_SPQI_EBCDIC || structId == MQ_STRUCTID_SPPO || structId == MQ_STRUCTID_SPPO_EBCDIC @@ -1595,7 +1595,7 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) || structId == MQ_STRUCTID_SPGO || structId == MQ_STRUCTID_SPGO_EBCDIC || structId == MQ_STRUCTID_SPGI || structId == MQ_STRUCTID_SPGI_EBCDIC || structId == MQ_STRUCTID_SPAO || structId == MQ_STRUCTID_SPAO_EBCDIC - || structId == MQ_STRUCTID_SPAI || structId == MQ_STRUCTID_SPAI_EBCDIC) + || structId == MQ_STRUCTID_SPAI || structId == MQ_STRUCTID_SPAI_EBCDIC) && tvb_length_remaining(tvb, offset) >= 12) { if (tree) @@ -1603,14 +1603,14 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) /* Dissect the common part of these structures */ guint8* sStructId; sStructId = tvb_get_ephemeral_string(tvb, offset, 4); - ti = proto_tree_add_text(mqroot_tree, tvb, offset, -1, "%s", (const char*)sStructId); + ti = proto_tree_add_text(mqroot_tree, tvb, offset, -1, "%s", sStructId); mq_tree = proto_item_add_subtree(ti, ett_mq_spi_base); - + proto_tree_add_item(mq_tree, hf_mq_spi_base_structid, tvb, offset, 4, FALSE); proto_tree_add_item(mq_tree, hf_mq_spi_base_version, tvb, offset + 4, 4, bLittleEndian); proto_tree_add_item(mq_tree, hf_mq_spi_base_length, tvb, offset + 8, 4, bLittleEndian); } - + if (structId == MQ_STRUCTID_SPQO && tvb_length_remaining(tvb, offset) >= 16) { if (tree) @@ -1618,11 +1618,11 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) gint iVerbNumber = 0; proto_tree_add_item(mq_tree, hf_mq_spi_spqo_nbverb, tvb, offset + 12, 4, bLittleEndian); iVerbNumber = tvb_get_guint32_endian(tvb, offset + 12, bLittleEndian); - + if (tvb_length_remaining(tvb, offset) >= iVerbNumber * 20 + 16) { gint iVerb = 0; - iOffsetSPI = offset + 16; + iOffsetSPI = offset + 16; for (iVerb = 0; iVerb < iVerbNumber; iVerb++) { proto_tree_add_item(mq_tree, hf_mq_spi_spqo_verbid, tvb, iOffsetSPI, 4, bLittleEndian); @@ -1665,11 +1665,11 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { proto_tree *mq_tree_sub = NULL; gint iOptionsFlags; - + ti = proto_tree_add_item(mq_tree, hf_mq_spi_spgo_options, tvb, offset + 12, 4, bLittleEndian); mq_tree_sub = proto_item_add_subtree(ti, ett_mq_spi_options); iOptionsFlags = tvb_get_guint32_endian(tvb, offset + 12, bLittleEndian); - + proto_tree_add_boolean(mq_tree_sub, hf_mq_spi_options_deferred, tvb, offset + 12, 4, iOptionsFlags); proto_tree_add_boolean(mq_tree_sub, hf_mq_spi_options_syncpoint, tvb, offset + 12, 4, iOptionsFlags); proto_tree_add_boolean(mq_tree_sub, hf_mq_spi_options_blank, tvb, offset + 12, 4, iOptionsFlags); @@ -1690,24 +1690,24 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) } else if ((opcode >= 0xA0 && opcode <= 0xB9) && tvb_length_remaining(tvb, offset) >= 16) { - /* The XA structures are special because they do not start with a structid */ + /* The XA structures are special because they do not start with a structid */ if (tree) { ti = proto_tree_add_text(mqroot_tree, tvb, offset, 16, "%s (%s)", MQ_TEXT_XA, val_to_str(opcode, mq_opcode_vals, "Unknown (0x%02x)")); mq_tree = proto_item_add_subtree(ti, ett_mq_xa); - + proto_tree_add_item(mq_tree, hf_mq_xa_length, tvb, offset, 4, FALSE); proto_tree_add_item(mq_tree, hf_mq_xa_returnvalue, tvb, offset + 4, 4, bLittleEndian); - + /* Transaction Manager flags */ { proto_tree *mq_tree_sub = NULL; guint32 iTMFlags; - + ti = proto_tree_add_item(mq_tree, hf_mq_xa_tmflags, tvb, offset + 8, 4, bLittleEndian); mq_tree_sub = proto_item_add_subtree(ti, ett_mq_xa_tmflags); iTMFlags = tvb_get_guint32_endian(tvb, offset + 8, bLittleEndian); - + proto_tree_add_boolean(mq_tree_sub, hf_mq_xa_tmflags_onephase, tvb, offset + 8, 4, iTMFlags); proto_tree_add_boolean(mq_tree_sub, hf_mq_xa_tmflags_fail, tvb, offset + 8, 4, iTMFlags); proto_tree_add_boolean(mq_tree_sub, hf_mq_xa_tmflags_resume, tvb, offset + 8, 4, iTMFlags); @@ -1717,7 +1717,7 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_tree_add_boolean(mq_tree_sub, hf_mq_xa_tmflags_endrscan, tvb, offset + 8, 4, iTMFlags); proto_tree_add_boolean(mq_tree_sub, hf_mq_xa_tmflags_join, tvb, offset + 8, 4, iTMFlags); } - + proto_tree_add_item(mq_tree, hf_mq_xa_rmid, tvb, offset + 12, 4, bLittleEndian); } offset += 16; @@ -1740,7 +1740,7 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { ti = proto_tree_add_text(mqroot_tree, tvb, offset, iXAInfoLength + 1, MQ_TEXT_XINF); mq_tree = proto_item_add_subtree(ti, ett_mq_xa_info); - + proto_tree_add_item(mq_tree, hf_mq_xa_xainfo_length, tvb, offset, 1, FALSE); proto_tree_add_item(mq_tree, hf_mq_xa_xainfo_value, tvb, offset + 1, iXAInfoLength, FALSE); } @@ -1766,7 +1766,7 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) if ((iSizeXid = dissect_mq_xid(tvb, mqroot_tree, bLittleEndian, offset)) != 0) offset += iSizeXid; else - break; + break; } } } @@ -1778,10 +1778,10 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) iVersionID = tvb_get_guint8(tvb, offset + 4); iSizeID = (iVersionID < 4 ? 44 : 104); /* guess */ /* actually 102 but must be aligned to multiple of 4 */ - + if (iSizeID != 0 && tvb_length_remaining(tvb, offset) >= iSizeID) { - if (check_col(pinfo->cinfo, COL_INFO)) + if (check_col(pinfo->cinfo, COL_INFO)) { guint8* sChannel; sChannel = tvb_get_ephemeral_string(tvb, offset + 24, 20); @@ -1790,24 +1790,24 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) col_append_fstr(pinfo->cinfo, COL_INFO, ": CHL=%s", sChannel); } } - + if (tree) { ti = proto_tree_add_text(mqroot_tree, tvb, offset, iSizeID, MQ_TEXT_ID); mq_tree = proto_item_add_subtree(ti, ett_mq_id); - + proto_tree_add_item(mq_tree, hf_mq_id_structid, tvb, offset, 4, FALSE); proto_tree_add_item(mq_tree, hf_mq_id_level, tvb, offset + 4, 1, FALSE); - + /* ID flags */ { proto_tree *mq_tree_sub = NULL; guint8 iIDFlags; - + ti = proto_tree_add_item(mq_tree, hf_mq_id_flags, tvb, offset + 5, 1, FALSE); mq_tree_sub = proto_item_add_subtree(ti, ett_mq_id_icf); iIDFlags = tvb_get_guint8(tvb, offset + 5); - + proto_tree_add_boolean(mq_tree_sub, hf_mq_id_icf_runtime, tvb, offset + 5, 1, iIDFlags); proto_tree_add_boolean(mq_tree_sub, hf_mq_id_icf_svrsec, tvb, offset + 5, 1, iIDFlags); proto_tree_add_boolean(mq_tree_sub, hf_mq_id_icf_mqreq, tvb, offset + 5, 1, iIDFlags); @@ -1815,18 +1815,18 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_tree_add_boolean(mq_tree_sub, hf_mq_id_icf_convcap, tvb, offset + 5, 1, iIDFlags); proto_tree_add_boolean(mq_tree_sub, hf_mq_id_icf_msgseq, tvb, offset + 5, 1, iIDFlags); } - + proto_tree_add_item(mq_tree, hf_mq_id_unknown2, tvb, offset + 6, 1, FALSE); - + /* Error flags */ { proto_tree *mq_tree_sub = NULL; guint8 iErrorFlags; - + ti = proto_tree_add_item(mq_tree, hf_mq_id_ieflags, tvb, offset + 7, 1, FALSE); mq_tree_sub = proto_item_add_subtree(ti, ett_mq_id_ief); iErrorFlags = tvb_get_guint8(tvb, offset + 7); - + proto_tree_add_boolean(mq_tree_sub, hf_mq_id_ief_hbint, tvb, offset + 7, 1, iErrorFlags); proto_tree_add_boolean(mq_tree_sub, hf_mq_id_ief_seqwrap, tvb, offset + 7, 1, iErrorFlags); proto_tree_add_boolean(mq_tree_sub, hf_mq_id_ief_mxmsgpb, tvb, offset + 7, 1, iErrorFlags); @@ -1836,7 +1836,7 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_tree_add_boolean(mq_tree_sub, hf_mq_id_ief_enc, tvb, offset + 7, 1, iErrorFlags); proto_tree_add_boolean(mq_tree_sub, hf_mq_id_ief_ccsid, tvb, offset + 7, 1, iErrorFlags); } - + proto_tree_add_item(mq_tree, hf_mq_id_unknown4, tvb, offset + 8, 2, FALSE); proto_tree_add_item(mq_tree, hf_mq_id_maxmsgperbatch, tvb, offset + 10, 2, bLittleEndian); proto_tree_add_item(mq_tree, hf_mq_id_maxtransmissionsize, tvb, offset + 12, 4, bLittleEndian); @@ -1844,10 +1844,10 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_tree_add_item(mq_tree, hf_mq_id_sequencewrapvalue, tvb, offset + 20, 4, bLittleEndian); proto_tree_add_item(mq_tree, hf_mq_id_channel, tvb, offset + 24, 20, FALSE); } - + if (iVersionID >= 4) { - if (check_col(pinfo->cinfo, COL_INFO)) + if (check_col(pinfo->cinfo, COL_INFO)) { guint8* sQueueManager; sQueueManager = tvb_get_ephemeral_string(tvb, offset + 48, 48); @@ -1856,7 +1856,7 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) col_append_fstr(pinfo->cinfo, COL_INFO, " QM=%s", sQueueManager); } } - + if (tree) { proto_tree_add_item(mq_tree, hf_mq_id_capflags, tvb, offset + 44, 1, FALSE); @@ -1865,7 +1865,7 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_tree_add_item(mq_tree, hf_mq_id_queuemanager, tvb, offset + 48, 48, FALSE); proto_tree_add_item(mq_tree, hf_mq_id_heartbeatinterval, tvb, offset + 96, 4, bLittleEndian); } - + } offset += iSizeID; } @@ -1878,10 +1878,10 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) * Instead we rely on the segment length announced in the TSH */ iSizeUID = iSegmentLength - iSizeTSH; if (iSizeUID != 28 && iSizeUID != 132) iSizeUID = 0; - + if (iSizeUID != 0 && tvb_length_remaining(tvb, offset) >= iSizeUID) { - if (check_col(pinfo->cinfo, COL_INFO)) + if (check_col(pinfo->cinfo, COL_INFO)) { guint8* sUserId; sUserId = tvb_get_ephemeral_string(tvb, offset + 4, 12); @@ -1890,17 +1890,17 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) col_append_fstr(pinfo->cinfo, COL_INFO, ": User=%s", sUserId); } } - + if (tree) { ti = proto_tree_add_text(mqroot_tree, tvb, offset, iSizeUID, MQ_TEXT_UID); mq_tree = proto_item_add_subtree(ti, ett_mq_uid); - + proto_tree_add_item(mq_tree, hf_mq_uid_structid, tvb, offset, 4, FALSE); proto_tree_add_item(mq_tree, hf_mq_uid_userid, tvb, offset + 4, 12, FALSE); proto_tree_add_item(mq_tree, hf_mq_uid_password, tvb, offset + 16, 12, FALSE); } - + if (iSizeUID == 132) { if (tree) @@ -1919,20 +1919,20 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) guint32 iVersionOD = 0; iVersionOD = tvb_get_guint32_endian(tvb, offset + 4, bLittleEndian); /* Compute length according to version */ - switch (iVersionOD) + switch (iVersionOD) { case 1: iSizeOD = 168; break; case 2: iSizeOD = 200; break; case 3: iSizeOD = 336; break; } - + if (iSizeOD != 0 && tvb_length_remaining(tvb, offset) >= iSizeOD) { gint iNbrRecords = 0; if (iVersionOD >= 2) iNbrRecords = tvb_get_guint32_endian(tvb, offset + 168, bLittleEndian); - - if (check_col(pinfo->cinfo, COL_INFO)) + + if (check_col(pinfo->cinfo, COL_INFO)) { guint8* sQueue; sQueue = tvb_get_ephemeral_string(tvb, offset + 12, 48); @@ -1941,12 +1941,12 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) col_append_fstr(pinfo->cinfo, COL_INFO, " Obj=%s", sQueue); } } - + if (tree) { ti = proto_tree_add_text(mqroot_tree, tvb, offset, iSizeOD, MQ_TEXT_OD); mq_tree = proto_item_add_subtree(ti, ett_mq_od); - + proto_tree_add_item(mq_tree, hf_mq_od_structid, tvb, offset, 4, FALSE); proto_tree_add_item(mq_tree, hf_mq_od_version, tvb, offset + 4, 4, bLittleEndian); proto_tree_add_item(mq_tree, hf_mq_od_objecttype, tvb, offset + 8, 4, bLittleEndian); @@ -1954,7 +1954,7 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_tree_add_item(mq_tree, hf_mq_od_objectqmgrname, tvb, offset + 60, 48, FALSE); proto_tree_add_item(mq_tree, hf_mq_od_dynamicqname, tvb, offset + 108, 48, FALSE); proto_tree_add_item(mq_tree, hf_mq_od_alternateuserid, tvb, offset + 156, 12, FALSE); - + if (iVersionOD >= 2) { proto_tree_add_item(mq_tree, hf_mq_od_recspresent, tvb, offset + 168, 4, bLittleEndian); @@ -1966,23 +1966,23 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_tree_add_item(mq_tree, hf_mq_od_objectrecptr, tvb, offset + 192, 4, bLittleEndian); proto_tree_add_item(mq_tree, hf_mq_od_responserecptr, tvb, offset + 196, 4, bLittleEndian); } - + if (iVersionOD >= 3) { proto_tree_add_item(mq_tree, hf_mq_od_alternatesecurityid, tvb, offset + 200, 40, FALSE); proto_tree_add_item(mq_tree, hf_mq_od_resolvedqname, tvb, offset + 240, 48, FALSE); proto_tree_add_item(mq_tree, hf_mq_od_resolvedqmgrname, tvb, offset + 288, 48, FALSE); } - + } offset += iSizeOD; - + if (iNbrRecords > 0) { gint iOffsetOR = 0; gint iOffsetRR = 0; gint iSizeORRR = 0; - + iDistributionListSize = iNbrRecords; iOffsetOR = tvb_get_guint32_endian(tvb, offset - iSizeOD + 184, bLittleEndian); iOffsetRR = tvb_get_guint32_endian(tvb, offset - iSizeOD + 188, bLittleEndian); @@ -1994,8 +1994,8 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) } structId = (tvb_length_remaining(tvb, offset) >= 4) ? tvb_get_ntohl(tvb, offset) : MQ_STRUCTID_NULL; } - if ((opcode == MQ_TST_MQOPEN || opcode == MQ_TST_MQCLOSE - || opcode == MQ_TST_MQOPEN_REPLY || opcode == MQ_TST_MQCLOSE_REPLY) + if ((opcode == MQ_TST_MQOPEN || opcode == MQ_TST_MQCLOSE + || opcode == MQ_TST_MQOPEN_REPLY || opcode == MQ_TST_MQCLOSE_REPLY) && tvb_length_remaining(tvb, offset) >= 4) { if (tree) @@ -2012,7 +2012,7 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) gint iSizeGMO = 0; gint iSizePMO = 0; offset += iSizeMD; - + if ((iSizeGMO = dissect_mq_gmo(tvb, pinfo, mqroot_tree, bLittleEndian, offset)) != 0) { offset += iSizeGMO; @@ -2040,22 +2040,22 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) } if (iDistributionListSize > 0) { - if (check_col(pinfo->cinfo, COL_INFO)) - col_append_fstr(pinfo->cinfo, COL_INFO, " (Distribution List, Size=%d)", iDistributionListSize); + if (check_col(pinfo->cinfo, COL_INFO)) + col_append_fstr(pinfo->cinfo, COL_INFO, " (Distribution List, Size=%d)", iDistributionListSize); } if (bPayload == TRUE) { if (iSizePayload != 0 && tvb_length_remaining(tvb, offset) > 0) { /* For the following header structures, each structure has a "format" field - which announces the type of the following structure. For dissection we + which announces the type of the following structure. For dissection we do not use it and rely on the structid instead. */ guint32 iHeadersLength = 0; if (tvb_length_remaining(tvb, offset) >= 4) { gint iSizeMD = 0; structId = tvb_get_ntohl(tvb, offset); - + if ((structId == MQ_STRUCTID_XQH || structId == MQ_STRUCTID_XQH_EBCDIC) && tvb_length_remaining(tvb, offset) >= 104) { /* if MD.format == MQXMIT */ @@ -2064,7 +2064,7 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { ti = proto_tree_add_text(mqroot_tree, tvb, offset, iSizeXQH, MQ_TEXT_XQH); mq_tree = proto_item_add_subtree(ti, ett_mq_xqh); - + proto_tree_add_item(mq_tree, hf_mq_xqh_structid, tvb, offset, 4, FALSE); proto_tree_add_item(mq_tree, hf_mq_xqh_version, tvb, offset + 4, 4, bLittleEndian); proto_tree_add_item(mq_tree, hf_mq_xqh_remoteq, tvb, offset + 8, 48, FALSE); @@ -2072,13 +2072,13 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) } offset += iSizeXQH; iHeadersLength += iSizeXQH; - + if ((iSizeMD = dissect_mq_md(tvb, mqroot_tree, bLittleEndian, offset, &tMsgProps)) != 0) { offset += iSizeMD; iHeadersLength += iSizeMD; } - + structId = (tvb_length_remaining(tvb, offset) >= 4) ? tvb_get_ntohl(tvb, offset) : MQ_STRUCTID_NULL; } if ((structId == MQ_STRUCTID_DH || structId == MQ_STRUCTID_DH_EBCDIC) && tvb_length_remaining(tvb, offset) >= 48) @@ -2087,7 +2087,7 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) gint iSizeDH = 48; gint iNbrRecords = 0; guint32 iRecFlags = 0; - + iNbrRecords = tvb_get_guint32_endian(tvb, offset + 36, bLittleEndian); iRecFlags = tvb_get_guint32_endian(tvb, offset + 32, bLittleEndian); tMsgProps.iOffsetEncoding = offset + 12; @@ -2098,7 +2098,7 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { ti = proto_tree_add_text(mqroot_tree, tvb, offset, iSizeDH, MQ_TEXT_DH); mq_tree = proto_item_add_subtree(ti, ett_mq_dh); - + proto_tree_add_item(mq_tree, hf_mq_head_structid, tvb, offset, 4, FALSE); proto_tree_add_item(mq_tree, hf_mq_head_version, tvb, offset + 4, 4, bLittleEndian); proto_tree_add_item(mq_tree, hf_mq_head_length, tvb, offset + 8, 4, bLittleEndian); @@ -2113,13 +2113,13 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) } offset += iSizeDH; iHeadersLength += iSizeDH; - + if (iNbrRecords > 0) { gint iOffsetOR = 0; gint iOffsetPMR = 0; gint iSizeORPMR = 0; - + iOffsetOR = tvb_get_guint32_endian(tvb, offset - iSizeDH + 40, bLittleEndian); iOffsetPMR = tvb_get_guint32_endian(tvb, offset - iSizeDH + 44, bLittleEndian); if ((iSizeORPMR = dissect_mq_or(tvb, mqroot_tree, offset, iNbrRecords, iOffsetOR)) != 0) @@ -2133,7 +2133,7 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) iHeadersLength += iSizeORPMR; } } - + structId = (tvb_length_remaining(tvb, offset) >= 4) ? tvb_get_ntohl(tvb, offset) : MQ_STRUCTID_NULL; } if ((structId == MQ_STRUCTID_DLH || structId == MQ_STRUCTID_DLH_EBCDIC) && tvb_length_remaining(tvb, offset) >= 172) @@ -2147,7 +2147,7 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { ti = proto_tree_add_text(mqroot_tree, tvb, offset, iSizeDLH, MQ_TEXT_DLH); mq_tree = proto_item_add_subtree(ti, ett_mq_dlh); - + proto_tree_add_item(mq_tree, hf_mq_dlh_structid, tvb, offset, 4, FALSE); proto_tree_add_item(mq_tree, hf_mq_dlh_version, tvb, offset + 4, 4, bLittleEndian); proto_tree_add_item(mq_tree, hf_mq_dlh_reason, tvb, offset + 8, 4, bLittleEndian); @@ -2176,7 +2176,7 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { ti = proto_tree_add_text(mqroot_tree, tvb, offset, iSizeMDE, MQ_TEXT_MDE); mq_tree = proto_item_add_subtree(ti, ett_mq_mde); - + proto_tree_add_item(mq_tree, hf_mq_head_structid, tvb, offset, 4, FALSE); proto_tree_add_item(mq_tree, hf_mq_head_version, tvb, offset + 4, 4, bLittleEndian); proto_tree_add_item(mq_tree, hf_mq_head_length, tvb, offset + 8, 4, bLittleEndian); @@ -2205,7 +2205,7 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) /* We assume that only one such header is present */ gint iSizeHeader = 0; iSizeHeader = tvb_get_guint32_endian(tvb, offset + 8, bLittleEndian); - + if (tvb_length_remaining(tvb, offset) >= iSizeHeader) { tMsgProps.iOffsetEncoding = offset + 12; @@ -2215,7 +2215,7 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { ti = proto_tree_add_text(mqroot_tree, tvb, offset, iSizeHeader, val_to_str(structId, mq_structid_vals, "Unknown (0x%08x)")); mq_tree = proto_item_add_subtree(ti, ett_mq_head); - + proto_tree_add_item(mq_tree, hf_mq_head_structid, tvb, offset, 4, FALSE); proto_tree_add_item(mq_tree, hf_mq_head_version, tvb, offset + 4, 4, bLittleEndian); proto_tree_add_item(mq_tree, hf_mq_head_length, tvb, offset + 8, 4, bLittleEndian); @@ -2224,7 +2224,7 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_tree_add_item(mq_tree, hf_mq_head_format, tvb, offset + 20, 8, FALSE); proto_tree_add_item(mq_tree, hf_mq_head_flags, tvb, offset + 28, 4, bLittleEndian); proto_tree_add_item(mq_tree, hf_mq_head_struct, tvb, offset + 32, iSizeHeader - 32, bLittleEndian); - + } offset += iSizeHeader; iHeadersLength += iSizeHeader; @@ -2232,13 +2232,13 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) } } } - + if (tMsgProps.iOffsetFormat != 0) { guint8* sFormat = NULL; sFormat = tvb_get_ephemeral_string(tvb, tMsgProps.iOffsetFormat, 8); if (strip_trailing_blanks(sFormat, 8) == 0) sFormat = (guint8*)g_strdup("MQNONE"); - if (check_col(pinfo->cinfo, COL_INFO)) + if (check_col(pinfo->cinfo, COL_INFO)) { col_append_fstr(pinfo->cinfo, COL_INFO, " Fmt=%s", sFormat); } @@ -2247,11 +2247,11 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_tree_add_string_hidden(tree, hf_mq_md_hidden_lastformat, tvb, tMsgProps.iOffsetFormat, 8, (const char*)sFormat); } } - if (check_col(pinfo->cinfo, COL_INFO)) + if (check_col(pinfo->cinfo, COL_INFO)) { col_append_fstr(pinfo->cinfo, COL_INFO, " (%d bytes)", iSizePayload - iHeadersLength); } - + { /* Call subdissector for the payload */ tvbuff_t* next_tvb = NULL; @@ -2310,13 +2310,13 @@ reassemble_mq(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) guint32 structId; structId = tvb_get_ntohl(tvb, 0); - if (structId == MQ_STRUCTID_TSH || structId == MQ_STRUCTID_TSH_EBCDIC) + if (structId == MQ_STRUCTID_TSH || structId == MQ_STRUCTID_TSH_EBCDIC) { guint8 iControlFlags = 0; guint32 iSegmentLength = 0; guint32 iBeginLength = 0; guint8 opcode; - gboolean bFirstSegment; + gboolean bFirstSegment; gboolean bLastSegment; opcode = tvb_get_guint8(tvb, 9); iControlFlags = tvb_get_guint8(tvb, 10); @@ -2324,7 +2324,7 @@ reassemble_mq(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) bFirstSegment = ((iControlFlags & MQ_TCF_FIRST) != 0); bLastSegment = ((iControlFlags & MQ_TCF_LAST) != 0); - if (opcode > 0x80 && !(bFirstSegment && bLastSegment)) + if (opcode > 0x80 && !(bFirstSegment && bLastSegment)) { /* Optimisation : only fragmented segments go through the reassembly process */ if (mq_reassembly) @@ -2334,10 +2334,10 @@ reassemble_mq(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) guint32 iConnectionId = (pinfo->srcport + pinfo->destport); if (opcode > 0x80 && !bFirstSegment) iBeginLength = 28; fd_head = fragment_add_seq_next(tvb, iBeginLength, pinfo, iConnectionId, mq_fragment_table, mq_reassembled_table, iSegmentLength - iBeginLength, !bLastSegment); - if (fd_head != NULL && pinfo->fd->num == fd_head->reassembled_in) + if (fd_head != NULL && pinfo->fd->num == fd_head->reassembled_in) { /* Reassembly finished */ - if (fd_head->next != NULL) + if (fd_head->next != NULL) { /* 2 or more fragments */ next_tvb = tvb_new_real_data(fd_head->data, fd_head->len, fd_head->len); @@ -2355,7 +2355,7 @@ reassemble_mq(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) else { /* Reassembly in progress */ - if (check_col(pinfo->cinfo, COL_PROTOCOL)) col_set_str(pinfo->cinfo, COL_PROTOCOL, "MQ"); + if (check_col(pinfo->cinfo, COL_PROTOCOL)) col_set_str(pinfo->cinfo, COL_PROTOCOL, "MQ"); if (check_col(pinfo->cinfo, COL_INFO)) col_add_fstr(pinfo->cinfo, COL_INFO, "%s [Reassembled MQ]", val_to_str(opcode, mq_opcode_vals, "Unknown (0x%02x)")); if (tree) { @@ -2364,7 +2364,7 @@ reassemble_mq(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_item_append_text(ti, " (%s) [Reassembled MQ]", val_to_str(opcode, mq_opcode_vals, "Unknown (0x%02x)")); } return; - } + } } else { @@ -2374,7 +2374,7 @@ reassemble_mq(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) /* MQ segment is the first of a unreassembled series */ if (check_col(pinfo->cinfo, COL_INFO)) col_append_str(pinfo->cinfo, COL_INFO, " [Unreassembled MQ]"); } - return; + return; } } /* Reassembly not enabled or non-fragmented message */ @@ -2389,7 +2389,7 @@ get_mq_pdu_len(tvbuff_t *tvb, int offset) { if (tvb_length_remaining(tvb, offset) >= 8) { - if ((tvb_get_ntohl(tvb, 0) == MQ_STRUCTID_TSH || tvb_get_ntohl(tvb, 0) == MQ_STRUCTID_TSH_EBCDIC)) + if ((tvb_get_ntohl(tvb, 0) == MQ_STRUCTID_TSH || tvb_get_ntohl(tvb, 0) == MQ_STRUCTID_TSH_EBCDIC)) return tvb_get_ntohl(tvb, offset + 4); } return 0; @@ -2418,17 +2418,17 @@ dissect_mq_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint iProto structId = tvb_get_ntohl(tvb, 0); cEndian = tvb_get_guint8(tvb, 8); - if ((structId == MQ_STRUCTID_TSH || structId == MQ_STRUCTID_TSH_EBCDIC) + if ((structId == MQ_STRUCTID_TSH || structId == MQ_STRUCTID_TSH_EBCDIC) && (cEndian == MQ_LITTLE_ENDIAN || cEndian == MQ_BIG_ENDIAN)) { /* Register this dissector for this conversation */ conversation_t *conversation = NULL; conversation = find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst, pinfo->ptype, pinfo->srcport, pinfo->destport, 0); - if (conversation == NULL) + if (conversation == NULL) { conversation = conversation_new(pinfo->fd->num, &pinfo->src, &pinfo->dst, pinfo->ptype, pinfo->srcport, pinfo->destport, 0); } - if (iProto == MQ_XPT_TCP) conversation_set_dissector(conversation, mq_tcp_handle); + if (iProto == MQ_XPT_TCP) conversation_set_dissector(conversation, mq_tcp_handle); /* Dissect the packet */ reassemble_mq(tvb, pinfo, tree); @@ -2484,16 +2484,16 @@ proto_register_mq(void) { &hf_mq_tsh_reserved, { "Reserved", "mq.tsh.reserved", FT_UINT8, BASE_HEX, NULL, 0x0, "TSH Reserved", HFILL }}, - + { &hf_mq_tsh_luwid, { "Logical unit of work identifier", "mq.tsh.luwid", FT_BYTES, BASE_HEX, NULL, 0x0, "TSH logical unit of work identifier", HFILL }}, - + { &hf_mq_tsh_encoding, { "Encoding", "mq.tsh.encoding", FT_UINT32, BASE_DEC, NULL, 0x0, "TSH Encoding", HFILL }}, { &hf_mq_tsh_ccsid, { "Character set", "mq.tsh.ccsid", FT_UINT16, BASE_DEC, NULL, 0x0, "TSH CCSID", HFILL }}, - + { &hf_mq_tsh_padding, { "Padding", "mq.tsh.padding", FT_UINT16, BASE_HEX, NULL, 0x0, "TSH Padding", HFILL }}, diff --git a/epan/dissectors/packet-xml.c b/epan/dissectors/packet-xml.c index 88e97822c1..ec49b2e3bd 100644 --- a/epan/dissectors/packet-xml.c +++ b/epan/dissectors/packet-xml.c @@ -54,33 +54,33 @@ #include <epan/prefs.h> typedef struct _xml_ns_t { - /* the name of this namespace */ + /* the name of this namespace */ gchar* name; - - /* its fully qualified name */ + + /* its fully qualified name */ gchar* fqn; /* the contents of the whole element from <> to </> */ int hf_tag; - + /* chunks of cdata from <> to </> excluding sub tags */ int hf_cdata; - + /* the subtree for its sub items */ gint ett; GHashTable* attributes; /* key: the attribute name value: hf_id of what's between quotes */ - + /* the namespace's namespaces */ GHashTable* elements; /* key: the element name value: the child namespace */ - + GPtrArray* element_names; /* imported directly from the parser and used while building the namespace */ - + } xml_ns_t; typedef struct { @@ -131,38 +131,38 @@ GArray* hf_arr; GArray* ett_arr; static const gchar* default_media_types[] = { - "text/xml", - "text/vnd.wap.wml", - "text/vnd.wap.si", - "text/vnd.wap.sl", - "text/vnd.wap.co", - "text/vnd.wap.emn", - "application/auth-policy+xml", + "text/xml", + "text/vnd.wap.wml", + "text/vnd.wap.si", + "text/vnd.wap.sl", + "text/vnd.wap.co", + "text/vnd.wap.emn", + "application/auth-policy+xml", "application/cpim-pidf+xml", "application/cpl+xml", - "application/mathml+xml", + "application/mathml+xml", "application/pidf+xml", "application/poc-settings+xml", - "application/rdf+xml", + "application/rdf+xml", "application/reginfo+xml", "application/resource-lists+xml", "application/rlmi+xml", "application/rls-services+xml", - "application/smil", + "application/smil", "application/simple-filter+xml", - "application/soap+xml", - "application/vnd.wv.csp+xml", + "application/soap+xml", + "application/vnd.wv.csp+xml", "application/vnd.wv.csp.xml", "application/watcherinfo+xml", - "application/xcap-att+xml", - "application/xcap-caps+xml", - "application/xcap-el+xml", - "application/xcap-error+xml", - "application/xml", - "application/xml-dtd", + "application/xcap-att+xml", + "application/xcap-caps+xml", + "application/xcap-el+xml", + "application/xcap-error+xml", + "application/xml", + "application/xml-dtd", "application/xpidf+xml", - "application/xslt+xml", - "image/svg+xml", + "application/xslt+xml", + "image/svg+xml", }; static void @@ -177,10 +177,10 @@ dissect_xml(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) col_append_str(pinfo->cinfo, COL_PROTOCOL, "/XML"); if(!tree) return; - + if (stack != NULL) g_ptr_array_free(stack,TRUE); - + stack = g_ptr_array_new(); current_frame = ep_alloc(sizeof(xml_frame_t)); g_ptr_array_add(stack,current_frame); @@ -189,22 +189,22 @@ dissect_xml(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) current_frame->start_offset = 0; root_ns = NULL; - + if (pinfo->match_string) root_ns = g_hash_table_lookup(media_types,pinfo->match_string); - + if (! root_ns ) { root_ns = &xml_ns; } - + current_frame->ns = root_ns; - + current_frame->item = proto_tree_add_item(tree,current_frame->ns->hf_tag,tvb,0,-1,FALSE); current_frame->tree = proto_item_add_subtree(current_frame->item,current_frame->ns->ett); current_frame->last_item = current_frame->item; - + while(( tok = tvbparse_get(tt, want) )) ; -} +} static gboolean dissect_xml_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { if ( pref_heuristic && tvbparse_peek(tvbparse_init(tvb,0,-1,NULL,want_ignore), want_heur)) { @@ -228,9 +228,9 @@ static void after_token(void* tvbparse_data, const void* wanted_data _U_, tvbpar } else { hfid = xml_ns.hf_cdata; } - + pi = proto_tree_add_item(current_frame->tree, hfid, tok->tvb, tok->offset, tok->len, FALSE); - + proto_item_set_text(pi, "%s", tvb_format_text(tok->tvb,tok->offset,tok->len)); } @@ -246,7 +246,7 @@ static void before_xmpli(void* tvbparse_data, const void* wanted_data _U_, tvbpa int hf_tag; gint ett; - + g_strdown(name); if (!ns) { hf_tag = hf_xmlpi; @@ -255,13 +255,13 @@ static void before_xmpli(void* tvbparse_data, const void* wanted_data _U_, tvbpa hf_tag = ns->hf_tag; ett = ns->ett; } - + pi = proto_tree_add_item(current_frame->tree,hf_tag,tok->tvb,tok->offset,tok->len,FALSE); - - proto_item_set_text(pi,tvb_format_text(tok->tvb,tok->offset,(name_tok->offset - tok->offset) + name_tok->len)); - + + proto_item_set_text(pi, "%s", tvb_format_text(tok->tvb,tok->offset,(name_tok->offset - tok->offset) + name_tok->len)); + pt = proto_item_add_subtree(pi,ett); - + current_frame = ep_alloc(sizeof(xml_frame_t)); current_frame->item = pi; current_frame->last_item = pi; @@ -270,17 +270,17 @@ static void before_xmpli(void* tvbparse_data, const void* wanted_data _U_, tvbpa current_frame->ns = ns; g_ptr_array_add(stack,current_frame); - + } static void after_xmlpi(void* tvbparse_data, const void* wanted_data _U_, tvbparse_elem_t* tok) { GPtrArray* stack = tvbparse_data; xml_frame_t* current_frame = g_ptr_array_index(stack,stack->len - 1); - + proto_tree_add_text(current_frame->tree, tok->tvb, tok->offset, tok->len, tvb_format_text(tok->tvb,tok->offset,tok->len)); - + if (stack->len > 1) { g_ptr_array_remove_index_fast(stack,stack->len - 1); } else { @@ -303,28 +303,28 @@ static void before_tag(void* tvbparse_data, const void* wanted_data _U_, tvbpars tvbparse_elem_t* root_tok = name_tok->sub->sub; tvbparse_elem_t* leaf_tok = name_tok->sub->sub->next->next; xml_ns_t* nameroot_ns; - + root_name = tvb_get_ephemeral_string(root_tok->tvb,root_tok->offset,root_tok->len); name = tvb_get_ephemeral_string(leaf_tok->tvb,leaf_tok->offset,leaf_tok->len); - + nameroot_ns = g_hash_table_lookup(xml_ns.elements,root_name); - + if(nameroot_ns) { ns = g_hash_table_lookup(nameroot_ns->elements,name); if (!ns) { - ns = &unknown_ns; + ns = &unknown_ns; } } else { ns = &unknown_ns; } - + } else { name = tvb_get_ephemeral_string(name_tok->tvb,name_tok->offset,name_tok->len); g_strdown(name); if(current_frame->ns) { ns = g_hash_table_lookup(current_frame->ns->elements,name); - + if (!ns) { if (! ( ns = g_hash_table_lookup(root_ns->elements,name) ) ) { ns = &unknown_ns; @@ -336,10 +336,10 @@ static void before_tag(void* tvbparse_data, const void* wanted_data _U_, tvbpars } pi = proto_tree_add_item(current_frame->tree,ns->hf_tag,tok->tvb,tok->offset,tok->len,FALSE); - proto_item_set_text(pi,tvb_format_text(tok->tvb,tok->offset,(name_tok->offset - tok->offset) + name_tok->len)); - + proto_item_set_text(pi, "%s", tvb_format_text(tok->tvb,tok->offset,(name_tok->offset - tok->offset) + name_tok->len)); + pt = proto_item_add_subtree(pi,ns->ett); - + new_frame = ep_alloc(sizeof(xml_frame_t)); new_frame->item = pi; new_frame->last_item = pi; @@ -362,13 +362,13 @@ static void after_closed_tag(void* tvbparse_data, const void* wanted_data _U_, t GPtrArray* stack = tvbparse_data; xml_frame_t* current_frame = g_ptr_array_index(stack,stack->len - 1); - proto_item_append_text(current_frame->last_item,"/>"); + proto_item_append_text(current_frame->last_item,"/>"); if (stack->len > 1) { g_ptr_array_remove_index_fast(stack,stack->len - 1); } else { proto_tree_add_text(current_frame->tree,tok->tvb,tok->offset,tok->len,"[ ERROR: Closing an unopened tag ]"); - } + } } static void after_untag(void* tvbparse_data, const void* wanted_data _U_, tvbparse_elem_t* tok){ @@ -376,7 +376,7 @@ static void after_untag(void* tvbparse_data, const void* wanted_data _U_, tvbpar xml_frame_t* current_frame = g_ptr_array_index(stack,stack->len - 1); proto_item_set_len(current_frame->item, (tok->offset - current_frame->start_offset) + tok->len); - + proto_tree_add_text(current_frame->tree,tok->tvb,tok->offset,tok->len,"%s", tvb_format_text(tok->tvb,tok->offset,tok->len)); @@ -394,7 +394,7 @@ static void before_dtd_doctype(void* tvbparse_data, const void* wanted_data _U_, tvbparse_elem_t* name_tok = tok->sub->next->next->next->sub->sub; proto_tree* dtd_item = proto_tree_add_item(current_frame->tree, hf_doctype, name_tok->tvb, name_tok->offset, name_tok->len, FALSE); - + proto_item_set_text(dtd_item,"%s",tvb_format_text(tok->tvb,tok->offset,tok->len)); current_frame = ep_alloc(sizeof(xml_frame_t)); @@ -416,13 +416,13 @@ static void pop_stack(void* tvbparse_data, const void* wanted_data _U_, tvbparse } else { proto_tree_add_text(current_frame->tree,tok->tvb,tok->offset,tok->len, "[ ERROR: Closing an unopened tag ]"); - } + } } static void after_dtd_close(void* tvbparse_data, const void* wanted_data _U_, tvbparse_elem_t* tok){ GPtrArray* stack = tvbparse_data; xml_frame_t* current_frame = g_ptr_array_index(stack,stack->len - 1); - + proto_tree_add_text(current_frame->tree,tok->tvb,tok->offset,tok->len,"%s", tvb_format_text(tok->tvb,tok->offset,tok->len)); if (stack->len > 1) { @@ -451,7 +451,7 @@ static void after_attrib(void* tvbparse_data, const void* wanted_data _U_, tvbpa hfid = hf_unknowwn_attrib; value = tok; } - + current_frame->last_item = proto_tree_add_item(current_frame->tree,hfid,value->tvb,value->offset,value->len,FALSE); proto_item_set_text(current_frame->last_item, "%s", tvb_format_text(tok->tvb,tok->offset,tok->len)); @@ -460,56 +460,56 @@ static void after_attrib(void* tvbparse_data, const void* wanted_data _U_, tvbpa static void unrecognized_token(void* tvbparse_data, const void* wanted_data _U_, tvbparse_elem_t* tok _U_){ GPtrArray* stack = tvbparse_data; xml_frame_t* current_frame = g_ptr_array_index(stack,stack->len - 1); - + proto_tree_add_text(current_frame->tree,tok->tvb,tok->offset,tok->len,"[ ERROR: Unrecognized text ]"); } -static void init_xml_parser(void) { +static void init_xml_parser(void) { tvbparse_wanted_t* want_name = tvbparse_chars(-1,1,0,"abcdefghijklmnopqrstuvwxyz-_ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",NULL,NULL,NULL); tvbparse_wanted_t* want_attr_name = tvbparse_chars(-1,1,0,"abcdefghijklmnopqrstuvwxyz-_ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789:",NULL,NULL,NULL); - + tvbparse_wanted_t* want_scoped_name = tvbparse_set_seq(XML_SCOPED_NAME, NULL, NULL, NULL, want_name, tvbparse_char(-1,":",NULL,NULL,NULL), want_name, NULL); - + tvbparse_wanted_t* want_tag_name = tvbparse_set_oneof(0, NULL, NULL, NULL, want_scoped_name, want_name, NULL); - + tvbparse_wanted_t* want_attrib_value = tvbparse_set_oneof(0, NULL, NULL, get_attrib_value, tvbparse_quoted(-1, NULL, NULL, tvbparse_shrink_token_cb,'\"','\\'), tvbparse_quoted(-1, NULL, NULL, tvbparse_shrink_token_cb,'\'','\\'), tvbparse_chars(-1,1,0,"0123456789",NULL,NULL,NULL), want_name, NULL); - + tvbparse_wanted_t* want_attributes = tvbparse_one_or_more(-1, NULL, NULL, NULL, tvbparse_set_seq(-1, NULL, NULL, after_attrib, want_attr_name, tvbparse_char(-1,"=",NULL,NULL,NULL), want_attrib_value, NULL)); - + tvbparse_wanted_t* want_stoptag = tvbparse_set_oneof(-1,NULL,NULL,NULL, tvbparse_char(-1, ">", NULL, NULL, after_open_tag), tvbparse_string(-1, "/>", NULL, NULL, after_closed_tag), NULL); - + tvbparse_wanted_t* want_stopxmlpi = tvbparse_string(-1,"?>",NULL,NULL,after_xmlpi); - + tvbparse_wanted_t* want_comment = tvbparse_set_seq(hf_comment,NULL,NULL,after_token, tvbparse_string(-1,"<!--",NULL,NULL,NULL), tvbparse_until(-1,NULL,NULL,NULL, tvbparse_string(-1,"-->",NULL,NULL,NULL), TP_UNTIL_INCLUDE), NULL); - + tvbparse_wanted_t* want_xmlpi = tvbparse_set_seq(hf_xmlpi,NULL,before_xmpli,NULL, tvbparse_string(-1,"<?",NULL,NULL,NULL), want_name, @@ -521,14 +521,14 @@ static void init_xml_parser(void) { NULL), NULL), NULL); - + tvbparse_wanted_t* want_closing_tag = tvbparse_set_seq(0,NULL,NULL,after_untag, tvbparse_char(-1, "<", NULL, NULL, NULL), tvbparse_char(-1, "/", NULL, NULL, NULL), want_tag_name, tvbparse_char(-1, ">", NULL, NULL, NULL), NULL); - + tvbparse_wanted_t* want_doctype_start = tvbparse_set_seq(-1,NULL,before_dtd_doctype,NULL, tvbparse_char(-1,"<",NULL,NULL,NULL), tvbparse_char(-1,"!",NULL,NULL,NULL), @@ -550,7 +550,7 @@ static void init_xml_parser(void) { NULL), NULL), NULL); - + tvbparse_wanted_t* want_dtd_tag = tvbparse_set_seq(hf_dtd_tag,NULL,NULL,after_token, tvbparse_char(-1,"<",NULL,NULL,NULL), tvbparse_char(-1,"!",NULL,NULL,NULL), @@ -558,7 +558,7 @@ static void init_xml_parser(void) { tvbparse_char(-1, ">", NULL, NULL, NULL), TP_UNTIL_INCLUDE), NULL); - + tvbparse_wanted_t* want_tag = tvbparse_set_seq(-1, NULL, before_tag, NULL, tvbparse_char(-1,"<",NULL,NULL,NULL), want_tag_name, @@ -570,15 +570,15 @@ static void init_xml_parser(void) { want_stoptag, NULL), NULL); - + tvbparse_wanted_t* want_dtd_close = tvbparse_set_seq(-1,NULL,NULL,after_dtd_close, tvbparse_char(-1,"]",NULL,NULL,NULL), tvbparse_char(-1,">",NULL,NULL,NULL), NULL); - + want_ignore = tvbparse_chars(-1,1,0," \t\r\n",NULL,NULL,NULL); - - + + want = tvbparse_set_oneof(-1, NULL, NULL, NULL, want_comment, want_xmlpi, @@ -590,7 +590,7 @@ static void init_xml_parser(void) { tvbparse_not_chars(XML_CDATA,1,0,"<",NULL,NULL,after_token), tvbparse_not_chars(-1,1,0," \t\r\n",NULL,NULL,unrecognized_token), NULL); - + want_heur = tvbparse_set_oneof(-1, NULL, NULL, NULL, want_comment, want_xmlpi, @@ -598,7 +598,7 @@ static void init_xml_parser(void) { want_dtd_tag, want_tag, NULL); - + } @@ -606,33 +606,33 @@ static xml_ns_t* xml_new_namespace(GHashTable* hash, gchar* name, ...) { xml_ns_t* ns = g_malloc(sizeof(xml_ns_t)); va_list ap; gchar* attr_name; - + ns->name = g_strdup(name); ns->hf_tag = -1; ns->hf_cdata = -1; ns->ett = -1; ns->attributes = g_hash_table_new(g_str_hash,g_str_equal); ns->elements = g_hash_table_new(g_str_hash,g_str_equal); - + va_start(ap,name); - + while(( attr_name = va_arg(ap,gchar*) )) { int* hfp = g_malloc(sizeof(int)); *hfp = -1; g_hash_table_insert(ns->attributes,g_strdup(attr_name),hfp); }; - + va_end(ap); - + g_hash_table_insert(hash,ns->name,ns); - + return ns; } static void add_xml_field(GArray* hfs, int* p_id, gchar* name, gchar* fqn) { hf_register_info hfri; - + hfri.p_id = p_id; hfri.hfinfo.name = name; hfri.hfinfo.abbrev = fqn; @@ -647,8 +647,8 @@ static void add_xml_field(GArray* hfs, int* p_id, gchar* name, gchar* fqn) { hfri.hfinfo.bitshift = 0; hfri.hfinfo.same_name_next = NULL; hfri.hfinfo.same_name_prev = NULL; - - g_array_append_val(hfs,hfri); + + g_array_append_val(hfs,hfri); } static void add_xml_attribute_names(gpointer k, gpointer v, gpointer p) { @@ -667,10 +667,10 @@ static void add_xmlpi_namespace(gpointer k _U_, gpointer v, gpointer p) { add_xml_field(hf_arr, &(ns->hf_tag), basename, basename); g_array_append_val(ett_arr,ett_p); - + d.basename = basename; d.hf = hf_arr; - + g_hash_table_foreach(ns->attributes,add_xml_attribute_names,&d); } @@ -681,9 +681,9 @@ static void destroy_dtd_data(dtd_build_data_t* dtd_data) { if(dtd_data->media_type) g_free(dtd_data->media_type); if(dtd_data->description) g_free(dtd_data->description); if(dtd_data->proto_root) g_free(dtd_data->proto_root); - + g_string_free(dtd_data->error,TRUE); - + while(dtd_data->elements->len) { dtd_named_list_t* nl = g_ptr_array_remove_index_fast(dtd_data->elements,0); @@ -692,7 +692,7 @@ static void destroy_dtd_data(dtd_build_data_t* dtd_data) { } g_ptr_array_free(dtd_data->elements,TRUE); - + while(dtd_data->attributes->len) { dtd_named_list_t* nl = g_ptr_array_remove_index_fast(dtd_data->elements,0); g_ptr_array_free(nl->list,TRUE); @@ -710,24 +710,24 @@ static void copy_attrib_item(gpointer k, gpointer v _U_, gpointer p) { gchar* key = g_strdup(k); int* value = g_malloc(sizeof(int)); GHashTable* dst = p; - + *value = -1; g_hash_table_insert(dst,key,value); - + } static GHashTable* copy_attributes_hash(GHashTable* src) { GHashTable* dst = g_hash_table_new(g_str_hash,g_str_equal); - + g_hash_table_foreach(src,copy_attrib_item,dst); - + return dst; } static xml_ns_t* duplicate_element(xml_ns_t* orig) { xml_ns_t* new_item = g_malloc(sizeof(xml_ns_t)); guint i; - + new_item->name = g_strdup(orig->name); new_item->hf_tag = -1; new_item->hf_cdata = -1; @@ -735,12 +735,12 @@ static xml_ns_t* duplicate_element(xml_ns_t* orig) { new_item->attributes = copy_attributes_hash(orig->attributes); new_item->elements = g_hash_table_new(g_str_hash,g_str_equal); new_item->element_names = g_ptr_array_new(); - + for(i=0; i < orig->element_names->len; i++) { g_ptr_array_add(new_item->element_names, g_ptr_array_index(orig->element_names,i)); } - + return new_item; } @@ -748,15 +748,15 @@ static gchar* fully_qualified_name(GPtrArray* hier, gchar* name) { guint i; GString* s = g_string_new(""); gchar* str; - + for (i = 0; i < hier->len; i++) { g_string_sprintfa(s, "%s.",(gchar*)g_ptr_array_index(hier,i)); } - + g_string_append(s,name); str = s->str; g_string_free(s,FALSE); - + return str; } @@ -784,22 +784,22 @@ static xml_ns_t* make_xml_hier(gchar* elem_name, g_string_sprintfa(error,"element '%s' is not defined\n", elem_name); return NULL; } - + for (i = 0; i < hier->len; i++) { if( strcmp(elem_name,(gchar*) g_ptr_array_index(hier,i) ) == 0 ) { recurred = TRUE; } } - + if (recurred) { return NULL; } - + fqn = fully_qualified_name(hier,elem_name); - + new = duplicate_element(orig); new->fqn = fqn; - + add_xml_field(hfs, &(new->hf_tag), g_strdup(elem_name), fqn); add_xml_field(hfs, &(new->hf_cdata), g_strdup(elem_name), fqn); @@ -808,22 +808,22 @@ static xml_ns_t* make_xml_hier(gchar* elem_name, d.basename = fqn; d.hf = hfs; - + g_hash_table_foreach(new->attributes,add_xml_attribute_names,&d); while(new->element_names->len) { gchar* child_name = g_ptr_array_remove_index(new->element_names,0); xml_ns_t* child_element = NULL; - + g_ptr_array_add(hier,elem_name); child_element = make_xml_hier(child_name, root, elements, hier,error,hfs,etts); g_ptr_array_remove_index_fast(hier,hier->len - 1); - + if (child_element) { g_hash_table_insert(new->elements,child_element->name,child_element); } } - + g_ptr_array_free(new->element_names,TRUE); new->element_names = NULL; return new; @@ -841,14 +841,14 @@ static gboolean free_elements(gpointer k _U_, gpointer v, gpointer p _U_) { g_hash_table_foreach_remove(e->attributes,free_both,NULL); g_hash_table_destroy(e->attributes); g_hash_table_destroy(e->elements); - + while (e->element_names->len) { g_free(g_ptr_array_remove_index(e->element_names,0)); } - + g_ptr_array_free(e->element_names,TRUE); g_free(e); - + return TRUE; } @@ -861,16 +861,16 @@ static void register_dtd(dtd_build_data_t* dtd_data, GString* errors) { GPtrArray* hier; gchar* curr_name; GPtrArray* element_names = g_ptr_array_new(); - + /* we first populate elements with the those coming from the parser */ while(dtd_data->elements->len) { dtd_named_list_t* nl = g_ptr_array_remove_index(dtd_data->elements,0); xml_ns_t* element = g_malloc(sizeof(xml_ns_t)); - + /* we will use the first element found as root in case no other one was given. */ if (root_name == NULL) root_name = g_strdup(nl->name); - + element->name = nl->name; element->element_names = nl->list; element->hf_tag = -1; @@ -878,7 +878,7 @@ static void register_dtd(dtd_build_data_t* dtd_data, GString* errors) { element->ett = -1; element->attributes = g_hash_table_new(g_str_hash,g_str_equal); element->elements = g_hash_table_new(g_str_hash,g_str_equal); - + if( g_hash_table_lookup(elements,element->name) ) { g_string_sprintfa(errors,"element %s defined more than once\n", element->name); free_elements(NULL,element,NULL); @@ -886,7 +886,7 @@ static void register_dtd(dtd_build_data_t* dtd_data, GString* errors) { g_hash_table_insert(elements,element->name,element); g_ptr_array_add(element_names,g_strdup(element->name)); } - + g_free(nl); } @@ -894,21 +894,21 @@ static void register_dtd(dtd_build_data_t* dtd_data, GString* errors) { while(dtd_data->attributes->len) { dtd_named_list_t* nl = g_ptr_array_remove_index(dtd_data->attributes,0); xml_ns_t* element = g_hash_table_lookup(elements,nl->name); - + if (!element) { g_string_sprintfa(errors,"element %s is not defined\n", nl->name); goto next_attribute; } - + while(nl->list->len) { gchar* name = g_ptr_array_remove_index(nl->list,0); int* id_p = g_malloc(sizeof(int)); - + *id_p = -1; g_hash_table_insert(element->attributes,name,id_p); } - + next_attribute: g_free(nl->name); g_ptr_array_free(nl->list,TRUE); @@ -924,7 +924,7 @@ next_attribute: /* we use a stack with the names to avoid recurring infinitelly */ hier = g_ptr_array_new(); - + /* * if a proto name was given in the dtd the dtd will be used as a protocol * or else the dtd will be loaded as a branch of the xml namespace @@ -932,17 +932,17 @@ next_attribute: if( ! dtd_data->proto_name ) { hfs = hf_arr; etts = ett_arr; - g_ptr_array_add(hier,g_strdup("xml")); + g_ptr_array_add(hier,g_strdup("xml")); root_element = &xml_ns; } else { /* * if we were given a proto_name the namespace will be registered * as an indipendent protocol with its own hf and ett arrays. - */ + */ hfs = g_array_new(FALSE,FALSE,sizeof(hf_register_info)); etts = g_array_new(FALSE,FALSE,sizeof(gint*)); } - + /* the root element of the dtd's namespace */ root_element = g_malloc(sizeof(xml_ns_t)); root_element->name = g_strdup(root_name); @@ -952,7 +952,7 @@ next_attribute: root_element->ett = -1; root_element->elements = g_hash_table_new(g_str_hash,g_str_equal); root_element->element_names = element_names; - + /* * we can either create a namespace as a flat namespace * in which all the elements are at the root level @@ -960,17 +960,17 @@ next_attribute: */ if (dtd_data->recursion) { xml_ns_t* orig_root; - + make_xml_hier(root_name, root_element, elements,hier,errors,hfs,etts); - + g_hash_table_insert(root_element->elements,root_element->name,root_element); - + orig_root = g_hash_table_lookup(elements,root_name); - + /* if the root element was defined copy its attrlist to the child */ - if(orig_root) { + if(orig_root) { struct _attr_reg_data d; - + d.basename = root_name; d.hf = hfs; @@ -982,29 +982,29 @@ next_attribute: /* we then create all the sub hierachies to catch the recurred cases */ g_ptr_array_add(hier,root_name); - + while(root_element->element_names->len) { curr_name = g_ptr_array_remove_index(root_element->element_names,0); - + if( ! g_hash_table_lookup(root_element->elements,curr_name) ) { xml_ns_t* new = make_xml_hier(curr_name, root_element, elements,hier,errors,hfs,etts); g_hash_table_insert(root_element->elements,new->name,new); } - + g_free(curr_name); } - + } else { /* a flat namespace */ g_ptr_array_add(hier,root_name); - + root_element->attributes = g_hash_table_new(g_str_hash,g_str_equal); while(root_element->element_names->len) { xml_ns_t* new; gint* ett_p; struct _attr_reg_data d; - + curr_name = g_ptr_array_remove_index(root_element->element_names,0); new = duplicate_element(g_hash_table_lookup(elements,curr_name)); new->fqn = fully_qualified_name(hier, curr_name); @@ -1019,17 +1019,17 @@ next_attribute: ett_p = &new->ett; g_array_append_val(etts,ett_p); - + g_ptr_array_free(new->element_names,TRUE); - + g_hash_table_insert(root_element->elements,new->name,new); } } g_ptr_array_free(element_names,TRUE); - + g_ptr_array_free(hier,TRUE); - + /* * if we were given a proto_name the namespace will be registered * as an indipendent protocol. @@ -1040,34 +1040,34 @@ next_attribute: if ( ! dtd_data->description) { dtd_data->description = g_strdup(root_name); } - + ett_p = &root_element->ett; g_array_append_val(etts,ett_p); add_xml_field(hfs, &root_element->hf_cdata, root_element->name, root_element->fqn); - + root_element->hf_tag = proto_register_protocol(dtd_data->description, dtd_data->proto_name, root_element->name); proto_register_field_array(root_element->hf_tag, (hf_register_info*)hfs->data, hfs->len); proto_register_subtree_array((gint**)etts->data, etts->len); - + if (dtd_data->media_type) { g_hash_table_insert(media_types,dtd_data->media_type,root_element); dtd_data->media_type = NULL; } - + dtd_data->description = NULL; dtd_data->proto_name = NULL; g_array_free(hfs,FALSE); g_array_free(etts,TRUE); } - + g_hash_table_insert(xml_ns.elements,root_element->name,root_element); - + g_hash_table_foreach_remove(elements,free_elements,NULL); g_hash_table_destroy(elements); - + destroy_dtd_data(dtd_data); - + if (root_name) g_free(root_name); } @@ -1095,62 +1095,62 @@ static void init_xml_names(void) { const FILE_T* file; const gchar* filename; gchar* dirname; - + #if GLIB_MAJOR_VERSION >= 2 GError** dummy = g_malloc(sizeof(GError *)); *dummy = NULL; #endif - + xmpli_names = g_hash_table_new(g_str_hash,g_str_equal); media_types = g_hash_table_new(g_str_hash,g_str_equal); - + unknown_ns.elements = xml_ns.elements = g_hash_table_new(g_str_hash,g_str_equal); unknown_ns.attributes = xml_ns.attributes = g_hash_table_new(g_str_hash,g_str_equal); - + xmlpi_xml_ns = xml_new_namespace(xmpli_names,"xml","version","encoding","standalone",NULL); - + g_hash_table_destroy(xmlpi_xml_ns->elements); xmlpi_xml_ns->elements = NULL; - + dirname = get_persconffile_path("dtds", FALSE); - + if (test_for_directory(dirname) != EISDIR) { /* Although dir isn't a directory it may still use memory */ g_free(dirname); dirname = get_datafile_path("dtds"); } - + if (test_for_directory(dirname) == EISDIR) { - + if ((dir = OPENDIR_OP(dirname)) != NULL) { while ((file = DIRGETNEXT_OP(dir)) != NULL) { guint namelen; filename = GETFNAME_OP(file); - + namelen = strlen(filename); if ( namelen > 4 && ( g_strcasecmp(filename+(namelen-4),".dtd") == 0 ) ) { GString* errors = g_string_new(""); GString* preparsed = dtd_preparse(dirname, filename, errors); dtd_build_data_t* dtd_data; - + if (errors->len) { report_failure("Dtd Preparser in file %s%c%s: %s",dirname,G_DIR_SEPARATOR,filename,errors->str); continue; } - + dtd_data = dtd_parse(preparsed); - + g_string_free(preparsed,TRUE); - + if (dtd_data->error->len) { report_failure("Dtd Parser in file %s%c%s: %s",dirname,G_DIR_SEPARATOR,filename,dtd_data->error->str); destroy_dtd_data(dtd_data); continue; } - + register_dtd(dtd_data,errors); - + if (errors->len) { report_failure("Dtd Registration in file: %s%c%s: %s",dirname,G_DIR_SEPARATOR,filename,errors->str); g_string_free(errors,TRUE); @@ -1158,29 +1158,29 @@ static void init_xml_names(void) { } } } - + CLOSEDIR_OP(dir); } } - + for(i=0;i<array_length(default_media_types);i++) { if( ! g_hash_table_lookup(media_types,default_media_types[i]) ) { g_hash_table_insert(media_types,(gpointer)default_media_types[i],&xml_ns); } } - + g_hash_table_foreach(xmpli_names,add_xmlpi_namespace,"xml.xmlpi"); #if GLIB_MAJOR_VERSION >= 2 g_free(dummy); -#endif +#endif } static void apply_prefs(void) { if (pref_heuristic) { heur_dissector_add("http", dissect_xml_heur, xml_ns.hf_tag); heur_dissector_add("sip", dissect_xml_heur, xml_ns.hf_tag); - heur_dissector_add("media", dissect_xml_heur, xml_ns.hf_tag); + heur_dissector_add("media", dissect_xml_heur, xml_ns.hf_tag); } } @@ -1192,7 +1192,7 @@ proto_register_xml(void) { &ett_dtd, &ett_xmpli }; - + static hf_register_info hf_base[] = { { &hf_xmlpi, {"XMLPI", "xml.xmlpi", FT_STRING, BASE_NONE, NULL, 0, "", HFILL }}, { &hf_comment, {"Comment", "xml.comment", FT_STRING, BASE_NONE, NULL, 0, "", HFILL }}, @@ -1210,26 +1210,26 @@ proto_register_xml(void) { g_array_append_vals(hf_arr,hf_base,array_length(hf_base)); g_array_append_vals(ett_arr,ett_base,array_length(ett_base)); - + init_xml_names(); xml_ns.hf_tag = proto_register_protocol("eXtensible Markup Language", "XML", xml_ns.name); proto_register_field_array(xml_ns.hf_tag, (hf_register_info*)hf_arr->data, hf_arr->len); proto_register_subtree_array((gint**)ett_arr->data, ett_arr->len); - + xml_module = prefs_register_protocol(xml_ns.hf_tag,apply_prefs); prefs_register_bool_preference(xml_module, "heuristic", "Use Heuristics", "Try to recognize XML for unknown media types", &pref_heuristic); - + g_array_free(hf_arr,FALSE); g_array_free(ett_arr,TRUE); - + register_dissector("xml", dissect_xml, xml_ns.hf_tag); - + init_xml_parser(); - + } static void add_dissector_media(gpointer k, gpointer v _U_, gpointer p _U_) { @@ -1239,9 +1239,9 @@ static void add_dissector_media(gpointer k, gpointer v _U_, gpointer p _U_) { void proto_reg_handoff_xml(void) { - + xml_handle = find_dissector("xml"); - + g_hash_table_foreach(media_types,add_dissector_media,NULL); - + } |