From 7b845e719444a8f7bc92759c98ca2a07d8af13df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Valverde?= Date: Thu, 29 Jul 2021 02:21:35 +0100 Subject: [PATCH] wsutil: rename bytestring_to_str() -> bytes_to_str_punct() --- debian/libwsutil0.symbols | 2 +- epan/dissectors/asn1/h248/h248.cnf | 4 ++-- epan/dissectors/asn1/snmp/snmp.cnf | 2 +- epan/dissectors/packet-data.c | 2 +- epan/dissectors/packet-frame.c | 2 +- epan/dissectors/packet-h248.c | 4 ++-- epan/dissectors/packet-ismp.c | 2 +- epan/dissectors/packet-mswsp.c | 2 +- epan/dissectors/packet-rtps-virtual-transport.c | 2 +- epan/dissectors/packet-snmp.c | 2 +- epan/oids.c | 6 +++--- epan/proto.c | 10 +++++----- epan/tvbuff.c | 2 +- plugins/epan/wimaxasncp/packet-wimaxasncp.c | 8 ++++---- wsutil/test_wsutil.c | 6 +++--- wsutil/to_str.c | 6 +++--- wsutil/to_str.h | 4 ++-- 17 files changed, 33 insertions(+), 33 deletions(-) diff --git a/debian/libwsutil0.symbols b/debian/libwsutil0.symbols index d39392fbd3..22e98365f8 100644 --- a/debian/libwsutil0.symbols +++ b/debian/libwsutil0.symbols @@ -11,7 +11,7 @@ libwsutil.so.0 libwsutil0 #MINVER# bytes_to_hexstr@Base 3.5.0 bytes_to_hexstr_punct@Base 3.5.0 bytes_to_str_max@Base 3.5.0 - bytestring_to_str_max@Base 3.5.0 + bytes_to_str_punct_max@Base 3.5.0 codec_decode@Base 3.1.0 codec_get_channels@Base 3.1.0 codec_get_frequency@Base 3.1.0 diff --git a/epan/dissectors/asn1/h248/h248.cnf b/epan/dissectors/asn1/h248/h248.cnf index 6f457c2875..7cb58c325b 100644 --- a/epan/dissectors/asn1/h248/h248.cnf +++ b/epan/dissectors/asn1/h248/h248.cnf @@ -362,10 +362,10 @@ SigParameterV1/value ABBREV=sig_param_value curr_info.term->buffer = (guint8 *)tvb_memdup(actx->pinfo->pool,new_tvb,0,curr_info.term->len); if(term_info.str){ curr_info.term->str = wmem_strdup_printf(actx->pinfo->pool, "%s %s", - bytestring_to_str(actx->pinfo->pool,curr_info.term->buffer,curr_info.term->len, 0), + bytes_to_str_punct(actx->pinfo->pool,curr_info.term->buffer,curr_info.term->len, 0), term_info.str); }else{ - curr_info.term->str = bytestring_to_str(actx->pinfo->pool,curr_info.term->buffer,curr_info.term->len, 0); + curr_info.term->str = bytes_to_str_punct(actx->pinfo->pool,curr_info.term->buffer,curr_info.term->len, 0); } } diff --git a/epan/dissectors/asn1/snmp/snmp.cnf b/epan/dissectors/asn1/snmp/snmp.cnf index a090c2a3b4..fe7947a32e 100644 --- a/epan/dissectors/asn1/snmp/snmp.cnf +++ b/epan/dissectors/asn1/snmp/snmp.cnf @@ -221,7 +221,7 @@ BulkPDU/request-id bulkPDU_request-id if (usm_p.authOK) { expert = &ei_snmp_authentication_ok; } else { - const gchar* calc_auth_str = bytestring_to_str(actx->pinfo->pool, calc_auth,calc_auth_len,' '); + const gchar* calc_auth_str = bytes_to_str_punct(actx->pinfo->pool, calc_auth,calc_auth_len,' '); proto_item_append_text(authen_item, " calculated = %s", calc_auth_str); expert = &ei_snmp_authentication_error; } diff --git a/epan/dissectors/packet-data.c b/epan/dissectors/packet-data.c index b626cd95e1..b8b73e958d 100644 --- a/epan/dissectors/packet-data.c +++ b/epan/dissectors/packet-data.c @@ -113,7 +113,7 @@ dissect_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_ cp = tvb_get_ptr(tvb, 0, bytes); gcry_md_hash_buffer(GCRY_MD_MD5, digest, cp, bytes); - digest_string = bytestring_to_str(pinfo->pool, digest, HASH_MD5_LENGTH, '\0'); + digest_string = bytes_to_str_punct(pinfo->pool, digest, HASH_MD5_LENGTH, '\0'); ti = proto_tree_add_string(data_tree, &hfi_data_md5_hash, tvb, 0, 0, digest_string); proto_item_set_generated(ti); } diff --git a/epan/dissectors/packet-frame.c b/epan/dissectors/packet-frame.c index 98dbf7114f..41b178ccd3 100644 --- a/epan/dissectors/packet-frame.c +++ b/epan/dissectors/packet-frame.c @@ -739,7 +739,7 @@ dissect_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* cp = tvb_get_ptr(tvb, 0, cap_len); gcry_md_hash_buffer(GCRY_MD_MD5, digest, cp, cap_len); - digest_string = bytestring_to_str(pinfo->pool, digest, HASH_MD5_LENGTH, '\0'); + digest_string = bytes_to_str_punct(pinfo->pool, digest, HASH_MD5_LENGTH, '\0'); ti = proto_tree_add_string(fh_tree, hf_frame_md5_hash, tvb, 0, 0, digest_string); proto_item_set_generated(ti); } diff --git a/epan/dissectors/packet-h248.c b/epan/dissectors/packet-h248.c index 67a6f9cf3d..d27797a3af 100644 --- a/epan/dissectors/packet-h248.c +++ b/epan/dissectors/packet-h248.c @@ -2981,10 +2981,10 @@ dissect_h248_T_terminationId(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int o curr_info.term->buffer = (guint8 *)tvb_memdup(actx->pinfo->pool,new_tvb,0,curr_info.term->len); if(term_info.str){ curr_info.term->str = wmem_strdup_printf(actx->pinfo->pool, "%s %s", - bytestring_to_str(actx->pinfo->pool,curr_info.term->buffer,curr_info.term->len, 0), + bytes_to_str_punct(actx->pinfo->pool,curr_info.term->buffer,curr_info.term->len, 0), term_info.str); }else{ - curr_info.term->str = bytestring_to_str(actx->pinfo->pool,curr_info.term->buffer,curr_info.term->len, 0); + curr_info.term->str = bytes_to_str_punct(actx->pinfo->pool,curr_info.term->buffer,curr_info.term->len, 0); } } diff --git a/epan/dissectors/packet-ismp.c b/epan/dissectors/packet-ismp.c index c5253873cc..258eb7b8ee 100644 --- a/epan/dissectors/packet-ismp.c +++ b/epan/dissectors/packet-ismp.c @@ -220,7 +220,7 @@ ipx_addr_to_str(const guint32 net, const guint8 *ad) else { buf = wmem_strdup_printf(wmem_packet_scope(), "%s.%s", get_ipxnet_name(wmem_packet_scope(), net), - bytestring_to_str(wmem_packet_scope(), ad, 6, '\0')); + bytes_to_str_punct(wmem_packet_scope(), ad, 6, '\0')); } return buf; } diff --git a/epan/dissectors/packet-mswsp.c b/epan/dissectors/packet-mswsp.c index f414b5b137..9ff7cec8f9 100644 --- a/epan/dissectors/packet-mswsp.c +++ b/epan/dissectors/packet-mswsp.c @@ -3044,7 +3044,7 @@ static int parse_guid(tvbuff_t *tvb, int offset, proto_tree *tree, e_guid_t *gui offset += 1; proto_tree_add_item(tr, hf_mswsp_guid_time_clock_low, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset += 1; - bytes = bytestring_to_str(wmem_packet_scope(), &guid->data4[2], 6, ':'); + bytes = bytes_to_str_punct(wmem_packet_scope(), &guid->data4[2], 6, ':'); proto_tree_add_string(tr, hf_mswsp_guid_node, tvb, offset, 6, bytes); offset += 6; diff --git a/epan/dissectors/packet-rtps-virtual-transport.c b/epan/dissectors/packet-rtps-virtual-transport.c index 2ceb294189..7e767e1b46 100644 --- a/epan/dissectors/packet-rtps-virtual-transport.c +++ b/epan/dissectors/packet-rtps-virtual-transport.c @@ -494,7 +494,7 @@ static gint dissect_parameter_transport_rtps_type( tvb, OFFSET_TO_VAL, param_length); - const gchar *guid_string = bytestring_to_str( + const gchar *guid_string = bytes_to_str_punct( pinfo->pool, guid_bytes, MIN(param_length, 12), diff --git a/epan/dissectors/packet-snmp.c b/epan/dissectors/packet-snmp.c index e090a4f6c3..1b847bbb09 100644 --- a/epan/dissectors/packet-snmp.c +++ b/epan/dissectors/packet-snmp.c @@ -2869,7 +2869,7 @@ dissect_snmp_SNMPv3Message(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int off if (usm_p.authOK) { expert = &ei_snmp_authentication_ok; } else { - const gchar* calc_auth_str = bytestring_to_str(actx->pinfo->pool, calc_auth,calc_auth_len,' '); + const gchar* calc_auth_str = bytes_to_str_punct(actx->pinfo->pool, calc_auth,calc_auth_len,' '); proto_item_append_text(authen_item, " calculated = %s", calc_auth_str); expert = &ei_snmp_authentication_error; } diff --git a/epan/oids.c b/epan/oids.c index b80c79a801..799f2e147b 100644 --- a/epan/oids.c +++ b/epan/oids.c @@ -194,7 +194,7 @@ extern void oid_add_from_encoded(const char* name, const guint8 *oid, gint oid_l add_oid(name,OID_KIND_UNKNOWN,NULL,NULL,subids_len,subids); wmem_free(NULL, sub); } else { - gchar* bytestr = bytestring_to_str(NULL, oid, oid_len, ':'); + gchar* bytestr = bytes_to_str_punct(NULL, oid, oid_len, ':'); D(1,("Failed to add Oid: %s [%d]%s ",name?name:"NULL", oid_len, bytestr)); wmem_free(NULL, bytestr); } @@ -1342,10 +1342,10 @@ char* oid_test_a2b(guint32 num_subids, guint32* subids) { "oid_string2encoded=[%d]%s \n" "oid_string2subid=%s \n " ,sub2str - ,sub2enc_len,bytestring_to_str(wmem_packet_scope(), sub2enc, sub2enc_len, ':') + ,sub2enc_len,bytes_to_str_punct(wmem_packet_scope(), sub2enc, sub2enc_len, ':') ,enc2sub ? oid_subid2string(wmem_packet_scope(), enc2sub,enc2sub_len) : "-" ,enc2str - ,str2enc_len,bytestring_to_str(wmem_packet_scope(), str2enc, str2enc_len, ':') + ,str2enc_len,bytes_to_str_punct(wmem_packet_scope(), str2enc, str2enc_len, ':') ,str2sub ? oid_subid2string(wmem_packet_scope(), str2sub,str2sub_len) : "-" ); diff --git a/epan/proto.c b/epan/proto.c index 3eaf21da78..9423faa3f9 100644 --- a/epan/proto.c +++ b/epan/proto.c @@ -1080,21 +1080,21 @@ hfinfo_format_bytes(wmem_allocator_t *scope, const header_field_info *hfinfo, */ switch (FIELD_DISPLAY(hfinfo->display)) { case SEP_DOT: - str = bytestring_to_str(scope, bytes, length, '.'); + str = bytes_to_str_punct(scope, bytes, length, '.'); break; case SEP_DASH: - str = bytestring_to_str(scope, bytes, length, '-'); + str = bytes_to_str_punct(scope, bytes, length, '-'); break; case SEP_COLON: - str = bytestring_to_str(scope, bytes, length, ':'); + str = bytes_to_str_punct(scope, bytes, length, ':'); break; case SEP_SPACE: - str = bytestring_to_str(scope, bytes, length, ' '); + str = bytes_to_str_punct(scope, bytes, length, ' '); break; case BASE_NONE: default: if (prefs.display_byte_fields_with_spaces) { - str = bytestring_to_str(scope, bytes, length, ' '); + str = bytes_to_str_punct(scope, bytes, length, ' '); } else { str = bytes_to_str(scope, bytes, length); } diff --git a/epan/tvbuff.c b/epan/tvbuff.c index d3a0e0d713..7a1d7956b9 100644 --- a/epan/tvbuff.c +++ b/epan/tvbuff.c @@ -4214,7 +4214,7 @@ int tvb_get_token_len(tvbuff_t *tvb, const gint offset, int len, gint *next_offs gchar * tvb_bytes_to_str_punct(wmem_allocator_t *scope, tvbuff_t *tvb, const gint offset, const gint len, const gchar punct) { - return bytestring_to_str(scope, ensure_contiguous(tvb, offset, len), len, punct); + return bytes_to_str_punct(scope, ensure_contiguous(tvb, offset, len), len, punct); } /* diff --git a/plugins/epan/wimaxasncp/packet-wimaxasncp.c b/plugins/epan/wimaxasncp/packet-wimaxasncp.c index b624a88192..76b6ed5f35 100644 --- a/plugins/epan/wimaxasncp/packet-wimaxasncp.c +++ b/plugins/epan/wimaxasncp/packet-wimaxasncp.c @@ -1043,7 +1043,7 @@ static void wimaxasncp_dissect_tlv_value( const gchar *format1; const gchar *format2; const guint8 *p = tvb_get_ptr(tvb, offset, length); - const gchar *s = bytestring_to_str(wmem_packet_scope(), p, MIN(length, max_show_bytes), 0); + const gchar *s = bytes_to_str_punct(wmem_packet_scope(), p, MIN(length, max_show_bytes), 0); if (length <= max_show_bytes) { @@ -1223,7 +1223,7 @@ static void wimaxasncp_dissect_tlv_value( { const gchar *format; const guint8 *p = tvb_get_ptr(tvb, offset, length); - const gchar *s = bytestring_to_str(wmem_packet_scope(), p, MIN(length, max_show_bytes), 0); + const gchar *s = bytes_to_str_punct(wmem_packet_scope(), p, MIN(length, max_show_bytes), 0); if (length <= max_show_bytes) { @@ -1712,7 +1712,7 @@ static void wimaxasncp_dissect_tlv_value( const gchar *format2; const guint8 *p = tvb_get_ptr(tvb, offset, length); const gchar *s = - bytestring_to_str(wmem_packet_scope(), p, MIN(length, max_show_bytes), 0); + bytes_to_str_punct(wmem_packet_scope(), p, MIN(length, max_show_bytes), 0); if (length <= max_show_bytes) { @@ -1752,7 +1752,7 @@ static void wimaxasncp_dissect_tlv_value( { const gchar *format; const guint8 *p = tvb_get_ptr(tvb, offset, length); - const gchar *s = bytestring_to_str(wmem_packet_scope(), p, MIN(length, max_show_bytes), 0); + const gchar *s = bytes_to_str_punct(wmem_packet_scope(), p, MIN(length, max_show_bytes), 0); if (length <= max_show_bytes) { diff --git a/wsutil/test_wsutil.c b/wsutil/test_wsutil.c index 9174e98d65..9ad6100ab7 100644 --- a/wsutil/test_wsutil.c +++ b/wsutil/test_wsutil.c @@ -45,13 +45,13 @@ void test_bytes_to_str(void) g_free(str); } -void test_bytestring_to_str(void) +void test_bytes_to_str_punct(void) { char *str; const guint8 buf[] = { 1, 2, 3}; - str = bytestring_to_str(NULL, buf, sizeof(buf), ':'); + str = bytes_to_str_punct(NULL, buf, sizeof(buf), ':'); g_assert_cmpstr(str, ==, "01:02:03"); g_free(str); } @@ -89,7 +89,7 @@ int main(int argc, char **argv) g_test_add_func("/str_util/format_size", test_format_size); g_test_add_func("/to_str/bytes_to_str", test_bytes_to_str); - g_test_add_func("/to_str/bytestring_to_str", test_bytestring_to_str); + g_test_add_func("/to_str/bytes_to_str_punct", test_bytes_to_str_punct); g_test_add_func("/to_str/bytes_to_str_trunc1", test_bytes_to_string_trunc1); ret = g_test_run(); diff --git a/wsutil/to_str.c b/wsutil/to_str.c index 11295aff37..5f8e753c86 100644 --- a/wsutil/to_str.c +++ b/wsutil/to_str.c @@ -102,7 +102,7 @@ bytes_to_hexstr_punct(char *out, const guint8 *ad, size_t len, char punct) * the resulting string is (len-1) bytes shorter) */ gchar * -bytestring_to_str_max(wmem_allocator_t *scope, const guint8 *ad, size_t len, const char punct, size_t max) +bytes_to_str_punct_max(wmem_allocator_t *scope, const guint8 *ad, size_t len, const char punct, size_t max) { gchar *buf; size_t buflen = len; @@ -110,12 +110,12 @@ bytestring_to_str_max(wmem_allocator_t *scope, const guint8 *ad, size_t len, con int truncated = 0; if (len == 0) { - ws_warning("Zero length passed to bytestring_to_str()"); + ws_warning("Zero length passed to bytes_to_str_punct()"); return wmem_strdup(scope, "(zero length)"); } if (!ad) { - ws_warning("Null pointer passed to bytestring_to_str()"); + ws_warning("Null pointer passed to bytes_to_str_punct()"); return wmem_strdup(scope, "(null pointer)"); } diff --git a/wsutil/to_str.h b/wsutil/to_str.h index b4037f8824..54eacf89af 100644 --- a/wsutil/to_str.h +++ b/wsutil/to_str.h @@ -58,9 +58,9 @@ WS_DLL_PUBLIC char *bytes_to_hexstr_punct(char *out, const guint8 *ad, size_t le * * @see bytes_to_str() */ -WS_DLL_PUBLIC gchar *bytestring_to_str_max(wmem_allocator_t *scope, const guint8 *ad, size_t len, const char punct, size_t max); +WS_DLL_PUBLIC gchar *bytes_to_str_punct_max(wmem_allocator_t *scope, const guint8 *ad, size_t len, const char punct, size_t max); -#define bytestring_to_str(scope, ad, len, punct) bytestring_to_str_max(scope, ad, len, punct, MAX_BYTE_STR_LEN) +#define bytes_to_str_punct(scope, ad, len, punct) bytes_to_str_punct_max(scope, ad, len, punct, MAX_BYTE_STR_LEN) /** Turn an array of bytes into a string showing the bytes in hex. *