X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/88ffe242bd70bc72969bdc7083751f334dc9d5d1..a10ab62bf4f611c63b479df48ab8c9192fa0b281:/print.c diff --git a/print.c b/print.c index 265eee7b..b1c81dd6 100644 --- a/print.c +++ b/print.c @@ -308,6 +308,11 @@ get_if_printer(int type) return printer; } +#ifdef ENABLE_INSTRUMENT_FUNCTIONS +extern int profile_func_level; +static int pretty_print_packet_level = -1; +#endif + void pretty_print_packet(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *sp, u_int packets_captured) @@ -315,6 +320,14 @@ pretty_print_packet(netdissect_options *ndo, const struct pcap_pkthdr *h, u_int hdrlen = 0; int invalid_header = 0; + if (ndo->ndo_print_sampling && packets_captured % ndo->ndo_print_sampling != 0) + return; + +#ifdef ENABLE_INSTRUMENT_FUNCTIONS + if (pretty_print_packet_level == -1) + pretty_print_packet_level = profile_func_level; +#endif + if (ndo->ndo_packet_number) ND_PRINT("%5u ", packets_captured); @@ -403,6 +416,10 @@ pretty_print_packet(netdissect_options *ndo, const struct pcap_pkthdr *h, nd_print_trunc(ndo); /* Print the full packet */ ndo->ndo_ll_hdr_len = 0; +#ifdef ENABLE_INSTRUMENT_FUNCTIONS + /* truncation => reassignment */ + profile_func_level = pretty_print_packet_level; +#endif break; } hdrlen = ndo->ndo_ll_hdr_len;