diff options
author | Lei Maohui <leimaohui@cn.fujitsu.com> | 2019-09-30 17:57:21 +0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2019-10-02 10:09:47 +0100 |
commit | 9df127876da83cdd6288f85d97a8d3397c515699 (patch) | |
tree | bc3b792f8a105547f5496b306291846a7e55b611 /meta | |
parent | 67d0a62bdd11b0271981a3d573747ec3a43b7596 (diff) | |
download | poky-9df127876da83cdd6288f85d97a8d3397c515699.tar.gz |
bluez5: update patch to fix do_patch error when PATCHTOOL = "patch".
(From OE-Core rev: 37eabe25d1e6dffee8e96675c42c25c64dd3bc70)
Signed-off-by: Lei Maohui <leimaohui@cn.fujitsu.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r-- | meta/recipes-connectivity/bluez5/bluez5/CVE-2018-10910.patch | 726 |
1 files changed, 263 insertions, 463 deletions
diff --git a/meta/recipes-connectivity/bluez5/bluez5/CVE-2018-10910.patch b/meta/recipes-connectivity/bluez5/bluez5/CVE-2018-10910.patch index b4b1846c45..2a78077443 100644 --- a/meta/recipes-connectivity/bluez5/bluez5/CVE-2018-10910.patch +++ b/meta/recipes-connectivity/bluez5/bluez5/CVE-2018-10910.patch | |||
@@ -1,3 +1,8 @@ | |||
1 | From 977321f2c7f974ea68a3d90df296c66189a3f254 Mon Sep 17 00:00:00 2001 | ||
2 | From: Lei Maohui <leimaohui@cn.fujitsu.com> | ||
3 | Date: Fri, 21 Jun 2019 17:57:35 +0900 | ||
4 | Subject: [PATCH] CVE-2018-10910 | ||
5 | |||
1 | A bug in Bluez may allow for the Bluetooth Discoverable state being set to on | 6 | A bug in Bluez may allow for the Bluetooth Discoverable state being set to on |
2 | when no Bluetooth agent is registered with the system. This situation could | 7 | when no Bluetooth agent is registered with the system. This situation could |
3 | lead to the unauthorized pairing of certain Bluetooth devices without any | 8 | lead to the unauthorized pairing of certain Bluetooth devices without any |
@@ -21,14 +26,24 @@ DiscoverableTimeout property: | |||
21 | [bluetooth]# discoverable-timeout 180 | 26 | [bluetooth]# discoverable-timeout 180 |
22 | Changing discoverable-timeout 180 succeeded | 27 | Changing discoverable-timeout 180 succeeded |
23 | --- | 28 | --- |
24 | client/main.c | 43 +++++++++++++++++++++++++++++++++++++++++++ | 29 | client/main.c | 82 +++++++++++++++++++++++++++++++++- |
25 | 1 file changed, 43 insertions(+) | 30 | doc/adapter-api.txt | 6 +++ |
31 | src/adapter.c | 125 ++++++++++++++++++++++++++++++++++++++++++++++------ | ||
32 | 3 files changed, 198 insertions(+), 15 deletions(-) | ||
26 | 33 | ||
27 | diff --git a/client/main.c b/client/main.c | 34 | diff --git a/client/main.c b/client/main.c |
28 | index 87323d8f7..59820c6d9 100644 | 35 | index 87323d8..1a66a3a 100644 |
29 | --- a/client/main.c | 36 | --- a/client/main.c |
30 | +++ b/client/main.c | 37 | +++ b/client/main.c |
31 | @@ -1061,6 +1061,47 @@ static void cmd_discoverable(int argc, char *argv[]) | 38 | @@ -877,6 +877,7 @@ static void cmd_show(int argc, char *argv[]) |
39 | print_property(proxy, "Class"); | ||
40 | print_property(proxy, "Powered"); | ||
41 | print_property(proxy, "Discoverable"); | ||
42 | + print_property(proxy, "DiscoverableTimeout"); | ||
43 | print_property(proxy, "Pairable"); | ||
44 | print_uuids(proxy); | ||
45 | print_property(proxy, "Modalias"); | ||
46 | @@ -1061,6 +1062,47 @@ static void cmd_discoverable(int argc, char *argv[]) | ||
32 | return bt_shell_noninteractive_quit(EXIT_FAILURE); | 47 | return bt_shell_noninteractive_quit(EXIT_FAILURE); |
33 | } | 48 | } |
34 | 49 | ||
@@ -76,7 +91,87 @@ index 87323d8f7..59820c6d9 100644 | |||
76 | static void cmd_agent(int argc, char *argv[]) | 91 | static void cmd_agent(int argc, char *argv[]) |
77 | { | 92 | { |
78 | dbus_bool_t enable; | 93 | dbus_bool_t enable; |
79 | @@ -2549,6 +2590,8 @@ static const struct bt_shell_menu main_menu = { | 94 | @@ -1124,6 +1166,7 @@ static struct set_discovery_filter_args { |
95 | char **uuids; | ||
96 | size_t uuids_len; | ||
97 | dbus_bool_t duplicate; | ||
98 | + dbus_bool_t discoverable; | ||
99 | bool set; | ||
100 | } filter = { | ||
101 | .rssi = DISTANCE_VAL_INVALID, | ||
102 | @@ -1163,6 +1206,11 @@ static void set_discovery_filter_setup(DBusMessageIter *iter, void *user_data) | ||
103 | DBUS_TYPE_BOOLEAN, | ||
104 | &args->duplicate); | ||
105 | |||
106 | + if (args->discoverable) | ||
107 | + g_dbus_dict_append_entry(&dict, "Discoverable", | ||
108 | + DBUS_TYPE_BOOLEAN, | ||
109 | + &args->discoverable); | ||
110 | + | ||
111 | dbus_message_iter_close_container(iter, &dict); | ||
112 | } | ||
113 | |||
114 | @@ -1320,6 +1368,26 @@ static void cmd_scan_filter_duplicate_data(int argc, char *argv[]) | ||
115 | filter.set = false; | ||
116 | } | ||
117 | |||
118 | +static void cmd_scan_filter_discoverable(int argc, char *argv[]) | ||
119 | +{ | ||
120 | + if (argc < 2 || !strlen(argv[1])) { | ||
121 | + bt_shell_printf("Discoverable: %s\n", | ||
122 | + filter.discoverable ? "on" : "off"); | ||
123 | + return bt_shell_noninteractive_quit(EXIT_SUCCESS); | ||
124 | + } | ||
125 | + | ||
126 | + if (!strcmp(argv[1], "on")) | ||
127 | + filter.discoverable = true; | ||
128 | + else if (!strcmp(argv[1], "off")) | ||
129 | + filter.discoverable = false; | ||
130 | + else { | ||
131 | + bt_shell_printf("Invalid option: %s\n", argv[1]); | ||
132 | + return bt_shell_noninteractive_quit(EXIT_FAILURE); | ||
133 | + } | ||
134 | + | ||
135 | + filter.set = false; | ||
136 | +} | ||
137 | + | ||
138 | static void filter_clear_uuids(void) | ||
139 | { | ||
140 | g_strfreev(filter.uuids); | ||
141 | @@ -1348,6 +1416,11 @@ static void filter_clear_duplicate(void) | ||
142 | filter.duplicate = false; | ||
143 | } | ||
144 | |||
145 | +static void filter_clear_discoverable(void) | ||
146 | +{ | ||
147 | + filter.discoverable = false; | ||
148 | +} | ||
149 | + | ||
150 | struct clear_entry { | ||
151 | const char *name; | ||
152 | void (*clear) (void); | ||
153 | @@ -1359,6 +1432,7 @@ static const struct clear_entry filter_clear[] = { | ||
154 | { "pathloss", filter_clear_pathloss }, | ||
155 | { "transport", filter_clear_transport }, | ||
156 | { "duplicate-data", filter_clear_duplicate }, | ||
157 | + { "discoverable", filter_clear_discoverable }, | ||
158 | {} | ||
159 | }; | ||
160 | |||
161 | @@ -2468,7 +2542,11 @@ static const struct bt_shell_menu scan_menu = { | ||
162 | { "duplicate-data", "[on/off]", cmd_scan_filter_duplicate_data, | ||
163 | "Set/Get duplicate data filter", | ||
164 | NULL }, | ||
165 | - { "clear", "[uuids/rssi/pathloss/transport/duplicate-data]", | ||
166 | + { "discoverable", "[on/off]", cmd_scan_filter_discoverable, | ||
167 | + "Set/Get discoverable filter", | ||
168 | + NULL }, | ||
169 | + { "clear", | ||
170 | + "[uuids/rssi/pathloss/transport/duplicate-data/discoverable]", | ||
171 | cmd_scan_filter_clear, | ||
172 | "Clears discovery filter.", | ||
173 | filter_clear_generator }, | ||
174 | @@ -2549,6 +2627,8 @@ static const struct bt_shell_menu main_menu = { | ||
80 | { "discoverable", "<on/off>", cmd_discoverable, | 175 | { "discoverable", "<on/off>", cmd_discoverable, |
81 | "Set controller discoverable mode", | 176 | "Set controller discoverable mode", |
82 | NULL }, | 177 | NULL }, |
@@ -85,74 +180,36 @@ index 87323d8f7..59820c6d9 100644 | |||
85 | { "agent", "<on/off/capability>", cmd_agent, | 180 | { "agent", "<on/off/capability>", cmd_agent, |
86 | "Enable/disable agent with given capability", | 181 | "Enable/disable agent with given capability", |
87 | capability_generator}, | 182 | capability_generator}, |
88 | -- | 183 | diff --git a/doc/adapter-api.txt b/doc/adapter-api.txt |
89 | 2.17.1 | 184 | index d14d0ca..4791af2 100644 |
90 | 185 | --- a/doc/adapter-api.txt | |
91 | Subject: [PATCH BlueZ 2/4] client: Make show command print DiscoverableTimeout | 186 | +++ b/doc/adapter-api.txt |
92 | From: Luiz Augusto von Dentz <luiz.dentz () gmail ! com> | 187 | @@ -113,6 +113,12 @@ Methods void StartDiscovery() |
93 | Date: 2018-07-25 10:20:33 | 188 | generated for either ManufacturerData and |
94 | Message-ID: 20180725102035.19439-2-luiz.dentz () gmail ! com | 189 | ServiceData everytime they are discovered. |
95 | [Download RAW message or body] | 190 | |
96 | 191 | + bool Discoverable (Default: false) | |
97 | From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 192 | + |
98 | 193 | + Make adapter discoverable while discovering, | |
99 | Controller XX:XX:XX:XX:XX:XX (public) | 194 | + if the adapter is already discoverable this |
100 | Name: Vudentz's T460s | 195 | + setting this filter won't do anything. |
101 | Alias: Intel-1 | 196 | + |
102 | Class: 0x004c010c | 197 | When discovery filter is set, Device objects will be |
103 | Powered: yes | 198 | created as new devices with matching criteria are |
104 | Discoverable: no | 199 | discovered regardless of they are connectable or |
105 | DiscoverableTimeout: 0x00000000 | ||
106 | Pairable: yes | ||
107 | UUID: Headset AG (00001112-0000-1000-8000-00805f9b34fb) | ||
108 | UUID: Generic Attribute Profile (00001801-0000-1000-8000-00805f9b34fb) | ||
109 | UUID: A/V Remote Control (0000110e-0000-1000-8000-00805f9b34fb) | ||
110 | UUID: SIM Access (0000112d-0000-1000-8000-00805f9b34fb) | ||
111 | UUID: Generic Access Profile (00001800-0000-1000-8000-00805f9b34fb) | ||
112 | UUID: PnP Information (00001200-0000-1000-8000-00805f9b34fb) | ||
113 | UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb) | ||
114 | UUID: Audio Source (0000110a-0000-1000-8000-00805f9b34fb) | ||
115 | UUID: Audio Sink (0000110b-0000-1000-8000-00805f9b34fb) | ||
116 | UUID: Headset (00001108-0000-1000-8000-00805f9b34fb) | ||
117 | Modalias: usb:v1D6Bp0246d0532 | ||
118 | Discovering: no | ||
119 | --- | ||
120 | client/main.c | 1 + | ||
121 | 1 file changed, 1 insertion(+) | ||
122 | |||
123 | diff --git a/client/main.c b/client/main.c | ||
124 | index 59820c6d9..6f472d050 100644 | ||
125 | --- a/client/main.c | ||
126 | +++ b/client/main.c | ||
127 | @@ -877,6 +877,7 @@ static void cmd_show(int argc, char *argv[]) | ||
128 | print_property(proxy, "Class"); | ||
129 | print_property(proxy, "Powered"); | ||
130 | print_property(proxy, "Discoverable"); | ||
131 | + print_property(proxy, "DiscoverableTimeout"); | ||
132 | print_property(proxy, "Pairable"); | ||
133 | print_uuids(proxy); | ||
134 | print_property(proxy, "Modalias"); | ||
135 | -- | ||
136 | 2.17.1 | ||
137 | Subject: [PATCH BlueZ 3/4] adapter: Track pending settings | ||
138 | From: Luiz Augusto von Dentz <luiz.dentz () gmail ! com> | ||
139 | Date: 2018-07-25 10:20:34 | ||
140 | Message-ID: 20180725102035.19439-3-luiz.dentz () gmail ! com | ||
141 | [Download RAW message or body] | ||
142 | |||
143 | From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | ||
144 | |||
145 | This tracks settings being changed and in case the settings is already | ||
146 | pending considered it to be done. | ||
147 | --- | ||
148 | src/adapter.c | 30 ++++++++++++++++++++++++++++-- | ||
149 | 1 file changed, 28 insertions(+), 2 deletions(-) | ||
150 | |||
151 | diff --git a/src/adapter.c b/src/adapter.c | 200 | diff --git a/src/adapter.c b/src/adapter.c |
152 | index af340fd6e..20c20f9e9 100644 | 201 | index af340fd..822bd34 100644 |
153 | --- a/src/adapter.c | 202 | --- a/src/adapter.c |
154 | +++ b/src/adapter.c | 203 | +++ b/src/adapter.c |
155 | @@ -196,6 +196,7 @@ struct btd_adapter { | 204 | @@ -157,6 +157,7 @@ struct discovery_filter { |
205 | int16_t rssi; | ||
206 | GSList *uuids; | ||
207 | bool duplicate; | ||
208 | + bool discoverable; | ||
209 | }; | ||
210 | |||
211 | struct watch_client { | ||
212 | @@ -196,6 +197,7 @@ struct btd_adapter { | ||
156 | char *name; /* controller device name */ | 213 | char *name; /* controller device name */ |
157 | char *short_name; /* controller short name */ | 214 | char *short_name; /* controller short name */ |
158 | uint32_t supported_settings; /* controller supported settings */ | 215 | uint32_t supported_settings; /* controller supported settings */ |
@@ -160,7 +217,15 @@ index af340fd6e..20c20f9e9 100644 | |||
160 | uint32_t current_settings; /* current controller settings */ | 217 | uint32_t current_settings; /* current controller settings */ |
161 | 218 | ||
162 | char *path; /* adapter object path */ | 219 | char *path; /* adapter object path */ |
163 | @@ -509,8 +510,10 @@ static void settings_changed(struct btd_adapter *adapter, uint32_t settings) | 220 | @@ -213,6 +215,7 @@ struct btd_adapter { |
221 | |||
222 | bool discovering; /* discovering property state */ | ||
223 | bool filtered_discovery; /* we are doing filtered discovery */ | ||
224 | + bool filtered_discoverable; /* we are doing filtered discovery */ | ||
225 | bool no_scan_restart_delay; /* when this flag is set, restart scan | ||
226 | * without delay */ | ||
227 | uint8_t discovery_type; /* current active discovery type */ | ||
228 | @@ -509,8 +512,10 @@ static void settings_changed(struct btd_adapter *adapter, uint32_t settings) | ||
164 | changed_mask = adapter->current_settings ^ settings; | 229 | changed_mask = adapter->current_settings ^ settings; |
165 | 230 | ||
166 | adapter->current_settings = settings; | 231 | adapter->current_settings = settings; |
@@ -171,7 +236,7 @@ index af340fd6e..20c20f9e9 100644 | |||
171 | 236 | ||
172 | if (changed_mask & MGMT_SETTING_POWERED) { | 237 | if (changed_mask & MGMT_SETTING_POWERED) { |
173 | g_dbus_emit_property_changed(dbus_conn, adapter->path, | 238 | g_dbus_emit_property_changed(dbus_conn, adapter->path, |
174 | @@ -596,10 +599,31 @@ static bool set_mode(struct btd_adapter *adapter, uint16_t opcode, | 239 | @@ -596,10 +601,31 @@ static bool set_mode(struct btd_adapter *adapter, uint16_t opcode, |
175 | uint8_t mode) | 240 | uint8_t mode) |
176 | { | 241 | { |
177 | struct mgmt_mode cp; | 242 | struct mgmt_mode cp; |
@@ -203,160 +268,11 @@ index af340fd6e..20c20f9e9 100644 | |||
203 | DBG("sending set mode command for index %u", adapter->dev_id); | 268 | DBG("sending set mode command for index %u", adapter->dev_id); |
204 | 269 | ||
205 | if (mgmt_send(adapter->mgmt, opcode, | 270 | if (mgmt_send(adapter->mgmt, opcode, |
206 | @@ -2739,13 +2763,15 @@ static void property_set_mode(struct btd_adapter *adapter, uint32_t setting, | 271 | @@ -1818,7 +1844,17 @@ static void discovery_free(void *user_data) |
207 | else | ||
208 | current_enable = FALSE; | ||
209 | |||
210 | - if (enable == current_enable) { | ||
211 | + if (enable == current_enable || adapter->pending_settings & setting) { | ||
212 | g_dbus_pending_property_success(id); | ||
213 | return; | ||
214 | } | ||
215 | |||
216 | mode = (enable == TRUE) ? 0x01 : 0x00; | ||
217 | |||
218 | + adapter->pending_settings |= setting; | ||
219 | + | ||
220 | switch (setting) { | ||
221 | case MGMT_SETTING_POWERED: | ||
222 | opcode = MGMT_OP_SET_POWERED; | ||
223 | @@ -2798,7 +2824,7 @@ static void property_set_mode(struct btd_adapter *adapter, uint32_t setting, | ||
224 | data->id = id; | ||
225 | |||
226 | if (mgmt_send(adapter->mgmt, opcode, adapter->dev_id, len, param, | ||
227 | - property_set_mode_complete, data, g_free) > 0) | ||
228 | + property_set_mode_complete, data, g_free) > 0) | ||
229 | return; | ||
230 | |||
231 | g_free(data); | ||
232 | -- | ||
233 | 2.17.1 | ||
234 | Subject: [PATCH BlueZ 4/4] adapter: Check pending when setting DiscoverableTimeout | ||
235 | From: Luiz Augusto von Dentz <luiz.dentz () gmail ! com> | ||
236 | Date: 2018-07-25 10:20:35 | ||
237 | Message-ID: 20180725102035.19439-4-luiz.dentz () gmail ! com | ||
238 | [Download RAW message or body] | ||
239 | |||
240 | From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | ||
241 | |||
242 | This makes DiscoverableTimeout check if discoverable is already pending | ||
243 | and don't attempt to set it once again which may cause discoverable to | ||
244 | be re-enabled when in fact the application just want to set the timeout | ||
245 | alone. | ||
246 | --- | ||
247 | src/adapter.c | 14 +++++++++++++- | ||
248 | 1 file changed, 13 insertions(+), 1 deletion(-) | ||
249 | |||
250 | diff --git a/src/adapter.c b/src/adapter.c | ||
251 | index 20c20f9e9..f92c897c7 100644 | ||
252 | --- a/src/adapter.c | ||
253 | +++ b/src/adapter.c | ||
254 | @@ -2901,6 +2901,7 @@ static void property_set_discoverable_timeout( | ||
255 | GDBusPendingPropertySet id, void *user_data) | ||
256 | { | ||
257 | struct btd_adapter *adapter = user_data; | ||
258 | + bool enabled; | ||
259 | dbus_uint32_t value; | ||
260 | |||
261 | dbus_message_iter_get_basic(iter, &value); | ||
262 | @@ -2914,8 +2915,19 @@ static void property_set_discoverable_timeout( | ||
263 | g_dbus_emit_property_changed(dbus_conn, adapter->path, | ||
264 | ADAPTER_INTERFACE, "DiscoverableTimeout"); | ||
265 | |||
266 | + if (adapter->pending_settings & MGMT_SETTING_DISCOVERABLE) { | ||
267 | + if (adapter->current_settings & MGMT_SETTING_DISCOVERABLE) | ||
268 | + enabled = false; | ||
269 | + else | ||
270 | + enabled = true; | ||
271 | + } else { | ||
272 | + if (adapter->current_settings & MGMT_SETTING_DISCOVERABLE) | ||
273 | + enabled = true; | ||
274 | + else | ||
275 | + enabled = false; | ||
276 | + } | ||
277 | |||
278 | - if (adapter->current_settings & MGMT_SETTING_DISCOVERABLE) | ||
279 | + if (enabled) | ||
280 | set_discoverable(adapter, 0x01, adapter->discoverable_timeout); | ||
281 | } | ||
282 | |||
283 | -- | ||
284 | 2.17.1 | ||
285 | Subject: [PATCH BlueZ 1/5] doc/adapter-api: Add Discoverable option to SetDiscoveryFilter | ||
286 | From: Luiz Augusto von Dentz <luiz.dentz () gmail ! com> | ||
287 | Date: 2018-07-26 14:17:19 | ||
288 | Message-ID: 20180726141723.20199-1-luiz.dentz () gmail ! com | ||
289 | [Download RAW message or body] | ||
290 | |||
291 | From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | ||
292 | |||
293 | This enables the client to set its discoverable setting while | ||
294 | discovering which is very typical situation as usually the setings | ||
295 | application would allow incoming pairing request while scanning, so | ||
296 | this would reduce the number of calls setting Discoverable and | ||
297 | DiscoverableTimeout and restoring after done with discovery. | ||
298 | --- | ||
299 | doc/adapter-api.txt | 6 ++++++ | ||
300 | 1 file changed, 6 insertions(+) | ||
301 | |||
302 | diff --git a/doc/adapter-api.txt b/doc/adapter-api.txt | ||
303 | index d14d0ca50..4791af2c7 100644 | ||
304 | --- a/doc/adapter-api.txt | ||
305 | +++ b/doc/adapter-api.txt | ||
306 | @@ -113,6 +113,12 @@ Methods void StartDiscovery() | ||
307 | generated for either ManufacturerData and | ||
308 | ServiceData everytime they are discovered. | ||
309 | |||
310 | + bool Discoverable (Default: false) | ||
311 | + | ||
312 | + Make adapter discoverable while discovering, | ||
313 | + if the adapter is already discoverable this | ||
314 | + setting this filter won't do anything. | ||
315 | + | ||
316 | When discovery filter is set, Device objects will be | ||
317 | created as new devices with matching criteria are | ||
318 | discovered regardless of they are connectable or | ||
319 | -- | ||
320 | 2.17.1 | ||
321 | Subject: [PATCH BlueZ 2/5] adapter: Discovery filter discoverable | ||
322 | From: Luiz Augusto von Dentz <luiz.dentz () gmail ! com> | ||
323 | Date: 2018-07-26 14:17:20 | ||
324 | Message-ID: 20180726141723.20199-2-luiz.dentz () gmail ! com | ||
325 | [Download RAW message or body] | ||
326 | |||
327 | From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | ||
328 | |||
329 | This implements the discovery filter discoverable and tracks which | ||
330 | clients had enabled it and restores the settings when the last client | ||
331 | enabling it exits. | ||
332 | --- | ||
333 | src/adapter.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++-- | ||
334 | 1 file changed, 54 insertions(+), 2 deletions(-) | ||
335 | |||
336 | diff --git a/src/adapter.c b/src/adapter.c | ||
337 | index f92c897c7..bd9edddc6 100644 | ||
338 | --- a/src/adapter.c | ||
339 | +++ b/src/adapter.c | ||
340 | @@ -157,6 +157,7 @@ struct discovery_filter { | ||
341 | int16_t rssi; | ||
342 | GSList *uuids; | ||
343 | bool duplicate; | ||
344 | + bool discoverable; | ||
345 | }; | ||
346 | |||
347 | struct watch_client { | ||
348 | @@ -214,6 +215,7 @@ struct btd_adapter { | ||
349 | |||
350 | bool discovering; /* discovering property state */ | ||
351 | bool filtered_discovery; /* we are doing filtered discovery */ | ||
352 | + bool filtered_discoverable; /* we are doing filtered discovery */ | ||
353 | bool no_scan_restart_delay; /* when this flag is set, restart scan | ||
354 | * without delay */ | ||
355 | uint8_t discovery_type; /* current active discovery type */ | ||
356 | @@ -1842,6 +1844,16 @@ static void discovery_free(void *user_data) | ||
357 | g_free(client); | 272 | g_free(client); |
358 | } | 273 | } |
359 | 274 | ||
275 | -static void discovery_remove(struct watch_client *client) | ||
360 | +static bool set_filtered_discoverable(struct btd_adapter *adapter, bool enable) | 276 | +static bool set_filtered_discoverable(struct btd_adapter *adapter, bool enable) |
361 | +{ | 277 | +{ |
362 | + if (adapter->filtered_discoverable == enable) | 278 | + if (adapter->filtered_discoverable == enable) |
@@ -367,13 +283,15 @@ index f92c897c7..bd9edddc6 100644 | |||
367 | + return set_discoverable(adapter, enable, 0); | 283 | + return set_discoverable(adapter, enable, 0); |
368 | +} | 284 | +} |
369 | + | 285 | + |
370 | static void discovery_remove(struct watch_client *client) | 286 | +static void discovery_remove(struct watch_client *client, bool exit) |
371 | { | 287 | { |
372 | struct btd_adapter *adapter = client->adapter; | 288 | struct btd_adapter *adapter = client->adapter; |
373 | @@ -1854,6 +1866,22 @@ static void discovery_remove(struct watch_client *client) | 289 | |
290 | @@ -1830,7 +1866,27 @@ static void discovery_remove(struct watch_client *client) | ||
374 | adapter->discovery_list = g_slist_remove(adapter->discovery_list, | 291 | adapter->discovery_list = g_slist_remove(adapter->discovery_list, |
375 | client); | 292 | client); |
376 | 293 | ||
294 | - discovery_free(client); | ||
377 | + if (adapter->filtered_discoverable && | 295 | + if (adapter->filtered_discoverable && |
378 | + client->discovery_filter->discoverable) { | 296 | + client->discovery_filter->discoverable) { |
379 | + GSList *l; | 297 | + GSList *l; |
@@ -390,10 +308,72 @@ index f92c897c7..bd9edddc6 100644 | |||
390 | + set_filtered_discoverable(adapter, false); | 308 | + set_filtered_discoverable(adapter, false); |
391 | + } | 309 | + } |
392 | + | 310 | + |
393 | discovery_free(client); | 311 | + if (!exit && client->discovery_filter) |
312 | + adapter->set_filter_list = g_slist_prepend( | ||
313 | + adapter->set_filter_list, client); | ||
314 | + else | ||
315 | + discovery_free(client); | ||
394 | 316 | ||
395 | /* | 317 | /* |
396 | @@ -2224,6 +2252,15 @@ static DBusMessage *start_discovery(DBusConnection *conn, | 318 | * If there are other client discoveries in progress, then leave |
319 | @@ -1859,8 +1915,11 @@ static void stop_discovery_complete(uint8_t status, uint16_t length, | ||
320 | goto done; | ||
321 | } | ||
322 | |||
323 | - if (client->msg) | ||
324 | + if (client->msg) { | ||
325 | g_dbus_send_reply(dbus_conn, client->msg, DBUS_TYPE_INVALID); | ||
326 | + dbus_message_unref(client->msg); | ||
327 | + client->msg = NULL; | ||
328 | + } | ||
329 | |||
330 | adapter->discovery_type = 0x00; | ||
331 | adapter->discovery_enable = 0x00; | ||
332 | @@ -1873,7 +1932,7 @@ static void stop_discovery_complete(uint8_t status, uint16_t length, | ||
333 | trigger_passive_scanning(adapter); | ||
334 | |||
335 | done: | ||
336 | - discovery_remove(client); | ||
337 | + discovery_remove(client, false); | ||
338 | } | ||
339 | |||
340 | static int compare_sender(gconstpointer a, gconstpointer b) | ||
341 | @@ -2094,14 +2153,14 @@ static int update_discovery_filter(struct btd_adapter *adapter) | ||
342 | return -EINPROGRESS; | ||
343 | } | ||
344 | |||
345 | -static int discovery_stop(struct watch_client *client) | ||
346 | +static int discovery_stop(struct watch_client *client, bool exit) | ||
347 | { | ||
348 | struct btd_adapter *adapter = client->adapter; | ||
349 | struct mgmt_cp_stop_discovery cp; | ||
350 | |||
351 | /* Check if there are more client discovering */ | ||
352 | if (g_slist_next(adapter->discovery_list)) { | ||
353 | - discovery_remove(client); | ||
354 | + discovery_remove(client, exit); | ||
355 | update_discovery_filter(adapter); | ||
356 | return 0; | ||
357 | } | ||
358 | @@ -2111,7 +2170,7 @@ static int discovery_stop(struct watch_client *client) | ||
359 | * and so it is enough to send out the signal and just return. | ||
360 | */ | ||
361 | if (adapter->discovery_enable == 0x00) { | ||
362 | - discovery_remove(client); | ||
363 | + discovery_remove(client, exit); | ||
364 | adapter->discovering = false; | ||
365 | g_dbus_emit_property_changed(dbus_conn, adapter->path, | ||
366 | ADAPTER_INTERFACE, "Discovering"); | ||
367 | @@ -2136,7 +2195,7 @@ static void discovery_disconnect(DBusConnection *conn, void *user_data) | ||
368 | |||
369 | DBG("owner %s", client->owner); | ||
370 | |||
371 | - discovery_stop(client); | ||
372 | + discovery_stop(client, true); | ||
373 | } | ||
374 | |||
375 | /* | ||
376 | @@ -2200,6 +2259,15 @@ static DBusMessage *start_discovery(DBusConnection *conn, | ||
397 | adapter->set_filter_list, client); | 377 | adapter->set_filter_list, client); |
398 | adapter->discovery_list = g_slist_prepend( | 378 | adapter->discovery_list = g_slist_prepend( |
399 | adapter->discovery_list, client); | 379 | adapter->discovery_list, client); |
@@ -409,7 +389,7 @@ index f92c897c7..bd9edddc6 100644 | |||
409 | goto done; | 389 | goto done; |
410 | } | 390 | } |
411 | 391 | ||
412 | @@ -2348,6 +2385,17 @@ static bool parse_duplicate_data(DBusMessageIter *value, | 392 | @@ -2324,6 +2392,17 @@ static bool parse_duplicate_data(DBusMessageIter *value, |
413 | return true; | 393 | return true; |
414 | } | 394 | } |
415 | 395 | ||
@@ -427,7 +407,7 @@ index f92c897c7..bd9edddc6 100644 | |||
427 | struct filter_parser { | 407 | struct filter_parser { |
428 | const char *name; | 408 | const char *name; |
429 | bool (*func)(DBusMessageIter *iter, struct discovery_filter *filter); | 409 | bool (*func)(DBusMessageIter *iter, struct discovery_filter *filter); |
430 | @@ -2357,6 +2405,7 @@ struct filter_parser { | 410 | @@ -2333,6 +2412,7 @@ struct filter_parser { |
431 | { "Pathloss", parse_pathloss }, | 411 | { "Pathloss", parse_pathloss }, |
432 | { "Transport", parse_transport }, | 412 | { "Transport", parse_transport }, |
433 | { "DuplicateData", parse_duplicate_data }, | 413 | { "DuplicateData", parse_duplicate_data }, |
@@ -435,7 +415,7 @@ index f92c897c7..bd9edddc6 100644 | |||
435 | { } | 415 | { } |
436 | }; | 416 | }; |
437 | 417 | ||
438 | @@ -2396,6 +2445,7 @@ static bool parse_discovery_filter_dict(struct btd_adapter *adapter, | 418 | @@ -2372,6 +2452,7 @@ static bool parse_discovery_filter_dict(struct btd_adapter *adapter, |
439 | (*filter)->rssi = DISTANCE_VAL_INVALID; | 419 | (*filter)->rssi = DISTANCE_VAL_INVALID; |
440 | (*filter)->type = get_scan_type(adapter); | 420 | (*filter)->type = get_scan_type(adapter); |
441 | (*filter)->duplicate = false; | 421 | (*filter)->duplicate = false; |
@@ -443,7 +423,7 @@ index f92c897c7..bd9edddc6 100644 | |||
443 | 423 | ||
444 | dbus_message_iter_init(msg, &iter); | 424 | dbus_message_iter_init(msg, &iter); |
445 | if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY || | 425 | if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY || |
446 | @@ -2441,8 +2491,10 @@ static bool parse_discovery_filter_dict(struct btd_adapter *adapter, | 426 | @@ -2417,8 +2498,10 @@ static bool parse_discovery_filter_dict(struct btd_adapter *adapter, |
447 | goto invalid_args; | 427 | goto invalid_args; |
448 | 428 | ||
449 | DBG("filtered discovery params: transport: %d rssi: %d pathloss: %d " | 429 | DBG("filtered discovery params: transport: %d rssi: %d pathloss: %d " |
@@ -456,250 +436,70 @@ index f92c897c7..bd9edddc6 100644 | |||
456 | 436 | ||
457 | return true; | 437 | return true; |
458 | 438 | ||
459 | -- | 439 | @@ -2510,7 +2593,7 @@ static DBusMessage *stop_discovery(DBusConnection *conn, |
460 | 2.17.1 | 440 | if (client->msg) |
461 | Subject: [PATCH BlueZ 3/5] client: Add scan.discoverable command | 441 | return btd_error_busy(msg); |
462 | From: Luiz Augusto von Dentz <luiz.dentz () gmail ! com> | ||
463 | Date: 2018-07-26 14:17:21 | ||
464 | Message-ID: 20180726141723.20199-3-luiz.dentz () gmail ! com | ||
465 | [Download RAW message or body] | ||
466 | |||
467 | From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | ||
468 | |||
469 | This adds discoverable command to scan menu which can be used to set | ||
470 | if adapter should become discoverable while scanning: | ||
471 | |||
472 | [bluetooth]# scan.discoverable on | ||
473 | [bluetooth]# scan on | ||
474 | SetDiscoveryFilter success | ||
475 | [CHG] Controller XX:XX:XX:XX:XX:XX Discoverable: yes | ||
476 | Discovery started | ||
477 | [CHG] Controller XX:XX:XX:XX:XX:XX Discovering: yes | ||
478 | [bluetooth]# scan off | ||
479 | Discovery stopped | ||
480 | [CHG] Controller XX:XX:XX:XX:XX:XX Discoverable: no | ||
481 | --- | ||
482 | client/main.c | 29 +++++++++++++++++++++++++++++ | ||
483 | 1 file changed, 29 insertions(+) | ||
484 | |||
485 | diff --git a/client/main.c b/client/main.c | ||
486 | index 6f472d050..6e6f6d2fb 100644 | ||
487 | --- a/client/main.c | ||
488 | +++ b/client/main.c | ||
489 | @@ -1166,6 +1166,7 @@ static struct set_discovery_filter_args { | ||
490 | char **uuids; | ||
491 | size_t uuids_len; | ||
492 | dbus_bool_t duplicate; | ||
493 | + dbus_bool_t discoverable; | ||
494 | bool set; | ||
495 | } filter = { | ||
496 | .rssi = DISTANCE_VAL_INVALID, | ||
497 | @@ -1205,6 +1206,11 @@ static void set_discovery_filter_setup(DBusMessageIter *iter, void *user_data) | ||
498 | DBUS_TYPE_BOOLEAN, | ||
499 | &args->duplicate); | ||
500 | 442 | ||
501 | + if (args->discoverable) | 443 | - err = discovery_stop(client); |
502 | + g_dbus_dict_append_entry(&dict, "Discoverable", | 444 | + err = discovery_stop(client, false); |
503 | + DBUS_TYPE_BOOLEAN, | 445 | switch (err) { |
504 | + &args->discoverable); | 446 | case 0: |
505 | + | 447 | return dbus_message_new_method_return(msg); |
506 | dbus_message_iter_close_container(iter, &dict); | 448 | @@ -2739,13 +2822,15 @@ static void property_set_mode(struct btd_adapter *adapter, uint32_t setting, |
507 | } | 449 | else |
450 | current_enable = FALSE; | ||
508 | 451 | ||
509 | @@ -1362,6 +1368,26 @@ static void cmd_scan_filter_duplicate_data(int argc, char *argv[]) | 452 | - if (enable == current_enable) { |
510 | filter.set = false; | 453 | + if (enable == current_enable || adapter->pending_settings & setting) { |
511 | } | 454 | g_dbus_pending_property_success(id); |
455 | return; | ||
456 | } | ||
512 | 457 | ||
513 | +static void cmd_scan_filter_discoverable(int argc, char *argv[]) | 458 | mode = (enable == TRUE) ? 0x01 : 0x00; |
514 | +{ | ||
515 | + if (argc < 2 || !strlen(argv[1])) { | ||
516 | + bt_shell_printf("Discoverable: %s\n", | ||
517 | + filter.discoverable ? "on" : "off"); | ||
518 | + return bt_shell_noninteractive_quit(EXIT_SUCCESS); | ||
519 | + } | ||
520 | + | ||
521 | + if (!strcmp(argv[1], "on")) | ||
522 | + filter.discoverable = true; | ||
523 | + else if (!strcmp(argv[1], "off")) | ||
524 | + filter.discoverable = false; | ||
525 | + else { | ||
526 | + bt_shell_printf("Invalid option: %s\n", argv[1]); | ||
527 | + return bt_shell_noninteractive_quit(EXIT_FAILURE); | ||
528 | + } | ||
529 | + | ||
530 | + filter.set = false; | ||
531 | +} | ||
532 | + | ||
533 | static void filter_clear_uuids(void) | ||
534 | { | ||
535 | g_strfreev(filter.uuids); | ||
536 | @@ -2510,6 +2536,9 @@ static const struct bt_shell_menu scan_menu = { | ||
537 | { "duplicate-data", "[on/off]", cmd_scan_filter_duplicate_data, | ||
538 | "Set/Get duplicate data filter", | ||
539 | NULL }, | ||
540 | + { "discoverable", "[on/off]", cmd_scan_filter_discoverable, | ||
541 | + "Set/Get discoverable filter", | ||
542 | + NULL }, | ||
543 | { "clear", "[uuids/rssi/pathloss/transport/duplicate-data]", | ||
544 | cmd_scan_filter_clear, | ||
545 | "Clears discovery filter.", | ||
546 | -- | ||
547 | 2.17.1 | ||
548 | Subject: [PATCH BlueZ 4/5] client: Add scan.clear discoverable | ||
549 | From: Luiz Augusto von Dentz <luiz.dentz () gmail ! com> | ||
550 | Date: 2018-07-26 14:17:22 | ||
551 | Message-ID: 20180726141723.20199-4-luiz.dentz () gmail ! com | ||
552 | [Download RAW message or body] | ||
553 | |||
554 | From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | ||
555 | |||
556 | This implements scan.clear for discoverable filter. | ||
557 | --- | ||
558 | client/main.c | 9 ++++++++- | ||
559 | 1 file changed, 8 insertions(+), 1 deletion(-) | ||
560 | |||
561 | diff --git a/client/main.c b/client/main.c | ||
562 | index 6e6f6d2fb..1a66a3ab4 100644 | ||
563 | --- a/client/main.c | ||
564 | +++ b/client/main.c | ||
565 | @@ -1416,6 +1416,11 @@ static void filter_clear_duplicate(void) | ||
566 | filter.duplicate = false; | ||
567 | } | ||
568 | 459 | ||
569 | +static void filter_clear_discoverable(void) | 460 | + adapter->pending_settings |= setting; |
570 | +{ | ||
571 | + filter.discoverable = false; | ||
572 | +} | ||
573 | + | 461 | + |
574 | struct clear_entry { | 462 | switch (setting) { |
575 | const char *name; | 463 | case MGMT_SETTING_POWERED: |
576 | void (*clear) (void); | 464 | opcode = MGMT_OP_SET_POWERED; |
577 | @@ -1427,6 +1432,7 @@ static const struct clear_entry filter_clear[] = { | 465 | @@ -2798,7 +2883,7 @@ static void property_set_mode(struct btd_adapter *adapter, uint32_t setting, |
578 | { "pathloss", filter_clear_pathloss }, | 466 | data->id = id; |
579 | { "transport", filter_clear_transport }, | ||
580 | { "duplicate-data", filter_clear_duplicate }, | ||
581 | + { "discoverable", filter_clear_discoverable }, | ||
582 | {} | ||
583 | }; | ||
584 | 467 | ||
585 | @@ -2539,7 +2545,8 @@ static const struct bt_shell_menu scan_menu = { | 468 | if (mgmt_send(adapter->mgmt, opcode, adapter->dev_id, len, param, |
586 | { "discoverable", "[on/off]", cmd_scan_filter_discoverable, | 469 | - property_set_mode_complete, data, g_free) > 0) |
587 | "Set/Get discoverable filter", | 470 | + property_set_mode_complete, data, g_free) > 0) |
588 | NULL }, | 471 | return; |
589 | - { "clear", "[uuids/rssi/pathloss/transport/duplicate-data]", | ||
590 | + { "clear", | ||
591 | + "[uuids/rssi/pathloss/transport/duplicate-data/discoverable]", | ||
592 | cmd_scan_filter_clear, | ||
593 | "Clears discovery filter.", | ||
594 | filter_clear_generator }, | ||
595 | -- | ||
596 | 2.17.1 | ||
597 | Subject: [PATCH BlueZ 5/5] adapter: Fix not keeping discovery filters | ||
598 | From: Luiz Augusto von Dentz <luiz.dentz () gmail ! com> | ||
599 | Date: 2018-07-26 14:17:23 | ||
600 | Message-ID: 20180726141723.20199-5-luiz.dentz () gmail ! com | ||
601 | [Download RAW message or body] | ||
602 | |||
603 | From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | ||
604 | |||
605 | If the discovery has been stopped and the client has set filters those | ||
606 | should be put back into filter list since the client may still be | ||
607 | interested in using them the next time it start a scanning. | ||
608 | --- | ||
609 | src/adapter.c | 25 ++++++++++++++++--------- | ||
610 | 1 file changed, 16 insertions(+), 9 deletions(-) | ||
611 | |||
612 | diff --git a/src/adapter.c b/src/adapter.c | ||
613 | index bd9edddc6..822bd3472 100644 | ||
614 | --- a/src/adapter.c | ||
615 | +++ b/src/adapter.c | ||
616 | @@ -1854,7 +1854,7 @@ static bool set_filtered_discoverable(struct btd_adapter *adapter, bool enable) | ||
617 | return set_discoverable(adapter, enable, 0); | ||
618 | } | ||
619 | 472 | ||
620 | -static void discovery_remove(struct watch_client *client) | 473 | g_free(data); |
621 | +static void discovery_remove(struct watch_client *client, bool exit) | 474 | @@ -2875,6 +2960,7 @@ static void property_set_discoverable_timeout( |
475 | GDBusPendingPropertySet id, void *user_data) | ||
622 | { | 476 | { |
623 | struct btd_adapter *adapter = client->adapter; | 477 | struct btd_adapter *adapter = user_data; |
624 | 478 | + bool enabled; | |
625 | @@ -1882,7 +1882,11 @@ static void discovery_remove(struct watch_client *client) | 479 | dbus_uint32_t value; |
626 | set_filtered_discoverable(adapter, false); | ||
627 | } | ||
628 | |||
629 | - discovery_free(client); | ||
630 | + if (!exit && client->discovery_filter) | ||
631 | + adapter->set_filter_list = g_slist_prepend( | ||
632 | + adapter->set_filter_list, client); | ||
633 | + else | ||
634 | + discovery_free(client); | ||
635 | 480 | ||
636 | /* | 481 | dbus_message_iter_get_basic(iter, &value); |
637 | * If there are other client discoveries in progress, then leave | 482 | @@ -2888,8 +2974,19 @@ static void property_set_discoverable_timeout( |
638 | @@ -1911,8 +1915,11 @@ static void stop_discovery_complete(uint8_t status, uint16_t length, | 483 | g_dbus_emit_property_changed(dbus_conn, adapter->path, |
639 | goto done; | 484 | ADAPTER_INTERFACE, "DiscoverableTimeout"); |
640 | } | ||
641 | 485 | ||
642 | - if (client->msg) | 486 | + if (adapter->pending_settings & MGMT_SETTING_DISCOVERABLE) { |
643 | + if (client->msg) { | 487 | + if (adapter->current_settings & MGMT_SETTING_DISCOVERABLE) |
644 | g_dbus_send_reply(dbus_conn, client->msg, DBUS_TYPE_INVALID); | 488 | + enabled = false; |
645 | + dbus_message_unref(client->msg); | 489 | + else |
646 | + client->msg = NULL; | 490 | + enabled = true; |
491 | + } else { | ||
492 | + if (adapter->current_settings & MGMT_SETTING_DISCOVERABLE) | ||
493 | + enabled = true; | ||
494 | + else | ||
495 | + enabled = false; | ||
647 | + } | 496 | + } |
648 | 497 | ||
649 | adapter->discovery_type = 0x00; | 498 | - if (adapter->current_settings & MGMT_SETTING_DISCOVERABLE) |
650 | adapter->discovery_enable = 0x00; | 499 | + if (enabled) |
651 | @@ -1925,7 +1932,7 @@ static void stop_discovery_complete(uint8_t status, uint16_t length, | 500 | set_discoverable(adapter, 0x01, adapter->discoverable_timeout); |
652 | trigger_passive_scanning(adapter); | ||
653 | |||
654 | done: | ||
655 | - discovery_remove(client); | ||
656 | + discovery_remove(client, false); | ||
657 | } | ||
658 | |||
659 | static int compare_sender(gconstpointer a, gconstpointer b) | ||
660 | @@ -2146,14 +2153,14 @@ static int update_discovery_filter(struct btd_adapter *adapter) | ||
661 | return -EINPROGRESS; | ||
662 | } | ||
663 | |||
664 | -static int discovery_stop(struct watch_client *client) | ||
665 | +static int discovery_stop(struct watch_client *client, bool exit) | ||
666 | { | ||
667 | struct btd_adapter *adapter = client->adapter; | ||
668 | struct mgmt_cp_stop_discovery cp; | ||
669 | |||
670 | /* Check if there are more client discovering */ | ||
671 | if (g_slist_next(adapter->discovery_list)) { | ||
672 | - discovery_remove(client); | ||
673 | + discovery_remove(client, exit); | ||
674 | update_discovery_filter(adapter); | ||
675 | return 0; | ||
676 | } | ||
677 | @@ -2163,7 +2170,7 @@ static int discovery_stop(struct watch_client *client) | ||
678 | * and so it is enough to send out the signal and just return. | ||
679 | */ | ||
680 | if (adapter->discovery_enable == 0x00) { | ||
681 | - discovery_remove(client); | ||
682 | + discovery_remove(client, exit); | ||
683 | adapter->discovering = false; | ||
684 | g_dbus_emit_property_changed(dbus_conn, adapter->path, | ||
685 | ADAPTER_INTERFACE, "Discovering"); | ||
686 | @@ -2188,7 +2195,7 @@ static void discovery_disconnect(DBusConnection *conn, void *user_data) | ||
687 | |||
688 | DBG("owner %s", client->owner); | ||
689 | |||
690 | - discovery_stop(client); | ||
691 | + discovery_stop(client, true); | ||
692 | } | 501 | } |
693 | 502 | ||
694 | /* | ||
695 | @@ -2586,7 +2593,7 @@ static DBusMessage *stop_discovery(DBusConnection *conn, | ||
696 | if (client->msg) | ||
697 | return btd_error_busy(msg); | ||
698 | |||
699 | - err = discovery_stop(client); | ||
700 | + err = discovery_stop(client, false); | ||
701 | switch (err) { | ||
702 | case 0: | ||
703 | return dbus_message_new_method_return(msg); | ||
704 | -- | 503 | -- |
705 | 2.17.1 | 504 | 2.7.4 |
505 | |||