diff options
88 files changed, 556 insertions, 833 deletions
diff --git a/asn1/gsmmap/packet-gsm_map-template.c b/asn1/gsmmap/packet-gsm_map-template.c index 5052f3dd41..2c5d9a86a8 100644 --- a/asn1/gsmmap/packet-gsm_map-template.c +++ b/asn1/gsmmap/packet-gsm_map-template.c @@ -151,27 +151,6 @@ unpack_digits(tvbuff_t *tvb, int offset){ #include "packet-gsm_map-fn.c" -/* Stuff included from the "old" packet-gsm_map.c for tapping purposes */ -static gchar * -my_match_strval(guint32 val, const value_string *vs, gint *idx) -{ - gint i = 0; - - while (vs[i].strptr) { - if (vs[i].value == val) - { - *idx = i; - return(vs[i].strptr); - } - - i++; - } - - *idx = -1; - return(NULL); -} -/* End includes from old" packet-gsm_map.c */ - const value_string gsm_map_opr_code_strings[] = { { 2, "updateLocation" }, { 3, "cancelLocation" }, @@ -1053,10 +1032,9 @@ dissect_gsm_map(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) { proto_item *item=NULL; proto_tree *tree=NULL; - /* Used for gsm_map TAP */ - static gsm_map_tap_rec_t tap_rec; - gint op_idx; - gchar *str = NULL; + /* Used for gsm_map TAP */ + static gsm_map_tap_rec_t tap_rec; + gint op_idx; if (check_col(pinfo->cinfo, COL_PROTOCOL)) @@ -1064,26 +1042,24 @@ dissect_gsm_map(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) col_set_str(pinfo->cinfo, COL_PROTOCOL, "GSM MAP"); } - top_tree = parent_tree; - dissector_add("tcap.itu_ssn",pinfo->match_port, map_handle); + top_tree = parent_tree; + dissector_add("tcap.itu_ssn",pinfo->match_port, map_handle); /* create display subtree for the protocol */ if(parent_tree){ - item = proto_tree_add_item(parent_tree, proto_gsm_map, tvb, 0, -1, FALSE); - tree = proto_item_add_subtree(item, ett_gsm_map); + item = proto_tree_add_item(parent_tree, proto_gsm_map, tvb, 0, -1, FALSE); + tree = proto_item_add_subtree(item, ett_gsm_map); } dissect_gsm_map_GSMMAPPDU(FALSE, tvb, 0, pinfo, tree, -1); - str = my_match_strval(opcode, gsm_map_opr_code_strings, &op_idx); - - tap_rec.invoke = FALSE; - if ( gsmmap_pdu_type == 1 ) - tap_rec.invoke = TRUE; - tap_rec.opr_code_idx = op_idx; - tap_rec.size = gsm_map_pdu_size; - - tap_queue_packet(gsm_map_tap, pinfo, &tap_rec); + match_strval_idx(opcode, gsm_map_opr_code_strings, &op_idx); + tap_rec.invoke = FALSE; + if ( gsmmap_pdu_type == 1 ) + tap_rec.invoke = TRUE; + tap_rec.opr_code_idx = op_idx; + tap_rec.size = gsm_map_pdu_size; + tap_queue_packet(gsm_map_tap, pinfo, &tap_rec); } static const value_string ssCode_vals[] = { diff --git a/asn1/h245/packet-h245-template.c b/asn1/h245/packet-h245-template.c index 66212567c8..ddb6b77ea7 100644 --- a/asn1/h245/packet-h245-template.c +++ b/asn1/h245/packet-h245-template.c @@ -200,7 +200,7 @@ static const value_string h245_AudioCapability_short_vals[] = { /* To put the codec type only in COL_INFO when an OLC is read */ -char* codec_type = NULL; +const char* codec_type = NULL; static char standard_oid_str[256]; static guint32 ipv4_address; static guint32 ipv4_port; diff --git a/epan/dissectors/packet-aarp.c b/epan/dissectors/packet-aarp.c index 9c68873009..32799253f7 100644 --- a/epan/dissectors/packet-aarp.c +++ b/epan/dissectors/packet-aarp.c @@ -157,7 +157,7 @@ dissect_aarp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { guint16 ar_op; proto_tree *aarp_tree; proto_item *ti; - gchar *op_str; + const gchar *op_str; int sha_offset, spa_offset, tha_offset, tpa_offset; const guint8 *sha_val, *spa_val, *tha_val, *tpa_val; gchar *sha_str, *spa_str, *tha_str, *tpa_str; diff --git a/epan/dissectors/packet-aim.c b/epan/dissectors/packet-aim.c index 6bc69b7336..5d57c2b67a 100644 --- a/epan/dissectors/packet-aim.c +++ b/epan/dissectors/packet-aim.c @@ -666,7 +666,8 @@ static void dissect_aim_newconn(tvbuff_t *tvb, packet_info *pinfo, int dissect_aim_snac_error(tvbuff_t *tvb, packet_info *pinfo, proto_tree *aim_tree) { - char *name; + const char *name; + if ((name = match_strval(tvb_get_ntohs(tvb, 0), aim_snac_errors)) != NULL) { if (check_col(pinfo->cinfo, COL_INFO)) col_add_fstr(pinfo->cinfo, COL_INFO, name); @@ -681,12 +682,12 @@ int dissect_aim_snac_error(tvbuff_t *tvb, packet_info *pinfo, int dissect_aim_userinfo(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *tree) { - offset = dissect_aim_buddyname(tvb, pinfo, offset, tree); + offset = dissect_aim_buddyname(tvb, pinfo, offset, tree); proto_tree_add_item(tree, hf_aim_userinfo_warninglevel, tvb, offset, 2, FALSE); offset += 2; - return dissect_aim_tlv_list(tvb, pinfo, offset, tree, onlinebuddy_tlvs); + return dissect_aim_tlv_list(tvb, pinfo, offset, tree, onlinebuddy_tlvs); } int dissect_aim_fnac_flags(tvbuff_t *tvb, int offset, int len, proto_item *ti, guint16 flags) diff --git a/epan/dissectors/packet-ajp13.c b/epan/dissectors/packet-ajp13.c index 8683f7e1aa..6ad7ccc437 100644 --- a/epan/dissectors/packet-ajp13.c +++ b/epan/dissectors/packet-ajp13.c @@ -268,7 +268,7 @@ get_nstring(tvbuff_t *tvb, gint offset, guint8* cbuf, size_t cbuflen) static void display_rsp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ajp13_tree) { - gchar* msg_code = NULL; + const gchar* msg_code = NULL; int pos = 0; guint8 mcode = 0; char mcode_buf[1024]; @@ -346,7 +346,7 @@ display_rsp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ajp13_tree) char hval[8192]; guint16 hval_len; int orig_pos = pos; - gchar* hname = NULL; + const gchar* hname = NULL; int dp = 0; int cl = 0; guint8 hname_bytes[1024]; @@ -478,7 +478,7 @@ display_req_forward(tvbuff_t *tvb, packet_info *pinfo, */ cod = tvb_get_guint8(tvb, 4); if (ajp13_tree) { - gchar* msg_code = NULL; + const gchar* msg_code = NULL; char mcode_buf[1024]; msg_code = val_to_str(cod, mtype_codes, "UNKNOWN"); sprintf(mcode_buf, "(%d) %s", cod, msg_code); @@ -489,7 +489,7 @@ display_req_forward(tvbuff_t *tvb, packet_info *pinfo, /* HTTP METHOD (ENCODED AS INTEGER) */ { - gchar* meth_code = NULL; + const gchar* meth_code = NULL; meth = tvb_get_guint8(tvb, pos); meth_code = val_to_str(meth, http_method_codes, "UNKNOWN"); if (ajp13_tree) { @@ -577,7 +577,7 @@ display_req_forward(tvbuff_t *tvb, packet_info *pinfo, char hval[8192]; guint16 hval_len; int orig_pos = pos; - gchar* hname = NULL; + const gchar* hname = NULL; int dp = 0; int cl = 0; guint8 hname_bytes[1024]; diff --git a/epan/dissectors/packet-alcap.c b/epan/dissectors/packet-alcap.c index cdf52f52b9..21b3217256 100644 --- a/epan/dissectors/packet-alcap.c +++ b/epan/dissectors/packet-alcap.c @@ -183,25 +183,6 @@ static const value_string msg_type_strings[] = { /* FUNCTIONS */ -static const gchar * -my_match_strval(guint32 val, const value_string *vs, gint *idx) -{ - gint i = 0; - - while (vs[i].strptr) { - if (vs[i].value == val) - { - *idx = i; - return(vs[i].strptr); - } - - i++; - } - - *idx = -1; - return(NULL); -} - /* * Ref. ITU-T Q.2630.1 (12/1999) * Section 7.4.1 @@ -1213,7 +1194,7 @@ dis_field_diagnostics(tvbuff_t *tvb, proto_tree *tree, guint *len, guint32 *offs */ oct = tvb_get_guint8(tvb, curr_offset); - str = my_match_strval(oct, msg_type_strings, &idx); + str = match_strval_idx(oct, msg_type_strings, &idx); proto_tree_add_none_format(subtree, hf_alcap_none, tvb, curr_offset, 1, (str == NULL) ? "Unknown message identifier" : str); @@ -1225,7 +1206,7 @@ dis_field_diagnostics(tvbuff_t *tvb, proto_tree *tree, guint *len, guint32 *offs { oct = tvb_get_guint8(tvb, curr_offset); - str = my_match_strval(oct, msg_parm_strings, &idx); + str = match_strval_idx(oct, msg_parm_strings, &idx); proto_tree_add_none_format(subtree, hf_alcap_none, tvb, curr_offset, 1, (str == NULL) ? "Unknown parameter" : str); @@ -1525,7 +1506,7 @@ dissect_alcap_parms(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint32 len parm = tvb_get_guint8(tvb, curr_offset); - str = my_match_strval(parm, msg_parm_strings, &idx); + str = match_strval_idx(parm, msg_parm_strings, &idx); if (str == NULL) { @@ -1606,7 +1587,7 @@ dissect_alcap_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *alcap_tree) msg_type = tvb_get_guint8(tvb, offset); - str = my_match_strval(msg_type, msg_type_strings, &idx); + str = match_strval_idx(msg_type, msg_type_strings, &idx); if (str == NULL) { diff --git a/epan/dissectors/packet-ansi_637.c b/epan/dissectors/packet-ansi_637.c index 142832c742..0f2291744f 100644 --- a/epan/dissectors/packet-ansi_637.c +++ b/epan/dissectors/packet-ansi_637.c @@ -275,27 +275,6 @@ decode_7_bits(tvbuff_t *tvb, guint32 *offset, guint8 num_fields, guint8 *last_oc *last_oct = (bit == 1) ? oct : oct2; } -static const gchar * -my_match_strval(guint32 val, const value_string *vs, gint *idx) -{ - gint i = 0; - - while (vs[i].strptr) - { - if (vs[i].value == val) - { - *idx = i; - return(vs[i].strptr); - } - - i++; - } - - *idx = -1; - return(NULL); -} - - /* PARAM FUNCTIONS */ #define EXTRANEOUS_DATA_CHECK(edc_len, edc_max_len) \ @@ -925,7 +904,7 @@ static void trans_param_tele_id(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset, gchar *add_string) { guint32 value; - gchar *str = NULL; + const gchar *str = NULL; EXACT_DATA_CHECK(len, 2); @@ -949,7 +928,7 @@ static void trans_param_srvc_cat(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset, gchar *add_string) { guint32 value; - gchar *str = NULL; + const gchar *str = NULL; EXACT_DATA_CHECK(len, 2); @@ -1498,7 +1477,7 @@ dissect_ansi_637_tele_param(tvbuff_t *tvb, proto_tree *tree, guint32 *offset) curr_offset = *offset; oct = tvb_get_guint8(tvb, curr_offset); - str = my_match_strval((guint32) oct, ansi_tele_param_strings, &idx); + str = match_strval_idx((guint32) oct, ansi_tele_param_strings, &idx); if (NULL == str) { @@ -1556,7 +1535,7 @@ dissect_ansi_637_tele_message(tvbuff_t *tvb, proto_tree *ansi_637_tree) guint32 curr_offset; guint32 msg_id; guint32 msg_type; - gchar *str = NULL; + const gchar *str = NULL; proto_item *item; proto_tree *subtree; @@ -1625,7 +1604,7 @@ dissect_ansi_637_tele(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { proto_item *ansi_637_item; proto_tree *ansi_637_tree = NULL; - gchar *str = NULL; + const gchar *str = NULL; if (check_col(pinfo->cinfo, COL_PROTOCOL)) { @@ -1673,7 +1652,7 @@ dissect_ansi_637_trans_param(tvbuff_t *tvb, proto_tree *tree, guint32 *offset) curr_offset = *offset; oct = tvb_get_guint8(tvb, curr_offset); - str = my_match_strval((guint32) oct, ansi_trans_param_strings, &idx); + str = match_strval_idx((guint32) oct, ansi_trans_param_strings, &idx); if (NULL == str) { @@ -1757,7 +1736,7 @@ dissect_ansi_637_trans(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) */ oct = tvb_get_guint8(tvb, 0); - str = my_match_strval(oct, ansi_trans_msg_type_strings, &idx); + str = match_strval_idx(oct, ansi_trans_msg_type_strings, &idx); if (NULL == str) { diff --git a/epan/dissectors/packet-ansi_683.c b/epan/dissectors/packet-ansi_683.c index de8cc6d140..02479fb8ea 100644 --- a/epan/dissectors/packet-ansi_683.c +++ b/epan/dissectors/packet-ansi_683.c @@ -80,27 +80,6 @@ static proto_tree *g_tree; /* FUNCTIONS */ -static const gchar * -my_match_strval(guint32 val, const value_string *vs, gint *idx) -{ - gint i = 0; - - while (vs[i].strptr) - { - if (vs[i].value == val) - { - *idx = i; - return(vs[i].strptr); - } - - i++; - } - - *idx = -1; - return(NULL); -} - - /* PARAM FUNCTIONS */ #define EXTRANEOUS_DATA_CHECK(edc_len, edc_max_len) \ @@ -1929,7 +1908,7 @@ dissect_ansi_683_for_message(tvbuff_t *tvb, proto_tree *ansi_683_tree) msg_type = tvb_get_guint8(tvb, 0); - str = my_match_strval(msg_type, for_msg_type_strings, &idx); + str = match_strval_idx(msg_type, for_msg_type_strings, &idx); if (str == NULL) { @@ -1959,7 +1938,7 @@ dissect_ansi_683_rev_message(tvbuff_t *tvb, proto_tree *ansi_683_tree) msg_type = tvb_get_guint8(tvb, 0); - str = my_match_strval(msg_type, rev_msg_type_strings, &idx); + str = match_strval_idx(msg_type, rev_msg_type_strings, &idx); if (str == NULL) { diff --git a/epan/dissectors/packet-ansi_801.c b/epan/dissectors/packet-ansi_801.c index 18cc4c2cfd..6277d1623a 100644 --- a/epan/dissectors/packet-ansi_801.c +++ b/epan/dissectors/packet-ansi_801.c @@ -80,27 +80,6 @@ static proto_tree *g_tree; /* FUNCTIONS */ -static const gchar * -my_match_strval(guint32 val, const value_string *vs, gint *idx) -{ - gint i = 0; - - while (vs[i].strptr) - { - if (vs[i].value == val) - { - *idx = i; - return(vs[i].strptr); - } - - i++; - } - - *idx = -1; - return(NULL); -} - - /* PARAM FUNCTIONS */ #define EXTRANEOUS_DATA_CHECK(edc_len, edc_max_len) \ @@ -321,7 +300,7 @@ for_request(tvbuff_t *tvb, proto_tree *tree, guint32 *offset_p) "%s : Reserved", bigbuf); - str = my_match_strval(oct & 0x0f, for_req_type_strings, &idx); + str = match_strval_idx(oct & 0x0f, for_req_type_strings, &idx); if (str == NULL) { @@ -384,7 +363,7 @@ for_response(tvbuff_t *tvb, proto_tree *tree, guint32 *offset_p) "%s : Unsolicited response indicator", bigbuf); - str = my_match_strval(oct & 0x0f, for_rsp_type_strings, &idx); + str = match_strval_idx(oct & 0x0f, for_rsp_type_strings, &idx); if (str == NULL) { @@ -442,7 +421,7 @@ rev_request(tvbuff_t *tvb, proto_tree *tree, guint32 *offset_p) "%s : Reserved", bigbuf); - str = my_match_strval(oct & 0x0f, rev_req_type_strings, &idx); + str = match_strval_idx(oct & 0x0f, rev_req_type_strings, &idx); if (str == NULL) { @@ -505,7 +484,7 @@ rev_response(tvbuff_t *tvb, proto_tree *tree, guint32 *offset_p) "%s : Unsolicited response indicator", bigbuf); - str = my_match_strval(oct & 0x0f, rev_rsp_type_strings, &idx); + str = match_strval_idx(oct & 0x0f, rev_rsp_type_strings, &idx); if (str == NULL) { diff --git a/epan/dissectors/packet-ansi_a.c b/epan/dissectors/packet-ansi_a.c index 510b8fa8ac..dd4757a0fd 100644 --- a/epan/dissectors/packet-ansi_a.c +++ b/epan/dissectors/packet-ansi_a.c @@ -447,26 +447,6 @@ my_dgt_tbcd_unpack( return(cnt); } -static const gchar * -my_match_strval(guint32 val, const value_string *vs, gint *idx) -{ - gint i = 0; - - while (vs[i].strptr) - { - if (vs[i].value == val) - { - *idx = i; - return(vs[i].strptr); - } - - i++; - } - - *idx = -1; - return(NULL); -} - /* ELEMENT FUNCTIONS */ #define EXTRANEOUS_DATA_CHECK(edc_len, edc_max_len) \ @@ -4531,7 +4511,7 @@ elem_ms_info_recs(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gc rec_type = tvb_get_guint8(tvb, curr_offset); - str = my_match_strval((guint32) rec_type, ansi_ms_info_rec_str, &idx); + str = match_strval_idx((guint32) rec_type, ansi_ms_info_rec_str, &idx); if (str == NULL) { @@ -7982,7 +7962,7 @@ dissect_bsmap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) */ oct = tvb_get_guint8(tvb, offset++); - msg_str = my_match_strval((guint32) oct, ansi_a_ios401_bsmap_strings, &idx); + msg_str = match_strval_idx((guint32) oct, ansi_a_ios401_bsmap_strings, &idx); /* * create the a protocol tree @@ -8105,7 +8085,7 @@ dissect_dtap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) saved_offset = offset; oct = tvb_get_guint8(tvb, offset++); - msg_str = my_match_strval((guint32) oct, ansi_a_ios401_dtap_strings, &idx); + msg_str = match_strval_idx((guint32) oct, ansi_a_ios401_dtap_strings, &idx); /* * create the a protocol tree diff --git a/epan/dissectors/packet-ansi_map.c b/epan/dissectors/packet-ansi_map.c index 621f9051c4..f2628cef62 100644 --- a/epan/dissectors/packet-ansi_map.c +++ b/epan/dissectors/packet-ansi_map.c @@ -747,27 +747,6 @@ my_dgt_tbcd_unpack( return(cnt); } -static const gchar * -my_match_strval(guint32 val, const value_string *vs, gint *idx) -{ - gint i = 0; - - while (vs[i].strptr) - { - if (vs[i].value == val) - { - *idx = i; - return(vs[i].strptr); - } - - i++; - } - - *idx = -1; - return(NULL); -} - - /* PARAM FUNCTIONS */ #define EXTRANEOUS_DATA_CHECK(edc_len, edc_max_len) \ @@ -3338,7 +3317,7 @@ param_faulty(ASN1_SCK *asn1, proto_tree *tree, guint len, gchar *add_string) saved_offset = asn1->offset; asn1_int32_value_decode(asn1, 1, &value); - str = my_match_strval((guint32) value, ansi_param_1_strings, &idx); + str = match_strval_idx((guint32) value, ansi_param_1_strings, &idx); if (NULL == str) { @@ -3353,7 +3332,7 @@ param_faulty(ASN1_SCK *asn1, proto_tree *tree, guint len, gchar *add_string) asn1->offset = saved_offset; asn1_uint32_value_decode(asn1, 2, &value); - str = my_match_strval((guint32) value, ansi_param_2_strings, &idx); + str = match_strval_idx((guint32) value, ansi_param_2_strings, &idx); if (NULL == str) { @@ -3368,7 +3347,7 @@ param_faulty(ASN1_SCK *asn1, proto_tree *tree, guint len, gchar *add_string) asn1->offset = saved_offset; asn1_int32_value_decode(asn1, 3, &value); - str = my_match_strval((guint32) value, ansi_param_3_strings, &idx); + str = match_strval_idx((guint32) value, ansi_param_3_strings, &idx); if (NULL == str) { @@ -6477,7 +6456,7 @@ param_sms_tele(ASN1_SCK *asn1, proto_tree *tree, guint len, gchar *add_string) { gint32 value; guint saved_offset; - gchar *str = NULL; + const gchar *str = NULL; ansi_map_sms_tele_id = -1; @@ -6686,7 +6665,7 @@ dissect_cdma2000_ios_data(ASN1_SCK *asn1, proto_tree *tree, guint len, gchar *ad num_elems++; asn1_int32_value_decode(asn1, 1, &value); - str = my_match_strval((guint32) value, ansi_a_ios401_elem_1_strings, &idx); + str = match_strval_idx((guint32) value, ansi_a_ios401_elem_1_strings, &idx); asn1_octet_decode(asn1, &elem_len); @@ -12411,7 +12390,7 @@ dissect_ansi_opr_code(ASN1_SCK *asn1, packet_info *pinfo, proto_tree *tree, gint guint len; guint tag; gint32 val; - gchar *str = NULL; + const gchar *str = NULL; guchar my_oct; proto_item *item; proto_tree *subtree; @@ -12728,21 +12707,21 @@ dissect_ansi_param(ASN1_SCK *asn1, proto_tree *tree) saved_offset = asn1->offset; asn1_uint32_value_decode(asn1, 1, &val); - str = my_match_strval((guint32) val, ansi_param_1_strings, &idx); + str = match_strval_idx((guint32) val, ansi_param_1_strings, &idx); if (NULL == str) { asn1->offset = saved_offset; asn1_uint32_value_decode(asn1, 2, &val); - str = my_match_strval((guint32) val, ansi_param_2_strings, &idx); + str = match_strval_idx((guint32) val, ansi_param_2_strings, &idx); if (NULL == str) { asn1->offset = saved_offset; asn1_int32_value_decode(asn1, 3, &val); - str = my_match_strval((guint32) val, ansi_param_3_strings, &idx); + str = match_strval_idx((guint32) val, ansi_param_3_strings, &idx); if (NULL == str) { @@ -12982,7 +12961,7 @@ dissect_ansi_map_message(ASN1_SCK *asn1, packet_info *pinfo, proto_tree *ansi_ma guint saved_offset; guint tag; guint len; - gchar *str = NULL; + const gchar *str = NULL; proto_item *item, *tag_item; proto_tree *subtree, *tag_subtree; gboolean def_len; diff --git a/epan/dissectors/packet-arp.c b/epan/dissectors/packet-arp.c index 8e38ef6cc4..504701d67c 100644 --- a/epan/dissectors/packet-arp.c +++ b/epan/dissectors/packet-arp.c @@ -257,7 +257,7 @@ static const value_string hrd_vals[] = { {ARPHRD_EUI_64, "EUI-64" }, {0, NULL } }; -gchar * +const gchar * arphrdtype_to_str(guint16 hwtype, const char *fmt) { return val_to_str(hwtype, hrd_vals, fmt); } @@ -389,7 +389,7 @@ dissect_atmarp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) int tot_len; proto_tree *arp_tree; proto_item *ti; - gchar *op_str; + const gchar *op_str; int sha_offset, ssa_offset, spa_offset; int tha_offset, tsa_offset, tpa_offset; const guint8 *sha_val, *ssa_val, *spa_val; @@ -637,7 +637,7 @@ dissect_arp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) int tot_len; proto_tree *arp_tree; proto_item *ti; - gchar *op_str; + const gchar *op_str; int sha_offset, spa_offset, tha_offset, tpa_offset; const guint8 *sha_val, *spa_val, *tha_val, *tpa_val; gboolean is_gratuitous; diff --git a/epan/dissectors/packet-arp.h b/epan/dissectors/packet-arp.h index 782ac7fbf5..808cb83447 100644 --- a/epan/dissectors/packet-arp.h +++ b/epan/dissectors/packet-arp.h @@ -5,10 +5,9 @@ * $Id$ * * Ethereal - Network traffic analyzer - * By Gerald Combs <gerald@zing.org> + * By Gerald Combs <gerald@ethereal.com> * Copyright 1998 Gerald Combs * - * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 @@ -28,7 +27,7 @@ #define __PACKET_ARP_H__ gchar *arphrdaddr_to_str(const guint8 *ad, int ad_len, guint16 type); -gchar *arphrdtype_to_str(guint16 hwtype, const char *fmt); +const gchar *arphrdtype_to_str(guint16 hwtype, const char *fmt); void dissect_atm_nsap(tvbuff_t *tvb, int offset, int len, proto_tree *tree); diff --git a/epan/dissectors/packet-bgp.c b/epan/dissectors/packet-bgp.c index ddb1e5d8f0..13297075c8 100644 --- a/epan/dissectors/packet-bgp.c +++ b/epan/dissectors/packet-bgp.c @@ -1488,7 +1488,7 @@ dissect_bgp_update(tvbuff_t *tvb, proto_tree *tree) subtree = proto_item_add_subtree(ti, ett_bgp_attrs); i = 2; while (i < len) { - char *msg; + const char *msg; int off; gint k; guint16 alen, tlen, aoff; @@ -2398,7 +2398,7 @@ dissect_bgp_notification(tvbuff_t *tvb, proto_tree *tree) { struct bgp_notification bgpn; /* BGP NOTIFICATION message */ int hlen; /* message length */ - char *p; /* string pointer */ + const char *p; /* string pointer */ /* snarf message */ tvb_memcpy(tvb, bgpn.bgpn_marker, 0, BGP_MIN_NOTIFICATION_MSG_SIZE); @@ -2596,7 +2596,7 @@ dissect_bgp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, { guint16 bgp_len; /* Message length */ guint8 bgp_type; /* Message type */ - char *typ; /* Message type (string) */ + const char *typ; /* Message type (string) */ proto_item *ti; /* tree item */ proto_tree *bgp_tree; /* BGP packet tree */ proto_tree *bgp1_tree; /* BGP message tree */ diff --git a/epan/dissectors/packet-bittorrent.c b/epan/dissectors/packet-bittorrent.c index a544a354e8..9aa9472c5e 100644 --- a/epan/dissectors/packet-bittorrent.c +++ b/epan/dissectors/packet-bittorrent.c @@ -123,8 +123,8 @@ static void dissect_bittorrent_message (tvbuff_t *tvb, packet_info *pinfo, proto type = tvb_get_guint8(tvb, offset); proto_tree_add_item(mtree, hf_bittorrent_msg_type, tvb, offset, 1, FALSE); offset+=1; - if (check_col(pinfo->cinfo, COL_INFO)) { - char *val = match_strval(type, bittorrent_messages); + if (check_col(pinfo->cinfo, COL_INFO)) { + const char *val = match_strval(type, bittorrent_messages); if (val != NULL) { col_set_str(pinfo->cinfo, COL_INFO, val); } diff --git a/epan/dissectors/packet-bssgp.c b/epan/dissectors/packet-bssgp.c index 707a6aa0bf..2e085f372b 100644 --- a/epan/dissectors/packet-bssgp.c +++ b/epan/dissectors/packet-bssgp.c @@ -1032,9 +1032,9 @@ translate_abqp_guaranteed_bit_rate_for_dl_extended(guint8 value, build_info_t *b return ""; } -static char* +static const char* translate_msrac_access_technology_type(guint8 value) { - value_string tab_values[] = { + static const value_string tab_values[] = { { 0, "GSM P" }, { 1, "GSM E" }, { 2, "GSM R" }, @@ -1054,9 +1054,9 @@ translate_msrac_access_technology_type(guint8 value) { return val_to_str(value, tab_values, "Unknown"); } -static char* +static const char* translate_msrac_dtm_gprs_multislot_class(guint8 value) { - value_string tab_values[] = { + static const value_string tab_values[] = { { 0, "Unused, interpreted as ""Multislot class 5 supported""" }, { 1, "Multislot class 5 supported" }, { 2, "Multislot class 9 supported" }, @@ -1269,7 +1269,7 @@ decode_mobile_identity(bssgp_ie_t *ie, build_info_t *bi, int ie_start_offset) { guint8 digits[MAX_NUM_IMSI_DIGITS]; char digits_str[MAX_NUM_IMSI_DIGITS + 1]; - value_string tab_type_of_identity[] = { + static const value_string tab_type_of_identity[] = { { BSSGP_MOBILE_IDENTITY_TYPE_IMSI, "IMSI" }, { BSSGP_MOBILE_IDENTITY_TYPE_IMEI, "IMEI" }, { BSSGP_MOBILE_IDENTITY_TYPE_IMEISV, "IMEISV" }, @@ -1531,7 +1531,7 @@ bssgp_pi_append_pfi(proto_item *pi, tvbuff_t *tvb, int offset) { const guint8 MASK_PFI = 0x7f; guint8 value; - value_string tab_pfi[] = { + static const value_string tab_pfi[] = { { 0, "Best effort" }, { 1, "Signaling" }, { 2, "SMS" }, @@ -1707,7 +1707,7 @@ decode_iei_cause(bssgp_ie_t *ie, build_info_t *bi, int ie_start_offset) { proto_item *ti; guint8 value; - value_string tab_cause[] = { + static const value_string tab_cause[] = { { 0x00, "Processor overload" }, { 0x01, "Equipment failure" }, { 0x02, "Transit network service failure" }, @@ -1800,7 +1800,7 @@ decode_iei_drx_parameters(bssgp_ie_t *ie, build_info_t *bi, int ie_start_offset) guint8 data, value; guint16 cycle_value; - value_string tab_non_drx_timer[] = { + static const value_string tab_non_drx_timer[] = { { 0, "No non-DRX mode after transfer state" }, { 1, "Max. 1 sec non-DRX mode after transfer state" }, { 2, "Max. 2 sec non-DRX mode after transfer state" }, @@ -1813,7 +1813,7 @@ decode_iei_drx_parameters(bssgp_ie_t *ie, build_info_t *bi, int ie_start_offset) /* Otherwise "" */ }; - value_string tab_cycle_length_coefficient[] = { + static const value_string tab_cycle_length_coefficient[] = { { 0, "CN Specific DRX cycle length coefficient not specified by the MS, ie. the system information value 'CN domain specific DRX cycle length' is used" }, { 6, "CN Specific DRX cycle length coefficient 6" }, { 7, "CN Specific DRX cycle length coefficient 7" }, @@ -1911,7 +1911,7 @@ decode_iei_emlpp_priority(bssgp_ie_t *ie, build_info_t *bi, int ie_start_offset) proto_item *ti; guint8 data, value; - value_string tab_call_priority[] = { + static const value_string tab_call_priority[] = { { 0, "No priority applied" }, { 1, "Call priority level 4" }, { 2, "Call priority level 3" }, @@ -1938,7 +1938,7 @@ decode_iei_flush_action(bssgp_ie_t *ie, build_info_t *bi, int ie_start_offset) { proto_item *ti; guint8 value; - value_string tab_action_value[] = { + static const value_string tab_action_value[] = { { 0x00, "LLC-PDU(s) deleted" }, { 0x01, "LLC-PDU(s) transferred" }, { 0, NULL }, @@ -2496,7 +2496,7 @@ decode_msrac_value_part(proto_tree *tree, tvbuff_t *tvb, guint64 bo) { guint8 att, length, bit, bl; proto_item *ti, *ti2, *pi; proto_tree *tf, *tf2; - char *att_name; + const char *att_name; guint64 start_bo; start_bo = bo; @@ -2593,7 +2593,7 @@ decode_iei_priority(bssgp_ie_t *ie, build_info_t *bi, int ie_start_offset) { proto_tree *tf; guint8 data, value; - value_string tab_priority_level[] = { + static const value_string tab_priority_level[] = { { 0, "Spare" }, { 1, "Priority Level 1 = highest priority" }, { 2, "Priority Level 2 = 2nd highest priority" }, @@ -2657,14 +2657,14 @@ decode_iei_qos_profile(bssgp_ie_t *ie, build_info_t *bi, int ie_start_offset) { guint8 data, value; guint16 peak_bit_rate; - value_string tab_precedence_ul[] = { + static const value_string tab_precedence_ul[] = { { 0, "High priority" }, { 1, "Normal priority" }, { 2, "Low priority" }, { 0, NULL }, }; - value_string tab_precedence_dl[] = { + static const value_string tab_precedence_dl[] = { { 0, "Radio priority 1" }, { 1, "Radio priority 2" }, { 2, "Radio priority 3" }, @@ -2730,7 +2730,7 @@ decode_iei_radio_cause(bssgp_ie_t *ie, build_info_t *bi, int ie_start_offset) { proto_item *ti; guint8 value; - value_string tab_radio_cause[] = { + static const value_string tab_radio_cause[] = { { 0x00, "Radio contact lost with the MS" }, { 0x01, "Radio link quality insufficient to continue communication" }, { 0x02, "Cell reselection ordered" }, @@ -2755,7 +2755,7 @@ decode_iei_ra_cap_upd_cause(bssgp_ie_t *ie, build_info_t *bi, int ie_start_offse proto_item *ti; guint8 value; - value_string tab_cause[] = { + static const value_string tab_cause[] = { { 0x00, "OK, RA capability IE present" }, { 0x01, "TLLI unknown in SGSN" }, { 0x02, "No RA capabilities or IMSI available for this MS" }, @@ -2882,7 +2882,7 @@ decode_iei_lsa_information(bssgp_ie_t *ie, build_info_t *bi, int ie_start_offset int num_lsa_infos, i; guint8 data, value; - value_string tab_priority[] = { + static const value_string tab_priority[] = { { 0, "Priority 1 = lowest priority" }, { 1, "Priority 2 = 2nd lowest priority" }, { 2, "Priority 3 = 3rd lowest priority" }, @@ -2953,7 +2953,7 @@ decode_iei_gprs_timer(bssgp_ie_t *ie, build_info_t *bi, int ie_start_offset) { proto_item *ti; guint8 data, value; - value_string tab_unit_value[] = { + static const value_string tab_unit_value[] = { { 0, "incremented in multiples of 2 s" }, { 1, "incremented in multiples of 1 minute" }, { 2, "incremented in multiples of decihours" }, @@ -3246,7 +3246,7 @@ decode_iei_service_utran_cco(bssgp_ie_t *ie, build_info_t *bi, int ie_start_offs proto_item *ti; guint8 data, value; - value_string tab_service_utran_cco[] = { + static const value_string tab_service_utran_cco[] = { { 0, "Network initiated cell change order procedure to UTRAN should be performed" }, { 1, "Network initiated cell change order procedure to UTRAN should not be performed" }, { 2, "Network initiated cell change order procedure to UTRAN shall not be performed" }, @@ -3297,7 +3297,7 @@ decode_iei_lcs_qos(bssgp_ie_t *ie, build_info_t *bi, int ie_start_offset) { proto_tree *tf; guint8 data, value, vert; - value_string tab_rt[] = { + static const value_string tab_rt[] = { { 0, "Response time is not specified" }, { 1, "Low delay" }, { 2, "Delay tolerant" }, @@ -3366,7 +3366,7 @@ decode_iei_lcs_client_type(bssgp_ie_t *ie, build_info_t *bi, int ie_start_offset proto_tree *tf; guint8 data, category, subtype; - value_string tab_category[] = { + static const value_string tab_category[] = { { 0, "Value Added Client" }, /* { 1, ??? XXX }, */ { 2, "PLMN Operator" }, @@ -3555,7 +3555,7 @@ decode_iei_location_type(bssgp_ie_t *ie, build_info_t *bi, int ie_start_offset) proto_tree *tf; guint8 value; - value_string tab_location_information[] = { + static const value_string tab_location_information[] = { { 0, "Current geographic location" }, { 1, "Location assistance information for the target MS" }, { 2, "Deciphering keys for broadcast assistance data for the target MS" }, @@ -3563,7 +3563,7 @@ decode_iei_location_type(bssgp_ie_t *ie, build_info_t *bi, int ie_start_offset) /* Otherwise "Reserved" */ }; - value_string tab_positioning_method[] = { + static const value_string tab_positioning_method[] = { { 0, "Reserved" }, { 1, "Mobile Assisted E-OTD" }, { 2, "Mobile Based E-OTD" }, @@ -3723,7 +3723,7 @@ decode_iei_lcs_cause(bssgp_ie_t *ie, build_info_t *bi, int ie_start_offset) { proto_tree *tf; guint8 value; - value_string tab_cause_value[] = { + static const value_string tab_cause_value[] = { { 0, "Unspecified" }, { 1, "System failure" }, { 2, "Protocol error" }, @@ -3744,7 +3744,7 @@ decode_iei_lcs_cause(bssgp_ie_t *ie, build_info_t *bi, int ie_start_offset) { /* Otherwise "Unspecified" */ }; - value_string tab_diagnostic_value[] = { + static const value_string tab_diagnostic_value[] = { { 0, "Congestion" }, { 1, "Insufficient resources" }, { 2, "Insufficient measurement data" }, @@ -4097,7 +4097,7 @@ decode_iei_global_cn_id(bssgp_ie_t *ie, build_info_t *bi, int ie_start_offset) { static void decode_ie(bssgp_ie_t *ie, build_info_t *bi) { int org_offset = bi->offset; - char *iename = val_to_str(ie->iei, tab_bssgp_ie_types, "Unknown"); + const char *iename = val_to_str(ie->iei, tab_bssgp_ie_types, "Unknown"); gboolean use_default_ie_name = (ie->name == NULL); if (tvb_length_remaining(bi->tvb, bi->offset) < 1) { diff --git a/epan/dissectors/packet-cast.c b/epan/dissectors/packet-cast.c index d58fc7a0ab..ab2201ff38 100644 --- a/epan/dissectors/packet-cast.c +++ b/epan/dissectors/packet-cast.c @@ -402,7 +402,7 @@ static void dissect_cast_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree guint32 hdr_data_length; guint32 hdr_marker; guint32 data_messageid; - gchar *messageid_str; + const gchar *messageid_str; /* guint32 data_size; */ guint i = 0; diff --git a/epan/dissectors/packet-cdp.c b/epan/dissectors/packet-cdp.c index 8be5813483..bee98ceea3 100644 --- a/epan/dissectors/packet-cdp.c +++ b/epan/dissectors/packet-cdp.c @@ -654,7 +654,7 @@ dissect_address_tlv(tvbuff_t *tvb, int offset, int length, proto_tree *tree) guint8 protocol_type; guint8 protocol_length; int nlpid; - char *protocol_str; + const char *protocol_str; guint16 address_length; char *address_type_str; char *address_str; diff --git a/epan/dissectors/packet-clnp.c b/epan/dissectors/packet-clnp.c index 54e34888ee..8f4b051313 100644 --- a/epan/dissectors/packet-clnp.c +++ b/epan/dissectors/packet-clnp.c @@ -1810,7 +1810,7 @@ static void dissect_clnp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) guint8 cnf_ttl; guint8 cnf_type; char flag_string[6+1]; - char *pdu_type_string; + const char *pdu_type_string; proto_tree *type_tree; guint16 segment_length; guint16 du_id = 0; diff --git a/epan/dissectors/packet-cops.c b/epan/dissectors/packet-cops.c index 8e14c82ed8..06594632da 100644 --- a/epan/dissectors/packet-cops.c +++ b/epan/dissectors/packet-cops.c @@ -1015,7 +1015,7 @@ static void dissect_cops_pr_objects(tvbuff_t *tvb, guint32 offset, proto_tree *t { int object_len, contents_len; guint8 s_num, s_type; - char *type_str; + const char *type_str; int ret; proto_tree *cops_pr_tree, *obj_tree; proto_item *ti; diff --git a/epan/dissectors/packet-dcerpc-afs4int.c b/epan/dissectors/packet-dcerpc-afs4int.c index eae7f2a8b1..a17f19e6d7 100644 --- a/epan/dissectors/packet-dcerpc-afs4int.c +++ b/epan/dissectors/packet-dcerpc-afs4int.c @@ -305,9 +305,6 @@ static gint ett_afs4int_afsbundled_stat = -1; /* vars for our macro(s) */ static int hf_error_st = -1; -static guint32 st; -static char *st_str; - static e_uuid_t uuid_afs4int = { 0x4d37f2dd, 0xed93, 0x0000, {0x02, 0xc0, 0x37, 0xcf, 0x1e, 0x00, 0x00, @@ -326,15 +323,19 @@ inode, volume, etc all will be garbage. */ #define MACRO_ST_CLEAR(name) \ - offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep, hf_error_st, &st); \ - st_str = val_to_str (st, dce_error_vals, "%u"); \ - if (st){ \ -if (check_col (pinfo->cinfo, COL_INFO)) \ - col_add_fstr (pinfo->cinfo, COL_INFO, "%s st:%s ", name, st_str); \ - }else{ \ -if (check_col (pinfo->cinfo, COL_INFO)) \ - col_append_fstr (pinfo->cinfo, COL_INFO, " st:%s ", st_str); \ -} + { \ + guint32 st; \ + const char *st_str; \ + offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep, hf_error_st, &st); \ + st_str = val_to_str (st, dce_error_vals, "%u"); \ + if (st){ \ + if (check_col (pinfo->cinfo, COL_INFO)) \ + col_add_fstr (pinfo->cinfo, COL_INFO, "%s st:%s ", name, st_str); \ + }else{ \ + if (check_col (pinfo->cinfo, COL_INFO)) \ + col_append_fstr (pinfo->cinfo, COL_INFO, " st:%s ", st_str); \ + } \ + } static int dissect_afsFid (tvbuff_t * tvb, int offset, @@ -899,6 +900,7 @@ dissect_afsErrorStatus (tvbuff_t * tvb, int offset, int old_offset = offset; guint32 st; dcerpc_info *di; + const char *st_str; di = pinfo->private_data; if (di->conformant_run) diff --git a/epan/dissectors/packet-dcerpc-nt.c b/epan/dissectors/packet-dcerpc-nt.c index b559549244..fb9fac0fa9 100644 --- a/epan/dissectors/packet-dcerpc-nt.c +++ b/epan/dissectors/packet-dcerpc-nt.c @@ -1148,7 +1148,7 @@ dissect_ndr_nt_SID(tvbuff_t *tvb, int offset, packet_info *pinfo, dcerpc_info *di = (dcerpc_info *)pinfo->private_data; dcerpc_call_value *dcv = (dcerpc_call_value *)di->call_data; char *sid_str=NULL; - char *name; + const char *name; if(di->hf_index!=-1){ name=proto_registrar_get_name(di->hf_index); diff --git a/epan/dissectors/packet-dcerpc-rs_pgo.c b/epan/dissectors/packet-dcerpc-rs_pgo.c index fe2b403319..70219453c9 100644 --- a/epan/dissectors/packet-dcerpc-rs_pgo.c +++ b/epan/dissectors/packet-dcerpc-rs_pgo.c @@ -127,7 +127,6 @@ static gint ett_rs_pgo_id_key_t = -1; static gint ett_rs_pgo_unix_num_key_t = -1; static gint ett_rs_pgo_query_result_t = -1; static gint ett_rs_pgo_result_t = -1; -static guint8 *st_str; #define sec_rgy_acct_admin_valid 0x1 @@ -176,6 +175,7 @@ dissect_error_status_t (tvbuff_t * tvb, int offset, int old_offset = offset; guint32 st; dcerpc_info *di; + const char *st_str; di = pinfo->private_data; if (di->conformant_run) @@ -1001,7 +1001,7 @@ dissect_rs_pgo_query_result_t (tvbuff_t * tvb, int offset, int old_offset = offset; guint32 st; dcerpc_info *di; - guint8 *status; + const char *status; #define error_status_ok 0 /* diff --git a/epan/dissectors/packet-dcerpc-spoolss.c b/epan/dissectors/packet-dcerpc-spoolss.c index 764de68e2a..9355d032dd 100644 --- a/epan/dissectors/packet-dcerpc-spoolss.c +++ b/epan/dissectors/packet-dcerpc-spoolss.c @@ -2652,7 +2652,7 @@ dissect_notify_field(tvbuff_t *tvb, int offset, packet_info *pinfo, guint16 *data) { guint16 field; - char *str; + const char *str; offset = dissect_ndr_uint16( tvb, offset, pinfo, NULL, drep, @@ -5868,7 +5868,7 @@ dissect_NOTIFY_INFO_DATA(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *subtree; guint32 count; guint16 type, field; - char *field_string; + const char *field_string; item = proto_tree_add_text(tree, tvb, offset, 0, "%s", ""); diff --git a/epan/dissectors/packet-dhcp-failover.c b/epan/dissectors/packet-dhcp-failover.c index dd663e79f2..b58c22eff9 100644 --- a/epan/dissectors/packet-dhcp-failover.c +++ b/epan/dissectors/packet-dhcp-failover.c @@ -341,7 +341,7 @@ dissect_dhcpfo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) guint type, serverflag; guint poffset; guint32 xid; - gchar *typestrval, *optionstrval, *tls_request_string; + gchar *tls_request_string; guint32 time, lease_expiration_time, grace_expiration_time; guint32 potential_expiration_time, client_last_transaction_time; guint32 start_time_of_state; @@ -352,15 +352,14 @@ dissect_dhcpfo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) guint8 htype, reject_reason, message_digest_type; const guint8 *chaddr; guint8 binding_status; - gchar *binding_status_str, *reject_reason_str; gchar *assigned_ip_address_str, *sending_server_ip_address_str; guint32 addresses_transfered; const guint8 *client_identifier_str, *vendor_class_str; - gchar *htype_str, *chaddr_str; + const gchar *htype_str; + gchar *chaddr_str; gchar *lease_expiration_time_str; gchar *grace_expiration_time_str, *potential_expiration_time_str; gchar *client_last_transaction_time_str, *start_time_of_state_str; - gchar *server_state_str; guint32 mclt; guint8 server_state, protocol_version; guint32 max_unacked_bndupd, receive_timer; @@ -371,10 +370,6 @@ dissect_dhcpfo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) length = tvb_get_ntohs(tvb, 0); type = tvb_get_guint8(tvb, 2); - typestrval= match_strval(type,failover_vals); - if (typestrval==NULL) { - typestrval="Unknown Packet"; - } poffset = tvb_get_guint8(tvb, 3); if(poffset > 12) @@ -391,7 +386,9 @@ dissect_dhcpfo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) if (check_col(pinfo->cinfo, COL_INFO)){ col_add_fstr(pinfo->cinfo, - COL_INFO,"%s xid: %x", typestrval,xid); + COL_INFO,"%s xid: %x", + val_to_str(type,failover_vals,"Unknown Packet"), + xid); } actualoffset = poffset; @@ -476,14 +473,11 @@ dissect_dhcpfo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) /*** DHCP-Style-Options ****/ - optionstrval= match_strval(helpliste->opcode,option_code_vals); - if (optionstrval==NULL) { - optionstrval="Unknown Packet"; - } - - - proto_item_append_text(oi, ", %s (%d)", - optionstrval, helpliste->opcode); + proto_item_append_text(oi, ", %s (%d)", + val_to_str(helpliste->opcode, + option_code_vals, + "Unknown Packet"), + helpliste->opcode); proto_tree_add_item(option_tree, hf_dhcpfo_option_code, tvb, @@ -503,15 +497,10 @@ dissect_dhcpfo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) binding_status = tvb_get_guint8(tvb, helpliste->actualpoffset+4); - binding_status_str = - match_strval(binding_status, - binding_status_vals); - if(binding_status_str == NULL) - { - binding_status_str = "Unknown Packet"; - } proto_item_append_text(oi, ", %s (%d)", - binding_status_str, + val_to_str(binding_status, + binding_status_vals, + "Unknown Packet"), binding_status); proto_tree_add_item(option_tree, @@ -612,14 +601,11 @@ dissect_dhcpfo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) reject_reason = tvb_get_guint8(tvb, helpliste->actualpoffset +4); - reject_reason_str = match_strval(reject_reason, - reject_reason_vals); - if (reject_reason_str==NULL) { - reject_reason_str="Unknown Packet"; - } - + proto_item_append_text(oi, ", %s (%d)", - reject_reason_str, + val_to_str(reject_reason, + reject_reason_vals, + "Unknown Packet"), reject_reason); if (helpliste->length != 1) @@ -760,12 +746,9 @@ dissect_dhcpfo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) server_state = tvb_get_guint8(tvb, helpliste->actualpoffset+4); - server_state_str = match_strval(server_state,server_state_vals); - if (server_state_str==NULL) { - server_state_str="Unknown Packet"; - } proto_item_append_text(oi, ", %s (%d)", - server_state_str, server_state); + val_to_str(server_state,server_state_vals, "Unknown Packet"), + server_state); proto_tree_add_item(option_tree, hf_dhcpfo_server_state, tvb, diff --git a/epan/dissectors/packet-dns.c b/epan/dissectors/packet-dns.c index 394ed7622f..bcb5cd755a 100644 --- a/epan/dissectors/packet-dns.c +++ b/epan/dissectors/packet-dns.c @@ -377,7 +377,7 @@ static const value_string dns_types[] = { {0, NULL} }; -static char * +static const char * dns_type_name (guint type) { return val_to_str(type, dns_types, "Unknown (%u)"); @@ -437,7 +437,7 @@ dns_type_description (guint type) "Next secured", /* future RFC 2535bis */ "DNS public key" /* future RFC 2535bis */ }; - char *short_name; + const char *short_name; const char *long_name; static char strbuf[1024+1]; @@ -499,7 +499,7 @@ static const value_string dns_classes[] = { {0,NULL} }; -char * +const char * dns_class_name(int class) { return val_to_str(class, dns_classes, "Unknown (%u)"); @@ -754,7 +754,7 @@ dissect_dns_query(tvbuff_t *tvb, int offset, int dns_data_offset, int name_len; int type; int class; - char *type_name; + const char *type_name; int data_offset; int data_start; proto_tree *q_tree; @@ -934,8 +934,8 @@ dissect_dns_answer(tvbuff_t *tvb, int offset, int dns_data_offset, int name_len; int type; int class; - char *class_name; - char *type_name; + const char *class_name; + const char *type_name; int data_offset; int cur_offset; int data_start; diff --git a/epan/dissectors/packet-dns.h b/epan/dissectors/packet-dns.h index 924784e2a5..275b54f84c 100644 --- a/epan/dissectors/packet-dns.h +++ b/epan/dissectors/packet-dns.h @@ -27,7 +27,7 @@ #ifndef __PACKET_DNS_H__ #define __PACKET_DNS_H__ -char *dns_class_name(int class); +const char *dns_class_name(int class); int get_dns_name(tvbuff_t *, int, int, char *, int); diff --git a/epan/dissectors/packet-edonkey.c b/epan/dissectors/packet-edonkey.c index 5ac4e82d24..d785efa935 100644 --- a/epan/dissectors/packet-edonkey.c +++ b/epan/dissectors/packet-edonkey.c @@ -290,8 +290,7 @@ static guint8 edonkey_metatag_name_get_type(tvbuff_t *tvb, gint start, gint leng { guint8 *tag_name; - tag_name = match_strval(special_tagtype, edonkey_special_tags); - if (tag_name == NULL) { + if (match_strval(special_tagtype, edonkey_special_tags) == NULL) { gint index; tag_name = tvb_get_string(tvb, start, length); index = lookup_str_index(tag_name, length, edonkey_special_tags); @@ -308,7 +307,7 @@ static guint8 edonkey_metatag_name_get_type(tvbuff_t *tvb, gint start, gint leng static proto_item* edonkey_tree_add_metatag_name(proto_tree *tree, tvbuff_t *tvb, gint start, gint length, guint8 special_tagtype) { - gchar *tag_name; + const gchar *tag_name; tag_name = match_strval(special_tagtype, edonkey_special_tags); if (tag_name == NULL) { return proto_tree_add_item(tree, hf_edonkey_metatag_name, tvb, start, length, FALSE); @@ -1190,7 +1189,7 @@ static void dissect_edonkey_tcp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tre int offset, bytes, messages; guint8 protocol, msg_type; guint32 msg_len; - gchar *protocol_name, *message_name; + const gchar *protocol_name, *message_name; void (*dissector)(guint8, tvbuff_t*, packet_info*, int, int, proto_tree*); if (check_col(pinfo->cinfo, COL_PROTOCOL)) @@ -1293,7 +1292,7 @@ static void dissect_edonkey_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *t proto_tree *edonkey_tree = NULL, *edonkey_msg_tree = NULL; int offset; guint8 protocol, msg_type; - gchar *protocol_name, *message_name; + const gchar *protocol_name, *message_name; if (check_col(pinfo->cinfo, COL_PROTOCOL)) col_set_str(pinfo->cinfo, COL_PROTOCOL, "eDonkey"); diff --git a/epan/dissectors/packet-esis.c b/epan/dissectors/packet-esis.c index 5dd67c4a67..44e5cda45d 100644 --- a/epan/dissectors/packet-esis.c +++ b/epan/dissectors/packet-esis.c @@ -273,7 +273,7 @@ esis_dissect_redirect_pdu( guint8 len, tvbuff_t *tvb, proto_tree *tree) { */ static void dissect_esis(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { - char *pdu_type_string = NULL; + const char *pdu_type_string = NULL; char *pdu_type_format_string = "PDU Type : %s (R:%s%s%s)"; esis_hdr_t ehdr; proto_item *ti; diff --git a/epan/dissectors/packet-ethertype.c b/epan/dissectors/packet-ethertype.c index 83fb26eb63..0fcf0d1f1d 100644 --- a/epan/dissectors/packet-ethertype.c +++ b/epan/dissectors/packet-ethertype.c @@ -157,7 +157,7 @@ ethertype(guint16 etype, tvbuff_t *tvb, int offset_after_etype, packet_info *pinfo, proto_tree *tree, proto_tree *fh_tree, int etype_id, int trailer_id, int fcs_len) { - char *description; + const char *description; tvbuff_t *next_tvb; guint length_before; volatile gboolean dissector_found = FALSE; diff --git a/epan/dissectors/packet-fclctl.c b/epan/dissectors/packet-fclctl.c index fbb7ecf298..446585c424 100644 --- a/epan/dissectors/packet-fclctl.c +++ b/epan/dissectors/packet-fclctl.c @@ -132,7 +132,7 @@ static const value_string fc_lctl_rjt_val[] = { static gchar errstr[64]; -gchar * +const gchar * fclctl_get_typestr (guint8 linkctl_type, guint8 type) { if ((linkctl_type == FC_LCTL_FBSYB) || diff --git a/epan/dissectors/packet-fclctl.h b/epan/dissectors/packet-fclctl.h index 67c8bca908..7466b9df8e 100644 --- a/epan/dissectors/packet-fclctl.h +++ b/epan/dissectors/packet-fclctl.h @@ -91,6 +91,6 @@ extern const value_string fc_lctl_proto_val[]; #define FC_LCTL_RJT_VEND_ERR 0xFF /* Function definitions */ -gchar *fclctl_get_typestr (guint8 linkctl_type, guint8 type); +const gchar *fclctl_get_typestr (guint8 linkctl_type, guint8 type); gchar *fclctl_get_paramstr (guint32 linkctl_type, guint32 param); #endif diff --git a/epan/dissectors/packet-gsm_a.c b/epan/dissectors/packet-gsm_a.c index f98e9240fb..e9e3b645ff 100644 --- a/epan/dissectors/packet-gsm_a.c +++ b/epan/dissectors/packet-gsm_a.c @@ -876,26 +876,6 @@ my_dgt_tbcd_unpack( return(cnt); } -static gchar * -my_match_strval(guint32 val, const value_string *vs, gint *idx) -{ - gint i = 0; - - while (vs[i].strptr) - { - if (vs[i].value == val) - { - *idx = i; - return(vs[i].strptr); - } - - i++; - } - - *idx = -1; - return(NULL); -} - /* ELEMENT FUNCTIONS */ #define EXTRANEOUS_DATA_CHECK(edc_len, edc_max_len) \ @@ -6076,7 +6056,7 @@ de_facility(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *a guint comp_len, temp_len; gboolean def_len[3]; guint comp_tag, tag; - gchar *str; + const gchar *str; gint32 int_val; add_string = add_string; @@ -6204,11 +6184,9 @@ de_facility(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *a saved_offset = asn1->offset; asn1_int32_value_decode(asn1, temp_len, &int_val); - str = match_strval(int_val, gsm_ss_opr_code_strings); - proto_tree_add_text(temp_subtree, asn1->tvb, saved_offset, temp_len, "Operation Code: %s (%d)", - (str == NULL) ? "Unknown Operation Code" : str, + val_to_str(int_val, gsm_ss_opr_code_strings, "Unknown Operation Code"), int_val); } @@ -6248,11 +6226,9 @@ de_facility(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *a saved_offset = asn1->offset; asn1_int32_value_decode(asn1, temp_len, &int_val); - str = match_strval(int_val, gsm_ss_opr_code_strings); - proto_tree_add_text(temp_subtree, asn1->tvb, saved_offset, temp_len, "Operation Code: %s (%d)", - (str == NULL) ? "Unknown Operation Code" : str, + val_to_str(int_val, gsm_ss_opr_code_strings, "Unknown Operation Code"), int_val); } @@ -6297,11 +6273,9 @@ de_facility(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *a saved_offset = asn1->offset; asn1_int32_value_decode(asn1, temp_len, &int_val); - str = match_strval(int_val, gsm_ss_err_code_strings); - proto_tree_add_text(temp_subtree, asn1->tvb, saved_offset, temp_len, "Error Code: %s (%d)", - (str == NULL) ? "Unknown Error Code" : str, + val_to_str(int_val, gsm_ss_err_code_strings, "Unknown Error Code"), int_val); } break; @@ -16053,7 +16027,7 @@ dissect_rp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) gint idx; proto_item *rp_item = NULL; proto_tree *rp_tree = NULL; - gchar *str; + const gchar *str; if (check_col(pinfo->cinfo, COL_INFO)) @@ -16083,7 +16057,7 @@ dissect_rp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) */ oct = tvb_get_guint8(tvb, offset++); - str = my_match_strval((guint32) oct, gsm_rp_msg_strings, &idx); + str = match_strval_idx((guint32) oct, gsm_rp_msg_strings, &idx); /* * create the protocol tree @@ -16150,7 +16124,7 @@ dissect_bssmap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) gint idx; proto_item *bssmap_item = NULL; proto_tree *bssmap_tree = NULL; - gchar *str; + const gchar *str; if (check_col(pinfo->cinfo, COL_INFO)) @@ -16182,7 +16156,7 @@ dissect_bssmap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) */ oct = tvb_get_guint8(tvb, offset++); - str = my_match_strval((guint32) oct, gsm_a_bssmap_msg_strings, &idx); + str = match_strval_idx((guint32) oct, gsm_a_bssmap_msg_strings, &idx); /* * create the protocol tree @@ -16259,7 +16233,7 @@ dissect_dtap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_tree *dtap_tree = NULL; proto_item *oct_1_item = NULL; proto_tree *pd_tree = NULL; - gchar *msg_str; + const gchar *msg_str; const gchar *str; gint ett_tree; gint ti; @@ -16336,7 +16310,7 @@ dissect_dtap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { case 3: str = gsm_a_pd_str[pd]; - msg_str = my_match_strval((guint32) (oct & DTAP_CC_IEI_MASK), gsm_a_dtap_msg_cc_strings, &idx); + msg_str = match_strval_idx((guint32) (oct & DTAP_CC_IEI_MASK), gsm_a_dtap_msg_cc_strings, &idx); ett_tree = ett_gsm_dtap_msg_cc[idx]; hf_idx = hf_gsm_a_dtap_msg_cc_type; msg_fcn = dtap_msg_cc_fcn[idx]; @@ -16346,7 +16320,7 @@ dissect_dtap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) case 5: str = gsm_a_pd_str[pd]; - msg_str = my_match_strval((guint32) (oct & DTAP_MM_IEI_MASK), gsm_a_dtap_msg_mm_strings, &idx); + msg_str = match_strval_idx((guint32) (oct & DTAP_MM_IEI_MASK), gsm_a_dtap_msg_mm_strings, &idx); ett_tree = ett_gsm_dtap_msg_mm[idx]; hf_idx = hf_gsm_a_dtap_msg_mm_type; msg_fcn = dtap_msg_mm_fcn[idx]; @@ -16355,7 +16329,7 @@ dissect_dtap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) case 6: str = gsm_a_pd_str[pd]; - msg_str = my_match_strval((guint32) (oct & DTAP_RR_IEI_MASK), gsm_a_dtap_msg_rr_strings, &idx); + msg_str = match_strval_idx((guint32) (oct & DTAP_RR_IEI_MASK), gsm_a_dtap_msg_rr_strings, &idx); ett_tree = ett_gsm_dtap_msg_rr[idx]; hf_idx = hf_gsm_a_dtap_msg_rr_type; msg_fcn = dtap_msg_rr_fcn[idx]; @@ -16363,7 +16337,7 @@ dissect_dtap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) case 8: str = gsm_a_pd_str[pd]; - msg_str = my_match_strval((guint32) (oct & DTAP_GMM_IEI_MASK), gsm_a_dtap_msg_gmm_strings, &idx); + msg_str = match_strval_idx((guint32) (oct & DTAP_GMM_IEI_MASK), gsm_a_dtap_msg_gmm_strings, &idx); ett_tree = ett_gsm_dtap_msg_gmm[idx]; hf_idx = hf_gsm_a_dtap_msg_gmm_type; msg_fcn = dtap_msg_gmm_fcn[idx]; @@ -16371,7 +16345,7 @@ dissect_dtap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) case 9: str = gsm_a_pd_str[pd]; - msg_str = my_match_strval((guint32) (oct & DTAP_SMS_IEI_MASK), gsm_a_dtap_msg_sms_strings, &idx); + msg_str = match_strval_idx((guint32) (oct & DTAP_SMS_IEI_MASK), gsm_a_dtap_msg_sms_strings, &idx); ett_tree = ett_gsm_dtap_msg_sms[idx]; hf_idx = hf_gsm_a_dtap_msg_sms_type; msg_fcn = dtap_msg_sms_fcn[idx]; @@ -16380,7 +16354,7 @@ dissect_dtap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) case 10: str = gsm_a_pd_str[pd]; - msg_str = my_match_strval((guint32) (oct & DTAP_SM_IEI_MASK), gsm_a_dtap_msg_sm_strings, &idx); + msg_str = match_strval_idx((guint32) (oct & DTAP_SM_IEI_MASK), gsm_a_dtap_msg_sm_strings, &idx); ett_tree = ett_gsm_dtap_msg_sm[idx]; hf_idx = hf_gsm_a_dtap_msg_sm_type; msg_fcn = dtap_msg_sm_fcn[idx]; @@ -16389,7 +16363,7 @@ dissect_dtap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) case 11: str = gsm_a_pd_str[pd]; - msg_str = my_match_strval((guint32) (oct & DTAP_SS_IEI_MASK), gsm_a_dtap_msg_ss_strings, &idx); + msg_str = match_strval_idx((guint32) (oct & DTAP_SS_IEI_MASK), gsm_a_dtap_msg_ss_strings, &idx); ett_tree = ett_gsm_dtap_msg_ss[idx]; hf_idx = hf_gsm_a_dtap_msg_ss_type; msg_fcn = dtap_msg_ss_fcn[idx]; diff --git a/epan/dissectors/packet-gsm_map.c b/epan/dissectors/packet-gsm_map.c index 64c4256f55..606cc8669c 100644 --- a/epan/dissectors/packet-gsm_map.c +++ b/epan/dissectors/packet-gsm_map.c @@ -12652,27 +12652,6 @@ dissect_gsm_map_UnknownOrUnreachableLCSClient_Param(gboolean implicit_tag _U_, t /*--- End of included file: packet-gsm_map-fn.c ---*/ -/* Stuff included from the "old" packet-gsm_map.c for tapping purposes */ -static gchar * -my_match_strval(guint32 val, const value_string *vs, gint *idx) -{ - gint i = 0; - - while (vs[i].strptr) { - if (vs[i].value == val) - { - *idx = i; - return(vs[i].strptr); - } - - i++; - } - - *idx = -1; - return(NULL); -} -/* End includes from old" packet-gsm_map.c */ - const value_string gsm_map_opr_code_strings[] = { { 2, "updateLocation" }, { 3, "cancelLocation" }, @@ -13554,10 +13533,9 @@ dissect_gsm_map(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) { proto_item *item=NULL; proto_tree *tree=NULL; - /* Used for gsm_map TAP */ - static gsm_map_tap_rec_t tap_rec; - gint op_idx; - gchar *str = NULL; + /* Used for gsm_map TAP */ + static gsm_map_tap_rec_t tap_rec; + gint op_idx; if (check_col(pinfo->cinfo, COL_PROTOCOL)) @@ -13565,26 +13543,24 @@ dissect_gsm_map(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) col_set_str(pinfo->cinfo, COL_PROTOCOL, "GSM MAP"); } - top_tree = parent_tree; - dissector_add("tcap.itu_ssn",pinfo->match_port, map_handle); + top_tree = parent_tree; + dissector_add("tcap.itu_ssn",pinfo->match_port, map_handle); /* create display subtree for the protocol */ if(parent_tree){ - item = proto_tree_add_item(parent_tree, proto_gsm_map, tvb, 0, -1, FALSE); - tree = proto_item_add_subtree(item, ett_gsm_map); + item = proto_tree_add_item(parent_tree, proto_gsm_map, tvb, 0, -1, FALSE); + tree = proto_item_add_subtree(item, ett_gsm_map); } dissect_gsm_map_GSMMAPPDU(FALSE, tvb, 0, pinfo, tree, -1); - str = my_match_strval(opcode, gsm_map_opr_code_strings, &op_idx); - - tap_rec.invoke = FALSE; - if ( gsmmap_pdu_type == 1 ) - tap_rec.invoke = TRUE; - tap_rec.opr_code_idx = op_idx; - tap_rec.size = gsm_map_pdu_size; - - tap_queue_packet(gsm_map_tap, pinfo, &tap_rec); + match_strval_idx(opcode, gsm_map_opr_code_strings, &op_idx); + tap_rec.invoke = FALSE; + if ( gsmmap_pdu_type == 1 ) + tap_rec.invoke = TRUE; + tap_rec.opr_code_idx = op_idx; + tap_rec.size = gsm_map_pdu_size; + tap_queue_packet(gsm_map_tap, pinfo, &tap_rec); } static const value_string ssCode_vals[] = { diff --git a/epan/dissectors/packet-gsm_sms.c b/epan/dissectors/packet-gsm_sms.c index e1c0b23f48..4c4712927f 100644 --- a/epan/dissectors/packet-gsm_sms.c +++ b/epan/dissectors/packet-gsm_sms.c @@ -140,25 +140,6 @@ static gint ett_udh_ieis[NUM_UDH_IEIS]; /* FUNCTIONS */ -gchar * -my_match_strval(guint32 val, const value_string *vs, gint *idx) -{ - gint i = 0; - - while (vs[i].strptr) { - if (vs[i].value == val) - { - *idx = i; - return(vs[i].strptr); - } - - i++; - } - - *idx = -1; - return(NULL); -} - /* 9.2.3.1 */ #define DIS_FIELD_MTI(m_tree, m_bitmask, m_offset) \ { \ @@ -2523,7 +2504,7 @@ dissect_gsm_sms(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) guint8 msg_type; guint8 oct; gint idx; - gchar *str = NULL; + const gchar *str = NULL; gint ett_msg_idx; @@ -2564,7 +2545,7 @@ dissect_gsm_sms(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) msg_type |= ((pinfo->p2p_dir == P2P_DIR_RECV) ? 0x04 : 0x00); } - str = my_match_strval(msg_type, msg_type_strings, &idx); + str = match_strval_idx(msg_type, msg_type_strings, &idx); /* * create the GSM_SMS protocol tree diff --git a/epan/dissectors/packet-gsm_ss.c b/epan/dissectors/packet-gsm_ss.c index 75f96da6e3..c40500a906 100644 --- a/epan/dissectors/packet-gsm_ss.c +++ b/epan/dissectors/packet-gsm_ss.c @@ -304,25 +304,6 @@ my_dgt_tbcd_unpack( return(cnt); } -static gchar * -my_match_strval(guint32 val, const value_string *vs, gint *idx) -{ - gint i = 0; - - while (vs[i].strptr) { - if (vs[i].value == val) - { - *idx = i; - return(vs[i].strptr); - } - - i++; - } - - *idx = -1; - return(NULL); -} - /* PARAMETER dissection */ void @@ -2501,15 +2482,12 @@ gsm_ss_dissect(ASN1_SCK *asn1, proto_tree *tree, guint exp_len, guint opr_code, guint comp_type_tag) { void (*dissect_fcn)(ASN1_SCK *asn1, proto_tree *tree, guint exp_len); - gchar *str; gint op_idx; dissect_fcn = NULL; - str = my_match_strval(opr_code, gsm_ss_opr_code_strings, &op_idx); - - if (str != NULL) + if (match_strval_idx(opr_code, gsm_ss_opr_code_strings, &op_idx) != NULL) { switch (comp_type_tag) { diff --git a/epan/dissectors/packet-h245.c b/epan/dissectors/packet-h245.c index ecd54669d8..b304a334c7 100644 --- a/epan/dissectors/packet-h245.c +++ b/epan/dissectors/packet-h245.c @@ -1,6 +1,6 @@ /* Do not modify this file. */ /* It is created automatically by the ASN.1 to Ethereal dissector compiler */ -/* .\packet-h245.c */ +/* ./packet-h245.c */ /* ../../tools/asn2eth.py -X -e -p h245 -c h245.cnf -s packet-h245-template h245.asn */ /* Input file: packet-h245-template.c */ @@ -207,7 +207,7 @@ static const value_string h245_AudioCapability_short_vals[] = { /* To put the codec type only in COL_INFO when an OLC is read */ -char* codec_type = NULL; +const char* codec_type = NULL; static char standard_oid_str[256]; static guint32 ipv4_address; static guint32 ipv4_port; @@ -2153,10 +2153,11 @@ static int dissect_type(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tre + static int dissect_h245_OBJECT_IDENTIFIER(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_object_identifier(tvb, offset, pinfo, tree, hf_index, - NULL); + NULL); return offset; } @@ -2357,7 +2358,7 @@ static int dissect_nonStandardMsg(tvbuff_t *tvb, int offset, packet_info *pinfo, static int dissect_h245_INTEGER_0_255(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 0U, 255U, NULL, NULL, FALSE); + 0U, 255U, NULL, NULL, FALSE); return offset; } @@ -2406,7 +2407,7 @@ static int dissect_temporalReference_0_255(tvbuff_t *tvb, int offset, packet_inf static int dissect_h245_INTEGER_0_16777215(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 0U, 16777215U, NULL, NULL, FALSE); + 0U, 16777215U, NULL, NULL, FALSE); return offset; } @@ -2444,7 +2445,7 @@ static int dissect_masterSlaveDetermination(tvbuff_t *tvb, int offset, packet_in static int dissect_h245_SequenceNumber(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 0U, 255U, NULL, NULL, FALSE); + 0U, 255U, NULL, NULL, FALSE); return offset; } @@ -2460,7 +2461,7 @@ static int dissect_h233AlgorithmIdentifier(tvbuff_t *tvb, int offset, packet_inf static int dissect_h245_INTEGER_1_256(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 1U, 256U, NULL, NULL, FALSE); + 1U, 256U, NULL, NULL, FALSE); return offset; } @@ -3193,7 +3194,7 @@ static int dissect_aal1(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tre static int dissect_h245_INTEGER_0_65535(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 0U, 65535U, NULL, NULL, FALSE); + 0U, 65535U, NULL, NULL, FALSE); return offset; } @@ -3280,7 +3281,7 @@ static int dissect_aal5(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tre static int dissect_h245_INTEGER_1_65535(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 1U, 65535U, NULL, NULL, FALSE); + 1U, 65535U, NULL, NULL, FALSE); return offset; } @@ -3539,7 +3540,7 @@ static int dissect_h222Capability(tvbuff_t *tvb, int offset, packet_info *pinfo, static int dissect_h245_INTEGER_0_1023(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 0U, 1023U, NULL, NULL, FALSE); + 0U, 1023U, NULL, NULL, FALSE); return offset; } @@ -3557,12 +3558,10 @@ static int dissect_pictureNumber(tvbuff_t *tvb, int offset, packet_info *pinfo, } + static int dissect_h245_NULL(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { - { proto_item *ti_tmp; - ti_tmp = proto_tree_add_item(tree, hf_index, tvb, offset>>8, 0, FALSE); - proto_item_append_text(ti_tmp, ": NULL"); - } + offset = dissect_per_null(tvb, offset, pinfo, tree, hf_index); return offset; } @@ -4379,7 +4378,7 @@ static int dissect_rtpPayloadIndication(tvbuff_t *tvb, int offset, packet_info * static int dissect_h245_INTEGER_1_15(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 1U, 15U, NULL, NULL, FALSE); + 1U, 15U, NULL, NULL, FALSE); return offset; } @@ -4392,7 +4391,7 @@ static int dissect_maximumNestingDepth(tvbuff_t *tvb, int offset, packet_info *p static int dissect_h245_INTEGER_2_255(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 2U, 255U, NULL, NULL, FALSE); + 2U, 255U, NULL, NULL, FALSE); return offset; } @@ -4500,7 +4499,7 @@ static int dissect_h223AnnexCCapability(tvbuff_t *tvb, int offset, packet_info * static int dissect_h245_INTEGER_1_19200(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 1U, 19200U, NULL, NULL, FALSE); + 1U, 19200U, NULL, NULL, FALSE); return offset; } @@ -4516,7 +4515,7 @@ static int dissect_maxBitRate_1_19200(tvbuff_t *tvb, int offset, packet_info *pi static int dissect_h245_INTEGER_1_255(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 1U, 255U, NULL, NULL, FALSE); + 1U, 255U, NULL, NULL, FALSE); return offset; } @@ -4559,7 +4558,7 @@ static int dissect_samplesPerFrame(tvbuff_t *tvb, int offset, packet_info *pinfo static int dissect_h245_INTEGER_1_65025(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 1U, 65025U, NULL, NULL, FALSE); + 1U, 65025U, NULL, NULL, FALSE); return offset; } @@ -4624,7 +4623,7 @@ static int dissect_h223Capability(tvbuff_t *tvb, int offset, packet_info *pinfo, static int dissect_h245_INTEGER_2_8191(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 2U, 8191U, NULL, NULL, FALSE); + 2U, 8191U, NULL, NULL, FALSE); return offset; } @@ -4637,7 +4636,7 @@ static int dissect_numOfDLCS(tvbuff_t *tvb, int offset, packet_info *pinfo, prot static int dissect_h245_INTEGER_1_4095(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 1U, 4095U, NULL, NULL, FALSE); + 1U, 4095U, NULL, NULL, FALSE); return offset; } @@ -4653,7 +4652,7 @@ static int dissect_n401(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tre static int dissect_h245_INTEGER_1_127(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 1U, 127U, NULL, NULL, FALSE); + 1U, 127U, NULL, NULL, FALSE); return offset; } @@ -4718,7 +4717,7 @@ static int dissect_v76Capability(tvbuff_t *tvb, int offset, packet_info *pinfo, static int dissect_h245_INTEGER_1_65536(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 1U, 65536U, NULL, NULL, FALSE); + 1U, 65536U, NULL, NULL, FALSE); return offset; } @@ -5047,7 +5046,7 @@ static int dissect_t38FaxRateManagement(tvbuff_t *tvb, int offset, packet_info * static int dissect_h245_INTEGER(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_integer(tvb, offset, pinfo, tree, hf_index, - NULL, NULL); + NULL, NULL); return offset; } @@ -5157,6 +5156,7 @@ static int dissect_t38fax(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_t } + static int dissect_h245_T_standard(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_object_identifier(tvb, offset, pinfo, tree, hf_index, @@ -5243,7 +5243,7 @@ static int dissect_capabilityIdentifier(tvbuff_t *tvb, int offset, packet_info * static int dissect_h245_INTEGER_0_4294967295(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 0U, 4294967295U, NULL, NULL, FALSE); + 0U, 4294967295U, NULL, NULL, FALSE); return offset; } @@ -5283,7 +5283,7 @@ static int dissect_expirationTime(tvbuff_t *tvb, int offset, packet_info *pinfo, static int dissect_h245_INTEGER_0_127(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 0U, 127U, NULL, NULL, FALSE); + 0U, 127U, NULL, NULL, FALSE); return offset; } @@ -5647,7 +5647,7 @@ static int dissect_mcCapability(tvbuff_t *tvb, int offset, packet_info *pinfo, p static int dissect_h245_INTEGER_1_32768_(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 1U, 32768U, NULL, NULL, TRUE); + 1U, 32768U, NULL, NULL, TRUE); return offset; } @@ -5762,7 +5762,7 @@ static int dissect_qosMode(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_ static int dissect_h245_INTEGER_1_4294967295(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 1U, 4294967295U, NULL, NULL, FALSE); + 1U, 4294967295U, NULL, NULL, FALSE); return offset; } @@ -5960,7 +5960,7 @@ static int dissect_transportCapability(tvbuff_t *tvb, int offset, packet_info *p static int dissect_h245_INTEGER_1_16(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 1U, 16U, NULL, NULL, FALSE); + 1U, 16U, NULL, NULL, FALSE); return offset; } @@ -5973,7 +5973,7 @@ static int dissect_numberOfThreads(tvbuff_t *tvb, int offset, packet_info *pinfo static int dissect_h245_INTEGER_0_15(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 0U, 15U, NULL, NULL, FALSE); + 0U, 15U, NULL, NULL, FALSE); return offset; } @@ -6125,7 +6125,7 @@ static int dissect_redundancyEncodingMethod(tvbuff_t *tvb, int offset, packet_in static int dissect_h245_CapabilityTableEntryNumber(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 1U, 65535U, NULL, NULL, FALSE); + 1U, 65535U, NULL, NULL, FALSE); return offset; } @@ -6259,7 +6259,7 @@ static int dissect_multiplexCapability(tvbuff_t *tvb, int offset, packet_info *p static int dissect_h245_INTEGER_1_4(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 1U, 4U, NULL, NULL, FALSE); + 1U, 4U, NULL, NULL, FALSE); return offset; } @@ -6296,7 +6296,7 @@ static int dissect_h261VideoCapability(tvbuff_t *tvb, int offset, packet_info *p static int dissect_h245_INTEGER_0_1073741823(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 0U, 1073741823U, NULL, NULL, FALSE); + 0U, 1073741823U, NULL, NULL, FALSE); return offset; } @@ -6309,7 +6309,7 @@ static int dissect_videoBitRate(tvbuff_t *tvb, int offset, packet_info *pinfo, p static int dissect_h245_INTEGER_0_262143(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 0U, 262143U, NULL, NULL, FALSE); + 0U, 262143U, NULL, NULL, FALSE); return offset; } @@ -6325,7 +6325,7 @@ static int dissect_additionalDecoderBuffer(tvbuff_t *tvb, int offset, packet_inf static int dissect_h245_INTEGER_0_16383(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 0U, 16383U, NULL, NULL, FALSE); + 0U, 16383U, NULL, NULL, FALSE); return offset; } @@ -6374,7 +6374,7 @@ static int dissect_h262VideoCapability(tvbuff_t *tvb, int offset, packet_info *p static int dissect_h245_INTEGER_1_32(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 1U, 32U, NULL, NULL, FALSE); + 1U, 32U, NULL, NULL, FALSE); return offset; } @@ -6399,7 +6399,7 @@ static int dissect_cif16MPI_1_32(tvbuff_t *tvb, int offset, packet_info *pinfo, static int dissect_h245_INTEGER_1_192400(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 1U, 192400U, NULL, NULL, FALSE); + 1U, 192400U, NULL, NULL, FALSE); return offset; } @@ -6412,7 +6412,7 @@ static int dissect_maxBitRate(tvbuff_t *tvb, int offset, packet_info *pinfo, pro static int dissect_h245_INTEGER_0_524287(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 0U, 524287U, NULL, NULL, FALSE); + 0U, 524287U, NULL, NULL, FALSE); return offset; } @@ -6425,7 +6425,7 @@ static int dissect_hrd_B(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tr static int dissect_h245_INTEGER_1_3600(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 1U, 3600U, NULL, NULL, FALSE); + 1U, 3600U, NULL, NULL, FALSE); return offset; } @@ -6450,7 +6450,7 @@ static int dissect_slowCif16MPI(tvbuff_t *tvb, int offset, packet_info *pinfo, p static int dissect_h245_INTEGER_M262144_262143(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - -262144, 262143U, NULL, NULL, FALSE); + -262144, 262143U, NULL, NULL, FALSE); return offset; } @@ -6538,7 +6538,7 @@ static int dissect_videoBackChannelSend(tvbuff_t *tvb, int offset, packet_info * static int dissect_h245_INTEGER_1_128(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 1U, 128U, NULL, NULL, FALSE); + 1U, 128U, NULL, NULL, FALSE); return offset; } @@ -6551,7 +6551,7 @@ static int dissect_mpuHorizMBs(tvbuff_t *tvb, int offset, packet_info *pinfo, pr static int dissect_h245_INTEGER_1_72(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 1U, 72U, NULL, NULL, FALSE); + 1U, 72U, NULL, NULL, FALSE); return offset; } @@ -6617,7 +6617,7 @@ static int dissect_refPictureSelection(tvbuff_t *tvb, int offset, packet_info *p static int dissect_h245_INTEGER_1000_1001(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 1000U, 1001U, NULL, NULL, FALSE); + 1000U, 1001U, NULL, NULL, FALSE); return offset; } @@ -6630,7 +6630,7 @@ static int dissect_clockConversionCode(tvbuff_t *tvb, int offset, packet_info *p static int dissect_h245_INTEGER_1_2048(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 1U, 2048U, NULL, NULL, FALSE); + 1U, 2048U, NULL, NULL, FALSE); return offset; } @@ -6705,7 +6705,7 @@ static int dissect_customPictureClockFrequency(tvbuff_t *tvb, int offset, packet static int dissect_h245_INTEGER_1_31(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 1U, 31U, NULL, NULL, FALSE); + 1U, 31U, NULL, NULL, FALSE); return offset; } @@ -6766,7 +6766,7 @@ static int dissect_mPI(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree static int dissect_h245_INTEGER_1_14(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 1U, 14U, NULL, NULL, FALSE); + 1U, 14U, NULL, NULL, FALSE); return offset; } @@ -7089,7 +7089,7 @@ static int dissect_spatialEnhancement(tvbuff_t *tvb, int offset, packet_info *pi static int dissect_h245_INTEGER_1_64(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 1U, 64U, NULL, NULL, FALSE); + 1U, 64U, NULL, NULL, FALSE); return offset; } @@ -7306,7 +7306,7 @@ static int dissect_g7231(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tr static int dissect_h245_INTEGER_1_448(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 1U, 448U, NULL, NULL, FALSE); + 1U, 448U, NULL, NULL, FALSE); return offset; } @@ -7343,7 +7343,7 @@ static int dissect_is11172AudioCapability(tvbuff_t *tvb, int offset, packet_info static int dissect_h245_INTEGER_1_1130(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 1U, 1130U, NULL, NULL, FALSE); + 1U, 1130U, NULL, NULL, FALSE); return offset; } @@ -7392,7 +7392,7 @@ static int dissect_is13818AudioCapability(tvbuff_t *tvb, int offset, packet_info static int dissect_h245_INTEGER_27_78(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 27U, 78U, NULL, NULL, FALSE); + 27U, 78U, NULL, NULL, FALSE); return offset; } @@ -7408,7 +7408,7 @@ static int dissect_highRateMode1(tvbuff_t *tvb, int offset, packet_info *pinfo, static int dissect_h245_INTEGER_23_66(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 23U, 66U, NULL, NULL, FALSE); + 23U, 66U, NULL, NULL, FALSE); return offset; } @@ -7424,7 +7424,7 @@ static int dissect_lowRateMode1(tvbuff_t *tvb, int offset, packet_info *pinfo, p static int dissect_h245_INTEGER_6_17(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 6U, 17U, NULL, NULL, FALSE); + 6U, 17U, NULL, NULL, FALSE); return offset; } @@ -7965,7 +7965,7 @@ static int dissect_receiveAndTransmitMultiplexedStreamCapability(tvbuff_t *tvb, static int dissect_h245_INTEGER_96_127(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 96U, 127U, NULL, NULL, FALSE); + 96U, 127U, NULL, NULL, FALSE); return offset; } @@ -8187,7 +8187,7 @@ static int dissect_capabilityTable(tvbuff_t *tvb, int offset, packet_info *pinfo static int dissect_h245_CapabilityDescriptorNumber(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 0U, 255U, NULL, NULL, FALSE); + 0U, 255U, NULL, NULL, FALSE); return offset; } @@ -8255,7 +8255,7 @@ static int dissect_terminalCapabilitySet(tvbuff_t *tvb, int offset, packet_info static int dissect_h245_LogicalChannelNumber(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 1U, 65535U, NULL, NULL, FALSE); + 1U, 65535U, NULL, NULL, FALSE); return offset; } @@ -8677,7 +8677,7 @@ dissect_h245_DataType(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_t static int dissect_h245_INTEGER_0_8191(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 0U, 8191U, NULL, NULL, FALSE); + 0U, 8191U, NULL, NULL, FALSE); return offset; } @@ -8713,7 +8713,7 @@ static int dissect_h222LogicalChannelParameters(tvbuff_t *tvb, int offset, packe static int dissect_h245_INTEGER_0_2(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 0U, 2U, NULL, NULL, FALSE); + 0U, 2U, NULL, NULL, FALSE); return offset; } @@ -8830,7 +8830,7 @@ static int dissect_crcLength2(tvbuff_t *tvb, int offset, packet_info *pinfo, pro static int dissect_h245_INTEGER_8_32(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 8U, 32U, NULL, NULL, FALSE); + 8U, 32U, NULL, NULL, FALSE); return offset; } @@ -8843,7 +8843,7 @@ static int dissect_rcpcCodeRate(tvbuff_t *tvb, int offset, packet_info *pinfo, p static int dissect_h245_INTEGER_0_16(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 0U, 16U, NULL, NULL, FALSE); + 0U, 16U, NULL, NULL, FALSE); return offset; } @@ -9674,7 +9674,7 @@ static int dissect_mediaControlChannel(tvbuff_t *tvb, int offset, packet_info *p static int dissect_h245_McuNumber(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 0U, 192U, NULL, NULL, FALSE); + 0U, 192U, NULL, NULL, FALSE); return offset; } @@ -9687,7 +9687,7 @@ static int dissect_mcuNumber(tvbuff_t *tvb, int offset, packet_info *pinfo, prot static int dissect_h245_TerminalNumber(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 0U, 192U, NULL, NULL, FALSE); + 0U, 192U, NULL, NULL, FALSE); return offset; } @@ -10276,7 +10276,7 @@ static int dissect_requestChannelClose(tvbuff_t *tvb, int offset, packet_info *p static int dissect_h245_MultiplexTableEntryNumber(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 1U, 15U, NULL, NULL, FALSE); + 1U, 15U, NULL, NULL, FALSE); return offset; } @@ -12094,7 +12094,7 @@ static int dissect_multilinkRequest(tvbuff_t *tvb, int offset, packet_info *pinf static int dissect_h245_MaximumBitRate(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 0U, 4294967295U, NULL, NULL, FALSE); + 0U, 4294967295U, NULL, NULL, FALSE); return offset; } @@ -14248,7 +14248,7 @@ static int dissect_endSessionCommand(tvbuff_t *tvb, int offset, packet_info *pin static int dissect_h245_INTEGER_0_17(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 0U, 17U, NULL, NULL, FALSE); + 0U, 17U, NULL, NULL, FALSE); return offset; } @@ -14261,7 +14261,7 @@ static int dissect_firstGOB(tvbuff_t *tvb, int offset, packet_info *pinfo, proto static int dissect_h245_INTEGER_1_18(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 1U, 18U, NULL, NULL, FALSE); + 1U, 18U, NULL, NULL, FALSE); return offset; } @@ -14291,7 +14291,7 @@ static int dissect_videoFastUpdateGOB(tvbuff_t *tvb, int offset, packet_info *pi static int dissect_h245_INTEGER_0_31(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 0U, 31U, NULL, NULL, FALSE); + 0U, 31U, NULL, NULL, FALSE); return offset; } @@ -14304,7 +14304,7 @@ static int dissect_videoTemporalSpatialTradeOff(tvbuff_t *tvb, int offset, packe static int dissect_h245_INTEGER_1_8192(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 1U, 8192U, NULL, NULL, FALSE); + 1U, 8192U, NULL, NULL, FALSE); return offset; } @@ -14418,7 +14418,7 @@ static int dissect_progressiveRefinementStart(tvbuff_t *tvb, int offset, packet_ static int dissect_h245_INTEGER_1_9216(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 1U, 9216U, NULL, NULL, FALSE); + 1U, 9216U, NULL, NULL, FALSE); return offset; } @@ -15356,7 +15356,7 @@ static int dissect_miscellaneousIndication(tvbuff_t *tvb, int offset, packet_inf static int dissect_h245_INTEGER_0_3(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 0U, 3U, NULL, NULL, FALSE); + 0U, 3U, NULL, NULL, FALSE); return offset; } @@ -15369,7 +15369,7 @@ static int dissect_estimatedReceivedJitterMantissa(tvbuff_t *tvb, int offset, pa static int dissect_h245_INTEGER_0_7(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 0U, 7U, NULL, NULL, FALSE); + 0U, 7U, NULL, NULL, FALSE); return offset; } @@ -15402,7 +15402,7 @@ static int dissect_jitterIndication(tvbuff_t *tvb, int offset, packet_info *pinf static int dissect_h245_INTEGER_0_4095(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 0U, 4095U, NULL, NULL, FALSE); + 0U, 4095U, NULL, NULL, FALSE); return offset; } @@ -15929,7 +15929,7 @@ static int dissect_mcLocationIndication(tvbuff_t *tvb, int offset, packet_info * static int dissect_h245_INTEGER_0_9(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { offset = dissect_per_constrained_integer(tvb, offset, pinfo, tree, hf_index, - 0U, 9U, NULL, NULL, FALSE); + 0U, 9U, NULL, NULL, FALSE); return offset; } diff --git a/epan/dissectors/packet-h245.h b/epan/dissectors/packet-h245.h index 2d9094c11c..2c0d3633a2 100644 --- a/epan/dissectors/packet-h245.h +++ b/epan/dissectors/packet-h245.h @@ -1,6 +1,6 @@ /* Do not modify this file. */ /* It is created automatically by the ASN.1 to Ethereal dissector compiler */ -/* .\packet-h245.h */ +/* ./packet-h245.h */ /* ../../tools/asn2eth.py -X -e -p h245 -c h245.cnf -s packet-h245-template h245.asn */ /* Input file: packet-h245-template.h */ diff --git a/epan/dissectors/packet-iapp.c b/epan/dissectors/packet-iapp.c index dcf03d9333..e95f77d4d9 100644 --- a/epan/dissectors/packet-iapp.c +++ b/epan/dissectors/packet-iapp.c @@ -185,7 +185,8 @@ static void dissect_caps(proto_item *pitem, tvbuff_t *tvb, int offset) { proto_tree *captree; int bit, val, z, thisbit; - gchar *strval, bitval[20]; + const gchar *strval; + gchar bitval[20]; captree = proto_item_add_subtree(pitem, ett_iapp_cap); val = tvb_get_guint8(tvb, offset + 3); @@ -289,7 +290,7 @@ append_pduval_str(proto_item *ti, int type, int len, tvbuff_t *tvb, int offset, { const guint8 *mac; int z, val; - gchar *strval; + const gchar *strval; proto_item_append_text(ti, " Value: "); @@ -418,7 +419,7 @@ dissect_iapp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) e_iapphdr ih; int ia_version; int ia_type; - gchar *codestrval; + const gchar *codestrval; if (check_col(pinfo->cinfo, COL_PROTOCOL)) col_set_str(pinfo->cinfo, COL_PROTOCOL, "IAPP"); diff --git a/epan/dissectors/packet-icmpv6.c b/epan/dissectors/packet-icmpv6.c index f872707ada..fa83f96c48 100644 --- a/epan/dissectors/packet-icmpv6.c +++ b/epan/dissectors/packet-icmpv6.c @@ -1016,8 +1016,8 @@ dissect_icmpv6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_item *ti, *tf = NULL; struct icmp6_hdr icmp6_hdr, *dp; struct icmp6_nodeinfo *ni = NULL; - char *codename, *typename; - char *colcodename, *coltypename; + const char *codename, *typename; + const char *colcodename, *coltypename; int len; guint length, reported_length; vec_t cksum_vec[4]; diff --git a/epan/dissectors/packet-icq.c b/epan/dissectors/packet-icq.c index 0de53f2ffa..0cd196c6ed 100644 --- a/epan/dissectors/packet-icq.c +++ b/epan/dissectors/packet-icq.c @@ -367,31 +367,31 @@ table_v5 [] = { 0x3C, 0x51, 0x54, 0x3D, 0x5E, 0x54, 0x5D, 0x4E, 0x4C, 0x39, 0x50, 0x5F, 0x5F, 0x5F, 0x3F, 0x6F, 0x47, 0x43, 0x69, 0x48, 0x33, 0x51, 0x54, 0x5D, 0x6E, 0x3C, 0x31, 0x64, 0x35, 0x5A, 0x00, 0x00 }; -static char* +static const char* findMsgType(int num) { return val_to_str(num, msgTypeCode, "Unknown"); } -static char* +static const char* findSubCmd(int num) { return val_to_str(num, serverMetaSubCmdCode, "Unknown (0x%04x)"); } -static char* +static const char* findClientCmd(int num) { return val_to_str(num, clientCmdCode, "Unknown (%u)"); } -static char* +static const char* findServerCmd(int num) { return val_to_str(num, serverCmdCode, "Unknown (%u)"); } -static char* +static const char* findStatus(int num) { return val_to_str(num, statusCode, "Unknown (0x%08x)"); diff --git a/epan/dissectors/packet-ieee80211.c b/epan/dissectors/packet-ieee80211.c index 731d8d419d..897d3aad02 100644 --- a/epan/dissectors/packet-ieee80211.c +++ b/epan/dissectors/packet-ieee80211.c @@ -961,7 +961,7 @@ dissect_vendor_specific_ie(proto_tree * tree, tvbuff_t * tvb, int offset, {48, "Delay Bound"}, {0, NULL} }; - char *field; + const char *field; snprintf(out_buff, SHORT_STR, "WME TSPEC: type %u, subtype %u, version %u", tag_val[tag_val_off + 3], tag_val[tag_val_off + 4], tag_val[tag_val_off + 5]); diff --git a/epan/dissectors/packet-image-jfif.c b/epan/dissectors/packet-image-jfif.c index 2425be08b9..a05e5de3d8 100644 --- a/epan/dissectors/packet-image-jfif.c +++ b/epan/dissectors/packet-image-jfif.c @@ -820,7 +820,7 @@ dissect_jfif(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree) * Process the remaining markers and marker segments */ while (offset < tvb_len) { - char *str; + const char *str; marker = tvb_get_ntohs(tvb, offset); str = match_strval(marker, vals_marker); if (str) { /* Known marker */ diff --git a/epan/dissectors/packet-ipdc.c b/epan/dissectors/packet-ipdc.c index 4fbd1c76f8..dfdf38d3cb 100644 --- a/epan/dissectors/packet-ipdc.c +++ b/epan/dissectors/packet-ipdc.c @@ -87,8 +87,8 @@ dissect_ipdc_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_tree *tag_tree; tvbuff_t *q931_tvb; - char *des; - char *enum_val = ""; + const char *des; + const char *enum_val = ""; char *tmp_str; char tmp_tag_text[IPDC_STR_LEN + 1]; const value_string *val_ptr; diff --git a/epan/dissectors/packet-ipp.c b/epan/dissectors/packet-ipp.c index 4b01e19cd2..88e72fe829 100644 --- a/epan/dissectors/packet-ipp.c +++ b/epan/dissectors/packet-ipp.c @@ -141,18 +141,18 @@ static const value_string status_vals[] = { static int parse_attributes(tvbuff_t *tvb, int offset, proto_tree *tree); static proto_tree *add_integer_tree(proto_tree *tree, tvbuff_t *tvb, int offset, int name_length, int value_length, guint8 tag); -static void add_integer_value(gchar *tag_desc, proto_tree *tree, +static void add_integer_value(const gchar *tag_desc, proto_tree *tree, tvbuff_t *tvb, int offset, int name_length, int value_length, guint8 tag); static proto_tree *add_octetstring_tree(proto_tree *tree, tvbuff_t *tvb, int offset, int name_length, int value_length); -static void add_octetstring_value(gchar *tag_desc, proto_tree *tree, +static void add_octetstring_value(const gchar *tag_desc, proto_tree *tree, tvbuff_t *tvb, int offset, int name_length, int value_length); static proto_tree *add_charstring_tree(proto_tree *tree, tvbuff_t *tvb, int offset, int name_length, int value_length); -static void add_charstring_value(gchar *tag_desc, proto_tree *tree, +static void add_charstring_value(const gchar *tag_desc, proto_tree *tree, + tvbuff_t *tvb, int offset, int name_length, int value_length); +static int add_value_head(const gchar *tag_desc, proto_tree *tree, tvbuff_t *tvb, int offset, int name_length, int value_length); -static int add_value_head(gchar *tag_desc, proto_tree *tree, tvbuff_t *tvb, - int offset, int name_length, int value_length); static void dissect_ipp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) @@ -298,7 +298,7 @@ static int parse_attributes(tvbuff_t *tvb, int offset, proto_tree *tree) { guint8 tag; - gchar *tag_desc; + const gchar *tag_desc; int name_length, value_length; proto_tree *as_tree = tree; proto_item *tas = NULL; @@ -494,7 +494,7 @@ add_integer_tree(proto_tree *tree, tvbuff_t *tvb, int offset, } static void -add_integer_value(gchar *tag_desc, proto_tree *tree, tvbuff_t *tvb, +add_integer_value(const gchar *tag_desc, proto_tree *tree, tvbuff_t *tvb, int offset, int name_length, int value_length, guint8 tag) { guint8 bool_val; @@ -539,7 +539,7 @@ add_octetstring_tree(proto_tree *tree, tvbuff_t *tvb, int offset, } static void -add_octetstring_value(gchar *tag_desc, proto_tree *tree, tvbuff_t *tvb, +add_octetstring_value(const gchar *tag_desc, proto_tree *tree, tvbuff_t *tvb, int offset, int name_length, int value_length) { offset = add_value_head(tag_desc, tree, tvb, offset, name_length, @@ -565,7 +565,7 @@ add_charstring_tree(proto_tree *tree, tvbuff_t *tvb, int offset, } static void -add_charstring_value(gchar *tag_desc, proto_tree *tree, tvbuff_t *tvb, +add_charstring_value(const gchar *tag_desc, proto_tree *tree, tvbuff_t *tvb, int offset, int name_length, int value_length) { offset = add_value_head(tag_desc, tree, tvb, offset, name_length, @@ -575,8 +575,8 @@ add_charstring_value(gchar *tag_desc, proto_tree *tree, tvbuff_t *tvb, } static int -add_value_head(gchar *tag_desc, proto_tree *tree, tvbuff_t *tvb, int offset, - int name_length, int value_length) +add_value_head(const gchar *tag_desc, proto_tree *tree, tvbuff_t *tvb, + int offset, int name_length, int value_length) { proto_tree_add_text(tree, tvb, offset, 1, "Tag: %s", tag_desc); offset += 1; diff --git a/epan/dissectors/packet-ipsec.c b/epan/dissectors/packet-ipsec.c index 2b29bd9c3c..ac8d9f10b0 100644 --- a/epan/dissectors/packet-ipsec.c +++ b/epan/dissectors/packet-ipsec.c @@ -292,7 +292,7 @@ dissect_ipcomp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_tree *ipcomp_tree; proto_item *ti; struct ipcomp ipcomp; - char *p; + const char *p; /* * load the top pane info. This should be overwritten by diff --git a/epan/dissectors/packet-ipv6.c b/epan/dissectors/packet-ipv6.c index 9b4bf99e0c..89b9a7f8c8 100644 --- a/epan/dissectors/packet-ipv6.c +++ b/epan/dissectors/packet-ipv6.c @@ -513,7 +513,7 @@ dissect_opts(tvbuff_t *tvb, int offset, proto_tree *tree, char *optname) break; case IP6OPT_RTALERT: { - char *rta; + const char *rta; tmp = tvb_get_guint8(tvb, p + 1); if (tmp == 2) { diff --git a/epan/dissectors/packet-isis-hello.c b/epan/dissectors/packet-isis-hello.c index e23c6f3385..197c4910f7 100644 --- a/epan/dissectors/packet-isis-hello.c +++ b/epan/dissectors/packet-isis-hello.c @@ -615,7 +615,7 @@ dissect_hello_ptp_adj_clv(tvbuff_t *tvb, { 0, NULL } }; guint8 adj_state; - char *adj_state_str; + const char *adj_state_str; adj_state = tvb_get_guint8(tvb, offset); adj_state_str = val_to_str(adj_state, adj_state_vals, "Unknown (%u)"); diff --git a/epan/dissectors/packet-laplink.c b/epan/dissectors/packet-laplink.c index c1d2a41d3c..2f737ba28d 100644 --- a/epan/dissectors/packet-laplink.c +++ b/epan/dissectors/packet-laplink.c @@ -89,7 +89,7 @@ dissect_laplink_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_item *ti; proto_tree *laplink_tree; guint32 udp_ident; - gchar *udp_ident_string; + const gchar *udp_ident_string; /* * Make sure the identifier is reasonable. diff --git a/epan/dissectors/packet-ldap.c b/epan/dissectors/packet-ldap.c index 2aa9538214..2597ee11cb 100644 --- a/epan/dissectors/packet-ldap.c +++ b/epan/dissectors/packet-ldap.c @@ -2136,7 +2136,7 @@ dissect_ldap_message(tvbuff_t *tvb, int offset, packet_info *pinfo, guint messageId; int next_offset; guint protocolOpCls, protocolOpCon, protocolOpTag; - gchar *typestr; + const gchar *typestr; guint opLen; ASN1_SCK a; int start; diff --git a/epan/dissectors/packet-lmp.c b/epan/dissectors/packet-lmp.c index d016439192..f3887620d3 100644 --- a/epan/dissectors/packet-lmp.c +++ b/epan/dissectors/packet-lmp.c @@ -1073,7 +1073,7 @@ dissect_lmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) guint8 class; guint8 type; guint8 negotiable; - char *object_type; + const char *object_type; obj_length = tvb_get_ntohs(tvb, offset+2); class = tvb_get_guint8(tvb, offset+1); diff --git a/epan/dissectors/packet-mbtcp.c b/epan/dissectors/packet-mbtcp.c index 4d9549b45f..190a26a7d9 100644 --- a/epan/dissectors/packet-mbtcp.c +++ b/epan/dissectors/packet-mbtcp.c @@ -212,7 +212,8 @@ dissect_mbtcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) int offset, group_offset, packet_type; guint i; gint packet_len, payload_start, payload_len; - char *func_string = "", pkt_type_str[9] = ""; + const char *func_string = ""; + char pkt_type_str[9] = ""; char err_str[100] = ""; guint32 byte_cnt, group_byte_cnt, group_word_cnt; guint32 packet_num; /* num to uniquely identify different mbtcp diff --git a/epan/dissectors/packet-mmse.c b/epan/dissectors/packet-mmse.c index 908a9ce0a0..703cf067d8 100644 --- a/epan/dissectors/packet-mmse.c +++ b/epan/dissectors/packet-mmse.c @@ -75,7 +75,7 @@ static void dissect_mmse_standalone(tvbuff_t *, packet_info *, proto_tree *); static void dissect_mmse_encapsulated(tvbuff_t *, packet_info *, proto_tree *); static void dissect_mmse(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, - guint8 pdut, char *message_type); + guint8 pdut, const char *message_type); /* * Header field values @@ -668,13 +668,13 @@ static void dissect_mmse_standalone(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { guint8 pdut; - char *message_type; + const char *message_type; DebugLog(("dissect_mmse_standalone() - START (Packet %u)\n", pinfo->fd->num)); pdut = tvb_get_guint8(tvb, 1); - message_type = match_strval(pdut, vals_message_type); + message_type = val_to_str(pdut, vals_message_type, "Unknown type %u"); /* Make entries in Protocol column and Info column on summary display */ if (check_col(pinfo->cinfo, COL_PROTOCOL)) @@ -692,13 +692,13 @@ static void dissect_mmse_encapsulated(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { guint8 pdut; - char *message_type; + const char *message_type; DebugLog(("dissect_mmse_encapsulated() - START (Packet %u)\n", pinfo->fd->num)); pdut = tvb_get_guint8(tvb, 1); - message_type = match_strval(pdut, vals_message_type); + message_type = val_to_str(pdut, vals_message_type, "Unknown type %u"); /* Make entries in Info column on summary display */ if (check_col(pinfo->cinfo, COL_INFO)) { @@ -711,7 +711,7 @@ dissect_mmse_encapsulated(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) static void dissect_mmse(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint8 pdut, - char *message_type) + const char *message_type) { guint offset; guint8 field = 0; @@ -1235,7 +1235,7 @@ dissect_mmse(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint8 pdut, default: if (field & 0x80) { /* Well-known WSP header encoding */ guint8 peek = tvb_get_guint8(tvb, offset); - char *hdr_name = val_to_str(field, vals_mm_header_names, + const char *hdr_name = val_to_str(field, vals_mm_header_names, "Unknown field (0x%02x)"); DebugLog(("\t\tUndecoded well-known header: %s\n", hdr_name)); diff --git a/epan/dissectors/packet-nbns.c b/epan/dissectors/packet-nbns.c index 0c9f554105..109189f355 100644 --- a/epan/dissectors/packet-nbns.c +++ b/epan/dissectors/packet-nbns.c @@ -600,7 +600,7 @@ dissect_nbns_answer(tvbuff_t *tvb, int offset, int nbns_data_offset, int name_type; int type; int class; - char *class_name; + const char *class_name; char *type_name; int data_offset; int cur_offset; diff --git a/epan/dissectors/packet-ncp2222.inc b/epan/dissectors/packet-ncp2222.inc index 9f462241c9..8fd96334a6 100644 --- a/epan/dissectors/packet-ncp2222.inc +++ b/epan/dissectors/packet-ncp2222.inc @@ -964,7 +964,7 @@ get_item_string(proto_item *item) } #endif -char * +static const char * get_item_name(proto_item *item) { return PITEM_FINFO(item)->hfinfo->name; @@ -1771,7 +1771,7 @@ print_nds_values(proto_tree *vtree, tvbuff_t *tvb, guint32 syntax_type, nds_val proto_tree *nvtree; proto_item *aditem; proto_tree *adtree; - char *valuestr = NULL; + const char *valuestr = NULL; guint16 rtype = 0; guint16 rstate = 0; guint16 rnum = 0; @@ -2178,7 +2178,7 @@ print_es_type(proto_tree *estree, tvbuff_t *tvb, nds_val *values, guint32 vtype, proto_item *nesitem; proto_tree *atree; proto_item *aitem; - char * vstring=""; + const char *vstring=""; strcpy(mval_buf.buffer, ""); @@ -2602,7 +2602,7 @@ process_multivalues(proto_tree *ncp_tree, tvbuff_t *tvb, nds_val *values) gint value5 = 0; guint32 value6 = 0; guint32 value7 = 0; - char * valuestr = ""; + const char *valuestr = ""; proto_tree *ntree; proto_tree *atree; proto_item *nitem; @@ -4790,10 +4790,10 @@ dissect_ncp_reply(tvbuff_t *tvb, packet_info *pinfo, guint32 nds_flags = 0; guint32 nds_offset = 0; nw_uni_t reply_buffer; - char * verb_string=""; + const char *verb_string=""; guint32 nds_error_code = 0; guint32 nds_reply_buffer = 0; - char * nds_error_string = NULL; + const char *nds_error_string = NULL; guint32 nds_frag=0; nds_val pvalues[9]; char string_buffer[9][1024]; @@ -4873,18 +4873,14 @@ dissect_ncp_reply(tvbuff_t *tvb, packet_info *pinfo, nds_offset += 4; nds_frag = tvb_get_letohl(tvb, nds_offset); if (nds_reply_buffer > 7) - { - nds_offset += 4; + { + nds_offset += 4; nds_error_code = tvb_get_letohl(tvb, nds_offset); nds_error_string = match_strval(nds_error_code, nds_reply_errors); if (nds_error_string == NULL) { nds_error_string = "NDS Error - No Definition Found"; } - if (nds_error_string == NULL || nds_error_code == 0x00000000) - { - nds_error_string = "Ok"; - } } } @@ -6129,7 +6125,7 @@ dissect_nds_request(tvbuff_t *tvb, packet_info *pinfo, gboolean run_req_cond = FALSE; gboolean run_info_str = FALSE; guint8 nds_verb = 0; - char * verb_string = ""; + const char *verb_string = ""; guint32 nds_frag = 0; gboolean added_arrow; nds_val pvalues[9]; diff --git a/epan/dissectors/packet-ndps.c b/epan/dissectors/packet-ndps.c index fc68a853fe..4bf955a02d 100644 --- a/epan/dissectors/packet-ndps.c +++ b/epan/dissectors/packet-ndps.c @@ -55,7 +55,7 @@ static guint32 tid = 1; static gboolean ndps_show_oids=FALSE; /* Global Attribute for evaluation of Values */ -static char *global_attribute_name=NULL; +static const char *global_attribute_name=NULL; static void dissect_ndps_request(tvbuff_t*, packet_info*, proto_tree*, guint32, guint32, int); @@ -1662,7 +1662,7 @@ static int objectidentifier(tvbuff_t* tvb, proto_tree *ndps_tree, int foffset) { guint32 length; - char *label=NULL; + const char *label=NULL; guint32 label_value=0; proto_tree *atree; proto_item *aitem; @@ -2312,7 +2312,7 @@ attribute_value(tvbuff_t* tvb, proto_tree *ndps_tree, int foffset) guint32 dimension; guint32 location; guint32 cardinal; - char *label; + const char *label; guint32 label_value; proto_tree *atree; proto_item *aitem; @@ -2402,7 +2402,8 @@ attribute_value(tvbuff_t* tvb, proto_tree *ndps_tree, int foffset) case 57: /* Job Priority */ case 72: /* Sides */ case 95: /* Enumeration */ - if (strcmp(global_attribute_name,"(Novell) Attribute PRINTER SECURITY LEVEL")==0) + if (global_attribute_name != NULL && + strcmp(global_attribute_name,"(Novell) Attribute PRINTER SECURITY LEVEL")==0) { proto_tree_add_item(ndps_tree, hf_print_security, tvb, foffset, 4, FALSE); foffset += 4; diff --git a/epan/dissectors/packet-netbios.c b/epan/dissectors/packet-netbios.c index 863c2bc152..2370312cea 100644 --- a/epan/dissectors/packet-netbios.c +++ b/epan/dissectors/packet-netbios.c @@ -331,7 +331,7 @@ int get_netbios_name( tvbuff_t *tvb, int offset, char *name_ret) /* * Get a string describing the type of a NetBIOS name. */ -char * +const char * netbios_name_type_descr(int name_type) { return val_to_str(name_type, nb_name_type_vals, "Unknown"); @@ -346,7 +346,7 @@ void netbios_add_name(char* label, tvbuff_t *tvb, int offset, proto_item *tf; char name_str[(NETBIOS_NAME_LEN - 1)*4 + 1]; int name_type; - char *name_type_str; + const char *name_type_str; /* decode the name field */ name_type = get_netbios_name( tvb, offset, name_str); @@ -1090,7 +1090,7 @@ dissect_netbios(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_tree *netb_tree = NULL; proto_item *ti; guint16 hdr_len, command; - char *command_name; + const char *command_name; char name[(NETBIOS_NAME_LEN - 1)*4 + 1]; int name_type; guint16 session_id; diff --git a/epan/dissectors/packet-netbios.h b/epan/dissectors/packet-netbios.h index 6bc1d51ac5..8568d5da0a 100644 --- a/epan/dissectors/packet-netbios.h +++ b/epan/dissectors/packet-netbios.h @@ -37,7 +37,7 @@ void capture_netbios(packet_counts *); extern int process_netbios_name(const guchar *name_ptr, char *name_ret); extern int get_netbios_name(tvbuff_t *tvb, int offset, char *name_ret); -extern char *netbios_name_type_descr(int name_type); +extern const char *netbios_name_type_descr(int name_type); extern void netbios_add_name( char* label, tvbuff_t *tvb, int offset, proto_tree *tree); extern void dissect_netbios_payload(tvbuff_t *tvb, packet_info *pinfo, diff --git a/epan/dissectors/packet-nfs.c b/epan/dissectors/packet-nfs.c index 1c15699317..256ff514da 100644 --- a/epan/dissectors/packet-nfs.c +++ b/epan/dissectors/packet-nfs.c @@ -1801,7 +1801,7 @@ static int dissect_nfs2_rmdir_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree* tree) { guint32 status; - char *err; + const char *err; offset = dissect_stat(tvb, offset, tree, &status); switch (status) { @@ -1823,7 +1823,7 @@ static int dissect_nfs2_symlink_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree* tree) { guint32 status; - char *err; + const char *err; offset = dissect_stat(tvb, offset, tree, &status); switch (status) { @@ -1845,7 +1845,7 @@ static int dissect_nfs2_link_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree* tree) { guint32 status; - char *err; + const char *err; offset = dissect_stat(tvb, offset, tree, &status); switch (status) { @@ -1867,7 +1867,7 @@ static int dissect_nfs2_rename_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree* tree) { guint32 status; - char *err; + const char *err; offset = dissect_stat(tvb, offset, tree, &status); switch (status) { @@ -1889,7 +1889,7 @@ static int dissect_nfs2_remove_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree* tree) { guint32 status; - char *err; + const char *err; offset = dissect_stat(tvb, offset, tree, &status); switch (status) { @@ -1921,7 +1921,7 @@ static int dissect_ftype(tvbuff_t *tvb, int offset, proto_tree *tree, char* name) { guint32 ftype; - char* ftype_name = NULL; + const char* ftype_name = NULL; const value_string nfs2_ftype[] = { @@ -2267,7 +2267,7 @@ static int dissect_attrstat(tvbuff_t *tvb, int offset, proto_tree *tree, packet_info *pinfo, char *funcname) { guint32 status; - char *err; + const char *err; offset = dissect_stat(tvb, offset, tree, &status); switch (status) { @@ -2415,7 +2415,7 @@ dissect_diropres(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree { guint32 status; guint32 hash; - char *err; + const char *err; offset = dissect_stat(tvb, offset, tree, &status); switch (status) { @@ -2499,7 +2499,7 @@ dissect_nfs2_readlink_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) { guint32 status; - char *err; + const char *err; char *name=NULL; offset = dissect_stat(tvb, offset, tree, &status); @@ -2564,7 +2564,7 @@ dissect_nfs2_read_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree* tree) { guint32 status; - char *err; + const char *err; offset = dissect_stat(tvb, offset, tree, &status); switch (status) { @@ -2812,7 +2812,7 @@ dissect_nfs2_readdir_reply(tvbuff_t *tvb, int offset, packet_info *pinfo, { guint32 status; guint32 eof_value; - char *err; + const char *err; offset = dissect_stat(tvb, offset, tree, &status); switch (status) { @@ -2851,7 +2851,7 @@ dissect_nfs2_statfs_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, guint32 blocks; guint32 bfree; guint32 bavail; - char *err; + const char *err; offset = dissect_stat(tvb, offset, tree, &status); switch (status) { @@ -3524,7 +3524,7 @@ dissect_set_mode3(tvbuff_t *tvb, int offset, proto_tree *tree, char* name) proto_tree* set_mode3_tree = NULL; int old_offset = offset; guint32 set_it; - char* set_it_name; + const char* set_it_name; set_it = tvb_get_ntohl(tvb, offset+0); set_it_name = val_to_str(set_it,value_follows,"Unknown"); @@ -3569,7 +3569,7 @@ dissect_set_uid3(tvbuff_t *tvb, int offset, proto_tree *tree, char* name) proto_tree* set_uid3_tree = NULL; int old_offset = offset; guint32 set_it; - char* set_it_name; + const char* set_it_name; set_it = tvb_get_ntohl(tvb, offset+0); set_it_name = val_to_str(set_it,value_follows,"Unknown"); @@ -3614,7 +3614,7 @@ dissect_set_gid3(tvbuff_t *tvb, int offset, proto_tree *tree, char* name) proto_tree* set_gid3_tree = NULL; int old_offset = offset; guint32 set_it; - char* set_it_name; + const char* set_it_name; set_it = tvb_get_ntohl(tvb, offset+0); set_it_name = val_to_str(set_it,value_follows,"Unknown"); @@ -3659,7 +3659,7 @@ dissect_set_size3(tvbuff_t *tvb, int offset, proto_tree *tree, char* name) proto_tree* set_size3_tree = NULL; int old_offset = offset; guint32 set_it; - char* set_it_name; + const char* set_it_name; set_it = tvb_get_ntohl(tvb, offset+0); set_it_name = val_to_str(set_it,value_follows,"Unknown"); @@ -3718,7 +3718,7 @@ dissect_set_atime(tvbuff_t *tvb, int offset, proto_tree *tree, char* name) proto_tree* set_atime_tree = NULL; int old_offset = offset; guint32 set_it; - char* set_it_name; + const char* set_it_name; set_it = tvb_get_ntohl(tvb, offset+0); set_it_name = val_to_str(set_it,time_how,"Unknown"); @@ -3765,7 +3765,7 @@ dissect_set_mtime(tvbuff_t *tvb, int offset, proto_tree *tree, char* name) proto_tree* set_mtime_tree = NULL; int old_offset = offset; guint32 set_it; - char* set_it_name; + const char* set_it_name; set_it = tvb_get_ntohl(tvb, offset+0); set_it_name = val_to_str(set_it,time_how,"Unknown"); @@ -4002,7 +4002,7 @@ dissect_nfs3_getattr_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree* tree) { guint32 status; - char *err; + const char *err; offset = dissect_nfsstat3(tvb, offset, tree, &status); switch (status) { @@ -4033,7 +4033,7 @@ dissect_sattrguard3(tvbuff_t *tvb, int offset, proto_tree* tree, char *name) proto_tree* sattrguard3_tree = NULL; int old_offset = offset; guint32 check; - char* check_name; + const char* check_name; check = tvb_get_ntohl(tvb, offset+0); check_name = val_to_str(check,value_follows,"Unknown"); @@ -4096,7 +4096,7 @@ dissect_nfs3_setattr_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree* tree) { guint32 status; - char *err; + const char *err; offset = dissect_nfsstat3(tvb, offset, tree, &status); switch (status) { @@ -4145,7 +4145,7 @@ dissect_nfs3_lookup_reply(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree* tree) { guint32 status; - char *err; + const char *err; guint32 hash; offset = dissect_nfsstat3(tvb, offset, tree, &status); @@ -4203,7 +4203,7 @@ dissect_nfs3_access_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree* tree) { guint32 status; - char *err; + const char *err; offset = dissect_nfsstat3(tvb, offset, tree, &status); switch (status) { @@ -4251,7 +4251,7 @@ dissect_nfs3_readlink_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree* tree) { guint32 status; - char *err; + const char *err; char *name=NULL; offset = dissect_nfsstat3(tvb, offset, tree, &status); @@ -4318,7 +4318,7 @@ dissect_nfs3_read_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, { guint32 status; guint32 len; - char *err; + const char *err; offset = dissect_nfsstat3(tvb, offset, tree, &status); switch (status) { @@ -4418,7 +4418,7 @@ dissect_nfs3_write_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, guint32 status; guint32 len; guint32 stable; - char *err; + const char *err; offset = dissect_nfsstat3(tvb, offset, tree, &status); switch (status) { @@ -4516,7 +4516,7 @@ dissect_nfs3_create_reply(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree* tree) { guint32 status; - char *err; + const char *err; offset = dissect_nfsstat3(tvb, offset, tree, &status); switch (status) { @@ -4567,7 +4567,7 @@ dissect_nfs3_mkdir_reply(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree* tree) { guint32 status; - char *err; + const char *err; offset = dissect_nfsstat3(tvb, offset, tree, &status); switch (status) { @@ -4620,7 +4620,7 @@ dissect_nfs3_symlink_reply(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree* tree) { guint32 status; - char *err; + const char *err; offset = dissect_nfsstat3(tvb, offset, tree, &status); switch (status) { @@ -4654,7 +4654,7 @@ dissect_nfs3_mknod_call(tvbuff_t *tvb, int offset, packet_info *pinfo, guint32 type; guint32 hash; char *name=NULL; - char *type_str; + const char *type_str; offset = dissect_diropargs3(tvb, offset, pinfo, tree, "where", &hash, &name); offset = dissect_ftype3(tvb, offset, tree, hf_nfs_ftype3, &type); @@ -4687,7 +4687,7 @@ dissect_nfs3_mknod_reply(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree* tree) { guint32 status; - char *err; + const char *err; offset = dissect_nfsstat3(tvb, offset, tree, &status); switch (status) { @@ -4719,7 +4719,7 @@ dissect_nfs3_remove_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree* tree) { guint32 status; - char *err; + const char *err; offset = dissect_nfsstat3(tvb, offset, tree, &status); switch (status) { @@ -4744,7 +4744,7 @@ dissect_nfs3_rmdir_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree* tree) { guint32 status; - char *err; + const char *err; offset = dissect_nfsstat3(tvb, offset, tree, &status); switch (status) { @@ -4796,7 +4796,7 @@ dissect_nfs3_rename_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree* tree) { guint32 status; - char *err; + const char *err; offset = dissect_nfsstat3(tvb, offset, tree, &status); switch (status) { @@ -4849,7 +4849,7 @@ dissect_nfs3_link_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree* tree) { guint32 status; - char *err; + const char *err; offset = dissect_nfsstat3(tvb, offset, tree, &status); switch (status) { @@ -4945,7 +4945,7 @@ dissect_nfs3_readdir_reply(tvbuff_t *tvb, int offset, packet_info *pinfo, { guint32 status; guint32 eof_value; - char *err; + const char *err; offset = dissect_stat(tvb, offset, tree, &status); switch (status) { @@ -5076,7 +5076,7 @@ dissect_nfs3_readdirplus_reply(tvbuff_t *tvb, int offset, packet_info *pinfo, { guint32 status; guint32 eof_value; - char *err; + const char *err; offset = dissect_stat(tvb, offset, tree, &status); switch (status) { @@ -5133,7 +5133,7 @@ dissect_nfs3_fsstat_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, { guint32 status; guint32 invarsec; - char *err; + const char *err; offset = dissect_nfsstat3(tvb, offset, tree, &status); switch (status) { @@ -5212,7 +5212,7 @@ dissect_nfs3_fsinfo_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, guint32 properties; proto_item* properties_item = NULL; proto_tree* properties_tree = NULL; - char *err; + const char *err; offset = dissect_nfsstat3(tvb, offset, tree, &status); switch (status) { @@ -5338,7 +5338,7 @@ dissect_nfs3_pathconf_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, guint32 status; guint32 linkmax; guint32 name_max; - char *err; + const char *err; offset = dissect_nfsstat3(tvb, offset, tree, &status); switch (status) { @@ -5408,7 +5408,7 @@ dissect_nfs3_commit_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree* tree) { guint32 status; - char *err; + const char *err; offset = dissect_nfsstat3(tvb, offset, tree, &status); switch (status) { diff --git a/epan/dissectors/packet-ospf.c b/epan/dissectors/packet-ospf.c index f0fc89877e..5ae181057d 100644 --- a/epan/dissectors/packet-ospf.c +++ b/epan/dissectors/packet-ospf.c @@ -1007,7 +1007,7 @@ dissect_ospf_lsa_mpls(tvbuff_t *tvb, int offset, proto_tree *tree, int tlv_end_offset; int stlv_type, stlv_len, stlv_offset; - char *stlv_name; + const char *stlv_name; guint32 stlv_admingrp, mask; int i; guint8 switch_cap; diff --git a/epan/dissectors/packet-pgsql.c b/epan/dissectors/packet-pgsql.c index 1d9264ac1a..308f75adb1 100644 --- a/epan/dissectors/packet-pgsql.c +++ b/epan/dissectors/packet-pgsql.c @@ -88,9 +88,53 @@ static void dissect_pgsql_fe_msg(guchar, guint, tvbuff_t *, gint, proto_tree *); static void dissect_pgsql_be_msg(guchar, guint, tvbuff_t *, gint, proto_tree *); static void dissect_pgsql_msg(tvbuff_t *, packet_info *, proto_tree *); static void dissect_pgsql(tvbuff_t *, packet_info *, proto_tree *); -static const char *identify(gboolean, guchar); static guint pgsql_length(tvbuff_t *, int); +static const value_string fe_messages[] = { + { 'p', "Password message" }, + { 'Q', "Simple query" }, + { 'P', "Parse" }, + { 'B', "Bind" }, + { 'E', "Execute" }, + { 'D', "Describe" }, + { 'C', "Close" }, + { 'H', "Flush" }, + { 'S', "Sync" }, + { 'F', "Function call" }, + { 'd', "Copy data" }, + { 'c', "Copy completion" }, + { 'f', "Copy failure" }, + { 'X', "Termination" }, + { 0, NULL } +}; + +static const value_string be_messages[] = { + { 'R', "Authentication request" }, + { 'K', "Backend key data" }, + { 'S', "Parameter status" }, + { '1', "Parse completion" }, + { '2', "Bind completion" }, + { '3', "Close completion" }, + { 'C', "Command completion" }, + { 't', "Parameter description" }, + { 'T', "Row description" }, + { 'D', "Data row" }, + { 'I', "Empty query" }, + { 'n', "No data" }, + { 'E', "Error" }, + { 'N', "Notice" }, + { 's', "Portal suspended" }, + { 'Z', "Ready for query" }, + { 'A', "Notification" }, + { 'V', "Function call response" }, + { 'G', "CopyIn response" }, + { 'H', "CopyOut response" }, + { 'd', "Copy data" }, + { 'c', "Copy completion" }, + { 0, NULL } +}; + + static const value_string auth_types[] = { { 0, "Success" }, { 1, "Kerberos V4" }, @@ -381,23 +425,29 @@ dissect_pgsql_msg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) n += 1; length = tvb_get_ntohl(tvb, n); - /* There are a few frontend messages that have no leading type byte. - We identify them by the fact that the first byte of their length - must be zero, and that the next four bytes are a unique tag. */ - if (fe && type == '\0') { - guint tag = tvb_get_ntohl(tvb, 4); - - if (length == 16 && tag == 80877102) - typestr = "Cancel request"; - else if (length == 8 && tag == 80877103) - typestr = "SSL request"; - else if (tag == 196608) - typestr = "Startup message"; - else - typestr = "Unknown"; + /* This is like specifying VALS(messages) for hf_type, which we can't do + directly because of messages without type bytes, and because the type + interpretation depends on fe. */ + if (fe) { + /* There are a few frontend messages that have no leading type byte. + We identify them by the fact that the first byte of their length + must be zero, and that the next four bytes are a unique tag. */ + if (type == '\0') { + guint tag = tvb_get_ntohl(tvb, 4); + + if (length == 16 && tag == 80877102) + typestr = "Cancel request"; + else if (length == 8 && tag == 80877103) + typestr = "SSL request"; + else if (tag == 196608) + typestr = "Startup message"; + else + typestr = "Unknown"; + } else + typestr = val_to_str(type, fe_messages, "Unknown"); } else { - typestr = identify(fe, type); + typestr = val_to_str(type, be_messages, "Unknown"); } if (info) { @@ -430,25 +480,6 @@ dissect_pgsql_msg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) } -static const value_string fe_messages[] = { - { 'p', "Password message" }, - { 'Q', "Simple query" }, - { 'P', "Parse" }, - { 'B', "Bind" }, - { 'E', "Execute" }, - { 'D', "Describe" }, - { 'C', "Close" }, - { 'H', "Flush" }, - { 'S', "Sync" }, - { 'F', "Function call" }, - { 'd', "Copy data" }, - { 'c', "Copy completion" }, - { 'f', "Copy failure" }, - { 'X', "Termination" }, - { 0, NULL } -}; - - static void dissect_pgsql_fe_msg(guchar type, guint length, tvbuff_t *tvb, gint n, proto_tree *tree) { @@ -664,33 +695,6 @@ static void dissect_pgsql_fe_msg(guchar type, guint length, tvbuff_t *tvb, } -static const value_string be_messages[] = { - { 'R', "Authentication request" }, - { 'K', "Backend key data" }, - { 'S', "Parameter status" }, - { '1', "Parse completion" }, - { '2', "Bind completion" }, - { '3', "Close completion" }, - { 'C', "Command completion" }, - { 't', "Parameter description" }, - { 'T', "Row description" }, - { 'D', "Data row" }, - { 'I', "Empty query" }, - { 'n', "No data" }, - { 'E', "Error" }, - { 'N', "Notice" }, - { 's', "Portal suspended" }, - { 'Z', "Ready for query" }, - { 'A', "Notification" }, - { 'V', "Function call response" }, - { 'G', "CopyIn response" }, - { 'H', "CopyOut response" }, - { 'd', "Copy data" }, - { 'c', "Copy completion" }, - { 0, NULL } -}; - - static void dissect_pgsql_be_msg(guchar type, guint length, tvbuff_t *tvb, gint n, proto_tree *tree) { @@ -870,27 +874,3 @@ static void dissect_pgsql_be_msg(guchar type, guint length, tvbuff_t *tvb, break; } } - - -/* This is like specifying VALS(messages) for hf_type, which we can't do - directly because of messages without type bytes, and because the type - interpretation depends on fe. */ - -static const char *identify(gboolean fe, guchar type) -{ - int i = 0; - const value_string *messages; - - if (fe) - messages = fe_messages; - else - messages = be_messages; - - while (messages[i].strptr) { - if (messages[i].value == type) - return messages[i].strptr; - i++; - } - - return "Unknown"; -} diff --git a/epan/dissectors/packet-pim.c b/epan/dissectors/packet-pim.c index 1aad390066..a4a9f35622 100644 --- a/epan/dissectors/packet-pim.c +++ b/epan/dissectors/packet-pim.c @@ -611,7 +611,7 @@ dissect_pim(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { guint16 pim_cksum, computed_cksum; vec_t cksum_vec[4]; guint32 phdr[2]; - char *typestr; + const char *typestr; proto_tree *pim_tree = NULL; proto_item *ti; proto_tree *pimopt_tree = NULL; diff --git a/epan/dissectors/packet-pppoe.c b/epan/dissectors/packet-pppoe.c index 9ab20c93d4..9f540c58fe 100644 --- a/epan/dissectors/packet-pppoe.c +++ b/epan/dissectors/packet-pppoe.c @@ -60,7 +60,7 @@ static dissector_handle_t ppp_handle; #define PPPOE_TAG_AC_ERR 0x0202 #define PPPOE_TAG_GENERIC_ERR 0x0203 -static gchar * +static const gchar * pppoecode_to_str(guint8 codetype, const char *fmt) { static const value_string code_vals[] = { {PPPOE_CODE_SESSION, "Session Data" }, @@ -74,7 +74,7 @@ pppoecode_to_str(guint8 codetype, const char *fmt) { return val_to_str(codetype, code_vals, fmt); } -static gchar * +static const gchar * pppoetag_to_str(guint16 tag_type, const char *fmt) { static const value_string code_vals[] = { {PPPOE_TAG_EOL, "End-Of-List" }, diff --git a/epan/dissectors/packet-radius.c b/epan/dissectors/packet-radius.c index 8ba3219190..0b5dfb1eea 100644 --- a/epan/dissectors/packet-radius.c +++ b/epan/dissectors/packet-radius.c @@ -3611,7 +3611,7 @@ rddecryptpass(gchar *dest,tvbuff_t *tvb,int offset,int length) dest[totlen+1] = '\0'; } -static gchar *rd_match_strval(guint32 val, const value_string *vs) { +static const gchar *rd_match_strval(guint32 val, const value_string *vs) { return val_to_str(val, vs, "Undefined"); } @@ -4376,7 +4376,6 @@ static void dissect_radius(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) e_radiushdr rh; gchar *hex_authenticator; - gchar *codestrval; if (check_col(pinfo->cinfo, COL_PROTOCOL)) col_set_str(pinfo->cinfo, COL_PROTOCOL, "RADIUS"); @@ -4390,11 +4389,6 @@ static void dissect_radius(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) rhlength = g_ntohs(rh.rh_pktlength); hdrlength = RD_HDR_LENGTH + AUTHENTICATOR_LENGTH; avplength = rhlength - hdrlength; - codestrval = match_strval(rhcode,radius_vals); - if (codestrval==NULL) - { - codestrval="Unknown Packet"; - } /* XXX Check for valid length value: * Length * @@ -4410,7 +4404,8 @@ static void dissect_radius(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) if (check_col(pinfo->cinfo, COL_INFO)) { col_add_fstr(pinfo->cinfo,COL_INFO,"%s(%d) (id=%d, l=%d)", - codestrval, rhcode, rhident, rhlength); + val_to_str(rhcode,radius_vals,"Unknown Packet"), + rhcode, rhident, rhlength); } if (tree) diff --git a/epan/dissectors/packet-rmcp.c b/epan/dissectors/packet-rmcp.c index 3c2de464cb..081dfafc37 100644 --- a/epan/dissectors/packet-rmcp.c +++ b/epan/dissectors/packet-rmcp.c @@ -86,7 +86,7 @@ dissect_rmcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_item *ti, *tf; tvbuff_t *next_tvb; guint8 class; - gchar *class_str; + const gchar *class_str; guint8 type; /* diff --git a/epan/dissectors/packet-rpc.c b/epan/dissectors/packet-rpc.c index 2a19b3e9a0..56b8a63309 100644 --- a/epan/dissectors/packet-rpc.c +++ b/epan/dissectors/packet-rpc.c @@ -1664,9 +1664,9 @@ dissect_rpc_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, unsigned int accept_state; unsigned int reject_state; - char *msg_type_name = NULL; + const char *msg_type_name = NULL; char *progname = NULL; - char *procname = NULL; + const char *procname = NULL; static char procname_static[20]; unsigned int vers_low; diff --git a/epan/dissectors/packet-rsvp.c b/epan/dissectors/packet-rsvp.c index 9b45366104..dffe25fd8f 100644 --- a/epan/dissectors/packet-rsvp.c +++ b/epan/dissectors/packet-rsvp.c @@ -1226,7 +1226,7 @@ static void dissect_rsvp_session (proto_tree *ti, tvbuff_t *tvb, int offset, int obj_length, int class, int type, - char *type_str) + const char *type_str) { int offset2 = offset + 4; proto_tree *rsvp_object_tree; @@ -1435,7 +1435,7 @@ static void dissect_rsvp_hop (proto_tree *ti, tvbuff_t *tvb, int offset, int obj_length, int class, int type, - char *type_str) + const char *type_str) { int offset2 = offset + 4; proto_tree *rsvp_object_tree; @@ -1506,7 +1506,7 @@ static void dissect_rsvp_time_values (proto_tree *ti, tvbuff_t *tvb, int offset, int obj_length, int class, int type, - char *type_str) + const char *type_str) { int offset2 = offset + 4; proto_tree *rsvp_object_tree; @@ -1592,7 +1592,7 @@ static void dissect_rsvp_error (proto_tree *ti, tvbuff_t *tvb, int offset, int obj_length, int class, int type, - char *type_str) + const char *type_str) { int offset2 = offset + 4; proto_tree *rsvp_object_tree; @@ -1689,7 +1689,7 @@ static void dissect_rsvp_scope (proto_tree *ti, tvbuff_t *tvb, int offset, int obj_length, int class, int type, - char *type_str) + const char *type_str) { int offset2 = offset + 4; proto_tree *rsvp_object_tree; @@ -1745,7 +1745,7 @@ static void dissect_rsvp_style (proto_tree *ti, tvbuff_t *tvb, int offset, int obj_length, int class, int type, - char *type_str) + const char *type_str) { int offset2 = offset + 4; proto_tree *rsvp_object_tree; @@ -1792,7 +1792,7 @@ static void dissect_rsvp_confirm (proto_tree *ti, tvbuff_t *tvb, int offset, int obj_length, int class, int type, - char *type_str) + const char *type_str) { int offset2 = offset + 4; proto_tree *rsvp_object_tree; @@ -1840,7 +1840,7 @@ static void dissect_rsvp_template_filter (proto_tree *ti, tvbuff_t *tvb, int offset, int obj_length, int class, int type, - char *type_str) + const char *type_str) { int offset2 = offset + 4; proto_tree *rsvp_object_tree; @@ -1917,7 +1917,7 @@ static void dissect_rsvp_tspec (proto_tree *ti, tvbuff_t *tvb, int offset, int obj_length, int class, int type, - char *type_str) + const char *type_str) { int offset2 = offset + 4; proto_tree *rsvp_object_tree; @@ -2213,7 +2213,7 @@ static void dissect_rsvp_flowspec (proto_tree *ti, tvbuff_t *tvb, int offset, int obj_length, int class, int type, - char *type_str) + const char *type_str) { int offset2 = offset + 4; proto_tree *rsvp_object_tree; @@ -2508,7 +2508,7 @@ static void dissect_rsvp_adspec (proto_tree *ti, tvbuff_t *tvb, int offset, int obj_length, int class, int type, - char *type_str) + const char *type_str) { int offset2 = offset + 4; proto_tree *rsvp_object_tree; @@ -2537,7 +2537,7 @@ dissect_rsvp_adspec (proto_tree *ti, tvbuff_t *tvb, guint8 service_num; guint8 break_bit; guint16 length; - char *str; + const char *str; service_num = tvb_get_guint8(tvb, offset2); str = val_to_str(service_num, intsrv_services_str, "Unknown"); @@ -2621,7 +2621,7 @@ static void dissect_rsvp_integrity (proto_tree *ti, tvbuff_t *tvb, int offset, int obj_length, int class, int type, - char *type_str) + const char *type_str) { int offset2 = offset + 4; proto_tree *rsvp_object_tree; @@ -2657,7 +2657,7 @@ static void dissect_rsvp_policy (proto_tree *ti, tvbuff_t *tvb, int offset, int obj_length, int class, int type, - char *type_str) + const char *type_str) { int offset2 = offset + 4; proto_tree *rsvp_object_tree; @@ -2681,7 +2681,7 @@ static void dissect_rsvp_label_request (proto_tree *ti, tvbuff_t *tvb, int offset, int obj_length, int class, int type, - char *type_str) + const char *type_str) { int offset2 = offset + 4; proto_tree *rsvp_object_tree; @@ -2827,7 +2827,7 @@ static void dissect_rsvp_label (proto_tree *ti, tvbuff_t *tvb, int offset, int obj_length, int class, int type, - char *type_str) + const char *type_str) { int offset2 = offset + 4; proto_tree *rsvp_object_tree; @@ -2890,7 +2890,7 @@ static void dissect_rsvp_label_set (proto_tree *ti, tvbuff_t *tvb, int offset, int obj_length, int class, int type, - char *type_str) + const char *type_str) { int offset2 = offset + 8; proto_tree *rsvp_object_tree; @@ -2934,7 +2934,7 @@ static void dissect_rsvp_session_attribute (proto_tree *ti, tvbuff_t *tvb, int offset, int obj_length, int class, int type, - char *type_str) + const char *type_str) { int offset2 = offset + 4; proto_tree *rsvp_object_tree; @@ -3365,7 +3365,7 @@ static void dissect_rsvp_explicit_route (proto_tree *ti, tvbuff_t *tvb, int offset, int obj_length, int class, int type, - char *type_str) + const char *type_str) { /* int offset2 = offset + 4; */ proto_tree *rsvp_object_tree; @@ -3406,7 +3406,7 @@ static void dissect_rsvp_record_route (proto_tree *ti, tvbuff_t *tvb, int offset, int obj_length, int class, int type, - char *type_str) + const char *type_str) { /* int offset2 = offset + 4; */ proto_tree *rsvp_object_tree; @@ -3447,7 +3447,7 @@ static void dissect_rsvp_message_id (proto_tree *ti, tvbuff_t *tvb, int offset, int obj_length, int class, int type, - char *type_str) + const char *type_str) { int offset2 = offset + 4; proto_tree *rsvp_object_tree; @@ -3490,7 +3490,7 @@ static void dissect_rsvp_message_id_ack (proto_tree *ti, tvbuff_t *tvb, int offset, int obj_length, int class, int type, - char *type_str) + const char *type_str) { int offset2 = offset + 4; proto_tree *rsvp_object_tree; @@ -3543,7 +3543,7 @@ static void dissect_rsvp_message_id_list (proto_tree *ti, tvbuff_t *tvb, int offset, int obj_length, int class, int type, - char *type_str) + const char *type_str) { int offset2 = offset + 4; proto_tree *rsvp_object_tree; @@ -3588,7 +3588,7 @@ static void dissect_rsvp_hello (proto_tree *ti, tvbuff_t *tvb, int offset, int obj_length, int class, int type, - char *type_str) + const char *type_str) { proto_tree *rsvp_object_tree; @@ -3627,7 +3627,7 @@ static void dissect_rsvp_dclass (proto_tree *ti, tvbuff_t *tvb, int offset, int obj_length, int class, int type, - char *type_str) + const char *type_str) { int offset2 = offset + 4; proto_tree *rsvp_object_tree; @@ -3675,7 +3675,7 @@ static void dissect_rsvp_admin_status (proto_tree *ti, tvbuff_t *tvb, int offset, int obj_length, int class, int type, - char *type_str) + const char *type_str) { int offset2 = offset + 4; proto_tree *rsvp_object_tree; @@ -3739,7 +3739,7 @@ static void dissect_rsvp_lsp_tunnel_if_id (proto_tree *ti, tvbuff_t *tvb, int offset, int obj_length, int class, int type, - char *type_str) + const char *type_str) { int offset2 = offset + 4; proto_tree *rsvp_object_tree; @@ -3782,7 +3782,7 @@ static void dissect_rsvp_gen_uni (proto_tree *ti, tvbuff_t *tvb, int offset, int obj_length, int class, int type, - char *type_str) + const char *type_str) { int offset2 = offset + 4; proto_tree *rsvp_object_tree; @@ -4070,7 +4070,7 @@ static void dissect_rsvp_call_id (proto_tree *ti, tvbuff_t *tvb, int offset, int obj_length, int class, int c_type, - char *type_str) + const char *type_str) { int type; char *str; @@ -4194,7 +4194,7 @@ static void dissect_rsvp_restart_cap (proto_tree *ti, tvbuff_t *tvb, int offset, int obj_length, int class, int type, - char *type_str) + const char *type_str) { int offset2 = offset + 4; proto_tree *rsvp_object_tree; @@ -4237,7 +4237,7 @@ static void dissect_rsvp_protection_info (proto_tree *ti, tvbuff_t *tvb, int offset, int obj_length, int class, int type, - char *type_str) + const char *type_str) { int offset2 = offset + 4; proto_tree *rsvp_object_tree; @@ -4280,7 +4280,7 @@ static void dissect_rsvp_fast_reroute (proto_tree *ti, tvbuff_t *tvb, int offset, int obj_length, int class, int type, - char *type_str) + const char *type_str) { proto_tree *rsvp_object_tree; guint8 flags; @@ -4357,7 +4357,7 @@ static void dissect_rsvp_detour (proto_tree *ti, tvbuff_t *tvb, int offset, int obj_length, int class, int type, - char *type_str) + const char *type_str) { proto_tree *rsvp_object_tree; int remaining_length, count; @@ -4412,7 +4412,7 @@ static void dissect_rsvp_diffserv (proto_tree *ti, tvbuff_t *tvb, int offset, int obj_length, int class, int type, - char *type_str + const char *type_str ) { proto_tree *rsvp_object_tree; @@ -4599,7 +4599,7 @@ dissect_rsvp_msg_tree(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, while (len < msg_length) { guint8 class; guint8 type; - char *type_str; + const char *type_str; obj_length = tvb_get_ntohs(tvb, offset); class = tvb_get_guint8(tvb, offset+2); diff --git a/epan/dissectors/packet-scsi.c b/epan/dissectors/packet-scsi.c index dc228cb2cc..cd56ca88dc 100644 --- a/epan/dissectors/packet-scsi.c +++ b/epan/dissectors/packet-scsi.c @@ -2838,7 +2838,7 @@ dissect_scsi_pagecode (tvbuff_t *tvb, packet_info *pinfo _U_, scsi_device_type devtype) { guint8 pcode; - gchar *valstr; + const gchar *valstr; int hf_pagecode; pcode = tvb_get_guint8 (tvb, offset); @@ -6570,7 +6570,7 @@ dissect_scsi_cdb (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint8 opcode; scsi_device_type devtype; scsi_cmnd_type cmd = 0; /* 0 is undefined type */ - gchar *valstr; + const gchar *valstr; scsi_task_data_t *cdata; scsi_devtype_key_t dkey; scsi_devtype_data_t *devdata; diff --git a/epan/dissectors/packet-ses.c b/epan/dissectors/packet-ses.c index fe34919adf..5884b026f8 100644 --- a/epan/dissectors/packet-ses.c +++ b/epan/dissectors/packet-ses.c @@ -782,7 +782,7 @@ dissect_parameter_group(tvbuff_t *tvb, int offset, proto_tree *tree, proto_item *ti; proto_tree *param_tree; guint8 param_type; - char *param_str; + const char *param_str; int len_len; guint16 param_len; @@ -861,7 +861,7 @@ dissect_parameters(tvbuff_t *tvb, int offset, guint16 len, proto_tree *tree, proto_item *ti; proto_tree *param_tree; guint8 param_type; - char *param_str; + const char *param_str; int len_len; guint16 param_len; diff --git a/epan/dissectors/packet-skinny.c b/epan/dissectors/packet-skinny.c index 6a1e334651..c9942a433f 100644 --- a/epan/dissectors/packet-skinny.c +++ b/epan/dissectors/packet-skinny.c @@ -1196,7 +1196,6 @@ static void dissect_skinny_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tr guint32 hdr_data_length; guint32 hdr_reserved; guint32 data_messageid; - gchar *messageid_str; /* guint32 data_size; */ guint i = 0; @@ -1234,10 +1233,9 @@ static void dissect_skinny_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tr proto_tree_add_uint(skinny_tree, hf_skinny_reserved, tvb, offset+4, 4, hdr_reserved); } - messageid_str = val_to_str(data_messageid, message_id, "0x%08X (Unknown)"); - if (check_col(pinfo->cinfo, COL_INFO)) { - col_add_str(pinfo->cinfo, COL_INFO, messageid_str); + col_add_str(pinfo->cinfo, COL_INFO, + val_to_str(data_messageid, message_id, "0x%08X (Unknown)")); } if (tree) { diff --git a/epan/dissectors/packet-slsk.c b/epan/dissectors/packet-slsk.c index 1ffffadf43..ef062880bc 100644 --- a/epan/dissectors/packet-slsk.c +++ b/epan/dissectors/packet-slsk.c @@ -267,18 +267,23 @@ static gboolean check_slsk_format(tvbuff_t *tvb, int offset, char format[]){ } -static char* get_message_type(tvbuff_t *tvb) { +static const char* get_message_type(tvbuff_t *tvb) { /* * Checks if the Message Code is known. * If unknown checks if the Message Code is stored in a byte. * Returns the Message Type. */ int msg_code = tvb_get_letohl(tvb, 4); - gchar *message_type = val_to_str(msg_code, slsk_tcp_msgs, "Unknown"); - if (strcmp(message_type, "Unknown") == 0) { - if (check_slsk_format(tvb, 4, "bisis")) message_type = "Distributed Search"; - if (check_slsk_format(tvb, 4, "bssi")) message_type = "Peer Init"; - if (check_slsk_format(tvb, 4, "bi")) message_type = "Pierce Fw"; + const gchar *message_type = match_strval(msg_code, slsk_tcp_msgs); + if (message_type == NULL) { + if (check_slsk_format(tvb, 4, "bisis")) + message_type = "Distributed Search"; + else if (check_slsk_format(tvb, 4, "bssi")) + message_type = "Peer Init"; + else if (check_slsk_format(tvb, 4, "bi")) + message_type = "Pierce Fw"; + else + message_type = "Unknown"; } return message_type; } diff --git a/epan/dissectors/packet-smb.c b/epan/dissectors/packet-smb.c index 5297ab7304..efdf5ae7e6 100644 --- a/epan/dissectors/packet-smb.c +++ b/epan/dissectors/packet-smb.c @@ -14558,7 +14558,7 @@ static const value_string HRD_errors[] = { {0, NULL} }; -static char *decode_smb_error(guint8 errcls, guint16 errcode) +static const char *decode_smb_error(guint8 errcls, guint16 errcode) { switch (errcls) { diff --git a/epan/dissectors/packet-smpp.c b/epan/dissectors/packet-smpp.c index 658c9db444..ff7b3c8530 100644 --- a/epan/dissectors/packet-smpp.c +++ b/epan/dissectors/packet-smpp.c @@ -1717,8 +1717,8 @@ dissect_smpp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) guint command_id; /* SMPP command */ guint command_status; /* Status code */ guint sequence_number; /* ...of command */ - gchar *command_str; - gchar *command_status_str = NULL; + const gchar *command_str; + const gchar *command_status_str = NULL; /* Set up structures needed to add the protocol subtree and manage it */ proto_item *ti = NULL; proto_tree *smpp_tree = NULL; diff --git a/epan/dissectors/packet-snmp.c b/epan/dissectors/packet-snmp.c index af0483d2ca..ba5ff32714 100644 --- a/epan/dissectors/packet-snmp.c +++ b/epan/dissectors/packet-snmp.c @@ -1037,7 +1037,7 @@ dissect_common_pdu(tvbuff_t *tvb, int offset, packet_info *pinfo, guint32 error_index; - char *pdu_type_string; + const char *pdu_type_string; subid_t *enterprise; guint enterprise_length; @@ -2045,7 +2045,7 @@ dissect_smux_pdu(tvbuff_t *tvb, int offset, packet_info *pinfo, guint length; guint pdu_type; - char *pdu_type_string; + const char *pdu_type_string; guint pdu_length; guint32 version; diff --git a/epan/dissectors/packet-ssl.c b/epan/dissectors/packet-ssl.c index 6a378a03c1..f4e24d8873 100644 --- a/epan/dissectors/packet-ssl.c +++ b/epan/dissectors/packet-ssl.c @@ -1033,7 +1033,6 @@ dissect_ssl3_record(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ti = NULL; proto_tree *ssl_record_tree = NULL; guint32 available_bytes = 0; - gchar *proto_name_str = NULL; available_bytes = tvb_length_remaining(tvb, offset); @@ -1203,11 +1202,10 @@ dissect_ssl3_record(tvbuff_t *tvb, packet_info *pinfo, col_append_str(pinfo->cinfo, COL_INFO, "Application Data"); if (ssl_record_tree) { - proto_name_str = match_strval(content_type, ssl_31_content_type); proto_item_set_text(ssl_record_tree, "%s Record Layer: %s Protocol: Application Data", ssl_version_short_names[*conv_version], - (proto_name_str!=NULL) ? proto_name_str : "unknown"); + val_to_str(content_type, ssl_31_content_type, "unknown")); tvb_ensure_bytes_exist(tvb, offset, record_length); proto_tree_add_item(ssl_record_tree, hf_ssl_record_appdata, tvb, offset, record_length, 0); @@ -1237,15 +1235,12 @@ dissect_ssl3_change_cipher_spec(tvbuff_t *tvb, * } ChangeCipherSpec; * */ - gchar *proto_name_str = NULL; - if (tree) { - proto_name_str = match_strval(content_type, ssl_31_content_type); proto_item_set_text(tree, "%s Record Layer: %s Protocol: Change Cipher Spec", ssl_version_short_names[*conv_version], - (proto_name_str!=NULL) ? proto_name_str : "unknown"); + val_to_str(content_type, ssl_31_content_type, "unknown")); proto_tree_add_item(tree, hf_ssl_change_cipher_spec, tvb, offset++, 1, FALSE); } @@ -1264,9 +1259,10 @@ dissect_ssl3_alert(tvbuff_t *tvb, packet_info *pinfo, */ proto_tree *ti; proto_tree *ssl_alert_tree = NULL; - gchar *level; - gchar *desc; + const gchar *level; + const gchar *desc; guint8 byte; + if (tree) { ti = proto_tree_add_item(tree, hf_ssl_alert_message, tvb, @@ -1350,8 +1346,7 @@ dissect_ssl3_handshake(tvbuff_t *tvb, packet_info *pinfo, */ proto_tree *ti = NULL; proto_tree *ssl_hand_tree = NULL; - gchar *msg_type_str = NULL; - gchar *proto_name_str = NULL; + const gchar *msg_type_str = NULL; guint8 msg_type; guint32 length; gboolean first_iteration = TRUE; @@ -1370,7 +1365,6 @@ dissect_ssl3_handshake(tvbuff_t *tvb, packet_info *pinfo, { msg_type = tvb_get_guint8(tvb, offset); msg_type_str = match_strval(msg_type, ssl_31_handshake_type); - proto_name_str = match_strval(content_type, ssl_31_content_type); length = tvb_get_ntoh24(tvb, offset + 1); if (!msg_type_str && !first_iteration) @@ -1403,15 +1397,15 @@ dissect_ssl3_handshake(tvbuff_t *tvb, packet_info *pinfo, { proto_item_set_text(tree, "%s Record Layer: %s Protocol: %s", ssl_version_short_names[*conv_version], - (proto_name_str!=NULL) ? proto_name_str : "unknown", - (msg_type_str!=NULL) ? msg_type_str : - "Encrypted Handshake Message"); + val_to_str(content_type, ssl_31_content_type, "unknown"), + (msg_type_str!=NULL) ? msg_type_str : + "Encrypted Handshake Message"); } else { proto_item_set_text(tree, "%s Record Layer: %s Protocol: %s", ssl_version_short_names[*conv_version], - (proto_name_str!=NULL) ? proto_name_str : "unknown", + val_to_str(content_type, ssl_31_content_type, "unknown"), "Multiple Handshake Messages"); } @@ -1973,7 +1967,7 @@ dissect_ssl2_record(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint is_escape = -1; gint16 padding_length = -1; guint8 msg_type = 0; - gchar *msg_type_str = NULL; + const gchar *msg_type_str = NULL; guint32 available_bytes = 0; proto_tree *ti; @@ -2936,7 +2930,7 @@ ssl_is_valid_content_type(guint8 type) static int ssl_is_valid_ssl_version(guint16 version) { - gchar *version_str = match_strval(version, ssl_versions); + const gchar *version_str = match_strval(version, ssl_versions); return version_str != NULL; } diff --git a/epan/dissectors/packet-stun.c b/epan/dissectors/packet-stun.c index 91b665e03c..8b9f5317d5 100644 --- a/epan/dissectors/packet-stun.c +++ b/epan/dissectors/packet-stun.c @@ -146,7 +146,7 @@ dissect_stun(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_tree *att_tree; guint16 msg_type; guint16 msg_length; - char *msg_type_str; + const char *msg_type_str; guint16 att_type; guint16 att_length; guint16 offset; diff --git a/epan/dissectors/packet-trmac.c b/epan/dissectors/packet-trmac.c index 42472b9866..c2b5f07aa9 100644 --- a/epan/dissectors/packet-trmac.c +++ b/epan/dissectors/packet-trmac.c @@ -283,7 +283,6 @@ dissect_trmac(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_item *ti; int mv_length, sv_offset, sv_additional; guint8 mv_val; - char *mv_text; if (check_col(pinfo->cinfo, COL_PROTOCOL)) col_set_str(pinfo->cinfo, COL_PROTOCOL, "TR MAC"); @@ -293,10 +292,9 @@ dissect_trmac(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) mv_val = tvb_get_guint8(tvb, 3); /* Interpret the major vector */ - mv_text = val_to_str(mv_val, major_vector_vs, "Unknown Major Vector: %u"); - if (check_col(pinfo->cinfo, COL_INFO)) - col_add_str(pinfo->cinfo, COL_INFO, mv_text); + col_add_str(pinfo->cinfo, COL_INFO, + val_to_str(mv_val, major_vector_vs, "Unknown Major Vector: %u")); if (tree) { mv_length = tvb_get_ntohs(tvb, 0); diff --git a/epan/dissectors/packet-tzsp.c b/epan/dissectors/packet-tzsp.c index f95b35d4c3..79bbfe6a6c 100644 --- a/epan/dissectors/packet-tzsp.c +++ b/epan/dissectors/packet-tzsp.c @@ -286,7 +286,8 @@ dissect_tzsp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) guint16 encapsulation = 0; int wtap_encap; dissector_handle_t encap_dissector; - char *encap_name, *info; + char *encap_name; + const char *info; guint8 type; if (check_col(pinfo->cinfo, COL_PROTOCOL)) diff --git a/epan/dissectors/packet-wsp.c b/epan/dissectors/packet-wsp.c index 3c54872868..a79085bf4b 100644 --- a/epan/dissectors/packet-wsp.c +++ b/epan/dissectors/packet-wsp.c @@ -5233,11 +5233,9 @@ dissect_wsp_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, headerStart = offset + count + 1; { guint8 reply_status = tvb_get_guint8(tvb, offset); - char *reply_status_str = match_strval (reply_status, vals_status); + const char *reply_status_str; - if (reply_status_str == NULL) - reply_status_str = "(Unknown response status)"; - + reply_status_str = val_to_str (reply_status, vals_status, "(Unknown response status)"); if (tree) { ti = proto_tree_add_item (wsp_tree, hf_wsp_header_status, tvb, offset, 1, bo_little_endian); diff --git a/epan/dissectors/packet-wtls.c b/epan/dissectors/packet-wtls.c index 50e0dbfa5a..8ce0374af6 100644 --- a/epan/dissectors/packet-wtls.c +++ b/epan/dissectors/packet-wtls.c @@ -462,8 +462,8 @@ dissect_wtls_handshake(proto_tree *tree, tvbuff_t *tvb, guint offset, guint coun guint public_key = 0; guint signature = 0; char valStr[1024]; - char *valBulk = NULL; - char *valMac = NULL; + const char *valBulk = NULL; + const char *valMac = NULL; proto_item *ti; proto_item *cli_key_item; diff --git a/epan/dissectors/packet-x11.c b/epan/dissectors/packet-x11.c index 72f3a63c06..ebd0b00d59 100644 --- a/epan/dissectors/packet-x11.c +++ b/epan/dissectors/packet-x11.c @@ -2167,7 +2167,7 @@ static guint32 field8(tvbuff_t *tvb, int *offsetp, proto_tree *t, int hf, { guint32 v = VALUE8(tvb, *offsetp); header_field_info *hfi = proto_registrar_get_nth(hf); - gchar *enumValue = NULL; + const gchar *enumValue = NULL; if (hfi -> strings) enumValue = match_strval(v, cVALS(hfi -> strings)); @@ -2186,7 +2186,7 @@ static guint32 field16(tvbuff_t *tvb, int *offsetp, proto_tree *t, int hf, { guint32 v = VALUE16(tvb, *offsetp); header_field_info *hfi = proto_registrar_get_nth(hf); - gchar *enumValue = NULL; + const gchar *enumValue = NULL; if (hfi -> strings) enumValue = match_strval(v, cVALS(hfi -> strings)); @@ -2205,7 +2205,7 @@ static guint32 field32(tvbuff_t *tvb, int *offsetp, proto_tree *t, int hf, { guint32 v = VALUE32(tvb, *offsetp); header_field_info *hfi = proto_registrar_get_nth(hf); - gchar *enumValue = NULL; + const gchar *enumValue = NULL; const gchar *nameAsChar = hfi -> name; if (hfi -> strings) diff --git a/epan/dissectors/packet-ypserv.c b/epan/dissectors/packet-ypserv.c index d4b6f78f5c..183a8c2dc4 100644 --- a/epan/dissectors/packet-ypserv.c +++ b/epan/dissectors/packet-ypserv.c @@ -98,7 +98,7 @@ static int dissect_ypserv_status(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, gint32 *rstatus) { gint32 status; - char *err; + const char *err; status=tvb_get_ntohl(tvb, offset); if(rstatus){ diff --git a/epan/libethereal.def b/epan/libethereal.def index c0680f108e..d38c838b90 100644 --- a/epan/libethereal.def +++ b/epan/libethereal.def @@ -330,6 +330,7 @@ is_tpkt list_tap_cmd_args LocationRejectReason_vals DATA match_strval +match_strval_idx mkstemp mtp3_addr_to_str_buf mtp3_service_indicator_code_short_vals DATA diff --git a/epan/value_string.c b/epan/value_string.c index e7aa117159..d2874379de 100644 --- a/epan/value_string.c +++ b/epan/value_string.c @@ -4,10 +4,9 @@ * $Id$ * * Ethereal - Network traffic analyzer - * By Gerald Combs <gerald@zing.org> + * By Gerald Combs <gerald@ethereal.com> * Copyright 1998 Gerald Combs * - * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 @@ -38,9 +37,9 @@ /* Tries to match val against each element in the value_string array vs. Returns the associated string ptr on a match. Formats val with fmt, and returns the resulting string, on failure. */ -gchar* +const gchar* val_to_str(guint32 val, const value_string *vs, const char *fmt) { - gchar *ret; + const gchar *ret; static gchar str[3][64]; static gchar *cur; @@ -62,23 +61,32 @@ val_to_str(guint32 val, const value_string *vs, const char *fmt) { } /* Tries to match val against each element in the value_string array vs. - Returns the associated string ptr on a match, or NULL on failure. */ -gchar* -match_strval(guint32 val, const value_string *vs) { + Returns the associated string ptr, and sets "*idx" to the index in + that table, on a match, and returns NULL, and sets "*idx" to -1, + on failure. */ +const gchar* +match_strval_idx(guint32 val, const value_string *vs, gint *idx) { gint i = 0; while (vs[i].strptr) { - if (vs[i].value == val) - /* XXX - the correct implementation would be to use the return type: - "const gchar *", but this would require to change most calls of this - function which are (directly and indirectly) *a lot* */ - return( (gchar *) vs[i].strptr); + if (vs[i].value == val) { + *idx = i; + return(vs[i].strptr); + } i++; } + *idx = -1; return(NULL); } +/* Like match_strval_idx(), but doesn't return the index. */ +const gchar* +match_strval(guint32 val, const value_string *vs) { + gint ignore_me; + return match_strval_idx(val, vs, &ignore_me); +} + /* Generate a string describing an enumerated bitfield (an N-bit field with various specific values having particular names). */ const char * diff --git a/epan/value_string.h b/epan/value_string.h index d6e7ec533f..5bb264a492 100644 --- a/epan/value_string.h +++ b/epan/value_string.h @@ -4,10 +4,9 @@ * $Id$ * * Ethereal - Network traffic analyzer - * By Gerald Combs <gerald@zing.org> + * By Gerald Combs <gerald@ethereal.com> * Copyright 1998 Gerald Combs * - * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 @@ -28,7 +27,7 @@ #include <glib.h> -/* Struct for the match_strval function */ +/* Struct for the val_to_str, match_strval_idx, and match_strval functions */ typedef struct _value_string { guint32 value; @@ -39,13 +38,18 @@ typedef struct _value_string { /* #define VS_END { 0, NULL } */ /* Tries to match val against each element in the value_string array vs. - Returns the associated string ptr on a match, or NULL on failure. */ -extern gchar* match_strval(guint32 val, const value_string *vs); + Returns the associated string ptr, and sets "*idx" to the index in + that table, on a match, and returns NULL, and sets "*idx" to -1, + on failure. */ +extern const gchar* match_strval_idx(guint32 val, const value_string *vs, gint *idx); + +/* Like match_strval_idx(), but doesn't return the index. */ +extern const gchar* match_strval(guint32 val, const value_string *vs); /* Tries to match val against each element in the value_string array vs. Returns the associated string ptr on a match. Formats val with fmt, and returns the resulting string, on failure. */ -extern gchar* val_to_str(guint32 val, const value_string *vs, const char *fmt); +extern const gchar* val_to_str(guint32 val, const value_string *vs, const char *fmt); /* Generate a string describing an enumerated bitfield (an N-bit field with various specific values having particular names). */ diff --git a/epan/xdlc.c b/epan/xdlc.c index 1cef001f9c..f631475303 100644 --- a/epan/xdlc.c +++ b/epan/xdlc.c @@ -185,7 +185,7 @@ dissect_xdlc_control(tvbuff_t *tvb, int offset, packet_info *pinfo, char info[80]; proto_tree *tc, *control_tree; gchar *frame_type = NULL; - gchar *modifier; + const gchar *modifier; switch (tvb_get_guint8(tvb, offset) & 0x03) { @@ -285,14 +285,12 @@ dissect_xdlc_control(tvbuff_t *tvb, int offset, packet_info *pinfo, cf_items = cf_items_nonext; control_format = "Control field: %s (0x%02X)"; if (is_response) { - modifier = match_strval(control & XDLC_U_MODIFIER_MASK, - u_modifier_short_vals_resp); + modifier = val_to_str(control & XDLC_U_MODIFIER_MASK, + u_modifier_short_vals_resp, "Unknown"); } else { - modifier = match_strval(control & XDLC_U_MODIFIER_MASK, - u_modifier_short_vals_cmd); + modifier = val_to_str(control & XDLC_U_MODIFIER_MASK, + u_modifier_short_vals_cmd, "Unknown"); } - if (modifier == NULL) - modifier = "Unknown"; poll_final = (control & XDLC_P_F); sprintf(info, "U%s, func=%s", (poll_final ? diff --git a/plugins/rtnet/packet-rtnet.c b/plugins/rtnet/packet-rtnet.c index cc6b959f96..d9b8033623 100644 --- a/plugins/rtnet/packet-rtnet.c +++ b/plugins/rtnet/packet-rtnet.c @@ -579,7 +579,7 @@ dissect_rtmac(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { proto_tree *ti=NULL, *rtmac_tree=NULL; proto_item *item; dissector_handle_t dissector=NULL; - gchar *type_str=NULL; + const gchar *type_str=NULL; /* Read the header */ type = tvb_get_ntohs(tvb, offset); @@ -627,11 +627,9 @@ dissect_rtmac(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { type_str = "Unknown"; } } else { - if (!(flags & RTMAC_FLAG_TUNNEL)) { - type_str = match_strval(type, rtmac_type_vals); - if (!type_str) - type_str = "Unknown"; - } else { + if (!(flags & RTMAC_FLAG_TUNNEL)) + type_str = val_to_str(type, rtmac_type_vals, "Unknown"); + else { if (dissector != data_handle) type_str = dissector_handle_get_short_name(dissector); else diff --git a/tap-wspstat.c b/tap-wspstat.c index 67805f62fb..8f76139a87 100644 --- a/tap-wspstat.c +++ b/tap-wspstat.c @@ -46,7 +46,7 @@ /* used to keep track of the stats for a specific PDU type*/ typedef struct _wsp_pdu_t { - gchar *type; + const gchar *type; guint32 packets; } wsp_pdu_t; /* used to keep track of RTT statistics */ |