diff options
-rw-r--r-- | epan/asn1.c | 3 | ||||
-rw-r--r-- | epan/column.c | 5 | ||||
-rw-r--r-- | epan/dfilter/dfilter-macro.c | 61 | ||||
-rw-r--r-- | epan/dfilter/dfilter.c | 8 | ||||
-rw-r--r-- | epan/dfilter/gencode.c | 2 | ||||
-rw-r--r-- | epan/dfilter/semcheck.c | 8 | ||||
-rw-r--r-- | epan/dissectors/packet-beep.c | 7 | ||||
-rw-r--r-- | epan/dissectors/packet-ber.c | 69 | ||||
-rw-r--r-- | epan/dissectors/packet-giop.c | 111 | ||||
-rw-r--r-- | epan/dissectors/packet-tacacs.c | 21 | ||||
-rw-r--r-- | epan/dissectors/packet-wtp.c | 4 | ||||
-rw-r--r-- | epan/except.c | 15 | ||||
-rw-r--r-- | epan/packet.c | 21 | ||||
-rw-r--r-- | epan/proto.c | 33 | ||||
-rw-r--r-- | epan/reedsolomon.c | 9 | ||||
-rw-r--r-- | epan/tvbuff_zlib.c | 9 | ||||
-rw-r--r-- | epan/wslua/init_wslua.c | 3 | ||||
-rw-r--r-- | epan/wslua/wslua_internals.c | 5 | ||||
-rw-r--r-- | plugins/wimaxasncp/packet-wimaxasncp.c | 3 | ||||
-rw-r--r-- | ws_version_info.c | 3 | ||||
-rw-r--r-- | wsutil/plugins.c | 3 | ||||
-rw-r--r-- | wsutil/sha1.c | 17 | ||||
-rw-r--r-- | wsutil/ws_printf.h | 8 |
23 files changed, 234 insertions, 194 deletions
diff --git a/epan/asn1.c b/epan/asn1.c index c2f718d732..6581e42da7 100644 --- a/epan/asn1.c +++ b/epan/asn1.c @@ -30,6 +30,7 @@ #include <math.h> #ifdef DEBUG #include <stdio.h> +#include <wsutil/ws_printf.h> /* ws_debug_printf */ #endif #include <epan/packet.h> @@ -272,7 +273,7 @@ double asn1_get_real(const guint8 *real_ptr, gint len) { } val = (double) S * N * pow(2, F) * pow(B, E); #ifdef DEBUG - printf("S = %d, N = %lu, F = %u, B = %u, E = %d -> %f\n", S, N, F, B, E, val); + ws_debug_printf("S = %d, N = %lu, F = %u, B = %u, E = %d -> %f\n", S, N, F, B, E, val); #endif } else if (octet & 0x40) { /* SpecialRealValue */ switch (octet & 0x3F) { diff --git a/epan/column.c b/epan/column.c index 709ab6bc64..1f7b2fa518 100644 --- a/epan/column.c +++ b/epan/column.c @@ -35,6 +35,7 @@ #include <epan/dfilter/dfilter.h> #include <epan/column.h> #include <epan/packet.h> +#include <wsutil/ws_printf.h> /* ws_debug_printf */ /* Given a format number (as defined in column-utils.h), returns its equivalent string */ @@ -183,10 +184,10 @@ column_dump_column_formats(void) gint fmt; for (fmt = 0; fmt < NUM_COL_FMTS; fmt++) { - printf("%s\t%s\n", col_format_to_string(fmt), col_format_desc(fmt)); + ws_debug_printf("%s\t%s\n", col_format_to_string(fmt), col_format_desc(fmt)); } - printf("\nFor example, to print Wireshark's default columns with tshark:\n\n" + ws_debug_printf("\nFor example, to print Wireshark's default columns with tshark:\n\n" #ifdef _WIN32 "tshark.exe -o \"gui.column.format:" "\\\"No.\\\",\\\"%%m\\\"," diff --git a/epan/dfilter/dfilter-macro.c b/epan/dfilter/dfilter-macro.c index 74c90e0f04..18f7b968f7 100644 --- a/epan/dfilter/dfilter-macro.c +++ b/epan/dfilter/dfilter-macro.c @@ -24,6 +24,7 @@ #ifdef DUMP_DFILTER_MACRO #include <stdio.h> +#include <wsutil/ws_printf.h> /* ws_debug_printf */ #endif #include <string.h> @@ -620,69 +621,69 @@ void dfilter_macro_get_uat(uat_t **dfmu_ptr_ptr) { void dump_dfilter_macro_t(const dfilter_macro_t *m, const char *function, const char *file, int line) { - printf("\n<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n"); + ws_debug_printf("\n<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n"); if(m == NULL) { - printf(" dfilter_macro_t * == NULL! (via: %s(): %s:%d)\n", function, file, line); - printf("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"); + ws_debug_printf(" dfilter_macro_t * == NULL! (via: %s(): %s:%d)\n", function, file, line); + ws_debug_printf("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"); } - printf("DUMP of dfilter_macro_t: %p (via: %s(): %s:%d)\n", m, function, file, line); + ws_debug_printf("DUMP of dfilter_macro_t: %p (via: %s(): %s:%d)\n", m, function, file, line); - printf(" &dfilter_macro->name == %p\n", &m->name); + ws_debug_printf(" &dfilter_macro->name == %p\n", &m->name); if(m->name == NULL) { - printf(" ->name == NULL\n"); + ws_debug_printf(" ->name == NULL\n"); } else { - printf(" ->name == %p\n", m->name); - printf(" ->name == <%s>\n", m->name); + ws_debug_printf(" ->name == %p\n", m->name); + ws_debug_printf(" ->name == <%s>\n", m->name); } - printf(" &dfilter_macro->text == %p\n", &m->text); + ws_debug_printf(" &dfilter_macro->text == %p\n", &m->text); if(m->text == NULL) { - printf(" ->text == NULL\n"); + ws_debug_printf(" ->text == NULL\n"); } else { - printf(" ->text == %p\n", m->text); - printf(" ->text == <%s>\n", m->text); + ws_debug_printf(" ->text == %p\n", m->text); + ws_debug_printf(" ->text == <%s>\n", m->text); } - printf(" &dfilter_macro->usable == %p\n", &m->usable); - printf(" ->usable == %u\n", m->usable); + ws_debug_printf(" &dfilter_macro->usable == %p\n", &m->usable); + ws_debug_printf(" ->usable == %u\n", m->usable); - printf(" &dfilter_macro->parts == %p\n", &m->parts); + ws_debug_printf(" &dfilter_macro->parts == %p\n", &m->parts); if(m->parts == NULL) { - printf(" ->parts == NULL\n"); + ws_debug_printf(" ->parts == NULL\n"); } else { int i = 0; while (m->parts[i]) { - printf(" ->parts[%d] == %p\n", i, m->parts[i]); - printf(" ->parts[%d] == <%s>\n", i, m->parts[i]); + ws_debug_printf(" ->parts[%d] == %p\n", i, m->parts[i]); + ws_debug_printf(" ->parts[%d] == <%s>\n", i, m->parts[i]); i++; } - printf(" ->parts[%d] == NULL\n", i); + ws_debug_printf(" ->parts[%d] == NULL\n", i); } - printf(" &dfilter_macro->args_pos == %p\n", &m->args_pos); + ws_debug_printf(" &dfilter_macro->args_pos == %p\n", &m->args_pos); if(m->args_pos == NULL) { - printf(" ->args_pos == NULL\n"); + ws_debug_printf(" ->args_pos == NULL\n"); } else { - printf(" ->args_pos == %p\n", m->args_pos); - /*printf(" ->args_pos == <%?>\n", m->args_pos);*/ + ws_debug_printf(" ->args_pos == %p\n", m->args_pos); + /*ws_debug_printf(" ->args_pos == <%?>\n", m->args_pos);*/ } - printf(" &dfilter_macro->argc == %p\n", &m->argc); - printf(" ->argc == %d\n", m->argc); + ws_debug_printf(" &dfilter_macro->argc == %p\n", &m->argc); + ws_debug_printf(" ->argc == %d\n", m->argc); - printf(" &dfilter_macro->priv == %p\n", &m->priv); + ws_debug_printf(" &dfilter_macro->priv == %p\n", &m->priv); if(m->priv == NULL) { - printf(" ->priv == NULL\n"); + ws_debug_printf(" ->priv == NULL\n"); } else { - printf(" ->priv == %p\n", m->priv); - printf(" ->priv == <%s>\n", (char *)m->priv); + ws_debug_printf(" ->priv == %p\n", m->priv); + ws_debug_printf(" ->priv == <%s>\n", (char *)m->priv); } - printf("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"); + ws_debug_printf("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"); } #endif diff --git a/epan/dfilter/dfilter.c b/epan/dfilter/dfilter.c index 151bb5ec7d..3e1d558828 100644 --- a/epan/dfilter/dfilter.c +++ b/epan/dfilter/dfilter.c @@ -32,6 +32,8 @@ #include "dfilter.h" #include "dfilter-macro.h" #include "scanner_lex.h" +#include <wsutil/ws_printf.h> /* ws_debug_printf */ + #define DFILTER_TOKEN_ID_OFFSET 1 @@ -447,12 +449,12 @@ dfilter_dump(dfilter_t *df) dfvm_dump(stdout, df); if (df->deprecated && df->deprecated->len) { - printf("\nDeprecated tokens: "); + ws_debug_printf("\nDeprecated tokens: "); for (i = 0; i < df->deprecated->len; i++) { - printf("%s\"%s\"", sep, (char *) g_ptr_array_index(df->deprecated, i)); + ws_debug_printf("%s\"%s\"", sep, (char *) g_ptr_array_index(df->deprecated, i)); sep = ", "; } - printf("\n"); + ws_debug_printf("\n"); } } diff --git a/epan/dfilter/gencode.c b/epan/dfilter/gencode.c index 573b05aa85..f5d1223ae7 100644 --- a/epan/dfilter/gencode.c +++ b/epan/dfilter/gencode.c @@ -385,7 +385,7 @@ gen_entity(dfwork_t *dfw, stnode_t *st_arg, dfvm_value_t **p_jmp) reg = dfw_append_function(dfw, st_arg, p_jmp); } else { - printf("sttype_id is %u\n", (unsigned)e_type); + /* printf("sttype_id is %u\n", (unsigned)e_type); */ g_assert_not_reached(); } return reg; diff --git a/epan/dfilter/semcheck.c b/epan/dfilter/semcheck.c index b1fb17bec3..de7057451f 100644 --- a/epan/dfilter/semcheck.c +++ b/epan/dfilter/semcheck.c @@ -33,6 +33,10 @@ #include <epan/exceptions.h> #include <epan/packet.h> +#ifdef DEBUG_dfilter +#include <wsutil/ws_printf.h> /* ws_debug_printf */ +#endif + #include <ftypes/ftypes-int.h> /* Enable debug logging by defining AM_CFLAGS @@ -41,8 +45,8 @@ #ifdef DEBUG_dfilter #define DebugLog(x) \ - printf("%s:%u: ", __FILE__, __LINE__); \ - printf x; \ + ws_debug_printf("%s:%u: ", __FILE__, __LINE__); \ + ws_debug_printf x; \ fflush(stdout) #else #define DebugLog(x) ; diff --git a/epan/dissectors/packet-beep.c b/epan/dissectors/packet-beep.c index d3bae70d60..ba8a96e810 100644 --- a/epan/dissectors/packet-beep.c +++ b/epan/dissectors/packet-beep.c @@ -35,6 +35,9 @@ #include <epan/conversation.h> #include <epan/expert.h> #include <epan/proto_data.h> +#if defined(DEBUG_BEEP_HASH) +#include <wsutil/ws_printf.h> /* ws_debug_printf */ +#endif #define TCP_PORT_BEEP 10288 @@ -165,7 +168,7 @@ beep_equal(gconstpointer v, gconstpointer w) const struct beep_request_key *v2 = (const struct beep_request_key *)w; #if defined(DEBUG_BEEP_HASH) - printf("Comparing %08X\n and %08X\n", + ws_debug_printf("Comparing %08X\n and %08X\n", v1->conversation, v2->conversation); #endif @@ -185,7 +188,7 @@ beep_hash(gconstpointer v) val = key->conversation; #if defined(DEBUG_BEEP_HASH) - printf("BEEP Hash calculated as %u\n", val); + ws_debug_printf("BEEP Hash calculated as %u\n", val); #endif return val; diff --git a/epan/dissectors/packet-ber.c b/epan/dissectors/packet-ber.c index c2e4714836..dd1300e575 100644 --- a/epan/dissectors/packet-ber.c +++ b/epan/dissectors/packet-ber.c @@ -67,6 +67,9 @@ #include <epan/uat.h> #include <epan/decode_as.h> #include <wiretap/wtap.h> +#ifdef DEBUG_BER +#include <wsutil/ws_printf.h> /* ws_debug_printf */ +#endif #include "packet-ber.h" @@ -658,9 +661,9 @@ name = hfinfo->name; name = "unnamed"; } if (tvb_reported_length_remaining(tvb, offset) > 3) { -printf("dissect_ber_tagged_type(%s) entered implicit_tag:%d offset:%d len:%d %02x:%02x:%02x\n", name, implicit_tag, offset, tvb_reported_length_remaining(tvb, offset), tvb_get_guint8(tvb, offset), tvb_get_guint8(tvb, offset+1), tvb_get_guint8(tvb, offset+2)); +proto_tree_add_debug_text(tree, "dissect_ber_tagged_type(%s) entered implicit_tag:%d offset:%d len:%d %02x:%02x:%02x\n", name, implicit_tag, offset, tvb_reported_length_remaining(tvb, offset), tvb_get_guint8(tvb, offset), tvb_get_guint8(tvb, offset+1), tvb_get_guint8(tvb, offset+2)); } else { -printf("dissect_ber_tagged_type(%s) entered\n", name); +proto_tree_add_debug_text(tree, "dissect_ber_tagged_type(%s) entered\n", name); } } #endif @@ -1193,7 +1196,7 @@ get_ber_identifier(tvbuff_t *tvb, int offset, gint8 *ber_class, gboolean *pc, gi id = tvb_get_guint8(tvb, offset); offset += 1; #ifdef DEBUG_BER -printf ("BER ID=%02x", id); +ws_debug_printf("BER ID=%02x", id); #endif /* 8.1.2.2 */ tmp_class = (id >> 6) & 0x03; @@ -1205,7 +1208,7 @@ printf ("BER ID=%02x", id); while (tvb_reported_length_remaining(tvb, offset) > 0) { t = tvb_get_guint8(tvb, offset); #ifdef DEBUG_BER -printf (" %02x", t); +ws_debug_printf(" %02x", t); #endif offset += 1; tmp_tag <<= 7; @@ -1216,7 +1219,7 @@ printf (" %02x", t); } #ifdef DEBUG_BER -printf ("\n"); +ws_debug_printf("\n"); #endif if (ber_class) *ber_class = tmp_class; @@ -1354,7 +1357,7 @@ try_get_ber_length(tvbuff_t *tvb, int offset, guint32 *length, gboolean *ind, gi *ind = tmp_ind; #ifdef DEBUG_BER -printf("get BER length %d, offset %d (remaining %d)\n", tmp_length, offset, tvb_reported_length_remaining(tvb, offset)); +ws_debug_printf("get BER length %d, offset %d (remaining %d)\n", tmp_length, offset, tvb_reported_length_remaining(tvb, offset)); #endif return offset; @@ -1400,7 +1403,7 @@ dissect_ber_length(packet_info *pinfo _U_, proto_tree *tree, tvbuff_t *tvb, int *ind = tmp_ind; #ifdef DEBUG_BER -printf("dissect BER length %d, offset %d (remaining %d)\n", tmp_length, offset, tvb_reported_length_remaining(tvb, offset)); +proto_tree_add_debug_text("dissect BER length %d, offset %d (remaining %d)\n", tmp_length, offset, tvb_reported_length_remaining(tvb, offset)); #endif last_length = tmp_length; @@ -1555,9 +1558,9 @@ name = hfinfo->name; name = "unnamed"; } if (tvb_reported_length_remaining(tvb, offset) > 3) { -printf("OCTET STRING dissect_ber_octet string(%s) entered implicit_tag:%d offset:%d len:%d %02x:%02x:%02x\n", name, implicit_tag, offset, tvb_reported_length_remaining(tvb, offset), tvb_get_guint8(tvb, offset), tvb_get_guint8(tvb, offset+1), tvb_get_guint8(tvb, offset+2)); +proto_tree_add_debug_text(tree, "OCTET STRING dissect_ber_octet string(%s) entered implicit_tag:%d offset:%d len:%d %02x:%02x:%02x\n", name, implicit_tag, offset, tvb_reported_length_remaining(tvb, offset), tvb_get_guint8(tvb, offset), tvb_get_guint8(tvb, offset+1), tvb_get_guint8(tvb, offset+2)); } else { -printf("OCTET STRING dissect_ber_octet_string(%s) entered\n", name); +proto_tree_add_debug_text(tree, "OCTET STRING dissect_ber_octet_string(%s) entered\n", name); } } #endif @@ -1860,9 +1863,9 @@ name = hfinfo->name; name = "unnamed"; } if (tvb_reported_length_remaining(tvb, offset) > 3) { -printf("INTEGERnew dissect_ber_integer(%s) entered implicit_tag:%d offset:%d len:%d %02x:%02x:%02x\n", name, implicit_tag, offset, tvb_reported_length_remaining(tvb, offset), tvb_get_guint8(tvb, offset), tvb_get_guint8(tvb, offset+1), tvb_get_guint8(tvb, offset+2)); +proto_tree_add_debug_text(tree, "INTEGERnew dissect_ber_integer(%s) entered implicit_tag:%d offset:%d len:%d %02x:%02x:%02x\n", name, implicit_tag, offset, tvb_reported_length_remaining(tvb, offset), tvb_get_guint8(tvb, offset), tvb_get_guint8(tvb, offset+1), tvb_get_guint8(tvb, offset+2)); } else { -printf("INTEGERnew dissect_ber_integer(%s) entered implicit_tag:%d \n", name, implicit_tag); +proto_tree_add_debug_text(tree, "INTEGERnew dissect_ber_integer(%s) entered implicit_tag:%d \n", name, implicit_tag); } } #endif @@ -2139,9 +2142,9 @@ name = hfinfo->name; name = "unnamed"; } if (tvb_reported_length_remaining(tvb, offset) > 3) { -printf("SEQUENCE dissect_ber_sequence(%s) entered offset:%d len:%d %02x:%02x:%02x\n", name, offset, tvb_reported_length_remaining(tvb, offset), tvb_get_guint8(tvb, offset), tvb_get_guint8(tvb, offset+1), tvb_get_guint8(tvb, offset+2)); +proto_tree_add_debug_text(tree, "SEQUENCE dissect_ber_sequence(%s) entered offset:%d len:%d %02x:%02x:%02x\n", name, offset, tvb_reported_length_remaining(tvb, offset), tvb_get_guint8(tvb, offset), tvb_get_guint8(tvb, offset+1), tvb_get_guint8(tvb, offset+2)); } else { -printf("SEQUENCE dissect_ber_sequence(%s) entered\n", name); +proto_tree_add_debug_text(tree, "SEQUENCE dissect_ber_sequence(%s) entered\n", name); } } #endif @@ -2397,9 +2400,9 @@ name = hfinfo->name; name = "unnamed"; } if (tvb_reported_length_remaining(next_tvb, 0) > 3) { -printf("SEQUENCE dissect_ber_sequence(%s) calling subdissector offset:%d len:%d %02x:%02x:%02x\n", name, offset, tvb_reported_length_remaining(next_tvb, 0), tvb_get_guint8(next_tvb, 0), tvb_get_guint8(next_tvb, 1), tvb_get_guint8(next_tvb, 2)); +proto_tree_add_debug_text(tree, "SEQUENCE dissect_ber_sequence(%s) calling subdissector offset:%d len:%d %02x:%02x:%02x\n", name, offset, tvb_reported_length_remaining(next_tvb, 0), tvb_get_guint8(next_tvb, 0), tvb_get_guint8(next_tvb, 1), tvb_get_guint8(next_tvb, 2)); } else { -printf("SEQUENCE dissect_ber_sequence(%s) calling subdissector\n", name); +proto_tree_add_debug_text(tree, "SEQUENCE dissect_ber_sequence(%s) calling subdissector\n", name); } } #endif @@ -2424,7 +2427,7 @@ name = hfinfo->name; } else { name = "unnamed"; } -printf("SEQUENCE dissect_ber_sequence(%s) subdissector ate %d bytes\n", name, count); +proto_tree_add_debug_text(tree, "SEQUENCE dissect_ber_sequence(%s) subdissector ate %d bytes\n", name, count); } #endif /* if it was optional and no bytes were eaten and it was */ @@ -2505,9 +2508,9 @@ name = hfinfo->name; name = "unnamed"; } if (tvb_reported_length_remaining(tvb, offset) > 3) { -printf("SET dissect_ber_set(%s) entered offset:%d len:%d %02x:%02x:%02x\n", name, offset, tvb_reported_length_remaining(tvb, offset), tvb_get_guint8(tvb, offset), tvb_get_guint8(tvb, offset+1), tvb_get_guint8(tvb, offset+2)); +proto_tree_add_debug_text(tree, "SET dissect_ber_set(%s) entered offset:%d len:%d %02x:%02x:%02x\n", name, offset, tvb_reported_length_remaining(tvb, offset), tvb_get_guint8(tvb, offset), tvb_get_guint8(tvb, offset+1), tvb_get_guint8(tvb, offset+2)); } else { -printf("SET dissect_ber_set(%s) entered\n", name); +proto_tree_add_debug_text(tree, "SET dissect_ber_set(%s) entered\n", name); } } #endif @@ -2651,9 +2654,9 @@ name = hfinfo->name; name = "unnamed"; } if (tvb_reported_length_remaining(next_tvb, 0) > 3) { -printf("SET dissect_ber_set(%s) calling subdissector offset:%d len:%d %02x:%02x:%02x\n", name, offset, tvb_reported_length_remaining(next_tvb, 0), tvb_get_guint8(next_tvb, 0), tvb_get_guint8(next_tvb, 1), tvb_get_guint8(next_tvb, 2)); +proto_tree_add_debug_text(tree, "SET dissect_ber_set(%s) calling subdissector offset:%d len:%d %02x:%02x:%02x\n", name, offset, tvb_reported_length_remaining(next_tvb, 0), tvb_get_guint8(next_tvb, 0), tvb_get_guint8(next_tvb, 1), tvb_get_guint8(next_tvb, 2)); } else { -printf("SET dissect_ber_set(%s) calling subdissector\n", name); +proto_tree_add_debug_text(tree, "SET dissect_ber_set(%s) calling subdissector\n", name); } } #endif @@ -2781,9 +2784,9 @@ name = hfinfo->name; name = "unnamed"; } if (tvb_reported_length_remaining(tvb, offset) > 3) { -printf("CHOICE dissect_ber_choice(%s) entered offset:%d len:%d %02x:%02x:%02x\n", name, offset, tvb_reported_length_remaining(tvb, offset), tvb_get_guint8(tvb, offset), tvb_get_guint8(tvb, offset+1), tvb_get_guint8(tvb, offset+2)); +proto_tree_add_debug_text(tree, "CHOICE dissect_ber_choice(%s) entered offset:%d len:%d %02x:%02x:%02x\n", name, offset, tvb_reported_length_remaining(tvb, offset), tvb_get_guint8(tvb, offset), tvb_get_guint8(tvb, offset+1), tvb_get_guint8(tvb, offset+2)); } else { -printf("CHOICE dissect_ber_choice(%s) entered len:%d\n", name, tvb_reported_length_remaining(tvb, offset)); +proto_tree_add_debug_text(tree, "CHOICE dissect_ber_choice(%s) entered len:%d\n", name, tvb_reported_length_remaining(tvb, offset)); } } #endif @@ -2846,7 +2849,7 @@ printf("CHOICE dissect_ber_choice(%s) entered len:%d\n", name, tvb_reported_leng } #ifdef DEBUG_BER_CHOICE -printf("CHOICE testing potential subdissector class[%p]:%d:(expected)%d tag:%d:(expected)%d flags:%d\n", ch, ber_class, ch->ber_class, tag, ch->tag, ch->flags); +proto_tree_add_debug_text(tree, "CHOICE testing potential subdissector class[%p]:%d:(expected)%d tag:%d:(expected)%d flags:%d\n", ch, ber_class, ch->ber_class, tag, ch->tag, ch->flags); #endif if ( (first_pass && (((ch->ber_class == ber_class) && (ch->tag == tag)) @@ -2901,9 +2904,9 @@ name = hfinfo->name; name = "unnamed"; } if (tvb_reported_length_remaining(next_tvb, 0) > 3) { -printf("CHOICE dissect_ber_choice(%s) calling subdissector start_offset:%d offset:%d len:%d %02x:%02x:%02x\n", name, start_offset, offset, tvb_reported_length_remaining(next_tvb, 0), tvb_get_guint8(next_tvb, 0), tvb_get_guint8(next_tvb, 1), tvb_get_guint8(next_tvb, 2)); +proto_tree_add_debug_text(tree, "CHOICE dissect_ber_choice(%s) calling subdissector start_offset:%d offset:%d len:%d %02x:%02x:%02x\n", name, start_offset, offset, tvb_reported_length_remaining(next_tvb, 0), tvb_get_guint8(next_tvb, 0), tvb_get_guint8(next_tvb, 1), tvb_get_guint8(next_tvb, 2)); } else { -printf("CHOICE dissect_ber_choice(%s) calling subdissector len:%d\n", name, tvb_reported_length(next_tvb)); +proto_tree_add_debug_text(tree, "CHOICE dissect_ber_choice(%s) calling subdissector len:%d\n", name, tvb_reported_length(next_tvb)); } } #endif @@ -2924,7 +2927,7 @@ name = hfinfo->name; } else { name = "unnamed"; } -printf("CHOICE dissect_ber_choice(%s) subdissector ate %d bytes\n", name, count); +proto_tree_add_debug_text(tree, "CHOICE dissect_ber_choice(%s) subdissector ate %d bytes\n", name, count); } #endif if ((count == 0) && (((ch->ber_class == ber_class) && (ch->tag == -1) && (ch->flags & BER_FLAGS_NOOWNTAG)) || !first_pass)) { @@ -2939,7 +2942,7 @@ name = hfinfo->name; } else { name = "unnamed"; } -printf("CHOICE dissect_ber_choice(%s) trying again\n", name); +proto_tree_add_debug_text(tree, "CHOICE dissect_ber_choice(%s) trying again\n", name); } #endif continue; @@ -3065,9 +3068,9 @@ name = hfinfo->name; name = "unnamed"; } if (tvb_reported_length_remaining(tvb, offset) > 3) { -printf("RESTRICTED STRING dissect_ber_octet string(%s) entered implicit_tag:%d offset:%d len:%d %02x:%02x:%02x\n", name, implicit_tag, offset, tvb_reported_length_remaining(tvb, offset), tvb_get_guint8(tvb, offset), tvb_get_guint8(tvb, offset+1), tvb_get_guint8(tvb, offset+2)); +proto_tree_add_debug_text(tree, "RESTRICTED STRING dissect_ber_octet string(%s) entered implicit_tag:%d offset:%d len:%d %02x:%02x:%02x\n", name, implicit_tag, offset, tvb_reported_length_remaining(tvb, offset), tvb_get_guint8(tvb, offset), tvb_get_guint8(tvb, offset+1), tvb_get_guint8(tvb, offset+2)); } else { -printf("RESTRICTED STRING dissect_ber_octet_string(%s) entered\n", name); +proto_tree_add_debug_text(tree, "RESTRICTED STRING dissect_ber_octet_string(%s) entered\n", name); } } #endif @@ -3161,9 +3164,9 @@ name = hfinfo->name; name = "unnamed"; } if (tvb_reported_length_remaining(tvb, offset) > 3) { -printf("OBJECT IDENTIFIER dissect_ber_any_oid(%s) entered implicit_tag:%d offset:%d len:%d %02x:%02x:%02x\n", name, implicit_tag, offset, tvb_reported_length_remaining(tvb, offset), tvb_get_guint8(tvb, offset), tvb_get_guint8(tvb, offset+1), tvb_get_guint8(tvb, offset+2)); +proto_tree_add_debug_text(tree, "OBJECT IDENTIFIER dissect_ber_any_oid(%s) entered implicit_tag:%d offset:%d len:%d %02x:%02x:%02x\n", name, implicit_tag, offset, tvb_reported_length_remaining(tvb, offset), tvb_get_guint8(tvb, offset), tvb_get_guint8(tvb, offset+1), tvb_get_guint8(tvb, offset+2)); } else { -printf("OBJECT IDENTIFIER dissect_ber_any_oid(%s) entered\n", name); +proto_tree_add_debug_text(tree, "OBJECT IDENTIFIER dissect_ber_any_oid(%s) entered\n", name); } } #endif @@ -3298,9 +3301,9 @@ name = hfinfo->name; name = "unnamed"; } if (tvb_reported_length_remaining(tvb,offset) > 3) { -printf("SQ OF dissect_ber_sq_of(%s) entered implicit_tag:%d offset:%d len:%d %02x:%02x:%02x\n", name, implicit_tag, offset, tvb_reported_length_remaining(tvb, offset), tvb_get_guint8(tvb, offset), tvb_get_guint8(tvb, offset+1), tvb_get_guint8(tvb, offset+2)); +proto_tree_add_debug_text(tree, "SQ OF dissect_ber_sq_of(%s) entered implicit_tag:%d offset:%d len:%d %02x:%02x:%02x\n", name, implicit_tag, offset, tvb_reported_length_remaining(tvb, offset), tvb_get_guint8(tvb, offset), tvb_get_guint8(tvb, offset+1), tvb_get_guint8(tvb, offset+2)); } else { -printf("SQ OF dissect_ber_sq_of(%s) entered\n", name); +proto_tree_add_debug_text(tree, "SQ OF dissect_ber_sq_of(%s) entered\n", name); } } #endif diff --git a/epan/dissectors/packet-giop.c b/epan/dissectors/packet-giop.c index aaffa5efb4..8fff55bfc8 100644 --- a/epan/dissectors/packet-giop.c +++ b/epan/dissectors/packet-giop.c @@ -294,6 +294,7 @@ #include <wsutil/str_util.h> #include <wsutil/pint.h> #include <wsutil/report_err.h> +#include <wsutil/ws_printf.h> /* ws_debug_printf */ #include "packet-giop.h" #include "packet-ziop.h" @@ -1344,8 +1345,8 @@ void register_giop_user_module(giop_sub_dissector_t *sub, const gchar *name, con /* So, passed module name should NOT exist in hash at this point.*/ #if DEBUG - printf("giop:register_module: Adding Module %s to module hash \n", module); - printf("giop:register_module: Module sub dissector name is %s \n", name); + ws_debug_printf("giop:register_module: Adding Module %s to module hash \n", module); + ws_debug_printf("giop:register_module: Module sub dissector name is %s \n", name); #endif new_module_key = (struct giop_module_key *)wmem_alloc(wmem_epan_scope(), sizeof(struct giop_module_key)); @@ -1382,7 +1383,7 @@ static gint giop_hash_objkey_equal(gconstpointer v, gconstpointer w) { } #if DEBUG - printf("giop:giop_hash_objkey_equal: Objkey's DO NOT match"); + ws_debug_printf("giop:giop_hash_objkey_equal: Objkey's DO NOT match"); #endif return 0; /* found differences */ @@ -1405,7 +1406,7 @@ static guint32 giop_hash_objkey_hash(gconstpointer v) { */ #if DEBUG - printf("giop:hash_objkey: Key length = %u \n", key->objkey_len ); + ws_debug_printf("giop:hash_objkey: Key length = %u \n", key->objkey_len ); #endif for (i=0; i< key->objkey_len; i++) { @@ -1453,7 +1454,7 @@ static void insert_in_objkey_hash(GHashTable *hash, const gchar *obj, guint32 le #if DEBUG - printf("giop: ******* Inserting Objkey with RepoID = %s and key length = %u into hash \n", + ws_debug_printf("giop: ******* Inserting Objkey with RepoID = %s and key length = %u into hash \n", objkey_val->repo_id, new_objkey_key->objkey_len); #endif @@ -1656,13 +1657,13 @@ static gchar * get_repoid_from_objkey(GHashTable *hash, const guint8 *obj, guint if (objkey_val) { #if DEBUG - printf("Lookup of object key returns RepoId = %s \n", objkey_val->repo_id ); + ws_debug_printf("Lookup of object key returns RepoId = %s \n", objkey_val->repo_id ); #endif return objkey_val->repo_id; /* found */ } #if DEBUG - printf("FAILED Lookup of object key \n" ); + ws_debug_printf("FAILED Lookup of object key \n" ); #endif return NULL; /* not found */ @@ -1734,7 +1735,7 @@ static void display_module_hash(gpointer key, gpointer val, gpointer user_data) struct giop_module_val *mv = (struct giop_module_val *) val; struct giop_module_key *mk = (struct giop_module_key *) key; - printf("giop:module: Key = (%s) , Val = (%s) \n", mk->module, mv->subh->sub_name); + ws_debug_printf("giop:module: Key = (%s) , Val = (%s) \n", mk->module, mv->subh->sub_name); return; @@ -1749,7 +1750,7 @@ static void display_complete_reply_hash(gpointer key, gpointer val, gpointer use struct complete_reply_hash_val *mv = (struct complete_reply_hash_val *) val; struct complete_reply_hash_key *mk = (struct complete_reply_hash_key *) key; - printf("giop:complete_reply: FN (key) = %8u , MFN (val) = %8u \n", mk->fn, mv->mfn); + ws_debug_printf("giop:complete_reply: FN (key) = %8u , MFN (val) = %8u \n", mk->fn, mv->mfn); return; @@ -1766,10 +1767,10 @@ static void display_objkey_hash(gpointer key, gpointer val, gpointer user_data) struct giop_object_key *mk = (struct giop_object_key *) key; - printf("giop:objkey: Key->objkey_len = %u, Key->objkey ", mk->objkey_len); + ws_debug_printf("giop:objkey: Key->objkey_len = %u, Key->objkey ", mk->objkey_len); for (i=0; i<mk->objkey_len; i++) { - printf("%.2x ", mk->objkey[i]); + ws_debug_printf("%.2x ", mk->objkey[i]); } /* @@ -1777,10 +1778,10 @@ static void display_objkey_hash(gpointer key, gpointer val, gpointer user_data) */ if (mv->src == 0) { - printf(", Repo ID = %s \n", mv->repo_id); + ws_debug_printf(", Repo ID = %s \n", mv->repo_id); } else { - printf(", Repo ID = %s , (file) \n", mv->repo_id); + ws_debug_printf(", Repo ID = %s , (file) \n", mv->repo_id); } return; @@ -1804,7 +1805,7 @@ static void display_heuristic_user_list() { for (i=0; i<len; i++) { subh = ( giop_sub_handle_t *) g_slist_nth_data(giop_sub_list, i); /* grab entry */ - printf("giop:heuristic_user: Element = %i, Val (user) = %s \n", i, subh->sub_name); + ws_debug_printf("giop:heuristic_user: Element = %i, Val (user) = %s \n", i, subh->sub_name); } } @@ -1826,7 +1827,7 @@ static void display_complete_request_list() { for (i=0; i<len; i++) { entry = (comp_req_list_entry_t *) g_list_nth_data(giop_complete_request_list, i); /* grab entry */ - printf("giop:Index = %8i , FN = %8i, reqid = %8u , operation = %20s , repoid = %30s \n", i, entry->fn, + ws_debug_printf("giop:Index = %8i , FN = %8i, reqid = %8u , operation = %20s , repoid = %30s \n", i, entry->fn, entry->reqid, entry->operation, entry->repoid); } @@ -1845,73 +1846,73 @@ static void giop_dump_collection(collection_data_t collection_type) { switch (collection_type) { case cd_heuristic_users: - printf("+----------------------------------------------+ \n"); - printf("+-------------- Heuristic User (Begin) --------+ \n"); - printf("+----------------------------------------------+ \n"); + ws_debug_printf("+----------------------------------------------+ \n"); + ws_debug_printf("+-------------- Heuristic User (Begin) --------+ \n"); + ws_debug_printf("+----------------------------------------------+ \n"); display_heuristic_user_list(); - printf("+----------------------------------------------+ \n"); - printf("+-------------- Heuristic User (End) ----------+ \n"); - printf("+----------------------------------------------+ \n"); + ws_debug_printf("+----------------------------------------------+ \n"); + ws_debug_printf("+-------------- Heuristic User (End) ----------+ \n"); + ws_debug_printf("+----------------------------------------------+ \n"); break; case cd_complete_request_list: - printf("+----------------------------------------------+ \n"); - printf("+------------- Complete Request List (Begin) --+ \n"); - printf("+----------------------------------------------+ \n"); + ws_debug_printf("+----------------------------------------------+ \n"); + ws_debug_printf("+------------- Complete Request List (Begin) --+ \n"); + ws_debug_printf("+----------------------------------------------+ \n"); display_complete_request_list(); - printf("+----------------------------------------------+ \n"); - printf("+------------ Complete Request List (End) -----+ \n"); - printf("+----------------------------------------------+ \n"); + ws_debug_printf("+----------------------------------------------+ \n"); + ws_debug_printf("+------------ Complete Request List (End) -----+ \n"); + ws_debug_printf("+----------------------------------------------+ \n"); break; case cd_module_hash: - printf("+----------------------------------------------+ \n"); - printf("+-------------- Module (Begin) ----------------+ \n"); - printf("+----------------------------------------------+ \n"); + ws_debug_printf("+----------------------------------------------+ \n"); + ws_debug_printf("+-------------- Module (Begin) ----------------+ \n"); + ws_debug_printf("+----------------------------------------------+ \n"); g_hash_table_foreach(giop_module_hash, display_module_hash, NULL); - printf("+----------------------------------------------+ \n"); - printf("+-------------- Module ( End) -----------------+ \n"); - printf("+----------------------------------------------+ \n\n"); + ws_debug_printf("+----------------------------------------------+ \n"); + ws_debug_printf("+-------------- Module ( End) -----------------+ \n"); + ws_debug_printf("+----------------------------------------------+ \n\n"); break; case cd_objkey_hash: - printf("+----------------------------------------------+ \n"); - printf("+-------------- Objkey (Begin) ----------------+ \n"); - printf("+----------------------------------------------+ \n"); + ws_debug_printf("+----------------------------------------------+ \n"); + ws_debug_printf("+-------------- Objkey (Begin) ----------------+ \n"); + ws_debug_printf("+----------------------------------------------+ \n"); g_hash_table_foreach(giop_objkey_hash, display_objkey_hash, NULL); - printf("+----------------------------------------------+ \n"); - printf("+-------------- Objkey (End) ------------------+ \n"); - printf("+----------------------------------------------+ \n\n"); + ws_debug_printf("+----------------------------------------------+ \n"); + ws_debug_printf("+-------------- Objkey (End) ------------------+ \n"); + ws_debug_printf("+----------------------------------------------+ \n\n"); break; case cd_complete_reply_hash: - printf("+----------------------------------------------+ \n"); - printf("+-------------- Complete_Reply_Hash (Begin) ---+ \n"); - printf("+----------------------------------------------+ \n"); + ws_debug_printf("+----------------------------------------------+ \n"); + ws_debug_printf("+-------------- Complete_Reply_Hash (Begin) ---+ \n"); + ws_debug_printf("+----------------------------------------------+ \n"); g_hash_table_foreach(giop_complete_reply_hash, display_complete_reply_hash, NULL); - printf("+----------------------------------------------+ \n"); - printf("+------------- Complete_Reply_Hash (End) ------+ \n"); - printf("+----------------------------------------------+ \n"); + ws_debug_printf("+----------------------------------------------+ \n"); + ws_debug_printf("+------------- Complete_Reply_Hash (End) ------+ \n"); + ws_debug_printf("+----------------------------------------------+ \n"); break; default: - printf("giop: giop_dump_collection: Unknown type \n"); + ws_debug_printf("giop: giop_dump_collection: Unknown type \n"); } @@ -2035,7 +2036,7 @@ static gboolean try_explicit_giop_dissector(tvbuff_t *tvb, packet_info *pinfo, p if (tvb_offset_exists(tvb, *offset)) { #if DEBUG - printf("giop:try_explicit_dissector calling sub = %s with module = (%s) \n", subdiss->sub_name , modname); + ws_debug_printf("giop:try_explicit_dissector calling sub = %s with module = (%s) \n", subdiss->sub_name , modname); #endif if (proto_is_protocol_enabled(subdiss->sub_proto)) { @@ -2948,7 +2949,7 @@ void get_CDR_fixed(tvbuff_t *tvb, packet_info *pinfo, proto_item *item, gchar ** */ #if DEBUG - printf("giop:get_CDR_fixed() called , digits = %u, scale = %u \n", digits, scale); + ws_debug_printf("giop:get_CDR_fixed() called , digits = %u, scale = %u \n", digits, scale); #endif if (scale <0) { @@ -2958,7 +2959,7 @@ void get_CDR_fixed(tvbuff_t *tvb, packet_info *pinfo, proto_item *item, gchar ** } #if DEBUG - printf("giop:get_CDR_fixed(): slen = %.2x \n", slen); + ws_debug_printf("giop:get_CDR_fixed(): slen = %.2x \n", slen); #endif tmpbuf = (gchar *)wmem_alloc0(wmem_packet_scope(), slen); /* allocate temp buffer */ @@ -2968,7 +2969,7 @@ void get_CDR_fixed(tvbuff_t *tvb, packet_info *pinfo, proto_item *item, gchar ** if (!(digits & 0x01)) { tval = get_CDR_octet(tvb, offset); #if DEBUG - printf("giop:get_CDR_fixed():even: octet = %.2x \n", tval); + ws_debug_printf("giop:get_CDR_fixed():even: octet = %.2x \n", tval); #endif tmpbuf[sindex] = (tval & 0x0f) + 0x30; /* convert top nibble to ascii */ sindex++; @@ -2983,7 +2984,7 @@ void get_CDR_fixed(tvbuff_t *tvb, packet_info *pinfo, proto_item *item, gchar ** for (i=0; i< ((digits-1)/2 ); i++) { tval = get_CDR_octet(tvb, offset); #if DEBUG - printf("giop:get_CDR_fixed():odd: octet = %.2x \n", tval); + v("giop:get_CDR_fixed():odd: octet = %.2x \n", tval); #endif tmpbuf[sindex] = ((tval & 0xf0) >> 4) + 0x30; /* convert top nibble to ascii */ @@ -2995,7 +2996,7 @@ void get_CDR_fixed(tvbuff_t *tvb, packet_info *pinfo, proto_item *item, gchar ** } /* digits > 3 */ #if DEBUG - printf("giop:get_CDR_fixed(): before last digit \n"); + ws_debug_printf("giop:get_CDR_fixed(): before last digit \n"); #endif @@ -3003,7 +3004,7 @@ void get_CDR_fixed(tvbuff_t *tvb, packet_info *pinfo, proto_item *item, gchar ** tval = get_CDR_octet(tvb, offset); #if DEBUG - printf("giop:get_CDR_fixed(): octet = %.2x \n", tval); + ws_debug_printf("giop:get_CDR_fixed(): octet = %.2x \n", tval); #endif tmpbuf[sindex] = (( tval & 0xf0)>> 4) + 0x30; /* convert top nibble to ascii */ sindex++; @@ -3019,7 +3020,7 @@ void get_CDR_fixed(tvbuff_t *tvb, packet_info *pinfo, proto_item *item, gchar ** *seq = wmem_alloc0_array(wmem_packet_scope(), gchar, slen + 3); /* allocate temp buffer , including space for sign, decimal point and * \0 -- TODO check slen is reasonable first */ #if DEBUG - printf("giop:get_CDR_fixed(): sign = %.2x \n", sign); + ws_debug_printf("giop:get_CDR_fixed(): sign = %.2x \n", sign); #endif switch (sign) { @@ -3076,7 +3077,7 @@ void get_CDR_fixed(tvbuff_t *tvb, packet_info *pinfo, proto_item *item, gchar ** } #if DEBUG - printf("giop:get_CDR_fixed(): value = %s \n", *seq); + ws_debug_printf("giop:get_CDR_fixed(): value = %s \n", *seq); #endif return; diff --git a/epan/dissectors/packet-tacacs.c b/epan/dissectors/packet-tacacs.c index 5054f90126..bf40af19c3 100644 --- a/epan/dissectors/packet-tacacs.c +++ b/epan/dissectors/packet-tacacs.c @@ -39,6 +39,7 @@ #include <epan/expert.h> #include <epan/addr_resolv.h> #include <wsutil/md5.h> +#include <wsutil/ws_printf.h> /* ws_debug_printf */ #include "packet-tacacs.h" @@ -749,9 +750,9 @@ tacplus_print_key_entry( gpointer data, gpointer user_data ) s_str = address_to_str( NULL, tacplus_data->s ); c_str = address_to_str( NULL, tacplus_data->c ); if( user_data ) { - printf("%s:%s=%s\n", s_str, c_str, tacplus_data->k ); + ws_debug_printf("%s:%s=%s\n", s_str, c_str, tacplus_data->k ); } else { - printf("%s:%s\n", s_str, c_str ); + ws_debug_printf("%s:%s\n", s_str, c_str ); } wmem_free(NULL, s_str); wmem_free(NULL, c_str); @@ -764,9 +765,9 @@ cmp_conv_address( gconstpointer p1, gconstpointer p2 ) const tacplus_key_entry *a2=(const tacplus_key_entry *)p2; gint32 ret; /* - printf("p1=>"); + ws_debug_printf("p1=>"); tacplus_print_key_entry( p1, NULL ); - printf("p2=>"); + ws_debug_printf("p2=>"); tacplus_print_key_entry( p2, NULL ); */ ret=cmp_address( a1->s, a2->s ); @@ -774,9 +775,9 @@ cmp_conv_address( gconstpointer p1, gconstpointer p2 ) ret=cmp_address( a1->c, a2->c ); /* if(ret) - printf("No Client found!"); */ + ws_debug_printf("No Client found!"); */ } else { - /* printf("No Server found!"); */ + /* ws_debug_printf("No Server found!"); */ } return ret; } @@ -789,10 +790,10 @@ find_key( address *srv, address *cln ) data.s=srv; data.c=cln; -/* printf("Looking for: "); +/* ws_debug_printf("Looking for: "); tacplus_print_key_entry( (gconstpointer)&data, NULL ); */ match=g_slist_find_custom( tacplus_keys, (gpointer)&data, cmp_conv_address ); -/* printf("Finished (%p)\n", match); */ +/* ws_debug_printf("Finished (%p)\n", match); */ if( match ) return ((tacplus_key_entry*)match->data)->k; @@ -819,7 +820,7 @@ parse_tuple( char *key_from_option ) char *client,*key; tacplus_key_entry *tacplus_data=(tacplus_key_entry *)g_malloc( sizeof(tacplus_key_entry) ); /* - printf("keys: %s\n", key_from_option ); + ws_debug_printf("keys: %s\n", key_from_option ); */ client=strchr(key_from_option,'/'); if(!client) { @@ -834,7 +835,7 @@ parse_tuple( char *key_from_option ) } *key++='\0'; /* - printf("%s %s => %s\n", key_from_option, client, key ); + ws_debug_printf("%s %s => %s\n", key_from_option, client, key ); */ mkipv4_address( &tacplus_data->s, key_from_option ); mkipv4_address( &tacplus_data->c, client ); diff --git a/epan/dissectors/packet-wtp.c b/epan/dissectors/packet-wtp.c index f35d861921..3d16a51c15 100644 --- a/epan/dissectors/packet-wtp.c +++ b/epan/dissectors/packet-wtp.c @@ -403,7 +403,7 @@ dissect_wtp_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) pdut = pdu_type(b0); #ifdef DEBUG - printf("WTP packet %u: tree = %p, pdu = %s (%u) length: %u\n", + proto_tree_add_debug_text(tree, "WTP packet %u: tree = %p, pdu = %s (%u) length: %u\n", pinfo->num, tree, val_to_str(pdut, vals_wtp_pdu_type, "Unknown PDU type 0x%x"), pdut, tvb_captured_length(tvb)); @@ -721,7 +721,7 @@ dissect_wtp_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) "Reassembled WTP", fd_wtp, &wtp_frag_items, NULL, wtp_tree); #ifdef DEBUG - printf("WTP: Packet %u %s -> %d: wsp_tvb = %p, fd_wtp = %p, frame = %u\n", + proto_tree_add_debug_text(tree, "WTP: Packet %u %s -> %d: wsp_tvb = %p, fd_wtp = %p, frame = %u\n", pinfo->num, fd_wtp ? "Reassembled" : "Not reassembled", fd_wtp ? fd_wtp->reassembled_in : -1, diff --git a/epan/except.c b/epan/except.c index 881796ebd8..2420b33760 100644 --- a/epan/except.c +++ b/epan/except.c @@ -35,6 +35,9 @@ #include <glib.h> #include "except.h" +#ifdef KAZLIB_TEST_MAIN +#include <wsutil/ws_printf.h> /* ws_debug_printf */ +#endif #ifdef _WIN32 #include <windows.h> @@ -381,13 +384,13 @@ void except_free(void *ptr) static void cleanup(void *arg) { - printf("cleanup(\"%s\") called\n", (char *) arg); + ws_debug_printf("cleanup(\"%s\") called\n", (char *) arg); } static void bottom_level(void) { char buf[256]; - printf("throw exception? "); fflush(stdout); + ws_debug_printf("throw exception? "); fflush(stdout); fgets(buf, sizeof buf, stdin); if (buf[0] >= 0 && (buf[0] == 'Y' || buf[0] == 'y')) @@ -422,10 +425,10 @@ int main(int argc, char **argv) /* inner catch */ msg = except_message(ex); if (msg == NULL) { - printf("caught exception (inner): s=%lu, c=%lu\n", + ws_debug_printf("caught exception (inner): s=%lu, c=%lu\n", except_group(ex), except_code(ex)); } else { - printf("caught exception (inner): \"%s\", s=%lu, c=%lu\n", + ws_debug_printf("caught exception (inner): \"%s\", s=%lu, c=%lu\n", msg, except_group(ex), except_code(ex)); } except_rethrow(ex); @@ -435,10 +438,10 @@ int main(int argc, char **argv) /* outer catch */ msg = except_message(ex); if (msg == NULL) { - printf("caught exception (outer): s=%lu, c=%lu\n", + ws_debug_printf("caught exception (outer): s=%lu, c=%lu\n", except_group(ex), except_code(ex)); } else { - printf("caught exception (outer): \"%s\", s=%lu, c=%lu\n", + ws_debug_printf("caught exception (outer): \"%s\", s=%lu, c=%lu\n", except_message(ex), except_group(ex), except_code(ex)); } } diff --git a/epan/packet.c b/epan/packet.c index d76fa44037..059c975125 100644 --- a/epan/packet.c +++ b/epan/packet.c @@ -51,6 +51,7 @@ #include <epan/asm_utils.h> #include <wsutil/str_util.h> +#include <wsutil/ws_printf.h> /* ws_debug_printf */ static gint proto_malformed = -1; static dissector_handle_t frame_handle = NULL; @@ -2534,7 +2535,7 @@ display_heur_dissector_table_entries(const char *table_name, heur_dtbl_entry_t *hdtbl_entry, gpointer user_data _U_) { if (hdtbl_entry->protocol != NULL) { - printf("%s\t%s\t%c\n", + ws_debug_printf("%s\t%s\t%c\n", table_name, proto_get_protocol_filter_name(proto_get_id(hdtbl_entry->protocol)), (proto_is_protocol_enabled(hdtbl_entry->protocol) && hdtbl_entry->enabled) ? 'T' : 'F'); @@ -2962,7 +2963,7 @@ dissector_dump_decodes_display(const gchar *table_name, if (proto_id != -1) { decode_as = proto_get_protocol_filter_name(proto_id); g_assert(decode_as != NULL); - printf("%s\t%u\t%s\n", table_name, selector, decode_as); + ws_debug_printf("%s\t%u\t%s\n", table_name, selector, decode_as); } break; @@ -2996,7 +2997,7 @@ dissector_dump_dissector_tables_display (gpointer key, gpointer user_data _U_) dissector_table_t table; table = (dissector_table_t)g_hash_table_lookup(dissector_tables, key); - printf("%s\t%s\t%s", table_name, table->ui_name, ftype_name(table->type)); + ws_debug_printf("%s\t%s\t%s", table_name, table->ui_name, ftype_name(table->type)); switch (table->type) { case FT_UINT8: @@ -3006,27 +3007,27 @@ dissector_dump_dissector_tables_display (gpointer key, gpointer user_data _U_) switch(table->param) { case BASE_NONE: - printf("\tBASE_NONE"); + ws_debug_printf("\tBASE_NONE"); break; case BASE_DEC: - printf("\tBASE_DEC"); + ws_debug_printf("\tBASE_DEC"); break; case BASE_HEX: - printf("\tBASE_HEX"); + ws_debug_printf("\tBASE_HEX"); break; case BASE_DEC_HEX: - printf("\tBASE_DEC_HEX"); + ws_debug_printf("\tBASE_DEC_HEX"); break; case BASE_HEX_DEC: - printf("\tBASE_HEX_DEC"); + ws_debug_printf("\tBASE_HEX_DEC"); break; default: - printf("\t%d", table->param); + ws_debug_printf("\t%d", table->param); break; } break; @@ -3034,7 +3035,7 @@ dissector_dump_dissector_tables_display (gpointer key, gpointer user_data _U_) default: break; } - printf("\n"); + ws_debug_printf("\n"); } static gint diff --git a/epan/proto.c b/epan/proto.c index 5298ba4c16..f675dfc37d 100644 --- a/epan/proto.c +++ b/epan/proto.c @@ -56,6 +56,7 @@ #include "in_cksum.h" #include <wsutil/plugins.h> +#include <wsutil/ws_printf.h> /* ws_debug_printf */ /* Ptvcursor limits */ #define SUBTREE_ONCE_ALLOCATION_NUMBER 8 @@ -1267,7 +1268,7 @@ proto_tree_add_debug_text(proto_tree *tree, const char *format, ...) va_start(ap, format); vprintf(format, ap); va_end(ap); - printf("\n"); + ws_debug_printf("\n"); return pi; } @@ -8188,7 +8189,7 @@ proto_registrar_dump_protocols(void) i = proto_get_first_protocol(&cookie); while (i != -1) { protocol = find_protocol_by_id(i); - printf("%s\t%s\t%s\n", protocol->name, protocol->short_name, + ws_debug_printf("%s\t%s\t%s\n", protocol->name, protocol->short_name, protocol->filter_name); i = proto_get_next_protocol(&cookie); } @@ -8325,7 +8326,7 @@ proto_registrar_dump_values(void) continue; } try_val_to_str_ext(0, vse_p); /* "prime" the extended value_string */ - printf("E\t%s\t%u\t%s\t%s\n", + ws_debug_printf("E\t%s\t%u\t%s\t%s\n", hfinfo->abbrev, VALUE_STRING_EXT_VS_NUM_ENTRIES(vse_p), VALUE_STRING_EXT_VS_NAME(vse_p), @@ -8335,13 +8336,13 @@ proto_registrar_dump_values(void) while (vals[vi].strptr) { /* Print in the proper base */ if (hfinfo->display == BASE_HEX) { - printf("V\t%s\t0x%x\t%s\n", + ws_debug_printf("V\t%s\t0x%x\t%s\n", hfinfo->abbrev, vals[vi].value, vals[vi].strptr); } else { - printf("V\t%s\t%u\t%s\n", + ws_debug_printf("V\t%s\t%u\t%s\n", hfinfo->abbrev, vals[vi].value, vals[vi].strptr); @@ -8352,7 +8353,7 @@ proto_registrar_dump_values(void) else if (vals64) { vi = 0; while (vals64[vi].strptr) { - printf("V64\t%s\t%" G_GINT64_MODIFIER "u\t%s\n", + ws_debug_printf("V64\t%s\t%" G_GINT64_MODIFIER "u\t%s\n", hfinfo->abbrev, vals64[vi].value, vals64[vi].strptr); @@ -8366,14 +8367,14 @@ proto_registrar_dump_values(void) while (range[vi].strptr) { /* Print in the proper base */ if ((hfinfo->display & FIELD_DISPLAY_E_MASK) == BASE_HEX) { - printf("R\t%s\t0x%x\t0x%x\t%s\n", + ws_debug_printf("R\t%s\t0x%x\t0x%x\t%s\n", hfinfo->abbrev, range[vi].value_min, range[vi].value_max, range[vi].strptr); } else { - printf("R\t%s\t%u\t%u\t%s\n", + ws_debug_printf("R\t%s\t%u\t%u\t%s\n", hfinfo->abbrev, range[vi].value_min, range[vi].value_max, @@ -8385,7 +8386,7 @@ proto_registrar_dump_values(void) /* Print true/false strings? */ else if (tfs) { - printf("T\t%s\t%s\t%s\n", hfinfo->abbrev, + ws_debug_printf("T\t%s\t%s\t%s\n", hfinfo->abbrev, tfs->true_string, tfs->false_string); } } @@ -8422,21 +8423,21 @@ proto_registrar_dump_fieldcount(void) same_name_count++; } - printf ("There are %u header fields registered, of which:\n" + ws_debug_printf("There are %u header fields registered, of which:\n" "\t%u are deregistered\n" "\t%u are protocols\n" "\t%u have the same name as another field\n\n", gpa_hfinfo.len, deregistered_count, protocol_count, same_name_count); - printf ("%d fields were pre-allocated.\n%s", PROTO_PRE_ALLOC_HF_FIELDS_MEM, + ws_debug_printf("%d fields were pre-allocated.\n%s", PROTO_PRE_ALLOC_HF_FIELDS_MEM, (gpa_hfinfo.allocated_len > PROTO_PRE_ALLOC_HF_FIELDS_MEM) ? "* * Please increase PROTO_PRE_ALLOC_HF_FIELDS_MEM (in epan/proto.c)! * *\n\n" : "\n"); - printf ("The header field table consumes %u KiB of memory.\n", + ws_debug_printf("The header field table consumes %u KiB of memory.\n", (unsigned int)(gpa_hfinfo.allocated_len * sizeof(header_field_info *) / 1024)); - printf ("The fields themselves consume %u KiB of memory.\n", + ws_debug_printf("The fields themselves consume %u KiB of memory.\n", (unsigned int)(gpa_hfinfo.len * sizeof(header_field_info) / 1024)); return (gpa_hfinfo.allocated_len > PROTO_PRE_ALLOC_HF_FIELDS_MEM); @@ -8493,7 +8494,7 @@ proto_registrar_dump_fields(void) /* format for protocols */ if (proto_registrar_is_protocol(i)) { - printf("P\t%s\t%s\n", hfinfo->name, hfinfo->abbrev); + ws_debug_printf("P\t%s\t%s\n", hfinfo->name, hfinfo->abbrev); } /* format for header fields */ else { @@ -8564,7 +8565,7 @@ proto_registrar_dump_fields(void) else if (strlen(blurb) == 0) blurb = "\"\""; - printf("F\t%s\t%s\t%s\t%s\t%s\t0x%" G_GINT64_MODIFIER "x\t%s\n", + ws_debug_printf("F\t%s\t%s\t%s\t%s\t%s\t0x%" G_GINT64_MODIFIER "x\t%s\n", hfinfo->name, hfinfo->abbrev, enum_name, parent_hfinfo->abbrev, base_name, hfinfo->bitmask, blurb); @@ -8587,7 +8588,7 @@ proto_registrar_dump_ftypes(void) int fte; for (fte = 0; fte < FT_NUM_TYPES; fte++) { - printf("%s\t%s\n", ftype_name((ftenum_t)fte), ftype_pretty_name((ftenum_t)fte)); + ws_debug_printf("%s\t%s\n", ftype_name((ftenum_t)fte), ftype_pretty_name((ftenum_t)fte)); } } diff --git a/epan/reedsolomon.c b/epan/reedsolomon.c index a11bd52a28..c47ba4cbe9 100644 --- a/epan/reedsolomon.c +++ b/epan/reedsolomon.c @@ -30,6 +30,7 @@ */ #include <stdio.h> #include "reedsolomon.h" +#include <wsutil/ws_printf.h> /* ws_debug_printf */ #ifdef CCSDS /* CCSDS field generator polynomial: 1+x+x^2+x^7+x^8 */ @@ -510,15 +511,15 @@ eras_dec_rs(dtype data[NN], int eras_pos[NN-KK], int no_eras) count++; } if (count != no_eras) { - printf("\n lambda(x) is WRONG\n"); + ws_debug_printf("\n lambda(x) is WRONG\n"); count = -1; goto finish; } #if DEBUG >= 2 - printf("\n Erasure positions as determined by roots of Eras Loc Poly:\n"); + ws_debug_printf("\n Erasure positions as determined by roots of Eras Loc Poly:\n"); for (i = 0; i < count; i++) - printf("%d ", loc[i]); - printf("\n"); + ws_debug_printf("%d ", loc[i]); + ws_debug_printf("\n"); #endif #endif } diff --git a/epan/tvbuff_zlib.c b/epan/tvbuff_zlib.c index e5cb40a6a0..c1a6a1092c 100644 --- a/epan/tvbuff_zlib.c +++ b/epan/tvbuff_zlib.c @@ -33,6 +33,9 @@ #endif #include "tvbuff.h" +#ifdef TVB_Z_DEBUG +#include <wsutil/ws_printf.h> /* ws_debug_printf */ +#endif #ifdef HAVE_ZLIB /* @@ -82,7 +85,7 @@ tvb_uncompress(tvbuff_t *tvb, const int offset, int comprlen) bufsiz = CLAMP(bufsiz, TVB_Z_MIN_BUFSIZ, TVB_Z_MAX_BUFSIZ); #ifdef TVB_Z_DEBUG - printf("bufsiz: %u bytes\n", bufsiz); + ws_debug_printf("bufsiz: %u bytes\n", bufsiz); #endif next = compr; @@ -315,8 +318,8 @@ tvb_uncompress(tvbuff_t *tvb, const int offset, int comprlen) } #ifdef TVB_Z_DEBUG - printf("inflate() total passes: %u\n", inflate_passes); - printf("bytes in: %u\nbytes out: %u\n\n", bytes_in, bytes_out); + ws_debug_printf("inflate() total passes: %u\n", inflate_passes); + ws_debug_printf("bytes in: %u\nbytes out: %u\n\n", bytes_in, bytes_out); #endif if (uncompr != NULL) { diff --git a/epan/wslua/init_wslua.c b/epan/wslua/init_wslua.c index cd71e2a5d6..dd57474377 100644 --- a/epan/wslua/init_wslua.c +++ b/epan/wslua/init_wslua.c @@ -34,6 +34,7 @@ #include <epan/ex-opt.h> #include <wsutil/privileges.h> #include <wsutil/file_util.h> +#include <wsutil/ws_printf.h> /* ws_debug_printf */ /* linked list of Lua plugins */ typedef struct _wslua_plugin { @@ -689,7 +690,7 @@ print_wslua_plugin_description(const char *name, const char *version, const char *description, const char *filename, void *user_data _U_) { - printf("%s\t%s\t%s\t%s\n", name, version, description, filename); + ws_debug_printf("%s\t%s\t%s\t%s\n", name, version, description, filename); } void diff --git a/epan/wslua/wslua_internals.c b/epan/wslua/wslua_internals.c index 53c57f8ec8..782d5bae68 100644 --- a/epan/wslua/wslua_internals.c +++ b/epan/wslua/wslua_internals.c @@ -28,6 +28,7 @@ #include "config.h" #include "wslua.h" +#include <wsutil/ws_printf.h> /* ws_debug_printf */ WSLUA_API int wslua__concat(lua_State* L) { /* Concatenate two objects to a string */ @@ -180,9 +181,9 @@ WSLUA_API void wslua_print_stack(char* s, lua_State* L) { int i; for (i=1;i<=lua_gettop(L);i++) { - printf("%s-%i: %s\n",s,i,lua_typename (L,lua_type(L, i))); + ws_debug_printf("%s-%i: %s\n",s,i,lua_typename (L,lua_type(L, i))); } - printf("\n"); + ws_debug_printf("\n"); } /* C-code function equivalent of the typeof() function we created in Lua. diff --git a/plugins/wimaxasncp/packet-wimaxasncp.c b/plugins/wimaxasncp/packet-wimaxasncp.c index 69e328358c..1c829f3c4c 100644 --- a/plugins/wimaxasncp/packet-wimaxasncp.c +++ b/plugins/wimaxasncp/packet-wimaxasncp.c @@ -40,6 +40,7 @@ #include <epan/eap.h> #include <wsutil/filesystem.h> #include <wsutil/report_err.h> +#include <wsutil/ws_printf.h> /* ws_debug_printf */ #include "wimaxasncp_dict.h" @@ -3320,7 +3321,7 @@ register_wimaxasncp_fields(const char* unused _U_) for (tlv = wimaxasncp_dict->tlvs; tlv; tlv = tlv->next) { - printf( + ws_debug_printf( "%s\n" " type = %u\n" " description = %s\n" diff --git a/ws_version_info.c b/ws_version_info.c index f1c5ee02f9..6f7e7fb40d 100644 --- a/ws_version_info.c +++ b/ws_version_info.c @@ -44,6 +44,7 @@ #include <wsutil/ws_cpuid.h> #include <wsutil/copyright_info.h> #include <wsutil/os_version_info.h> +#include <wsutil/ws_printf.h> /* ws_debug_printf */ /* * If the string doesn't end with a newline, append one. @@ -379,7 +380,7 @@ void show_version(const gchar *prog_name_str, GString *comp_info_str, GString *runtime_info_str) { - printf("%s %s\n" + ws_debug_printf("%s %s\n" "\n" "%s" "\n" diff --git a/wsutil/plugins.c b/wsutil/plugins.c index ec3800bdf0..8a390948f5 100644 --- a/wsutil/plugins.c +++ b/wsutil/plugins.c @@ -40,6 +40,7 @@ #include <wsutil/report_err.h> #include <wsutil/plugins.h> +#include <wsutil/ws_printf.h> /* ws_debug_printf */ /* linked list of all plugins */ typedef struct _plugin { @@ -372,7 +373,7 @@ print_plugin_description(const char *name, const char *version, const char *description, const char *filename, void *user_data _U_) { - printf("%s\t%s\t%s\t%s\n", name, version, description, filename); + ws_debug_printf("%s\t%s\t%s\t%s\n", name, version, description, filename); } void diff --git a/wsutil/sha1.c b/wsutil/sha1.c index 3aaf557052..9b115d56b2 100644 --- a/wsutil/sha1.c +++ b/wsutil/sha1.c @@ -339,6 +339,7 @@ void sha1_hmac( const guint8 *key, guint32 keylen, const guint8 *buf, guint32 bu #include <stdlib.h> #include <stdio.h> #include <errno.h> +#include <wsutil/ws_printf.h> /* ws_debug_printf */ /* * those are the standard FIPS-180-1 test vectors @@ -369,11 +370,11 @@ int main( int argc, char *argv[] ) if( argc < 2 ) { - printf( "\n SHA-1 Validation Tests:\n\n" ); + ws_debug_printf( "\n SHA-1 Validation Tests:\n\n" ); for( i = 0; i < 3; i++ ) { - printf( " Test %d ", i + 1 ); + ws_debug_printf( " Test %d ", i + 1 ); sha1_starts( &ctx ); @@ -401,20 +402,20 @@ int main( int argc, char *argv[] ) if( memcmp( output, val[i], 40 ) ) { - printf( "failed!\n" ); + ws_debug_printf( "failed!\n" ); return( 1 ); } - printf( "passed.\n" ); + ws_debug_printf( "passed.\n" ); } - printf( "\n" ); + ws_debug_printf( "\n" ); } else { if( ! ( f = ws_fopen( argv[1], "rb" ) ) ) { - printf("fopen: %s", g_strerror(errno)); + ws_debug_printf("fopen: %s", g_strerror(errno)); return( 1 ); } @@ -429,10 +430,10 @@ int main( int argc, char *argv[] ) for( j = 0; j < SHA1_DIGEST_LEN; j++ ) { - printf( "%02x", sha1sum[j] ); + ws_debug_printf( "%02x", sha1sum[j] ); } - printf( " %s\n", argv[1] ); + ws_debug_printf( " %s\n", argv[1] ); } return( 0 ); diff --git a/wsutil/ws_printf.h b/wsutil/ws_printf.h index 1ee3bf69e6..d996d01c5e 100644 --- a/wsutil/ws_printf.h +++ b/wsutil/ws_printf.h @@ -93,6 +93,14 @@ ws_snprintf(char *buffer, size_t size_of_buffer, const char * format, ...) { va_end(argptr); } +/* This is intended to fool checkAPIs.pl for places that have "debugging" +(using printf) usually wrapped in an #ifdef, but checkAPIs.pl isn't smart +enough to figure that out. +Dissectors should still try to use proto_tree_add_debug_text when the +debugging context has a protocol tree. +*/ +#define ws_debug_printf printf + #ifdef __cplusplus } #endif /* __cplusplus */ |