Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Parser - Fix packet parsing issue when --with-pcap is enabled #256

Merged
merged 1 commit into from
Feb 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions input/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -683,25 +683,29 @@ void parse_packet(parser_opt_t *opt, ParserStats& stats, struct timeval ts, cons
uint32_t l3_hdr_offset = 0;
uint32_t l4_hdr_offset = 0;
try {
#ifdef WITH_PCAP
if (opt->datalink == DLT_EN10MB) {
#ifdef WITH_PCAP
if (!opt->datalink || opt->datalink == DLT_EN10MB) {
data_offset = parse_eth_hdr(data, caplen, pkt);
} else if (opt->datalink == DLT_LINUX_SLL) {
data_offset = parse_sll(data, caplen, pkt);
# ifdef DLT_LINUX_SLL2
# ifdef DLT_LINUX_SLL2
} else if (opt->datalink == DLT_LINUX_SLL2) {
data_offset = parse_sll2(data, caplen, pkt);
# endif /* DLT_LINUX_SLL2 */
# endif /* DLT_LINUX_SLL2 */
} else if (opt->datalink == DLT_RAW) {
if ((data[0] & 0xF0) == 0x40) {
pkt->ethertype = ETH_P_IP;
} else if ((data[0] & 0xF0) == 0x60) {
pkt->ethertype = ETH_P_IPV6;
}
} else {
stats.unknown_packets++;
DEBUG_MSG("Unknown datalink type %u\n", opt->datalink);
return;
}
#else
#else
data_offset = parse_eth_hdr(data, caplen, pkt);
#endif /* WITH_PCAP */
#endif /* WITH_PCAP */

if (pkt->ethertype == ETH_P_TRILL) {
data_offset += parse_trill(data + data_offset, caplen - data_offset, pkt);
Expand Down
Loading