paquet-mq: Eliminiate proto_tree_add_text
Eliminate proto_tree_add_text for Expert Info Improve PCF Parameters numeric value display Change-Id: Ibc259ba05d0591d434e7638d91d6943101d45305 Reviewed-on: https://code.wireshark.org/review/5080 Reviewed-by: Robert Grange <robionekenobi@bluewin.ch> Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
This commit is contained in:
parent
d550b17984
commit
7f3f4a5307
|
@ -99,7 +99,7 @@ static gint ett_mqpcf_cfh = -1;
|
|||
|
||||
static guint32 dissect_mqpcf_getDigits(guint uCnt)
|
||||
{
|
||||
return (guint) log10(uCnt) + 1;
|
||||
return (guint32)(log10( (double)uCnt ) + 1);
|
||||
}
|
||||
/*
|
||||
* Here we get a special value_string, that return another value_string
|
||||
|
@ -135,12 +135,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]: %8d-%s", hfinfo->name, iDigit, iCnt, uVal, pVal);
|
||||
"%s[%*d]: %8x-(%9d)-%s", hfinfo->name, iDigit, iCnt, uVal, uVal, pVal);
|
||||
}
|
||||
else
|
||||
{
|
||||
proto_tree_add_int_format(tree, hfindex, tvb, offset, 4, uVal,
|
||||
"%s[%*d]: %8x-%d", hfinfo->name, iDigit, iCnt, uVal, uVal);
|
||||
"%s[%*d]: %8x-(%9d)", hfinfo->name, iDigit, iCnt, uVal, uVal);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -148,12 +148,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,
|
||||
"%8d-%s", uVal, pVal);
|
||||
"%8x-(%9d)-%s", uVal, uVal, pVal);
|
||||
}
|
||||
else
|
||||
{
|
||||
proto_tree_add_int_format_value(tree, hfindex, tvb, offset, 4, uVal,
|
||||
"%8x-%d", uVal, uVal);
|
||||
"%8x-(%9d)", uVal, uVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -193,8 +193,7 @@ static void dissect_mqpcf_parm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *mq
|
|||
uLen = tvb_get_guint32_endian(tvb, xOfs + 4, bLittleEndian);
|
||||
if (uLen < 16)
|
||||
{
|
||||
ti = proto_tree_add_text(mq_tree, tvb, xOfs, 16, sPrmCnt, uLen, uCnt);
|
||||
expert_add_info(pinfo, ti, &ei_mq_pcf_PrmCnt);
|
||||
proto_tree_add_expert_format(tree, pinfo, &ei_mq_pcf_PrmCnt, tvb, xOfs, 16, sPrmCnt, uLen, uCnt);
|
||||
break;
|
||||
}
|
||||
uCnt++;
|
||||
|
@ -212,8 +211,7 @@ static void dissect_mqpcf_parm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *mq
|
|||
uLen = tvb_get_guint32_endian(tvb, offset + 4, bLittleEndian);
|
||||
if (uLen == 0)
|
||||
{
|
||||
ti = proto_tree_add_text(mq_tree, tvb, offset, 12, sPrmLn0, u+1, uCount);
|
||||
expert_add_info(pinfo, ti, &ei_mq_pcf_prmln0);
|
||||
proto_tree_add_expert_format(tree, pinfo, &ei_mq_pcf_prmln0, tvb, offset, 12, sPrmLn0, u+1, uCount);
|
||||
u = uCount;
|
||||
break;
|
||||
}
|
||||
|
@ -245,16 +243,18 @@ static void dissect_mqpcf_parm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *mq
|
|||
uVal = tvb_get_guint32_endian(tvb, offset + uLenF, bLittleEndian);
|
||||
if (bParse)
|
||||
pVal = dissect_mqpcf_parm_getintval(uPrm, uVal);
|
||||
|
||||
if (pVal)
|
||||
{
|
||||
tree = proto_tree_add_subtree_format(mq_tree, tvb, offset, uLen, ett_mqpcf_prm, NULL,
|
||||
"%s %d-%s", strPrm, uVal, pVal);
|
||||
"%s %8x-(%9d) %s", strPrm, uVal, uVal, pVal);
|
||||
}
|
||||
else
|
||||
{
|
||||
tree = proto_tree_add_subtree_format(mq_tree, tvb, offset, uLen, ett_mqpcf_prm, NULL,
|
||||
"%s %8x-%d", strPrm, uVal, uVal);
|
||||
"%s %8x-(%9d)", strPrm, uVal, uVal);
|
||||
}
|
||||
|
||||
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);
|
||||
proto_tree_add_item(tree, (bParse) ? hf_mq_pcf_prmid : hf_mq_pcf_prmidnovals, tvb, offset + 8, 4, bLittleEndian);
|
||||
|
@ -273,7 +273,7 @@ static void dissect_mqpcf_parm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *mq
|
|||
if (*sStr)
|
||||
strip_trailing_blanks(sStr, uSLn);
|
||||
if (*sStr)
|
||||
format_text_chr(sStr, strlen(sStr), '.');
|
||||
format_text_chr(sStr, strlen((const char *)sStr), '.');
|
||||
|
||||
tree = proto_tree_add_subtree_format(mq_tree, tvb, offset, uLen, ett_mqpcf_prm, NULL, "%s %s", strPrm, sStr);
|
||||
|
||||
|
@ -310,8 +310,7 @@ static void dissect_mqpcf_parm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *mq
|
|||
}
|
||||
if (u2 != uCnt)
|
||||
{
|
||||
ti = proto_tree_add_text(tree, tvb, offset, uLen, sMaxLst, u2, uCnt);
|
||||
expert_add_info(pinfo, ti, &ei_mq_pcf_MaxInt);
|
||||
proto_tree_add_expert_format(tree, pinfo, &ei_mq_pcf_MaxInt, tvb, offset, (uCnt- u2) * 4, sMaxLst, u2, uCnt);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -347,16 +346,15 @@ static void dissect_mqpcf_parm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *mq
|
|||
if (*sStr)
|
||||
strip_trailing_blanks(sStr, uSLn);
|
||||
if (*sStr)
|
||||
format_text_chr(sStr, strlen(sStr), '.');
|
||||
format_text_chr(sStr, strlen((const char *)sStr), '.');
|
||||
|
||||
proto_tree_add_string_format(tree, hf_mq_pcf_stringlist, tvb, offset, uSLn, sStr,
|
||||
proto_tree_add_string_format(tree, hf_mq_pcf_stringlist, tvb, offset, uSLn, (const char *)sStr,
|
||||
"%s[%*d]: %s", hfinfo->name, uDigit, u2+1, sStr);
|
||||
offset += uSLn;
|
||||
}
|
||||
if (u2 != uCnt)
|
||||
{
|
||||
ti = proto_tree_add_text(tree, tvb, offset, uLen, sMaxLst, u2, uCnt);
|
||||
expert_add_info(pinfo, ti, &ei_mq_pcf_MaxStr);
|
||||
proto_tree_add_expert_format(tree, pinfo, &ei_mq_pcf_MaxStr, tvb, offset,(uCnt - u2) * uSLn, sMaxLst, u2, uCnt);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -377,8 +375,8 @@ static void dissect_mqpcf_parm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *mq
|
|||
uSLn = tvb_get_guint32_endian(tvb, offset + uLenF, bLittleEndian);
|
||||
if (uSLn)
|
||||
{
|
||||
guint8 *sStrA = format_text_chr(tvb_get_string_enc(wmem_packet_scope(), tvb, offset + uLenF + 4, uSLn, ENC_ASCII) , uSLn, '.');
|
||||
guint8 *sStrE = format_text_chr(tvb_get_string_enc(wmem_packet_scope(), tvb, offset + uLenF + 4, uSLn, ENC_EBCDIC), uSLn, '.');
|
||||
guint8 *sStrA = (guint8 *)format_text_chr(tvb_get_string_enc(wmem_packet_scope(), tvb, offset + uLenF + 4, uSLn, ENC_ASCII) , uSLn, '.');
|
||||
guint8 *sStrE = (guint8 *)format_text_chr(tvb_get_string_enc(wmem_packet_scope(), tvb, offset + uLenF + 4, uSLn, ENC_EBCDIC), uSLn, '.');
|
||||
if (uSLn > 35)
|
||||
{
|
||||
tree = proto_tree_add_subtree_format(mq_tree, tvb, offset, uLen, ett_mqpcf_prm, NULL,
|
||||
|
@ -414,8 +412,8 @@ static void dissect_mqpcf_parm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *mq
|
|||
uOpe = tvb_get_guint32_endian(tvb, offset + uLenF , bLittleEndian);
|
||||
uVal = tvb_get_guint32_endian(tvb, offset + uLenF + 4, bLittleEndian);
|
||||
|
||||
tree = proto_tree_add_subtree_format(mq_tree, tvb, offset, uLen, ett_mqpcf_prm, NULL, "%s %s %d",
|
||||
strPrm, val_to_str(uOpe, GET_VALSV(FilterOP), " Unknown (0x%02x)")+7, uVal);
|
||||
tree = proto_tree_add_subtree_format(mq_tree, tvb, offset, uLen, ett_mqpcf_prm, NULL, "%s %s %8x-(%9d)",
|
||||
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);
|
||||
proto_tree_add_item(tree, hf_mq_pcf_prmlen , tvb, offset + 4, 4, bLittleEndian);
|
||||
|
@ -433,7 +431,7 @@ static void dissect_mqpcf_parm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *mq
|
|||
uOpe = tvb_get_guint32_endian(tvb, offset + uLenF, bLittleEndian);
|
||||
uCCS = tvb_get_guint32_endian(tvb, offset + uLenF + 4, bLittleEndian);
|
||||
uSLn = tvb_get_guint32_endian(tvb, offset + uLenF + 8, bLittleEndian);
|
||||
sStr = format_text_chr(tvb_get_string_enc(wmem_packet_scope(), tvb, offset + uLenF + 12, uSLn, (uCCS != 500) ? ENC_ASCII : ENC_EBCDIC), uSLn, '.');
|
||||
sStr = (guint8 *)format_text_chr(tvb_get_string_enc(wmem_packet_scope(), tvb, offset + uLenF + 12, uSLn, (uCCS != 500) ? ENC_ASCII : ENC_EBCDIC), uSLn, '.');
|
||||
strip_trailing_blanks(sStr, uSLn);
|
||||
|
||||
tree = proto_tree_add_subtree_format(mq_tree, tvb, offset, uLen, ett_mqpcf_prm, NULL, "%s %s %s",
|
||||
|
@ -456,8 +454,8 @@ static void dissect_mqpcf_parm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *mq
|
|||
uSLn = tvb_get_guint32_endian(tvb, offset + uLenF + 4, bLittleEndian);
|
||||
if (uSLn)
|
||||
{
|
||||
guint8 *sStrA = format_text_chr(tvb_get_string_enc(wmem_packet_scope(), tvb, offset + uLenF + 8, uSLn, ENC_ASCII), uSLn, '.');
|
||||
guint8 *sStrE = format_text_chr(tvb_get_string_enc(wmem_packet_scope(), tvb, offset + uLenF + 8, uSLn, ENC_EBCDIC), uSLn, '.');
|
||||
guint8 *sStrA = (guint8 *)format_text_chr(tvb_get_string_enc(wmem_packet_scope(), tvb, offset + uLenF + 8, uSLn, ENC_ASCII), uSLn, '.');
|
||||
guint8 *sStrE = (guint8 *)format_text_chr(tvb_get_string_enc(wmem_packet_scope(), tvb, offset + uLenF + 8, uSLn, ENC_EBCDIC), uSLn, '.');
|
||||
tree = proto_tree_add_subtree_format(mq_tree, tvb, offset, uLen, ett_mqpcf_prm, NULL, "%s %s A(%s) E(%s)",
|
||||
strPrm, val_to_str(uOpe, GET_VALSV(FilterOP), " Unknown (0x%02x)")+7, sStrA, sStrE);
|
||||
}
|
||||
|
@ -526,13 +524,13 @@ static void dissect_mqpcf_parm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *mq
|
|||
{
|
||||
uVal64 = tvb_get_guint64_endian(tvb, offset, bLittleEndian);
|
||||
proto_tree_add_int64_format(tree, hf_mq_pcf_int64list, tvb, offset, 8, uVal64,
|
||||
"%s[%*d]: %" G_GINT64_MODIFIER "d", hfinfo->name, uDigit, u2+1, uVal64);
|
||||
"%s[%*d]: %" G_GINT64_MODIFIER "x (%" G_GINT64_MODIFIER "d)",
|
||||
hfinfo->name, uDigit, u2+1, uVal64, uVal64);
|
||||
offset += 8;
|
||||
}
|
||||
if (u2 != uCnt)
|
||||
{
|
||||
ti = proto_tree_add_text(tree, tvb, offset, uLen, sMaxLst, u2, uCnt);
|
||||
expert_add_info(pinfo, ti, &ei_mq_pcf_MaxI64);
|
||||
proto_tree_add_expert_format(tree, pinfo, &ei_mq_pcf_MaxI64, tvb, offset, (uCnt - u2) * 8, sMaxLst, u2, uCnt);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -541,8 +539,7 @@ static void dissect_mqpcf_parm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *mq
|
|||
}
|
||||
if (u != uCount)
|
||||
{
|
||||
ti = proto_tree_add_text(mq_tree, tvb, offset, uLen, sMaxPrm, u, uCount);
|
||||
expert_add_info(pinfo, ti, &ei_mq_pcf_MaxPrm);
|
||||
proto_tree_add_expert_format(mq_tree, pinfo, &ei_mq_pcf_MaxPrm, tvb, offset, tvb_reported_length_remaining(tvb, offset), sMaxPrm, u, uCount);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4035,11 +4035,15 @@ static gboolean dissect_mq_heur_http(tvbuff_t *tvb, packet_info *pinfo, proto
|
|||
return dissect_mq_heur(tvb, pinfo, tree, MQ_XPT_HTTP, NULL);
|
||||
}
|
||||
/*
|
||||
function used to compare value_string when sorting the arry
|
||||
function used to compare value_string when sorting the array
|
||||
*/
|
||||
static int _mq_vals_fncomp(const void *e1, const void *e2)
|
||||
{
|
||||
return (((value_string *)e1)->value < ((value_string *)e2)->value) ? -1 : (((value_string *)e1)->value > ((value_string *)e2)->value) ? 1 : 0;
|
||||
if (((const value_string *)e1)->value < ((const value_string *)e2)->value)
|
||||
return -1;
|
||||
if (((const value_string *)e1)->value > ((const value_string *)e2)->value)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
if the value_string_ext is not yet initialized, try first to
|
||||
|
@ -4049,7 +4053,8 @@ static void _try_mq_vals_sort(value_string_ext *pExt)
|
|||
{
|
||||
if (pExt->_vs_match2 == _try_val_to_str_ext_init)
|
||||
{
|
||||
qsort((void *)pExt->_vs_p, pExt->_vs_num_entries, sizeof(value_string), _mq_vals_fncomp);
|
||||
qsort((void *)(value_string_ext *)pExt->_vs_p,
|
||||
pExt->_vs_num_entries, sizeof(value_string), _mq_vals_fncomp);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4756,6 +4761,7 @@ void proto_reg_handoff_mq(void)
|
|||
Sort the value_string_ext to improve the use of bsearch
|
||||
in case the string_value is not sorted by value when created
|
||||
*/
|
||||
|
||||
_try_mq_vals_sort(GET_VALS_EXTP(mqrc));
|
||||
_try_mq_vals_sort(GET_VALS_EXTP(mqcmd));
|
||||
_try_mq_vals_sort(GET_VALS_EXTP(PrmId));
|
||||
|
|
|
@ -2775,6 +2775,7 @@ typedef struct _mq_parm_t
|
|||
#define MQ_MQRCCF_CFIL_DUPLICATE_VALUE 3026
|
||||
#define MQ_MQRCCF_CFIL_COUNT_ERROR 3027
|
||||
#define MQ_MQRCCF_CFIL_LENGTH_ERROR 3028
|
||||
#define MQ_MQRCCF_QUIESCE_VALUE_ERROR 3029
|
||||
#define MQ_MQRCCF_MODE_VALUE_ERROR 3029
|
||||
#define MQ_MQRCCF_MSG_SEQ_NUMBER_ERROR 3030
|
||||
#define MQ_MQRCCF_PING_DATA_COUNT_ERROR 3031
|
||||
|
|
Loading…
Reference in New Issue