From e55956215df399b5a64aa205bba181f5fcb59ee1 Mon Sep 17 00:00:00 2001 From: yangwei Date: Sun, 25 Apr 2021 14:51:07 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9Efix(dumpfile=20offset):=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D-o=E5=8F=82=E6=95=B0=E5=9C=A8-r=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E4=B8=8B=E6=9C=AA=E7=94=9F=E6=95=88=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/tcpdump.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/tcpdump.c b/src/tcpdump.c index af6c9dc..c81c866 100644 --- a/src/tcpdump.c +++ b/src/tcpdump.c @@ -2559,6 +2559,10 @@ main(int argc, char **argv) /***************************** starting capture... ***********************************/ + if(tcpdump_data_offset != 0 && greedy_seek_flag != 0){ + printf("option -o and -g is exclusive, can't use at same time!\n"); + exit(1); + } if(0 == has_device_flag){ MESA_dump(callback, pcap_userdata, cmdbuf, cnt, sapp_cmd_port); } @@ -3046,8 +3050,14 @@ dump_packet(u_char *user, const struct pcap_pkthdr *h, const u_char *sp) ++packets_captured; ++infodelay; - - pcap_dump(user, h, sp); + if(tcpdump_data_offset > 0) + { + pcap_dump(user, h, sp+tcpdump_data_offset); + } + else + { + pcap_dump(user, h, sp); + } #ifdef HAVE_PCAP_DUMP_FLUSH if (Uflag) pcap_dump_flush((pcap_dumper_t *)user); @@ -3123,8 +3133,14 @@ print_packet(u_char *user, const struct pcap_pkthdr *h, const u_char *sp) ++packets_captured; ++infodelay; - - pretty_print_packet((netdissect_options *)user, h, sp, packets_captured); + if(tcpdump_data_offset > 0) + { + pretty_print_packet((netdissect_options *)user, h, sp+tcpdump_data_offset, packets_captured); + } + else + { + pretty_print_packet((netdissect_options *)user, h, sp, packets_captured); + } --infodelay; if (infoprint) @@ -3333,7 +3349,7 @@ print_usage(void) (void)fprintf(stderr, "\t\t[ -k thread-id ] to assign sapp recv thread id, support multi-range, for example: 1,3,5,7.\n"); (void)fprintf(stderr, -"\t\t[ -o offset ] to assign offset from MAC, for skip some low layer data, for example: vxlan=50, mac_in_mac=14.\n"); +"\t\t[ -o offset ] to assign offset from MAC, for skip some low layer data, for example: jump vxlan using -o 50, jump mac_in_mac using -o 14.\n"); (void)fprintf(stderr, "\t\t[ -P port ] to assign sapp recv command port.\n"); (void)fprintf(stderr,