dect
/
libpcap
Archived
13
0
Fork 0

Check for "no such device" for the "get the media types" ioctl in *BSD.

This lets us return PCAP_ERROR_NO_SUCH_DEVICE if we've done a
pcap_create() on a non-existent device and asked whether it supports
monitor mode.
This commit is contained in:
Guy Harris 2010-05-18 18:56:38 -07:00
parent 06a81b2e72
commit 8666f21afc
1 changed files with 16 additions and 5 deletions

View File

@ -2268,17 +2268,28 @@ monitor_mode(pcap_t *p, int set)
/*
* Can't get the media types.
*/
if (errno == EINVAL) {
switch (errno) {
case ENXIO:
/*
* There's no such device.
*/
close(sock);
return (PCAP_ERROR_NO_SUCH_DEVICE);
case EINVAL:
/*
* Interface doesn't support SIOC{G,S}IFMEDIA.
*/
close(sock);
return (PCAP_ERROR_RFMON_NOTSUP);
default:
snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"SIOCGIFMEDIA 1: %s", pcap_strerror(errno));
close(sock);
return (PCAP_ERROR);
}
snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "SIOCGIFMEDIA 1: %s",
pcap_strerror(errno));
close(sock);
return (PCAP_ERROR);
}
if (req.ifm_count == 0) {
/*