From 86b28f0d4b2b5034186789682b1acb953399915b Mon Sep 17 00:00:00 2001 From: Michael Tuexen Date: Sun, 30 May 2021 01:08:14 +0200 Subject: [PATCH] wiretap: improve code consistency in pcapng.c --- wiretap/pcapng.c | 390 +++++++++++++++++++++++++---------------------- 1 file changed, 210 insertions(+), 180 deletions(-) diff --git a/wiretap/pcapng.c b/wiretap/pcapng.c index 92ff63c1f1..1029229443 100644 --- a/wiretap/pcapng.c +++ b/wiretap/pcapng.c @@ -512,7 +512,7 @@ pcapng_read_option(FILE_T fh, const section_info_t *section_info, /* read option header */ if (!wtap_read_bytes(fh, oh, sizeof (*oh), err, err_info)) { - ws_debug("pcapng_read_option: failed to read option"); + ws_debug("%s: failed to read option", G_STRFUNC); return -1; } block_read = sizeof (*oh); @@ -539,13 +539,13 @@ pcapng_read_option(FILE_T fh, const section_info_t *section_info, /* read option content */ if (!wtap_read_bytes(fh, content, oh->option_length, err, err_info)) { - ws_debug("pcapng_read_option: failed to read content of option %u", oh->option_code); + ws_debug("%s: failed to read content of option %u", G_STRFUNC, oh->option_code); return -1; } block_read += oh->option_length; /* jump over potential padding bytes at end of option */ - if ( (oh->option_length % 4) != 0) { + if ((oh->option_length % 4) != 0) { if (!wtap_read_bytes(fh, NULL, 4 - (oh->option_length % 4), err, err_info)) return -1; block_read += 4 - (oh->option_length % 4); @@ -712,8 +712,8 @@ pcapng_read_section_header_block(FILE_T fh, pcapng_block_header_t *bh, version_major = shb.version_major; version_minor = shb.version_minor; - ws_debug("pcapng_read_section_header_block: SHB (our byte order) V%u.%u, len %u", - version_major, version_minor, bh->block_total_length); + ws_debug("%s: SHB (our byte order) V%u.%u, len %u", G_STRFUNC, + version_major, version_minor, bh->block_total_length); break; case(0x4D3C2B1A): /* this seems pcapng with swapped byte order */ @@ -724,8 +724,8 @@ pcapng_read_section_header_block(FILE_T fh, pcapng_block_header_t *bh, /* tweak the block length to meet current swapping that we know now */ bh->block_total_length = GUINT32_SWAP_LE_BE(bh->block_total_length); - ws_debug("pcapng_read_section_header_block: SHB (byte-swapped) V%u.%u, len %u", - version_major, version_minor, bh->block_total_length); + ws_debug("%s: SHB (byte-swapped) V%u.%u, len %u", G_STRFUNC, + version_major, version_minor, bh->block_total_length); break; default: /* Not a "pcapng" magic number we know about. */ @@ -813,13 +813,13 @@ pcapng_read_section_header_block(FILE_T fh, pcapng_block_header_t *bh, *err = ENOMEM; /* we assume we're out of memory */ return PCAPNG_BLOCK_ERROR; } - ws_debug("pcapng_read_section_header_block: Options %u bytes", to_read); + ws_debug("%s: Options %u bytes", G_STRFUNC, to_read); while (to_read != 0) { /* read option */ - ws_debug("pcapng_read_section_header_block: Options %u bytes remaining", to_read); + ws_debug("%s: Options %u bytes remaining", G_STRFUNC, to_read); bytes_read = pcapng_read_option(fh, section_info, &oh, option_content, opt_cont_buf_len, to_read, err, err_info, "section_header"); if (bytes_read <= 0) { - ws_debug("pcapng_read_section_header_block: failed to read option"); + ws_debug("%s: failed to read option", G_STRFUNC); g_free(option_content); return PCAPNG_BLOCK_ERROR; } @@ -845,11 +845,11 @@ pcapng_read_section_header_block(FILE_T fh, pcapng_block_header_t *bh, switch (oh.option_code) { case(OPT_EOFOPT): if (to_read != 0) { - ws_debug("pcapng_read_section_header_block: %u bytes after opt_endofopt", to_read); + ws_debug("%s: %u bytes after opt_endofopt", G_STRFUNC, to_read); /* padding should be ok here, just get out of this */ to_read = 0; } else { - ws_debug("pcapng_read_section_header_block: opt_endofopt"); + ws_debug("%s: opt_endofopt", G_STRFUNC); } break; case(OPT_COMMENT): @@ -912,7 +912,7 @@ pcapng_read_if_descr_block(wtap *wth, FILE_T fh, pcapng_block_header_t *bh, /* read block content */ if (!wtap_read_bytes(fh, &idb, sizeof idb, err, err_info)) { - ws_debug("pcapng_read_if_descr_block: failed to read IDB"); + ws_debug("%s: failed to read IDB", G_STRFUNC); return FALSE; } @@ -931,18 +931,18 @@ pcapng_read_if_descr_block(wtap *wth, FILE_T fh, pcapng_block_header_t *bh, if_descr_mand->time_units_per_second = time_units_per_second; if_descr_mand->tsprecision = tsprecision; - ws_debug("pcapng_read_if_descr_block: IDB link_type %u (%s), snap %u", - link_type, - wtap_encap_description(if_descr_mand->wtap_encap), - if_descr_mand->snap_len); + ws_debug("%s: IDB link_type %u (%s), snap %u", G_STRFUNC, + link_type, + wtap_encap_description(if_descr_mand->wtap_encap), + if_descr_mand->snap_len); if (if_descr_mand->snap_len > wtap_max_snaplen_for_encap(if_descr_mand->wtap_encap)) { /* * We do not use this value, maybe we should check the * snap_len of the packets against it. For now, only warn. */ - ws_debug("pcapng_read_if_descr_block: snapshot length %u unrealistic.", - if_descr_mand->snap_len); + ws_debug("%s: snapshot length %u unrealistic.", G_STRFUNC, + if_descr_mand->snap_len); /*if_descr_mand->snap_len = WTAP_MAX_PACKET_SIZE_STANDARD;*/ } @@ -961,7 +961,7 @@ pcapng_read_if_descr_block(wtap *wth, FILE_T fh, pcapng_block_header_t *bh, /* read option */ bytes_read = pcapng_read_option(fh, section_info, &oh, option_content, opt_cont_buf_len, to_read, err, err_info, "if_descr"); if (bytes_read <= 0) { - ws_debug("pcapng_read_if_descr_block: failed to read option"); + ws_debug("%s: failed to read option", G_STRFUNC); g_free(option_content); return FALSE; } @@ -987,7 +987,7 @@ pcapng_read_if_descr_block(wtap *wth, FILE_T fh, pcapng_block_header_t *bh, switch (oh.option_code) { case(OPT_EOFOPT): /* opt_endofopt */ if (to_read != 0) { - ws_debug("pcapng_read_if_descr_block: %u bytes after opt_endofopt", to_read); + ws_debug("%s: %u bytes after opt_endofopt", G_STRFUNC, to_read); } /* padding should be ok here, just get out of this */ to_read = 0; @@ -1027,7 +1027,7 @@ pcapng_read_if_descr_block(wtap *wth, FILE_T fh, pcapng_block_header_t *bh, time_units_per_second = G_MAXUINT64; } if (time_units_per_second > (((guint64)1) << 32)) { - ws_debug("pcapng_open: time conversion might be inaccurate"); + ws_debug("%s: time conversion might be inaccurate", G_STRFUNC); } if_descr_mand->time_units_per_second = time_units_per_second; /* Fails with multiple options; we silently ignore the failure */ @@ -1045,9 +1045,10 @@ pcapng_read_if_descr_block(wtap *wth, FILE_T fh, pcapng_block_header_t *bh, else tsprecision = WTAP_TSPREC_SEC; if_descr_mand->tsprecision = tsprecision; - ws_debug("pcapng_read_if_descr_block: if_tsresol %u, units/s %" G_GINT64_MODIFIER "u, tsprecision %d", if_tsresol, if_descr_mand->time_units_per_second, tsprecision); + ws_debug("%s: if_tsresol %u, units/s %" G_GINT64_MODIFIER "u, tsprecision %d", + G_STRFUNC, if_tsresol, if_descr_mand->time_units_per_second, tsprecision); } else { - ws_debug("pcapng_read_if_descr_block: if_tsresol length %u not 1 as expected", oh.option_length); + ws_debug("%s: if_tsresol length %u not 1 as expected", G_STRFUNC, oh.option_length); } break; /* @@ -1063,7 +1064,8 @@ pcapng_read_if_descr_block(wtap *wth, FILE_T fh, pcapng_block_header_t *bh, if (option_content[0] == 0) { if_filter.type = if_filter_pcap; if_filter.data.filter_str = g_strndup((char *)option_content+1, oh.option_length-1); - ws_debug("pcapng_read_if_descr_block: filter_str %s oh.option_length %u", if_filter.data.filter_str, oh.option_length); + ws_debug("%s: filter_str %s oh.option_length %u", G_STRFUNC, + if_filter.data.filter_str, oh.option_length); /* Fails with multiple options; we silently ignore the failure */ wtap_block_add_if_filter_option(wblock->block, oh.option_code, &if_filter); g_free(if_filter.data.filter_str); @@ -1104,7 +1106,7 @@ pcapng_read_if_descr_block(wtap *wth, FILE_T fh, pcapng_block_header_t *bh, g_free(if_filter.data.bpf_prog.bpf_prog); } } else { - ws_debug("pcapng_read_if_descr_block: if_filter length %u seems strange", oh.option_length); + ws_debug("%s: if_filter length %u seems strange", G_STRFUNC, oh.option_length); } break; case(OPT_IDB_OS): /* if_os */ @@ -1119,10 +1121,10 @@ pcapng_read_if_descr_block(wtap *wth, FILE_T fh, pcapng_block_header_t *bh, if (oh.option_length == 1) { /* Fails with multiple options; we silently ignore the failure */ wtap_block_add_uint8_option(wblock->block, oh.option_code, option_content[0]); - ws_debug("pcapng_read_if_descr_block: if_fcslen %u", option_content[0]); + ws_debug("%s: if_fcslen %u", G_STRFUNC, option_content[0]); /* XXX - add sanity check */ } else { - ws_debug("pcapng_read_if_descr_block: if_fcslen length %u not 1 as expected", oh.option_length); + ws_debug("%s: if_fcslen length %u not 1 as expected", G_STRFUNC, oh.option_length); } break; case(OPT_IDB_HARDWARE): /* if_hardware */ @@ -1310,7 +1312,7 @@ pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, return FALSE; } if (!wtap_read_bytes(fh, &epb, sizeof epb, err, err_info)) { - ws_debug("pcapng_read_packet_block: failed to read packet data"); + ws_debug("%s: failed to read packet data", G_STRFUNC); return FALSE; } block_read = (guint)sizeof epb; @@ -1330,8 +1332,8 @@ pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, packet.cap_len = epb.captured_len; packet.packet_len = epb.packet_len; } - ws_debug("pcapng_read_packet_block: EPB on interface_id %d, cap_len %d, packet_len %d", - packet.interface_id, packet.cap_len, packet.packet_len); + ws_debug("%s: EPB on interface_id %d, cap_len %d, packet_len %d", + G_STRFUNC, packet.interface_id, packet.cap_len, packet.packet_len); } else { /* * Is this block long enough to be a PB? @@ -1341,12 +1343,12 @@ pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, * No. */ *err = WTAP_ERR_BAD_FILE; - *err_info = g_strdup_printf("pcapng_read_packet_block: total block length %u of a PB is less than the minimum PB size %u", - bh->block_total_length, MIN_PB_SIZE); + *err_info = g_strdup_printf("%s: total block length %u of a PB is less than the minimum PB size %u", + G_STRFUNC, bh->block_total_length, MIN_PB_SIZE); return FALSE; } if (!wtap_read_bytes(fh, &pb, sizeof pb, err, err_info)) { - ws_debug("pcapng_read_packet_block: failed to read packet data"); + ws_debug("%s: failed to read packet data", G_STRFUNC); return FALSE; } block_read = (guint)sizeof pb; @@ -1366,8 +1368,8 @@ pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, packet.cap_len = pb.captured_len; packet.packet_len = pb.packet_len; } - ws_debug("pcapng_read_packet_block: PB on interface_id %d, cap_len %d, packet_len %d", - packet.interface_id, packet.cap_len, packet.packet_len); + ws_debug("%s: PB on interface_id %d, cap_len %d, packet_len %d", + G_STRFUNC, packet.interface_id, packet.cap_len, packet.packet_len); } /* @@ -1385,7 +1387,7 @@ pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, } else { block_total_length = bh->block_total_length; } - ws_debug("pcapng_read_packet_block: block_total_length %d", block_total_length); + ws_debug("%s: block_total_length %d", G_STRFUNC, block_total_length); /* * Is this block long enough to hold the packet data? @@ -1397,8 +1399,8 @@ pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, * No. */ *err = WTAP_ERR_BAD_FILE; - *err_info = g_strdup_printf("pcapng_read_packet_block: total block length %u of EPB is too small for %u bytes of packet data", - block_total_length, packet.cap_len); + *err_info = g_strdup_printf("%s: total block length %u of EPB is too small for %u bytes of packet data", + G_STRFUNC, block_total_length, packet.cap_len); return FALSE; } } else { @@ -1408,20 +1410,22 @@ pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, * No. */ *err = WTAP_ERR_BAD_FILE; - *err_info = g_strdup_printf("pcapng_read_packet_block: total block length %u of PB is too small for %u bytes of packet data", - block_total_length, packet.cap_len); + *err_info = g_strdup_printf("%s: total block length %u of PB is too small for %u bytes of packet data", + G_STRFUNC, block_total_length, packet.cap_len); return FALSE; } } - ws_debug("pcapng_read_packet_block: packet data: packet_len %u captured_len %u interface_id %u", - packet.packet_len, - packet.cap_len, - packet.interface_id); + ws_debug("%s: packet data: packet_len %u captured_len %u interface_id %u", + G_STRFUNC, + packet.packet_len, + packet.cap_len, + packet.interface_id); if (packet.interface_id >= section_info->interfaces->len) { *err = WTAP_ERR_BAD_FILE; - *err_info = g_strdup_printf("pcapng_read_packet_block: interface index %u is not less than section interface count %u", + *err_info = g_strdup_printf("%s: interface index %u is not less than section interface count %u", + G_STRFUNC, packet.interface_id, section_info->interfaces->len); return FALSE; @@ -1440,10 +1444,11 @@ pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, wblock->rec->rec_type = REC_TYPE_PACKET; wblock->rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN|WTAP_HAS_INTERFACE_ID; - ws_debug("pcapng_read_packet_block: encapsulation = %d (%s), pseudo header size = %d.", - iface_info.wtap_encap, - wtap_encap_description(iface_info.wtap_encap), - pcap_get_phdr_size(iface_info.wtap_encap, &wblock->rec->rec_header.packet_header.pseudo_header)); + ws_debug("%s: encapsulation = %d (%s), pseudo header size = %d.", + G_STRFUNC, + iface_info.wtap_encap, + wtap_encap_description(iface_info.wtap_encap), + pcap_get_phdr_size(iface_info.wtap_encap, &wblock->rec->rec_header.packet_header.pseudo_header)); wblock->rec->rec_header.packet_header.interface_id = packet.interface_id; wblock->rec->rec_header.packet_header.pkt_encap = iface_info.wtap_encap; wblock->rec->tsprec = iface_info.tsprecision; @@ -1525,7 +1530,7 @@ pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, option_content = opt_ptr + sizeof (pcapng_option_header_t); bytes_read = pcapng_read_option(fh, section_info, oh, option_content, opt_cont_buf_len, to_read, err, err_info, "packet"); if (bytes_read <= 0) { - ws_debug("pcapng_read_packet_block: failed to read option"); + ws_debug("%s: failed to read option", G_STRFUNC); /* XXX - free anything? */ return FALSE; } @@ -1551,7 +1556,7 @@ pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, switch (oh->option_code) { case(OPT_EOFOPT): if (to_read != 0) { - ws_debug("pcapng_read_packet_block: %u bytes after opt_endofopt", to_read); + ws_debug("%s: %u bytes after opt_endofopt", G_STRFUNC, to_read); } /* padding should be ok here, just get out of this */ to_read = 0; @@ -1561,9 +1566,11 @@ pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, wblock->rec->presence_flags |= WTAP_HAS_COMMENTS; g_free(wblock->rec->opt_comment); wblock->rec->opt_comment = g_strndup((char *)option_content, oh->option_length); - ws_debug("pcapng_read_packet_block: length %u opt_comment '%s'", oh->option_length, wblock->rec->opt_comment); + ws_debug("%s: length %u opt_comment '%s'", G_STRFUNC, + oh->option_length, wblock->rec->opt_comment); } else { - ws_debug("pcapng_read_packet_block: opt_comment length %u seems strange", oh->option_length); + ws_debug("%s: opt_comment length %u seems strange", G_STRFUNC, + oh->option_length); } break; case(OPT_EPB_FLAGS): @@ -1588,17 +1595,18 @@ pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, /* The FCS length is present */ fcslen = PACK_FLAGS_FCS_LENGTH(wblock->rec->rec_header.packet_header.pack_flags); } - ws_debug("pcapng_read_packet_block: pack_flags %u (ignored)", wblock->rec->rec_header.packet_header.pack_flags); + ws_debug("%s: pack_flags 0x%08x", G_STRFUNC, + wblock->rec->rec_header.packet_header.pack_flags); break; case(OPT_EPB_HASH): - ws_debug("pcapng_read_packet_block: epb_hash %u currently not handled - ignoring %u bytes", - oh->option_code, oh->option_length); + ws_debug("%s: epb_hash %u currently not handled - ignoring %u bytes", + G_STRFUNC, oh->option_code, oh->option_length); break; case(OPT_EPB_DROPCOUNT): if (oh->option_length != 8) { *err = WTAP_ERR_BAD_FILE; - *err_info = g_strdup_printf("pcapng_read_packet_block: packet block drop count option length %u is not 8", - oh->option_length); + *err_info = g_strdup_printf("%s: packet block drop count option length %u is not 8", + G_STRFUNC, oh->option_length); /* XXX - free anything? */ return FALSE; } @@ -1613,13 +1621,14 @@ pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, memcpy(option_content, &wblock->rec->rec_header.packet_header.drop_count, sizeof(guint64)); } - ws_debug("pcapng_read_packet_block: drop_count %" G_GINT64_MODIFIER "u", wblock->rec->rec_header.packet_header.drop_count); + ws_debug("%s: drop_count %" G_GINT64_MODIFIER "u", G_STRFUNC, + wblock->rec->rec_header.packet_header.drop_count); break; case(OPT_EPB_PACKETID): if (oh->option_length != 8) { *err = WTAP_ERR_BAD_FILE; - *err_info = g_strdup_printf("pcapng_read_packet_block: packet block packet id option length %u is not 8", - oh->option_length); + *err_info = g_strdup_printf("%s: packet block packet id option length %u is not 8", + G_STRFUNC, oh->option_length); /* XXX - free anything? */ return FALSE; } @@ -1633,13 +1642,14 @@ pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, wblock->rec->rec_header.packet_header.packet_id = GUINT64_SWAP_LE_BE(wblock->rec->rec_header.packet_header.packet_id); memcpy(option_content, &wblock->rec->rec_header.packet_header.packet_id, sizeof(guint64)); } - ws_debug("pcapng_read_packet_block: packet_id %" G_GINT64_MODIFIER "u", wblock->rec->rec_header.packet_header.packet_id); + ws_debug("%s: packet_id %" G_GINT64_MODIFIER "u", G_STRFUNC, + wblock->rec->rec_header.packet_header.packet_id); break; case(OPT_EPB_QUEUE): if (oh->option_length != 4) { *err = WTAP_ERR_BAD_FILE; - *err_info = g_strdup_printf("pcapng_read_packet_block: packet block queue option length %u is not 4", - oh->option_length); + *err_info = g_strdup_printf("%s: packet block queue option length %u is not 4", + G_STRFUNC, oh->option_length); /* XXX - free anything? */ return FALSE; } @@ -1653,7 +1663,8 @@ pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, wblock->rec->rec_header.packet_header.interface_queue = GUINT32_SWAP_LE_BE(wblock->rec->rec_header.packet_header.interface_queue); memcpy(option_content, &wblock->rec->rec_header.packet_header.interface_queue, sizeof(guint32)); } - ws_debug("pcapng_read_packet_block: queue %u", wblock->rec->rec_header.packet_header.interface_queue); + ws_debug("%s: queue %u", G_STRFUNC, + wblock->rec->rec_header.packet_header.interface_queue); break; case(OPT_EPB_VERDICT): if (oh->option_length < 1 || @@ -1697,12 +1708,12 @@ pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, oh->option_length, g_free, option_content_copy)); - ws_debug("pcapng_read_packet_block: verdict type %u, data len %u", - option_content[0], oh->option_length - 1); + ws_debug("%s: verdict type %u, data len %u", G_STRFUNC, + option_content[0], oh->option_length - 1); break; default: - ws_debug("pcapng_read_packet_block: unknown option %u - ignoring %u bytes", - oh->option_code, oh->option_length); + ws_debug("%s: unknown option %u - ignoring %u bytes", G_STRFUNC, + oh->option_code, oh->option_length); break; } } @@ -1741,14 +1752,14 @@ pcapng_read_simple_packet_block(FILE_T fh, pcapng_block_header_t *bh, * No. */ *err = WTAP_ERR_BAD_FILE; - *err_info = g_strdup_printf("pcapng_read_simple_packet_block: total block length %u of an SPB is less than the minimum SPB size %u", - bh->block_total_length, MIN_SPB_SIZE); + *err_info = g_strdup_printf("%s: total block length %u of an SPB is less than the minimum SPB size %u", + G_STRFUNC, bh->block_total_length, MIN_SPB_SIZE); return FALSE; } /* "Simple Packet Block" read fixed part */ if (!wtap_read_bytes(fh, &spb, sizeof spb, err, err_info)) { - ws_debug("pcapng_read_simple_packet_block: failed to read packet data"); + ws_debug("%s: failed to read packet data", G_STRFUNC); return FALSE; } @@ -1790,7 +1801,7 @@ pcapng_read_simple_packet_block(FILE_T fh, pcapng_block_header_t *bh, } else { block_total_length = bh->block_total_length; } - ws_debug("pcapng_read_simple_packet_block: block_total_length %d", block_total_length); + ws_debug("%s: block_total_length %d", G_STRFUNC, block_total_length); /* * Is this block long enough to hold the packet data? @@ -1815,11 +1826,11 @@ pcapng_read_simple_packet_block(FILE_T fh, pcapng_block_header_t *bh, wtap_max_snaplen_for_encap(iface_info.wtap_encap)); return FALSE; } - ws_debug("pcapng_read_simple_packet_block: packet data: packet_len %u", - simple_packet.packet_len); + ws_debug("%s: packet data: packet_len %u", + G_STRFUNC, simple_packet.packet_len); - ws_debug("pcapng_read_simple_packet_block: Need to read pseudo header of size %d", - pcap_get_phdr_size(iface_info.wtap_encap, &wblock->rec->rec_header.packet_header.pseudo_header)); + ws_debug("%s: Need to read pseudo header of size %d", + G_STRFUNC, pcap_get_phdr_size(iface_info.wtap_encap, &wblock->rec->rec_header.packet_header.pseudo_header)); /* No time stamp in a simple packet block; no options, either */ wblock->rec->rec_type = REC_TYPE_PACKET; @@ -1951,14 +1962,14 @@ pcapng_read_name_resolution_block(FILE_T fh, pcapng_block_header_t *bh, * No. */ *err = WTAP_ERR_BAD_FILE; - *err_info = g_strdup_printf("pcapng_read_name_resolution_block: total block length %u of an NRB is less than the minimum NRB size %u", - bh->block_total_length, MIN_NRB_SIZE); + *err_info = g_strdup_printf("%s: total block length %u of an NRB is less than the minimum NRB size %u", + G_STRFUNC, bh->block_total_length, MIN_NRB_SIZE); return FALSE; } to_read = bh->block_total_length - 8 - 4; /* We have read the header and should not read the final block_total_length */ - ws_debug("pcapng_read_name_resolution_block, total %d bytes", bh->block_total_length); + ws_debug("%s: total %d bytes", G_STRFUNC, bh->block_total_length); /* Ensure we have a name resolution block */ if (wblock->block == NULL) { @@ -1979,14 +1990,15 @@ pcapng_read_name_resolution_block(FILE_T fh, pcapng_block_header_t *bh, if ((size_t)(to_read - block_read) < sizeof nrb) { ws_buffer_free(&nrb_rec); *err = WTAP_ERR_BAD_FILE; - *err_info = g_strdup_printf("pcapng_read_name_resolution_block: %d bytes left in the block < NRB record header size %u", + *err_info = g_strdup_printf("%s: %d bytes left in the block < NRB record header size %u", + G_STRFUNC, to_read - block_read, (guint)sizeof nrb); return FALSE; } if (!wtap_read_bytes(fh, &nrb, sizeof nrb, err, err_info)) { ws_buffer_free(&nrb_rec); - ws_debug("pcapng_read_name_resolution_block: failed to read record header"); + ws_debug("%s: failed to read record header", G_STRFUNC); return FALSE; } block_read += (int)sizeof nrb; @@ -1999,7 +2011,8 @@ pcapng_read_name_resolution_block(FILE_T fh, pcapng_block_header_t *bh, if (to_read - block_read < nrb.record_len + PADDING4(nrb.record_len)) { ws_buffer_free(&nrb_rec); *err = WTAP_ERR_BAD_FILE; - *err_info = g_strdup_printf("pcapng_read_name_resolution_block: %d bytes left in the block < NRB record length + padding %u", + *err_info = g_strdup_printf("%s: %d bytes left in the block < NRB record length + padding %u", + G_STRFUNC, to_read - block_read, nrb.record_len + PADDING4(nrb.record_len)); return FALSE; @@ -2027,15 +2040,15 @@ pcapng_read_name_resolution_block(FILE_T fh, pcapng_block_header_t *bh, if (nrb.record_len < 4) { ws_buffer_free(&nrb_rec); *err = WTAP_ERR_BAD_FILE; - *err_info = g_strdup_printf("pcapng_read_name_resolution_block: NRB record length for IPv4 record %u < minimum length 4", - nrb.record_len); + *err_info = g_strdup_printf("%s: NRB record length for IPv4 record %u < minimum length 4", + G_STRFUNC, nrb.record_len); return FALSE; } ws_buffer_assure_space(&nrb_rec, nrb.record_len); if (!wtap_read_bytes(fh, ws_buffer_start_ptr(&nrb_rec), nrb.record_len, err, err_info)) { ws_buffer_free(&nrb_rec); - ws_debug("pcapng_read_name_resolution_block: failed to read IPv4 record data"); + ws_debug("%s: failed to read IPv4 record data", G_STRFUNC); return FALSE; } block_read += nrb.record_len; @@ -2133,7 +2146,7 @@ pcapng_read_name_resolution_block(FILE_T fh, pcapng_block_header_t *bh, block_read += PADDING4(nrb.record_len); break; default: - ws_debug("pcapng_read_name_resolution_block: unknown record type 0x%x", nrb.record_type); + ws_debug("%s: unknown record type 0x%x", G_STRFUNC, nrb.record_type); if (!wtap_read_bytes(fh, NULL, nrb.record_len + PADDING4(nrb.record_len), err, err_info)) { ws_buffer_free(&nrb_rec); return FALSE; @@ -2169,7 +2182,7 @@ read_options: /* read option */ bytes_read = pcapng_read_option(fh, section_info, &oh, option_content, opt_cont_buf_len, to_read, err, err_info, "name_resolution"); if (bytes_read <= 0) { - ws_debug("pcapng_read_name_resolution_block: failed to read option"); + ws_debug("%s: failed to read option", G_STRFUNC); g_free(option_content); ws_buffer_free(&nrb_rec); return FALSE; @@ -2196,7 +2209,7 @@ read_options: switch (oh.option_code) { case(OPT_EOFOPT): if (to_read != 0) { - ws_debug("pcapng_read_name_resolution_block: %u bytes after opt_endofopt", to_read); + ws_debug("%s: %u bytes after opt_endofopt", G_STRFUNC, to_read); } /* padding should be ok here, just get out of this */ to_read = 0; @@ -2243,14 +2256,14 @@ pcapng_read_interface_statistics_block(FILE_T fh, pcapng_block_header_t *bh, * No. */ *err = WTAP_ERR_BAD_FILE; - *err_info = g_strdup_printf("pcapng_read_interface_statistics_block: total block length %u is too small (< %u)", - bh->block_total_length, MIN_ISB_SIZE); + *err_info = g_strdup_printf("%s: total block length %u is too small (< %u)", + G_STRFUNC, bh->block_total_length, MIN_ISB_SIZE); return FALSE; } /* "Interface Statistics Block" read fixed part */ if (!wtap_read_bytes(fh, &isb, sizeof isb, err, err_info)) { - ws_debug("pcapng_read_interface_statistics_block: failed to read packet data"); + ws_debug("%s: failed to read packet data", G_STRFUNC); return FALSE; } @@ -2265,7 +2278,7 @@ pcapng_read_interface_statistics_block(FILE_T fh, pcapng_block_header_t *bh, if_stats_mand->ts_high = isb.timestamp_high; if_stats_mand->ts_low = isb.timestamp_low; } - ws_debug("pcapng_read_interface_statistics_block: interface_id %u", if_stats_mand->interface_id); + ws_debug("%s: interface_id %u", G_STRFUNC, if_stats_mand->interface_id); /* Options */ to_read = bh->block_total_length - @@ -2283,7 +2296,7 @@ pcapng_read_interface_statistics_block(FILE_T fh, pcapng_block_header_t *bh, /* read option */ bytes_read = pcapng_read_option(fh, section_info, &oh, option_content, opt_cont_buf_len, to_read, err, err_info, "interface_statistics"); if (bytes_read <= 0) { - ws_debug("pcapng_read_interface_statistics_block: failed to read option"); + ws_debug("%s: failed to read option", G_STRFUNC); g_free(option_content); return FALSE; } @@ -2309,7 +2322,7 @@ pcapng_read_interface_statistics_block(FILE_T fh, pcapng_block_header_t *bh, switch (oh.option_code) { case(OPT_EOFOPT): /* opt_endofopt */ if (to_read != 0) { - ws_debug("pcapng_read_interface_statistics_block: %u bytes after opt_endofopt", to_read); + ws_debug("%s: %u bytes after opt_endofopt", G_STRFUNC, to_read); } /* padding should be ok here, just get out of this */ to_read = 0; @@ -2393,8 +2406,8 @@ pcapng_read_sysdig_event_block(FILE_T fh, pcapng_block_header_t *bh, block_total_length = bh->block_total_length; } - ws_debug("pcapng_read_sysdig_event_block: block_total_length %u", - bh->block_total_length); + ws_debug("%s: block_total_length %u", + G_STRFUNC, bh->block_total_length); wblock->rec->rec_type = REC_TYPE_SYSCALL; wblock->rec->rec_header.syscall_header.record_type = bh->block_type; @@ -2402,28 +2415,28 @@ pcapng_read_sysdig_event_block(FILE_T fh, pcapng_block_header_t *bh, wblock->rec->tsprec = WTAP_TSPREC_NSEC; if (!wtap_read_bytes(fh, &cpu_id, sizeof cpu_id, err, err_info)) { - ws_debug("pcapng_read_packet_block: failed to read sysdig event cpu id"); + ws_debug("%s: failed to read sysdig event cpu id", G_STRFUNC); return FALSE; } if (!wtap_read_bytes(fh, &wire_ts, sizeof wire_ts, err, err_info)) { - ws_debug("pcapng_read_packet_block: failed to read sysdig event timestamp"); + ws_debug("%s: failed to read sysdig event timestamp", G_STRFUNC); return FALSE; } if (!wtap_read_bytes(fh, &thread_id, sizeof thread_id, err, err_info)) { - ws_debug("pcapng_read_packet_block: failed to read sysdig event thread id"); + ws_debug("%s: failed to read sysdig event thread id", G_STRFUNC); return FALSE; } if (!wtap_read_bytes(fh, &event_len, sizeof event_len, err, err_info)) { - ws_debug("pcapng_read_packet_block: failed to read sysdig event length"); + ws_debug("%s: failed to read sysdig event length", G_STRFUNC); return FALSE; } if (!wtap_read_bytes(fh, &event_type, sizeof event_type, err, err_info)) { - ws_debug("pcapng_read_packet_block: failed to read sysdig event type"); + ws_debug("%s: failed to read sysdig event type", G_STRFUNC); return FALSE; } if (bh->block_type == BLOCK_TYPE_SYSDIG_EVENT_V2) { if (!wtap_read_bytes(fh, &nparams, sizeof nparams, err, err_info)) { - ws_debug("pcapng_read_packet_block: failed to read sysdig number of parameters"); + ws_debug("%s: failed to read sysdig number of parameters", G_STRFUNC); return FALSE; } } @@ -2645,7 +2658,7 @@ pcapng_read_and_check_block_trailer(FILE_T fh, pcapng_block_header_t *bh, /* sanity check: first and second block lengths must match */ if (!wtap_read_bytes(fh, &block_total_length, sizeof block_total_length, err, err_info)) { - ws_debug("pcapng_read_and_check_block_trailer: couldn't read second block length"); + ws_debug("%s: couldn't read second block length", G_STRFUNC); return FALSE; } @@ -2654,8 +2667,8 @@ pcapng_read_and_check_block_trailer(FILE_T fh, pcapng_block_header_t *bh, if (block_total_length != bh->block_total_length) { *err = WTAP_ERR_BAD_FILE; - *err_info = g_strdup_printf("pcapng_read_and_check_block_trailer: total block lengths (first %u and second %u) don't match", - bh->block_total_length, block_total_length); + *err_info = g_strdup_printf("%s: total block lengths (first %u and second %u) don't match", + G_STRFUNC, bh->block_total_length, block_total_length); return FALSE; } return TRUE; @@ -2675,7 +2688,7 @@ pcapng_read_block(wtap *wth, FILE_T fh, pcapng_t *pn, /* Try to read the (next) block header */ if (!wtap_read_bytes_or_eof(fh, &bh, sizeof bh, err, err_info)) { - ws_debug("pcapng_read_block: wtap_read_bytes_or_eof() failed, err = %d.", *err); + ws_debug("%s: wtap_read_bytes_or_eof() failed, err = %d.", G_STRFUNC, *err); return FALSE; } @@ -2702,7 +2715,7 @@ pcapng_read_block(wtap *wth, FILE_T fh, pcapng_t *pn, */ wblock->type = bh.block_type; - ws_debug("pcapng_read_block: block_type 0x%x", bh.block_type); + ws_debug("%s: block_type 0x%08x", G_STRFUNC, bh.block_type); /* * Fill in the section_info_t passed to us for use when @@ -2732,7 +2745,7 @@ pcapng_read_block(wtap *wth, FILE_T fh, pcapng_t *pn, wblock->type = bh.block_type; - ws_debug("pcapng_read_block: block_type 0x%x", bh.block_type); + ws_debug("%s: block_type 0x%08x", G_STRFUNC, bh.block_type); /* Don't try to allocate memory for a huge number of options, as that might fail and, even if it succeeds, it might not leave @@ -2796,7 +2809,8 @@ pcapng_read_block(wtap *wth, FILE_T fh, pcapng_t *pn, return FALSE; break; default: - ws_debug("pcapng_read_block: Unknown block_type: 0x%x (block ignored), block total length %d", bh.block_type, bh.block_total_length); + ws_debug("%s: Unknown block_type: 0x%08x (block ignored), block total length %d", + G_STRFUNC, bh.block_type, bh.block_total_length); if (!pcapng_read_unknown_block(fh, &bh, section_info, wblock, err, err_info)) return FALSE; break; @@ -2867,14 +2881,14 @@ pcapng_open(wtap *wth, int *err, gchar **err_info) gint64 saved_offset; section_info_t first_section, new_section, *current_section; - ws_debug("pcapng_open: opening file"); + ws_debug("%s: opening file", G_STRFUNC); /* * Read first block. * * First, try to read the block header. */ if (!wtap_read_bytes_or_eof(wth->fh, &bh, sizeof bh, err, err_info)) { - ws_debug("pcapng_open: wtap_read_bytes_or_eof() failed, err = %d.", *err); + ws_debug("%s: wtap_read_bytes_or_eof() failed, err = %d.", G_STRFUNC, *err); if (*err == 0 || *err == WTAP_ERR_SHORT_READ) { /* * Short read or EOF. @@ -2902,11 +2916,11 @@ pcapng_open(wtap *wth, int *err, gchar **err_info) * between Windows and UN*X as text rather than * binary data? */ - ws_debug("pcapng_open: first block type %u not SHB", bh.block_type); + ws_debug("%s: first block type 0x%08x not SHB", G_STRFUNC, bh.block_type); return WTAP_OPEN_NOT_MINE; } - ws_debug("pcapng_open: got an SHB"); + ws_debug("%s: got an SHB", G_STRFUNC); /* * Now try to read the block body, filling in the section_info_t @@ -3021,10 +3035,11 @@ pcapng_open(wtap *wth, int *err, gchar **err_info) if (!wtap_read_bytes_or_eof(wth->fh, &bh, sizeof bh, err, err_info)) { if (*err == 0) { /* EOF */ - ws_debug("No more IDBs available..."); + ws_debug("%s: No more IDBs available...", G_STRFUNC); break; } - ws_debug("pcapng_open: Check for more IDBs, wtap_read_bytes_or_eof() failed, err = %d.", *err); + ws_debug("%s: Check for more IDBs, wtap_read_bytes_or_eof() failed, err = %d.", + G_STRFUNC, *err); return WTAP_OPEN_ERROR; } @@ -3041,7 +3056,8 @@ pcapng_open(wtap *wth, int *err, gchar **err_info) bh.block_type = GUINT32_SWAP_LE_BE(bh.block_type); } - ws_debug("pcapng_open: Check for more IDBs, block_type 0x%x", bh.block_type); + ws_debug("%s: Check for more IDBs, block_type 0x%08x", + G_STRFUNC, bh.block_type); if (bh.block_type != BLOCK_TYPE_IDB) { break; /* No more IDBs */ @@ -3051,17 +3067,17 @@ pcapng_open(wtap *wth, int *err, gchar **err_info) &new_section, &wblock, err, err_info)) { wtap_block_free(wblock.block); if (*err == 0) { - ws_debug("No more IDBs available..."); + ws_debug("%s: No more IDBs available...", G_STRFUNC); break; } else { - ws_debug("pcapng_open: couldn't read IDB"); + ws_debug("%s:: couldn't read IDB", G_STRFUNC); return WTAP_OPEN_ERROR; } } pcapng_process_idb(wth, current_section, &wblock); wtap_block_free(wblock.block); - ws_debug("pcapng_open: Read IDB number_of_interfaces %u, wtap_encap %i", - wth->interface_data->len, wth->file_encap); + ws_debug("%s: Read IDB number_of_interfaces %u, wtap_encap %i", + G_STRFUNC, wth->interface_data->len, wth->file_encap); } return WTAP_OPEN_MINE; } @@ -3089,7 +3105,7 @@ pcapng_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err, /* read next block */ while (1) { *data_offset = file_tell(wth->fh); - ws_debug("pcapng_read: data_offset is %" G_GINT64_MODIFIER "d", *data_offset); + ws_debug("%s: data_offset is %" G_GINT64_MODIFIER "d", G_STRFUNC, *data_offset); /* * Get the section_info_t for the current section. @@ -3102,8 +3118,8 @@ pcapng_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err, */ if (!pcapng_read_block(wth, wth->fh, pcapng, current_section, &new_section, &wblock, err, err_info)) { - ws_debug("pcapng_read: data_offset is finally %" G_GINT64_MODIFIER "d", *data_offset); - ws_debug("pcapng_read: couldn't read packet block"); + ws_debug("%s: data_offset is finally %" G_GINT64_MODIFIER "d", G_STRFUNC, *data_offset); + ws_debug("%s: couldn't read packet block", G_STRFUNC); wtap_block_free(wblock.block); return FALSE; } @@ -3112,6 +3128,7 @@ pcapng_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err, /* * This is a block type we return to the caller to process. */ + ws_debug("%s: rec_type %u", G_STRFUNC, wblock.rec->rec_type); break; } @@ -3122,7 +3139,7 @@ pcapng_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err, switch (wblock.type) { case(BLOCK_TYPE_SHB): - ws_debug("pcapng_read: another section header block"); + ws_debug("%s: another section header block", G_STRFUNC); g_array_append_val(wth->shb_hdrs, wblock.block); /* @@ -3138,21 +3155,21 @@ pcapng_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err, case(BLOCK_TYPE_IDB): /* A new interface */ - ws_debug("pcapng_read: block type BLOCK_TYPE_IDB"); + ws_debug("%s: block type BLOCK_TYPE_IDB", G_STRFUNC); pcapng_process_idb(wth, current_section, &wblock); wtap_block_free(wblock.block); break; case(BLOCK_TYPE_DSB): /* Decryption secrets. */ - ws_debug("pcapng_read: block type BLOCK_TYPE_DSB"); + ws_debug("%s: block type BLOCK_TYPE_DSB", G_STRFUNC); pcapng_process_dsb(wth, &wblock); /* Do not free wblock.block, it is consumed by pcapng_process_dsb */ break; case(BLOCK_TYPE_NRB): /* More name resolution entries */ - ws_debug("pcapng_read: block type BLOCK_TYPE_NRB"); + ws_debug("%s: block type BLOCK_TYPE_NRB", G_STRFUNC); if (wth->nrb_hdrs == NULL) { wth->nrb_hdrs = g_array_new(FALSE, FALSE, sizeof(wtap_block_t)); } @@ -3180,17 +3197,18 @@ pcapng_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err, * that would be the best way of showing "summary" * statistics. */ - ws_debug("pcapng_read: block type BLOCK_TYPE_ISB"); + ws_debug("%s: block type BLOCK_TYPE_ISB", G_STRFUNC); if_stats_mand_block = (wtapng_if_stats_mandatory_t*)wtap_block_get_mandatory_data(wblock.block); if (wth->interface_data->len <= if_stats_mand_block->interface_id) { - ws_debug("pcapng_read: BLOCK_TYPE_ISB wblock.if_stats.interface_id %u >= number_of_interfaces", if_stats_mand_block->interface_id); + ws_debug("%s: BLOCK_TYPE_ISB wblock.if_stats.interface_id %u >= number_of_interfaces", + G_STRFUNC, if_stats_mand_block->interface_id); } else { /* Get the interface description */ wtapng_if_descr = g_array_index(wth->interface_data, wtap_block_t, if_stats_mand_block->interface_id); wtapng_if_descr_mand = (wtapng_if_descr_mandatory_t*)wtap_block_get_mandatory_data(wtapng_if_descr); if (wtapng_if_descr_mand->num_stat_entries == 0) { /* First ISB found, no previous entry */ - ws_debug("pcapng_read: block type BLOCK_TYPE_ISB. First ISB found, no previous entry"); + ws_debug("%s: block type BLOCK_TYPE_ISB. First ISB found, no previous entry", G_STRFUNC); wtapng_if_descr_mand->interface_statistics = g_array_new(FALSE, FALSE, sizeof(wtap_block_t)); } @@ -3209,13 +3227,13 @@ pcapng_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err, default: /* XXX - improve handling of "unknown" blocks */ - ws_debug("pcapng_read: Unknown block type 0x%08x", wblock.type); + ws_debug("%s: Unknown block type 0x%08x", G_STRFUNC, wblock.type); break; } } - /*ws_debug("Read length: %u Packet length: %u", bytes_read, rec->rec_header.packet_header.caplen);*/ - ws_debug("pcapng_read: data_offset is finally %" G_GINT64_MODIFIER "d", *data_offset); + /*ws_debug("%s: Read length: %u Packet length: %u", G_STRFUNC, bytes_read, rec->rec_header.packet_header.caplen);*/ + ws_debug("%s: data_offset is finally %" G_GINT64_MODIFIER "d", G_STRFUNC, *data_offset); return TRUE; } @@ -3236,7 +3254,7 @@ pcapng_seek_read(wtap *wth, gint64 seek_off, if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) < 0) { return FALSE; /* Seek error */ } - ws_debug("pcapng_seek_read: reading at offset %" G_GINT64_MODIFIER "u", seek_off); + ws_debug("%s: reading at offset %" G_GINT64_MODIFIER "u", G_STRFUNC, seek_off); /* * Find the section_info_t for the section in which this block @@ -3275,16 +3293,15 @@ pcapng_seek_read(wtap *wth, gint64 seek_off, /* read the block */ if (!pcapng_read_block(wth, wth->random_fh, pcapng, section_info, &new_section, &wblock, err, err_info)) { - ws_debug("pcapng_seek_read: couldn't read packet block (err=%d).", - *err); + ws_debug("%s: couldn't read packet block (err=%d).", G_STRFUNC, *err); wtap_block_free(wblock.block); return FALSE; } /* block must not be one we process internally rather than supplying */ if (wblock.internal) { - ws_debug("pcapng_seek_read: block type %u is not one we return", - wblock.type); + ws_debug("%s: block type 0x%08x is not one we return", + G_STRFUNC, wblock.type); wtap_block_free(wblock.block); return FALSE; } @@ -3300,7 +3317,7 @@ pcapng_close(wtap *wth) { pcapng_t *pcapng = (pcapng_t *)wth->priv; - ws_debug("pcapng_close: closing file"); + ws_debug("%s: closing file", G_STRFUNC); /* * Free up the interfaces tables for all the sections. @@ -3526,7 +3543,7 @@ pcapng_write_section_header_block(wtap_dumper *wdh, int *err) block_size.size = 0; bh.block_total_length = (guint32)(sizeof(bh) + sizeof(shb) + 4); if (wdh_shb) { - ws_debug("pcapng_write_section_header_block: Have shb_hdr"); + ws_debug("%s: Have shb_hdr", G_STRFUNC); /* Compute block size */ wtap_block_foreach_option(wdh_shb, compute_shb_option_size, &block_size); @@ -3539,7 +3556,7 @@ pcapng_write_section_header_block(wtap_dumper *wdh, int *err) bh.block_total_length += block_size.size; } - ws_debug("pcapng_write_section_header_block: Total len %u", bh.block_total_length); + ws_debug("%s: Total len %u", G_STRFUNC, bh.block_total_length); /* write block header */ bh.block_type = BLOCK_TYPE_SHB; @@ -3801,7 +3818,8 @@ pcapng_write_enhanced_packet_block(wtap_dumper *wdh, const wtap_rec *rec, wdh->bytes_dumped += 4; /* Write the comments string */ - ws_debug("pcapng_write_enhanced_packet_block, comment:'%s' comment_len %u comment_pad_len %u" , rec->opt_comment, comment_len, comment_pad_len); + ws_debug("%s: comment:'%s' comment_len %u comment_pad_len %u", + G_STRFUNC, rec->opt_comment, comment_len, comment_pad_len); if (!wtap_dump_file_write(wdh, rec->opt_comment, comment_len, err)) return FALSE; wdh->bytes_dumped += comment_len; @@ -3813,9 +3831,8 @@ pcapng_write_enhanced_packet_block(wtap_dumper *wdh, const wtap_rec *rec, wdh->bytes_dumped += comment_pad_len; } - ws_debug("pcapng_write_enhanced_packet_block: Wrote Options comments: comment_len %u, comment_pad_len %u", - comment_len, - comment_pad_len); + ws_debug("%s: Wrote Options comments: comment_len %u, comment_pad_len %u", + G_STRFUNC, comment_len, comment_pad_len); } if (rec->presence_flags & WTAP_HAS_PACK_FLAGS) { option_hdr.type = OPT_EPB_FLAGS; @@ -3826,7 +3843,8 @@ pcapng_write_enhanced_packet_block(wtap_dumper *wdh, const wtap_rec *rec, if (!wtap_dump_file_write(wdh, &rec->rec_header.packet_header.pack_flags, 4, err)) return FALSE; wdh->bytes_dumped += 4; - ws_debug("pcapng_write_enhanced_packet_block: Wrote Options packet flags: %x", rec->rec_header.packet_header.pack_flags); + ws_debug("%s: Wrote Options packet flags: %x", + G_STRFUNC, rec->rec_header.packet_header.pack_flags); } if (rec->presence_flags & WTAP_HAS_DROP_COUNT) { option_hdr.type = OPT_EPB_DROPCOUNT; @@ -3837,7 +3855,8 @@ pcapng_write_enhanced_packet_block(wtap_dumper *wdh, const wtap_rec *rec, if (!wtap_dump_file_write(wdh, &rec->rec_header.packet_header.drop_count, 8, err)) return FALSE; wdh->bytes_dumped += 8; - ws_debug("pcapng_write_enhanced_packet_block: Wrote Options drop count: %" G_GINT64_MODIFIER "u", rec->rec_header.packet_header.drop_count); + ws_debug("%s: Wrote Options drop count: %" G_GINT64_MODIFIER "u", + G_STRFUNC, rec->rec_header.packet_header.drop_count); } if (rec->presence_flags & WTAP_HAS_PACKET_ID) { option_hdr.type = OPT_EPB_PACKETID; @@ -3848,7 +3867,8 @@ pcapng_write_enhanced_packet_block(wtap_dumper *wdh, const wtap_rec *rec, if (!wtap_dump_file_write(wdh, &rec->rec_header.packet_header.packet_id, 8, err)) return FALSE; wdh->bytes_dumped += 8; - ws_debug("pcapng_write_enhanced_packet_block: Wrote Options packet id: %" G_GINT64_MODIFIER "u", rec->rec_header.packet_header.packet_id); + ws_debug("%s: Wrote Options packet id: %" G_GINT64_MODIFIER "u", + G_STRFUNC, rec->rec_header.packet_header.packet_id); } if (rec->presence_flags & WTAP_HAS_INT_QUEUE) { option_hdr.type = OPT_EPB_QUEUE; @@ -3859,7 +3879,8 @@ pcapng_write_enhanced_packet_block(wtap_dumper *wdh, const wtap_rec *rec, if (!wtap_dump_file_write(wdh, &rec->rec_header.packet_header.interface_queue, 4, err)) return FALSE; wdh->bytes_dumped += 4; - ws_debug("pcapng_write_enhanced_packet_block: Wrote Options queue: %u", rec->rec_header.packet_header.interface_queue); + ws_debug("%s: Wrote Options queue: %u", + G_STRFUNC, rec->rec_header.packet_header.interface_queue); } if (rec->presence_flags & WTAP_HAS_VERDICT && rec->packet_verdict != NULL) { @@ -3886,8 +3907,8 @@ pcapng_write_enhanced_packet_block(wtap_dumper *wdh, const wtap_rec *rec, return FALSE; wdh->bytes_dumped += plen; } - ws_debug("pcapng_write_enhanced_packet_block: Wrote Options verdict: %u", - verdict_data[0]); + ws_debug("%s: Wrote Options verdict: %u", + G_STRFUNC, verdict_data[0]); } } } @@ -4040,9 +4061,9 @@ pcapng_write_systemd_journal_export_block(wtap_dumper *wdh, const wtap_rec *rec, bh.block_type = BLOCK_TYPE_SYSTEMD_JOURNAL; bh.block_total_length = (guint32)sizeof(bh) + rec->rec_header.systemd_journal_header.record_len + pad_len + 4; - ws_debug("%s: writing %u bytes, %u padded", G_STRFUNC, - rec->rec_header.systemd_journal_header.record_len, - bh.block_total_length); + ws_debug("%s: writing %u bytes, %u padded", + G_STRFUNC, rec->rec_header.systemd_journal_header.record_len, + bh.block_total_length); if (!wtap_dump_file_write(wdh, &bh, sizeof bh, err)) return FALSE; @@ -4365,7 +4386,8 @@ pcapng_write_name_resolution_block(wtap_dumper *wdh, int *err) /* Copy the block trailer. */ memcpy(block_data + block_off, &bh.block_total_length, sizeof(bh.block_total_length)); - ws_debug("pcapng_write_name_resolution_block: Write bh.block_total_length bytes %d, block_off %u", bh.block_total_length, block_off); + ws_debug("%s: Write bh.block_total_length bytes %d, block_off %u", + G_STRFUNC, bh.block_total_length, block_off); if (!wtap_dump_file_write(wdh, block_data, bh.block_total_length, err)) { g_free(block_data); @@ -4388,7 +4410,8 @@ pcapng_write_name_resolution_block(wtap_dumper *wdh, int *err) block_off += namelen; memset(block_data + block_off, 0, PADDING4(namelen)); block_off += PADDING4(namelen); - ws_debug("NRB: added IPv4 record for %s", ipv4_hash_list_entry->name); + ws_debug("%s: added IPv4 record for %s", + G_STRFUNC, ipv4_hash_list_entry->name); i++; ipv4_hash_list_entry = (hashipv4_t *)g_list_nth_data(wdh->addrinfo_lists->ipv4_addr_list, i); @@ -4445,7 +4468,8 @@ pcapng_write_name_resolution_block(wtap_dumper *wdh, int *err) /* Copy the block trailer. */ memcpy(block_data + block_off, &bh.block_total_length, sizeof(bh.block_total_length)); - ws_debug("pcapng_write_name_resolution_block: Write bh.block_total_length bytes %d, block_off %u", bh.block_total_length, block_off); + ws_debug("%s: write bh.block_total_length bytes %d, block_off %u", + G_STRFUNC, bh.block_total_length, block_off); if (!wtap_dump_file_write(wdh, block_data, bh.block_total_length, err)) { g_free(block_data); @@ -4468,7 +4492,8 @@ pcapng_write_name_resolution_block(wtap_dumper *wdh, int *err) block_off += namelen; memset(block_data + block_off, 0, PADDING4(namelen)); block_off += PADDING4(namelen); - ws_debug("NRB: added IPv6 record for %s", ipv6_hash_list_entry->name); + ws_debug("%s: added IPv6 record for %s", + G_STRFUNC, ipv6_hash_list_entry->name); i++; ipv6_hash_list_entry = (hashipv6_t *)g_list_nth_data(wdh->addrinfo_lists->ipv6_addr_list, i); @@ -4495,7 +4520,8 @@ pcapng_write_name_resolution_block(wtap_dumper *wdh, int *err) /* Copy the block trailer. */ memcpy(block_data + block_off, &bh.block_total_length, sizeof(bh.block_total_length)); - ws_debug("pcapng_write_name_resolution_block: Write bh.block_total_length bytes %d, block_off %u", bh.block_total_length, block_off); + ws_debug("%s: Write bh.block_total_length bytes %d, block_off %u", + G_STRFUNC, bh.block_total_length, block_off); if (!wtap_dump_file_write(wdh, block_data, bh.block_total_length, err)) { g_free(block_data); @@ -4595,7 +4621,7 @@ pcapng_write_interface_statistics_block(wtap_dumper *wdh, wtap_block_t if_stats, struct pcapng_option_header option_hdr; wtapng_if_stats_mandatory_t* mand_data = (wtapng_if_stats_mandatory_t*)wtap_block_get_mandatory_data(if_stats); - ws_debug("pcapng_write_interface_statistics_block"); + ws_debug("%s", G_STRFUNC); /* Compute block size */ block_size.size = 0; @@ -4609,7 +4635,7 @@ pcapng_write_interface_statistics_block(wtap_dumper *wdh, wtap_block_t if_stats, /* write block header */ bh.block_type = BLOCK_TYPE_ISB; bh.block_total_length = (guint32)(sizeof(bh) + sizeof(isb) + block_size.size + 4); - ws_debug("pcapng_write_interface_statistics_block: Total len %u", bh.block_total_length); + ws_debug("%s: Total len %u", G_STRFUNC, bh.block_total_length); if (!wtap_dump_file_write(wdh, &bh, sizeof bh, err)) return FALSE; @@ -4860,10 +4886,11 @@ pcapng_write_if_descr_block(wtap_dumper *wdh, wtap_block_t int_data, int *err) wtapng_if_descr_mandatory_t* mand_data = (wtapng_if_descr_mandatory_t*)wtap_block_get_mandatory_data(int_data); int link_type; - ws_debug("pcapng_write_if_descr_block: encap = %d (%s), snaplen = %d", - mand_data->wtap_encap, - wtap_encap_description(mand_data->wtap_encap), - mand_data->snap_len); + ws_debug("%s: encap = %d (%s), snaplen = %d", + G_STRFUNC, + mand_data->wtap_encap, + wtap_encap_description(mand_data->wtap_encap), + mand_data->snap_len); link_type = wtap_wtap_encap_to_pcap_encap(mand_data->wtap_encap); if (link_type == -1) { @@ -4885,7 +4912,7 @@ pcapng_write_if_descr_block(wtap_dumper *wdh, wtap_block_t int_data, int *err) /* write block header */ bh.block_type = BLOCK_TYPE_IDB; bh.block_total_length = (guint32)(sizeof(bh) + sizeof(idb) + block_size.size + 4); - ws_debug("pcapng_write_if_descr_block: Total len %u", bh.block_total_length); + ws_debug("%s: Total len %u", G_STRFUNC, bh.block_total_length); if (!wtap_dump_file_write(wdh, &bh, sizeof bh, err)) return FALSE; @@ -4968,9 +4995,9 @@ static gboolean pcapng_dump(wtap_dumper *wdh, ws_debug("%s: encap = %d (%s) rec type = %u", G_STRFUNC, - rec->rec_header.packet_header.pkt_encap, - wtap_encap_description(rec->rec_header.packet_header.pkt_encap), - rec->rec_type); + rec->rec_header.packet_header.pkt_encap, + wtap_encap_description(rec->rec_header.packet_header.pkt_encap), + rec->rec_type); switch (rec->rec_type) { @@ -5052,14 +5079,16 @@ static gboolean pcapng_dump_finish(wtap_dumper *wdh, int *err, wtap_block_t if_stats; if_stats = g_array_index(int_data_mand->interface_statistics, wtap_block_t, j); - ws_debug("pcapng_dump_finish: write ISB for interface %u", ((wtapng_if_stats_mandatory_t*)wtap_block_get_mandatory_data(if_stats))->interface_id); + ws_debug("%s: write ISB for interface %u", + G_STRFUNC, + ((wtapng_if_stats_mandatory_t*)wtap_block_get_mandatory_data(if_stats))->interface_id); if (!pcapng_write_interface_statistics_block(wdh, if_stats, err)) { return FALSE; } } } - ws_debug("pcapng_dump_finish"); + ws_debug("%s", G_STRFUNC); return TRUE; } @@ -5071,7 +5100,7 @@ pcapng_dump_open(wtap_dumper *wdh, int *err, gchar **err_info _U_) { guint i; - ws_debug("pcapng_dump_open"); + ws_debug("%s", G_STRFUNC); /* This is a pcapng file */ wdh->subtype_add_idb = pcapng_add_idb; wdh->subtype_write = pcapng_dump; @@ -5081,11 +5110,11 @@ pcapng_dump_open(wtap_dumper *wdh, int *err, gchar **err_info _U_) if (!pcapng_write_section_header_block(wdh, err)) { return FALSE; } - ws_debug("pcapng_dump_open: wrote section header block."); + ws_debug("%s: wrote section header block.", G_STRFUNC); /* Write the Interface description blocks */ - ws_debug("pcapng_dump_open: Number of IDBs to write (number of interfaces) %u", - wdh->interface_data->len); + ws_debug("%s: Number of IDBs to write (number of interfaces) %u", + G_STRFUNC, wdh->interface_data->len); for (i = 0; i < wdh->interface_data->len; i++) { @@ -5118,9 +5147,10 @@ pcapng_dump_open(wtap_dumper *wdh, int *err, gchar **err_info _U_) an error indication otherwise. */ static int pcapng_dump_can_write_encap(int wtap_encap) { - ws_debug("pcapng_dump_can_write_encap: encap = %d (%s)", - wtap_encap, - wtap_encap_description(wtap_encap)); + ws_debug("%s: encap = %d (%s)", + G_STRFUNC, + wtap_encap, + wtap_encap_description(wtap_encap)); /* Per-packet encapsulation is supported. */ if (wtap_encap == WTAP_ENCAP_PER_PACKET)