[BlueZ PATCH v1] core: Disable advmon manager interface for old kernel

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This disables Advertisement monitor manager interface if the underlying
kernel does not support necessary MGMT commands such as add/remove
filters, so clients can know that they are not able to register any
filters before actually register one.
---

 src/adapter.c | 9 +++++++--
 src/adapter.h | 1 +
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index ec6a6a64c50a..cbfbd5feecd9 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -8649,7 +8649,8 @@ static int adapter_register(struct btd_adapter *adapter)
 	adapter->adv_manager = btd_adv_manager_new(adapter, adapter->mgmt);
 
 	if (g_dbus_get_flags() & G_DBUS_FLAG_ENABLE_EXPERIMENTAL) {
-		if (adapter->supported_settings & MGMT_SETTING_LE) {
+		if (adapter->supported_settings & MGMT_SETTING_LE &&
+			btd_has_kernel_features(KERNEL_ADV_MONITOR_CMDS)) {
 			adapter->adv_monitor_manager =
 				btd_adv_monitor_manager_create(adapter,
 								adapter->mgmt);
@@ -8661,7 +8662,7 @@ static int adapter_register(struct btd_adapter *adapter)
 			}
 		} else {
 			btd_info(adapter->dev_id, "Adv Monitor Manager "
-					"skipped, LE unavailable");
+					"skipped, kernel or LE unavailable");
 		}
 	}
 
@@ -9721,6 +9722,10 @@ static void read_commands_complete(uint8_t status, uint16_t length,
 			DBG("kernel supports controller cap command");
 			kernel_features |= KERNEL_HAS_CONTROLLER_CAP_CMD;
 			break;
+		case MGMT_OP_ADD_ADV_PATTERNS_MONITOR:
+			DBG("kernel supports adv monitor commands");
+			kernel_features |= KERNEL_ADV_MONITOR_CMDS;
+			break;
 		default:
 			break;
 		}
diff --git a/src/adapter.h b/src/adapter.h
index 60b5e3bcca34..39bb3990abbe 100644
--- a/src/adapter.h
+++ b/src/adapter.h
@@ -237,6 +237,7 @@ enum kernel_features {
 	KERNEL_HAS_RESUME_EVT		= 1 << 4,
 	KERNEL_HAS_EXT_ADV_ADD_CMDS	= 1 << 5,
 	KERNEL_HAS_CONTROLLER_CAP_CMD	= 1 << 6,
+	KERNEL_ADV_MONITOR_CMDS		= 1 << 7,
 };
 
 bool btd_has_kernel_features(uint32_t feature);
-- 
2.29.2.684.gfbc64c5ab5-goog




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux