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

Fix parsing of packets when --with-pcap is enabled #254

Closed
wants to merge 1 commit into from
Closed
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
31 changes: 17 additions & 14 deletions input/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -682,26 +682,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
try
{
#ifdef WITH_PCAP
if (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
data_offset = parse_sll(data, caplen, pkt);
# ifdef DLT_LINUX_SLL2
} else if (opt->datalink == DLT_LINUX_SLL2) {
data_offset = parse_sll2(data, caplen, pkt);
# endif /* DLT_LINUX_SLL2 */
data_offset = parse_sll2(data, caplen, pkt);
# 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;
}
if ((data[0] & 0xF0) == 0x40) {
pkt->ethertype = ETH_P_IP;
} else if ((data[0] & 0xF0) == 0x60) {
pkt->ethertype = ETH_P_IPV6;
}
} else {
#endif /* WITH_PCAP */
data_offset = parse_eth_hdr(data, caplen, pkt);
#ifdef WITH_PCAP
}
#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