| | 715 | |
| | 716 | /* |
| | 717 | * Return -1 if we can't figure it out, else return the DLT_ value |
| | 718 | */ |
| | 719 | int |
| | 720 | sendpacket_get_dlt(sendpacket_t *sp) |
| | 721 | { |
| | 722 | int dlt; |
| | 723 | #if defined HAVE_PF_PACKET |
| | 724 | dlt = -1; |
| | 725 | #elif defined HAVE_BPF |
| | 726 | int fh, rcode; |
| | 727 | |
| | 728 | |
| | 729 | if ((rcode = ioctl(sp->handle.fd, BIOCGDLT, &dlt)) < 0) { |
| | 730 | warnx("Unable to get DLT value for BPF device (%s): %s", sp->device, strerror(errno)); |
| | 731 | return -1; |
| | 732 | } |
| | 733 | #elif defined HAVE_LIBNET |
| | 734 | dlt = -1; |
| | 735 | #else /* HAVE_PCAP_SENDPACKET / HAVE_PCAP_INJECT */ |
| | 736 | dlt = pcap_datalink(sp->handle.pcap); |
| | 737 | #endif |
| | 738 | return dlt; |
| | 739 | } |
| | 740 | |