Skip to content

Commit cdbf52a

Browse files
committed
Fix parsing of packets when --with-pcap is enabled
1 parent 70e7cc2 commit cdbf52a

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

input/parser.cpp

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -682,26 +682,29 @@ void parse_packet(parser_opt_t *opt, ParserStats& stats, struct timeval ts, cons
682682

683683
uint32_t l3_hdr_offset = 0;
684684
uint32_t l4_hdr_offset = 0;
685-
try {
686-
#ifdef WITH_PCAP
685+
try
686+
{
687+
#ifdef WITH_PCAP
687688
if (opt->datalink == DLT_EN10MB) {
688689
data_offset = parse_eth_hdr(data, caplen, pkt);
689690
} else if (opt->datalink == DLT_LINUX_SLL) {
690-
data_offset = parse_sll(data, caplen, pkt);
691-
# ifdef DLT_LINUX_SLL2
691+
data_offset = parse_sll(data, caplen, pkt);
692+
# ifdef DLT_LINUX_SLL2
692693
} else if (opt->datalink == DLT_LINUX_SLL2) {
693-
data_offset = parse_sll2(data, caplen, pkt);
694-
# endif /* DLT_LINUX_SLL2 */
694+
data_offset = parse_sll2(data, caplen, pkt);
695+
# endif /* DLT_LINUX_SLL2 */
695696
} else if (opt->datalink == DLT_RAW) {
696-
if ((data[0] & 0xF0) == 0x40) {
697-
pkt->ethertype = ETH_P_IP;
698-
} else if ((data[0] & 0xF0) == 0x60) {
699-
pkt->ethertype = ETH_P_IPV6;
700-
}
697+
if ((data[0] & 0xF0) == 0x40) {
698+
pkt->ethertype = ETH_P_IP;
699+
} else if ((data[0] & 0xF0) == 0x60) {
700+
pkt->ethertype = ETH_P_IPV6;
701+
}
702+
} else {
703+
#endif /* WITH_PCAP */
704+
data_offset = parse_eth_hdr(data, caplen, pkt);
705+
#ifdef WITH_PCAP
701706
}
702-
#else
703-
data_offset = parse_eth_hdr(data, caplen, pkt);
704-
#endif /* WITH_PCAP */
707+
#endif /* WITH_PCAP */
705708

706709
if (pkt->ethertype == ETH_P_TRILL) {
707710
data_offset += parse_trill(data + data_offset, caplen - data_offset, pkt);

0 commit comments

Comments
 (0)