diff options
author | Guy Harris <gharris@sonic.net> | 2024-04-15 11:53:33 -0700 |
---|---|---|
committer | Guy Harris <gharris@sonic.net> | 2024-04-16 03:07:31 -0700 |
commit | 912eba84c974b3549f8ed076a07021c61f18a45a (patch) | |
tree | 1d1b1cfe9e4afae73de809ce9c1ce7b61fb1b5b3 | |
parent | 5beb826857ab531928e32c7703aeed3b38d9c969 (diff) | |
download | libpcap-912eba84c974b3549f8ed076a07021c61f18a45a.tar.gz |
bt-linux, bt-monitor-linux: use PCAP_ERROR_ codes.
Use them rather than numerical values.
(cherry picked from commit 844f9d7ddff47c58f27b76c1620f38345ba73627)
-rw-r--r-- | pcap-bt-linux.c | 12 | ||||
-rw-r--r-- | pcap-bt-monitor-linux.c | 8 |
2 files changed, 10 insertions, 10 deletions
diff --git a/pcap-bt-linux.c b/pcap-bt-linux.c index 73548bde..e847c020 100644 --- a/pcap-bt-linux.c +++ b/pcap-bt-linux.c @@ -86,7 +86,7 @@ bt_findalldevs(pcap_if_list_t *devlistp, char *err_str) return 0; pcapint_fmt_errmsg_for_errno(err_str, PCAP_ERRBUF_SIZE, errno, "Can't open raw Bluetooth socket"); - return -1; + return PCAP_ERROR; } dev_list = malloc(HCI_MAX_DEV * sizeof(*dev_req) + sizeof(*dev_list)); @@ -94,7 +94,7 @@ bt_findalldevs(pcap_if_list_t *devlistp, char *err_str) { snprintf(err_str, PCAP_ERRBUF_SIZE, "Can't allocate %zu bytes for Bluetooth device list", HCI_MAX_DEV * sizeof(*dev_req) + sizeof(*dev_list)); - ret = -1; + ret = PCAP_ERROR; goto done; } @@ -112,7 +112,7 @@ bt_findalldevs(pcap_if_list_t *devlistp, char *err_str) { pcapint_fmt_errmsg_for_errno(err_str, PCAP_ERRBUF_SIZE, errno, "Can't get Bluetooth device list via ioctl"); - ret = -1; + ret = PCAP_ERROR; goto free; } @@ -133,7 +133,7 @@ bt_findalldevs(pcap_if_list_t *devlistp, char *err_str) */ if (pcapint_add_dev(devlistp, dev_name, PCAP_IF_WIRELESS, dev_descr, err_str) == NULL) { - ret = -1; + ret = PCAP_ERROR; break; } } @@ -343,7 +343,7 @@ bt_read_linux(pcap_t *handle, int max_packets _U_, pcap_handler callback, u_char if (handle->break_loop) { handle->break_loop = 0; - return -2; + return PCAP_ERROR_BREAK; } ret = recvmsg(handle->fd, &msg, 0); } while ((ret == -1) && (errno == EINTR)); @@ -355,7 +355,7 @@ bt_read_linux(pcap_t *handle, int max_packets _U_, pcap_handler callback, u_char } pcapint_fmt_errmsg_for_errno(handle->errbuf, PCAP_ERRBUF_SIZE, errno, "Can't receive packet"); - return -1; + return PCAP_ERROR; } pkth.caplen = (bpf_u_int32)ret; diff --git a/pcap-bt-monitor-linux.c b/pcap-bt-monitor-linux.c index 9abd97bf..e4115878 100644 --- a/pcap-bt-monitor-linux.c +++ b/pcap-bt-monitor-linux.c @@ -84,7 +84,7 @@ bt_monitor_findalldevs(pcap_if_list_t *devlistp, char *err_str) PCAP_IF_WIRELESS|PCAP_IF_CONNECTION_STATUS_NOT_APPLICABLE, "Bluetooth Linux Monitor", err_str) == NULL) { - ret = -1; + ret = PCAP_ERROR; } return ret; @@ -121,7 +121,7 @@ bt_monitor_read(pcap_t *handle, int max_packets _U_, pcap_handler callback, u_ch if (handle->break_loop) { handle->break_loop = 0; - return -2; + return PCAP_ERROR_BREAK; } ret = recvmsg(handle->fd, &msg, 0); } while ((ret == -1) && (errno == EINTR)); @@ -133,7 +133,7 @@ bt_monitor_read(pcap_t *handle, int max_packets _U_, pcap_handler callback, u_ch } pcapint_fmt_errmsg_for_errno(handle->errbuf, PCAP_ERRBUF_SIZE, errno, "Can't receive packet"); - return -1; + return PCAP_ERROR; } pkth.caplen = (bpf_u_int32)(ret - sizeof(hdr) + sizeof(pcap_bluetooth_linux_monitor_header)); @@ -163,7 +163,7 @@ bt_monitor_inject(pcap_t *handle, const void *buf _U_, int size _U_) { snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Packet injection is not supported yet on Bluetooth monitor devices"); - return -1; + return PCAP_ERROR; } static int |