4#include <QtCore/qloggingcategory.h>
5#include <QtCore/qsocketnotifier.h>
6#include <QtCore/qtimer.h>
10#include "../qbluetoothsocketbase_p.h"
14#include <sys/syscall.h>
16#include <linux/capability.h>
67#ifndef _LINUX_CAPABILITY_VERSION_3
68#define _LINUX_CAPABILITY_VERSION_3 0x20080522
71#ifndef _LINUX_CAPABILITY_U32S_3
72#define _LINUX_CAPABILITY_U32S_3 2
76#define CAP_NET_ADMIN 12
80#define CAP_TO_INDEX(x) ((x) >> 5)
84#define CAP_TO_MASK(x) (1 << ((x) & 31))
108 qCWarning(QT_BT_BLUEZ,
"BluetoothManangement: getCap failed with %s",
119 if (!hasPermission) {
120 qCInfo(QT_BT_BLUEZ,
"Missing CAP_NET_ADMIN permission. Cannot determine whether "
121 "a found address is of random or public type.");
129 qCWarning(QT_BT_BLUEZ,
"Cannot open Bluetooth Management socket: %s",
134 memset(&hciAddr, 0,
sizeof(hciAddr));
139 if (
::bind(
fd, (
struct sockaddr *)(&hciAddr),
sizeof(hciAddr)) < 0) {
140 qCWarning(QT_BT_BLUEZ,
"Cannot bind Bluetooth Management socket: %s",
162 return bluetoothKernelManager();
165void BluetoothManagement::_q_readNotifier()
187 const qsizetype remainingPackageSize =
data.size() - nextPackageSize;
189 if (
data.size() < nextPackageSize)
204 qCDebug(QT_BT_BLUEZ) <<
"BluetoothManagement: found random device"
206 processRandomAddressFlagInformation(qtAddress);
212 qCDebug(QT_BT_BLUEZ) <<
"BluetoothManagement: Ignored event:"
217 if (
data.size() > nextPackageSize)
218 data =
data.right(remainingPackageSize);
240void BluetoothManagement::cleanupOldAddressFlags()
246 auto i = privateFlagAddresses.
begin();
247 while (
i != privateFlagAddresses.
end()) {
248 if (
i.value() < cutOffTime)
249 i = privateFlagAddresses.
erase(
i);
266 return (
fd == -1) ?
false :
true;
272#include "moc_bluetoothmanagement_p.cpp"
#define _LINUX_CAPABILITY_U32S_3
#define _LINUX_CAPABILITY_VERSION_3
struct capHdr __attribute__
static int sysCallCapGet(capHdr *header, capData *data)
static bool hasBtMgmtPermission()
#define QPRIVATELINEARBUFFER_BUFFERSIZE
#define HCI_CHANNEL_CONTROL
DarwinBluetooth::LECBManagerNotifier * notifier
bool isAddressRandom(const QBluetoothAddress &address) const
bool isMonitoringEnabled() const
BluetoothManagement(QObject *parent=nullptr)
static QDateTime currentDateTimeUtc()
QDateTime addDays(qint64 days) const
Returns a QDateTime object containing a datetime ndays days later than the datetime of this object (o...
iterator begin()
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the first item in the hash.
iterator erase(const_iterator it)
bool contains(const Key &key) const noexcept
Returns true if the hash contains an item with the key; otherwise returns false.
iterator end() noexcept
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the last ...
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
void activated(QSocketDescriptor socket, QSocketNotifier::Type activationEvent, QPrivateSignal)
void start(int msec)
Starts or restarts the timer with a timeout interval of msec milliseconds.
void setInterval(int msec)
void timeout(QPrivateSignal)
This signal is emitted when the timer times out.
void setTimerType(Qt::TimerType atype)
Combined button and popup list for selecting options.
QTextStream & hex(QTextStream &stream)
Calls QTextStream::setIntegerBase(16) on stream and returns stream.
static void convertAddress(const quint64 from, quint8(&to)[6])
static QString header(const QString &name)
constexpr T qFromLittleEndian(T source)
#define Q_GLOBAL_STATIC(TYPE, NAME,...)
Q_DECL_COLD_FUNCTION Q_CORE_EXPORT QString qt_error_string(int errorCode=-1)
#define qCInfo(category,...)
#define qCWarning(category,...)
#define qCDebug(category,...)
#define Q_DECLARE_LOGGING_CATEGORY(name)
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLuint GLuint64EXT address
GLuint GLenum GLsizei GLsizei GLint GLint GLboolean packed
#define qPrintable(string)
unsigned long long quint64
ReturnedValue read(const char *data)
socketLayer bind(QHostAddress::Any, 4000)
unsigned short hci_channel
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent