summaryrefslogtreecommitdiff
path: root/src/tcpdump.c
diff options
context:
space:
mode:
authoryangwei <[email protected]>2021-04-25 14:51:07 +0800
committeryangwei <[email protected]>2021-04-25 14:51:07 +0800
commite55956215df399b5a64aa205bba181f5fcb59ee1 (patch)
tree01fa096f23b8f060c43bcc1ac7a5791b057b9584 /src/tcpdump.c
parent4ef2936f429161fc22e69aa190c9da92ce639202 (diff)
🐞fix(dumpfile offset): 修复-o参数在-r模式下未生效的bug
Diffstat (limited to 'src/tcpdump.c')
-rw-r--r--src/tcpdump.c26
1 files 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,