From e131717d83432c79309bfb0b9c4ff578b48f8703 Mon Sep 17 00:00:00 2001 From: robionekenobi Date: Fri, 27 Nov 2020 09:05:45 +0100 Subject: packet-mq: Improve MQINQ Display Improve the display of MQINQ Segment, by adding dec/hex/Name of selector in MQINQ/MQINQ_REPLY and trying to display dec/hex/Name value of Integer Value when possible in MQINQ_REPLY --- epan/dissectors/packet-mq-pcf.c | 20 ++++++++++---------- epan/dissectors/packet-mq.c | 28 +++++++++++++++++++++++++--- epan/dissectors/packet-mq.h | 6 +++--- 3 files changed, 38 insertions(+), 16 deletions(-) diff --git a/epan/dissectors/packet-mq-pcf.c b/epan/dissectors/packet-mq-pcf.c index 18168411e4..b3fe22d3f2 100644 --- a/epan/dissectors/packet-mq-pcf.c +++ b/epan/dissectors/packet-mq-pcf.c @@ -98,7 +98,7 @@ static guint32 dissect_mqpcf_getDigits(guint uCnt) * to get val_to_str value from the value of a parameter on a more * easier way than using switch cases. */ -static const guint8 *dissect_mqpcf_parm_getintval(guint uPrm, guint uVal) +const guint8 *dissect_mqpcf_parm_getintval(guint uPrm, guint uVal) { const value_string *pVs; pVs = (const value_string *)try_val_to_str_ext(uPrm, GET_VALS_EXTP(MQCFINT_Parse)); @@ -127,12 +127,12 @@ static void dissect_mqpcf_parm_int(tvbuff_t *tvb, proto_tree *tree, guint offset if (pVal) { proto_tree_add_int_format(tree, hfindex, tvb, offset, 4, uVal, - "%s[%*d]: %8x-(%9d)-%s", hfinfo->name, iDigit, iCnt, uVal, uVal, pVal); + "%s[%*d]: 0x%08x (%d) %s", hfinfo->name, iDigit, iCnt, uVal, uVal, pVal); } else { proto_tree_add_int_format(tree, hfindex, tvb, offset, 4, uVal, - "%s[%*d]: %8x-(%9d)", hfinfo->name, iDigit, iCnt, uVal, uVal); + "%s[%*d]: 0x%08x (%d)", hfinfo->name, iDigit, iCnt, uVal, uVal); } } else @@ -140,12 +140,12 @@ static void dissect_mqpcf_parm_int(tvbuff_t *tvb, proto_tree *tree, guint offset if (pVal) { proto_tree_add_int_format_value(tree, hfindex, tvb, offset, 4, uVal, - "%8x-(%9d)-%s", uVal, uVal, pVal); + "0x%08x (%d) %s", uVal, uVal, pVal); } else { proto_tree_add_int_format_value(tree, hfindex, tvb, offset, 4, uVal, - "%8x-(%9d)", uVal, uVal); + "0x%08x (%d)", uVal, uVal); } } } @@ -271,12 +271,12 @@ guint32 dissect_mqpcf_parm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *mq_tre if (pVal) { tree = proto_tree_add_subtree_format(mq_tree, tvb, offset, uLen, ett_mqpcf_prm, NULL, - "%s %8x-(%9d) %s", strPrm, uVal, uVal, pVal); + "%s 0x%08x (%d) %s", strPrm, uVal, uVal, pVal); } else { tree = proto_tree_add_subtree_format(mq_tree, tvb, offset, uLen, ett_mqpcf_prm, NULL, - "%s %8x-(%9d)", strPrm, uVal, uVal); + "%s 0x%08x (%d)", strPrm, uVal, uVal); } proto_tree_add_item(tree, hf_mq_pcf_prmtyp, tvb, offset, 4, bLittleEndian); @@ -449,7 +449,7 @@ guint32 dissect_mqpcf_parm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *mq_tre uOpe = tvb_get_guint32(tvb, offset + uLenF, bLittleEndian); uVal = tvb_get_guint32(tvb, offset + uLenF + 4, bLittleEndian); - tree = proto_tree_add_subtree_format(mq_tree, tvb, offset, uLen, ett_mqpcf_prm, NULL, "%s %s %8x-(%9d)", + tree = proto_tree_add_subtree_format(mq_tree, tvb, offset, uLen, ett_mqpcf_prm, NULL, "%s %s 0x%08x (%d)", strPrm, val_to_str(uOpe, GET_VALSV(FilterOP), " Unknown (0x%02x)") + 7, uVal, uVal); proto_tree_add_item(tree, hf_mq_pcf_prmtyp, tvb, offset, 4, bLittleEndian); @@ -529,7 +529,7 @@ guint32 dissect_mqpcf_parm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *mq_tre { uVal64 = tvb_get_guint64(tvb, offset + uLenF + 4, bLittleEndian); tree = proto_tree_add_subtree_format(mq_tree, tvb, offset, uLen, ett_mqpcf_prm, NULL, - "%s %" G_GINT64_MODIFIER "x (%" G_GINT64_MODIFIER "d)", strPrm, uVal64, uVal64); + "%s 0x%" G_GINT64_MODIFIER "x (%" G_GINT64_MODIFIER "d)", strPrm, uVal64, uVal64); proto_tree_add_item(tree, hf_mq_pcf_prmtyp, tvb, offset, 4, bLittleEndian); proto_tree_add_item(tree, hf_mq_pcf_prmlen, tvb, offset + 4, 4, bLittleEndian); @@ -561,7 +561,7 @@ guint32 dissect_mqpcf_parm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *mq_tre { uVal64 = tvb_get_guint64(tvb, offset, bLittleEndian); proto_tree_add_int64_format(tree, hf_mq_pcf_int64list, tvb, offset, 8, uVal64, - "%s[%*d]: %" G_GINT64_MODIFIER "x (%" G_GINT64_MODIFIER "d)", + "%s[%*d]: 0x%" G_GINT64_MODIFIER "x (%" G_GINT64_MODIFIER "d)", hfinfo->name, uDigit, u2 + 1, uVal64, uVal64); offset += 8; } diff --git a/epan/dissectors/packet-mq.c b/epan/dissectors/packet-mq.c index 865d1673dd..83cc3f9906 100644 --- a/epan/dissectors/packet-mq.c +++ b/epan/dissectors/packet-mq.c @@ -2644,9 +2644,16 @@ static void dissect_mq_pdu(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree) iOffsetINQ = 12; if (tvb_reported_length_remaining(tvb, offset + iOffsetINQ) >= iNbSelectors * 4) { + guint _posSel = offset + iOffsetINQ; + guint _posSelE = _posSel + iNbSelectors * 4 + 4; + const guint8* _pVal = NULL; for (iSelector = 0; iSelector < iNbSelectors; iSelector++) { - proto_tree_add_item(mq_tree, hf_mq_inq_sel, tvb, offset + iOffsetINQ + iSelector * 4, 4, p_mq_parm->mq_int_enc); + //proto_tree_add_item(mq_tree, hf_mq_inq_sel, tvb, offset + iOffsetINQ + iSelector * 4, 4, p_mq_parm->mq_int_enc); + guint _Val = tvb_get_guint32(tvb, offset + iOffsetINQ + iSelector* 4, p_mq_parm->mq_int_enc); + _pVal = (const guint8*)try_val_to_str_ext(_Val, GET_VALS_EXTP(selector)); + proto_tree_add_uint_format(mq_tree, hf_mq_inq_sel, tvb, offset + iOffsetINQ + iSelector * 4, 4, 0, + "Selector........: 0x%08x (%d) %s", _Val, _Val, _pVal); } iOffsetINQ += iNbSelectors * 4; if (p_mq_parm->mq_opcode == MQ_TST_MQINQ_REPLY || p_mq_parm->mq_opcode == MQ_TST_MQSET) @@ -2656,9 +2663,24 @@ static void dissect_mq_pdu(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree) if (tvb_reported_length_remaining(tvb, offset + iOffsetINQ) >= iSizeINQValues) { gint iInteger; + guint _lVal; + guint _lSel; for (iInteger = 0; iInteger < iNbIntegers; iInteger++) { - proto_tree_add_item(mq_tree, hf_mq_inq_intvalue, tvb, offset + iOffsetINQ + iInteger * 4, 4, p_mq_parm->mq_int_enc); + _lSel = tvb_get_guint32(tvb, _posSel, p_mq_parm->mq_int_enc); + while (_posSel < _posSelE && (_lSel < MQ_MQIA_FIRST || _lSel > MQ_MQIA_LAST)) + { + _posSel += 4; + _lSel = tvb_get_guint32(tvb, _posSel, p_mq_parm->mq_int_enc); + } + _lVal = tvb_get_guint32(tvb, offset + iOffsetINQ + iInteger * 4, p_mq_parm->mq_int_enc); + _pVal = dissect_mqpcf_parm_getintval(_lSel, _lVal); + _posSel += 4; + if (_pVal) + proto_tree_add_uint_format(mq_tree, hf_mq_inq_intvalue, tvb, offset + iOffsetINQ + iInteger * 4, 4, 0, + "Integer value...: 0x%08x (%d) %s", _lVal, _lVal, _pVal); + else + proto_tree_add_item(mq_tree, hf_mq_inq_intvalue, tvb, offset + iOffsetINQ + iInteger * 4, 4, p_mq_parm->mq_int_enc); } iOffsetINQ += iNbIntegers * 4; if (iCharLen != 0) @@ -4153,7 +4175,7 @@ void proto_register_mq(void) {&hf_mq_inq_nbsel, {"Selector count..", "mq.inq.nbsel", FT_UINT32, BASE_DEC, NULL, 0x0, "INQ Selector count", HFILL}}, {&hf_mq_inq_nbint, {"Integer count...", "mq.inq.nbint", FT_UINT32, BASE_DEC, NULL, 0x0, "INQ Integer count", HFILL}}, {&hf_mq_inq_charlen, {"Character length", "mq.inq.charlen", FT_UINT32, BASE_DEC, NULL, 0x0, "INQ Character length", HFILL}}, - {&hf_mq_inq_sel, {"Selector........", "mq.inq.sel", FT_UINT32, BASE_DEC | BASE_EXT_STRING, GET_VALS_EXTP(selector), 0x0, "INQ Selector", HFILL}}, + {&hf_mq_inq_sel, {"Selector........", "mq.inq.sel", FT_UINT32, BASE_HEX_DEC | BASE_EXT_STRING, GET_VALS_EXTP(selector), 0x0, "INQ Selector", HFILL}}, {&hf_mq_inq_intvalue, {"Integer value...", "mq.inq.intvalue", FT_UINT32, BASE_DEC, NULL, 0x0, "INQ Integer value", HFILL}}, {&hf_mq_inq_charvalues, {"Char values.....", "mq.inq.charvalues", FT_STRING, STR_UNICODE, NULL, 0x0, "INQ Character values", HFILL}}, diff --git a/epan/dissectors/packet-mq.h b/epan/dissectors/packet-mq.h index 70107b0cc4..b6b69960ae 100644 --- a/epan/dissectors/packet-mq.h +++ b/epan/dissectors/packet-mq.h @@ -5580,10 +5580,10 @@ typedef struct _mq_parm_t #endif -extern gint32 strip_trailing_blanks(guint8 *a_str, - guint32 a_size); +extern gint32 strip_trailing_blanks(guint8 *a_str, guint32 a_size); +extern const guint8* dissect_mqpcf_parm_getintval(guint uPrm, guint uVal); extern guint32 dissect_mqpcf_parm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *mq_tree, - guint offset, guint32 uCount, guint bLittleEndian, gboolean bParse); + guint offset, guint32 uCount, guint bLittleEndian, gboolean bParse); extern int dissect_mqpcf_parm_grp(tvbuff_t* tvb, packet_info* pinfo, proto_tree* mq_tree, guint offset, guint bLittleEndian, gboolean bParse); -- cgit v1.2.3