From 37600a157ba2036a79a5ebf466b31b8eee19244e Mon Sep 17 00:00:00 2001 From: Evan Huus Date: Fri, 29 Mar 2013 00:26:23 +0000 Subject: [PATCH] Rename value string (and similar) functions to use a consistent pattern. This was done using textual search+replace, not anything syntax-aware, so presumably it got most comments as well (except where there were typos). Use a consistent coding style, and make proper use of the WS_DLL_* defines. Group the functions appropriately in the header. I ended up getting rid of most of the explanatory comments since many of them duplicated what was in the value_string.c file (and were out of sync with the recent updates I made to those in r48633). Presumably most of the comments should be in the .h file not the .c file, but there's enough churn ahead that it's not worth fixing yet. Part of https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8467 svn path=/trunk/; revision=48634 --- asn1/gsm_map/packet-gsm_map-template.c | 2 +- asn1/h248/packet-h248-template.c | 16 +- asn1/h450/packet-h450-template.c | 6 +- asn1/isdn-sup/packet-isdn-sup-template.c | 6 +- asn1/mms/packet-mms-template.c | 2 +- asn1/mpeg-pes/packet-mpeg-pes-template.c | 4 +- asn1/qsig/packet-qsig-template.c | 10 +- epan/dissectors/packet-3g-a11.c | 2 +- epan/dissectors/packet-aarp.c | 2 +- epan/dissectors/packet-adwin.c | 6 +- epan/dissectors/packet-ansi_637.c | 10 +- epan/dissectors/packet-ansi_683.c | 4 +- epan/dissectors/packet-ansi_801.c | 16 +- epan/dissectors/packet-ansi_a.c | 14 +- epan/dissectors/packet-aodv.c | 2 +- epan/dissectors/packet-armagetronad.c | 2 +- epan/dissectors/packet-arp.c | 6 +- epan/dissectors/packet-assa_r3.c | 2 +- epan/dissectors/packet-bfcp.c | 4 +- epan/dissectors/packet-bittorrent.c | 4 +- epan/dissectors/packet-bssgp.c | 2 +- epan/dissectors/packet-bvlc.c | 2 +- epan/dissectors/packet-cell_broadcast.c | 2 +- epan/dissectors/packet-cimd.c | 4 +- epan/dissectors/packet-cip.c | 4 +- epan/dissectors/packet-classicstun.c | 2 +- epan/dissectors/packet-cmpp.c | 4 +- epan/dissectors/packet-csm-encaps.c | 4 +- epan/dissectors/packet-ddtp.c | 2 +- epan/dissectors/packet-diameter.c | 2 +- epan/dissectors/packet-dlsw.c | 4 +- epan/dissectors/packet-dtls.c | 8 +- epan/dissectors/packet-dvb-ait.c | 2 +- epan/dissectors/packet-dvbci.c | 16 +- epan/dissectors/packet-e212.c | 2 +- epan/dissectors/packet-edonkey.c | 10 +- epan/dissectors/packet-enip.c | 4 +- epan/dissectors/packet-epl.c | 2 +- epan/dissectors/packet-etch.c | 6 +- epan/dissectors/packet-ethertype.c | 2 +- epan/dissectors/packet-fcoib.c | 4 +- epan/dissectors/packet-forces.c | 2 +- epan/dissectors/packet-gadu-gadu.c | 4 +- epan/dissectors/packet-ged125.c | 2 +- epan/dissectors/packet-gmr1_rr.c | 4 +- epan/dissectors/packet-gsm_a_bssmap.c | 4 +- epan/dissectors/packet-gsm_a_dtap.c | 12 +- epan/dissectors/packet-gsm_a_gm.c | 4 +- epan/dissectors/packet-gsm_a_rp.c | 2 +- epan/dissectors/packet-gsm_a_rr.c | 4 +- epan/dissectors/packet-gsm_abis_oml.c | 8 +- epan/dissectors/packet-gsm_bssmap_le.c | 2 +- epan/dissectors/packet-gsm_map.c | 2 +- epan/dissectors/packet-gsm_sms.c | 2 +- epan/dissectors/packet-gtp.c | 2 +- epan/dissectors/packet-h248.c | 16 +- epan/dissectors/packet-h264.c | 2 +- epan/dissectors/packet-h282.c | 6 +- epan/dissectors/packet-h283.c | 12 +- epan/dissectors/packet-h450.c | 6 +- epan/dissectors/packet-h501.c | 2 +- epan/dissectors/packet-iapp.c | 4 +- epan/dissectors/packet-ieee80211.c | 2 +- epan/dissectors/packet-image-jfif.c | 2 +- epan/dissectors/packet-ip.c | 2 +- epan/dissectors/packet-ipmi.c | 2 +- epan/dissectors/packet-ipsec.c | 2 +- epan/dissectors/packet-ipx.c | 2 +- epan/dissectors/packet-iscsi.c | 16 +- epan/dissectors/packet-isdn-sup.c | 6 +- epan/dissectors/packet-isns.c | 4 +- epan/dissectors/packet-isup.c | 2 +- epan/dissectors/packet-kingfisher.c | 2 +- epan/dissectors/packet-laplink.c | 2 +- epan/dissectors/packet-llrp.c | 2 +- epan/dissectors/packet-mac-lte.c | 4 +- epan/dissectors/packet-memcache.c | 8 +- epan/dissectors/packet-mms.c | 2 +- epan/dissectors/packet-mmse.c | 2 +- epan/dissectors/packet-mp4ves.c | 4 +- epan/dissectors/packet-mpeg-descriptor.c | 4 +- epan/dissectors/packet-mpeg-pes.c | 4 +- epan/dissectors/packet-ms-mms.c | 2 +- epan/dissectors/packet-nas_eps.c | 4 +- epan/dissectors/packet-nat-pmp.c | 4 +- epan/dissectors/packet-ncp-nmas.c | 4 +- epan/dissectors/packet-ncp-sss.c | 4 +- epan/dissectors/packet-ncp.c | 4 +- epan/dissectors/packet-ndps.c | 40 ++-- epan/dissectors/packet-oicq.c | 4 +- epan/dissectors/packet-omron-fins.c | 2 +- epan/dissectors/packet-pw-atm.c | 4 +- epan/dissectors/packet-pw-cesopsn.c | 2 +- epan/dissectors/packet-qsig.c | 10 +- epan/dissectors/packet-radius.c | 2 +- epan/dissectors/packet-rmcp.c | 2 +- epan/dissectors/packet-rpcap.c | 4 +- epan/dissectors/packet-rsvp.c | 2 +- epan/dissectors/packet-rtmpt.c | 2 +- epan/dissectors/packet-rtnet.c | 2 +- epan/dissectors/packet-rtps.c | 4 +- epan/dissectors/packet-sccp.c | 14 +- epan/dissectors/packet-scsi.c | 10 +- epan/dissectors/packet-ses.c | 8 +- epan/dissectors/packet-sgsap.c | 2 +- epan/dissectors/packet-slimp3.c | 2 +- epan/dissectors/packet-slowprotocols.c | 2 +- epan/dissectors/packet-slsk.c | 2 +- epan/dissectors/packet-smpp.c | 8 +- epan/dissectors/packet-ssl.c | 12 +- epan/dissectors/packet-sua.c | 2 +- epan/dissectors/packet-synphasor.c | 2 +- epan/dissectors/packet-telnet.c | 2 +- epan/dissectors/packet-tn3270.c | 4 +- epan/dissectors/packet-tpncp.c | 4 +- epan/dissectors/packet-ucp.c | 2 +- epan/dissectors/packet-usb-video.c | 2 +- epan/dissectors/packet-wbxml.c | 2 +- epan/dissectors/packet-wccp.c | 2 +- epan/dissectors/packet-wsp.c | 16 +- epan/dissectors/packet-wtls.c | 4 +- epan/dissectors/packet-x11.c | 10 +- epan/ipproto.c | 2 +- epan/proto.c | 14 +- epan/value_string.c | 82 ++++---- epan/value_string.h | 211 ++++++++------------ epan/xdlc.c | 4 +- plugins/ethercat/packet-ethercat-datagram.c | 2 +- plugins/gryphon/packet-gryphon.c | 2 +- ui/cli/tap-wspstat.c | 2 +- ui/export_object_smb.c | 12 +- ui/gtk/expert_comp_dlg.c | 6 +- ui/gtk/expert_comp_table.c | 4 +- ui/gtk/rtp_player.c | 2 +- ui/gtk/wsp_stat.c | 4 +- 135 files changed, 447 insertions(+), 498 deletions(-) diff --git a/asn1/gsm_map/packet-gsm_map-template.c b/asn1/gsm_map/packet-gsm_map-template.c index 1254839415..ea39f5d1b3 100644 --- a/asn1/gsm_map/packet-gsm_map-template.c +++ b/asn1/gsm_map/packet-gsm_map-template.c @@ -1916,7 +1916,7 @@ dissect_gsm_map(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) } dissect_gsm_map_GSMMAPPDU(FALSE, tvb, 0, &asn1_ctx, tree, -1); - match_strval_idx(opcode, gsm_map_opr_code_strings, &op_idx); + try_val_to_str_idx(opcode, gsm_map_opr_code_strings, &op_idx); if (op_idx != -1) { tap_rec.invoke = (gsmmap_pdu_type == 1) ? TRUE : FALSE; diff --git a/asn1/h248/packet-h248-template.c b/asn1/h248/packet-h248-template.c index b5e13761e2..679fd2ba66 100644 --- a/asn1/h248/packet-h248-template.c +++ b/asn1/h248/packet-h248-template.c @@ -774,7 +774,7 @@ extern void h248_param_PkgdName(proto_tree* tree, tvbuff_t* tvb, packet_info* pi pi = proto_tree_add_uint(package_tree, hf_248_pkg_param, tvb, offset-2, 2, name_minor); - if (pkg->signal_names && ( strval = match_strval(name_minor, pkg->signal_names) )) { + if (pkg->signal_names && ( strval = try_val_to_str(name_minor, pkg->signal_names) )) { strval = ep_strdup_printf("%s (%d)",strval,name_minor); } else { strval = ep_strdup_printf("Unknown (%d)",name_minor); @@ -916,7 +916,7 @@ void h248_register_package(const h248_package_t* pkg, pkg_reg_action reg_action) pkg_found->param_names = vst; pkg_found->hfid = &hf_h248_pkg_name; pkg_found->ett = &ett_packagename; - match_strval_idx((pkg_found->id)<<16,base_event_name_vals, &j); + try_val_to_str_idx((pkg_found->id)<<16,base_event_name_vals, &j); /* now look for events and signals that may be defined for package. If found, create value_strings */ if (j != -1) { j++; idx=j; @@ -934,7 +934,7 @@ void h248_register_package(const h248_package_t* pkg, pkg_reg_action reg_action) } } /* now look at signals */ - if (!match_strval_idx((pkg_found->id)<<16, base_signal_name_vals, &j)) { + if (!try_val_to_str_idx((pkg_found->id)<<16, base_signal_name_vals, &j)) { j++; idx=j; while((base_signal_name_vals[j].strptr != NULL) && ((base_signal_name_vals[j].value>>16) == (pkg_found->id))) { }; @@ -1031,7 +1031,7 @@ static int dissect_h248_PkgdName(gboolean implicit_tag, tvbuff_t *tvb, int offse proto_item* pi = proto_tree_add_uint(package_tree, hf_248_pkg_param, tvb, offset-2, 2, name_minor); const gchar* strval; - if (pkg->param_names && ( strval = match_strval(name_minor, pkg->param_names) )) { + if (pkg->param_names && ( strval = try_val_to_str(name_minor, pkg->param_names) )) { strval = ep_strdup_printf("%s (%d)",strval,name_minor); } else { strval = ep_strdup_printf("Unknown (%d)",name_minor); @@ -1094,7 +1094,7 @@ static int dissect_h248_EventName(gboolean implicit_tag, tvbuff_t *tvb, int offs proto_item* pi = proto_tree_add_uint(package_tree, hf_h248_event_code, tvb, offset-2, 2, name_minor); const gchar* strval; - if (pkg->event_names && ( strval = match_strval(name_minor, pkg->event_names) )) { + if (pkg->event_names && ( strval = try_val_to_str(name_minor, pkg->event_names) )) { strval = ep_strdup_printf("%s (%d)",strval,name_minor); } else { strval = ep_strdup_printf("Unknown (%d)",name_minor); @@ -1159,7 +1159,7 @@ static int dissect_h248_SignalName(gboolean implicit_tag , tvbuff_t *tvb, int of proto_item* pi = proto_tree_add_uint(package_tree, hf_h248_signal_code, tvb, offset-2, 2, name_minor); const gchar* strval; - if (pkg->signal_names && ( strval = match_strval(name_minor, pkg->signal_names) )) { + if (pkg->signal_names && ( strval = try_val_to_str(name_minor, pkg->signal_names) )) { strval = ep_strdup_printf("%s (%d)",strval,name_minor); } else { strval = ep_strdup_printf("Unknown (%d)",name_minor); @@ -1252,7 +1252,7 @@ static int dissect_h248_SigParameterName(gboolean implicit_tag _U_, tvbuff_t *tv } } - if (curr_info.sig && curr_info.sig->param_names && ( strval = match_strval(param_id, curr_info.sig->param_names) )) { + if (curr_info.sig && curr_info.sig->param_names && ( strval = try_val_to_str(param_id, curr_info.sig->param_names) )) { strval = ep_strdup_printf("%s (%d)",strval,param_id); } else { strval = ep_strdup_printf("Unknown (%d)",param_id); @@ -1329,7 +1329,7 @@ static int dissect_h248_EventParameterName(gboolean implicit_tag _U_, tvbuff_t * curr_info.par = &no_param; } - if (curr_info.evt && curr_info.evt->param_names && ( strval = match_strval(param_id, curr_info.evt->param_names) )) { + if (curr_info.evt && curr_info.evt->param_names && ( strval = try_val_to_str(param_id, curr_info.evt->param_names) )) { strval = ep_strdup_printf("%s (%d)",strval,param_id); } else { strval = ep_strdup_printf("Unknown (%d)",param_id); diff --git a/asn1/h450/packet-h450-template.c b/asn1/h450/packet-h450-template.c index f1ac186618..cd0ab0a2e0 100644 --- a/asn1/h450/packet-h450-template.c +++ b/asn1/h450/packet-h450-template.c @@ -133,7 +133,7 @@ dissect_h450_arg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data hidden_item = proto_tree_add_uint(tree, hf_h450_operation, tvb, 0, 0, opcode); PROTO_ITEM_SET_HIDDEN(hidden_item); - p = match_strval(opcode, VALS(h450_str_operation)); + p = try_val_to_str(opcode, VALS(h450_str_operation)); if (p) { proto_item_append_text(rctx->d.code_item, " - %s", p); if (rctx->apdu_depth >= 0) @@ -175,7 +175,7 @@ dissect_h450_res(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data hidden_item = proto_tree_add_uint(tree, hf_h450_operation, tvb, 0, 0, opcode); PROTO_ITEM_SET_HIDDEN(hidden_item); - p = match_strval(opcode, VALS(h450_str_operation)); + p = try_val_to_str(opcode, VALS(h450_str_operation)); if (p) { proto_item_append_text(rctx->d.code_item, " - %s", p); if (rctx->apdu_depth >= 0) @@ -217,7 +217,7 @@ dissect_h450_err(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data hidden_item = proto_tree_add_uint(tree, hf_h450_error, tvb, 0, 0, errcode); PROTO_ITEM_SET_HIDDEN(hidden_item); - p = match_strval(errcode, VALS(h450_str_error)); + p = try_val_to_str(errcode, VALS(h450_str_error)); if (p) { proto_item_append_text(rctx->d.code_item, " - %s", p); if (rctx->apdu_depth >= 0) diff --git a/asn1/isdn-sup/packet-isdn-sup-template.c b/asn1/isdn-sup/packet-isdn-sup-template.c index a54e600895..8354f72d0d 100644 --- a/asn1/isdn-sup/packet-isdn-sup-template.c +++ b/asn1/isdn-sup/packet-isdn-sup-template.c @@ -161,7 +161,7 @@ dissect_isdn_sup_arg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void * isdn_sup_tree = proto_item_add_subtree(ti, ett_isdn_sup); proto_tree_add_uint(isdn_sup_tree, hf_isdn_sup_operation, tvb, 0, 0, opcode); - p = match_strval(opcode, VALS(isdn_sup_str_operation)); + p = try_val_to_str(opcode, VALS(isdn_sup_str_operation)); if (p) { proto_item_append_text(ti, ": %s", p); proto_item_append_text(rctx->d.code_item, " - %s", p); @@ -207,7 +207,7 @@ dissect_isdn_sup_res(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void * isdn_sup_tree = proto_item_add_subtree(ti, ett_isdn_sup); proto_tree_add_uint(isdn_sup_tree, hf_isdn_sup_operation, tvb, 0, 0, opcode); - p = match_strval(opcode, VALS(isdn_sup_str_operation)); + p = try_val_to_str(opcode, VALS(isdn_sup_str_operation)); if (p) { proto_item_append_text(ti, ": %s", p); proto_item_append_text(rctx->d.code_item, " - %s", p); @@ -254,7 +254,7 @@ dissect_isdn_sup_err(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void * isdn_sup_tree = proto_item_add_subtree(ti, ett_isdn_sup); proto_tree_add_uint(isdn_sup_tree, hf_isdn_sup_error, tvb, 0, 0, errcode); - p = match_strval(errcode, VALS(isdn_sup_str_error)); + p = try_val_to_str(errcode, VALS(isdn_sup_str_error)); if (p) { proto_item_append_text(ti, ": %s", p); proto_item_append_text(rctx->d.code_item, " - %s", p); diff --git a/asn1/mms/packet-mms-template.c b/asn1/mms/packet-mms-template.c index 8bea578a46..f4deec0ee0 100644 --- a/asn1/mms/packet-mms-template.c +++ b/asn1/mms/packet-mms-template.c @@ -136,7 +136,7 @@ dissect_mms_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, voi return FALSE; /* see if the tag is a valid MMS PDU */ - match_strval_idx(tmp_tag, mms_MMSpdu_vals, &idx); + try_val_to_str_idx(tmp_tag, mms_MMSpdu_vals, &idx); if (idx == -1) { return FALSE; /* no, it isn't an MMS PDU */ } diff --git a/asn1/mpeg-pes/packet-mpeg-pes-template.c b/asn1/mpeg-pes/packet-mpeg-pes-template.c index 32a6f96306..60bce351b7 100644 --- a/asn1/mpeg-pes/packet-mpeg-pes-template.c +++ b/asn1/mpeg-pes/packet-mpeg-pes-template.c @@ -405,7 +405,7 @@ dissect_mpeg_pes(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data stream = tvb_get_guint8(tvb, 3); if (check_col(pinfo->cinfo, COL_INFO)) { - const char *s = match_strval(stream, mpeg_pes_T_stream_vals); + const char *s = try_val_to_str(stream, mpeg_pes_T_stream_vals); if (s != NULL) col_set_str(pinfo->cinfo, COL_INFO, s); } @@ -423,7 +423,7 @@ dissect_mpeg_pes(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data frame_type = tvb_get_guint8(tvb, 5) >> 3 & 0x07; if (check_col(pinfo->cinfo, COL_INFO)) { - const char *s = match_strval(frame_type, + const char *s = try_val_to_str(frame_type, mpeg_pes_T_frame_type_vals); if (s != NULL) col_set_str(pinfo->cinfo, COL_INFO, s); diff --git a/asn1/qsig/packet-qsig-template.c b/asn1/qsig/packet-qsig-template.c index c4261414c4..ed47e62d8d 100644 --- a/asn1/qsig/packet-qsig-template.c +++ b/asn1/qsig/packet-qsig-template.c @@ -403,7 +403,7 @@ dissect_qsig_arg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data qsig_tree = proto_item_add_subtree(ti, ett_qsig); proto_tree_add_uint(qsig_tree, hf_qsig_operation, tvb, 0, 0, opcode); - p = match_strval(opcode, VALS(qsig_str_operation)); + p = try_val_to_str(opcode, VALS(qsig_str_operation)); if (p) { proto_item_append_text(ti, ": %s", p); proto_item_append_text(rctx->d.code_item, " - %s", p); @@ -412,7 +412,7 @@ dissect_qsig_arg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data } ti_tmp = proto_tree_add_uint(qsig_tree, hf_qsig_service, tvb, 0, 0, service); - p = match_strval(service, VALS(qsig_str_service_name)); + p = try_val_to_str(service, VALS(qsig_str_service_name)); if (p) proto_item_append_text(ti_tmp, " - %s", p); if (op_ptr->arg_pdu) @@ -454,7 +454,7 @@ dissect_qsig_res(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data qsig_tree = proto_item_add_subtree(ti, ett_qsig); proto_tree_add_uint(qsig_tree, hf_qsig_operation, tvb, 0, 0, opcode); - p = match_strval(opcode, VALS(qsig_str_operation)); + p = try_val_to_str(opcode, VALS(qsig_str_operation)); if (p) { proto_item_append_text(ti, ": %s", p); proto_item_append_text(rctx->d.code_item, " - %s", p); @@ -463,7 +463,7 @@ dissect_qsig_res(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data } ti_tmp = proto_tree_add_uint(qsig_tree, hf_qsig_service, tvb, 0, 0, service); - p = match_strval(service, VALS(qsig_str_service_name)); + p = try_val_to_str(service, VALS(qsig_str_service_name)); if (p) proto_item_append_text(ti_tmp, " - %s", p); if (op_ptr->res_pdu) @@ -504,7 +504,7 @@ dissect_qsig_err(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data qsig_tree = proto_item_add_subtree(ti, ett_qsig); proto_tree_add_uint(qsig_tree, hf_qsig_error, tvb, 0, 0, errcode); - p = match_strval(errcode, VALS(qsig_str_error)); + p = try_val_to_str(errcode, VALS(qsig_str_error)); if (p) { proto_item_append_text(ti, ": %s", p); proto_item_append_text(rctx->d.code_item, " - %s", p); diff --git a/epan/dissectors/packet-3g-a11.c b/epan/dissectors/packet-3g-a11.c index 3acaf1f8ee..4aaba2d9b4 100644 --- a/epan/dissectors/packet-3g-a11.c +++ b/epan/dissectors/packet-3g-a11.c @@ -1463,7 +1463,7 @@ dissect_a11( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_ return 0; /* not enough data to check message type */ type = tvb_get_guint8(tvb, offset); - if (match_strval(type, a11_types) == NULL) + if (try_val_to_str(type, a11_types) == NULL) return 0; /* not a known message type */ /* Make entries in Protocol column and Info column on summary display */ diff --git a/epan/dissectors/packet-aarp.c b/epan/dissectors/packet-aarp.c index ddaf120067..bdb98efefd 100644 --- a/epan/dissectors/packet-aarp.c +++ b/epan/dissectors/packet-aarp.c @@ -200,7 +200,7 @@ dissect_aarp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { } if (tree) { - if ((op_str = match_strval(ar_op, op_vals))) + if ((op_str = try_val_to_str(ar_op, op_vals))) ti = proto_tree_add_protocol_format(tree, proto_aarp, tvb, 0, MIN_AARP_HEADER_SIZE + 2*ar_hln + 2*ar_pln, "AppleTalk Address Resolution Protocol (%s)", op_str); diff --git a/epan/dissectors/packet-adwin.c b/epan/dissectors/packet-adwin.c index acdf697a75..3983890260 100644 --- a/epan/dissectors/packet-adwin.c +++ b/epan/dissectors/packet-adwin.c @@ -813,7 +813,7 @@ dissect_UDPR1(tvbuff_t *tvb, packet_info *pinfo, guint32 seq_num, status; status = tvb_get_letohl(tvb, 0); - status_string = match_strval_ext(status, &error_code_mapping_ext); + status_string = try_val_to_str_ext(status, &error_code_mapping_ext); if (status_string) { *info_string = ep_strdup_printf("UDPR1 Status: %s", status_string); } else { @@ -847,7 +847,7 @@ dissect_UDPR2(tvbuff_t *tvb, packet_info *pinfo, guint32 i, status, seq_num; status = tvb_get_letohl(tvb, 0); - status_string = match_strval_ext(status, &error_code_mapping_ext); + status_string = try_val_to_str_ext(status, &error_code_mapping_ext); if (status_string) { *info_string = ep_strdup_printf("UDPR2 Status: %s", status_string); } else { @@ -934,7 +934,7 @@ dissect_UDPR4(tvbuff_t *tvb, packet_info *pinfo, guint32 data_type, i, status, seq_num; status = tvb_get_letohl(tvb, 0); - status_string = match_strval_ext(status, &error_code_mapping_ext); + status_string = try_val_to_str_ext(status, &error_code_mapping_ext); if (status_string) { *info_string = ep_strdup_printf("UDPR4 Status: %s", status_string); } else { diff --git a/epan/dissectors/packet-ansi_637.c b/epan/dissectors/packet-ansi_637.c index 56367b259e..404b41e1ec 100644 --- a/epan/dissectors/packet-ansi_637.c +++ b/epan/dissectors/packet-ansi_637.c @@ -1167,7 +1167,7 @@ trans_param_tele_id(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset, ansi_637_trans_tele_id = value; - str = match_strval(value, ansi_tele_id_strings); + str = try_val_to_str(value, ansi_tele_id_strings); if (NULL == str) { @@ -1779,7 +1779,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 = match_strval_idx((guint32) oct, ansi_tele_param_strings, &idx); + str = try_val_to_str_idx((guint32) oct, ansi_tele_param_strings, &idx); if (NULL == str) { @@ -1868,7 +1868,7 @@ dissect_ansi_637_tele(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) /* * create the ansi_637 protocol tree */ - str = match_strval(value, ansi_tele_id_strings); + str = try_val_to_str(value, ansi_tele_id_strings); if (NULL == str) { @@ -1965,7 +1965,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 = match_strval_idx((guint32) oct, ansi_trans_param_strings, &idx); + str = try_val_to_str_idx((guint32) oct, ansi_trans_param_strings, &idx); if (NULL == str) { @@ -2055,7 +2055,7 @@ dissect_ansi_637_trans(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) */ oct = tvb_get_guint8(tvb, 0); - str = match_strval_idx(oct, ansi_trans_msg_type_strings, &idx); + str = try_val_to_str_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 a02b3867af..8075e3d688 100644 --- a/epan/dissectors/packet-ansi_683.c +++ b/epan/dissectors/packet-ansi_683.c @@ -4679,7 +4679,7 @@ dissect_ansi_683_for_message(tvbuff_t *tvb, proto_tree *ansi_683_tree) msg_type = tvb_get_guint8(tvb, 0); - str = match_strval_idx(msg_type, for_msg_type_strings, &idx); + str = try_val_to_str_idx(msg_type, for_msg_type_strings, &idx); if (str == NULL) { @@ -4709,7 +4709,7 @@ dissect_ansi_683_rev_message(tvbuff_t *tvb, proto_tree *ansi_683_tree) msg_type = tvb_get_guint8(tvb, 0); - str = match_strval_idx(msg_type, rev_msg_type_strings, &idx); + str = try_val_to_str_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 b4e696f987..c8d9dc257a 100644 --- a/epan/dissectors/packet-ansi_801.c +++ b/epan/dissectors/packet-ansi_801.c @@ -429,7 +429,7 @@ for_req_cancel(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset) oct = tvb_get_guint8(tvb, offset); - str = match_strval_idx((oct & 0xf0) >> 4, for_req_type_strings, &idx); + str = try_val_to_str_idx((oct & 0xf0) >> 4, for_req_type_strings, &idx); if (str == NULL) { str = "Reserved"; @@ -466,7 +466,7 @@ for_reject(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset) oct = tvb_get_guint8(tvb, offset); - str = match_strval_idx((oct & 0xf0) >> 4, rev_req_type_strings, &idx); + str = try_val_to_str_idx((oct & 0xf0) >> 4, rev_req_type_strings, &idx); if (str == NULL) { str = "Reserved"; @@ -1156,7 +1156,7 @@ rev_reject(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset) oct = tvb_get_guint8(tvb, offset); - str = match_strval_idx((oct & 0xf0) >> 4, for_req_type_strings, &idx); + str = try_val_to_str_idx((oct & 0xf0) >> 4, for_req_type_strings, &idx); if (str == NULL) { str = "Reserved"; @@ -1388,7 +1388,7 @@ rev_pr_can_ack(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset) oct = tvb_get_guint8(tvb, offset); - str = match_strval_idx((oct & 0xf0) >> 4, for_req_type_strings, &idx); + str = try_val_to_str_idx((oct & 0xf0) >> 4, for_req_type_strings, &idx); if (str == NULL) { str = "Reserved"; @@ -1494,7 +1494,7 @@ for_request(tvbuff_t *tvb, proto_tree *tree, guint32 *offset_p, guint8 pd_msg_ty "%s : Reserved", bigbuf); - str = match_strval_idx(oct & 0x0f, for_req_type_strings, &idx); + str = try_val_to_str_idx(oct & 0x0f, for_req_type_strings, &idx); if (str == NULL) { return; @@ -1569,7 +1569,7 @@ for_response(tvbuff_t *tvb, proto_tree *tree, guint32 *offset_p) "%s : Unsolicited response indicator", bigbuf); - str = match_strval_idx(oct & 0x0f, for_rsp_type_strings, &idx); + str = try_val_to_str_idx(oct & 0x0f, for_rsp_type_strings, &idx); if (str == NULL) { @@ -1629,7 +1629,7 @@ rev_request(tvbuff_t *tvb, proto_tree *tree, guint32 *offset_p, guint8 pd_msg_ty "%s : Reserved", bigbuf); - str = match_strval_idx(oct & 0x0f, rev_req_type_strings, &idx); + str = try_val_to_str_idx(oct & 0x0f, rev_req_type_strings, &idx); if (str == NULL) { return; @@ -1701,7 +1701,7 @@ rev_response(tvbuff_t *tvb, proto_tree *tree, guint32 *offset_p) "%s : Unsolicited response indicator", bigbuf); - str = match_strval_idx(oct & 0x0f, rev_rsp_type_strings, &idx); + str = try_val_to_str_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 65cfc3befe..98746aa844 100644 --- a/epan/dissectors/packet-ansi_a.c +++ b/epan/dissectors/packet-ansi_a.c @@ -63,7 +63,7 @@ void proto_register_ansi_a(void); void proto_reg_handoff_ansi_a(void); static const gchar * -my_match_strval_idx(guint32 val, const ext_value_string_t *vs, gint *idx, gint *dec_idx) +my_try_val_to_str_idx(guint32 val, const ext_value_string_t *vs, gint *idx, gint *dec_idx) { gint i = 0; @@ -3381,7 +3381,7 @@ elem_info_rec_req(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, guint rec_type = tvb_get_guint8(tvb, curr_offset); - str = match_strval_idx((guint32) rec_type, ansi_rev_ms_info_rec_str, &idx); + str = try_val_to_str_idx((guint32) rec_type, ansi_rev_ms_info_rec_str, &idx); if (str == NULL) { @@ -5318,7 +5318,7 @@ elem_adds_user_part(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, gui adds_app = oct & 0x3f; - str = match_strval_idx((guint32) adds_app, ansi_a_adds_strings, &idx); + str = try_val_to_str_idx((guint32) adds_app, ansi_a_adds_strings, &idx); if (str == NULL) { str = "Reserved"; @@ -6273,7 +6273,7 @@ elem_fwd_ms_info_recs(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, g rec_type = tvb_get_guint8(tvb, curr_offset); - str = match_strval_idx((guint32) rec_type, ansi_fwd_ms_info_rec_str, &idx); + str = try_val_to_str_idx((guint32) rec_type, ansi_fwd_ms_info_rec_str, &idx); if (str == NULL) { @@ -6564,7 +6564,7 @@ elem_rev_ms_info_recs(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, g rec_type = tvb_get_guint8(tvb, curr_offset); - str = match_strval_idx((guint32) rec_type, ansi_rev_ms_info_rec_str, &idx); + str = try_val_to_str_idx((guint32) rec_type, ansi_rev_ms_info_rec_str, &idx); if (str == NULL) { @@ -11669,7 +11669,7 @@ dissect_bsmap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) */ oct = tvb_get_guint8(tvb, offset++); - msg_str = my_match_strval_idx((guint32) oct, ansi_a_bsmap_strings, &idx, &dec_idx); + msg_str = my_try_val_to_str_idx((guint32) oct, ansi_a_bsmap_strings, &idx, &dec_idx); /* * create the a protocol tree @@ -11786,7 +11786,7 @@ dissect_dtap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) */ oct = tvb_get_guint8(tvb, offset++); - msg_str = my_match_strval_idx((guint32) oct, ansi_a_dtap_strings, &idx, &dec_idx); + msg_str = my_try_val_to_str_idx((guint32) oct, ansi_a_dtap_strings, &idx, &dec_idx); /* * create the a protocol tree diff --git a/epan/dissectors/packet-aodv.c b/epan/dissectors/packet-aodv.c index 4ec809b165..89080953f3 100644 --- a/epan/dissectors/packet-aodv.c +++ b/epan/dissectors/packet-aodv.c @@ -769,7 +769,7 @@ dissect_aodv(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_ /* Check the type of AODV packet. */ type = tvb_get_guint8(tvb, 0); - if (match_strval(type, type_vals) == NULL) { + if (try_val_to_str(type, type_vals) == NULL) { /* * We assume this is not an AODV packet. */ diff --git a/epan/dissectors/packet-armagetronad.c b/epan/dissectors/packet-armagetronad.c index 7528daaa12..74c887a546 100644 --- a/epan/dissectors/packet-armagetronad.c +++ b/epan/dissectors/packet-armagetronad.c @@ -127,7 +127,7 @@ is_armagetronad_packet(tvbuff_t * tvb) * with the table, that's why we don't consider that as * a heuristic */ - if (!match_strval(tvb_get_ntohs(tvb, offset), descriptors)) + if (!try_val_to_str(tvb_get_ntohs(tvb, offset), descriptors)) /* DescriptorID not found in the table */ return FALSE; #endif diff --git a/epan/dissectors/packet-arp.c b/epan/dissectors/packet-arp.c index 3afab3f618..b6668c881e 100644 --- a/epan/dissectors/packet-arp.c +++ b/epan/dissectors/packet-arp.c @@ -1118,7 +1118,7 @@ dissect_atmarp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) } if (tree) { - if ((op_str = match_strval(ar_op, atmop_vals))) + if ((op_str = try_val_to_str(ar_op, atmop_vals))) ti = proto_tree_add_protocol_format(tree, proto_arp, tvb, 0, tot_len, "ATM Address Resolution Protocol (%s)", op_str); @@ -1358,7 +1358,7 @@ dissect_ax25arp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) } if (tree) { - if ((op_str = match_strval(ar_op, op_vals))) { + if ((op_str = try_val_to_str(ar_op, op_vals))) { if (is_gratuitous && (ar_op == ARPOP_REQUEST)) op_str = "request/gratuitous ARP"; if (is_gratuitous && (ar_op == ARPOP_REPLY)) @@ -1727,7 +1727,7 @@ dissect_arp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) } if (tree) { - if ((op_str = match_strval(ar_op, op_vals))) { + if ((op_str = try_val_to_str(ar_op, op_vals))) { if (is_gratuitous && (ar_op == ARPOP_REQUEST)) op_str = "request/gratuitous ARP"; if (is_gratuitous && (ar_op == ARPOP_REPLY)) diff --git a/epan/dissectors/packet-assa_r3.c b/epan/dissectors/packet-assa_r3.c index ee8fec8616..fb1f54d041 100644 --- a/epan/dissectors/packet-assa_r3.c +++ b/epan/dissectors/packet-assa_r3.c @@ -5693,7 +5693,7 @@ dissect_r3_cmd_alarmconfigure (tvbuff_t *tvb, guint32 start_offset, guint32 leng const gchar *as; guint32 alarm_len; - if (!(ai = match_strval_ext (tvb_get_guint8 (payload_tvb, offset + 1), &r3_alarmidnames_ext))) + if (!(ai = try_val_to_str_ext (tvb_get_guint8 (payload_tvb, offset + 1), &r3_alarmidnames_ext))) { ai = "[Unknown Alarm ID]"; as = "N/A"; diff --git a/epan/dissectors/packet-bfcp.c b/epan/dissectors/packet-bfcp.c index a7ad78916a..7899b1f4d0 100644 --- a/epan/dissectors/packet-bfcp.c +++ b/epan/dissectors/packet-bfcp.c @@ -395,7 +395,7 @@ dissect_bfcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_tree *bfcp_tree = NULL; primitive = tvb_get_guint8(tvb, 1); - str = match_strval(primitive, map_bfcp_primitive); + str = try_val_to_str(primitive, map_bfcp_primitive); /* Make entries in Protocol column and Info column on summary display*/ col_set_str(pinfo->cinfo, COL_PROTOCOL, "BFCP"); @@ -474,7 +474,7 @@ dissect_bfcp_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat if ((primitive < 1) || (primitive > 18)) return FALSE; - str = match_strval(primitive, map_bfcp_primitive); + str = try_val_to_str(primitive, map_bfcp_primitive); if (NULL == str) return FALSE; diff --git a/epan/dissectors/packet-bittorrent.c b/epan/dissectors/packet-bittorrent.c index 4cc2f9f7fc..631cc4d111 100644 --- a/epan/dissectors/packet-bittorrent.c +++ b/epan/dissectors/packet-bittorrent.c @@ -624,10 +624,10 @@ dissect_bittorrent_message (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) } } - msgtype = match_strval(type, bittorrent_messages); + msgtype = try_val_to_str(type, bittorrent_messages); #if 0 if (msgtype == NULL && isamp) { - msgtype = match_strval(type, azureus_messages); + msgtype = try_val_to_str(type, azureus_messages); } #endif if (msgtype == NULL) { diff --git a/epan/dissectors/packet-bssgp.c b/epan/dissectors/packet-bssgp.c index d420fd4a21..83361655fe 100644 --- a/epan/dissectors/packet-bssgp.c +++ b/epan/dissectors/packet-bssgp.c @@ -6347,7 +6347,7 @@ static void get_bssgp_msg_params(guint8 oct, const gchar **msg_str, int *ett_tre { gint idx; - *msg_str = match_strval_idx_ext((guint32) (oct & 0xff), &bssgp_msg_strings_ext, &idx); + *msg_str = try_val_to_str_idx_ext((guint32) (oct & 0xff), &bssgp_msg_strings_ext, &idx); *hf_idx = hf_bssgp_msg_type; if (*msg_str != NULL) { *ett_tree = ett_bssgp_msg[idx]; diff --git a/epan/dissectors/packet-bvlc.c b/epan/dissectors/packet-bvlc.c index 47675de307..61039a1e3c 100644 --- a/epan/dissectors/packet-bvlc.c +++ b/epan/dissectors/packet-bvlc.c @@ -131,7 +131,7 @@ dissect_bvlc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_ /* * Simple sanity check - make sure the type is one we know about. */ - if (match_strval(bvlc_type, bvlc_types) == NULL) + if (try_val_to_str(bvlc_type, bvlc_types) == NULL) return 0; col_set_str(pinfo->cinfo, COL_PROTOCOL, "BVLC"); diff --git a/epan/dissectors/packet-cell_broadcast.c b/epan/dissectors/packet-cell_broadcast.c index 61f6536618..92430936d6 100644 --- a/epan/dissectors/packet-cell_broadcast.c +++ b/epan/dissectors/packet-cell_broadcast.c @@ -188,7 +188,7 @@ guint16 dissect_cbs_message_identifier(tvbuff_t *tvb, proto_tree *tree, guint16 const char *msg_id_string = NULL; msg_id = tvb_get_ntohs(tvb, offset); - msg_id_string = match_strval(msg_id, message_id_values); + msg_id_string = try_val_to_str(msg_id, message_id_values); if (msg_id_string == NULL) { if (msg_id < 1000) diff --git a/epan/dissectors/packet-cimd.c b/epan/dissectors/packet-cimd.c index e8e565b26f..49df5bb1dd 100644 --- a/epan/dissectors/packet-cimd.c +++ b/epan/dissectors/packet-cimd.c @@ -724,7 +724,7 @@ dissect_cimd_operation(tvbuff_t *tvb, proto_tree *tree, gint etxp, guint16 check break; PC = decimal_int_value(tvb, offset + 1, CIMD_PC_LENGTH); - match_strval_idx(PC, cimd_vals_PC, &idx); + try_val_to_str_idx(PC, cimd_vals_PC, &idx); if (idx != -1 && tree) { (vals_hdr_PC[idx].diss)(tvb, cimd_tree, idx, offset, endOffset); @@ -813,7 +813,7 @@ dissect_cimd_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat /* Try getting the operation-code */ opcode = decimal_int_value(tvb, CIMD_OC_OFFSET, CIMD_OC_LENGTH); - if (match_strval(opcode, vals_hdr_OC) == NULL) + if (try_val_to_str(opcode, vals_hdr_OC) == NULL) return FALSE; if (tvb_get_guint8(tvb, CIMD_OC_OFFSET + CIMD_OC_LENGTH) != CIMD_COLON) diff --git a/epan/dissectors/packet-cip.c b/epan/dissectors/packet-cip.c index 26b7d6e3be..62b0c0088f 100644 --- a/epan/dissectors/packet-cip.c +++ b/epan/dissectors/packet-cip.c @@ -6135,7 +6135,7 @@ dissect_cip_data( proto_tree *item_tree, tvbuff_t *tvb, int offset, packet_info } /* Check to see if service is 'generic' */ - match_strval_idx((service & 0x7F), cip_sc_vals, &service_index); + try_val_to_str_idx((service & 0x7F), cip_sc_vals, &service_index); if (service_index >= 0) { /* See if object dissector wants to override generic service handling */ @@ -6211,7 +6211,7 @@ dissect_cip_data( proto_tree *item_tree, tvbuff_t *tvb, int offset, packet_info } /* Check to see if service is 'generic' */ - match_strval_idx(service, cip_sc_vals, &service_index); + try_val_to_str_idx(service, cip_sc_vals, &service_index); if (service_index >= 0) { /* See if object dissector wants to override generic service handling */ diff --git a/epan/dissectors/packet-classicstun.c b/epan/dissectors/packet-classicstun.c index af62914706..2a1624424c 100644 --- a/epan/dissectors/packet-classicstun.c +++ b/epan/dissectors/packet-classicstun.c @@ -248,7 +248,7 @@ dissect_classicstun(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *d return 0; /* check if message type is correct */ - msg_type_str = match_strval(msg_type, messages); + msg_type_str = try_val_to_str(msg_type, messages); if (msg_type_str == NULL) return 0; diff --git a/epan/dissectors/packet-cmpp.c b/epan/dissectors/packet-cmpp.c index 4699a6bced..1f582552aa 100644 --- a/epan/dissectors/packet-cmpp.c +++ b/epan/dissectors/packet-cmpp.c @@ -556,7 +556,7 @@ dissect_cmpp_tcp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) total_length = tvb_get_ntohl(tvb, 0); /* Get the pdu length */ command_id = tvb_get_ntohl(tvb, 4); /* get the pdu command id */ - if (match_strval(command_id, vals_command_Id) == NULL) + if (try_val_to_str(command_id, vals_command_Id) == NULL) { /* Should never happen: we checked this in dissect_cmpp() */ return; @@ -648,7 +648,7 @@ dissect_cmpp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_ if (total_length < CMPP_FIX_HEADER_LENGTH || total_length > 1000) return 0; - if (match_strval(command_id, vals_command_Id) == NULL) + if (try_val_to_str(command_id, vals_command_Id) == NULL) return 0; col_clear(pinfo->cinfo, COL_INFO); diff --git a/epan/dissectors/packet-csm-encaps.c b/epan/dissectors/packet-csm-encaps.c index f0a5677151..6fe19afef7 100644 --- a/epan/dissectors/packet-csm-encaps.c +++ b/epan/dissectors/packet-csm-encaps.c @@ -177,11 +177,11 @@ csm_to_host(guint16 fc, guint16 ct) { if (fc == 0x0000) { - return (match_strval(ct, exclusive_to_host_ct_vals) != NULL); + return (try_val_to_str(ct, exclusive_to_host_ct_vals) != NULL); } else { - return (match_strval(fc, exclusive_to_host_vals) != NULL); + return (try_val_to_str(fc, exclusive_to_host_vals) != NULL); } } diff --git a/epan/dissectors/packet-ddtp.c b/epan/dissectors/packet-ddtp.c index dd1f0653be..b9baba82f3 100644 --- a/epan/dissectors/packet-ddtp.c +++ b/epan/dissectors/packet-ddtp.c @@ -99,7 +99,7 @@ dissect_ddtp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_ * If we don't recognize the version number, don't dissect this. */ if (tvb_length(tvb) >= 4) { - if (match_strval(tvb_get_ntohl(tvb, 0), vals_ddtp_version) == NULL) + if (try_val_to_str(tvb_get_ntohl(tvb, 0), vals_ddtp_version) == NULL) return 0; } diff --git a/epan/dissectors/packet-diameter.c b/epan/dissectors/packet-diameter.c index db5c350607..af55b25a1e 100644 --- a/epan/dissectors/packet-diameter.c +++ b/epan/dissectors/packet-diameter.c @@ -928,7 +928,7 @@ dissect_diameter_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) cmd_vs = (value_string *)(void *)all_cmds->data; app_item = proto_tree_add_item(diam_tree, hf_diameter_application_id, tvb, 8, 4, ENC_BIG_ENDIAN); - if (match_strval(fourth, dictionary.applications) == NULL) { + if (try_val_to_str(fourth, dictionary.applications) == NULL) { proto_tree *tu = proto_item_add_subtree(app_item,ett_unknown); proto_item *iu = proto_tree_add_text(tu, tvb, 8, 4, "Unknown Application Id, " "if you know what this is you can add it to dictionary.xml"); diff --git a/epan/dissectors/packet-dlsw.c b/epan/dissectors/packet-dlsw.c index 887ef8b1d9..8c83b947f8 100644 --- a/epan/dissectors/packet-dlsw.c +++ b/epan/dissectors/packet-dlsw.c @@ -469,7 +469,7 @@ dissect_dlsw_capex(tvbuff_t *tvb, proto_tree *tree, proto_tree *ti2) static int dissect_dlsw_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) { - if (match_strval(tvb_get_guint8(tvb, 0), dlsw_version_vals) == NULL) + if (try_val_to_str(tvb_get_guint8(tvb, 0), dlsw_version_vals) == NULL) { /* Probably not a DLSw packet. */ return 0; @@ -503,7 +503,7 @@ get_dlsw_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset) static int dissect_dlsw_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) { - if (match_strval(tvb_get_guint8(tvb, 0), dlsw_version_vals) == NULL) + if (try_val_to_str(tvb_get_guint8(tvb, 0), dlsw_version_vals) == NULL) { /* Probably not a DLSw packet. */ return 0; diff --git a/epan/dissectors/packet-dtls.c b/epan/dissectors/packet-dtls.c index c231de4068..0899673219 100644 --- a/epan/dissectors/packet-dtls.c +++ b/epan/dissectors/packet-dtls.c @@ -1057,10 +1057,10 @@ dissect_dtls_alert(tvbuff_t *tvb, packet_info *pinfo, /* first lookup the names for the alert level and description */ byte = tvb_get_guint8(tvb, offset); /* grab the level byte */ - level = match_strval(byte, ssl_31_alert_level); + level = try_val_to_str(byte, ssl_31_alert_level); byte = tvb_get_guint8(tvb, offset+1); /* grab the desc byte */ - desc = match_strval(byte, ssl_31_alert_description); + desc = try_val_to_str(byte, ssl_31_alert_description); /* now set the text in the record layer line */ if (level && desc) @@ -1171,7 +1171,7 @@ dissect_dtls_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); + msg_type_str = try_val_to_str(msg_type, ssl_31_handshake_type); if (!msg_type_str && !first_iteration) { @@ -1486,7 +1486,7 @@ dissect_dtls_heartbeat(tvbuff_t *tvb, packet_info *pinfo, /* first lookup the names for the message type and the payload length */ byte = tvb_get_guint8(tvb, offset); - type = match_strval(byte, tls_heartbeat_type); + type = try_val_to_str(byte, tls_heartbeat_type); payload_length = tvb_get_ntohs(tvb, offset + 1); padding_length = record_length - 3 - payload_length; diff --git a/epan/dissectors/packet-dvb-ait.c b/epan/dissectors/packet-dvb-ait.c index c082649a79..54b371bc2d 100644 --- a/epan/dissectors/packet-dvb-ait.c +++ b/epan/dissectors/packet-dvb-ait.c @@ -241,7 +241,7 @@ dissect_dvb_ait_descriptor(tvbuff_t *tvb, guint offset, we dissect it ourselves otherwise, we assume it's a generic DVB-SI descriptor and pass it on to packet-mpeg-descriptor */ - if (match_strval(tag, ait_descr_tag)) { + if (try_val_to_str(tag, ait_descr_tag)) { offset_start = offset; descr_tree_ti = proto_tree_add_text(tree, tvb, offset_start, len+2, diff --git a/epan/dissectors/packet-dvbci.c b/epan/dissectors/packet-dvbci.c index 5c54c31df3..bdc15f8ce9 100644 --- a/epan/dissectors/packet-dvbci.c +++ b/epan/dissectors/packet-dvbci.c @@ -2674,7 +2674,7 @@ dissect_dvbci_payload_dt(guint32 tag, gint len_field, } else if (tag==T_DATE_TIME) { if (len_field!=5 && len_field!=7) { - tag_str = match_strval(tag, dvbci_apdu_tag); + tag_str = try_val_to_str(tag, dvbci_apdu_tag); pi = proto_tree_add_text(tree, tvb, APDU_TAG_SIZE, offset-APDU_TAG_SIZE, "Invalid APDU length field"); expert_add_info_format(pinfo, pi, PI_MALFORMED, PI_ERROR, @@ -3752,7 +3752,7 @@ dissect_dvbci_apdu(tvbuff_t *tvb, circuit_t *circuit, app_tree = proto_item_add_subtree(ti, ett_dvbci_application); tag = tvb_get_ntoh24(tvb, 0); - tag_str = match_strval(tag, dvbci_apdu_tag); + tag_str = try_val_to_str(tag, dvbci_apdu_tag); offset = APDU_TAG_SIZE; col_set_str(pinfo->cinfo, COL_INFO, @@ -3880,7 +3880,7 @@ dissect_dvbci_spdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, sess_tree = proto_item_add_subtree(ti, ett_dvbci_session); tag = tvb_get_guint8(tvb,0); - tag_str = match_strval(tag, dvbci_spdu_tag); + tag_str = try_val_to_str(tag, dvbci_spdu_tag); col_add_str(pinfo->cinfo, COL_INFO, val_to_str_const(tag, dvbci_spdu_tag, "Invalid SPDU")); if (tag_str) { @@ -4071,7 +4071,7 @@ dissect_dvbci_tpdu_status(tvbuff_t *tvb, gint offset, offset_new++; sb_value = tvb_get_guint8(tvb, offset_new); - sb_str = match_strval(sb_value, dvbci_sb_value); + sb_str = try_val_to_str(sb_value, dvbci_sb_value); if (sb_str) { col_append_sep_fstr(pinfo->cinfo, COL_INFO, ": ", "%s", sb_str); proto_tree_add_item(tree, hf_dvbci_sb_value, tvb, @@ -4106,7 +4106,7 @@ dissect_dvbci_tpdu_hdr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, if (direction==DATA_HOST_TO_CAM) { c_tpdu_tag = tvb_get_guint8(tvb, 0); tag = &c_tpdu_tag; - c_tpdu_str = match_strval(c_tpdu_tag, dvbci_c_tpdu); + c_tpdu_str = try_val_to_str(c_tpdu_tag, dvbci_c_tpdu); if (c_tpdu_str) { col_append_sep_fstr(pinfo->cinfo, COL_INFO, NULL, "%s", c_tpdu_str); proto_tree_add_item(tree, hf_dvbci_c_tpdu_tag, tvb, 0, 1, ENC_BIG_ENDIAN); @@ -4124,7 +4124,7 @@ dissect_dvbci_tpdu_hdr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, else { r_tpdu_tag = tvb_get_guint8(tvb, 0); tag = &r_tpdu_tag; - r_tpdu_str = match_strval(r_tpdu_tag, dvbci_r_tpdu); + r_tpdu_str = try_val_to_str(r_tpdu_tag, dvbci_r_tpdu); if (r_tpdu_str) { col_append_sep_fstr(pinfo->cinfo, COL_INFO, NULL, "%s", r_tpdu_str); proto_tree_add_item(tree, hf_dvbci_r_tpdu_tag, tvb, 0, 1, ENC_BIG_ENDIAN); @@ -4288,7 +4288,7 @@ dissect_dvbci_lpdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_tree_add_item(link_tree, hf_dvbci_tcid, tvb, 0, 1, ENC_BIG_ENDIAN); more_last = tvb_get_guint8(tvb, 1); - if (match_strval(more_last, dvbci_ml)) { + if (try_val_to_str(more_last, dvbci_ml)) { proto_tree_add_item(link_tree, hf_dvbci_ml, tvb, 1, 1, ENC_BIG_ENDIAN); } else { @@ -4644,7 +4644,7 @@ dissect_dvbci(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U offset_evt = offset; event = tvb_get_guint8(tvb, offset++); - event_str = match_strval(event, dvbci_event); + event_str = try_val_to_str(event, dvbci_event); if (!event_str) return 0; diff --git a/epan/dissectors/packet-e212.c b/epan/dissectors/packet-e212.c index d47f743bd4..728eaf6b5c 100644 --- a/epan/dissectors/packet-e212.c +++ b/epan/dissectors/packet-e212.c @@ -2643,7 +2643,7 @@ dissect_e212_mcc_mnc_in_address(tvbuff_t *tvb, packet_info *pinfo, proto_tree *t mnc = 10 * mnc1 + mnc2; /* Try to match the MCC and 2 digits MNC with an entry in our list of operators */ - if (!match_strval_ext(mcc * 1000 + 10 * mnc, &mcc_mnc_codes_ext)) { + if (!try_val_to_str_ext(mcc * 1000 + 10 * mnc, &mcc_mnc_codes_ext)) { mnc = 10 * mnc + mnc3; long_mnc = TRUE; } diff --git a/epan/dissectors/packet-edonkey.c b/epan/dissectors/packet-edonkey.c index 06887ec1f0..cb80039f52 100644 --- a/epan/dissectors/packet-edonkey.c +++ b/epan/dissectors/packet-edonkey.c @@ -597,7 +597,7 @@ static guint8 edonkey_metatag_name_get_type(tvbuff_t *tvb, gint start, gint leng { guint8 *tag_name; - if (match_strval(special_tagtype, edonkey_special_tags) == NULL) { + if (try_val_to_str(special_tagtype, edonkey_special_tags) == NULL) { gint idx; tag_name = tvb_get_ephemeral_string(tvb, start, length); idx = lookup_str_index(tag_name, length, edonkey_special_tags); @@ -613,7 +613,7 @@ static proto_item* edonkey_tree_add_metatag_name(proto_tree *tree, tvbuff_t *tvb gint start, gint length, guint8 special_tagtype) { const gchar *tag_name; - tag_name = match_strval(special_tagtype, edonkey_special_tags); + tag_name = try_val_to_str(special_tagtype, edonkey_special_tags); if (tag_name == NULL) { return proto_tree_add_item(tree, hf_edonkey_metatag_name, tvb, start, length, ENC_ASCII|ENC_NA); } @@ -2955,7 +2955,7 @@ static void dissect_edonkey_tcp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tre protocol = tvb_get_guint8(tvb, offset); msg_len = tvb_get_letohl(tvb, offset+1); - protocol_name = match_strval(protocol, edonkey_protocols); + protocol_name = try_val_to_str(protocol, edonkey_protocols); /* Add edonkey message tree */ if (edonkey_tree) { @@ -3034,7 +3034,7 @@ static int dissect_edonkey_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tr return 0; protocol = tvb_get_guint8(tvb, 0); - if (match_strval(protocol, edonkey_protocols) == NULL) + if (try_val_to_str(protocol, edonkey_protocols) == NULL) return 0; /* Not a known protocol */ col_clear(pinfo->cinfo, COL_INFO); @@ -3058,7 +3058,7 @@ static int dissect_edonkey_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tr return 0; protocol = tvb_get_guint8(tvb, offset); - if (match_strval(protocol, edonkey_protocols) == NULL) + if (try_val_to_str(protocol, edonkey_protocols) == NULL) return 0; /* Not a known protocol */ col_set_str(pinfo->cinfo, COL_PROTOCOL, "eDonkey"); diff --git a/epan/dissectors/packet-enip.c b/epan/dissectors/packet-enip.c index 60be5589e9..eebffcedb4 100644 --- a/epan/dissectors/packet-enip.c +++ b/epan/dissectors/packet-enip.c @@ -2089,7 +2089,7 @@ dissect_enip_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data /* Get the command type and see if it's valid. */ encap_cmd = tvb_get_letohs( tvb, 0 ); - if (match_strval(encap_cmd, encap_cmd_vals) == NULL) + if (try_val_to_str(encap_cmd, encap_cmd_vals) == NULL) return 0; /* not a known command */ dissect_enip_pdu(tvb, pinfo, tree); @@ -2107,7 +2107,7 @@ dissect_enip_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data /* Get the command type and see if it's valid. */ encap_cmd = tvb_get_letohs( tvb, 0 ); - if (match_strval(encap_cmd, encap_cmd_vals) == NULL) + if (try_val_to_str(encap_cmd, encap_cmd_vals) == NULL) return 0; /* not a known command */ tcp_dissect_pdus(tvb, pinfo, tree, enip_desegment, 4, get_enip_pdu_len, dissect_enip_pdu); diff --git a/epan/dissectors/packet-epl.c b/epan/dissectors/packet-epl.c index c99fe3e912..84322e4de1 100644 --- a/epan/dissectors/packet-epl.c +++ b/epan/dissectors/packet-epl.c @@ -823,7 +823,7 @@ decode_epl_address (guchar adr) { const gchar *addr_str; - addr_str = match_strval(adr, addr_str_vals); + addr_str = try_val_to_str(adr, addr_str_vals); if (addr_str != NULL) { diff --git a/epan/dissectors/packet-etch.c b/epan/dissectors/packet-etch.c index 4c0b22fe66..1819654c75 100644 --- a/epan/dissectors/packet-etch.c +++ b/epan/dissectors/packet-etch.c @@ -167,7 +167,7 @@ void proto_reg_handoff_etch(void); * a. Upon startup & whenever symbol folder changed: Read from file(s) * and add all hash/symbol pairs to a GArray; * b. When file reads complete, sort the GArray and then create a - * value_string_ext from the array for use by match_strval_ext & friends. + * value_string_ext from the array for use by try_val_to_str_ext & friends. * (Code based upon code in packet-diameter.c) */ static GArray *gbl_symbols_array = NULL; @@ -528,7 +528,7 @@ read_number(unsigned int *offset, tvbuff_t *tvb, proto_tree *etch_tree, gbl_symbol_buffer = ep_strbuf_new_label(""); /* no symbol found yet */ if (byteLength == 4) { hash = tvb_get_ntohl(tvb, *offset); - symbol = match_strval_ext(hash, gbl_symbols_vs_ext); + symbol = try_val_to_str_ext(hash, gbl_symbols_vs_ext); if(symbol != NULL) { asWhat = hf_etch_symbol; gbl_have_symbol = TRUE; @@ -693,7 +693,7 @@ get_column_info(tvbuff_t *tvb) const gchar *symbol; guint32 hash; hash = tvb_get_ntohl(tvb, my_offset); - symbol = match_strval_ext(hash, gbl_symbols_vs_ext); + symbol = try_val_to_str_ext(hash, gbl_symbols_vs_ext); if (symbol != NULL) { ep_strbuf_append_printf(result_buf, "%s()", symbol); } diff --git a/epan/dissectors/packet-ethertype.c b/epan/dissectors/packet-ethertype.c index 6f43608ef2..bd49796a8a 100644 --- a/epan/dissectors/packet-ethertype.c +++ b/epan/dissectors/packet-ethertype.c @@ -311,7 +311,7 @@ ethertype(guint16 etype, tvbuff_t *tvb, int offset_after_etype, /* Label protocol */ col_add_fstr(pinfo->cinfo, COL_PROTOCOL, "0x%04x", etype); - description = match_strval(etype, etype_vals); + description = try_val_to_str(etype, etype_vals); if (description) { col_add_str(pinfo->cinfo, COL_INFO, description); } diff --git a/epan/dissectors/packet-fcoib.c b/epan/dissectors/packet-fcoib.c index dcd90b0913..82f06e4b0e 100644 --- a/epan/dissectors/packet-fcoib.c +++ b/epan/dissectors/packet-fcoib.c @@ -212,9 +212,9 @@ dissect_fcoib(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U return FALSE; /* the sig field in the FCoIB Encap. header MUST be 2'b01*/ if (!tvb_bytes_exist(tvb, eof_offset + 1, 3) || tvb_get_ntoh24(tvb, eof_offset + 1) != 0) return FALSE; /* 3 bytes of RESERVED field immediately after eEOF MUST be 0 */ - if (!match_strval(sof, fcoib_sof_vals)) + if (!try_val_to_str(sof, fcoib_sof_vals)) return FALSE; /* invalid value for SOF */ - if (!match_strval(eof, fcoib_eof_vals)) + if (!try_val_to_str(eof, fcoib_eof_vals)) return FALSE; /* invalid value for EOF */ } diff --git a/epan/dissectors/packet-forces.c b/epan/dissectors/packet-forces.c index 688f6862c5..41728d9a78 100644 --- a/epan/dissectors/packet-forces.c +++ b/epan/dissectors/packet-forces.c @@ -364,7 +364,7 @@ dissect_operation_tlv(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint type = tvb_get_ntohs(tvb,offset); ti = proto_tree_add_item(oper_tree, hf_forces_lfbselect_tlv_type_operation_type, tvb, offset, 2, ENC_BIG_ENDIAN); - if (match_strval(type, operation_type_vals) == NULL) + if (try_val_to_str(type, operation_type_vals) == NULL) expert_add_info_format(pinfo, ti, PI_PROTOCOL, PI_WARN, "Bogus: ForCES Operation TLV (Type:0x%04x) is not supported", type); diff --git a/epan/dissectors/packet-gadu-gadu.c b/epan/dissectors/packet-gadu-gadu.c index 364ad65ee7..504814cadc 100644 --- a/epan/dissectors/packet-gadu-gadu.c +++ b/epan/dissectors/packet-gadu-gadu.c @@ -1741,7 +1741,7 @@ dissect_gadu_gadu_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) case GG_OWN_RESOURCE_INFO: default: { - const char *pkt_name = match_strval(pkt_type, gadu_gadu_packets_type_recv); + const char *pkt_name = try_val_to_str(pkt_type, gadu_gadu_packets_type_recv); if (pkt_name) col_set_str(pinfo->cinfo, COL_INFO, pkt_name); @@ -1865,7 +1865,7 @@ dissect_gadu_gadu_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) case GG_LOGIN105: default: { - const char *pkt_name = match_strval(pkt_type, gadu_gadu_packets_type_send); + const char *pkt_name = try_val_to_str(pkt_type, gadu_gadu_packets_type_send); if (pkt_name) col_set_str(pinfo->cinfo, COL_INFO, pkt_name); diff --git a/epan/dissectors/packet-ged125.c b/epan/dissectors/packet-ged125.c index 3f41bee428..abb7fe7957 100644 --- a/epan/dissectors/packet-ged125.c +++ b/epan/dissectors/packet-ged125.c @@ -1284,7 +1284,7 @@ dissect_ged125(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _ message_type = tvb_get_ntohl(tvb, 4); /*checks to make sure it's of a ged125 base message type*/ - if (match_strval(message_type, base_message_values) == NULL) + if (try_val_to_str(message_type, base_message_values) == NULL) return 0; /* not a known command */ if (tree) diff --git a/epan/dissectors/packet-gmr1_rr.c b/epan/dissectors/packet-gmr1_rr.c index 0bfb0ad8fa..4f51e069eb 100644 --- a/epan/dissectors/packet-gmr1_rr.c +++ b/epan/dissectors/packet-gmr1_rr.c @@ -1759,10 +1759,10 @@ gmr1_get_msg_rr_params(guint8 oct, int dcch, const gchar **msg_str, gint idx; if (dcch) - m = match_strval_idx((guint32)oct | 0x100, gmr1_msg_rr_strings, &idx); + m = try_val_to_str_idx((guint32)oct | 0x100, gmr1_msg_rr_strings, &idx); if (!m) - m = match_strval_idx((guint32)oct, gmr1_msg_rr_strings, &idx); + m = try_val_to_str_idx((guint32)oct, gmr1_msg_rr_strings, &idx); *msg_str = m; *hf_idx = hf_rr_msg_type; diff --git a/epan/dissectors/packet-gsm_a_bssmap.c b/epan/dissectors/packet-gsm_a_bssmap.c index d354f3d9b8..0ac40af1d3 100644 --- a/epan/dissectors/packet-gsm_a_bssmap.c +++ b/epan/dissectors/packet-gsm_a_bssmap.c @@ -4686,7 +4686,7 @@ be_field_element_dissect(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, gu */ oct = tvb_get_guint8(tvb, curr_offset++); - str = match_strval_idx((guint32) oct, bssmap_field_element_ids, &idx); + str = try_val_to_str_idx((guint32) oct, bssmap_field_element_ids, &idx); ie_len = tvb_get_guint8(tvb, curr_offset++); if (!str) @@ -6976,7 +6976,7 @@ dissect_bssmap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) */ oct = tvb_get_guint8(tvb, offset++); - str = match_strval_idx_ext((guint32) oct, &gsm_a_bssmap_msg_strings_ext, &idx); + str = try_val_to_str_idx_ext((guint32) oct, &gsm_a_bssmap_msg_strings_ext, &idx); if (sccp_msg_p && !sccp_msg_p->data.co.label) { sccp_msg_p->data.co.label = se_strdup(val_to_str_ext((guint32)oct, diff --git a/epan/dissectors/packet-gsm_a_dtap.c b/epan/dissectors/packet-gsm_a_dtap.c index e9d8df0a54..e89f98a405 100644 --- a/epan/dissectors/packet-gsm_a_dtap.c +++ b/epan/dissectors/packet-gsm_a_dtap.c @@ -825,7 +825,7 @@ de_rej_cause(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 of oct = tvb_get_guint8(tvb, offset); - str = match_strrval(oct, gsm_a_dtap_rej_cause_vals); + str = try_rval_to_str(oct, gsm_a_dtap_rej_cause_vals); if(!str) { if(is_uplink == IS_UPLINK_TRUE) @@ -6431,7 +6431,7 @@ dissect_dtap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) switch (pd) { case 3: - msg_str = match_strval_idx((guint32) (oct & DTAP_CC_IEI_MASK), gsm_a_dtap_msg_cc_strings, &idx); + msg_str = try_val_to_str_idx((guint32) (oct & DTAP_CC_IEI_MASK), gsm_a_dtap_msg_cc_strings, &idx); if (msg_str != NULL) { ett_tree = ett_gsm_dtap_msg_cc[idx]; @@ -6443,7 +6443,7 @@ dissect_dtap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) break; case 5: - msg_str = match_strval_idx((guint32) (oct & DTAP_MM_IEI_MASK), gsm_a_dtap_msg_mm_strings, &idx); + msg_str = try_val_to_str_idx((guint32) (oct & DTAP_MM_IEI_MASK), gsm_a_dtap_msg_mm_strings, &idx); if (msg_str != NULL) { ett_tree = ett_gsm_dtap_msg_mm[idx]; @@ -6462,7 +6462,7 @@ dissect_dtap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) break; case 9: - msg_str = match_strval_idx((guint32) (oct & DTAP_SMS_IEI_MASK), gsm_a_dtap_msg_sms_strings, &idx); + msg_str = try_val_to_str_idx((guint32) (oct & DTAP_SMS_IEI_MASK), gsm_a_dtap_msg_sms_strings, &idx); hf_idx = hf_gsm_a_dtap_msg_sms_type; if (msg_str != NULL) { @@ -6478,7 +6478,7 @@ dissect_dtap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) break; case 11: - msg_str = match_strval_idx((guint32) (oct & DTAP_SS_IEI_MASK), gsm_a_dtap_msg_ss_strings, &idx); + msg_str = try_val_to_str_idx((guint32) (oct & DTAP_SS_IEI_MASK), gsm_a_dtap_msg_ss_strings, &idx); hf_idx = hf_gsm_a_dtap_msg_ss_type; if (msg_str != NULL) { @@ -6490,7 +6490,7 @@ dissect_dtap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) break; case 15: - msg_str = match_strval_idx((guint32) (oct & DTAP_TP_IEI_MASK), gsm_a_dtap_msg_tp_strings, &idx); + msg_str = try_val_to_str_idx((guint32) (oct & DTAP_TP_IEI_MASK), gsm_a_dtap_msg_tp_strings, &idx); hf_idx = hf_gsm_a_dtap_msg_tp_type; if (msg_str != NULL) { diff --git a/epan/dissectors/packet-gsm_a_gm.c b/epan/dissectors/packet-gsm_a_gm.c index 034dd4b6f1..7614f4ecf5 100644 --- a/epan/dissectors/packet-gsm_a_gm.c +++ b/epan/dissectors/packet-gsm_a_gm.c @@ -7116,7 +7116,7 @@ get_gmm_msg_params(guint8 oct, const gchar **msg_str, int *ett_tree, int *hf_idx { gint idx; - *msg_str = match_strval_idx((guint32) (oct & DTAP_GMM_IEI_MASK), gsm_a_dtap_msg_gmm_strings, &idx); + *msg_str = try_val_to_str_idx((guint32) (oct & DTAP_GMM_IEI_MASK), gsm_a_dtap_msg_gmm_strings, &idx); *hf_idx = hf_gsm_a_dtap_msg_gmm_type; if (*msg_str != NULL) { *ett_tree = ett_gsm_dtap_msg_gmm[idx]; @@ -7131,7 +7131,7 @@ get_sm_msg_params(guint8 oct, const gchar **msg_str, int *ett_tree, int *hf_idx, { gint idx; - *msg_str = match_strval_idx((guint32) (oct & DTAP_SM_IEI_MASK), gsm_a_dtap_msg_sm_strings, &idx); + *msg_str = try_val_to_str_idx((guint32) (oct & DTAP_SM_IEI_MASK), gsm_a_dtap_msg_sm_strings, &idx); *hf_idx = hf_gsm_a_dtap_msg_sm_type; if (*msg_str != NULL) { *ett_tree = ett_gsm_dtap_msg_sm[idx]; diff --git a/epan/dissectors/packet-gsm_a_rp.c b/epan/dissectors/packet-gsm_a_rp.c index b1325b58a7..83a50b0a8b 100644 --- a/epan/dissectors/packet-gsm_a_rp.c +++ b/epan/dissectors/packet-gsm_a_rp.c @@ -469,7 +469,7 @@ dissect_rp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) */ oct = tvb_get_guint8(tvb, offset++); - str = match_strval_idx((guint32) oct, gsm_rp_msg_strings, &idx); + str = try_val_to_str_idx((guint32) oct, gsm_rp_msg_strings, &idx); /* * create the protocol tree diff --git a/epan/dissectors/packet-gsm_a_rr.c b/epan/dissectors/packet-gsm_a_rr.c index 158ae80f19..02c17abbda 100644 --- a/epan/dissectors/packet-gsm_a_rr.c +++ b/epan/dissectors/packet-gsm_a_rr.c @@ -10443,7 +10443,7 @@ void get_rr_msg_params(guint8 oct, const gchar **msg_str, int *ett_tree, int *hf { gint idx; - *msg_str = match_strval_idx((guint32) (oct & DTAP_RR_IEI_MASK), gsm_a_dtap_msg_rr_strings, &idx); + *msg_str = try_val_to_str_idx((guint32) (oct & DTAP_RR_IEI_MASK), gsm_a_dtap_msg_rr_strings, &idx); *hf_idx = hf_gsm_a_dtap_msg_rr_type; if (*msg_str != NULL) { *ett_tree = ett_gsm_dtap_msg_rr[idx]; @@ -10680,7 +10680,7 @@ get_rr_short_pd_msg_params(guint8 mess_type, const gchar **msg_str, int *ett_tre { gint idx; - *msg_str = match_strval_idx((guint32) mess_type, gsm_a_rr_short_pd_msg_strings, &idx); + *msg_str = try_val_to_str_idx((guint32) mess_type, gsm_a_rr_short_pd_msg_strings, &idx); *hf_idx = hf_gsm_a_rr_short_pd_msg_type; if (*msg_str != NULL) { *ett_tree = ett_gsm_sacch_msg_rr[idx]; diff --git a/epan/dissectors/packet-gsm_abis_oml.c b/epan/dissectors/packet-gsm_abis_oml.c index 92dd2c81c3..fdd204df5b 100644 --- a/epan/dissectors/packet-gsm_abis_oml.c +++ b/epan/dissectors/packet-gsm_abis_oml.c @@ -1164,10 +1164,10 @@ static void format_custom_msgtype(gchar *out, guint32 in) switch (global_oml_dialect) { case OML_DIALECT_SIEMENS: - tmp = match_strval(in, oml_fom_msgtype_vals_bs11); + tmp = try_val_to_str(in, oml_fom_msgtype_vals_bs11); break; case OML_DIALECT_IPA: - tmp = match_strval(in, oml_fom_msgtype_vals_ipa); + tmp = try_val_to_str(in, oml_fom_msgtype_vals_ipa); break; case OML_DIALECT_ETSI: default: @@ -1189,10 +1189,10 @@ static void format_custom_attr(gchar *out, guint32 in) switch (global_oml_dialect) { case OML_DIALECT_SIEMENS: - tmp = match_strval(in, oml_fom_attr_vals_bs11); + tmp = try_val_to_str(in, oml_fom_attr_vals_bs11); break; case OML_DIALECT_IPA: - tmp = match_strval(in, oml_fom_attr_vals_ipa); + tmp = try_val_to_str(in, oml_fom_attr_vals_ipa); break; case OML_DIALECT_ETSI: default: diff --git a/epan/dissectors/packet-gsm_bssmap_le.c b/epan/dissectors/packet-gsm_bssmap_le.c index d914b5f6ba..0879c0c198 100644 --- a/epan/dissectors/packet-gsm_bssmap_le.c +++ b/epan/dissectors/packet-gsm_bssmap_le.c @@ -947,7 +947,7 @@ dissect_bssmap_le(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) */ oct = tvb_get_guint8(tvb, offset++); - str = match_strval_idx((guint32) oct, gsm_bssmap_le_msg_strings, &idx); + str = try_val_to_str_idx((guint32) oct, gsm_bssmap_le_msg_strings, &idx); if (sccp_msg_p && !sccp_msg_p->data.co.label) { sccp_msg_p->data.co.label = se_strdup(val_to_str((guint32) oct, gsm_bssmap_le_msg_strings, "BSSMAP LE(0x%02x)")); diff --git a/epan/dissectors/packet-gsm_map.c b/epan/dissectors/packet-gsm_map.c index d0a3fbb037..dcef63d42c 100644 --- a/epan/dissectors/packet-gsm_map.c +++ b/epan/dissectors/packet-gsm_map.c @@ -19762,7 +19762,7 @@ dissect_gsm_map(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) } dissect_gsm_map_GSMMAPPDU(FALSE, tvb, 0, &asn1_ctx, tree, -1); - match_strval_idx(opcode, gsm_map_opr_code_strings, &op_idx); + try_val_to_str_idx(opcode, gsm_map_opr_code_strings, &op_idx); if (op_idx != -1) { tap_rec.invoke = (gsmmap_pdu_type == 1) ? TRUE : FALSE; diff --git a/epan/dissectors/packet-gsm_sms.c b/epan/dissectors/packet-gsm_sms.c index 3ee4e3b37e..56418047f3 100644 --- a/epan/dissectors/packet-gsm_sms.c +++ b/epan/dissectors/packet-gsm_sms.c @@ -3490,7 +3490,7 @@ dissect_gsm_sms(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) */ msg_type |= ((pinfo->p2p_dir == P2P_DIR_RECV) ? 0x04 : 0x00); - str = match_strval_idx(msg_type, msg_type_strings, &idx); + str = try_val_to_str_idx(msg_type, msg_type_strings, &idx); /* * create the GSM_SMS protocol tree diff --git a/epan/dissectors/packet-gtp.c b/epan/dissectors/packet-gtp.c index 23596de211..387e0cbdfe 100644 --- a/epan/dissectors/packet-gtp.c +++ b/epan/dissectors/packet-gtp.c @@ -7835,7 +7835,7 @@ dissect_gtp_common(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree) return 0; } octet = tvb_get_guint8(tvb, 1); - if (octet == GTP_MSG_UNKNOWN || match_strval(octet, gtp_message_type) == NULL) { + if (octet == GTP_MSG_UNKNOWN || try_val_to_str(octet, gtp_message_type) == NULL) { /* Unknown message type; reject the packet */ return 0; } diff --git a/epan/dissectors/packet-h248.c b/epan/dissectors/packet-h248.c index c75d57ae6f..02b60ce44b 100644 --- a/epan/dissectors/packet-h248.c +++ b/epan/dissectors/packet-h248.c @@ -1249,7 +1249,7 @@ extern void h248_param_PkgdName(proto_tree* tree, tvbuff_t* tvb, packet_info* pi pi = proto_tree_add_uint(package_tree, hf_248_pkg_param, tvb, offset-2, 2, name_minor); - if (pkg->signal_names && ( strval = match_strval(name_minor, pkg->signal_names) )) { + if (pkg->signal_names && ( strval = try_val_to_str(name_minor, pkg->signal_names) )) { strval = ep_strdup_printf("%s (%d)",strval,name_minor); } else { strval = ep_strdup_printf("Unknown (%d)",name_minor); @@ -1391,7 +1391,7 @@ void h248_register_package(const h248_package_t* pkg, pkg_reg_action reg_action) pkg_found->param_names = vst; pkg_found->hfid = &hf_h248_pkg_name; pkg_found->ett = &ett_packagename; - match_strval_idx((pkg_found->id)<<16,base_event_name_vals, &j); + try_val_to_str_idx((pkg_found->id)<<16,base_event_name_vals, &j); /* now look for events and signals that may be defined for package. If found, create value_strings */ if (j != -1) { j++; idx=j; @@ -1409,7 +1409,7 @@ void h248_register_package(const h248_package_t* pkg, pkg_reg_action reg_action) } } /* now look at signals */ - if (!match_strval_idx((pkg_found->id)<<16, base_signal_name_vals, &j)) { + if (!try_val_to_str_idx((pkg_found->id)<<16, base_signal_name_vals, &j)) { j++; idx=j; while((base_signal_name_vals[j].strptr != NULL) && ((base_signal_name_vals[j].value>>16) == (pkg_found->id))) { }; @@ -1506,7 +1506,7 @@ static int dissect_h248_PkgdName(gboolean implicit_tag, tvbuff_t *tvb, int offse proto_item* pi = proto_tree_add_uint(package_tree, hf_248_pkg_param, tvb, offset-2, 2, name_minor); const gchar* strval; - if (pkg->param_names && ( strval = match_strval(name_minor, pkg->param_names) )) { + if (pkg->param_names && ( strval = try_val_to_str(name_minor, pkg->param_names) )) { strval = ep_strdup_printf("%s (%d)",strval,name_minor); } else { strval = ep_strdup_printf("Unknown (%d)",name_minor); @@ -1569,7 +1569,7 @@ static int dissect_h248_EventName(gboolean implicit_tag, tvbuff_t *tvb, int offs proto_item* pi = proto_tree_add_uint(package_tree, hf_h248_event_code, tvb, offset-2, 2, name_minor); const gchar* strval; - if (pkg->event_names && ( strval = match_strval(name_minor, pkg->event_names) )) { + if (pkg->event_names && ( strval = try_val_to_str(name_minor, pkg->event_names) )) { strval = ep_strdup_printf("%s (%d)",strval,name_minor); } else { strval = ep_strdup_printf("Unknown (%d)",name_minor); @@ -1634,7 +1634,7 @@ static int dissect_h248_SignalName(gboolean implicit_tag , tvbuff_t *tvb, int of proto_item* pi = proto_tree_add_uint(package_tree, hf_h248_signal_code, tvb, offset-2, 2, name_minor); const gchar* strval; - if (pkg->signal_names && ( strval = match_strval(name_minor, pkg->signal_names) )) { + if (pkg->signal_names && ( strval = try_val_to_str(name_minor, pkg->signal_names) )) { strval = ep_strdup_printf("%s (%d)",strval,name_minor); } else { strval = ep_strdup_printf("Unknown (%d)",name_minor); @@ -1727,7 +1727,7 @@ static int dissect_h248_SigParameterName(gboolean implicit_tag _U_, tvbuff_t *tv } } - if (curr_info.sig && curr_info.sig->param_names && ( strval = match_strval(param_id, curr_info.sig->param_names) )) { + if (curr_info.sig && curr_info.sig->param_names && ( strval = try_val_to_str(param_id, curr_info.sig->param_names) )) { strval = ep_strdup_printf("%s (%d)",strval,param_id); } else { strval = ep_strdup_printf("Unknown (%d)",param_id); @@ -1804,7 +1804,7 @@ static int dissect_h248_EventParameterName(gboolean implicit_tag _U_, tvbuff_t * curr_info.par = &no_param; } - if (curr_info.evt && curr_info.evt->param_names && ( strval = match_strval(param_id, curr_info.evt->param_names) )) { + if (curr_info.evt && curr_info.evt->param_names && ( strval = try_val_to_str(param_id, curr_info.evt->param_names) )) { strval = ep_strdup_printf("%s (%d)",strval,param_id); } else { strval = ep_strdup_printf("Unknown (%d)",param_id); diff --git a/epan/dissectors/packet-h264.c b/epan/dissectors/packet-h264.c index 59cabef7fa..433b46a9ed 100644 --- a/epan/dissectors/packet-h264.c +++ b/epan/dissectors/packet-h264.c @@ -2027,7 +2027,7 @@ dissect_h264_par_level(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree _U_, DISSECTOR_ASSERT(actx); lvl = tvb_get_ntohs(tvb, offset); - p = match_strval(lvl, VALS(h264_par_level_values)); + p = try_val_to_str(lvl, VALS(h264_par_level_values)); if (p) { proto_item_append_text(actx->created_item, " - Level %s", p); } diff --git a/epan/dissectors/packet-h282.c b/epan/dissectors/packet-h282.c index a41e09b7f9..29489bed14 100644 --- a/epan/dissectors/packet-h282.c +++ b/epan/dissectors/packet-h282.c @@ -4265,7 +4265,7 @@ dissect_h282_RequestPDU(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, &msg_type); #line 27 "../../asn1/h282/h282.cnf" - p = match_strval(msg_type, VALS(h282_RequestPDU_vals)); + p = try_val_to_str(msg_type, VALS(h282_RequestPDU_vals)); if (p) col_add_fstr(actx->pinfo->cinfo, COL_INFO, "RequestPDU/%s", p); @@ -4308,7 +4308,7 @@ dissect_h282_ResponsePDU(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_ &msg_type); #line 38 "../../asn1/h282/h282.cnf" - p = match_strval(msg_type, VALS(h282_ResponsePDU_vals)); + p = try_val_to_str(msg_type, VALS(h282_ResponsePDU_vals)); if (p) col_add_fstr(actx->pinfo->cinfo, COL_INFO, "ResponsePDU/%s", p); @@ -4343,7 +4343,7 @@ dissect_h282_IndicationPDU(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _ &msg_type); #line 49 "../../asn1/h282/h282.cnf" - p = match_strval(msg_type, VALS(h282_IndicationPDU_vals)); + p = try_val_to_str(msg_type, VALS(h282_IndicationPDU_vals)); if (p) col_add_fstr(actx->pinfo->cinfo, COL_INFO, "IndicationPDU/%s", p); diff --git a/epan/dissectors/packet-h283.c b/epan/dissectors/packet-h283.c index 7758852749..30f07de0d1 100644 --- a/epan/dissectors/packet-h283.c +++ b/epan/dissectors/packet-h283.c @@ -277,7 +277,7 @@ dissect_h283_LCTRequest(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, &msg_type); #line 61 "../../asn1/h283/h283.cnf" - p = match_strval(msg_type, VALS(h283_LCTRequest_vals)); + p = try_val_to_str(msg_type, VALS(h283_LCTRequest_vals)); if (!info_is_set && p ) { col_add_fstr(actx->pinfo->cinfo, COL_INFO, "LCTRequest/%s", p); info_is_set = TRUE; @@ -328,7 +328,7 @@ dissect_h283_LCTResponse(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_ &msg_type); #line 74 "../../asn1/h283/h283.cnf" - p = match_strval(msg_type, VALS(h283_LCTResponse_vals)); + p = try_val_to_str(msg_type, VALS(h283_LCTResponse_vals)); if (!info_is_set && p ) { col_add_fstr(actx->pinfo->cinfo, COL_INFO, "LCTResponse/%s", p); info_is_set = TRUE; @@ -359,7 +359,7 @@ dissect_h283_LCTIndication(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _ &msg_type); #line 87 "../../asn1/h283/h283.cnf" - p = match_strval(msg_type, VALS(h283_LCTIndication_vals)); + p = try_val_to_str(msg_type, VALS(h283_LCTIndication_vals)); if (!info_is_set && p ) { col_add_fstr(actx->pinfo->cinfo, COL_INFO, "LCTIndication/%s", p); info_is_set = TRUE; @@ -423,7 +423,7 @@ dissect_h283_LCTMessage(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, &msg_type); #line 48 "../../asn1/h283/h283.cnf" - p = match_strval(msg_type, VALS(h283_LCTMessage_vals)); + p = try_val_to_str(msg_type, VALS(h283_LCTMessage_vals)); if (!info_is_set && p ) { col_add_fstr(actx->pinfo->cinfo, COL_INFO, "LCTMessage/%s", p); info_is_set = TRUE; @@ -475,7 +475,7 @@ dissect_h283_T_dataType(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, &data_type); #line 35 "../../asn1/h283/h283.cnf" - p = match_strval(data_type, VALS(h283_T_dataType_vals)); + p = try_val_to_str(data_type, VALS(h283_T_dataType_vals)); if (!info_is_set && p ) { col_add_fstr(actx->pinfo->cinfo, COL_INFO, "RDCData/%s", p); info_is_set = TRUE; @@ -523,7 +523,7 @@ dissect_h283_T_pduType(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, &pdu_type); #line 22 "../../asn1/h283/h283.cnf" - p = match_strval(pdu_type, VALS(h283_T_pduType_vals)); + p = try_val_to_str(pdu_type, VALS(h283_T_pduType_vals)); if (!info_is_set && p ) { col_set_str(actx->pinfo->cinfo, COL_INFO, p); info_is_set = TRUE; diff --git a/epan/dissectors/packet-h450.c b/epan/dissectors/packet-h450.c index f3818e2fe8..53225b102e 100644 --- a/epan/dissectors/packet-h450.c +++ b/epan/dissectors/packet-h450.c @@ -4727,7 +4727,7 @@ dissect_h450_arg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data hidden_item = proto_tree_add_uint(tree, hf_h450_operation, tvb, 0, 0, opcode); PROTO_ITEM_SET_HIDDEN(hidden_item); - p = match_strval(opcode, VALS(h450_str_operation)); + p = try_val_to_str(opcode, VALS(h450_str_operation)); if (p) { proto_item_append_text(rctx->d.code_item, " - %s", p); if (rctx->apdu_depth >= 0) @@ -4769,7 +4769,7 @@ dissect_h450_res(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data hidden_item = proto_tree_add_uint(tree, hf_h450_operation, tvb, 0, 0, opcode); PROTO_ITEM_SET_HIDDEN(hidden_item); - p = match_strval(opcode, VALS(h450_str_operation)); + p = try_val_to_str(opcode, VALS(h450_str_operation)); if (p) { proto_item_append_text(rctx->d.code_item, " - %s", p); if (rctx->apdu_depth >= 0) @@ -4811,7 +4811,7 @@ dissect_h450_err(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data hidden_item = proto_tree_add_uint(tree, hf_h450_error, tvb, 0, 0, errcode); PROTO_ITEM_SET_HIDDEN(hidden_item); - p = match_strval(errcode, VALS(h450_str_error)); + p = try_val_to_str(errcode, VALS(h450_str_error)); if (p) { proto_item_append_text(rctx->d.code_item, " - %s", p); if (rctx->apdu_depth >= 0) diff --git a/epan/dissectors/packet-h501.c b/epan/dissectors/packet-h501.c index 7d7a0d8dd6..3967cd237f 100644 --- a/epan/dissectors/packet-h501.c +++ b/epan/dissectors/packet-h501.c @@ -2365,7 +2365,7 @@ dissect_h501_MessageBody(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_ &msg_type); #line 25 "../../asn1/h501/h501.cnf" - p = match_strval(msg_type, VALS(h501_MessageBody_vals)); + p = try_val_to_str(msg_type, VALS(h501_MessageBody_vals)); if (p ) col_set_str(actx->pinfo->cinfo, COL_INFO, p); diff --git a/epan/dissectors/packet-iapp.c b/epan/dissectors/packet-iapp.c index d518c6a5d1..52e101b04c 100644 --- a/epan/dissectors/packet-iapp.c +++ b/epan/dissectors/packet-iapp.c @@ -185,7 +185,7 @@ static void dissect_caps(proto_item *pitem, tvbuff_t *tvb, int offset) for (bit = 7; bit >= 0; bit--) { thisbit = 1 << bit; - strval = match_strval(thisbit, iapp_cap_vals); + strval = try_val_to_str(thisbit, iapp_cap_vals); if (strval) { other_decode_bitfield_value(bitval, val, thisbit, 8); @@ -300,7 +300,7 @@ append_pduval_str(proto_item *ti, int type, int len, tvbuff_t *tvb, int offset, for (mask = 0x80; mask; mask >>= 1) if (val & mask) { - strval = match_strval(mask, iapp_cap_vals); + strval = try_val_to_str(mask, iapp_cap_vals); if (strval) { if (!first) diff --git a/epan/dissectors/packet-ieee80211.c b/epan/dissectors/packet-ieee80211.c index ba0e84a7c1..5f3be8e516 100644 --- a/epan/dissectors/packet-ieee80211.c +++ b/epan/dissectors/packet-ieee80211.c @@ -7435,7 +7435,7 @@ dissect_vendor_ie_wpawme(proto_tree *tree, tvbuff_t *tvb, int offset, guint32 ta proto_tree_add_item(aci_aifsn_tree, hf_ieee80211_wfa_ie_wme_acp_reserved, tvb, offset, 1, ENC_NA); aci_aifsn = tvb_get_guint8(tvb, offset); proto_item_append_text(ac_item, " ACI %u (%s), ACM %s, AIFSN %u", - (aci_aifsn & 0x60) >> 5, match_strval((aci_aifsn & 0x60) >> 5, ieee80211_wfa_ie_wme_acs_vals), + (aci_aifsn & 0x60) >> 5, try_val_to_str((aci_aifsn & 0x60) >> 5, ieee80211_wfa_ie_wme_acs_vals), (aci_aifsn & 0x10) ? "yes" : "no ", aci_aifsn & 0x0f); offset += 1; diff --git a/epan/dissectors/packet-image-jfif.c b/epan/dissectors/packet-image-jfif.c index a193f1c36f..8a2e577987 100644 --- a/epan/dissectors/packet-image-jfif.c +++ b/epan/dissectors/packet-image-jfif.c @@ -815,7 +815,7 @@ dissect_jfif(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_ "Fill bytes"); marker = tvb_get_ntohs(tvb, start_marker); - str = match_strval(marker, vals_marker); + str = try_val_to_str(marker, vals_marker); if (str) { /* Known marker */ if (marker_has_length(marker)) { /* Marker segment */ /* Length of marker segment = 2 + len */ diff --git a/epan/dissectors/packet-ip.c b/epan/dissectors/packet-ip.c index 5dcd28b033..30d6c31ac6 100644 --- a/epan/dissectors/packet-ip.c +++ b/epan/dissectors/packet-ip.c @@ -755,7 +755,7 @@ dissect_ipopt_security(const ip_tcp_opt *optp, tvbuff_t *tvb, int offset, /* Analyze payload start to decide whether it should be dissected according to RFC 791 or RFC 1108 */ val = tvb_get_ntohs(tvb, curr_offset); - if (match_strval(val, secl_rfc791_vals)) { + if (try_val_to_str(val, secl_rfc791_vals)) { /* Dissect as RFC 791 */ proto_tree_add_item(field_tree, hf_ip_opt_sec_rfc791_sec, tvb, curr_offset, 2, ENC_BIG_ENDIAN); diff --git a/epan/dissectors/packet-ipmi.c b/epan/dissectors/packet-ipmi.c index 0da71f0c1a..4d2acdea1c 100644 --- a/epan/dissectors/packet-ipmi.c +++ b/epan/dissectors/packet-ipmi.c @@ -1040,7 +1040,7 @@ ipmi_get_completion_code(guint8 completion, ipmi_cmd_t *cmd) } if (completion >= 0x80 && completion <= 0xbe) { - if (cmd && cmd->cs_cc && (res = match_strval(completion, cmd->cs_cc)) != NULL) { + if (cmd && cmd->cs_cc && (res = try_val_to_str(completion, cmd->cs_cc)) != NULL) { return res; } return "Standard command-specific code"; diff --git a/epan/dissectors/packet-ipsec.c b/epan/dissectors/packet-ipsec.c index 12584b38cd..8454c7898e 100644 --- a/epan/dissectors/packet-ipsec.c +++ b/epan/dissectors/packet-ipsec.c @@ -1967,7 +1967,7 @@ dissect_ipcomp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) tvb_memcpy(tvb, (guint8 *)&ipcomp, 0, sizeof(ipcomp)); if (check_col(pinfo->cinfo, COL_INFO)) { - p = match_strval(g_ntohs(ipcomp.comp_cpi), cpi2val); + p = try_val_to_str(g_ntohs(ipcomp.comp_cpi), cpi2val); if (p == NULL) { col_add_fstr(pinfo->cinfo, COL_INFO, "IPComp (CPI=0x%04x)", g_ntohs(ipcomp.comp_cpi)); diff --git a/epan/dissectors/packet-ipx.c b/epan/dissectors/packet-ipx.c index 028caa24c5..3a8936d38a 100644 --- a/epan/dissectors/packet-ipx.c +++ b/epan/dissectors/packet-ipx.c @@ -538,7 +538,7 @@ spx_conn_ctrl(guint8 ctrl) { 0x00, NULL } }; - p = match_strval((ctrl & 0xf0), conn_vals ); + p = try_val_to_str((ctrl & 0xf0), conn_vals ); if (p) { return p; diff --git a/epan/dissectors/packet-iscsi.c b/epan/dissectors/packet-iscsi.c index a03ac41a15..dfb287672a 100644 --- a/epan/dissectors/packet-iscsi.c +++ b/epan/dissectors/packet-iscsi.c @@ -1502,7 +1502,7 @@ dissect_iscsi_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint off offset = handleHeaderDigest(iscsi_session, ti, tvb, offset, 48); next_opcode = tvb_get_guint8(tvb, offset) & 0x3f; - next_opcode_str = match_strval(next_opcode, iscsi_opcodes); + next_opcode_str = try_val_to_str(next_opcode, iscsi_opcodes); tf = proto_tree_add_text(ti, tvb, offset, -1, "Rejected Header"); tt = proto_item_add_subtree(tf, ett_iscsi_RejectHeader); @@ -1850,7 +1850,7 @@ dissect_iscsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean chec return FALSE; } /* Function must be known */ - if(!match_strval(tmpbyte&0x7f, iscsi_task_management_functions)){ + if(!try_val_to_str(tmpbyte&0x7f, iscsi_task_management_functions)){ return FALSE; } /* bytes 2,3 must be null */ @@ -1904,7 +1904,7 @@ dissect_iscsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean chec return FALSE; } /* Reason code must be known */ - if(!match_strval(tmpbyte&0x7f, iscsi_logout_reasons)){ + if(!try_val_to_str(tmpbyte&0x7f, iscsi_logout_reasons)){ return FALSE; } /* bytes 2,3 must be null */ @@ -1935,7 +1935,7 @@ dissect_iscsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean chec return FALSE; } /* type must be known */ - if(!match_strval(tmpbyte&0x0f, iscsi_snack_types)){ + if(!try_val_to_str(tmpbyte&0x0f, iscsi_snack_types)){ return FALSE; } /* for status/snack and datack itt must be 0xffffffff @@ -2003,7 +2003,7 @@ dissect_iscsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean chec return FALSE; } /* reason must be known */ - if(!match_strval(tvb_get_guint8(tvb,offset+2), iscsi_reject_reasons)){ + if(!try_val_to_str(tvb_get_guint8(tvb,offset+2), iscsi_reject_reasons)){ return FALSE; } /* byte 3 must be 0 */ @@ -2119,7 +2119,7 @@ dissect_iscsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean chec return FALSE; } /* status must be known */ - if(!match_strval(tvb_get_guint8(tvb,offset+3), scsi_status_val)){ + if(!try_val_to_str(tvb_get_guint8(tvb,offset+3), scsi_status_val)){ return FALSE; } /* the 32bit words at offsets 8, 12 @@ -2165,7 +2165,7 @@ dissect_iscsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean chec return FALSE; } /* response must be known */ - if(!match_strval(tvb_get_guint8(tvb,offset+2), iscsi_logout_response)){ + if(!try_val_to_str(tvb_get_guint8(tvb,offset+2), iscsi_logout_response)){ return FALSE; } /* byte 3 must be 0 */ @@ -2245,7 +2245,7 @@ dissect_iscsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean chec opcode = tvb_get_guint8(tvb, offset + 0); opcode &= OPCODE_MASK; - opcode_str = match_strval(opcode, iscsi_opcodes); + opcode_str = try_val_to_str(opcode, iscsi_opcodes); if(opcode == ISCSI_OPCODE_TASK_MANAGEMENT_FUNCTION || opcode == ISCSI_OPCODE_TASK_MANAGEMENT_FUNCTION_RESPONSE || opcode == ISCSI_OPCODE_R2T || diff --git a/epan/dissectors/packet-isdn-sup.c b/epan/dissectors/packet-isdn-sup.c index 4490fdf964..88fbe37000 100644 --- a/epan/dissectors/packet-isdn-sup.c +++ b/epan/dissectors/packet-isdn-sup.c @@ -2641,7 +2641,7 @@ dissect_isdn_sup_arg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void * isdn_sup_tree = proto_item_add_subtree(ti, ett_isdn_sup); proto_tree_add_uint(isdn_sup_tree, hf_isdn_sup_operation, tvb, 0, 0, opcode); - p = match_strval(opcode, VALS(isdn_sup_str_operation)); + p = try_val_to_str(opcode, VALS(isdn_sup_str_operation)); if (p) { proto_item_append_text(ti, ": %s", p); proto_item_append_text(rctx->d.code_item, " - %s", p); @@ -2687,7 +2687,7 @@ dissect_isdn_sup_res(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void * isdn_sup_tree = proto_item_add_subtree(ti, ett_isdn_sup); proto_tree_add_uint(isdn_sup_tree, hf_isdn_sup_operation, tvb, 0, 0, opcode); - p = match_strval(opcode, VALS(isdn_sup_str_operation)); + p = try_val_to_str(opcode, VALS(isdn_sup_str_operation)); if (p) { proto_item_append_text(ti, ": %s", p); proto_item_append_text(rctx->d.code_item, " - %s", p); @@ -2734,7 +2734,7 @@ dissect_isdn_sup_err(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void * isdn_sup_tree = proto_item_add_subtree(ti, ett_isdn_sup); proto_tree_add_uint(isdn_sup_tree, hf_isdn_sup_error, tvb, 0, 0, errcode); - p = match_strval(errcode, VALS(isdn_sup_str_error)); + p = try_val_to_str(errcode, VALS(isdn_sup_str_error)); if (p) { proto_item_append_text(ti, ": %s", p); proto_item_append_text(rctx->d.code_item, " - %s", p); diff --git a/epan/dissectors/packet-isns.c b/epan/dissectors/packet-isns.c index 78339eda68..5bc37b7ce5 100644 --- a/epan/dissectors/packet-isns.c +++ b/epan/dissectors/packet-isns.c @@ -720,7 +720,7 @@ dissect_isns_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data /* Get the function id from the packet */ function_id = tvb_get_ntohs(tvb, 2); - if (match_strval_ext(function_id, &isns_function_ids_ext) == NULL) { + if (try_val_to_str_ext(function_id, &isns_function_ids_ext) == NULL) { /* Unknown function ID */ return 0; } @@ -751,7 +751,7 @@ dissect_isns_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data /* Get the function id from the packet */ function_id = tvb_get_ntohs(tvb, 2); - if (match_strval_ext(function_id, &isns_function_ids_ext) == NULL) { + if (try_val_to_str_ext(function_id, &isns_function_ids_ext) == NULL) { /* Unknown function ID */ return 0; } diff --git a/epan/dissectors/packet-isup.c b/epan/dissectors/packet-isup.c index 81199eac97..32fafdc217 100644 --- a/epan/dissectors/packet-isup.c +++ b/epan/dissectors/packet-isup.c @@ -10832,7 +10832,7 @@ msg_stats_tree_init(stats_tree *st) static int msg_stats_tree_packet(stats_tree *st, packet_info *pinfo, epan_dissect_t *edt _U_, const void *p) { - const gchar *msg = match_strval_ext(((const isup_tap_rec_t*)p)->message_type, &isup_message_type_value_acro_ext); + const gchar *msg = try_val_to_str_ext(((const isup_tap_rec_t*)p)->message_type, &isup_message_type_value_acro_ext); gchar *dir; int msg_node; int dir_node; diff --git a/epan/dissectors/packet-kingfisher.c b/epan/dissectors/packet-kingfisher.c index 88829e4546..089ffb20a7 100644 --- a/epan/dissectors/packet-kingfisher.c +++ b/epan/dissectors/packet-kingfisher.c @@ -230,7 +230,7 @@ dissect_kingfisher(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean /* the function code must be known */ kfp->function = tvb_get_guint8( tvb, 6 ); - if (match_strval(kfp->function, function_code_vals) == NULL) { + if (try_val_to_str(kfp->function, function_code_vals) == NULL) { /* This appears not to be a kingfisher packet */ return FALSE; } diff --git a/epan/dissectors/packet-laplink.c b/epan/dissectors/packet-laplink.c index 86e36ea3c4..aa11be1767 100644 --- a/epan/dissectors/packet-laplink.c +++ b/epan/dissectors/packet-laplink.c @@ -86,7 +86,7 @@ dissect_laplink_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *d if (!tvb_bytes_exist(tvb, offset, 4)) return 0; /* not enough bytes to check */ udp_ident = tvb_get_ntohl(tvb, offset); - udp_ident_string = match_strval(udp_ident, laplink_udp_magic); + udp_ident_string = try_val_to_str(udp_ident, laplink_udp_magic); if (udp_ident_string == NULL) return 0; /* unknown */ diff --git a/epan/dissectors/packet-llrp.c b/epan/dissectors/packet-llrp.c index 55ca11e3d6..2fe872aaa6 100644 --- a/epan/dissectors/packet-llrp.c +++ b/epan/dissectors/packet-llrp.c @@ -2633,7 +2633,7 @@ dissect_llrp_packet(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_tree_add_item(llrp_tree, hf_llrp_id, tvb, offset, 4, ENC_BIG_ENDIAN); offset += 4; - if (match_strval_ext(type, &message_types_ext)) + if (try_val_to_str_ext(type, &message_types_ext)) dissect_llrp_message(tvb, pinfo, llrp_tree, type, offset); } diff --git a/epan/dissectors/packet-mac-lte.c b/epan/dissectors/packet-mac-lte.c index a1345bff26..3d9817301f 100644 --- a/epan/dissectors/packet-mac-lte.c +++ b/epan/dissectors/packet-mac-lte.c @@ -2934,7 +2934,7 @@ static void dissect_ulsch_or_dlsch(tvbuff_t *tvb, packet_info *pinfo, proto_tree /* Flag unknown lcid values in expert info */ - if (match_strval(lcids[number_of_headers], + if (try_val_to_str(lcids[number_of_headers], (direction == DIRECTION_UPLINK) ? ulsch_lcid_vals : dlsch_lcid_vals) == NULL) { expert_add_info_format(pinfo, pdu_subheader_ti, PI_MALFORMED, PI_ERROR, "%cL-SCH: Unexpected LCID received (%u)", @@ -3968,7 +3968,7 @@ static void dissect_mch(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, pro /* Flag unknown lcid values in expert info */ - if (match_strval(lcids[number_of_headers],mch_lcid_vals) == NULL) { + if (try_val_to_str(lcids[number_of_headers],mch_lcid_vals) == NULL) { expert_add_info_format(pinfo, pdu_subheader_ti, PI_MALFORMED, PI_ERROR, "MCH: Unexpected LCID received (%u)", lcids[number_of_headers]); diff --git a/epan/dissectors/packet-memcache.c b/epan/dissectors/packet-memcache.c index 08ef8413cd..adc8864634 100644 --- a/epan/dissectors/packet-memcache.c +++ b/epan/dissectors/packet-memcache.c @@ -530,7 +530,7 @@ dissect_memcache (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) ti = proto_tree_add_item (memcache_tree, hf_magic, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; - if (match_strval (magic, magic_vals) == NULL) { + if (try_val_to_str (magic, magic_vals) == NULL) { expert_add_info_format (pinfo, ti, PI_UNDECODED, PI_WARN, "Unknown magic byte: %d", magic); } @@ -538,7 +538,7 @@ dissect_memcache (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) ti = proto_tree_add_item (memcache_tree, hf_opcode, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; - if (match_strval (opcode, opcode_vals) == NULL) { + if (try_val_to_str (opcode, opcode_vals) == NULL) { expert_add_info_format (pinfo, ti, PI_UNDECODED, PI_WARN, "Unknown opcode: %d", opcode); } @@ -1915,7 +1915,7 @@ dissect_memcache_tcp (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) magic = tvb_get_guint8 (tvb, offset); - if (match_strval (magic, magic_vals) != NULL) { + if (try_val_to_str (magic, magic_vals) != NULL) { tcp_dissect_pdus (tvb, pinfo, tree, memcache_desegment_body, 12, get_memcache_pdu_len, dissect_memcache); } else { @@ -1932,7 +1932,7 @@ dissect_memcache_udp (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) magic = tvb_get_guint8 (tvb, offset); - if (match_strval (magic, magic_vals) != NULL) { + if (try_val_to_str (magic, magic_vals) != NULL) { dissect_memcache (tvb, pinfo, tree); } else { dissect_memcache_message (tvb, 0, pinfo, tree); diff --git a/epan/dissectors/packet-mms.c b/epan/dissectors/packet-mms.c index fe409b5b07..e129dd8d9c 100644 --- a/epan/dissectors/packet-mms.c +++ b/epan/dissectors/packet-mms.c @@ -10021,7 +10021,7 @@ dissect_mms_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, voi return FALSE; /* see if the tag is a valid MMS PDU */ - match_strval_idx(tmp_tag, mms_MMSpdu_vals, &idx); + try_val_to_str_idx(tmp_tag, mms_MMSpdu_vals, &idx); if (idx == -1) { return FALSE; /* no, it isn't an MMS PDU */ } diff --git a/epan/dissectors/packet-mmse.c b/epan/dissectors/packet-mmse.c index 2a235573bc..aacebaf1fa 100644 --- a/epan/dissectors/packet-mmse.c +++ b/epan/dissectors/packet-mmse.c @@ -642,7 +642,7 @@ dissect_mmse_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat if (tvb_get_guint8(tvb, 0) != MM_MTYPE_HDR) return FALSE; pdut = tvb_get_guint8(tvb, 1); - if (match_strval(pdut, vals_message_type) == NULL) + if (try_val_to_str(pdut, vals_message_type) == NULL) return FALSE; if ((tvb_get_guint8(tvb, 2) != MM_TID_HDR) && (tvb_get_guint8(tvb, 2) != MM_VERSION_HDR)) diff --git a/epan/dissectors/packet-mp4ves.c b/epan/dissectors/packet-mp4ves.c index 8d6972a7d4..8774863612 100644 --- a/epan/dissectors/packet-mp4ves.c +++ b/epan/dissectors/packet-mp4ves.c @@ -793,7 +793,7 @@ dissect_mp4ves_par_profile(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tr DISSECTOR_ASSERT(actx); lvl = tvb_get_ntohs(tvb, offset); - p = match_strval(lvl, VALS(mp4ves_level_indication_vals)); + p = try_val_to_str(lvl, VALS(mp4ves_level_indication_vals)); if (p) { proto_item_append_text(actx->created_item, " - profileAndLevel %s", p); } @@ -812,7 +812,7 @@ dissect_mp4ves_par_video_object_type(tvbuff_t *tvb, packet_info *pinfo _U_, prot DISSECTOR_ASSERT(actx); lvl = tvb_get_ntohs(tvb, offset); - p = match_strval(lvl, VALS(mp4ves_video_object_type_vals)); + p = try_val_to_str(lvl, VALS(mp4ves_video_object_type_vals)); if (p) { proto_item_append_text(actx->created_item, " - video_object_type %s", p); } diff --git a/epan/dissectors/packet-mpeg-descriptor.c b/epan/dissectors/packet-mpeg-descriptor.c index 72206637e0..94be11af1d 100644 --- a/epan/dissectors/packet-mpeg-descriptor.c +++ b/epan/dissectors/packet-mpeg-descriptor.c @@ -2529,7 +2529,7 @@ proto_mpeg_descriptor_dissect_private_ciplus(tvbuff_t *tvb, guint offset, proto_ offset_start=offset; tag = tvb_get_guint8(tvb, offset); - tag_str = match_strval(tag, mpeg_descriptor_ciplus_tag_vals); + tag_str = try_val_to_str(tag, mpeg_descriptor_ciplus_tag_vals); if (!tag_str) return 0; @@ -2768,7 +2768,7 @@ proto_mpeg_descriptor_loop_dissect(tvbuff_t *tvb, guint offset, guint loop_len, /* the default descriptor function takes precedence however, if it does not know the current descriptor, we search for a context-specific subfunction this subfunction gets to see the entire descriptor, including tag and len */ - if (match_strval(tag, mpeg_descriptor_tag_vals)) { + if (try_val_to_str(tag, mpeg_descriptor_tag_vals)) { desc_len = proto_mpeg_descriptor_dissect(tvb, offset, tree); } else { diff --git a/epan/dissectors/packet-mpeg-pes.c b/epan/dissectors/packet-mpeg-pes.c index af92a0de6e..93c97583d3 100644 --- a/epan/dissectors/packet-mpeg-pes.c +++ b/epan/dissectors/packet-mpeg-pes.c @@ -846,7 +846,7 @@ dissect_mpeg_pes(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data stream = tvb_get_guint8(tvb, 3); if (check_col(pinfo->cinfo, COL_INFO)) { - const char *s = match_strval(stream, mpeg_pes_T_stream_vals); + const char *s = try_val_to_str(stream, mpeg_pes_T_stream_vals); if (s != NULL) col_set_str(pinfo->cinfo, COL_INFO, s); } @@ -864,7 +864,7 @@ dissect_mpeg_pes(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data frame_type = tvb_get_guint8(tvb, 5) >> 3 & 0x07; if (check_col(pinfo->cinfo, COL_INFO)) { - const char *s = match_strval(frame_type, + const char *s = try_val_to_str(frame_type, mpeg_pes_T_frame_type_vals); if (s != NULL) col_set_str(pinfo->cinfo, COL_INFO, s); diff --git a/epan/dissectors/packet-ms-mms.c b/epan/dissectors/packet-ms-mms.c index 5b5a8ef015..62e737ad8d 100644 --- a/epan/dissectors/packet-ms-mms.c +++ b/epan/dissectors/packet-ms-mms.c @@ -651,7 +651,7 @@ static gint dissect_msmms_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tr /* Flag value is in 5th byte */ value = tvb_get_letohs(tvb, 4) & 0xff00; /* Reject packet if not a recognised packet type */ - if (match_strval(value, tcp_flags_vals) == NULL) + if (try_val_to_str(value, tcp_flags_vals) == NULL) { return 0; } diff --git a/epan/dissectors/packet-nas_eps.c b/epan/dissectors/packet-nas_eps.c index 3602ffd55c..725c65f20d 100644 --- a/epan/dissectors/packet-nas_eps.c +++ b/epan/dissectors/packet-nas_eps.c @@ -4577,7 +4577,7 @@ get_nas_esm_msg_params(guint8 oct, const gchar **msg_str, int *ett_tree, int *hf { gint idx; - *msg_str = match_strval_idx_ext((guint32) (oct & 0xff), &nas_msg_esm_strings_ext, &idx); + *msg_str = try_val_to_str_idx_ext((guint32) (oct & 0xff), &nas_msg_esm_strings_ext, &idx); *hf_idx = hf_nas_eps_msg_esm_type; if (*msg_str != NULL) { *ett_tree = ett_nas_msg_esm[idx]; @@ -4635,7 +4635,7 @@ get_nas_emm_msg_params(guint8 oct, const gchar **msg_str, int *ett_tree, int *hf { gint idx; - *msg_str = match_strval_idx_ext((guint32) (oct & 0xff), &nas_msg_emm_strings_ext, &idx); + *msg_str = try_val_to_str_idx_ext((guint32) (oct & 0xff), &nas_msg_emm_strings_ext, &idx); *hf_idx = hf_nas_eps_msg_emm_type; if (*msg_str != NULL) { *ett_tree = ett_nas_msg_emm[idx]; diff --git a/epan/dissectors/packet-nat-pmp.c b/epan/dissectors/packet-nat-pmp.c index 5bf59592c0..d45ef30eee 100644 --- a/epan/dissectors/packet-nat-pmp.c +++ b/epan/dissectors/packet-nat-pmp.c @@ -335,7 +335,7 @@ dissect_portcontrol_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gui } start_opcode_offset = offset; - if (match_strval(opcode, opcode_vals) != NULL) + if (try_val_to_str(opcode, opcode_vals) != NULL) { opcode_ti = proto_tree_add_text(pcp_tree, tvb, offset, 0, "%s", op_str); opcode_tree = proto_item_add_subtree (opcode_ti, ett_opcode); @@ -420,7 +420,7 @@ dissect_portcontrol_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gui /* Now see if there are any options for the supported opcodes */ if ((tvb_reported_length_remaining(tvb, offset) > 0) && - (match_strval(opcode, opcode_vals) != NULL)) + (try_val_to_str(opcode, opcode_vals) != NULL)) { start_option_offset = offset; option_ti = proto_tree_add_text(opcode_tree, tvb, offset, 0, "Options"); diff --git a/epan/dissectors/packet-ncp-nmas.c b/epan/dissectors/packet-ncp-nmas.c index e7e40c7a0e..8c5089b00f 100644 --- a/epan/dissectors/packet-ncp-nmas.c +++ b/epan/dissectors/packet-ncp-nmas.c @@ -594,7 +594,7 @@ dissect_nmas_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ncp_tree, guin break; case 7: encrypt_error = tvb_get_ntohl(tvb, foffset); - str = match_strval(encrypt_error, nmas_errors_enum); + str = try_val_to_str(encrypt_error, nmas_errors_enum); if (str) { col_add_fstr(pinfo->cinfo, COL_INFO, "R Payload Error - %s", str); @@ -618,7 +618,7 @@ dissect_nmas_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ncp_tree, guin break; } } - str = match_strval(return_code, nmas_errors_enum); + str = try_val_to_str(return_code, nmas_errors_enum); if (str) { expert_item = proto_tree_add_item(atree, hf_return_code, tvb, roffset, 4, ENC_LITTLE_ENDIAN); diff --git a/epan/dissectors/packet-ncp-sss.c b/epan/dissectors/packet-ncp-sss.c index 1a7436bc66..85227ec5b7 100644 --- a/epan/dissectors/packet-ncp-sss.c +++ b/epan/dissectors/packet-ncp-sss.c @@ -697,7 +697,7 @@ dissect_sss_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ncp_tree, guint case 2: if (request_value) { subverb = request_value->req_nds_flags; - str = match_strval(subverb, sss_verb_enum); + str = try_val_to_str(subverb, sss_verb_enum); if (str) { proto_tree_add_text(atree, tvb, foffset, tvb_length_remaining(tvb, foffset), "Verb: %s", str); } @@ -713,7 +713,7 @@ dissect_sss_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ncp_tree, guint { foffset += 4; return_code = tvb_get_letohl(tvb, foffset); - str = match_strval(return_code, sss_errors_enum); + str = try_val_to_str(return_code, sss_errors_enum); if (str) { expert_item = proto_tree_add_item(atree, hf_return_code, tvb, foffset, 4, ENC_LITTLE_ENDIAN); diff --git a/epan/dissectors/packet-ncp.c b/epan/dissectors/packet-ncp.c index d1b4240ca3..9f77a3fc8d 100644 --- a/epan/dissectors/packet-ncp.c +++ b/epan/dissectors/packet-ncp.c @@ -349,9 +349,9 @@ dissect_ncp_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, commhdr += 4; } /* Check to see if this is a valid offset, otherwise increment for packet signature */ - if (match_strval(tvb_get_ntohs(tvb, commhdr), ncp_type_vals)==NULL) { + if (try_val_to_str(tvb_get_ntohs(tvb, commhdr), ncp_type_vals)==NULL) { /* Check to see if we have a valid type after packet signature length */ - if (match_strval(tvb_get_ntohs(tvb, commhdr+8), ncp_type_vals)!=NULL) { + if (try_val_to_str(tvb_get_ntohs(tvb, commhdr+8), ncp_type_vals)!=NULL) { proto_tree_add_item(ncp_tree, hf_ncp_ip_packetsig, tvb, commhdr, 8, ENC_NA); commhdr += 8; } diff --git a/epan/dissectors/packet-ndps.c b/epan/dissectors/packet-ndps.c index 5383d422e2..070c38ee2b 100644 --- a/epan/dissectors/packet-ndps.c +++ b/epan/dissectors/packet-ndps.c @@ -2064,7 +2064,7 @@ objectidentifier(tvbuff_t* tvb, proto_tree *ndps_tree, int foffset) { case 9: label_value = tvb_get_ntohl(tvb, foffset+5); - label = match_strval(label_value, object_ids_7); + label = try_val_to_str(label_value, object_ids_7); if (label==NULL) { aitem = proto_tree_add_text(ndps_tree, tvb, foffset, length, "Unknown ID"); @@ -2075,7 +2075,7 @@ objectidentifier(tvbuff_t* tvb, proto_tree *ndps_tree, int foffset) break; case 10: label_value = tvb_get_ntohl(tvb, foffset+6); - label = match_strval(label_value, object_ids_8); + label = try_val_to_str(label_value, object_ids_8); if (label==NULL) { aitem = proto_tree_add_text(ndps_tree, tvb, foffset, length, "Unknown ID"); @@ -2086,7 +2086,7 @@ objectidentifier(tvbuff_t* tvb, proto_tree *ndps_tree, int foffset) break; case 11: label_value = tvb_get_ntohl(tvb, foffset+7); - label = match_strval(label_value, object_ids_9); + label = try_val_to_str(label_value, object_ids_9); if (label==NULL) { aitem = proto_tree_add_text(ndps_tree, tvb, foffset, length, "Unknown ID"); @@ -2097,7 +2097,7 @@ objectidentifier(tvbuff_t* tvb, proto_tree *ndps_tree, int foffset) break; case 12: label_value = tvb_get_ntohl(tvb, foffset+8); - label = match_strval(label_value, object_ids_10); + label = try_val_to_str(label_value, object_ids_10); if (label==NULL) { aitem = proto_tree_add_text(ndps_tree, tvb, foffset, length, "Unknown ID"); @@ -2108,7 +2108,7 @@ objectidentifier(tvbuff_t* tvb, proto_tree *ndps_tree, int foffset) break; case 13: label_value = tvb_get_ntohl(tvb, foffset+9); - label = match_strval(label_value, object_ids_11); + label = try_val_to_str(label_value, object_ids_11); if (label==NULL) { aitem = proto_tree_add_text(ndps_tree, tvb, foffset, length, "Unknown ID"); @@ -2119,7 +2119,7 @@ objectidentifier(tvbuff_t* tvb, proto_tree *ndps_tree, int foffset) break; case 14: label_value = tvb_get_ntohl(tvb, foffset+10); - label = match_strval(label_value, object_ids_12); + label = try_val_to_str(label_value, object_ids_12); if (label==NULL) { aitem = proto_tree_add_text(ndps_tree, tvb, foffset, length, "Unknown ID"); @@ -2130,7 +2130,7 @@ objectidentifier(tvbuff_t* tvb, proto_tree *ndps_tree, int foffset) break; case 15: label_value = tvb_get_ntohl(tvb, foffset+11); - label = match_strval(label_value, object_ids_13); + label = try_val_to_str(label_value, object_ids_13); if (label==NULL) { aitem = proto_tree_add_text(ndps_tree, tvb, foffset, length, "Unknown ID"); @@ -2141,7 +2141,7 @@ objectidentifier(tvbuff_t* tvb, proto_tree *ndps_tree, int foffset) break; case 16: label_value = tvb_get_ntohl(tvb, foffset+12); - label = match_strval(label_value, object_ids_14); + label = try_val_to_str(label_value, object_ids_14); if (label==NULL) { aitem = proto_tree_add_text(ndps_tree, tvb, foffset, length, "Unknown ID"); @@ -2152,7 +2152,7 @@ objectidentifier(tvbuff_t* tvb, proto_tree *ndps_tree, int foffset) break; case 17: label_value = tvb_get_ntohl(tvb, foffset+13); - label = match_strval(label_value, object_ids_15); + label = try_val_to_str(label_value, object_ids_15); if (label==NULL) { aitem = proto_tree_add_text(ndps_tree, tvb, foffset, length, "Unknown ID"); @@ -2163,7 +2163,7 @@ objectidentifier(tvbuff_t* tvb, proto_tree *ndps_tree, int foffset) break; case 18: label_value = tvb_get_ntohl(tvb, foffset+14); - label = match_strval(label_value, object_ids_16); + label = try_val_to_str(label_value, object_ids_16); if (label==NULL) { aitem = proto_tree_add_text(ndps_tree, tvb, foffset, length, "Unknown ID"); @@ -2180,7 +2180,7 @@ objectidentifier(tvbuff_t* tvb, proto_tree *ndps_tree, int foffset) if (!found) { label_value = 1; - label = match_strval(label_value, object_ids_7); + label = try_val_to_str(label_value, object_ids_7); } if (ndps_show_oids) { @@ -2705,7 +2705,7 @@ attribute_value(tvbuff_t* tvb, proto_tree *ndps_tree, int foffset) if (global_attribute_name==NULL) { label_value = 1; - label = match_strval(label_value, object_ids_7); + label = try_val_to_str(label_value, object_ids_7); global_attribute_name = label; } attribute_type = tvb_get_ntohl(tvb, foffset); @@ -4222,7 +4222,7 @@ dissect_ndps(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ndps_tree) proto_tree_add_item(ndps_tree, hf_ndps_rpc_version, tvb, foffset, 4, ENC_BIG_ENDIAN); foffset += 4; ndps_prog = tvb_get_ntohl(tvb, foffset); - ndps_program_string = match_strval(ndps_prog, spx_ndps_program_vals); + ndps_program_string = try_val_to_str(ndps_prog, spx_ndps_program_vals); if( ndps_program_string != NULL) { proto_tree_add_item(ndps_tree, hf_spx_ndps_program, tvb, foffset, 4, ENC_BIG_ENDIAN); @@ -4239,27 +4239,27 @@ dissect_ndps(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ndps_tree) { case 0x060976: ndps_hfname = hf_spx_ndps_func_print; - ndps_func_string = match_strval(ndps_func, spx_ndps_print_func_vals); + ndps_func_string = try_val_to_str(ndps_func, spx_ndps_print_func_vals); break; case 0x060977: ndps_hfname = hf_spx_ndps_func_broker; - ndps_func_string = match_strval(ndps_func, spx_ndps_broker_func_vals); + ndps_func_string = try_val_to_str(ndps_func, spx_ndps_broker_func_vals); break; case 0x060978: ndps_hfname = hf_spx_ndps_func_registry; - ndps_func_string = match_strval(ndps_func, spx_ndps_registry_func_vals); + ndps_func_string = try_val_to_str(ndps_func, spx_ndps_registry_func_vals); break; case 0x060979: ndps_hfname = hf_spx_ndps_func_notify; - ndps_func_string = match_strval(ndps_func, spx_ndps_notify_func_vals); + ndps_func_string = try_val_to_str(ndps_func, spx_ndps_notify_func_vals); break; case 0x06097a: ndps_hfname = hf_spx_ndps_func_resman; - ndps_func_string = match_strval(ndps_func, spx_ndps_resman_func_vals); + ndps_func_string = try_val_to_str(ndps_func, spx_ndps_resman_func_vals); break; case 0x06097b: ndps_hfname = hf_spx_ndps_func_delivery; - ndps_func_string = match_strval(ndps_func, spx_ndps_deliver_func_vals); + ndps_func_string = try_val_to_str(ndps_func, spx_ndps_deliver_func_vals); break; default: ndps_hfname = 0; @@ -7028,7 +7028,7 @@ dissect_ndps_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ndps_tree, int proto_tree_add_uint(ndps_tree, hf_ndps_error_val, tvb, foffset, 4, error_val); foffset += 4; /* Some functions return an error with no data, 0 is ok */ - if (match_strval(tvb_get_ntohl(tvb, foffset), ndps_error_types) && tvb_length_remaining(tvb,foffset) < 8 && (tvb_get_ntohl(tvb, foffset)!=0)) + if (try_val_to_str(tvb_get_ntohl(tvb, foffset), ndps_error_types) && tvb_length_remaining(tvb,foffset) < 8 && (tvb_get_ntohl(tvb, foffset)!=0)) { expert_status = tvb_get_ntohl(tvb, foffset); expert_item = proto_tree_add_item(ndps_tree, hf_ndps_return_code, tvb, foffset, 4, ENC_BIG_ENDIAN); diff --git a/epan/dissectors/packet-oicq.c b/epan/dissectors/packet-oicq.c index b53f40bfa5..8ce426e472 100644 --- a/epan/dissectors/packet-oicq.c +++ b/epan/dissectors/packet-oicq.c @@ -122,8 +122,8 @@ dissect_oicq(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_ /* heuristic: OICQ iff (([0] == STX) && ([3/4] == ) ) */ /* (Supposedly each OICQ message ends with an ETX so a test for */ /* same could also be part of the heuristic). */ - if ( (match_strval(tvb_get_guint8(tvb, 0), oicq_flag_vals) == NULL) || - (match_strval(tvb_get_ntohs(tvb, 3), oicq_command_vals) == NULL) ) + if ( (try_val_to_str(tvb_get_guint8(tvb, 0), oicq_flag_vals) == NULL) || + (try_val_to_str(tvb_get_ntohs(tvb, 3), oicq_command_vals) == NULL) ) return 0; col_set_str(pinfo->cinfo, COL_PROTOCOL, "OICQ"); diff --git a/epan/dissectors/packet-omron-fins.c b/epan/dissectors/packet-omron-fins.c index cceed2747f..1864529920 100644 --- a/epan/dissectors/packet-omron-fins.c +++ b/epan/dissectors/packet-omron-fins.c @@ -1117,7 +1117,7 @@ dissect_omron_fins(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *da col_set_str(pinfo->cinfo, COL_PROTOCOL, "OMRON"); - cmd_str = match_strval_idx(command_code, command_code_cv, &cmd_str_idx); + cmd_str = try_val_to_str_idx(command_code, command_code_cv, &cmd_str_idx); if (cmd_str_idx == -1) cmd_str = ep_strdup_printf("Unknown (%d)", command_code); diff --git a/epan/dissectors/packet-pw-atm.c b/epan/dissectors/packet-pw-atm.c index 3d53dfe062..eb3ffb1473 100644 --- a/epan/dissectors/packet-pw-atm.c +++ b/epan/dissectors/packet-pw-atm.c @@ -1504,7 +1504,7 @@ dissect_cell_header(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void proto_tree_add_uint(tree2, hf_cell_h_vci, tvb, 1, 3, (unsigned)pd->vci); item2 = proto_tree_add_item(tree2, hf_cell_h_pti, tvb, 3, 1, ENC_BIG_ENDIAN); - if (NULL == match_strval(pd->pti, atm_pt_vals)) + if (NULL == try_val_to_str(pd->pti, atm_pt_vals)) { expert_add_info_format(pinfo, item2, PI_UNDECODED, PI_WARN, "Unknown value of PTI field (%d) in the ATM cell header", @@ -1568,7 +1568,7 @@ dissect_cell_header(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void if (MODE_11(pd->mode)) { item2 = proto_tree_add_item(tree2, hf_cell_h_pti, tvb, 0, 1, ENC_BIG_ENDIAN); - if (NULL == match_strval(pd->pti, atm_pt_vals)) + if (NULL == try_val_to_str(pd->pti, atm_pt_vals)) { expert_add_info_format(pinfo, item2, PI_UNDECODED, PI_WARN, "Unknown value of PTI field (%d) in the atm-specific byte" diff --git a/epan/dissectors/packet-pw-cesopsn.c b/epan/dissectors/packet-pw-cesopsn.c index c5207df07d..c5f7218465 100644 --- a/epan/dissectors/packet-pw-cesopsn.c +++ b/epan/dissectors/packet-pw-cesopsn.c @@ -191,7 +191,7 @@ void dissect_pw_cesopsn( tvbuff_t * tvb_original { guint8 cw_lm; cw_lm = tvb_get_guint8(tvb_original, 0) & 0x0b /*l+mod*/; - if (NULL == match_strval(cw_lm, vals_cw_lm)) + if (NULL == try_val_to_str(cw_lm, vals_cw_lm)) { properties |= PWC_CW_SUSPECT_LM; } diff --git a/epan/dissectors/packet-qsig.c b/epan/dissectors/packet-qsig.c index 1d741b7207..b9fee968e1 100644 --- a/epan/dissectors/packet-qsig.c +++ b/epan/dissectors/packet-qsig.c @@ -12411,7 +12411,7 @@ dissect_qsig_arg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data qsig_tree = proto_item_add_subtree(ti, ett_qsig); proto_tree_add_uint(qsig_tree, hf_qsig_operation, tvb, 0, 0, opcode); - p = match_strval(opcode, VALS(qsig_str_operation)); + p = try_val_to_str(opcode, VALS(qsig_str_operation)); if (p) { proto_item_append_text(ti, ": %s", p); proto_item_append_text(rctx->d.code_item, " - %s", p); @@ -12420,7 +12420,7 @@ dissect_qsig_arg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data } ti_tmp = proto_tree_add_uint(qsig_tree, hf_qsig_service, tvb, 0, 0, service); - p = match_strval(service, VALS(qsig_str_service_name)); + p = try_val_to_str(service, VALS(qsig_str_service_name)); if (p) proto_item_append_text(ti_tmp, " - %s", p); if (op_ptr->arg_pdu) @@ -12462,7 +12462,7 @@ dissect_qsig_res(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data qsig_tree = proto_item_add_subtree(ti, ett_qsig); proto_tree_add_uint(qsig_tree, hf_qsig_operation, tvb, 0, 0, opcode); - p = match_strval(opcode, VALS(qsig_str_operation)); + p = try_val_to_str(opcode, VALS(qsig_str_operation)); if (p) { proto_item_append_text(ti, ": %s", p); proto_item_append_text(rctx->d.code_item, " - %s", p); @@ -12471,7 +12471,7 @@ dissect_qsig_res(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data } ti_tmp = proto_tree_add_uint(qsig_tree, hf_qsig_service, tvb, 0, 0, service); - p = match_strval(service, VALS(qsig_str_service_name)); + p = try_val_to_str(service, VALS(qsig_str_service_name)); if (p) proto_item_append_text(ti_tmp, " - %s", p); if (op_ptr->res_pdu) @@ -12512,7 +12512,7 @@ dissect_qsig_err(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data qsig_tree = proto_item_add_subtree(ti, ett_qsig); proto_tree_add_uint(qsig_tree, hf_qsig_error, tvb, 0, 0, errcode); - p = match_strval(errcode, VALS(qsig_str_error)); + p = try_val_to_str(errcode, VALS(qsig_str_error)); if (p) { proto_item_append_text(ti, ": %s", p); proto_item_append_text(rctx->d.code_item, " - %s", p); diff --git a/epan/dissectors/packet-radius.c b/epan/dissectors/packet-radius.c index de11a63782..7e3502a279 100644 --- a/epan/dissectors/packet-radius.c +++ b/epan/dissectors/packet-radius.c @@ -1316,7 +1316,7 @@ is_radius(tvbuff_t *tvb) guint16 length; code=tvb_get_guint8(tvb, 0); - if (match_strval_ext(code, &radius_pkt_type_codes_ext) == NULL) { + if (try_val_to_str_ext(code, &radius_pkt_type_codes_ext) == NULL) { return FALSE; } diff --git a/epan/dissectors/packet-rmcp.c b/epan/dissectors/packet-rmcp.c index eb1cf2fa6e..20e28c854d 100644 --- a/epan/dissectors/packet-rmcp.c +++ b/epan/dissectors/packet-rmcp.c @@ -105,7 +105,7 @@ dissect_rmcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_ type = (rmcp_class & RMCP_TYPE_MASK) >> 7; rmcp_class &= RMCP_CLASS_MASK; - class_str = match_strval(rmcp_class, rmcp_class_vals); + class_str = try_val_to_str(rmcp_class, rmcp_class_vals); if (class_str == NULL) return 0; /* unknown class value */ diff --git a/epan/dissectors/packet-rpcap.c b/epan/dissectors/packet-rpcap.c index 7888f2829a..4f4f248a51 100644 --- a/epan/dissectors/packet-rpcap.c +++ b/epan/dissectors/packet-rpcap.c @@ -1020,7 +1020,7 @@ check_rpcap_heur (tvbuff_t *tvb, gboolean tcp) /* UDP is only used for packets */ return FALSE; } - if (match_strval(msg_type, message_type) == NULL) + if (try_val_to_str(msg_type, message_type) == NULL) /* Unknown message type */ return FALSE; offset++; @@ -1029,7 +1029,7 @@ check_rpcap_heur (tvbuff_t *tvb, gboolean tcp) if (msg_value > 0) { if (msg_type == RPCAP_MSG_ERROR) { /* Must have a valid error code */ - if (match_strval(msg_value, error_codes) == NULL) + if (try_val_to_str(msg_value, error_codes) == NULL) return FALSE; } else if (msg_type != RPCAP_MSG_FINDALLIF_REPLY) { return FALSE; diff --git a/epan/dissectors/packet-rsvp.c b/epan/dissectors/packet-rsvp.c index 00e9fe7ce2..9611741039 100644 --- a/epan/dissectors/packet-rsvp.c +++ b/epan/dissectors/packet-rsvp.c @@ -3571,7 +3571,7 @@ dissect_rsvp_adspec(proto_item *ti, proto_tree *rsvp_object_tree, id = tvb_get_guint8(tvb, offset2); phdr_length = tvb_get_ntohs(tvb, offset2+2); - str = match_strval_ext(id, &adspec_params_ext); + str = try_val_to_str_ext(id, &adspec_params_ext); if (str) { switch(id) { case 4: diff --git a/epan/dissectors/packet-rtmpt.c b/epan/dissectors/packet-rtmpt.c index 74ab442241..6f9ea74d4d 100644 --- a/epan/dissectors/packet-rtmpt.c +++ b/epan/dissectors/packet-rtmpt.c @@ -724,7 +724,7 @@ rtmpt_get_packet_desc(tvbuff_t *tvb, guint32 offset, guint32 remain, rtmpt_conv_ if (tp->len<2 || remain<2) return NULL; iUCM = tvb_get_ntohs(tvb, offset); - sFunc = match_strval(iUCM, rtmpt_ucm_vals); + sFunc = try_val_to_str(iUCM, rtmpt_ucm_vals); if (sFunc==NULL) { *deschasopcode = TRUE; sFunc = ep_strdup_printf("User Control Message 0x%01x", iUCM); diff --git a/epan/dissectors/packet-rtnet.c b/epan/dissectors/packet-rtnet.c index f6d96e9a39..84fcf2aa6b 100644 --- a/epan/dissectors/packet-rtnet.c +++ b/epan/dissectors/packet-rtnet.c @@ -568,7 +568,7 @@ dissect_rtmac(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { flags = tvb_get_guint8(tvb, offset+3); if (ver == 1) { - type_str = match_strval(type, rtmac_type_vals); + type_str = try_val_to_str(type, rtmac_type_vals); if (!type_str) { dissector = dissector_get_uint_handle(ethertype_table, type); } diff --git a/epan/dissectors/packet-rtps.c b/epan/dissectors/packet-rtps.c index 9f6cd93e2d..16bc0690a6 100644 --- a/epan/dissectors/packet-rtps.c +++ b/epan/dissectors/packet-rtps.c @@ -861,7 +861,7 @@ int rtps_util_add_entity_id(proto_tree *tree, tvbuff_t * tvb, gint offset, guint32 entity_id = tvb_get_ntohl(tvb, offset); guint32 entity_key = (entity_id >> 8); guint8 entity_kind = (entity_id & 0xff); - const char *str_predef = match_strval(entity_id, entity_id_vals); + const char *str_predef = try_val_to_str(entity_id, entity_id_vals); if (entity_id_out != NULL) { *entity_id_out = entity_id; @@ -916,7 +916,7 @@ void rtps_util_add_generic_entity_id(proto_tree *tree, guint32 entity_id = tvb_get_ntohl(tvb, offset); guint32 entity_key = (entity_id >> 8); guint8 entity_kind = (entity_id & 0xff); - const char *str_predef = match_strval(entity_id, entity_id_vals); + const char *str_predef = try_val_to_str(entity_id, entity_id_vals); guint8 temp_buffer[MAX_GUID_SIZE]; if (str_predef == NULL) { diff --git a/epan/dissectors/packet-sccp.c b/epan/dissectors/packet-sccp.c index 1ec7aeed5b..7d4cb73d20 100644 --- a/epan/dissectors/packet-sccp.c +++ b/epan/dissectors/packet-sccp.c @@ -909,7 +909,7 @@ looks_like_valid_sccp(guint32 frame_num _U_, tvbuff_t *tvb, guint8 my_mtp3_stand RETURN_FALSE; msgtype = tvb_get_guint8(tvb, SCCP_MSG_TYPE_OFFSET); - if (!match_strval(msgtype, sccp_message_type_acro_values)) { + if (!try_val_to_str(msgtype, sccp_message_type_acro_values)) { RETURN_FALSE; } offset = SCCP_MSG_TYPE_LENGTH; @@ -963,7 +963,7 @@ looks_like_valid_sccp(guint32 frame_num _U_, tvbuff_t *tvb, guint8 my_mtp3_stand msgtype == SCCP_MSG_TYPE_LUDTS) { cause = tvb_get_guint8(tvb, offset); - if (!match_strval(cause, sccp_return_cause_values)) + if (!try_val_to_str(cause, sccp_return_cause_values)) RETURN_FALSE; offset += RETURN_CAUSE_LENGTH; } @@ -1088,7 +1088,7 @@ looks_like_valid_sccp(guint32 frame_num _U_, tvbuff_t *tvb, guint8 my_mtp3_stand offset += DESTINATION_LOCAL_REFERENCE_LENGTH; cause = tvb_get_guint8(tvb, offset); - if (!match_strval(cause, sccp_refusal_cause_values)) + if (!try_val_to_str(cause, sccp_refusal_cause_values)) RETURN_FALSE; offset += REFUSAL_CAUSE_LENGTH; @@ -1122,7 +1122,7 @@ looks_like_valid_sccp(guint32 frame_num _U_, tvbuff_t *tvb, guint8 my_mtp3_stand offset += SOURCE_LOCAL_REFERENCE_LENGTH; cause = tvb_get_guint8(tvb, offset); - if (!match_strval(cause, sccp_release_cause_values)) + if (!try_val_to_str(cause, sccp_release_cause_values)) RETURN_FALSE; offset += RELEASE_CAUSE_LENGTH; @@ -1161,7 +1161,7 @@ looks_like_valid_sccp(guint32 frame_num _U_, tvbuff_t *tvb, guint8 my_mtp3_stand offset += DESTINATION_LOCAL_REFERENCE_LENGTH; cause = tvb_get_guint8(tvb, offset); - if (!match_strval(cause, sccp_error_cause_values)) + if (!try_val_to_str(cause, sccp_error_cause_values)) RETURN_FALSE; } break; @@ -1264,7 +1264,7 @@ looks_like_valid_sccp(guint32 frame_num _U_, tvbuff_t *tvb, guint8 my_mtp3_stand opt_param = tvb_get_guint8(tvb, opt_ptr); /* Check if the (1st) optional parameter tag is valid */ - if (!match_strval(opt_param, sccp_parameter_values)) + if (!try_val_to_str(opt_param, sccp_parameter_values)) RETURN_FALSE; /* Check that the (1st) parameter length is within bounds */ @@ -2069,7 +2069,7 @@ dissect_sccp_class_param(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gu pi = proto_tree_add_item(tree, hf_sccp_handling, tvb, 0, length, ENC_NA); handling >>= CLASS_SPARE_HANDLING_SHIFT; - if (match_strval(handling, sccp_class_handling_values) == NULL) { + if (try_val_to_str(handling, sccp_class_handling_values) == NULL) { expert_add_info_format(pinfo, pi, PI_MALFORMED, PI_ERROR, "Invalid message handling"); } } diff --git a/epan/dissectors/packet-scsi.c b/epan/dissectors/packet-scsi.c index ed38aa76ad..66ad5dd696 100644 --- a/epan/dissectors/packet-scsi.c +++ b/epan/dissectors/packet-scsi.c @@ -3511,7 +3511,7 @@ dissect_scsi_modepage(tvbuff_t *tvb, packet_info *pinfo, plen = tvb_get_guint8(tvb, offset + 1); } - if (match_strval(pcode & SCSI_MS_PCODE_BITS, + if (try_val_to_str(pcode & SCSI_MS_PCODE_BITS, scsi_spc_modepage_val) == NULL) { /* * This isn't a generic mode page that applies to all SCSI @@ -3546,7 +3546,7 @@ dissect_scsi_modepage(tvbuff_t *tvb, packet_info *pinfo, default: /* * The "val_to_str()" lookup will fail in this table - * (it failed in "match_strval()"), so it'll return + * (it failed in "try_val_to_str()"), so it'll return * "Unknown (XXX)", which is what we want. */ modepage_val = scsi_spc_modepage_val; @@ -3798,7 +3798,7 @@ dissect_scsi_pagecode(tvbuff_t *tvb, packet_info *pinfo _U_, return; pcode = tvb_get_guint8(tvb, offset); - if (match_strval(pcode & SCSI_MS_PCODE_BITS, + if (try_val_to_str(pcode & SCSI_MS_PCODE_BITS, scsi_spc_modepage_val) == NULL) { /* * This isn't a generic mode page that applies to all SCSI @@ -4871,8 +4871,8 @@ dissect_scsi_cdb(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, } #endif - if ((valstr = match_strval(opcode, scsi_spc_vals)) == NULL) { - valstr = match_strval(opcode, csdata->cdb_vals); + if ((valstr = try_val_to_str(opcode, scsi_spc_vals)) == NULL) { + valstr = try_val_to_str(opcode, csdata->cdb_vals); } if (check_col(pinfo->cinfo, COL_INFO)) { diff --git a/epan/dissectors/packet-ses.c b/epan/dissectors/packet-ses.c index 71239e2947..c0f85d6330 100644 --- a/epan/dissectors/packet-ses.c +++ b/epan/dissectors/packet-ses.c @@ -1962,7 +1962,7 @@ dissect_ses_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, voi /* get SPDU type */ type = tvb_get_guint8(tvb, offset); /* check SPDU type */ - if (match_strval(type, ses_vals) == NULL) + if (try_val_to_str(type, ses_vals) == NULL) { return FALSE; /* no, it isn't a session PDU */ } @@ -1973,7 +1973,7 @@ dissect_ses_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, voi /* get SPDU type */ type = tvb_get_guint8(tvb, offset+2); /* check SPDU type */ - if (match_strval(type, ses_vals) == NULL) + if (try_val_to_str(type, ses_vals) == NULL) { return FALSE; /* no, it isn't a session PDU */ } @@ -1985,7 +1985,7 @@ dissect_ses_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, voi * so if the parameter type is unknown, it's probably SIMATIC */ if(type == 0x32 && tvb_length(tvb) >= 3) { type = tvb_get_guint8(tvb, offset+2); - if (match_strval(type, param_vals) == NULL) { + if (try_val_to_str(type, param_vals) == NULL) { return FALSE; /* it's probably a SIMATIC protocol */ } } @@ -2004,7 +2004,7 @@ dissect_ses_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, voi if (tvb_length(tvb) > 1+(guint) len) { type = tvb_get_guint8(tvb, offset + len + 1); /* check SPDU type */ - if (match_strval(type, ses_vals) == NULL) { + if (try_val_to_str(type, ses_vals) == NULL) { return FALSE; /* no, it isn't a session PDU */ } } diff --git a/epan/dissectors/packet-sgsap.c b/epan/dissectors/packet-sgsap.c index 39eb51fcf5..e7bdd18845 100644 --- a/epan/dissectors/packet-sgsap.c +++ b/epan/dissectors/packet-sgsap.c @@ -1369,7 +1369,7 @@ static void get_sgsap_msg_params(guint8 oct, const gchar **msg_str, int *ett_tre { gint idx; - *msg_str = match_strval_idx_ext((guint32) (oct & 0xff), &sgsap_msg_strings_ext, &idx); + *msg_str = try_val_to_str_idx_ext((guint32) (oct & 0xff), &sgsap_msg_strings_ext, &idx); *hf_idx = hf_sgsap_msg_type; if (*msg_str != NULL) { *ett_tree = ett_sgsap_msg[idx]; diff --git a/epan/dissectors/packet-slimp3.c b/epan/dissectors/packet-slimp3.c index 23f3702a94..1f413e44cf 100644 --- a/epan/dissectors/packet-slimp3.c +++ b/epan/dissectors/packet-slimp3.c @@ -251,7 +251,7 @@ dissect_slimp3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _ if (!tvb_bytes_exist(tvb, offset, 1)) return 0; /* not even an opcode */ opcode = tvb_get_guint8(tvb, offset); - opcode_str = match_strval(opcode, slimp3_opcode_vals); + opcode_str = try_val_to_str(opcode, slimp3_opcode_vals); if (opcode_str == NULL) return 0; diff --git a/epan/dissectors/packet-slowprotocols.c b/epan/dissectors/packet-slowprotocols.c index 11f0886b5e..0974a9cf98 100644 --- a/epan/dissectors/packet-slowprotocols.c +++ b/epan/dissectors/packet-slowprotocols.c @@ -1748,7 +1748,7 @@ dissect_esmc_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *treex) expert_add_info_format(pinfo, item_c, PI_MALFORMED, PI_WARN ,"Unused bits of TLV must be all zeroes"); } - if (NULL != match_strval(ql, esmc_quality_level_opt_1_vals)) + if (NULL != try_val_to_str(ql, esmc_quality_level_opt_1_vals)) { proto_tree_add_item(tree_b, hf_esmc_quality_level_opt_1, tvb, offset, 1, ENC_BIG_ENDIAN); } diff --git a/epan/dissectors/packet-slsk.c b/epan/dissectors/packet-slsk.c index 124da92743..57a9adc79b 100644 --- a/epan/dissectors/packet-slsk.c +++ b/epan/dissectors/packet-slsk.c @@ -273,7 +273,7 @@ static const char* get_message_type(tvbuff_t *tvb) { * Returns the Message Type. */ int msg_code = tvb_get_letohl(tvb, 4); - const gchar *message_type = match_strval(msg_code, slsk_tcp_msgs); + const gchar *message_type = try_val_to_str(msg_code, slsk_tcp_msgs); if (message_type == NULL) { if (check_slsk_format(tvb, 4, "bisis")) message_type = "Distributed Search"; diff --git a/epan/dissectors/packet-smpp.c b/epan/dissectors/packet-smpp.c index 95d7c65802..a256e8848b 100644 --- a/epan/dissectors/packet-smpp.c +++ b/epan/dissectors/packet-smpp.c @@ -2370,11 +2370,11 @@ dissect_smpp_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat if (command_length > 64 * 1024 || command_length < SMPP_MIN_LENGTH) return FALSE; command_id = tvb_get_ntohl(tvb, 4); /* Only known commands */ - if (match_strval(command_id, vals_command_id) == NULL) + if (try_val_to_str(command_id, vals_command_id) == NULL) return FALSE; command_status = tvb_get_ntohl(tvb, 8); /* ..with known status */ - if (match_strval(command_status, vals_command_status) == NULL && - match_strrval(command_status, reserved_command_status) == NULL) + if (try_val_to_str(command_status, vals_command_status) == NULL && + try_rval_to_str(command_status, reserved_command_status) == NULL) return FALSE; dissect_smpp(tvb, pinfo, tree); return TRUE; @@ -2460,7 +2460,7 @@ dissect_smpp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) command_status = tvb_get_ntohl(tvb, offset); if (command_id & 0x80000000) { /* PDU is a response. */ - command_status_str = match_strval(command_status, vals_command_status); + command_status_str = try_val_to_str(command_status, vals_command_status); if (command_status_str == NULL) { /* Check if the reserved value is in the vendor-specific range. */ command_status_str = (command_status >= 0x400 && command_status <= 0x4FF ? diff --git a/epan/dissectors/packet-ssl.c b/epan/dissectors/packet-ssl.c index f1ac01db2e..e8b70ec3c1 100644 --- a/epan/dissectors/packet-ssl.c +++ b/epan/dissectors/packet-ssl.c @@ -1842,10 +1842,10 @@ dissect_ssl3_alert(tvbuff_t *tvb, packet_info *pinfo, /* first lookup the names for the alert level and description */ byte = tvb_get_guint8(tvb, offset); /* grab the level byte */ - level = match_strval(byte, ssl_31_alert_level); + level = try_val_to_str(byte, ssl_31_alert_level); byte = tvb_get_guint8(tvb, offset+1); /* grab the desc byte */ - desc = match_strval(byte, ssl_31_alert_description); + desc = try_val_to_str(byte, ssl_31_alert_description); /* now set the text in the record layer line */ if (level && desc) @@ -1939,7 +1939,7 @@ dissect_ssl3_handshake(tvbuff_t *tvb, packet_info *pinfo, * message is actually a known handshake message type. */ if (offset + length <= record_length) - msg_type_str = match_strval(msg_type, ssl_31_handshake_type); + msg_type_str = try_val_to_str(msg_type, ssl_31_handshake_type); else msg_type_str = NULL; @@ -2260,7 +2260,7 @@ dissect_ssl3_heartbeat(tvbuff_t *tvb, packet_info *pinfo, /* first lookup the names for the message type and the payload length */ byte = tvb_get_guint8(tvb, offset); - type = match_strval(byte, tls_heartbeat_type); + type = try_val_to_str(byte, tls_heartbeat_type); payload_length = tvb_get_ntohs(tvb, offset + 1); padding_length = record_length - 3 - payload_length; @@ -3677,7 +3677,7 @@ dissect_ssl2_record(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, /* see if the msg_type is valid; if not the payload is * probably encrypted, so note that fact and bail */ - msg_type_str = match_strval(msg_type, + msg_type_str = try_val_to_str(msg_type, (*conv_version == SSL_VER_PCT) ? pct_msg_types : ssl_20_msg_types); if (!msg_type_str @@ -4709,7 +4709,7 @@ ssl_is_valid_ssl_version(const guint16 version) { const gchar *version_str; - version_str = match_strval(version, ssl_versions); + version_str = try_val_to_str(version, ssl_versions); return version_str != NULL; } diff --git a/epan/dissectors/packet-sua.c b/epan/dissectors/packet-sua.c index 334850248b..7cd445985f 100644 --- a/epan/dissectors/packet-sua.c +++ b/epan/dissectors/packet-sua.c @@ -1896,7 +1896,7 @@ dissect_parameter(tvbuff_t *parameter_tvb, packet_info *pinfo, proto_tree *tree /* If it's a known parameter it's present in the value_string. * If param_tag_str = NULL then this is an unknown parameter */ - param_tag_str = match_strval(tag, parameter_tag_values); + param_tag_str = try_val_to_str(tag, parameter_tag_values); if(param_tag_str) { /* The parameter exists */ parameter_item = proto_tree_add_text(tree, parameter_tvb, PARAMETER_HEADER_OFFSET, tvb_length(parameter_tvb), "%s", param_tag_str); diff --git a/epan/dissectors/packet-synphasor.c b/epan/dissectors/packet-synphasor.c index 8e5fe8f9ec..f243799317 100644 --- a/epan/dissectors/packet-synphasor.c +++ b/epan/dissectors/packet-synphasor.c @@ -1128,7 +1128,7 @@ static gint dissect_ANUNIT(tvbuff_t *tvb, proto_tree *tree, gint offset, gint cn temp_item = proto_tree_add_text(temp_tree, tvb, offset, 4, "Factor for analog value #%i: %s", i + 1, - match_strrval((tmp >> 24) & 0x000000FF, conf_anconvnames)); + try_rval_to_str((tmp >> 24) & 0x000000FF, conf_anconvnames)); tmp &= 0x00FFFFFF; if ( tmp & 0x00800000) /* sign bit set */ diff --git a/epan/dissectors/packet-telnet.c b/epan/dissectors/packet-telnet.c index aa559f9cf5..13aeb56ad9 100644 --- a/epan/dissectors/packet-telnet.c +++ b/epan/dissectors/packet-telnet.c @@ -411,7 +411,7 @@ dissect_tn3270e_subopt(packet_info *pinfo _U_, const char *optname _U_, tvbuff_t while (len > 0) { rsn = tvb_get_guint8(tvb, offset); proto_tree_add_item( tree, hf_tn3270_request, tvb, offset, 1, ENC_NA ); - if (match_strval(rsn, tn3270_request_vals) == NULL) + if (try_val_to_str(rsn, tn3270_request_vals) == NULL) break; offset++; diff --git a/epan/dissectors/packet-tn3270.c b/epan/dissectors/packet-tn3270.c index 55f07ab341..359daf2b73 100644 --- a/epan/dissectors/packet-tn3270.c +++ b/epan/dissectors/packet-tn3270.c @@ -4708,7 +4708,7 @@ dissect_structured_fields(proto_tree *tn3270_tree, tvbuff_t *tvb, gint offset, sf_id_len = 2; } - sf_id_str = match_strval(sf_id, direction_inbound ? + sf_id_str = try_val_to_str(sf_id, direction_inbound ? vals_inbound_structured_fields : vals_outbound_structured_fields); if (sf_id_str != NULL) { sf_tree = display_sf_hdr(tn3270_tree, tvb, offset, @@ -4724,7 +4724,7 @@ dissect_structured_fields(proto_tree *tn3270_tree, tvbuff_t *tvb, gint offset, } /* Not found above: See if an "outbound-inbound" field */ - sf_id_str = match_strval(sf_id, vals_outbound_inbound_structured_fields); + sf_id_str = try_val_to_str(sf_id, vals_outbound_inbound_structured_fields); if (sf_id_str != NULL) { sf_tree = display_sf_hdr(tn3270_tree, tvb, offset, sf_length, sf_id, sf_id_len, sf_id_str); diff --git a/epan/dissectors/packet-tpncp.c b/epan/dissectors/packet-tpncp.c index 3c85ab78ac..5ec37e0e57 100644 --- a/epan/dissectors/packet-tpncp.c +++ b/epan/dissectors/packet-tpncp.c @@ -290,7 +290,7 @@ static void dissect_tpncp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { proto_tree_add_uint(tpncp_tree, hf_tpncp_reserved, tvb, 6, 2, reserved); if (pinfo->srcport == UDP_PORT_TPNCP_TRUNKPACK) { - if (match_strval(id, tpncp_events_id_vals)) { + if (try_val_to_str(id, tpncp_events_id_vals)) { proto_tree_add_uint(tpncp_tree, hf_tpncp_event_id, tvb, 8, 4, id); proto_tree_add_int(tpncp_tree, hf_tpncp_cid, tvb, 12, 4, cid); offset += 16; @@ -302,7 +302,7 @@ static void dissect_tpncp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { } } else { - if (match_strval(id, tpncp_commands_id_vals)) { + if (try_val_to_str(id, tpncp_commands_id_vals)) { proto_tree_add_uint(tpncp_tree, hf_tpncp_command_id, tvb, 8, 4, id); offset += 12; if (tpncp_commands_info_db[id].tpncp_data_field_size) { diff --git a/epan/dissectors/packet-ucp.c b/epan/dissectors/packet-ucp.c index 127854819d..c7ac61cd37 100644 --- a/epan/dissectors/packet-ucp.c +++ b/epan/dissectors/packet-ucp.c @@ -1736,7 +1736,7 @@ dissect_ucp_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data (tvb_get_guint8(tvb, UCP_OT_OFFSET + UCP_OT_LEN) != '/')) return FALSE; - if (match_strval(tvb_get_guint8(tvb, UCP_O_R_OFFSET), vals_hdr_O_R) == NULL) + if (try_val_to_str(tvb_get_guint8(tvb, UCP_O_R_OFFSET), vals_hdr_O_R) == NULL) return FALSE; /* diff --git a/epan/dissectors/packet-usb-video.c b/epan/dissectors/packet-usb-video.c index bc95ce04f9..04a01fc710 100644 --- a/epan/dissectors/packet-usb-video.c +++ b/epan/dissectors/packet-usb-video.c @@ -1668,7 +1668,7 @@ get_control_selector_name(guint8 entity_id, guint8 control_sel, usb_conv_info_t selectors = get_control_selector_values(entity_id, usb_conv_info); if (selectors) - control_name = match_strval_ext(control_sel, selectors); + control_name = try_val_to_str_ext(control_sel, selectors); return control_name; } diff --git a/epan/dissectors/packet-wbxml.c b/epan/dissectors/packet-wbxml.c index 4b82addebb..cb05adff6d 100644 --- a/epan/dissectors/packet-wbxml.c +++ b/epan/dissectors/packet-wbxml.c @@ -6893,7 +6893,7 @@ map_token (const value_valuestring *token_map, guint8 codepage, guint8 token) { if (token_map) { /* Found map */ if ((vs = val_to_valstr (codepage, token_map))) { /* Found codepage map */ - s = match_strval (token, vs); + s = try_val_to_str (token, vs); if (s) { /* Found valid token */ DebugLog(("map_token(codepage = %u, token = %u: [%s]\n", codepage, token, s)); return s; diff --git a/epan/dissectors/packet-wccp.c b/epan/dissectors/packet-wccp.c index 0ae754e37b..0244f451f2 100644 --- a/epan/dissectors/packet-wccp.c +++ b/epan/dissectors/packet-wccp.c @@ -296,7 +296,7 @@ dissect_wccp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_ wccp_message_type = tvb_get_ntohl(tvb, offset); /* Check if this is really a WCCP message */ - if (match_strval(wccp_message_type, wccp_type_vals) == NULL) + if (try_val_to_str(wccp_message_type, wccp_type_vals) == NULL) return 0; col_set_str(pinfo->cinfo, COL_PROTOCOL, "WCCP"); diff --git a/epan/dissectors/packet-wsp.c b/epan/dissectors/packet-wsp.c index 51009797ed..d7d000602a 100644 --- a/epan/dissectors/packet-wsp.c +++ b/epan/dissectors/packet-wsp.c @@ -3311,7 +3311,7 @@ wkh_ ## underscored(proto_tree *tree, tvbuff_t *tvb, guint32 hdr_start, packet_i guint32 val = 0, off = val_start, len; \ \ wkh_1_WellKnownValue; \ - val_str = match_strval_ext(val_id & 0x7F, valueStringExtAddr); \ + val_str = try_val_to_str_ext(val_id & 0x7F, valueStringExtAddr); \ if (val_str) { \ tvb_ensure_bytes_exist(tvb, hdr_start, offset - hdr_start); \ ti = proto_tree_add_string(tree, hf_hdr_ ## underscored, \ @@ -3330,7 +3330,7 @@ wkh_ ## underscored(proto_tree *tree, tvbuff_t *tvb, guint32 hdr_start, packet_i get_long_integer(val, tvb, off, len, ok); \ if (ok) { \ val = val; /* hack to prevent 'set but not used' gcc warning */ \ - val_str = match_strval_ext(val_id & 0x7F, valueStringExtAddr); \ + val_str = try_val_to_str_ext(val_id & 0x7F, valueStringExtAddr); \ if (val_str) { \ tvb_ensure_bytes_exist(tvb, hdr_start, offset - hdr_start); \ ti = proto_tree_add_string(tree, hf_hdr_ ## underscored, \ @@ -3364,7 +3364,7 @@ wkh_cache_control(proto_tree *tree, tvbuff_t *tvb, guint32 hdr_start, packet_inf wkh_1_WellKnownValue; val = val_id & 0x7F; - val_str = match_strval_ext(val, &vals_cache_control_ext); + val_str = try_val_to_str_ext(val, &vals_cache_control_ext); if (val_str) { tvb_ensure_bytes_exist(tvb, hdr_start, offset - hdr_start); ti = proto_tree_add_string(tree, hf_hdr_cache_control, @@ -3487,7 +3487,7 @@ wkh_warning(proto_tree *tree, tvbuff_t *tvb, guint32 hdr_start, packet_info *pin wkh_1_WellKnownValue; val = val_id & 0x7F; - val_str = match_strval_ext(val, &vals_wsp_warning_code_ext); + val_str = try_val_to_str_ext(val, &vals_wsp_warning_code_ext); if (val_str) { tvb_ensure_bytes_exist(tvb, hdr_start, offset - hdr_start); ti = proto_tree_add_string(tree, hf_hdr_warning, @@ -3505,7 +3505,7 @@ wkh_warning(proto_tree *tree, tvbuff_t *tvb, guint32 hdr_start, packet_info *pin warn_code = tvb_get_guint8(tvb, off); if (warn_code & 0x80) { /* Well known warn code */ val = warn_code & 0x7f; - val_str = match_strval_ext(val, &vals_wsp_warning_code_short_ext); + val_str = try_val_to_str_ext(val, &vals_wsp_warning_code_short_ext); if (val_str) { /* OK */ str = ep_strdup_printf("code=%s", val_str); tvb_ensure_bytes_exist(tvb, hdr_start, offset - hdr_start); @@ -3553,7 +3553,7 @@ wkh_profile_warning(proto_tree *tree, tvbuff_t *tvb, guint32 hdr_start, packet_i wkh_1_WellKnownValue; val = val_id & 0x7F; - val_str = match_strval_ext(val, &vals_wsp_profile_warning_code_ext); + val_str = try_val_to_str_ext(val, &vals_wsp_profile_warning_code_ext); if (val_str) { tvb_ensure_bytes_exist(tvb, hdr_start, offset - hdr_start); ti = proto_tree_add_string(tree, hf_hdr_profile_warning, @@ -3566,7 +3566,7 @@ wkh_profile_warning(proto_tree *tree, tvbuff_t *tvb, guint32 hdr_start, packet_i off = val_start + val_len_len; warn_code = tvb_get_guint8(tvb, off++); if (warn_code & 0x80) { /* Well known warn code */ - val_str = match_strval_ext(val, &vals_wsp_profile_warning_code_ext); + val_str = try_val_to_str_ext(val, &vals_wsp_profile_warning_code_ext); if (val_str) { /* OK */ tvb_ensure_bytes_exist(tvb, hdr_start, offset - hdr_start); ti = proto_tree_add_string(tree, hf_hdr_profile_warning, @@ -3776,7 +3776,7 @@ static guint32 wkh_te (proto_tree *tree, tvbuff_t *tvb, guint32 hdr_start, packe off = val_start + val_len_len; val = tvb_get_guint8(tvb, off); if (val & 0x80) { /* Well-known-TE */ - val_str = match_strval_ext((val & 0x7F), &vals_well_known_te_ext); + val_str = try_val_to_str_ext((val & 0x7F), &vals_well_known_te_ext); if (val_str) { tvb_ensure_bytes_exist(tvb, hdr_start, offset - hdr_start); ti = proto_tree_add_string(tree, hf_hdr_te, diff --git a/epan/dissectors/packet-wtls.c b/epan/dissectors/packet-wtls.c index f136455ec7..df79c656e6 100644 --- a/epan/dissectors/packet-wtls.c +++ b/epan/dissectors/packet-wtls.c @@ -794,10 +794,10 @@ dissect_wtls_handshake(proto_tree *tree, tvbuff_t *tvb, guint offset, guint coun offset+=1; for (;count > 0;count-=client_size) { value = tvb_get_guint8 (tvb, offset); - valBulk = match_strval_ext(value, &wtls_vals_cipher_bulk_ext); + valBulk = try_val_to_str_ext(value, &wtls_vals_cipher_bulk_ext); offset++; client_size=1; - valMac = match_strval_ext(tvb_get_guint8 (tvb, offset), &wtls_vals_cipher_mac_ext); + valMac = try_val_to_str_ext(tvb_get_guint8 (tvb, offset), &wtls_vals_cipher_mac_ext); if (valBulk != NULL) { if (valMac != NULL) diff --git a/epan/dissectors/packet-x11.c b/epan/dissectors/packet-x11.c index e0217ea549..6d49ee6c79 100644 --- a/epan/dissectors/packet-x11.c +++ b/epan/dissectors/packet-x11.c @@ -1331,7 +1331,7 @@ static void atom(tvbuff_t *tvb, int *offsetp, proto_tree *t, int hf, else { header_field_info *hfi = proto_registrar_get_nth(hf); if (hfi -> strings) - interpretation = match_strval(v, cVALS(hfi -> strings)); + interpretation = try_val_to_str(v, cVALS(hfi -> strings)); } if (!interpretation) interpretation = "error in Xlib client program ?"; proto_tree_add_uint_format(t, hf, tvb, *offsetp, 4, v, "%s: %u (%s)", @@ -2219,7 +2219,7 @@ static guint32 field8(tvbuff_t *tvb, int *offsetp, proto_tree *t, int hf, const gchar *enumValue = NULL; if (hfi -> strings) - enumValue = match_strval(v, cVALS(hfi -> strings)); + enumValue = try_val_to_str(v, cVALS(hfi -> strings)); if (enumValue) proto_tree_add_uint_format(t, hf, tvb, *offsetp, 1, v, hfi -> display == BASE_DEC ? "%s: %u (%s)" : "%s: 0x%02x (%s)", @@ -2238,7 +2238,7 @@ static guint32 field16(tvbuff_t *tvb, int *offsetp, proto_tree *t, int hf, const gchar *enumValue = NULL; if (hfi -> strings) - enumValue = match_strval(v, cVALS(hfi -> strings)); + enumValue = try_val_to_str(v, cVALS(hfi -> strings)); if (enumValue) proto_tree_add_uint_format(t, hf, tvb, *offsetp, 2, v, hfi -> display == BASE_DEC ? "%s: %u (%s)" : "%s: 0x%02x (%s)", @@ -2258,7 +2258,7 @@ static guint32 field32(tvbuff_t *tvb, int *offsetp, proto_tree *t, int hf, const gchar *nameAsChar = hfi -> name; if (hfi -> strings) - enumValue = match_strval(v, cVALS(hfi -> strings)); + enumValue = try_val_to_str(v, cVALS(hfi -> strings)); if (enumValue) proto_tree_add_uint_format(t, hf, tvb, *offsetp, 4, v, hfi -> display == BASE_DEC ? "%s: %u (%s)" : "%s: 0x%08x (%s)", @@ -3037,7 +3037,7 @@ static void tryExtension(int opcode, tvbuff_t *tvb, packet_info *pinfo, int *off const gchar *extension; void (*func)(tvbuff_t *tvb, packet_info *pinfo, int *offsetp, proto_tree *t, guint byte_order); - extension = match_strval(opcode, state->opcode_vals); + extension = try_val_to_str(opcode, state->opcode_vals); if (!extension) return; diff --git a/epan/ipproto.c b/epan/ipproto.c index 2089e5793c..7668471073 100644 --- a/epan/ipproto.c +++ b/epan/ipproto.c @@ -273,7 +273,7 @@ value_string_ext ipproto_val_ext = VALUE_STRING_EXT_INIT(ipproto_val); const char *ipprotostr(const int proto) { const char *s; - if ((s = match_strval_ext(proto, &ipproto_val_ext)) != NULL) + if ((s = try_val_to_str_ext(proto, &ipproto_val_ext)) != NULL) return s; s = "Unknown"; diff --git a/epan/proto.c b/epan/proto.c index c5b5812ca6..4ea0e2fffc 100644 --- a/epan/proto.c +++ b/epan/proto.c @@ -6535,7 +6535,7 @@ proto_registrar_dump_values(void) g_warning("Invalid value_string_ext ptr for: %s", hfinfo->abbrev); continue; } - match_strval_ext(0, vse_p); /* "prime" the extended value_string */ + try_val_to_str_ext(0, vse_p); /* "prime" the extended value_string */ printf("E\t%s\t%d\t%s\t%s\n", hfinfo->abbrev, VALUE_STRING_EXT_VS_NUM_ENTRIES(vse_p), @@ -6973,11 +6973,11 @@ construct_match_selected_string(field_info *finfo, epan_dissect_t *edt, case FT_INT24: case FT_INT32: if (hfinfo->display & BASE_RANGE_STRING) { - str = match_strrval(fvalue_get_sinteger(&finfo->value), (const range_string *)hfinfo->strings); + str = try_rval_to_str(fvalue_get_sinteger(&finfo->value), (const range_string *)hfinfo->strings); } else if (hfinfo->display & BASE_EXT_STRING) { - str = match_strval_ext(fvalue_get_sinteger(&finfo->value), (const value_string_ext *)hfinfo->strings); + str = try_val_to_str_ext(fvalue_get_sinteger(&finfo->value), (const value_string_ext *)hfinfo->strings); } else { - str = match_strval(fvalue_get_sinteger(&finfo->value), (const value_string *)hfinfo->strings); + str = try_val_to_str(fvalue_get_sinteger(&finfo->value), (const value_string *)hfinfo->strings); } break; @@ -6986,11 +6986,11 @@ construct_match_selected_string(field_info *finfo, epan_dissect_t *edt, case FT_UINT24: case FT_UINT32: if (hfinfo->display & BASE_RANGE_STRING) { - str = match_strrval(fvalue_get_uinteger(&finfo->value), (const range_string *)hfinfo->strings); + str = try_rval_to_str(fvalue_get_uinteger(&finfo->value), (const range_string *)hfinfo->strings); } else if (hfinfo->display & BASE_EXT_STRING) { - str = match_strval_ext(fvalue_get_uinteger(&finfo->value), (const value_string_ext *)hfinfo->strings); + str = try_val_to_str_ext(fvalue_get_uinteger(&finfo->value), (const value_string_ext *)hfinfo->strings); } else { - str = match_strval(fvalue_get_uinteger(&finfo->value), (const value_string *)hfinfo->strings); + str = try_val_to_str(fvalue_get_uinteger(&finfo->value), (const value_string *)hfinfo->strings); } break; diff --git a/epan/value_string.c b/epan/value_string.c index c2b79e0b49..2c97801094 100644 --- a/epan/value_string.c +++ b/epan/value_string.c @@ -44,7 +44,7 @@ val_to_str(const guint32 val, const value_string *vs, const char *fmt) DISSECTOR_ASSERT(fmt != NULL); - ret = match_strval(val, vs); + ret = try_val_to_str(val, vs); if (ret != NULL) return ret; @@ -62,7 +62,7 @@ val_to_str_const(const guint32 val, const value_string *vs, DISSECTOR_ASSERT(unknown_str != NULL); - ret = match_strval(val, vs); + ret = try_val_to_str(val, vs); if (ret != NULL) return ret; @@ -74,7 +74,7 @@ val_to_str_const(const guint32 val, const value_string *vs, that table, on a match, and returns NULL, and sets "*idx" to -1, on failure. */ const gchar* -match_strval_idx(const guint32 val, const value_string *vs, gint *idx) +try_val_to_str_idx(const guint32 val, const value_string *vs, gint *idx) { gint i = 0; @@ -94,12 +94,12 @@ match_strval_idx(const guint32 val, const value_string *vs, gint *idx) return NULL; } -/* Like match_strval_idx(), but doesn't return the index. */ +/* Like try_val_to_str_idx(), but doesn't return the index. */ const gchar* -match_strval(const guint32 val, const value_string *vs) +try_val_to_str(const guint32 val, const value_string *vs) { gint ignore_me; - return match_strval_idx(val, vs, &ignore_me); + return try_val_to_str_idx(val, vs, &ignore_me); } /* EXTENDED VALUE STRING */ @@ -157,15 +157,15 @@ value_string_ext_new(value_string *vs, guint vs_tot_num_entries, * simple way to do lazy initialization of extended value strings. * The init function also sets up _vs_first_value for us. */ vse->_vs_first_value = 0; - vse->_vs_match2 = _match_strval_ext_init; + vse->_vs_match2 = _try_val_to_str_ext_init; vse->_vs_name = vs_name; return vse; } -/* Like match_strval for extended value strings */ +/* Like try_val_to_str for extended value strings */ const gchar* -match_strval_ext(const guint32 val, const value_string_ext *vse) +try_val_to_str_ext(const guint32 val, const value_string_ext *vse) { if (vse) { const value_string *vs = vse->_vs_match2(val, vse); @@ -178,9 +178,9 @@ match_strval_ext(const guint32 val, const value_string_ext *vse) return NULL; } -/* Like match_strval_idx for extended value strings */ +/* Like try_val_to_str_idx for extended value strings */ const gchar* -match_strval_idx_ext(const guint32 val, value_string_ext *vse, gint *idx) +try_val_to_str_idx_ext(const guint32 val, value_string_ext *vse, gint *idx) { if (vse) { const value_string *vs = vse->_vs_match2(val, vse); @@ -201,7 +201,7 @@ val_to_str_ext(const guint32 val, const value_string_ext *vse, const char *fmt) DISSECTOR_ASSERT(fmt != NULL); - ret = match_strval_ext(val, vse); + ret = try_val_to_str_ext(val, vse); if (ret != NULL) return ret; @@ -217,7 +217,7 @@ val_to_str_ext_const(const guint32 val, const value_string_ext *vse, DISSECTOR_ASSERT(unknown_str != NULL); - ret = match_strval_ext(val, vse); + ret = try_val_to_str_ext(val, vse); if (ret != NULL) return ret; @@ -226,7 +226,7 @@ val_to_str_ext_const(const guint32 val, const value_string_ext *vse, /* Fallback linear matching algorithm for extended value strings */ static const value_string * -_match_strval_linear(const guint32 val, const value_string_ext *vse) +_try_val_to_str_linear(const guint32 val, const value_string_ext *vse) { const value_string *vs_p = vse->_vs_p; guint i; @@ -239,7 +239,7 @@ _match_strval_linear(const guint32 val, const value_string_ext *vse) /* Constant-time matching algorithm for contiguous extended value strings */ static const value_string * -_match_strval_index(const guint32 val, const value_string_ext *vse) +_try_val_to_str_index(const guint32 val, const value_string_ext *vse) { guint i; @@ -253,7 +253,7 @@ _match_strval_index(const guint32 val, const value_string_ext *vse) /* log(n)-time matching algorithm for sorted extended value strings */ static const value_string * -_match_strval_bsearch(const guint32 val, const value_string_ext *vse) +_try_val_to_str_bsearch(const guint32 val, const value_string_ext *vse) { guint low, i, max; guint32 item; @@ -280,12 +280,12 @@ _match_strval_bsearch(const guint32 val, const value_string_ext *vse) * - Verifies that the value_string is terminated by {0, NULL} */ const value_string * -_match_strval_ext_init(const guint32 val, const value_string_ext *a_vse) +_try_val_to_str_ext_init(const guint32 val, const value_string_ext *a_vse) { /* Cast away the constness! * It's better if the prototype for this function matches the other - * _match_strval_* functions (so we don't have to cast it when storing it - * in _match_strval so the compiler will notice if the prototypes get out + * _try_val_to_str_* functions (so we don't have to cast it when storing it + * in _try_val_to_str so the compiler will notice if the prototypes get out * of sync), but the init function is unique in that it does actually * modify the vse. */ @@ -357,13 +357,13 @@ _match_strval_ext_init(const guint32 val, const value_string_ext *a_vse) switch (type) { case VS_SEARCH: - vse->_vs_match2 = _match_strval_linear; + vse->_vs_match2 = _try_val_to_str_linear; break; case VS_BIN_TREE: - vse->_vs_match2 = _match_strval_bsearch; + vse->_vs_match2 = _try_val_to_str_bsearch; break; case VS_INDEX: - vse->_vs_match2 = _match_strval_index; + vse->_vs_match2 = _try_val_to_str_index; break; default: g_assert_not_reached(); @@ -386,16 +386,16 @@ str_to_str(const gchar *val, const string_string *vs, const char *fmt) DISSECTOR_ASSERT(fmt != NULL); - ret = match_strstr(val, vs); + ret = try_str_to_str(val, vs); if (ret != NULL) return ret; return ep_strdup_printf(fmt, val); } -/* Like match_strval_idx except for string_string */ +/* Like try_val_to_str_idx except for string_string */ const gchar* -match_strstr_idx(const gchar *val, const string_string *vs, gint *idx) +try_str_to_str_idx(const gchar *val, const string_string *vs, gint *idx) { gint i = 0; @@ -413,12 +413,12 @@ match_strstr_idx(const gchar *val, const string_string *vs, gint *idx) return NULL; } -/* Like match_strval except for string_string */ +/* Like try_val_to_str except for string_string */ const gchar* -match_strstr(const gchar *val, const string_string *vs) +try_str_to_str(const gchar *val, const string_string *vs) { gint ignore_me; - return match_strstr_idx(val, vs, &ignore_me); + return try_str_to_str_idx(val, vs, &ignore_me); } /* RANGE TO STRING MATCHING */ @@ -434,16 +434,16 @@ rval_to_str(const guint32 val, const range_string *rs, const char *fmt) DISSECTOR_ASSERT(fmt != NULL); - ret = match_strrval(val, rs); + ret = try_rval_to_str(val, rs); if(ret != NULL) return ret; return ep_strdup_printf(fmt, val); } -/* Like match_strval_idx except for range_string */ +/* Like try_val_to_str_idx except for range_string */ const gchar * -match_strrval_idx(const guint32 val, const range_string *rs, gint *idx) +try_rval_to_str_idx(const guint32 val, const range_string *rs, gint *idx) { gint i = 0; @@ -461,12 +461,12 @@ match_strrval_idx(const guint32 val, const range_string *rs, gint *idx) return NULL; } -/* Like match_strval except for range_string */ +/* Like try_val_to_str except for range_string */ const gchar * -match_strrval(const guint32 val, const range_string *rs) +try_rval_to_str(const guint32 val, const range_string *rs) { gint ignore_me = 0; - return match_strrval_idx(val, rs, &ignore_me); + return try_rval_to_str_idx(val, rs, &ignore_me); } /* MISC */ @@ -478,10 +478,10 @@ value_string_ext_validate(const value_string_ext *vse) { if (vse == NULL) return FALSE; - if ((vse->_vs_match2 == _match_strval_ext_init) || - (vse->_vs_match2 == _match_strval_linear) || - (vse->_vs_match2 == _match_strval_bsearch) || - (vse->_vs_match2 == _match_strval_index)) + if ((vse->_vs_match2 == _try_val_to_str_ext_init) || + (vse->_vs_match2 == _try_val_to_str_linear) || + (vse->_vs_match2 == _try_val_to_str_bsearch) || + (vse->_vs_match2 == _try_val_to_str_index)) return TRUE; return FALSE; } @@ -489,11 +489,11 @@ value_string_ext_validate(const value_string_ext *vse) const gchar * value_string_ext_match_type_str(const value_string_ext *vse) { - if (vse->_vs_match2 == _match_strval_linear) + if (vse->_vs_match2 == _try_val_to_str_linear) return "[Linear Search]"; - if (vse->_vs_match2 == _match_strval_bsearch) + if (vse->_vs_match2 == _try_val_to_str_bsearch) return "[Binary Search]"; - if (vse->_vs_match2 == _match_strval_index) + if (vse->_vs_match2 == _try_val_to_str_index) return "[Direct (indexed) Access]"; return "[Match Type not initialized or invalid]"; } diff --git a/epan/value_string.h b/epan/value_string.h index bfdb33bb05..cdb8a8272a 100644 --- a/epan/value_string.h +++ b/epan/value_string.h @@ -28,93 +28,31 @@ #include #include "ws_symbol_export.h" -/* Struct for the val_to_str, match_strval_idx, and match_strval functions */ +/* VALUE TO STRING MATCHING */ typedef struct _value_string { guint32 value; const gchar *strptr; } value_string; -/* Struct for the str_to_str, match_strstr_idx, and match_strstr functions */ +WS_DLL_PUBLIC +const gchar* +val_to_str(const guint32 val, const value_string *vs, const char *fmt); -typedef struct _string_string { - const gchar *value; - const gchar *strptr; -} string_string; +WS_DLL_PUBLIC +const gchar* +val_to_str_const(const guint32 val, const value_string *vs, const char *unknown_str); -/* Struct for the rval_to_str, match_strrval_idx, and match_strrval functions */ -typedef struct _range_string { - guint32 value_min; - guint32 value_max; - const gchar *strptr; -} range_string; +WS_DLL_PUBLIC +const gchar* +try_val_to_str(const guint32 val, const value_string *vs); -/* #define VS_DEF(x) { x, #x } */ -/* #define VS_END { 0, NULL } */ +WS_DLL_PUBLIC +const gchar* +try_val_to_str_idx(const guint32 val, const value_string *vs, gint *idx); -/* Tries to match val against each element in the value_string array 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. */ -WS_DLL_PUBLIC const gchar* match_strval_idx(const guint32 val, const value_string *vs, gint *idx); +/* EXTENDED VALUE TO STRING MATCHING */ -/* Like match_strval_idx(), but doesn't return the index. */ -WS_DLL_PUBLIC const gchar* match_strval(const 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. */ -WS_DLL_PUBLIC const gchar* val_to_str(const 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. - Returns 'unknown_str', on failure. */ -WS_DLL_PUBLIC const gchar* val_to_str_const(const guint32 val, const value_string *vs, const char *unknown_str); - -/* Tries to match val against each element in the string_string array 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_strstr_idx(const gchar *val, const string_string *vs, gint *idx); - -/* Like match_strstr_idx(), but doesn't return the index. */ -extern const gchar* match_strstr(const gchar *val, const string_string *vs); - -/* Tries to match val against each element in the string_string array vs. - Returns the associated string ptr on a match. - Formats val with fmt, and returns the resulting string, on failure. */ -WS_DLL_PUBLIC const gchar* str_to_str(const gchar *val, const string_string *vs, const char *fmt); - -/* --------------------------------------------------------------------*/ -/* value_string_ext functions - * - * Extended value strings allow fast(er) value_string array lookups by - * using (if possible) direct access or a binary search of the array. - * - * If the values in the value_string array are a contiguous range of values - * from min to max, the value will be used as as a direct index into the array. - * - * If the values in the array are not contiguous (ie: there are "gaps"), - * but are in assending order a binary search will be used. - * - * If direct access or binary search cannot be used, then a linear search - * is used. - * - * Note that the value_string array used with VALUE_STRING_EXT_INIT - * *must* be terminated with {0, NULL}). - * - * Extended value strings are defined at compile time as follows: - * static const value_string vs[] = { {value1, "string1"}, {value2, "string2"}, ..., {0, NULL}}; - * static value_string_ext vse = VALUE_STRING_EXT_INIT(vs); - * - * Extended value strings can be created at runtime by calling - * value_string_ext_new(, - * , - * ); - * Note: should include the {0, NULL} entry - */ -/* --------------------------------------------------------------------*/ struct _value_string_ext; typedef const value_string *(*_value_string_match2_t)(const guint32, const struct _value_string_ext *); @@ -127,50 +65,78 @@ typedef struct _value_string_ext { const gchar *_vs_name; /* vse "Name" (for error messages) */ } value_string_ext; -/* "Accessors" */ #define VALUE_STRING_EXT_VS_P(x) (x)->_vs_p #define VALUE_STRING_EXT_VS_NUM_ENTRIES(x) (x)->_vs_num_entries #define VALUE_STRING_EXT_VS_NAME(x) (x)->_vs_name -/* (Fcns for use by proto_registrar_dump_values() [See proto.c]) */ +WS_DLL_PUBLIC +const value_string* +_try_val_to_str_ext_init(const guint32 val, const value_string_ext *vse); +#define VALUE_STRING_EXT_INIT(x) { _try_val_to_str_ext_init, 0, array_length(x)-1, x, #x } + +WS_DLL_PUBLIC +value_string_ext* +value_string_ext_new(value_string *vs, guint vs_tot_num_entries, const gchar *vs_name); + +WS_DLL_PUBLIC +const gchar* +val_to_str_ext(const guint32 val, const value_string_ext *vs, const char *fmt); + +WS_DLL_PUBLIC +const gchar* +val_to_str_ext_const(const guint32 val, const value_string_ext *vs, const char *unknown_str); + +WS_DLL_PUBLIC +const gchar* +try_val_to_str_ext(const guint32 val, const value_string_ext *vse); + +WS_DLL_PUBLIC +const gchar* +try_val_to_str_idx_ext(const guint32 val, value_string_ext *vse, gint *idx); + +/* STRING TO STRING MATCHING */ + +typedef struct _string_string { + const gchar *value; + const gchar *strptr; +} string_string; + +WS_DLL_PUBLIC +const gchar* +str_to_str(const gchar *val, const string_string *vs, const char *fmt); + +WS_DLL_PUBLIC +const gchar* +try_str_to_str(const gchar *val, const string_string *vs); + +WS_DLL_PUBLIC +const gchar* +try_str_to_str_idx(const gchar *val, const string_string *vs, gint *idx); + +/* RANGE TO STRING MATCHING */ + +typedef struct _range_string { + guint32 value_min; + guint32 value_max; + const gchar *strptr; +} range_string; + +WS_DLL_PUBLIC +const gchar* +rval_to_str(const guint32 val, const range_string *rs, const char *fmt); + +WS_DLL_PUBLIC +const gchar* +try_rval_to_str(const guint32 val, const range_string *rs); + +WS_DLL_PUBLIC +const gchar* +try_rval_to_str_idx(const guint32 val, const range_string *rs, gint *idx); + +/* MISC (generally do not use) */ + gboolean value_string_ext_validate(const value_string_ext *vse); const gchar *value_string_ext_match_type_str(const value_string_ext *vse); -/* --- --- */ - -WS_DLL_PUBLIC const value_string *_match_strval_ext_init(const guint32 val, const value_string_ext *vse); -#define VALUE_STRING_EXT_INIT(x) { _match_strval_ext_init, 0, array_length(x)-1, x, #x } - -/* Create a value_string_ext given a ptr to a value_string array and the total number of entries. */ -/* Note: vs_tot_num_entries should include the required {0, NULL} terminating entry of the array. */ -/* Return: a pointer to a gmalloc'd and initialized value_string_ext struct. */ -extern value_string_ext *value_string_ext_new(value_string *vs, guint vs_tot_num_entries, const gchar *vs_name); - -/* Looks up val in a value_string array using access method (direct, binary search - * or linear) determined at rutime during the initial access); (see _match_strval_ext_init) - * Returns the associated string ptr on a match or NULL on failure. - */ -WS_DLL_PUBLIC const gchar* match_strval_ext(const guint32 val, const value_string_ext *vse); - -/* Tries to match val against each element in the value_string array 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_ext(const guint32 val, value_string_ext *vse, gint *idx); - -/* - Similar to match_strval_ext except that on failure - * Formats val with fmt, and returns the resulting string - */ -WS_DLL_PUBLIC const gchar* val_to_str_ext(const guint32 val, const value_string_ext *vs, const char *fmt); - -/* - Similar to match_strval_ext except that on failure - * Returns 'unknown_str' - */ -WS_DLL_PUBLIC const gchar* val_to_str_ext_const(const guint32 val, const value_string_ext *vs, const char *unknown_str); - -/* ---- ---- */ /* Generate a string describing an enumerated bitfield (an N-bit field with various specific values having particular names). */ @@ -182,21 +148,4 @@ WS_DLL_PUBLIC const char *decode_enumerated_bitfield(const guint32 val, const gu WS_DLL_PUBLIC const char *decode_enumerated_bitfield_shifted(const guint32 val, const guint32 mask, const int width, const value_string *tab, const char *fmt); - -/* ranges aware versions */ - -/* Tries to match val against each range in the range_string array rs. - Returns the associated string ptr on a match. - Formats val with fmt, and returns the resulting string, on failure. */ -WS_DLL_PUBLIC const gchar* rval_to_str(const guint32 val, const range_string *rs, const char *fmt); - -/* Tries to match val against each range in the range_string array rs. - 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. */ -WS_DLL_PUBLIC const gchar *match_strrval_idx(const guint32 val, const range_string *rs, gint *idx); - -/* Like match_strrval_idx(), but doesn't return the index. */ -WS_DLL_PUBLIC const gchar *match_strrval(const guint32 val, const range_string *rs); - #endif /* __VALUE_STRING_H__ */ diff --git a/epan/xdlc.c b/epan/xdlc.c index f1a6e0f2de..d11ff0e699 100644 --- a/epan/xdlc.c +++ b/epan/xdlc.c @@ -207,11 +207,11 @@ check_xdlc_control(tvbuff_t *tvb, int offset, u_modifier_short_vals_resp = modifier_short_vals_resp; control = tvb_get_guint8(tvb, offset); if (is_response) { - if (match_strval(control & XDLC_U_MODIFIER_MASK, + if (try_val_to_str(control & XDLC_U_MODIFIER_MASK, u_modifier_short_vals_resp) == NULL) return FALSE; /* unknown modifier */ } else { - if (match_strval(control & XDLC_U_MODIFIER_MASK, + if (try_val_to_str(control & XDLC_U_MODIFIER_MASK, u_modifier_short_vals_cmd) == NULL) return FALSE; /* unknown modifier */ } diff --git a/plugins/ethercat/packet-ethercat-datagram.c b/plugins/ethercat/packet-ethercat-datagram.c index 68908e8c78..9299f47417 100644 --- a/plugins/ethercat/packet-ethercat-datagram.c +++ b/plugins/ethercat/packet-ethercat-datagram.c @@ -386,7 +386,7 @@ static void EcSummaryFormater(guint32 datalength, tvbuff_t *tvb, gint offset, ch static void EcCmdFormatter(guint8 cmd, char *szText, gint nMax) { gint idx=0; - const gchar *szCmd = match_strval_idx((guint32)cmd, EcCmdLong, &idx); + const gchar *szCmd = try_val_to_str_idx((guint32)cmd, EcCmdLong, &idx); if ( idx != -1 ) g_snprintf(szText, nMax, "Cmd : %d (%s)", cmd, szCmd); diff --git a/plugins/gryphon/packet-gryphon.c b/plugins/gryphon/packet-gryphon.c index d1bc014ca1..70c0a4bc40 100644 --- a/plugins/gryphon/packet-gryphon.c +++ b/plugins/gryphon/packet-gryphon.c @@ -816,7 +816,7 @@ dissect_gryphon_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, if (tree == NULL) return; - if (match_strval(frmtyp, frame_type) == NULL) { + if (try_val_to_str(frmtyp, frame_type) == NULL) { /* * Unknown message type. */ diff --git a/ui/cli/tap-wspstat.c b/ui/cli/tap-wspstat.c index a3a3a42057..165f78d0c8 100644 --- a/ui/cli/tap-wspstat.c +++ b/ui/cli/tap-wspstat.c @@ -249,7 +249,7 @@ wspstat_init(const char *optarg, void* userdata _U_) for (i=0;inum_pdus; i++) { sp->pdu_stats[i].packets=0; - sp->pdu_stats[i].type = match_strval_ext( index2pdut( i ), &wsp_vals_pdu_type_ext) ; + sp->pdu_stats[i].type = try_val_to_str_ext( index2pdut( i ), &wsp_vals_pdu_type_ext) ; } error_string = register_tap_listener( diff --git a/ui/export_object_smb.c b/ui/export_object_smb.c index bd2752db8c..dec3de9eca 100644 --- a/ui/export_object_smb.c +++ b/ui/export_object_smb.c @@ -310,7 +310,7 @@ gchar *aux_smb_fid_type_string; if (eo_info->smbversion==1) { /* Is this an eo_smb supported file_type? (right now we only support FILE) */ is_supported_filetype = (eo_info->fid_type == SMB_FID_TYPE_FILE); - aux_smb_fid_type_string=g_strdup(match_strval(eo_info->fid_type, smb_fid_types)); + aux_smb_fid_type_string=g_strdup(try_val_to_str(eo_info->fid_type, smb_fid_types)); /* What kind of data this packet contains? */ switch(eo_info->cmd) { @@ -329,7 +329,7 @@ gchar *aux_smb_fid_type_string; } else { /* Is this an eo_smb supported file_type? (right now we only support FILE) */ is_supported_filetype = (eo_info->fid_type == SMB2_FID_TYPE_FILE ); - aux_smb_fid_type_string=g_strdup(match_strval(eo_info->fid_type, smb2_fid_types)); + aux_smb_fid_type_string=g_strdup(try_val_to_str(eo_info->fid_type, smb2_fid_types)); /* What kind of data this packet contains? */ switch(eo_info->cmd) { @@ -382,7 +382,7 @@ gchar *aux_smb_fid_type_string; aux_smb_fid_type_string, new_file->data_gathered, new_file->file_length, - match_strval(contains, smb_eo_contains_string)); + try_val_to_str(contains, smb_eo_contains_string)); } else { if (new_file->file_length > 0) { percent = (gfloat) (100*new_file->data_gathered/new_file->file_length); @@ -395,7 +395,7 @@ gchar *aux_smb_fid_type_string; aux_smb_fid_type_string, new_file->data_gathered, new_file->file_length, - match_strval(contains, smb_eo_contains_string), + try_val_to_str(contains, smb_eo_contains_string), percent); } @@ -417,7 +417,7 @@ gchar *aux_smb_fid_type_string; aux_smb_fid_type_string, current_file->data_gathered, current_file->file_length, - match_strval(current_file->flag_contains, smb_eo_contains_string)); + try_val_to_str(current_file->flag_contains, smb_eo_contains_string)); } else { percent = (gfloat) (100*current_file->data_gathered/current_file->file_length); current_entry->content_type = @@ -425,7 +425,7 @@ gchar *aux_smb_fid_type_string; aux_smb_fid_type_string, current_file->data_gathered, current_file->file_length, - match_strval(current_file->flag_contains, smb_eo_contains_string), + try_val_to_str(current_file->flag_contains, smb_eo_contains_string), percent); } } diff --git a/ui/gtk/expert_comp_dlg.c b/ui/gtk/expert_comp_dlg.c index 517f10f3f5..b7772f4353 100644 --- a/ui/gtk/expert_comp_dlg.c +++ b/ui/gtk/expert_comp_dlg.c @@ -681,11 +681,11 @@ expert_dlg_draw(void *data) packet_no = ei->packet_num; } - /* match_strval return a static string or NULL + /* try_val_to_str return a static string or NULL severity */ - severity_str = match_strval(ei->severity, expert_severity_vals); + severity_str = try_val_to_str(ei->severity, expert_severity_vals); /* group */ - group_str = match_strval(ei->group, expert_group_vals); + group_str = try_val_to_str(ei->group, expert_group_vals); /* protocol */ if(ei->protocol) { diff --git a/ui/gtk/expert_comp_table.c b/ui/gtk/expert_comp_table.c index 2c27ff33ab..718983858d 100644 --- a/ui/gtk/expert_comp_table.c +++ b/ui/gtk/expert_comp_table.c @@ -769,9 +769,9 @@ init_error_table_row(error_equiv_table *err, const expert_info_t *expert_data) store = GTK_TREE_STORE(gtk_tree_view_get_model(err->tree_view)); /* Get store */ gtk_tree_store_append (store, &procedure->iter, NULL); /* Acquire an iterator */ - /* match_strval return a static constant or null */ + /* try_val_to_str return a static constant or null */ gtk_tree_store_set (store, &procedure->iter, - GROUP_COLUMN, match_strval(expert_data->group, expert_group_vals), + GROUP_COLUMN, try_val_to_str(expert_data->group, expert_group_vals), PROTOCOL_COLUMN, procedure->entries[0], SUMMARY_COLUMN, procedure->entries[1], -1); diff --git a/ui/gtk/rtp_player.c b/ui/gtk/rtp_player.c index e710db026e..31e792537a 100644 --- a/ui/gtk/rtp_player.c +++ b/ui/gtk/rtp_player.c @@ -498,7 +498,7 @@ decode_rtp_packet(rtp_packet_t *rp, SAMPLE **out_buff, GHashTable *decoders_hash decoder = g_new(rtp_decoder_t,1); decoder->handle = NULL; decoder->context = NULL; - p = match_strval_ext(payload_type, &rtp_payload_type_short_vals_ext); + p = try_val_to_str_ext(payload_type, &rtp_payload_type_short_vals_ext); if (p) { decoder->handle = find_codec(p); if (decoder->handle) diff --git a/ui/gtk/wsp_stat.c b/ui/gtk/wsp_stat.c index f5353dd1df..a4c52b948f 100644 --- a/ui/gtk/wsp_stat.c +++ b/ui/gtk/wsp_stat.c @@ -261,10 +261,10 @@ wsp_init_table(wspstat_t *sp) /* Maybe we should display the hexadecimal value ? */ #if 0 g_snprintf(buffer, sizeof(buffer), "%s (0X%x)", - match_strval_ext(index2pdut(i), &wsp_vals_pdu_type_ext), index2pdut(i)); + try_val_to_str_ext(index2pdut(i), &wsp_vals_pdu_type_ext), index2pdut(i)); #endif add_table_entry(sp, - match_strval_ext(index2pdut(i), &wsp_vals_pdu_type_ext), /* or buffer, */ + try_val_to_str_ext(index2pdut(i), &wsp_vals_pdu_type_ext), /* or buffer, */ x, pos, 0