diff options
author | Guy Harris <guy@alum.mit.edu> | 2015-08-09 16:01:40 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2015-08-09 16:01:40 -0700 |
commit | b0f028907bac3a1b4cbabd0faade2a72e0753ee8 (patch) | |
tree | df1ca401e612221337b0fd62b569b471cd95b15c /pcap-bt-monitor-linux.c | |
parent | 4ad986a1659485b72b4c7bdb7ceba6e8c527c217 (diff) | |
download | libpcap-b0f028907bac3a1b4cbabd0faade2a72e0753ee8.tar.gz |
Make the buffer member of a pcap_t a void *.
Yes, in some sense, it's an array of bytes - on modern processors, *all*
data is ultimately an array of bytes - but different modules will use it
in different ways, not all of which will be an undifferentiated array of
bytes.
This squelches a complaint from the Clang static analyzer.
Clean up some code while we're at it.
Diffstat (limited to 'pcap-bt-monitor-linux.c')
-rw-r--r-- | pcap-bt-monitor-linux.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/pcap-bt-monitor-linux.c b/pcap-bt-monitor-linux.c index b18bdcae..b73d08b8 100644 --- a/pcap-bt-monitor-linux.c +++ b/pcap-bt-monitor-linux.c @@ -82,13 +82,15 @@ bt_monitor_read(pcap_t *handle, int max_packets _U_, pcap_handler callback, u_ch ssize_t ret; struct pcap_pkthdr pkth; pcap_bluetooth_linux_monitor_header *bthdr; + char *pktd; struct hci_mon_hdr hdr; - bthdr = (pcap_bluetooth_linux_monitor_header*) &handle->buffer[handle->offset]; + pktd = (char *)handle->buffer + BT_CONTROL_SIZE; + bthdr = (pcap_bluetooth_linux_monitor_header*)(void *)pktd; iv[0].iov_base = &hdr; iv[0].iov_len = sizeof(hdr); - iv[1].iov_base = &handle->buffer[handle->offset + sizeof(pcap_bluetooth_linux_monitor_header)]; + iv[1].iov_base = pktd + sizeof(pcap_bluetooth_linux_monitor_header); iv[1].iov_len = handle->snapshot; memset(&pkth.ts, 0, sizeof(pkth.ts)); @@ -96,7 +98,7 @@ bt_monitor_read(pcap_t *handle, int max_packets _U_, pcap_handler callback, u_ch msg.msg_iov = iv; msg.msg_iovlen = 2; msg.msg_control = handle->buffer; - msg.msg_controllen = handle->offset; + msg.msg_controllen = BT_CONTROL_SIZE; do { ret = recvmsg(handle->fd, &msg, 0); @@ -128,9 +130,8 @@ bt_monitor_read(pcap_t *handle, int max_packets _U_, pcap_handler callback, u_ch bthdr->opcode = htons(hdr.opcode); if (handle->fcode.bf_insns == NULL || - bpf_filter(handle->fcode.bf_insns, &handle->buffer[handle->offset], - pkth.len, pkth.caplen)) { - callback(user, &pkth, &handle->buffer[handle->offset]); + bpf_filter(handle->fcode.bf_insns, pktd, pkth.len, pkth.caplen)) { + callback(user, &pkth, pktd); return 1; } return 0; /* didn't pass filter */ @@ -172,8 +173,7 @@ bt_monitor_activate(pcap_t* handle) return PCAP_ERROR_RFMON_NOTSUP; } - handle->bufsize = handle->snapshot + BT_CONTROL_SIZE + sizeof(pcap_bluetooth_linux_monitor_header); - handle->offset = BT_CONTROL_SIZE; + handle->bufsize = BT_CONTROL_SIZE + sizeof(pcap_bluetooth_linux_monitor_header) + handle->snapshot; handle->linktype = DLT_BLUETOOTH_LINUX_MONITOR; handle->read_op = bt_monitor_read; |