Set packet type for RAW PCAPs

This commit is contained in:
William Robinet 2023-09-12 12:50:12 +02:00
parent bd730f31c4
commit 24398758e1
No known key found for this signature in database
GPG key ID: 003FA3DF74C7A949

View file

@ -205,6 +205,18 @@ void pcap_cb(u_char *ptr, const struct pcap_pkthdr *hdr, const u_char *data) {
switch(pcap_if_type) { switch(pcap_if_type) {
case DLT_RAW: case DLT_RAW:
switch(((u_int8_t)*data) >> 4) {
case 4:
type = ETHERTYPE_IP;
break;
case 6:
type = ETHERTYPE_IPV6;
break;
default:
fprintf(stderr, "Unknown packet type, skipping ...\n");
return;
}
break;
#ifdef DLT_LOOP #ifdef DLT_LOOP
case DLT_LOOP: case DLT_LOOP:
#endif #endif