summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--netsniff-ng.c3
-rw-r--r--pcap_io.h6
2 files changed, 5 insertions, 4 deletions
diff --git a/netsniff-ng.c b/netsniff-ng.c
index 19d4db3..960ceaa 100644
--- a/netsniff-ng.c
+++ b/netsniff-ng.c
@@ -1102,7 +1102,6 @@ int main(int argc, char **argv)
bool prio_high = false, setsockmem = true;
void (*main_loop)(struct ctx *ctx) = NULL;
struct ctx ctx = {
- .link_type = LINKTYPE_EN10MB,
.print_mode = PRINT_NORM,
.cpu = -1,
.packet_type = -1,
@@ -1364,6 +1363,8 @@ int main(int argc, char **argv)
if (ctx.device_in && (device_mtu(ctx.device_in) ||
!strncmp("any", ctx.device_in, strlen(ctx.device_in)))) {
+ if (!ctx.rfraw)
+ ctx.link_type = pcap_devtype_to_linktype(ctx.device_in);
if (!ctx.device_out) {
ctx.dump = 0;
main_loop = recv_only_or_dump;
diff --git a/pcap_io.h b/pcap_io.h
index b61e042..310ac6c 100644
--- a/pcap_io.h
+++ b/pcap_io.h
@@ -663,17 +663,17 @@ static inline void pcap_validate_header(const struct pcap_filehdr *hdr)
pcap_check_magic(hdr->magic);
if (hdr->linktype < LINKTYPE_MAX) {
- if (!pcap_supported_linktypes[hdr->linktype])
+ if (pcap_supported_linktypes[hdr->linktype])
good = true;
}
if (linktype_swab < LINKTYPE_MAX) {
- if (!pcap_supported_linktypes[linktype_swab])
+ if (pcap_supported_linktypes[linktype_swab])
good = true;
}
if (!good)
- panic("This file has an unsupported pcap header!\n");
+ panic("This file has an unsupported pcap link type (%d)!\n", hdr->linktype);
if (unlikely(hdr->version_major != PCAP_VERSION_MAJOR) &&
___constant_swab16(hdr->version_major) != PCAP_VERSION_MAJOR)
panic("This file has not a valid pcap header\n");