]> The Tcpdump Group git mirrors - libpcap/commitdiff
From Paolo Abeni: don't treate an EAFNOSUPPORT error when trying to open
authorguy <guy>
Tue, 5 Dec 2006 20:08:58 +0000 (20:08 +0000)
committerguy <guy>
Tue, 5 Dec 2006 20:08:58 +0000 (20:08 +0000)
a Bluetooth socket as an error - it just means there's no Bluetooth
support in the kernel, and thus there are no Bluetooth devices.

Clean up error messages a bit, including indications that these are from
the Bluetooth code.

pcap-bt-linux.c

index eac136cffe772d2b8fbf87873efb4d74e9fedcf8..8bc99bae03b56a02ecc7fcabc7730da73c0200ff 100644 (file)
@@ -78,7 +78,10 @@ bt_platform_finddevs(pcap_if_t **alldevsp, char *err_str)
        sock  = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI);
        if (sock < 0)
        {
-               snprintf(err_str, PCAP_ERRBUF_SIZE, "can't open raw by socket %d:%s",
+               /* if bluetooth is not supported this this is not fatal*/ 
+               if (errno == EAFNOSUPPORT)
+                       return 0;
+               snprintf(err_str, PCAP_ERRBUF_SIZE, "Can't open raw Bluetooth socket %d:%s",
                        errno, strerror(errno));
                return -1;
        }
@@ -86,7 +89,7 @@ bt_platform_finddevs(pcap_if_t **alldevsp, char *err_str)
        dev_list = malloc(HCI_MAX_DEV * sizeof(*dev_req) + sizeof(*dev_list));
        if (!dev_list) 
        {
-               snprintf(err_str, PCAP_ERRBUF_SIZE, "can't allocate %d bytes for dev cache",
+               snprintf(err_str, PCAP_ERRBUF_SIZE, "Can't allocate %d bytes for Bluetooth device list",
                        HCI_MAX_DEV * sizeof(*dev_req) + sizeof(*dev_list));
                ret = -1;
                goto done;
@@ -96,7 +99,7 @@ bt_platform_finddevs(pcap_if_t **alldevsp, char *err_str)
 
        if (ioctl(sock, HCIGETDEVLIST, (void *) dev_list) < 0) 
        {
-               snprintf(err_str, PCAP_ERRBUF_SIZE, "can't get dev list via ioctl %d:%s",
+               snprintf(err_str, PCAP_ERRBUF_SIZE, "Can't get Bluetooth device list via ioctl %d:%s",
                        errno, strerror(errno));
                ret = -1;
                goto free;