[-]
[+]
|
Changed |
_service:tar_git:bluez5.changes
|
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5.spec
^
|
|
[-]
[+]
|
Changed |
_service
^
|
@@ -1,7 +1,7 @@
<services>
<service name="tar_git">
- <param name="url">https://github.com/piggz/bluez5.git</param>
- <param name="branch">use-cached-appearance</param>
+ <param name="url">https://github.com/sailfishos/bluez5.git</param>
+ <param name="branch">master</param>
<param name="revision">HEAD</param>
<param name="debian">N</param>
<param name="dumb">N</param>
|
[-]
[+]
|
Deleted |
_service:tar_git:bluez5-5.63+git1+use.cached.appearance.20220405092430.1.ga06796ad7.tar.gz/attrib/gatt-service.c
^
|
@@ -1,362 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-/*
- *
- * BlueZ - Bluetooth protocol stack for Linux
- *
- * Copyright (C) 2011 Nokia Corporation
- * Copyright (C) 2011 Marcel Holtmann <marcel@holtmann.org>
- *
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <glib.h>
-
-#include "lib/bluetooth.h"
-#include "lib/sdp.h"
-#include "lib/uuid.h"
-
-#include "src/adapter.h"
-#include "src/shared/util.h"
-#include "attrib/gattrib.h"
-#include "attrib/att.h"
-#include "attrib/gatt.h"
-#include "attrib/att-database.h"
-#include "src/attrib-server.h"
-#include "attrib/gatt-service.h"
-#include "src/log.h"
-
-struct gatt_info {
- bt_uuid_t uuid;
- uint8_t props;
- int authentication;
- int authorization;
- GSList *callbacks;
- unsigned int num_attrs;
- uint16_t *value_handle;
- uint16_t *ccc_handle;
-};
-
-struct attrib_cb {
- attrib_event_t event;
- void *fn;
- void *user_data;
-};
-
-static inline void put_uuid_le(const bt_uuid_t *src, void *dst)
-{
- if (src->type == BT_UUID16)
- put_le16(src->value.u16, dst);
- else
- /* Convert from 128-bit BE to LE */
- bswap_128(&src->value.u128, dst);
-}
-
-static GSList *parse_opts(gatt_option opt1, va_list args)
-{
- gatt_option opt = opt1;
- struct gatt_info *info;
- struct attrib_cb *cb;
- GSList *l = NULL;
-
- info = g_new0(struct gatt_info, 1);
- l = g_slist_append(l, info);
-
- while (opt != GATT_OPT_INVALID) {
- switch (opt) {
- case GATT_OPT_CHR_UUID16:
- bt_uuid16_create(&info->uuid, va_arg(args, int));
- /* characteristic declaration and value */
- info->num_attrs += 2;
- break;
- case GATT_OPT_CHR_UUID:
- memcpy(&info->uuid, va_arg(args, bt_uuid_t *),
- sizeof(bt_uuid_t));
- /* characteristic declaration and value */
- info->num_attrs += 2;
- break;
- case GATT_OPT_CHR_PROPS:
- info->props = va_arg(args, int);
-
- if (info->props & (GATT_CHR_PROP_NOTIFY |
- GATT_CHR_PROP_INDICATE))
- /* client characteristic configuration */
- info->num_attrs += 1;
-
- /* TODO: "Extended Properties" property requires a
- * descriptor, but it is not supported yet. */
- break;
- case GATT_OPT_CHR_VALUE_CB:
- cb = g_new0(struct attrib_cb, 1);
- cb->event = va_arg(args, attrib_event_t);
- cb->fn = va_arg(args, void *);
- cb->user_data = va_arg(args, void *);
- info->callbacks = g_slist_append(info->callbacks, cb);
- break;
- case GATT_OPT_CHR_VALUE_GET_HANDLE:
- info->value_handle = va_arg(args, void *);
- break;
- case GATT_OPT_CCC_GET_HANDLE:
- info->ccc_handle = va_arg(args, void *);
- break;
- case GATT_OPT_CHR_AUTHENTICATION:
- info->authentication = va_arg(args, gatt_option);
- break;
- case GATT_OPT_CHR_AUTHORIZATION:
- info->authorization = va_arg(args, gatt_option);
- break;
- case GATT_CHR_VALUE_READ:
- case GATT_CHR_VALUE_WRITE:
- case GATT_CHR_VALUE_BOTH:
- case GATT_OPT_INVALID:
- default:
- error("Invalid option: %d", opt);
- }
-
- opt = va_arg(args, gatt_option);
- if (opt == GATT_OPT_CHR_UUID16 || opt == GATT_OPT_CHR_UUID) {
- info = g_new0(struct gatt_info, 1);
- l = g_slist_append(l, info);
- }
- }
-
- return l;
-}
-
-static struct attribute *add_service_declaration(struct btd_adapter *adapter,
- uint16_t handle, uint16_t svc, bt_uuid_t *uuid)
-{
- bt_uuid_t bt_uuid;
- uint8_t atval[16];
- int len;
-
- put_uuid_le(uuid, &atval[0]);
- len = bt_uuid_len(uuid);
-
- bt_uuid16_create(&bt_uuid, svc);
-
- return attrib_db_add(adapter, handle, &bt_uuid, ATT_NONE,
- ATT_NOT_PERMITTED, atval, len);
-}
-
-static int att_read_req(int authorization, int authentication, uint8_t props)
-{
- if (authorization == GATT_CHR_VALUE_READ ||
- authorization == GATT_CHR_VALUE_BOTH)
- return ATT_AUTHORIZATION;
- else if (authentication == GATT_CHR_VALUE_READ ||
- authentication == GATT_CHR_VALUE_BOTH)
- return ATT_AUTHENTICATION;
- else if (!(props & GATT_CHR_PROP_READ))
- return ATT_NOT_PERMITTED;
-
- return ATT_NONE;
-}
-
-static int att_write_req(int authorization, int authentication, uint8_t props)
-{
- if (authorization == GATT_CHR_VALUE_WRITE ||
- authorization == GATT_CHR_VALUE_BOTH)
- return ATT_AUTHORIZATION;
- else if (authentication == GATT_CHR_VALUE_WRITE ||
- authentication == GATT_CHR_VALUE_BOTH)
- return ATT_AUTHENTICATION;
- else if (!(props & (GATT_CHR_PROP_WRITE |
- GATT_CHR_PROP_WRITE_WITHOUT_RESP)))
- return ATT_NOT_PERMITTED;
-
- return ATT_NONE;
-}
-
-static int find_callback(gconstpointer a, gconstpointer b)
-{
- const struct attrib_cb *cb = a;
- unsigned int event = GPOINTER_TO_UINT(b);
-
- return cb->event - event;
-}
-
-static gboolean add_characteristic(struct btd_adapter *adapter,
- uint16_t *handle, struct gatt_info *info)
-{
- int read_req, write_req;
- uint16_t h = *handle;
- struct attribute *a;
- bt_uuid_t bt_uuid;
- uint8_t atval[ATT_MAX_VALUE_LEN];
- GSList *l;
-
- if ((info->uuid.type != BT_UUID16 && info->uuid.type != BT_UUID128) ||
- !info->props) {
- error("Characteristic UUID or properties are missing");
- return FALSE;
- }
-
- read_req = att_read_req(info->authorization, info->authentication,
- info->props);
|
[-]
[+]
|
Deleted |
_service:tar_git:bluez5-5.63+git1+use.cached.appearance.20220405092430.1.ga06796ad7.tar.gz/attrib/gatt-service.h
^
|
@@ -1,44 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
- *
- * BlueZ - Bluetooth protocol stack for Linux
- *
- * Copyright (C) 2011 Nokia Corporation
- * Copyright (C) 2011 Marcel Holtmann <marcel@holtmann.org>
- *
- *
- */
-
-typedef enum {
- GATT_OPT_INVALID = 0,
-
- /* bt_uuid_t* value */
- GATT_OPT_CHR_UUID,
-
- /* a uint16 value */
- GATT_OPT_CHR_UUID16,
-
- GATT_OPT_CHR_PROPS,
- GATT_OPT_CHR_VALUE_CB,
- GATT_OPT_CHR_AUTHENTICATION,
- GATT_OPT_CHR_AUTHORIZATION,
-
- /* Get attribute handle for characteristic value */
- GATT_OPT_CHR_VALUE_GET_HANDLE,
-
- /* Get handle for ccc attribute */
- GATT_OPT_CCC_GET_HANDLE,
-
- /* arguments for authentication/authorization */
- GATT_CHR_VALUE_READ,
- GATT_CHR_VALUE_WRITE,
- GATT_CHR_VALUE_BOTH,
-} gatt_option;
-
-typedef enum {
- ATTRIB_READ,
- ATTRIB_WRITE,
-} attrib_event_t;
-
-gboolean gatt_service_add(struct btd_adapter *adapter, uint16_t uuid,
- bt_uuid_t *svc_uuid, gatt_option opt1, ...);
|
[-]
[+]
|
Deleted |
_service:tar_git:bluez5-5.63+git1+use.cached.appearance.20220405092430.1.ga06796ad7.tar.gz/src/attrib-server.c
^
|
@@ -1,1656 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-/*
- *
- * BlueZ - Bluetooth protocol stack for Linux
- *
- * Copyright (C) 2010 Nokia Corporation
- * Copyright (C) 2010 Marcel Holtmann <marcel@holtmann.org>
- *
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <errno.h>
-#include <stdint.h>
-#include <stdbool.h>
-#include <string.h>
-#include <unistd.h>
-#include <glib.h>
-#include <sys/stat.h>
-
-#include "lib/bluetooth.h"
-#include "lib/sdp.h"
-#include "lib/sdp_lib.h"
-#include "lib/uuid.h"
-
-#include "btio/btio.h"
-#include "log.h"
-#include "backtrace.h"
-#include "adapter.h"
-#include "device.h"
-#include "src/shared/util.h"
-#include "attrib/gattrib.h"
-#include "attrib/att.h"
-#include "attrib/gatt.h"
-#include "attrib/att-database.h"
-#include "textfile.h"
-#include "storage.h"
-
-#include "attrib-server.h"
-
-static GSList *servers = NULL;
-
-struct gatt_server {
- struct btd_adapter *adapter;
- GIOChannel *l2cap_io;
- GIOChannel *le_io;
- uint32_t gatt_sdp_handle;
- uint32_t gap_sdp_handle;
- GList *database;
- GSList *clients;
- uint16_t name_handle;
- uint16_t appearance_handle;
-};
-
-struct gatt_channel {
- GAttrib *attrib;
- guint mtu;
- gboolean le;
- guint id;
- gboolean encrypted;
- struct gatt_server *server;
- guint cleanup_id;
- struct btd_device *device;
-};
-
-struct group_elem {
- uint16_t handle;
- uint16_t end;
- uint8_t *data;
- uint16_t len;
-};
-
-static bt_uuid_t prim_uuid = {
- .type = BT_UUID16,
- .value.u16 = GATT_PRIM_SVC_UUID
-};
-static bt_uuid_t snd_uuid = {
- .type = BT_UUID16,
- .value.u16 = GATT_SND_SVC_UUID
-};
-static bt_uuid_t ccc_uuid = {
- .type = BT_UUID16,
- .value.u16 = GATT_CLIENT_CHARAC_CFG_UUID
-};
-
-static void attrib_free(void *data)
-{
- struct attribute *a = data;
-
- g_free(a->data);
- g_free(a);
-}
-
-static void channel_free(struct gatt_channel *channel)
-{
-
- if (channel->cleanup_id)
- g_source_remove(channel->cleanup_id);
-
- if (channel->device)
- btd_device_unref(channel->device);
-
- g_attrib_unref(channel->attrib);
- g_free(channel);
-}
-
-static void gatt_server_free(struct gatt_server *server)
-{
- g_list_free_full(server->database, attrib_free);
-
- if (server->l2cap_io != NULL) {
- g_io_channel_shutdown(server->l2cap_io, FALSE, NULL);
- g_io_channel_unref(server->l2cap_io);
- }
-
- if (server->le_io != NULL) {
- g_io_channel_shutdown(server->le_io, FALSE, NULL);
- g_io_channel_unref(server->le_io);
- }
-
- g_slist_free_full(server->clients, (GDestroyNotify) channel_free);
-
- if (server->gatt_sdp_handle > 0)
- adapter_service_remove(server->adapter,
- server->gatt_sdp_handle);
-
- if (server->gap_sdp_handle > 0)
- adapter_service_remove(server->adapter, server->gap_sdp_handle);
-
- if (server->adapter != NULL)
- btd_adapter_unref(server->adapter);
-
- g_free(server);
-}
-
-static int adapter_cmp_addr(gconstpointer a, gconstpointer b)
-{
- const struct gatt_server *server = a;
- const bdaddr_t *bdaddr = b;
-
- return bacmp(btd_adapter_get_address(server->adapter), bdaddr);
-}
-
-static int adapter_cmp(gconstpointer a, gconstpointer b)
-{
- const struct gatt_server *server = a;
- const struct btd_adapter *adapter = b;
-
- if (server->adapter == adapter)
- return 0;
-
- return -1;
-}
-
-static struct gatt_server *find_gatt_server(const bdaddr_t *bdaddr)
-{
- GSList *l;
-
- l = g_slist_find_custom(servers, bdaddr, adapter_cmp_addr);
- if (l == NULL) {
- char addr[18];
-
- ba2str(bdaddr, addr);
- error("No GATT server found in %s", addr);
- return NULL;
- }
-
- return l->data;
-}
-
-static sdp_record_t *server_record_new(uuid_t *uuid, uint16_t start, uint16_t end)
-{
- sdp_list_t *svclass_id, *apseq, *proto[2], *root, *aproto;
- uuid_t root_uuid, proto_uuid, l2cap;
- sdp_record_t *record;
- sdp_data_t *psm, *sh, *eh;
- uint16_t lp = ATT_PSM;
-
- if (uuid == NULL)
- return NULL;
-
- if (start > end)
- return NULL;
-
- record = sdp_record_alloc();
- if (record == NULL)
- return NULL;
-
- sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
- root = sdp_list_append(NULL, &root_uuid);
- sdp_set_browse_groups(record, root);
- sdp_list_free(root, NULL);
-
- svclass_id = sdp_list_append(NULL, uuid);
- sdp_set_service_classes(record, svclass_id);
- sdp_list_free(svclass_id, NULL);
|
[-]
[+]
|
Deleted |
_service:tar_git:bluez5-5.63+git1+use.cached.appearance.20220405092430.1.ga06796ad7.tar.gz/src/attrib-server.h
^
|
@@ -1,29 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
- *
- * BlueZ - Bluetooth protocol stack for Linux
- *
- * Copyright (C) 2010 Nokia Corporation
- * Copyright (C) 2010 Marcel Holtmann <marcel@holtmann.org>
- *
- *
- */
-
-uint16_t attrib_db_find_avail(struct btd_adapter *adapter, bt_uuid_t *svc_uuid,
- uint16_t nitems);
-struct attribute *attrib_db_add(struct btd_adapter *adapter, uint16_t handle,
- bt_uuid_t *uuid, int read_req,
- int write_req, const uint8_t *value,
- size_t len);
-int attrib_db_update(struct btd_adapter *adapter, uint16_t handle,
- bt_uuid_t *uuid, const uint8_t *value,
- size_t len, struct attribute **attr);
-int attrib_db_del(struct btd_adapter *adapter, uint16_t handle);
-int attrib_gap_set(struct btd_adapter *adapter, uint16_t uuid,
- const uint8_t *value, size_t len);
-uint32_t attrib_create_sdp(struct btd_adapter *adapter, uint16_t handle,
- const char *name);
-void attrib_free_sdp(struct btd_adapter *adapter, uint32_t sdp_handle);
-GAttrib *attrib_from_device(struct btd_device *device);
-guint attrib_channel_attach(GAttrib *attrib);
-gboolean attrib_channel_detach(GAttrib *attrib, guint id);
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/ChangeLog
^
|
@@ -1,3 +1,27 @@
+ver 5.65:
+ Fix issue with A2DP cache invalidation handling.
+ Fix issue with A2DP and not initialized SEP codec.
+ Fix issue with A2DP and multiple SetConfiguration to same SEP
+ Fix issue with AVRCP and not properly initialized volume.
+ Fix issue with SDP records when operating in LE only mode.
+ Fix issue with HoG and not reading report map of instances.
+ Fix issue with GATT server crashing while disconnecting.
+ Fix issue with not removing connected devices.
+ Fix issue with enabling wake support without RPA Resolution.
+ Fix issue with pairing failed due to the error of Already Paired.
+ Add support for CONFIGURATION_DIRECTORY environment variable.
+ Add support for STATE_DIRECTORY environment variable.
+ Add support for "Bonded" property with Device API.
+ Add experimental support for ISO socket.
+
+ver 5.64:
+ Fix issue with handling A2DP discover procedure.
+ Fix issue with media endpoint replies and SetConfiguration.
+ Fix issue with HoG queuing events before report map is read.
+ Fix issue with HoG and read order of GATT attributes.
+ Fix issue with HoG and not using UHID_CREATE2 interface.
+ Fix issue with failed scanning for 5 minutes after reboot.
+
ver 5.63:
Fix issue with storing IRK causing invalid read access.
Fix issue with disconnecting due to GattCharacteristic1.MTU.
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/Makefile.am
^
|
@@ -28,14 +28,14 @@
$(LIBEDATASERVER_CFLAGS) $(ell_cflags)
AM_LDFLAGS = $(MISC_LDFLAGS)
+confdir = $(sysconfdir)/bluetooth
+statedir = $(localstatedir)/lib/bluetooth
+
if DATAFILES
dbusdir = $(DBUS_CONFDIR)/dbus-1/system.d
dbus_DATA = src/bluetooth.conf
-confdir = $(sysconfdir)/bluetooth
conf_DATA =
-
-statedir = $(localstatedir)/lib/bluetooth
state_DATA =
endif
@@ -69,7 +69,7 @@
lib/sco.h lib/l2cap.h lib/sdp.h lib/sdp_lib.h \
lib/rfcomm.h lib/bnep.h lib/cmtp.h lib/hidp.h
-extra_headers = lib/mgmt.h lib/uuid.h lib/a2mp.h lib/amp.h
+extra_headers = lib/mgmt.h lib/uuid.h lib/a2mp.h lib/amp.h lib/iso.h
extra_sources = lib/uuid.c
local_headers = $(foreach file,$(lib_headers), lib/bluetooth/$(notdir $(file)))
@@ -82,7 +82,7 @@
lib_LTLIBRARIES += lib/libbluetooth.la
lib_libbluetooth_la_SOURCES = $(lib_headers) $(lib_sources)
-lib_libbluetooth_la_LDFLAGS = $(AM_LDFLAGS) -version-info 22:6:19
+lib_libbluetooth_la_LDFLAGS = $(AM_LDFLAGS) -version-info 22:7:19
lib_libbluetooth_la_DEPENDENCIES = $(local_headers)
endif
@@ -267,8 +267,7 @@
attrib_sources = attrib/att.h attrib/att-database.h attrib/att.c \
attrib/gatt.h attrib/gatt.c \
- attrib/gattrib.h attrib/gattrib.c \
- attrib/gatt-service.h attrib/gatt-service.c
+ attrib/gattrib.h attrib/gattrib.c
btio_sources = btio/btio.h btio/btio.c
@@ -320,7 +319,6 @@
src/rfkill.c src/btd.h src/sdpd.h \
src/sdpd-server.c src/sdpd-request.c \
src/sdpd-service.c src/sdpd-database.c \
- src/attrib-server.h src/attrib-server.c \
src/gatt-database.h src/gatt-database.c \
src/sdp-xml.h src/sdp-xml.c \
src/sdp-client.h src/sdp-client.c \
@@ -339,7 +337,8 @@
src/dbus-common.c src/dbus-common.h \
src/eir.h src/eir.c \
src/adv_monitor.h src/adv_monitor.c \
- src/battery.h src/battery.c
+ src/battery.h src/battery.c \
+ src/settings.h src/settings.c
src_bluetoothd_LDADD = lib/libbluetooth-internal.la \
gdbus/libgdbus-internal.la \
src/libshared-glib.la \
@@ -523,23 +522,23 @@
unit_test_gobex_SOURCES = $(gobex_sources) unit/util.c unit/util.h \
unit/test-gobex.c
-unit_test_gobex_LDADD = $(GLIB_LIBS)
+unit_test_gobex_LDADD = src/libshared-glib.la $(GLIB_LIBS)
unit_test_gobex_packet_SOURCES = $(gobex_sources) unit/util.c unit/util.h \
unit/test-gobex-packet.c
-unit_test_gobex_packet_LDADD = $(GLIB_LIBS)
+unit_test_gobex_packet_LDADD = src/libshared-glib.la $(GLIB_LIBS)
unit_test_gobex_header_SOURCES = $(gobex_sources) unit/util.c unit/util.h \
unit/test-gobex-header.c
-unit_test_gobex_header_LDADD = $(GLIB_LIBS)
+unit_test_gobex_header_LDADD = src/libshared-glib.la $(GLIB_LIBS)
unit_test_gobex_transfer_SOURCES = $(gobex_sources) unit/util.c unit/util.h \
unit/test-gobex-transfer.c
-unit_test_gobex_transfer_LDADD = $(GLIB_LIBS)
+unit_test_gobex_transfer_LDADD = src/libshared-glib.la $(GLIB_LIBS)
unit_test_gobex_apparam_SOURCES = $(gobex_sources) unit/util.c unit/util.h \
unit/test-gobex-apparam.c
-unit_test_gobex_apparam_LDADD = $(GLIB_LIBS)
+unit_test_gobex_apparam_LDADD = src/libshared-glib.la $(GLIB_LIBS)
endif
unit_tests += unit/test-lib
@@ -645,6 +644,9 @@
SED_PROCESS = $(AM_V_GEN)$(MKDIR_P) $(dir $@) && \
$(SED) -e 's,@pkglibexecdir\@,$(pkglibexecdir),g' \
+ -e 's,@libexecdir\@,$(libexecdir),g' \
+ -e 's,@statedir\@,$(statedir),g' \
+ -e 's,@confdir\@,$(confdir),g' \
< $< > $@
if RUN_RST2MAN
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/Makefile.obexd
^
|
@@ -92,6 +92,7 @@
obexd/src/map_ap.h
obexd_src_obexd_LDADD = lib/libbluetooth-internal.la \
gdbus/libgdbus-internal.la \
+ src/libshared-glib.la \
$(ICAL_LIBS) $(DBUS_LIBS) $(LIBEBOOK_LIBS) \
$(LIBEDATASERVER_LIBS) $(GLIB_LIBS) -ldl
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/Makefile.tools
^
|
@@ -10,8 +10,8 @@
client/adv_monitor.h \
client/adv_monitor.c \
client/gatt.h client/gatt.c \
- client/admin.h \
- client/admin.c
+ client/admin.h client/admin.c \
+ client/player.h client/player.c
client_bluetoothctl_LDADD = gdbus/libgdbus-internal.la src/libshared-glib.la \
$(GLIB_LIBS) $(DBUS_LIBS) -lreadline
endif
@@ -48,9 +48,14 @@
monitor/broadcom.h monitor/broadcom.c \
monitor/msft.h monitor/msft.c \
monitor/jlink.h monitor/jlink.c \
- monitor/tty.h
+ monitor/tty.h monitor/emulator.h \
+ monitor/att.h monitor/att.c \
+ src/log.h src/log.c \
+ src/textfile.h src/textfile.c \
+ src/settings.h src/settings.c
monitor_btmon_LDADD = lib/libbluetooth-internal.la \
- src/libshared-mainloop.la $(UDEV_LIBS) -ldl
+ src/libshared-mainloop.la \
+ $(GLIB_LIBS) $(UDEV_LIBS) -ldl
if MANPAGES
man_MANS += monitor/btmon.1
@@ -81,7 +86,7 @@
tools/l2cap-tester tools/sco-tester \
tools/smp-tester tools/hci-tester \
tools/rfcomm-tester tools/bnep-tester \
- tools/userchan-tester
+ tools/userchan-tester tools/iso-tester
emulator_btvirt_SOURCES = emulator/main.c monitor/bt.h \
emulator/serial.h emulator/serial.c \
@@ -189,11 +194,20 @@
emulator/smp.c
tools_userchan_tester_LDADD = lib/libbluetooth-internal.la \
src/libshared-glib.la $(GLIB_LIBS)
+
+tools_iso_tester_SOURCES = tools/iso-tester.c monitor/bt.h \
+ emulator/hciemu.h emulator/hciemu.c \
+ emulator/vhci.h emulator/vhci.c \
+ emulator/btdev.h emulator/btdev.c \
+ emulator/bthost.h emulator/bthost.c \
+ emulator/smp.c
+tools_iso_tester_LDADD = lib/libbluetooth-internal.la \
+ src/libshared-glib.la $(GLIB_LIBS)
endif
if TOOLS
bin_PROGRAMS += tools/rctest tools/l2test tools/l2ping tools/bluemoon \
- tools/hex2hcd tools/mpris-proxy tools/btattach
+ tools/hex2hcd tools/mpris-proxy tools/btattach tools/isotest
noinst_PROGRAMS += tools/bdaddr tools/avinfo tools/avtest \
tools/scotest tools/amptest tools/hwdb \
@@ -302,13 +316,16 @@
tools_mpris_proxy_LDADD = gdbus/libgdbus-internal.la $(GLIB_LIBS) $(DBUS_LIBS)
tools_gatt_service_SOURCES = tools/gatt-service.c
-tools_gatt_service_LDADD = $(GLIB_LIBS) $(DBUS_LIBS) gdbus/libgdbus-internal.la
+tools_gatt_service_LDADD = gdbus/libgdbus-internal.la \
+ src/libshared-mainloop.la $(GLIB_LIBS) $(DBUS_LIBS)
+
+tools_isotest_LDADD = lib/libbluetooth-internal.la
profiles_iap_iapd_SOURCES = profiles/iap/main.c
profiles_iap_iapd_LDADD = gdbus/libgdbus-internal.la $(GLIB_LIBS) $(DBUS_LIBS)
if MANPAGES
-man_MANS += tools/rctest.1 tools/l2ping.1 tools/btattach.1
+man_MANS += tools/rctest.1 tools/l2ping.1 tools/btattach.1 tools/isotest.1
endif
if MESH
@@ -426,7 +443,7 @@
tools/hcitool.1 tools/hcidump.1 \
tools/rfcomm.1 tools/sdptool.1 tools/ciptool.1 \
tools/rctest.1 tools/l2ping.1 tools/btattach.1 \
- tools/bdaddr.1
+ tools/bdaddr.1 tools/isotest.1
if HID2HCI
udevdir = $(UDEV_DIR)
@@ -448,20 +465,21 @@
tools_obex_client_tool_SOURCES = $(gobex_sources) $(btio_sources) \
tools/obex-client-tool.c
tools_obex_client_tool_LDADD = lib/libbluetooth-internal.la \
- $(GLIB_LIBS) -lreadline
+ src/libshared-glib.la $(GLIB_LIBS) -lreadline
tools_obex_server_tool_SOURCES = $(gobex_sources) $(btio_sources) \
tools/obex-server-tool.c
-tools_obex_server_tool_LDADD = lib/libbluetooth-internal.la $(GLIB_LIBS)
+tools_obex_server_tool_LDADD = lib/libbluetooth-internal.la \
+ src/libshared-glib.la $(GLIB_LIBS)
-tools_bluetooth_player_SOURCES = tools/bluetooth-player.c
+tools_bluetooth_player_SOURCES = tools/bluetooth-player.c client/player.c
tools_bluetooth_player_LDADD = gdbus/libgdbus-internal.la \
src/libshared-glib.la \
$(GLIB_LIBS) $(DBUS_LIBS) -lreadline
tools_obexctl_SOURCES = tools/obexctl.c
tools_obexctl_LDADD = gdbus/libgdbus-internal.la src/libshared-glib.la \
- $(GLIB_LIBS) $(DBUS_LIBS) -lreadline
+ $(GLIB_LIBS) $(DBUS_LIBS) -lreadline
tools_btmgmt_SOURCES = tools/btmgmt.c src/uuid-helper.c client/display.c
tools_btmgmt_LDADD = lib/libbluetooth-internal.la src/libshared-mainloop.la \
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/acinclude.m4
^
|
@@ -71,13 +71,13 @@
AC_DEFUN([MISC_FLAGS], [
misc_cflags=""
misc_ldflags=""
- AC_ARG_ENABLE(optimization, AC_HELP_STRING([--disable-optimization],
+ AC_ARG_ENABLE(optimization, AS_HELP_STRING([--disable-optimization],
[disable code optimization through compiler]), [
if (test "${enableval}" = "no"); then
misc_cflags="$misc_cflags -O0"
fi
])
- AC_ARG_ENABLE(asan, AC_HELP_STRING([--enable-asan],
+ AC_ARG_ENABLE(asan, AS_HELP_STRING([--enable-asan],
[enable linking with address sanitizer]), [
save_LIBS=$LIBS
AC_CHECK_LIB(asan, _init)
@@ -90,7 +90,7 @@
AC_SUBST([ASAN_LIB], ${ac_cv_lib_asan__init})
fi
])
- AC_ARG_ENABLE(lsan, AC_HELP_STRING([--enable-lsan],
+ AC_ARG_ENABLE(lsan, AS_HELP_STRING([--enable-lsan],
[enable linking with address sanitizer]), [
save_LIBS=$LIBS
AC_CHECK_LIB(lsan, _init)
@@ -103,7 +103,7 @@
AC_SUBST([ASAN_LIB], ${ac_cv_lib_lsan__init})
fi
])
- AC_ARG_ENABLE(ubsan, AC_HELP_STRING([--enable-ubsan],
+ AC_ARG_ENABLE(ubsan, AS_HELP_STRING([--enable-ubsan],
[enable linking with address sanitizer]), [
save_LIBS=$LIBS
AC_CHECK_LIB(ubsan, _init)
@@ -115,14 +115,14 @@
misc_ldflags="$misc_ldflags -fsanitize=undefined";
fi
])
- AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug],
+ AC_ARG_ENABLE(debug, AS_HELP_STRING([--enable-debug],
[enable compiling with debugging information]), [
if (test "${enableval}" = "yes" &&
test "${ac_cv_prog_cc_g}" = "yes"); then
misc_cflags="$misc_cflags -g"
fi
])
- AC_ARG_ENABLE(pie, AC_HELP_STRING([--enable-pie],
+ AC_ARG_ENABLE(pie, AS_HELP_STRING([--enable-pie],
[enable position independent executables flag]), [
if (test "${enableval}" = "yes" &&
test "${ac_cv_prog_cc_pie}" = "yes"); then
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/android/a2dp.c
^
|
@@ -26,6 +26,7 @@
#include "lib/sdp_lib.h"
#include "profiles/audio/a2dp-codecs.h"
#include "src/shared/queue.h"
+#include "src/shared/util.h"
#include "src/log.h"
#include "hal-msg.h"
#include "ipc-common.h"
@@ -428,7 +429,7 @@
p = g_new0(struct a2dp_preset, 1);
p->len = conf_len;
- p->data = g_memdup(conf, p->len);
+ p->data = util_memdup(conf, p->len);
return p;
}
@@ -448,7 +449,7 @@
p = g_new0(struct a2dp_preset, 1);
p->len = conf_len;
- p->data = g_memdup(conf, p->len);
+ p->data = util_memdup(conf, p->len);
return p;
}
@@ -1036,7 +1037,7 @@
preset = g_new0(struct a2dp_preset, 1);
preset->len = cap->length - sizeof(*codec);
- preset->data = g_memdup(codec->data, preset->len);
+ preset->data = util_memdup(codec->data, preset->len);
if (check_config(endpoint, preset) < 0) {
preset_free(preset);
@@ -1365,7 +1366,7 @@
preset = g_new0(struct a2dp_preset, 1);
preset->len = p->len;
- preset->data = g_memdup(p->data, preset->len);
+ preset->data = util_memdup(p->data, preset->len);
l = g_slist_append(l, preset);
len -= preset->len;
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/android/avctp.c
^
|
@@ -31,6 +31,7 @@
#include <glib.h>
#include "lib/sdp.h"
+#include "src/shared/util.h"
#include "src/log.h"
#include "avctp.h"
@@ -1177,7 +1178,7 @@
for (i = 0; i < iov_cnt; i++) {
pdu[i].iov_len = iov[i].iov_len;
- pdu[i].iov_base = g_memdup(iov[i].iov_base, iov[i].iov_len);
+ pdu[i].iov_base = util_memdup(iov[i].iov_base, iov[i].iov_len);
}
req = g_new0(struct avctp_control_req, 1);
@@ -1218,7 +1219,7 @@
for (i = 0; i < iov_cnt; i++) {
pdu[i].iov_len = iov[i].iov_len;
- pdu[i].iov_base = g_memdup(iov[i].iov_base, iov[i].iov_len);
+ pdu[i].iov_base = util_memdup(iov[i].iov_base, iov[i].iov_len);
}
req = g_new0(struct avctp_browsing_req, 1);
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/android/avrcp-lib.c
^
|
@@ -2620,7 +2620,7 @@
return NULL;
}
- folders[count] = g_memdup(¶ms[i], len);
+ folders[count] = util_memdup(¶ms[i], len);
i += len;
}
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/android/gatt.c
^
|
@@ -1338,7 +1338,8 @@
}
bt_uuid_to_uuid128(&uuid, &u128);
- new_uuid = g_memdup(&u128.value.u128, sizeof(u128.value.u128));
+ new_uuid = util_memdup(&u128.value.u128,
+ sizeof(u128.value.u128));
uuids = g_slist_prepend(uuids, new_uuid);
}
@@ -6633,7 +6634,7 @@
queue_push_tail(dev->pending_requests, data);
- data->value = g_memdup(value, vlen);
+ data->value = util_memdup(value, vlen);
data->length = vlen;
if (!gatt_db_attribute_write(attrib, offset, value, vlen, cmd[0],
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/android/hidhost.c
^
|
@@ -689,7 +689,8 @@
goto fail;
dev->rd_size = data->unitSize;
- dev->rd_data = g_memdup(data->val.str, data->unitSize);
+ dev->rd_data = util_memdup(data->val.str,
+ data->unitSize);
}
}
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/android/tester-main.c
^
|
@@ -1253,7 +1253,8 @@
for (i = 0; i < num_properties; i++) {
props[i].type = properties[i].type;
props[i].len = properties[i].len;
- props[i].val = g_memdup(properties[i].val, properties[i].len);
+ props[i].val = util_memdup(properties[i].val,
+ properties[i].len);
}
return props;
@@ -1268,7 +1269,8 @@
for (i = 0; i < num_properties; i++) {
props[i].type = properties[i]->type;
props[i].len = properties[i]->len;
- props[i].val = g_memdup(properties[i]->val, properties[i]->len);
+ props[i].val = util_memdup(properties[i]->val,
+ properties[i]->len);
}
return props;
@@ -1281,7 +1283,7 @@
prop->type = type;
prop->len = len;
- prop->val = g_memdup(val, len);
+ prop->val = util_memdup(val, len);
return prop;
}
@@ -1615,7 +1617,7 @@
step->callback = CB_GATTC_SEARCH_RESULT;
step->callback_result.conn_id = conn_id;
- step->callback_result.service = g_memdup(srvc_id, sizeof(*srvc_id));
+ step->callback_result.service = util_memdup(srvc_id, sizeof(*srvc_id));
schedule_callback_verification(step);
}
@@ -1639,8 +1641,8 @@
step->callback = CB_GATTC_GET_CHARACTERISTIC;
step->callback_result.status = status;
step->callback_result.conn_id = conn_id;
- step->callback_result.service = g_memdup(srvc_id, sizeof(*srvc_id));
- step->callback_result.characteristic = g_memdup(char_id,
+ step->callback_result.service = util_memdup(srvc_id, sizeof(*srvc_id));
+ step->callback_result.characteristic = util_memdup(char_id,
sizeof(*char_id));
step->callback_result.char_prop = char_prop;
@@ -1656,10 +1658,10 @@
step->callback = CB_GATTC_GET_DESCRIPTOR;
step->callback_result.status = status;
step->callback_result.conn_id = conn_id;
- step->callback_result.service = g_memdup(srvc_id, sizeof(*srvc_id));
- step->callback_result.characteristic = g_memdup(char_id,
+ step->callback_result.service = util_memdup(srvc_id, sizeof(*srvc_id));
+ step->callback_result.characteristic = util_memdup(char_id,
sizeof(*char_id));
- step->callback_result.descriptor = g_memdup(descr_id,
+ step->callback_result.descriptor = util_memdup(descr_id,
sizeof(*descr_id));
schedule_callback_verification(step);
@@ -1673,8 +1675,8 @@
step->callback = CB_GATTC_GET_INCLUDED_SERVICE;
step->callback_result.status = status;
step->callback_result.conn_id = conn_id;
- step->callback_result.service = g_memdup(srvc_id, sizeof(*srvc_id));
- step->callback_result.included = g_memdup(incl_srvc_id,
+ step->callback_result.service = util_memdup(srvc_id, sizeof(*srvc_id));
+ step->callback_result.included = util_memdup(incl_srvc_id,
sizeof(*srvc_id));
schedule_callback_verification(step);
@@ -1688,7 +1690,8 @@
step->callback = CB_GATTC_READ_CHARACTERISTIC;
step->callback_result.status = status;
step->callback_result.conn_id = conn_id;
- step->callback_result.read_params = g_memdup(p_data, sizeof(*p_data));
+ step->callback_result.read_params = util_memdup(p_data,
+ sizeof(*p_data));
schedule_callback_verification(step);
}
@@ -1701,7 +1704,8 @@
step->callback = CB_GATTC_READ_DESCRIPTOR;
step->callback_result.status = status;
step->callback_result.conn_id = conn_id;
- step->callback_result.read_params = g_memdup(p_data, sizeof(*p_data));
+ step->callback_result.read_params = util_memdup(p_data,
+ sizeof(*p_data));
schedule_callback_verification(step);
}
@@ -1714,7 +1718,8 @@
step->callback = CB_GATTC_WRITE_CHARACTERISTIC;
step->callback_result.status = status;
step->callback_result.conn_id = conn_id;
- step->callback_result.write_params = g_memdup(p_data, sizeof(*p_data));
+ step->callback_result.write_params = util_memdup(p_data,
+ sizeof(*p_data));
schedule_callback_verification(step);
}
@@ -1727,7 +1732,8 @@
step->callback = CB_GATTC_WRITE_DESCRIPTOR;
step->callback_result.status = status;
step->callback_result.conn_id = conn_id;
- step->callback_result.write_params = g_memdup(p_data, sizeof(*p_data));
+ step->callback_result.write_params = util_memdup(p_data,
+ sizeof(*p_data));
schedule_callback_verification(step);
}
@@ -1742,8 +1748,8 @@
step->callback = CB_GATTC_REGISTER_FOR_NOTIFICATION;
step->callback_result.status = status;
step->callback_result.conn_id = conn_id;
- step->callback_result.service = g_memdup(srvc_id, sizeof(*srvc_id));
- step->callback_result.characteristic = g_memdup(char_id,
+ step->callback_result.service = util_memdup(srvc_id, sizeof(*srvc_id));
+ step->callback_result.characteristic = util_memdup(char_id,
sizeof(*char_id));
step->callback_result.notification_registered = registered;
@@ -1756,7 +1762,8 @@
step->callback = CB_GATTC_NOTIFY;
step->callback_result.conn_id = conn_id;
- step->callback_result.notify_params = g_memdup(p_data, sizeof(*p_data));
+ step->callback_result.notify_params = util_memdup(p_data,
+ sizeof(*p_data));
schedule_callback_verification(step);
}
@@ -1827,8 +1834,8 @@
step->callback_result.status = status;
step->callback_result.gatt_app_id = server_if;
- step->callback_result.service = g_memdup(srvc_id, sizeof(*srvc_id));
- step->callback_result.srvc_handle = g_memdup(&srvc_handle,
+ step->callback_result.service = util_memdup(srvc_id, sizeof(*srvc_id));
+ step->callback_result.srvc_handle = util_memdup(&srvc_handle,
sizeof(srvc_handle));
schedule_callback_verification(step);
@@ -1844,9 +1851,9 @@
step->callback_result.status = status;
step->callback_result.gatt_app_id = server_if;
- step->callback_result.srvc_handle = g_memdup(&srvc_handle,
+ step->callback_result.srvc_handle = util_memdup(&srvc_handle,
sizeof(srvc_handle));
- step->callback_result.inc_srvc_handle = g_memdup(&inc_srvc_handle,
+ step->callback_result.inc_srvc_handle = util_memdup(&inc_srvc_handle,
sizeof(inc_srvc_handle));
schedule_callback_verification(step);
@@ -1863,10 +1870,10 @@
step->callback_result.status = status;
step->callback_result.gatt_app_id = server_if;
- step->callback_result.srvc_handle = g_memdup(&srvc_handle,
+ step->callback_result.srvc_handle = util_memdup(&srvc_handle,
sizeof(srvc_handle));
- step->callback_result.uuid = g_memdup(uuid, sizeof(*uuid));
- step->callback_result.char_handle = g_memdup(&char_handle,
+ step->callback_result.uuid = util_memdup(uuid, sizeof(*uuid));
+ step->callback_result.char_handle = util_memdup(&char_handle,
sizeof(char_handle));
schedule_callback_verification(step);
@@ -1883,10 +1890,10 @@
step->callback_result.status = status;
step->callback_result.gatt_app_id = server_if;
- step->callback_result.srvc_handle = g_memdup(&srvc_handle,
+ step->callback_result.srvc_handle = util_memdup(&srvc_handle,
sizeof(srvc_handle));
- step->callback_result.uuid = g_memdup(uuid, sizeof(*uuid));
- step->callback_result.desc_handle = g_memdup(&desc_handle,
+ step->callback_result.uuid = util_memdup(uuid, sizeof(*uuid));
+ step->callback_result.desc_handle = util_memdup(&desc_handle,
sizeof(desc_handle));
schedule_callback_verification(step);
@@ -1900,7 +1907,7 @@
step->callback_result.status = status;
step->callback_result.gatt_app_id = server_if;
- step->callback_result.srvc_handle = g_memdup(&srvc_handle,
+ step->callback_result.srvc_handle = util_memdup(&srvc_handle,
sizeof(srvc_handle));
schedule_callback_verification(step);
@@ -1914,7 +1921,7 @@
step->callback_result.status = status;
step->callback_result.gatt_app_id = server_if;
- step->callback_result.srvc_handle = g_memdup(&srvc_handle,
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/attrib/gatt.c
^
|
@@ -135,7 +135,7 @@
g_slist_free_full(dc->characteristics, g_free);
g_attrib_unref(dc->attrib);
- g_free(dc->uuid);
+ free(dc->uuid);
g_free(dc);
}
@@ -157,7 +157,7 @@
g_slist_free_full(dd->descriptors, g_free);
g_attrib_unref(dd->attrib);
- g_free(dd->uuid);
+ free(dd->uuid);
g_free(dd);
}
@@ -696,7 +696,7 @@
dc->user_data = user_data;
dc->end = end;
dc->start = start;
- dc->uuid = g_memdup(uuid, sizeof(bt_uuid_t));
+ dc->uuid = util_memdup(uuid, sizeof(bt_uuid_t));
dc->id = g_attrib_send(attrib, 0, buf, plen, char_discovered_cb,
discover_char_ref(dc), discover_char_unref);
@@ -905,7 +905,7 @@
if (long_write->offset == long_write->vlen) {
execute_write(long_write->attrib, ATT_WRITE_ALL_PREP_WRITES,
long_write->func, long_write->user_data);
- g_free(long_write->value);
+ free(long_write->value);
g_free(long_write);
return;
@@ -964,7 +964,7 @@
long_write->func = func;
long_write->user_data = user_data;
long_write->handle = handle;
- long_write->value = g_memdup(value, vlen);
+ long_write->value = util_memdup(value, vlen);
long_write->vlen = vlen;
return prepare_write(long_write);
@@ -1130,7 +1130,7 @@
dd->user_data = user_data;
dd->start = start;
dd->end = end;
- dd->uuid = g_memdup(uuid, sizeof(bt_uuid_t));
+ dd->uuid = util_memdup(uuid, sizeof(bt_uuid_t));
dd->id = g_attrib_send(attrib, 0, buf, plen, desc_discovered_cb,
discover_desc_ref(dd), discover_desc_unref);
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/bootstrap-configure
^
|
@@ -33,5 +33,4 @@
--enable-ubsan \
--enable-cups \
--enable-library \
- --enable-admin \
--disable-datafiles $*
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/btio/btio.c
^
|
@@ -27,6 +27,7 @@
#include "lib/l2cap.h"
#include "lib/rfcomm.h"
#include "lib/sco.h"
+#include "lib/iso.h"
#include "btio.h"
@@ -44,6 +45,7 @@
BT_IO_L2CAP,
BT_IO_RFCOMM,
BT_IO_SCO,
+ BT_IO_ISO,
BT_IO_INVALID,
} BtIOType;
@@ -66,6 +68,7 @@
int flushable;
uint32_t priority;
uint16_t voice;
+ struct bt_iso_qos qos;
};
struct connect {
@@ -123,6 +126,8 @@
return BT_IO_SCO;
case BTPROTO_L2CAP:
return BT_IO_L2CAP;
+ case BTPROTO_ISO:
+ return BT_IO_ISO;
default:
g_set_error(gerr, BT_IO_ERROR, EINVAL,
"Unknown BtIO socket type");
@@ -763,6 +768,24 @@
return 0;
}
+static int iso_bind(int sock, const bdaddr_t *src, uint8_t src_type,
+ GError **err)
+{
+ struct sockaddr_iso addr;
+
+ memset(&addr, 0, sizeof(addr));
+ addr.iso_family = AF_BLUETOOTH;
+ bacpy(&addr.iso_bdaddr, src);
+ addr.iso_bdaddr_type = src_type;
+
+ if (!bind(sock, (struct sockaddr *) &addr, sizeof(addr)))
+ return 0;
+
+ ERROR_FAILED(err, "iso_bind", errno);
+
+ return -errno;
+}
+
static int sco_connect(int sock, const bdaddr_t *dst)
{
struct sockaddr_sco addr;
@@ -779,6 +802,23 @@
return 0;
}
+static int iso_connect(int sock, const bdaddr_t *dst, uint8_t dst_type)
+{
+ struct sockaddr_iso addr;
+ int err;
+
+ memset(&addr, 0, sizeof(addr));
+ addr.iso_family = AF_BLUETOOTH;
+ bacpy(&addr.iso_bdaddr, dst);
+ addr.iso_bdaddr_type = dst_type;
+
+ err = connect(sock, (struct sockaddr *) &addr, sizeof(addr));
+ if (err < 0 && !(errno == EAGAIN || errno == EINPROGRESS))
+ return -errno;
+
+ return 0;
+}
+
static gboolean sco_set(int sock, uint16_t mtu, uint16_t voice, GError **err)
{
struct sco_options sco_opt;
@@ -817,6 +857,17 @@
return TRUE;
}
+static gboolean iso_set(int sock, struct bt_iso_qos *qos, GError **err)
+{
+ if (setsockopt(sock, SOL_BLUETOOTH, BT_ISO_QOS, qos,
+ sizeof(*qos)) < 0) {
+ ERROR_FAILED(err, "setsockopt(BT_ISO_QOS)", errno);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
static gboolean parse_set_opts(struct set_opts *opts, GError **err,
BtIOOption opt1, va_list args)
{
@@ -894,6 +945,13 @@
break;
case BT_IO_OPT_MODE:
opts->mode = va_arg(args, int);
+ if (opts->mode == BT_IO_MODE_ISO) {
+ opts->type = BT_IO_ISO;
+ if (opts->src_type == BDADDR_BREDR)
+ opts->src_type = BDADDR_LE_PUBLIC;
+ if (opts->dst_type == BDADDR_BREDR)
+ opts->dst_type = BDADDR_LE_PUBLIC;
+ }
break;
case BT_IO_OPT_FLUSHABLE:
opts->flushable = va_arg(args, gboolean);
@@ -904,6 +962,9 @@
case BT_IO_OPT_VOICE:
opts->voice = va_arg(args, int);
break;
+ case BT_IO_OPT_QOS:
+ opts->qos = *va_arg(args, struct bt_iso_qos *);
+ break;
case BT_IO_OPT_INVALID:
case BT_IO_OPT_KEY_SIZE:
case BT_IO_OPT_SOURCE_CHANNEL:
@@ -1227,6 +1288,7 @@
case BT_IO_OPT_DEST_CHANNEL:
case BT_IO_OPT_MTU:
case BT_IO_OPT_VOICE:
+ case BT_IO_OPT_QOS:
default:
g_set_error(err, BT_IO_ERROR, EINVAL,
"Unknown option %d", opt);
@@ -1380,6 +1442,7 @@
case BT_IO_OPT_FLUSHABLE:
case BT_IO_OPT_PRIORITY:
case BT_IO_OPT_VOICE:
+ case BT_IO_OPT_QOS:
case BT_IO_OPT_INVALID:
default:
g_set_error(err, BT_IO_ERROR, EINVAL,
@@ -1489,6 +1552,95 @@
case BT_IO_OPT_FLUSHABLE:
case BT_IO_OPT_PRIORITY:
case BT_IO_OPT_VOICE:
+ case BT_IO_OPT_QOS:
+ case BT_IO_OPT_INVALID:
+ default:
+ g_set_error(err, BT_IO_ERROR, EINVAL,
+ "Unknown option %d", opt);
+ return FALSE;
+ }
+
+ opt = va_arg(args, int);
+ }
+
+ return TRUE;
+}
+
+static gboolean iso_get(int sock, GError **err, BtIOOption opt1, va_list args)
+{
+ BtIOOption opt = opt1;
+ struct sockaddr_iso src, dst;
+ struct bt_iso_qos qos;
+ socklen_t len;
+ uint32_t phy;
+
+ len = sizeof(qos);
+ memset(&qos, 0, len);
+ if (getsockopt(sock, SOL_BLUETOOTH, BT_ISO_QOS, &qos, &len) < 0) {
+ ERROR_FAILED(err, "getsockopt(BT_ISO_QOS)", errno);
+ return FALSE;
+ }
+
+ if (!get_src(sock, &src, sizeof(src), err))
+ return FALSE;
+
+ if (!get_dst(sock, &dst, sizeof(dst), err))
+ return FALSE;
+
+ while (opt != BT_IO_OPT_INVALID) {
+ switch (opt) {
+ case BT_IO_OPT_SOURCE:
+ ba2str(&src.iso_bdaddr, va_arg(args, char *));
+ break;
+ case BT_IO_OPT_SOURCE_BDADDR:
+ bacpy(va_arg(args, bdaddr_t *), &src.iso_bdaddr);
+ break;
+ case BT_IO_OPT_SOURCE_TYPE:
+ *(va_arg(args, uint8_t *)) = src.iso_bdaddr_type;
+ break;
+ case BT_IO_OPT_DEST:
+ ba2str(&dst.iso_bdaddr, va_arg(args, char *));
+ break;
+ case BT_IO_OPT_DEST_BDADDR:
+ bacpy(va_arg(args, bdaddr_t *), &dst.iso_bdaddr);
+ break;
+ case BT_IO_OPT_DEST_TYPE:
+ *(va_arg(args, uint8_t *)) = dst.iso_bdaddr_type;
+ break;
+ case BT_IO_OPT_MTU:
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/btio/btio.h
^
|
@@ -44,6 +44,7 @@
BT_IO_OPT_PRIORITY,
BT_IO_OPT_VOICE,
BT_IO_OPT_PHY,
+ BT_IO_OPT_QOS,
} BtIOOption;
typedef enum {
@@ -58,7 +59,8 @@
BT_IO_MODE_ERTM,
BT_IO_MODE_STREAMING,
BT_IO_MODE_LE_FLOWCTL,
- BT_IO_MODE_EXT_FLOWCTL
+ BT_IO_MODE_EXT_FLOWCTL,
+ BT_IO_MODE_ISO
} BtIOMode;
typedef void (*BtIOConfirm)(GIOChannel *io, gpointer user_data);
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/client/advertising.c
^
|
@@ -125,8 +125,6 @@
str[sizeof(str) - 3] = '.';
if (str[sizeof(str) - 4] == ' ')
str[sizeof(str) - 4] = '.';
-
- n = sizeof(str) - 1;
}
bt_shell_printf("UUID: %s(%s)\n", str, uuid);
@@ -1009,13 +1007,13 @@
return bt_shell_noninteractive_quit(EXIT_SUCCESS);
}
- if (ad.min_interval != *min) {
+ if (min && ad.min_interval != *min) {
ad.min_interval = *min;
g_dbus_emit_property_changed(conn, AD_PATH, AD_IFACE,
"MinInterval");
}
- if (ad.max_interval != *max) {
+ if (max && ad.max_interval != *max) {
ad.max_interval = *max;
g_dbus_emit_property_changed(conn, AD_PATH, AD_IFACE,
"MaxInterval");
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/client/gatt.c
^
|
@@ -811,7 +811,7 @@
*val_len = i;
- return g_memdup(value, i);
+ return util_memdup(value, i);
}
void gatt_write_attribute(GDBusProxy *proxy, int argc, char *argv[])
@@ -1527,8 +1527,10 @@
if (argc > 2) {
service->handle = parse_handle(argv[2]);
- if (!service->handle)
+ if (!service->handle) {
+ service_free(service);
return bt_shell_noninteractive_quit(EXIT_FAILURE);
+ }
}
if (g_dbus_register_interface(conn, service->path,
@@ -2622,8 +2624,10 @@
if (argc > 3) {
chrc->handle = parse_handle(argv[3]);
- if (!chrc->handle)
+ if (!chrc->handle) {
+ chrc_free(chrc);
return bt_shell_noninteractive_quit(EXIT_FAILURE);
+ }
}
if (g_dbus_register_interface(conn, chrc->path, CHRC_INTERFACE,
@@ -2902,8 +2906,10 @@
if (argc > 3) {
desc->handle = parse_handle(argv[3]);
- if (!desc->handle)
+ if (!desc->handle) {
+ desc_free(desc);
return bt_shell_noninteractive_quit(EXIT_FAILURE);
+ }
}
if (g_dbus_register_interface(conn, desc->path, DESC_INTERFACE,
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/client/main.c
^
|
@@ -30,6 +30,7 @@
#include "advertising.h"
#include "adv_monitor.h"
#include "admin.h"
+#include "player.h"
/* String display constants */
#define COLORED_NEW COLOR_GREEN "NEW" COLOR_OFF
@@ -77,6 +78,14 @@
NULL
};
+static const char * const device_arguments[] = {
+ "Paired",
+ "Bonded",
+ "Trusted",
+ "Connected",
+ NULL
+};
+
static void proxy_leak(gpointer data)
{
printf("Leaking proxy %p\n", data);
@@ -911,6 +920,28 @@
return TRUE;
}
+static gboolean parse_argument_devices(int argc, char *argv[],
+ const char * const *arg_table,
+ const char **option)
+{
+ const char * const *opt;
+
+ if (argc < 2) {
+ *option = NULL;
+ return TRUE;
+ }
+
+ for (opt = arg_table; opt && *opt; opt++) {
+ if (strcmp(argv[1], *opt) == 0) {
+ *option = *opt;
+ return TRUE;
+ }
+ }
+
+ bt_shell_printf("Invalid argument %s\n", argv[1]);
+ return FALSE;
+}
+
static gboolean parse_argument(int argc, char *argv[], const char **arg_table,
const char *msg, dbus_bool_t *value,
const char **option)
@@ -1050,22 +1081,11 @@
static void cmd_devices(int argc, char *argv[])
{
GList *ll;
+ const char *property;
- if (check_default_ctrl() == FALSE)
- return bt_shell_noninteractive_quit(EXIT_SUCCESS);
-
- for (ll = g_list_first(default_ctrl->devices);
- ll; ll = g_list_next(ll)) {
- GDBusProxy *proxy = ll->data;
- print_device(proxy, NULL);
- }
-
- return bt_shell_noninteractive_quit(EXIT_SUCCESS);
-}
-
-static void cmd_paired_devices(int argc, char *argv[])
-{
- GList *ll;
+ if (!parse_argument_devices(argc, argv, device_arguments,
+ &property))
+ return bt_shell_noninteractive_quit(EXIT_FAILURE);
if (check_default_ctrl() == FALSE)
return bt_shell_noninteractive_quit(EXIT_SUCCESS);
@@ -1074,15 +1094,17 @@
ll; ll = g_list_next(ll)) {
GDBusProxy *proxy = ll->data;
DBusMessageIter iter;
- dbus_bool_t paired;
-
- if (g_dbus_proxy_get_property(proxy, "Paired", &iter) == FALSE)
- continue;
-
- dbus_message_iter_get_basic(&iter, &paired);
- if (!paired)
- continue;
+ dbus_bool_t status;
+ if (property) {
+ if (g_dbus_proxy_get_property(proxy,
+ property, &iter) == FALSE)
+ continue;
+
+ dbus_message_iter_get_basic(&iter, &status);
+ if (!status)
+ continue;
+ }
print_device(proxy, NULL);
}
@@ -1294,6 +1316,7 @@
dbus_bool_t discoverable;
bool set;
bool active;
+ unsigned int timeout;
} filter = {
.rssi = DISTANCE_VAL_INVALID,
.pathloss = DISTANCE_VAL_INVALID,
@@ -1415,18 +1438,33 @@
filter.set = true;
}
+static const char *scan_arguments[] = {
+ "on",
+ "off",
+ "bredr",
+ "le",
+ NULL
+};
+
static void cmd_scan(int argc, char *argv[])
{
dbus_bool_t enable;
const char *method;
+ const char *mode;
- if (!parse_argument(argc, argv, NULL, NULL, &enable, NULL))
+ if (!parse_argument(argc, argv, scan_arguments, "Mode", &enable,
+ &mode))
return bt_shell_noninteractive_quit(EXIT_FAILURE);
if (check_default_ctrl() == FALSE)
return bt_shell_noninteractive_quit(EXIT_FAILURE);
if (enable == TRUE) {
+ if (strcmp(mode, "")) {
+ g_free(filter.transport);
+ filter.transport = g_strdup(mode);
+ }
+
set_discovery_filter(false);
method = "StartDiscovery";
} else
@@ -1764,6 +1802,7 @@
print_property(proxy, "Appearance");
print_property(proxy, "Icon");
print_property(proxy, "Paired");
+ print_property(proxy, "Bonded");
print_property(proxy, "Trusted");
print_property(proxy, "Blocked");
print_property(proxy, "Connected");
@@ -2514,6 +2553,11 @@
return argument_generator(text, state, agent_arguments);
}
+static char *scan_generator(const char *text, int state)
+{
+ return argument_generator(text, state, scan_arguments);
+}
+
static void cmd_advertise(int argc, char *argv[])
{
dbus_bool_t enable;
@@ -2724,7 +2768,7 @@
max = min;
if (argc > 2) {
- max = strtol(argv[1], &endptr, 0);
+ max = strtol(argv[2], &endptr, 0);
if (!endptr || *endptr != '\0' || max < 20 || max > 10485) {
bt_shell_printf("Invalid argument\n");
return bt_shell_noninteractive_quit(EXIT_FAILURE);
@@ -3091,9 +3135,9 @@
ctrl_generator },
{ "select", "<ctrl>", cmd_select, "Select default controller",
ctrl_generator },
- { "devices", NULL, cmd_devices, "List available devices" },
- { "paired-devices", NULL, cmd_paired_devices,
- "List paired devices"},
+ { "devices", "[Paired/Bonded/Trusted/Connected]", cmd_devices,
+ "List available devices, with an "
+ "optional property as the filter" },
{ "system-alias", "<name>", cmd_system_alias,
"Set controller alias" },
{ "reset-alias", NULL, cmd_reset_alias,
@@ -3117,7 +3161,8 @@
"Enable/disable advertising with given type",
ad_generator},
{ "set-alias", "<alias>", cmd_set_alias, "Set device alias" },
- { "scan", "<on/off>", cmd_scan, "Scan for devices", NULL },
+ { "scan", "<on/off/bredr/le>", cmd_scan,
+ "Scan for devices", scan_generator },
{ "info", "[dev]", cmd_info, "Device information",
dev_generator },
{ "pair", "[dev]", cmd_pair, "Pair with device",
|
[-]
[+]
|
Added |
_service:tar_git:bluez5-5.65+git1.tar.gz/client/player.c
^
|
@@ -0,0 +1,2749 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2020 Intel Corporation. All rights reserved.
+ *
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <errno.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/uio.h>
+#include <wordexp.h>
+
+#include <glib.h>
+
+#include "gdbus/gdbus.h"
+
+#include "lib/bluetooth.h"
+#include "lib/uuid.h"
+
+#include "profiles/audio/a2dp-codecs.h"
+
+#include "src/shared/util.h"
+#include "src/shared/shell.h"
+#include "src/shared/io.h"
+#include "src/shared/queue.h"
+#include "player.h"
+
+/* String display constants */
+#define COLORED_NEW COLOR_GREEN "NEW" COLOR_OFF
+#define COLORED_CHG COLOR_YELLOW "CHG" COLOR_OFF
+#define COLORED_DEL COLOR_RED "DEL" COLOR_OFF
+
+#define BLUEZ_MEDIA_INTERFACE "org.bluez.Media1"
+#define BLUEZ_MEDIA_PLAYER_INTERFACE "org.bluez.MediaPlayer1"
+#define BLUEZ_MEDIA_FOLDER_INTERFACE "org.bluez.MediaFolder1"
+#define BLUEZ_MEDIA_ITEM_INTERFACE "org.bluez.MediaItem1"
+#define BLUEZ_MEDIA_ENDPOINT_INTERFACE "org.bluez.MediaEndpoint1"
+#define BLUEZ_MEDIA_TRANSPORT_INTERFACE "org.bluez.MediaTransport1"
+
+#define BLUEZ_MEDIA_ENDPOINT_PATH "/local/endpoint"
+
+#define NSEC_USEC(_t) (_t / 1000L)
+#define SEC_USEC(_t) (_t * 1000000L)
+#define TS_USEC(_ts) (SEC_USEC((_ts)->tv_sec) + NSEC_USEC((_ts)->tv_nsec))
+
+struct endpoint {
+ char *path;
+ char *uuid;
+ uint8_t codec;
+ struct iovec *caps;
+ bool auto_accept;
+ char *transport;
+ DBusMessage *msg;
+};
+
+static DBusConnection *dbus_conn;
+static GDBusProxy *default_player;
+static GList *medias = NULL;
+static GList *players = NULL;
+static GList *folders = NULL;
+static GList *items = NULL;
+static GList *endpoints = NULL;
+static GList *local_endpoints = NULL;
+static GList *transports = NULL;
+static struct queue *ios = NULL;
+
+struct transport {
+ GDBusProxy *proxy;
+ int sk;
+ uint16_t mtu[2];
+ char *filename;
+ int fd;
+ struct io *io;
+ uint32_t seq;
+};
+
+static void endpoint_unregister(void *data)
+{
+ struct endpoint *ep = data;
+
+ bt_shell_printf("Endpoint %s unregistered\n", ep->path);
+ g_dbus_unregister_interface(dbus_conn, ep->path,
+ BLUEZ_MEDIA_ENDPOINT_INTERFACE);
+}
+
+static void disconnect_handler(DBusConnection *connection, void *user_data)
+{
+ g_list_free_full(local_endpoints, endpoint_unregister);
+ local_endpoints = NULL;
+}
+
+static bool check_default_player(void)
+{
+ if (!default_player) {
+ bt_shell_printf("No default player available\n");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static char *generic_generator(const char *text, int state, GList *source)
+{
+ static int index = 0;
+
+ if (!source)
+ return NULL;
+
+ if (!state)
+ index = 0;
+
+ return g_dbus_proxy_path_lookup(source, &index, text);
+}
+
+static char *player_generator(const char *text, int state)
+{
+ return generic_generator(text, state, players);
+}
+
+static char *item_generator(const char *text, int state)
+{
+ return generic_generator(text, state, items);
+}
+
+static void play_reply(DBusMessage *message, void *user_data)
+{
+ DBusError error;
+
+ dbus_error_init(&error);
+
+ if (dbus_set_error_from_message(&error, message) == TRUE) {
+ bt_shell_printf("Failed to play: %s\n", error.name);
+ dbus_error_free(&error);
+ return bt_shell_noninteractive_quit(EXIT_FAILURE);
+ }
+
+ bt_shell_printf("Play successful\n");
+
+ return bt_shell_noninteractive_quit(EXIT_FAILURE);
+}
+
+static void cmd_play(int argc, char *argv[])
+{
+ GDBusProxy *proxy;
+
+ if (argc > 1) {
+ proxy = g_dbus_proxy_lookup(items, NULL, argv[1],
+ BLUEZ_MEDIA_ITEM_INTERFACE);
+ if (proxy == NULL) {
+ bt_shell_printf("Item %s not available\n", argv[1]);
+ return bt_shell_noninteractive_quit(EXIT_FAILURE);
+ }
+ } else {
+ if (!check_default_player())
+ return bt_shell_noninteractive_quit(EXIT_FAILURE);
+ proxy = default_player;
+ }
+
+ if (g_dbus_proxy_method_call(proxy, "Play", NULL, play_reply,
+ NULL, NULL) == FALSE) {
+ bt_shell_printf("Failed to play\n");
+ return bt_shell_noninteractive_quit(EXIT_FAILURE);
+ }
+
+ bt_shell_printf("Attempting to play %s\n", argv[1] ? : "");
+}
+
+static void pause_reply(DBusMessage *message, void *user_data)
+{
+ DBusError error;
+
+ dbus_error_init(&error);
+
+ if (dbus_set_error_from_message(&error, message) == TRUE) {
+ bt_shell_printf("Failed to pause: %s\n", error.name);
+ dbus_error_free(&error);
+ return bt_shell_noninteractive_quit(EXIT_FAILURE);
+ }
+
+ bt_shell_printf("Pause successful\n");
+
+ return bt_shell_noninteractive_quit(EXIT_SUCCESS);
+}
+
|
[-]
[+]
|
Added |
_service:tar_git:bluez5-5.65+git1.tar.gz/client/player.h
^
|
@@ -0,0 +1,12 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2020 Intel Corporation. All rights reserved.
+ *
+ *
+ */
+
+void player_add_submenu(void);
+void player_remove_submenu(void);
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/configure.ac
^
|
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: GPL-2.0
AC_PREREQ(2.60)
-AC_INIT(bluez, 5.63)
+AC_INIT(bluez, 5.65)
AM_INIT_AUTOMAKE([foreign subdir-objects color-tests silent-rules
tar-pax no-dist-gzip dist-xz])
@@ -16,7 +16,7 @@
COMPILER_FLAGS
-AC_LANG_C
+AC_LANG([C])
AC_C_RESTRICT
@@ -49,11 +49,13 @@
AM_CONDITIONAL(VALGRIND, test "${enable_valgrind}" = "yes" &&
test "$ASAN_LIB" != "yes" && test "LSAN_LIB" != "yes")
-AC_ARG_ENABLE(threads, AC_HELP_STRING([--enable-threads],
+AC_ARG_ENABLE(threads, AS_HELP_STRING([--enable-threads],
[enable threading support]), [enable_threads=${enableval}])
AC_CHECK_FUNCS(explicit_bzero)
+AC_CHECK_FUNCS(getrandom)
+
AC_CHECK_FUNCS(rawmemchr)
AC_CHECK_FUNC(signalfd, dummy=yes,
@@ -68,7 +70,7 @@
AC_CHECK_LIB(dl, dlopen, dummy=yes,
AC_MSG_ERROR(dynamic linking loader is required))
-AC_CHECK_HEADERS(linux/types.h linux/if_alg.h linux/uinput.h linux/uhid.h)
+AC_CHECK_HEADERS(linux/types.h linux/if_alg.h linux/uinput.h linux/uhid.h sys/random.h)
PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.28, dummy=yes,
AC_MSG_ERROR(GLib >= 2.28 is required))
@@ -88,7 +90,7 @@
AC_SUBST(DBUS_CFLAGS)
AC_SUBST(DBUS_LIBS)
-AC_ARG_WITH([dbusconfdir], AC_HELP_STRING([--with-dbusconfdir=DIR],
+AC_ARG_WITH([dbusconfdir], AS_HELP_STRING([--with-dbusconfdir=DIR],
[path to D-Bus configuration directory]),
[path_dbusconfdir=${withval}])
if (test -z "${path_dbusconfdir}"); then
@@ -101,7 +103,7 @@
fi
AC_SUBST(DBUS_CONFDIR, [${path_dbusconfdir}])
-AC_ARG_WITH([dbussystembusdir], AC_HELP_STRING([--with-dbussystembusdir=DIR],
+AC_ARG_WITH([dbussystembusdir], AS_HELP_STRING([--with-dbussystembusdir=DIR],
[path to D-Bus system bus services directory]),
[path_dbussystembusdir=${withval}])
if (test -z "${path_dbussystembusdir}"); then
@@ -114,7 +116,7 @@
fi
AC_SUBST(DBUS_SYSTEMBUSDIR, [${path_dbussystembusdir}])
-AC_ARG_WITH([dbussessionbusdir], AC_HELP_STRING([--with-dbussessionbusdir=DIR],
+AC_ARG_WITH([dbussessionbusdir], AS_HELP_STRING([--with-dbussessionbusdir=DIR],
[path to D-Bus session bus services directory]),
[path_dbussessionbusdir=${withval}])
if (test -z "${path_dbussessionbusdir}"); then
@@ -127,7 +129,7 @@
fi
AC_SUBST(DBUS_SESSIONBUSDIR, [${path_dbussessionbusdir}])
-AC_ARG_WITH([zsh-completion-dir], AC_HELP_STRING([--with-zsh-completion-dir=DIR],
+AC_ARG_WITH([zsh-completion-dir], AS_HELP_STRING([--with-zsh-completion-dir=DIR],
[path to install zsh completions]),
[path_zshcompletiondir=${withval}],
[path_zshcompletiondir="yes"])
@@ -139,7 +141,7 @@
AC_SUBST(ZSH_COMPLETIONDIR, [${path_zshcompletiondir}])
AM_CONDITIONAL(ZSH_COMPLETIONS, test "${path_zshcompletiondir}" != "no")
-AC_ARG_ENABLE(backtrace, AC_HELP_STRING([--enable-backtrace],
+AC_ARG_ENABLE(backtrace, AS_HELP_STRING([--enable-backtrace],
[compile backtrace support]), [enable_backtrace=${enableval}])
if (test "${enable_backtrace}" = "yes"); then
@@ -153,55 +155,55 @@
AC_SUBST(BACKTRACE_LIBS)
fi
-AC_ARG_ENABLE(library, AC_HELP_STRING([--enable-library],
+AC_ARG_ENABLE(library, AS_HELP_STRING([--enable-library],
[install Bluetooth library]), [enable_library=${enableval}])
AM_CONDITIONAL(LIBRARY, test "${enable_library}" = "yes")
-AC_ARG_ENABLE(test, AC_HELP_STRING([--enable-test],
+AC_ARG_ENABLE(test, AS_HELP_STRING([--enable-test],
[enable test/example scripts]), [enable_test=${enableval}])
AM_CONDITIONAL(TEST, test "${enable_test}" = "yes")
-AC_ARG_ENABLE(nfc, AC_HELP_STRING([--enable-nfc],
+AC_ARG_ENABLE(nfc, AS_HELP_STRING([--enable-nfc],
[enable NFC paring]), [enable_nfc=${enableval}])
AM_CONDITIONAL(NFC, test "${enable_nfc}" = "yes")
-AC_ARG_ENABLE(sap, AC_HELP_STRING([--enable-sap],
+AC_ARG_ENABLE(sap, AS_HELP_STRING([--enable-sap],
[enable SAP profile]), [enable_sap=${enableval}])
AM_CONDITIONAL(SAP, test "${enable_sap}" = "yes")
-AC_ARG_ENABLE(a2dp, AC_HELP_STRING([--disable-a2dp],
+AC_ARG_ENABLE(a2dp, AS_HELP_STRING([--disable-a2dp],
[disable A2DP profile]), [enable_a2dp=${enableval}])
AM_CONDITIONAL(A2DP, test "${enable_a2dp}" != "no")
-AC_ARG_ENABLE(avrcp, AC_HELP_STRING([--disable-avrcp],
+AC_ARG_ENABLE(avrcp, AS_HELP_STRING([--disable-avrcp],
[disable AVRCP profile]), [enable_avrcp=${enableval}])
AM_CONDITIONAL(AVRCP, test "${enable_avrcp}" != "no")
-AC_ARG_ENABLE(network, AC_HELP_STRING([--disable-network],
+AC_ARG_ENABLE(network, AS_HELP_STRING([--disable-network],
[disable network profiles]), [enable_network=${enableval}])
AM_CONDITIONAL(NETWORK, test "${enable_network}" != "no")
-AC_ARG_ENABLE(hid, AC_HELP_STRING([--disable-hid],
+AC_ARG_ENABLE(hid, AS_HELP_STRING([--disable-hid],
[disable HID profile]), [enable_hid=${enableval}])
AM_CONDITIONAL(HID, test "${enable_hid}" != "no")
-AC_ARG_ENABLE(hog, AC_HELP_STRING([--disable-hog],
+AC_ARG_ENABLE(hog, AS_HELP_STRING([--disable-hog],
[disable HoG profile]), [enable_hog=${enableval}])
AM_CONDITIONAL(HOG, test "${enable_hog}" != "no")
-AC_ARG_ENABLE(health, AC_HELP_STRING([--enable-health],
+AC_ARG_ENABLE(health, AS_HELP_STRING([--enable-health],
[enable health profiles]), [enable_health=${enableval}])
AM_CONDITIONAL(HEALTH, test "${enable_health}" = "yes")
-AC_ARG_ENABLE(tools, AC_HELP_STRING([--disable-tools],
+AC_ARG_ENABLE(tools, AS_HELP_STRING([--disable-tools],
[disable Bluetooth tools]), [enable_tools=${enableval}])
AM_CONDITIONAL(TOOLS, test "${enable_tools}" != "no")
-AC_ARG_ENABLE(monitor, AC_HELP_STRING([--disable-monitor],
+AC_ARG_ENABLE(monitor, AS_HELP_STRING([--disable-monitor],
[disable Bluetooth monitor]), [enable_monitor=${enableval}])
AM_CONDITIONAL(MONITOR, test "${enable_monitor}" != "no")
-AC_ARG_ENABLE(udev, AC_HELP_STRING([--disable-udev],
+AC_ARG_ENABLE(udev, AS_HELP_STRING([--disable-udev],
[disable udev device support]), [enable_udev=${enableval}])
if (test "${enable_tools}" != "no" && test "${enable_udev}" != "no"); then
PKG_CHECK_MODULES(UDEV, libudev >= 172, dummy=yes,
@@ -214,7 +216,7 @@
fi
AM_CONDITIONAL(UDEV, test "${enable_udev}" != "no")
-AC_ARG_WITH([udevdir], AC_HELP_STRING([--with-udevdir=DIR],
+AC_ARG_WITH([udevdir], AS_HELP_STRING([--with-udevdir=DIR],
[path to udev directory]), [path_udevdir=${withval}])
if (test "${enable_udev}" != "no" && test -z "${path_udevdir}"); then
AC_MSG_CHECKING([udev directory])
@@ -226,11 +228,11 @@
fi
AC_SUBST(UDEV_DIR, [${path_udevdir}])
-AC_ARG_ENABLE(cups, AC_HELP_STRING([--disable-cups],
+AC_ARG_ENABLE(cups, AS_HELP_STRING([--disable-cups],
[disable CUPS printer support]), [enable_cups=${enableval}])
AM_CONDITIONAL(CUPS, test "${enable_cups}" != "no")
-AC_ARG_ENABLE(mesh, AC_HELP_STRING([--enable-mesh],
+AC_ARG_ENABLE(mesh, AS_HELP_STRING([--enable-mesh],
[enable Mesh profile support]), [enable_mesh=${enableval}])
AM_CONDITIONAL(MESH, test "${enable_mesh}" = "yes")
@@ -241,7 +243,7 @@
AC_SUBST(JSON_LIBS)
fi
-AC_ARG_ENABLE(midi, AC_HELP_STRING([--enable-midi],
+AC_ARG_ENABLE(midi, AS_HELP_STRING([--enable-midi],
[enable MIDI support]), [enable_midi=${enableval}])
AM_CONDITIONAL(MIDI, test "${enable_midi}" = "yes")
@@ -252,7 +254,7 @@
AC_SUBST(ALSA_LIBS)
fi
-AC_ARG_ENABLE(obex, AC_HELP_STRING([--disable-obex],
+AC_ARG_ENABLE(obex, AS_HELP_STRING([--disable-obex],
[disable OBEX profile support]), [enable_obex=${enableval}])
if (test "${enable_obex}" != "no"); then
PKG_CHECK_MODULES(ICAL, libical, dummy=yes,
@@ -262,11 +264,11 @@
fi
AM_CONDITIONAL(OBEX, test "${enable_obex}" != "no")
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/doc/adapter-api.txt
^
|
@@ -21,6 +21,9 @@
During discovery RSSI delta-threshold is imposed.
+ Each client can request a single device discovery session
+ per adapter.
+
Possible errors: org.bluez.Error.NotReady
org.bluez.Error.Failed
org.bluez.Error.InProgress
@@ -32,7 +35,8 @@
Note that a discovery procedure is shared between all
discovery sessions thus calling StopDiscovery will only
- release a single session.
+ release a single session and discovery will stop when
+ all sessions from all clients have finished.
Possible errors: org.bluez.Error.NotReady
org.bluez.Error.Failed
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/doc/coding-style.txt
^
|
@@ -7,14 +7,14 @@
understood and maintained.
First of all, BlueZ coding style must follow every rule for Linux kernel
-(http://www.kernel.org/doc/Documentation/CodingStyle). There also exists a tool
-named checkpatch.pl to help you check the compliance with it. Just type
-"checkpatch.pl --no-tree patch_name" to check your patch. In theory, you need
-to clean up all the warnings and errors except this one: "ERROR: Missing
-Signed-off-by: line(s)". BlueZ does not used Signed-Off lines, so including
-them is actually an error. In certain circumstances one can ignore the 80
-character per line limit. This is generally only allowed if the alternative
-would make the code even less readable.
+(https://www.kernel.org/doc/Documentation/process/coding-style.rst). There also
+exists a tool named checkpatch.pl to help you check the compliance with it.
+Just type "checkpatch.pl --no-tree patch_name" to check your patch. In theory,
+you need to clean up all the warnings and errors except this one: "ERROR:
+Missing Signed-off-by: line(s)". BlueZ does not used Signed-Off lines, so
+including them is actually an error. In certain circumstances one can ignore
+the 80 character per line limit. This is generally only allowed if the
+alternative would make the code even less readable.
Besides the kernel coding style above, BlueZ has special flavors for its own.
Some of them are mandatory (marked as 'M'), while some others are optional
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/doc/device-api.txt
^
|
@@ -169,7 +169,16 @@
boolean Paired [readonly]
- Indicates if the remote device is paired.
+ Indicates if the remote device is paired. Paired means
+ the pairing process where devices exchange the
+ information to establish an encrypted connection has
+ been completed.
+
+ boolean Bonded [readonly]
+
+ Indicates if the remote device is bonded. Bonded means
+ the information exchanged on pairing process has been
+ stored and will be persisted.
boolean Connected [readonly]
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/doc/mgmt-api.txt
^
|
@@ -332,6 +332,7 @@
15 Static Address
16 PHY Configuration
17 Wideband Speech
+ 18 Quality Report
This command generates a Command Complete event on success or
a Command Status event on failure.
@@ -2924,6 +2925,7 @@
15 Static Address
16 PHY Configuration
17 Wideband Speech
+ 18 Quality Report
The EIR_Data field contains information about class of device,
local name and other values. Not all of them might be present. For
@@ -3591,7 +3593,6 @@
Controller Index: <controller id>
Command Parameters: Instance (1 Octet)
Flags (4 Octets)
- Params (2 Octets)
Duration (2 Octets)
Timeout (2 Octets)
MinInterval (4 Octets)
@@ -3629,6 +3630,8 @@
7 Secondary Channel with LE 1M
8 Secondary Channel with LE 2M
9 Secondary Channel with LE Coded
+ 10 Indicate tx power can be specified
+ 11 Indicate HW supports the advertising offload
12 The Duration parameter should be used
13 The Timeout parameter should be used
14 The Interval parameters should be used
@@ -3858,6 +3861,45 @@
Invalid Parameters
+Set Quality Report Command
+==========================
+
+ Command Code: 0x0057
+ Controller Index: <controller id>
+ Command Parameters: Quality_Report (1 Octet)
+ Return Parameters: Current_Settings (4 Octets)
+
+ This command is used to enable and disable the controller's quality
+ report feature. The allowed values for the Quality_Report command
+ parameter are 0x00 and 0x01. All other values will return Invalid
+ Parameters.
+
+ The value 0x00 disables the Quality Report, and the value 0x01
+ enables the Quality Report feature.
+
+ This command is only available for the controllers that support
+ either AOSP Bluetooth quality report or Intel telemetry event.
+ It is supported if the supported_settings indicate support for it.
+
+ This command requires to use a valid controller index. Otherwise,
+ an Invalid Index status will be returned.
+
+ The command is sent to the controller to enable/disable the quality
+ report feature, and generates a Command Complete event on success.
+ If the controller failed to execute the action, a Failed status will
+ be returned.
+
+ The quality report state is maintained by the kernel over the adapter
+ power cycle. When the adapter is powered off, the quality report
+ feature is disabled by the kernel. When the adapter is powered on, it
+ is enabled again by the kernel if it was enabled before.
+
+ Possible errors: Failed
+ Invalid Index
+ Invalid Parameters
+ Not Supported
+
+
Command Complete Event
======================
@@ -4978,3 +5020,22 @@
2 LE Random
This event will be sent to all management sockets.
+
+
+Quality Report Event
+====================
+
+ Event code: 0x0031
+ Controller Index: <controller_id>
+ Event Parameters: Quality_Spec (1 Octet)
+ Report_Len (2 Octets)
+ Report (0-65535 Octets)
+
+ This event carries the Bluetooth quality report sent by the
+ controller.
+
+ Possible values for the Quality_Spec parameter:
+ 0 AOSP Bluetooth Quality Report Event
+ 1 Intel Telemetry Event
+
+ This event will be sent to all management sockets.
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/doc/settings-storage.txt
^
|
@@ -18,6 +18,11 @@
Default storage directory is /var/lib/bluetooth. This can be adjusted
by the --localstatedir configure switch. Default is --localstatedir=/var.
+When loading as a service the storage directory can be set via
+StateDirectory environment variable:
+
+https://www.freedesktop.org/software/systemd/man/systemd.exec.html
+
All files are in ini-file format.
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/doc/test-runner.txt
^
|
@@ -41,6 +41,8 @@
CONFIG_BT_HIDP=y
CONFIG_BT_LE=y
+ CONFIG_BT_HCIUART=y
+ CONFIG_BT_HCIUART_H4=y
CONFIG_BT_HCIVHCI=y
CONFIG_CRYPTO_CMAC=y
@@ -52,6 +54,11 @@
CONFIG_UHID=y
+For Audio functionality:
+ CONFIG_SYSVIPC=y
+ CONFIG_SOUND=y
+ CONFIG_SND=y
+ CONFIG_SND_INTEL8X0=y
These options should be installed as .config in the kernel source directory
followed by this command.
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/doc/tester.config
^
|
@@ -34,6 +34,8 @@
CONFIG_BT_AOSPEXT=y
CONFIG_BT_FEATURE_DEBUG=y
+CONFIG_BT_HCIUART=y
+CONFIG_BT_HCIUART_H4=y
CONFIG_BT_HCIVHCI=y
CONFIG_CRYPTO_CMAC=y
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/emulator/btdev.c
^
|
@@ -34,11 +34,13 @@
#include "src/shared/queue.h"
#include "monitor/bt.h"
#include "monitor/msft.h"
+#include "monitor/emulator.h"
#include "btdev.h"
#define AL_SIZE 16
#define RL_SIZE 16
#define CIS_SIZE 3
+#define BIS_SIZE 3
#define has_bredr(btdev) (!((btdev)->features[4] & 0x20))
#define has_le(btdev) (!!((btdev)->features[4] & 0x40))
@@ -46,6 +48,8 @@
#define ACL_HANDLE 42
#define ISO_HANDLE 257
#define SCO_HANDLE 257
+#define SYC_HANDLE 1
+#define INV_HANDLE 0xffff
struct hook {
btdev_hook_func handler;
@@ -62,6 +66,7 @@
uint8_t type;
struct btdev *dev;
struct btdev_conn *link;
+ void *data;
};
struct btdev_al {
@@ -142,6 +147,8 @@
const struct btdev_cmd *cmds;
uint16_t msft_opcode;
const struct btdev_cmd *msft_cmds;
+ uint16_t emu_opcode;
+ const struct btdev_cmd *emu_cmds;
bool aosp_capable;
uint16_t default_link_policy;
@@ -186,12 +193,15 @@
uint8_t le_scan_filter_policy;
uint8_t le_filter_dup;
uint8_t le_adv_enable;
- uint8_t le_periodic_adv_enable;
- uint16_t le_periodic_adv_properties;
- uint16_t le_periodic_min_interval;
- uint16_t le_periodic_max_interval;
- uint8_t le_periodic_data_len;
- uint8_t le_periodic_data[31];
+ uint8_t le_pa_enable;
+ uint16_t le_pa_properties;
+ uint16_t le_pa_min_interval;
+ uint16_t le_pa_max_interval;
+ uint8_t le_pa_data_len;
+ uint8_t le_pa_data[31];
+ struct bt_hci_cmd_le_pa_create_sync pa_sync_cmd;
+ uint16_t le_pa_sync_handle;
+ uint8_t big_handle;
uint8_t le_ltk[16];
struct {
struct bt_hci_cmd_le_set_cig_params params;
@@ -499,6 +509,42 @@
btdev->le_rl_len = len;
}
+static void conn_unlink(struct btdev_conn *conn1, struct btdev_conn *conn2)
+{
+ conn1->link = NULL;
+ conn2->link = NULL;
+}
+
+static void conn_remove(void *data)
+{
+ struct btdev_conn *conn = data;
+
+ if (conn->link) {
+ struct btdev_conn *link = conn->link;
+
+ conn_unlink(conn, conn->link);
+ conn_remove(link);
+ }
+
+ queue_remove(conn->dev->conns, conn);
+
+ free(conn->data);
+ free(conn);
+}
+
+static void le_ext_adv_free(void *data)
+{
+ struct le_ext_adv *ext_adv = data;
+
+ /* Remove to queue */
+ queue_remove(ext_adv->dev->le_ext_adv, ext_adv);
+
+ if (ext_adv->id)
+ timeout_remove(ext_adv->id);
+
+ free(ext_adv);
+}
+
static void btdev_reset(struct btdev *btdev)
{
/* FIXME: include here clearing of all states that should be
@@ -507,12 +553,16 @@
btdev->le_scan_enable = 0x00;
btdev->le_adv_enable = 0x00;
+ btdev->le_pa_enable = 0x00;
al_clear(btdev);
rl_clear(btdev);
btdev->le_al_len = AL_SIZE;
btdev->le_rl_len = RL_SIZE;
+
+ queue_remove_all(btdev->conns, NULL, NULL, conn_remove);
+ queue_remove_all(btdev->le_ext_adv, NULL, NULL, le_ext_adv_free);
}
static int cmd_reset(struct btdev *dev, const void *data, uint8_t len)
@@ -664,28 +714,6 @@
return conn->handle == handle;
}
-static void conn_unlink(struct btdev_conn *conn1, struct btdev_conn *conn2)
-{
- conn1->link = NULL;
- conn2->link = NULL;
-}
-
-static void conn_remove(void *data)
-{
- struct btdev_conn *conn = data;
-
- if (conn->link) {
- struct btdev_conn *link = conn->link;
-
- conn_unlink(conn, conn->link);
- conn_remove(link);
- }
-
- queue_remove(conn->dev->conns, conn);
-
- free(conn);
-}
-
static void disconnect_complete(struct btdev *dev, uint16_t handle,
uint8_t status, uint8_t reason)
{
@@ -1114,9 +1142,66 @@
return conn_link(acl->dev, acl->link->dev, handle, HCI_ISODATA_PKT);
}
-static struct btdev_conn *conn_add_bis(struct btdev *dev, uint16_t handle)
+static struct btdev_conn *conn_add_bis(struct btdev *dev, uint16_t handle,
+ const struct bt_hci_bis *bis)
{
- return conn_new(dev, handle, HCI_ISODATA_PKT);
+ struct btdev_conn *conn;
+
+ conn = conn_new(dev, handle, HCI_ISODATA_PKT);
+ if (!conn)
+ return conn;
+
+ conn->data = util_memdup(bis, sizeof(*bis));
+
+ return conn;
+}
+
+static struct btdev_conn *find_bis_index(const struct btdev *remote,
+ uint8_t index)
+{
+ struct btdev_conn *conn;
+ const struct queue_entry *entry;
+
+ for (entry = queue_get_entries(remote->conns); entry;
+ entry = entry->next) {
+ conn = entry->data;
+
+ /* Skip if not a broadcast */
+ if (conn->type != HCI_ISODATA_PKT || conn->link)
+ continue;
+
+ if (!index)
+ return conn;
+
+ index--;
+ }
+
+ return NULL;
+}
+
+static struct btdev_conn *conn_link_bis(struct btdev *dev, struct btdev *remote,
+ uint8_t index)
+{
+ struct btdev_conn *conn;
+ struct btdev_conn *bis;
+
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/emulator/btdev.h
^
|
@@ -102,3 +102,4 @@
int btdev_set_msft_opcode(struct btdev *btdev, uint16_t opcode);
int btdev_set_aosp_capable(struct btdev *btdev, bool enable);
+int btdev_set_emu_opcode(struct btdev *btdev, uint16_t opcode);
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/emulator/bthost.c
^
|
@@ -37,6 +37,9 @@
#define acl_handle(h) (h & 0x0fff)
#define acl_flags(h) (h >> 12)
+#define iso_flags_pb(f) (f & 0x0003)
+#define iso_data_len_pack(h, f) ((uint16_t) ((h) | ((f) << 14)))
+
#define L2CAP_FEAT_FIXED_CHAN 0x00000080
#define L2CAP_FC_SIG_BREDR 0x02
#define L2CAP_FC_SMP_BREDR 0x80
@@ -131,6 +134,11 @@
struct rfcomm_chan_hook *next;
};
+struct iso_hook {
+ bthost_cid_hook_func_t func;
+ void *user_data;
+};
+
struct btconn {
uint16_t handle;
uint8_t bdaddr[6];
@@ -142,8 +150,12 @@
struct rcconn *rcconns;
struct cid_hook *cid_hooks;
struct rfcomm_chan_hook *rfcomm_chan_hooks;
+ struct iso_hook *iso_hook;
struct btconn *next;
void *smp_data;
+ uint16_t recv_len;
+ uint16_t data_len;
+ void *recv_data;
};
struct l2conn {
@@ -211,6 +223,8 @@
void *cmd_complete_data;
bthost_new_conn_cb new_conn_cb;
void *new_conn_data;
+ bthost_new_conn_cb new_iso_cb;
+ void *new_iso_data;
struct rfcomm_connection_data *rfcomm_conn_data;
struct l2cap_conn_cb_data *new_l2cap_conn_data;
struct rfcomm_conn_cb_data *new_rfcomm_conn_data;
@@ -292,6 +306,8 @@
free(hook);
}
+ free(conn->iso_hook);
+ free(conn->recv_data);
free(conn);
}
@@ -659,6 +675,28 @@
conn->cid_hooks = hook;
}
+void bthost_add_iso_hook(struct bthost *bthost, uint16_t handle,
+ bthost_cid_hook_func_t func, void *user_data)
+{
+ struct iso_hook *hook;
+ struct btconn *conn;
+
+ conn = bthost_find_conn(bthost, handle);
+ if (!conn || conn->iso_hook)
+ return;
+
+ hook = malloc(sizeof(*hook));
+ if (!hook)
+ return;
+
+ memset(hook, 0, sizeof(*hook));
+
+ hook->func = func;
+ hook->user_data = user_data;
+
+ conn->iso_hook = hook;
+}
+
void bthost_send_cid(struct bthost *bthost, uint16_t handle, uint16_t cid,
const void *data, uint16_t len)
{
@@ -683,6 +721,52 @@
send_iov(bthost, handle, cid, iov, iovcnt);
}
+static void send_iso(struct bthost *bthost, uint16_t handle,
+ const struct iovec *iov, int iovcnt)
+{
+ struct bt_hci_iso_hdr iso_hdr;
+ struct bt_hci_iso_data_start data_hdr;
+ uint8_t pkt = BT_H4_ISO_PKT;
+ struct iovec pdu[3 + iovcnt];
+ int i, len = 0;
+ static uint16_t sn;
+
+ for (i = 0; i < iovcnt; i++) {
+ pdu[3 + i].iov_base = iov[i].iov_base;
+ pdu[3 + i].iov_len = iov[i].iov_len;
+ len += iov[i].iov_len;
+ }
+
+ pdu[0].iov_base = &pkt;
+ pdu[0].iov_len = sizeof(pkt);
+
+ iso_hdr.handle = acl_handle_pack(handle, 0x02);
+ iso_hdr.dlen = cpu_to_le16(len + sizeof(data_hdr));
+
+ pdu[1].iov_base = &iso_hdr;
+ pdu[1].iov_len = sizeof(iso_hdr);
+
+ data_hdr.sn = cpu_to_le16(sn++);
+ data_hdr.slen = cpu_to_le16(iso_data_len_pack(len, 0));
+
+ pdu[2].iov_base = &data_hdr;
+ pdu[2].iov_len = sizeof(data_hdr);
+
+ send_packet(bthost, pdu, 3 + iovcnt);
+}
+
+void bthost_send_iso(struct bthost *bthost, uint16_t handle,
+ const struct iovec *iov, int iovcnt)
+{
+ struct btconn *conn;
+
+ conn = bthost_find_conn(bthost, handle);
+ if (!conn)
+ return;
+
+ send_iso(bthost, handle, iov, iovcnt);
+}
+
bool bthost_l2cap_req(struct bthost *bthost, uint16_t handle, uint8_t code,
const void *data, uint16_t len,
bthost_l2cap_rsp_cb cb, void *user_data)
@@ -922,6 +1006,10 @@
break;
case BT_HCI_CMD_LE_SET_EXT_ADV_ENABLE:
break;
+ case BT_HCI_CMD_LE_SET_PA_PARAMS:
+ break;
+ case BT_HCI_CMD_LE_SET_PA_ENABLE:
+ break;
default:
bthost_debug(bthost, "Unhandled cmd_complete opcode 0x%04x",
opcode);
@@ -1333,6 +1421,40 @@
sizeof(cp));
}
+static void init_iso(struct bthost *bthost, uint16_t handle,
+ const uint8_t *bdaddr, uint8_t addr_type)
+{
+ struct btconn *conn;
+
+ bthost_debug(bthost, "ISO handle 0x%4.4x", handle);
+
+ conn = malloc(sizeof(*conn));
+ if (!conn)
+ return;
+
+ memset(conn, 0, sizeof(*conn));
+ conn->handle = handle;
+ memcpy(conn->bdaddr, bdaddr, 6);
+ conn->addr_type = addr_type;
+
+ conn->next = bthost->conns;
+ bthost->conns = conn;
+
+ if (bthost->new_iso_cb)
+ bthost->new_iso_cb(handle, bthost->new_iso_data);
+}
+
+static void evt_le_cis_established(struct bthost *bthost, const void *data,
+ uint8_t size)
+{
+ const struct bt_hci_evt_le_cis_established *ev = data;
+
+ if (ev->status)
+ return;
+
+ init_iso(bthost, ev->conn_handle, BDADDR_ANY->b, BDADDR_LE_PUBLIC);
+}
+
static void evt_le_cis_req(struct bthost *bthost, const void *data, uint8_t len)
{
const struct bt_hci_evt_le_cis_req *ev = data;
@@ -1380,6 +1502,38 @@
}
}
+static void evt_le_big_complete(struct bthost *bthost, const void *data,
+ uint8_t size)
+{
+ const struct bt_hci_evt_le_big_complete *ev = data;
+ int i;
+
+ if (ev->status)
+ return;
+
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/emulator/bthost.h
^
|
@@ -47,6 +47,9 @@
void bthost_set_connect_cb(struct bthost *bthost, bthost_new_conn_cb cb,
void *user_data);
+void bthost_set_iso_cb(struct bthost *bthost, bthost_new_conn_cb cb,
+ void *user_data);
+
void bthost_hci_connect(struct bthost *bthost, const uint8_t *bdaddr,
uint8_t addr_type);
@@ -62,10 +65,18 @@
void bthost_add_cid_hook(struct bthost *bthost, uint16_t handle, uint16_t cid,
bthost_cid_hook_func_t func, void *user_data);
+typedef void (*bthost_iso_hook_func_t)(const void *data, uint16_t len,
+ void *user_data);
+
+void bthost_add_iso_hook(struct bthost *bthost, uint16_t handle,
+ bthost_iso_hook_func_t func, void *user_data);
+
void bthost_send_cid(struct bthost *bthost, uint16_t handle, uint16_t cid,
const void *data, uint16_t len);
void bthost_send_cid_v(struct bthost *bthost, uint16_t handle, uint16_t cid,
const struct iovec *iov, int iovcnt);
+void bthost_send_iso(struct bthost *bthost, uint16_t handle,
+ const struct iovec *iov, int iovcnt);
typedef void (*bthost_l2cap_rsp_cb) (uint8_t code, const void *data,
uint16_t len, void *user_data);
@@ -84,8 +95,17 @@
uint8_t len);
void bthost_set_ext_adv_params(struct bthost *bthost);
void bthost_set_ext_adv_enable(struct bthost *bthost, uint8_t enable);
+void bthost_set_pa_params(struct bthost *bthost);
+void bthost_set_pa_enable(struct bthost *bthost, uint8_t enable);
+void bthost_create_big(struct bthost *bthost, uint8_t num_bis);
bool bthost_search_ext_adv_addr(struct bthost *bthost, const uint8_t *addr);
+void bthost_set_cig_params(struct bthost *bthost, uint8_t cig_id,
+ uint8_t cis_id);
+void bthost_create_cis(struct bthost *bthost, uint16_t cis_handle,
+ uint16_t acl_handle);
+
+
void bthost_set_scan_params(struct bthost *bthost, uint8_t scan_type,
uint8_t addr_type, uint8_t filter_policy);
void bthost_set_scan_enable(struct bthost *bthost, uint8_t enable);
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/emulator/hciemu.c
^
|
@@ -190,6 +190,7 @@
case BT_H4_CMD_PKT:
case BT_H4_ACL_PKT:
case BT_H4_SCO_PKT:
+ case BT_H4_ISO_PKT:
btdev_receive_h4(btdev, buf, len);
break;
}
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/emulator/le.c
^
|
@@ -20,7 +20,6 @@
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/uio.h>
-#include <sys/random.h>
#include <time.h>
#include "lib/bluetooth.h"
@@ -509,7 +508,7 @@
/* The advertising delay is a pseudo-random value with a range
* of 0 ms to 10 ms generated for each advertising event.
*/
- if (getrandom(&val, sizeof(val), 0) < 0) {
+ if (util_getrandom(&val, sizeof(val), 0) < 0) {
/* If it fails to get the random number, use a static value */
val = 5;
}
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/emulator/main.c
^
|
@@ -193,6 +193,7 @@
if (debug_enabled)
vhci_set_debug(vhci, vhci_debug, UINT_TO_PTR(i), NULL);
+ vhci_set_emu_opcode(vhci, 0xfc10);
vhci_set_msft_opcode(vhci, 0xfc1e);
}
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/emulator/phy.c
^
|
@@ -19,7 +19,6 @@
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
-#include <sys/random.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <time.h>
@@ -174,7 +173,7 @@
mainloop_add_fd(phy->rx_fd, EPOLLIN, phy_rx_callback, phy, NULL);
if (!get_random_bytes(&phy->id, sizeof(phy->id))) {
- if (getrandom(&phy->id, sizeof(phy->id), 0) < 0) {
+ if (util_getrandom(&phy->id, sizeof(phy->id), 0) < 0) {
mainloop_remove_fd(phy->rx_fd);
close(phy->tx_fd);
close(phy->rx_fd);
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/emulator/vhci.c
^
|
@@ -252,3 +252,8 @@
return vhci_debugfs_write(vhci, "aosp_capable", &val, sizeof(val));
}
+
+int vhci_set_emu_opcode(struct vhci *vhci, uint16_t opcode)
+{
+ return btdev_set_emu_opcode(vhci->btdev, opcode);
+}
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/emulator/vhci.h
^
|
@@ -27,3 +27,4 @@
int vhci_set_force_wakeup(struct vhci *vhci, bool enable);
int vhci_set_msft_opcode(struct vhci *vhci, uint16_t opcode);
int vhci_set_aosp_capable(struct vhci *vhci, bool enable);
+int vhci_set_emu_opcode(struct vhci *vhci, uint16_t opcode);
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/gdbus/object.c
^
|
@@ -565,6 +565,12 @@
if (root == NULL || data == root)
return;
+ /* Emit InterfacesAdded on the parent first so it appears first on the
+ * bus as child objects may point to it.
+ */
+ if (data->parent && data->parent->added)
+ emit_interfaces_added(data->parent);
+
signal = dbus_message_new_signal(root->path,
DBUS_INTERFACE_OBJECT_MANAGER,
"InterfacesAdded");
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/gobex/gobex-packet.c
^
|
@@ -17,6 +17,7 @@
#include "gobex-defs.h"
#include "gobex-packet.h"
#include "gobex-debug.h"
+#include "src/shared/util.h"
#define FINAL_BIT 0x80
@@ -201,7 +202,7 @@
switch (data_policy) {
case G_OBEX_DATA_COPY:
- pkt->data.buf = g_memdup(data, len);
+ pkt->data.buf = util_memdup(data, len);
break;
case G_OBEX_DATA_REF:
pkt->data.buf_ref = data;
@@ -259,7 +260,7 @@
switch (pkt->data_policy) {
case G_OBEX_DATA_INHERIT:
case G_OBEX_DATA_COPY:
- g_free(pkt->data.buf);
+ free(pkt->data.buf);
break;
case G_OBEX_DATA_REF:
break;
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/gobex/gobex.c
^
|
@@ -419,6 +419,8 @@
gpointer user_data)
{
GObex *obex = user_data;
+ struct pending_pkt *p = NULL;
+ GError *err = NULL;
if (cond & G_IO_NVAL)
return FALSE;
@@ -427,9 +429,9 @@
goto stop_tx;
if (obex->tx_data == 0) {
- struct pending_pkt *p = g_queue_pop_head(obex->tx_queue);
ssize_t len;
+ p = g_queue_pop_head(obex->tx_queue);
if (p == NULL)
goto stop_tx;
@@ -469,6 +471,8 @@
check_srm_final(obex,
obex->tx_buf[0] & ~FINAL_BIT);
pending_pkt_free(p);
+ /* g_free() doesn't set the pointer to NULL */
+ p = NULL;
}
obex->tx_data = len;
@@ -480,8 +484,19 @@
return FALSE;
}
- if (!obex->write(obex, NULL))
+ if (!obex->write(obex, &err)) {
+ g_obex_debug(G_OBEX_DEBUG_ERROR, "%s", err->message);
+
+ if (p) {
+ if (p->rsp_func)
+ p->rsp_func(obex, err, NULL, p->rsp_data);
+
+ pending_pkt_free(p);
+ }
+
+ g_error_free(err);
goto stop_tx;
+ }
done:
if (obex->tx_data > 0 || g_queue_get_length(obex->tx_queue) > 0)
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/lib/bluetooth.h
^
|
@@ -37,6 +37,7 @@
#define BTPROTO_CMTP 5
#define BTPROTO_HIDP 6
#define BTPROTO_AVDTP 7
+#define BTPROTO_ISO 8
#define SOL_HCI 0
#define SOL_L2CAP 6
@@ -140,7 +141,39 @@
#define BT_SCM_PKT_STATUS 0x03
-#define BT_CODEC 19
+#define BT_ISO_QOS 17
+
+#define BT_ISO_QOS_CIG_UNSET 0xff
+#define BT_ISO_QOS_CIS_UNSET 0xff
+
+struct bt_iso_io_qos {
+ uint32_t interval;
+ uint16_t latency;
+ uint16_t sdu;
+ uint8_t phy;
+ uint8_t rtn;
+};
+
+struct bt_iso_qos {
+ union {
+ uint8_t cig;
+ uint8_t big;
+ };
+ union {
+ uint8_t cis;
+ uint8_t bis;
+ };
+ union {
+ uint8_t sca;
+ uint8_t sync_interval;
+ };
+ uint8_t packing;
+ uint8_t framing;
+ struct bt_iso_io_qos in;
+ struct bt_iso_io_qos out;
+};
+
+#define BT_CODEC 19
struct bt_codec {
uint8_t id;
uint16_t cid;
@@ -158,6 +191,7 @@
struct bt_codec codecs[];
} __attribute__((packed));
+
/* Connection and socket states */
enum {
BT_CONNECTED = 1, /* Equal to TCP_ESTABLISHED to make net code happy */
@@ -171,6 +205,8 @@
BT_CLOSED
};
+#define BT_ISO_BASE 20
+
/* Byte order conversions */
#if __BYTE_ORDER == __LITTLE_ENDIAN
#define htobs(d) (d)
@@ -378,6 +414,10 @@
const char *bt_compidtostr(int id);
typedef struct {
+ uint8_t data[3];
+} uint24_t;
+
+typedef struct {
uint8_t data[16];
} uint128_t;
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/lib/hci.c
^
|
@@ -323,7 +323,7 @@
int ret = hci_str2bit(link_mode_map, str, val);
/* Deprecated name. Kept for compatibility. */
- if (strcasestr(str, "MASTER")) {
+ if (!!str && strcasestr(str, "MASTER")) {
ret = 1;
*val |= HCI_LM_MASTER;
}
|
[-]
[+]
|
Added |
_service:tar_git:bluez5-5.65+git1.tar.gz/lib/iso.h
^
|
@@ -0,0 +1,42 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2022 Intel Corporation.
+ *
+ */
+
+#ifndef __ISO_H
+#define __ISO_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* ISO defaults */
+#define ISO_DEFAULT_MTU 251
+#define ISO_MAX_NUM_BIS 0x1f
+
+/* ISO socket broadcast address */
+struct sockaddr_iso_bc {
+ bdaddr_t bc_bdaddr;
+ uint8_t bc_bdaddr_type;
+ uint8_t bc_sid;
+ uint8_t bc_num_bis;
+ uint8_t bc_bis[ISO_MAX_NUM_BIS];
+};
+
+/* ISO socket address */
+struct sockaddr_iso {
+ sa_family_t iso_family;
+ bdaddr_t iso_bdaddr;
+ uint8_t iso_bdaddr_type;
+ struct sockaddr_iso_bc iso_bc[];
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __ISO_H */
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/lib/mgmt.h
^
|
@@ -511,6 +511,9 @@
#define MGMT_ADV_PARAM_TX_POWER (1 << 15)
#define MGMT_ADV_PARAM_SCAN_RSP (1 << 16)
+#define MGMT_ADV_FLAG_SEC_MASK (MGMT_ADV_FLAG_SEC_1M | MGMT_ADV_FLAG_SEC_2M | \
+ MGMT_ADV_FLAG_SEC_CODED)
+
#define MGMT_OP_REMOVE_ADVERTISING 0x003F
struct mgmt_cp_remove_advertising {
uint8_t instance;
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/lib/uuid.c
^
|
@@ -251,6 +251,9 @@
int bt_string_to_uuid(bt_uuid_t *uuid, const char *string)
{
+ if (!string)
+ return -EINVAL;
+
if (is_base_uuid128(string))
return bt_string_to_uuid16(uuid, string + 4);
else if (is_uuid128(string))
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/mesh/appkey.c
^
|
@@ -139,11 +139,15 @@
key->net_idx = net_idx;
key->app_idx = app_idx;
- if (key_value && !set_key(key, app_idx, key_value, false))
+ if (key_value && !set_key(key, app_idx, key_value, false)) {
+ appkey_key_free(key);
return false;
+ }
- if (new_key_value && !set_key(key, app_idx, new_key_value, true))
+ if (new_key_value && !set_key(key, app_idx, new_key_value, true)) {
+ appkey_key_free(key);
return false;
+ }
l_queue_push_tail(app_keys, key);
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/mesh/appkey.h
^
|
@@ -18,7 +18,7 @@
void appkey_key_free(void *data);
void appkey_finalize(struct mesh_net *net, uint16_t net_idx);
const uint8_t *appkey_get_key(struct mesh_net *net, uint16_t app_idx,
- uint8_t *key_id);
+ uint8_t *key_aid);
int appkey_get_key_idx(struct mesh_app_key *app_key,
const uint8_t **key, uint8_t *key_aid,
const uint8_t **new_key, uint8_t *new_key_aid);
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/mesh/crypto.c
^
|
@@ -553,8 +553,11 @@
n = 9;
if (!ctl) {
- hdr = segmented << SEG_HDR_SHIFT;
+ uint32_t tmp = segmented ? 0x1 : 0;
+
+ hdr = tmp << SEG_HDR_SHIFT;
hdr |= (key_aid & KEY_ID_MASK) << KEY_HDR_SHIFT;
+
if (segmented) {
hdr |= szmic << SZMIC_HDR_SHIFT;
hdr |= (seqZero & SEQ_ZERO_MASK) << SEQ_ZERO_HDR_SHIFT;
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/mesh/friend.c
^
|
@@ -59,7 +59,7 @@
{
struct mesh_friend *neg = user_data;
uint16_t net_idx = neg->net_idx;
- uint32_t key_id, seq;
+ uint32_t net_key_id, seq;
uint8_t msg[8];
uint16_t n = 0;
bool res;
@@ -67,11 +67,11 @@
l_timeout_remove(timeout);
/* Create key Set for this offer */
- res = mesh_net_get_key(neg->net, false, net_idx, &key_id);
+ res = mesh_net_get_key(neg->net, false, net_idx, &net_key_id);
if (!res)
goto cleanup;
- neg->net_key_cur = net_key_frnd_add(key_id, neg->lp_addr,
+ neg->net_key_cur = net_key_frnd_add(net_key_id, neg->lp_addr,
mesh_net_get_address(neg->net),
neg->lp_cnt, counter);
if (!neg->net_key_cur)
@@ -88,7 +88,7 @@
n += 2;
seq = mesh_net_next_seq_num(neg->net);
print_packet("Tx-NET_OP_FRND_OFFER", msg, n);
- mesh_net_transport_send(neg->net, key_id, 0,
+ mesh_net_transport_send(neg->net, net_key_id, 0,
mesh_net_get_iv_index(neg->net), 0,
seq, 0, neg->lp_addr,
msg, n);
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/mesh/keyring.c
^
|
@@ -39,22 +39,25 @@
{
const char *node_path;
char fname[PATH_MAX];
+ int ret;
if (!node)
return -1;
node_path = node_get_storage_dir(node);
- if (strlen(node_path) + strlen(key_dir) + 1 + 3 >= PATH_MAX)
- return -1;
-
if (flags & O_CREAT) {
- snprintf(fname, PATH_MAX, "%s%s", node_path, key_dir);
+ ret = snprintf(fname, PATH_MAX, "%s%s", node_path, key_dir);
+ if (ret < 0)
+ return -1;
+
if (mkdir(fname, 0755) != 0 && errno != EEXIST)
l_error("Failed to create dir(%d): %s", errno, fname);
}
- snprintf(fname, PATH_MAX, "%s%s/%3.3x", node_path, key_dir, idx);
+ ret = snprintf(fname, PATH_MAX, "%s%s/%3.3x", node_path, key_dir, idx);
+ if (ret < 0)
+ return -1;
if (flags & O_CREAT)
return open(fname, flags, 0600);
@@ -152,7 +155,7 @@
const char *node_path;
char key_dir[PATH_MAX];
DIR *dir;
- int dir_fd;
+ int ret, dir_fd;
struct dirent *entry;
if (!node)
@@ -160,10 +163,10 @@
node_path = node_get_storage_dir(node);
- if (strlen(node_path) + strlen(app_key_dir) + 1 >= PATH_MAX)
+ ret = snprintf(key_dir, PATH_MAX, "%s%s", node_path, app_key_dir);
+ if (ret < 0)
return false;
- snprintf(key_dir, PATH_MAX, "%s%s", node_path, app_key_dir);
dir = opendir(key_dir);
if (!dir) {
if (errno == ENOENT)
@@ -192,7 +195,7 @@
const char *node_path;
char key_file[PATH_MAX];
bool result = true;
- int fd, i;
+ int ret, fd, i;
if (!IS_UNICAST_RANGE(unicast, count))
return false;
@@ -202,17 +205,19 @@
node_path = node_get_storage_dir(node);
- if (strlen(node_path) + strlen(dev_key_dir) + 1 + 4 >= PATH_MAX)
+ ret = snprintf(key_file, PATH_MAX, "%s%s", node_path, dev_key_dir);
+ if (ret < 0)
return false;
- snprintf(key_file, PATH_MAX, "%s%s", node_path, dev_key_dir);
-
- if (mkdir(key_file, 0755) != 0)
+ if (mkdir(key_file, 0755) != 0 && errno != EEXIST)
l_error("Failed to create dir(%d): %s", errno, key_file);
for (i = 0; i < count; i++) {
- snprintf(key_file, PATH_MAX, "%s%s/%4.4x", node_path,
+ ret = snprintf(key_file, PATH_MAX, "%s%s/%4.4x", node_path,
dev_key_dir, unicast + i);
+ if (ret < 0)
+ return false;
+
l_debug("Put Dev Key %s", key_file);
fd = open(key_file, O_WRONLY | O_CREAT | O_TRUNC, 0600);
@@ -267,7 +272,7 @@
const char *node_path;
char key_file[PATH_MAX];
bool result = false;
- int fd;
+ int ret, fd;
if (!IS_UNICAST(unicast))
return false;
@@ -277,8 +282,11 @@
node_path = node_get_storage_dir(node);
- snprintf(key_file, PATH_MAX, "%s%s/%4.4x", node_path, dev_key_dir,
+ ret = snprintf(key_file, PATH_MAX, "%s%s/%4.4x", node_path, dev_key_dir,
unicast);
+ if (ret < 0)
+ return false;
+
fd = open(key_file, O_RDONLY);
if (fd >= 0) {
if (read(fd, dev_key, 16) == 16)
@@ -294,13 +302,17 @@
{
const char *node_path;
char key_file[PATH_MAX];
+ int ret;
if (!node)
return false;
node_path = node_get_storage_dir(node);
- snprintf(key_file, PATH_MAX, "%s%s/%3.3x", node_path, net_key_dir,
+ ret = snprintf(key_file, PATH_MAX, "%s%s/%3.3x", node_path, net_key_dir,
net_idx);
+ if (ret < 0)
+ return false;
+
l_debug("RM Net Key %s", key_file);
remove(key_file);
@@ -314,13 +326,17 @@
{
const char *node_path;
char key_file[PATH_MAX];
+ int ret;
if (!node)
return false;
node_path = node_get_storage_dir(node);
- snprintf(key_file, PATH_MAX, "%s%s/%3.3x", node_path, app_key_dir,
+ ret = snprintf(key_file, PATH_MAX, "%s%s/%3.3x", node_path, app_key_dir,
app_idx);
+ if (ret < 0)
+ return false;
+
l_debug("RM App Key %s", key_file);
remove(key_file);
@@ -332,7 +348,7 @@
{
const char *node_path;
char key_file[PATH_MAX];
- int i;
+ int ret, i;
if (!IS_UNICAST_RANGE(unicast, count))
return false;
@@ -343,8 +359,11 @@
node_path = node_get_storage_dir(node);
for (i = 0; i < count; i++) {
- snprintf(key_file, PATH_MAX, "%s%s/%4.4x", node_path,
+ ret = snprintf(key_file, PATH_MAX, "%s%s/%4.4x", node_path,
dev_key_dir, unicast + i);
+ if (ret < 0)
+ return false;
+
l_debug("RM Dev Key %s", key_file);
remove(key_file);
}
@@ -356,18 +375,16 @@
{
char dir_path[PATH_MAX];
DIR *key_dir;
+ int ret;
- if (strlen(node_path) + strlen(key_dir_name) + 1 >= PATH_MAX)
+ ret = snprintf(dir_path, PATH_MAX, "%s%s", node_path, key_dir_name);
+ if (ret < 0)
return NULL;
- snprintf(dir_path, PATH_MAX, "%s%s", node_path, key_dir_name);
-
key_dir = opendir(dir_path);
- if (!key_dir) {
+ if (!key_dir)
l_error("Failed to open keyring storage directory: %s",
dir_path);
- return NULL;
- }
return key_dir;
}
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/mesh/mesh-config-json.c
^
|
@@ -156,7 +156,7 @@
uint32_t mod_id, bool vendor)
{
json_object *jelements, *jelement, *jmodels;
- int i, num_mods;
+ int i, num_mods, ret;
size_t len;
char buf[9];
@@ -174,13 +174,15 @@
if (!num_mods)
return NULL;
- if (!vendor) {
- snprintf(buf, 5, "%4.4x", (uint16_t)mod_id);
- len = 4;
- } else {
- snprintf(buf, 9, "%8.8x", mod_id);
- len = 8;
- }
+ if (!vendor)
+ ret = snprintf(buf, 5, "%4.4x", (uint16_t)mod_id);
+ else
+ ret = snprintf(buf, 9, "%8.8x", mod_id);
+
+ if (ret < 0)
+ return NULL;
+
+ len = ret;
for (i = 0; i < num_mods; ++i) {
json_object *jmodel, *jvalue;
@@ -818,7 +820,7 @@
uint16_t app_idx)
{
json_object *jnode, *jmodel, *jstring, *jarray = NULL;
- int ele_idx;
+ int ele_idx, ret;
char buf[5];
if (!cfg)
@@ -826,6 +828,10 @@
jnode = cfg->jnode;
+ ret = snprintf(buf, 5, "%4.4x", app_idx);
+ if (ret < 0)
+ return false;
+
ele_idx = get_element_index(jnode, ele_addr);
if (ele_idx < 0)
return false;
@@ -834,8 +840,6 @@
if (!jmodel)
return false;
- snprintf(buf, 5, "%4.4x", app_idx);
-
json_object_object_get_ex(jmodel, "bind", &jarray);
if (jarray && jarray_has_string(jarray, buf, 4))
return true;
@@ -863,7 +867,7 @@
uint16_t app_idx)
{
json_object *jnode, *jmodel, *jarray;
- int ele_idx;
+ int ele_idx, ret;
char buf[5];
if (!cfg)
@@ -871,6 +875,10 @@
jnode = cfg->jnode;
+ ret = snprintf(buf, 5, "%4.4x", app_idx);
+ if (ret < 0)
+ return false;
+
ele_idx = get_element_index(jnode, ele_addr);
if (ele_idx < 0)
return false;
@@ -882,8 +890,6 @@
if (!json_object_object_get_ex(jmodel, "bind", &jarray))
return true;
- snprintf(buf, 5, "%4.4x", app_idx);
-
jarray_string_del(jarray, buf, 4);
if (!json_object_array_length(jarray))
@@ -1415,9 +1421,13 @@
uint16_t value)
{
json_object *jstring;
+ int ret;
char buf[5];
- snprintf(buf, 5, "%4.4x", value);
+ ret = snprintf(buf, 5, "%4.4x", value);
+ if (ret < 0)
+ return false;
+
jstring = json_object_new_string(buf);
if (!jstring)
return false;
@@ -1430,9 +1440,13 @@
static bool write_uint32_hex(json_object *jobj, const char *desc, uint32_t val)
{
json_object *jstring;
+ int ret;
char buf[9];
- snprintf(buf, 9, "%8.8x", val);
+ ret = snprintf(buf, 9, "%8.8x", val);
+ if (ret < 0)
+ return false;
+
jstring = json_object_new_string(buf);
if (!jstring)
return false;
@@ -1716,22 +1730,24 @@
char uuid_buf[33];
char name_buf[PATH_MAX];
struct mesh_config *cfg;
- size_t max_len = strlen(cfgnode_name) + strlen(bak_ext);
+ int ret;
if (!hex2str((uint8_t *) uuid, 16, uuid_buf, sizeof(uuid_buf)))
return NULL;
- snprintf(name_buf, PATH_MAX, "%s/%s", cfgdir_name, uuid_buf);
-
- if (strlen(name_buf) + max_len >= PATH_MAX)
+ ret = snprintf(name_buf, PATH_MAX, "%s/%s", cfgdir_name, uuid_buf);
+ if (ret < 0)
return NULL;
/* Create a new directory and node.json file */
if (mkdir(name_buf, 0755) != 0)
return NULL;
- snprintf(name_buf, PATH_MAX, "%s/%s%s", cfgdir_name, uuid_buf,
+ ret = snprintf(name_buf, PATH_MAX, "%s/%s%s", cfgdir_name, uuid_buf,
cfgnode_name);
+ if (ret < 0)
+ return NULL;
+
l_debug("New node config %s", name_buf);
cfg = create_config(name_buf, uuid, db_node);
@@ -1904,12 +1920,14 @@
static void del_page(json_object *jarray, uint8_t page)
{
char buf[3];
- int i, len;
+ int i, len, ret;
if (!jarray)
return;
- snprintf(buf, 3, "%2.2x", page);
+ ret = snprintf(buf, 3, "%2.2x", page);
+ if (ret < 0)
+ return;
len = json_object_array_length(jarray);
@@ -1931,7 +1949,7 @@
{
json_object *jnode, *jstring, *jarray = NULL;
char *buf;
- int len;
+ int len, ret;
if (!cfg)
return false;
@@ -1942,7 +1960,10 @@
len = (size * 2) + 3;
buf = l_malloc(len);
- snprintf(buf, len, "%2.2x", page);
+ ret = snprintf(buf, len, "%2.2x", page);
+ if (ret < 0)
+ return false;
+
hex2str(data, size, buf + 2, len - 2);
if (jarray && jarray_has_string(jarray, buf, len)) {
@@ -1967,12 +1988,16 @@
uint8_t *data;
char *str;
char old_buf[3];
- int i, len, dlen = 0;
+ int i, len, ret, dlen = 0;
bool status = true;
if (!cfg || old == nw)
return false;
+ ret = snprintf(old_buf, 3, "%2.2x", old);
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/mesh/mesh-io-generic.c
^
|
@@ -725,7 +725,6 @@
{
struct mesh_io_private *pvt = io->pvt;
struct tx_pkt *tx;
- bool sending = false;
if (!info || !data || !len || len > sizeof(tx->pkt))
return false;
@@ -739,23 +738,21 @@
if (info->type == MESH_IO_TIMING_TYPE_POLL_RSP)
l_queue_push_head(pvt->tx_pkts, tx);
else {
- if (pvt->tx)
- sending = true;
- else
- sending = !l_queue_isempty(pvt->tx_pkts);
-
- l_queue_push_tail(pvt->tx_pkts, tx);
-
/*
* If transmitter is idle, send packets at least twice to
* guard against in-line cancelation of HCI command chain.
*/
- if (info->type == MESH_IO_TIMING_TYPE_GENERAL && !sending &&
- tx->info.u.gen.cnt == 1)
+ if (info->type == MESH_IO_TIMING_TYPE_GENERAL &&
+ !pvt->tx &&
+ l_queue_isempty(pvt->tx_pkts) &&
+ tx->info.u.gen.cnt == 1)
tx->info.u.gen.cnt++;
+
+ l_queue_push_tail(pvt->tx_pkts, tx);
}
- if (!sending) {
+ /* If not already sending, schedule the tx worker */
+ if (!pvt->tx) {
l_timeout_remove(pvt->tx_timeout);
pvt->tx_timeout = NULL;
l_idle_oneshot(tx_worker, pvt, NULL);
@@ -810,10 +807,13 @@
static bool find_by_filter(const void *a, const void *b)
{
- const struct pvt_rx_reg *rx_reg = a;
- const uint8_t *filter = b;
+ const struct pvt_rx_reg *rx_reg_old = a;
+ const struct pvt_rx_reg *rx_reg = b;
+
+ if (rx_reg_old->len != rx_reg->len)
+ return false;
- return !memcmp(rx_reg->filter, filter, rx_reg->len);
+ return !memcmp(rx_reg_old->filter, rx_reg->filter, rx_reg->len);
}
static bool recv_register(struct mesh_io *io, const uint8_t *filter,
@@ -821,16 +821,13 @@
{
struct bt_hci_cmd_le_set_scan_enable cmd;
struct mesh_io_private *pvt = io->pvt;
- struct pvt_rx_reg *rx_reg;
+ struct pvt_rx_reg *rx_reg, *rx_reg_old;
bool already_scanning;
bool active = false;
if (!cb || !filter || !len)
return false;
- rx_reg = l_queue_remove_if(pvt->rx_regs, find_by_filter, filter);
-
- l_free(rx_reg);
rx_reg = l_malloc(sizeof(*rx_reg) + len);
memcpy(rx_reg->filter, filter, len);
@@ -838,6 +835,10 @@
rx_reg->cb = cb;
rx_reg->user_data = user_data;
+ rx_reg_old = l_queue_remove_if(pvt->rx_regs, find_by_filter, rx_reg);
+
+ l_free(rx_reg_old);
+
already_scanning = !l_queue_isempty(pvt->rx_regs);
l_queue_push_head(pvt->rx_regs, rx_reg);
@@ -863,14 +864,20 @@
{
struct bt_hci_cmd_le_set_scan_enable cmd = {0, 0};
struct mesh_io_private *pvt = io->pvt;
- struct pvt_rx_reg *rx_reg;
+ struct pvt_rx_reg *rx_reg, *rx_reg_tmp;
bool active = false;
- rx_reg = l_queue_remove_if(pvt->rx_regs, find_by_filter, filter);
+ rx_reg_tmp = l_malloc(sizeof(*rx_reg_tmp) + len);
+ memcpy(&rx_reg_tmp->filter, filter, len);
+ rx_reg_tmp->len = len;
+
+ rx_reg = l_queue_remove_if(pvt->rx_regs, find_by_filter, rx_reg_tmp);
if (rx_reg)
l_free(rx_reg);
+ l_free(rx_reg_tmp);
+
/* Look for any AD types requiring Active Scanning */
if (l_queue_find(pvt->rx_regs, find_active, NULL))
active = true;
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/mesh/mesh-io-unit.c
^
|
@@ -488,24 +488,24 @@
static bool find_by_filter(const void *a, const void *b)
{
- const struct pvt_rx_reg *rx_reg = a;
- const uint8_t *filter = b;
+ const struct pvt_rx_reg *rx_reg_old = a;
+ const struct pvt_rx_reg *rx_reg = b;
- return !memcmp(rx_reg->filter, filter, rx_reg->len);
+ if (rx_reg_old->len != rx_reg->len)
+ return false;
+
+ return !memcmp(rx_reg_old->filter, rx_reg->filter, rx_reg->len);
}
static bool recv_register(struct mesh_io *io, const uint8_t *filter,
uint8_t len, mesh_io_recv_func_t cb, void *user_data)
{
struct mesh_io_private *pvt = io->pvt;
- struct pvt_rx_reg *rx_reg;
+ struct pvt_rx_reg *rx_reg, *rx_reg_old;
if (!cb || !filter || !len)
return false;
- rx_reg = l_queue_remove_if(pvt->rx_regs, find_by_filter, filter);
-
- l_free(rx_reg);
rx_reg = l_malloc(sizeof(*rx_reg) + len);
memcpy(rx_reg->filter, filter, len);
@@ -513,6 +513,10 @@
rx_reg->cb = cb;
rx_reg->user_data = user_data;
+ rx_reg_old = l_queue_remove_if(pvt->rx_regs, find_by_filter, rx_reg);
+
+ l_free(rx_reg_old);
+
l_queue_push_head(pvt->rx_regs, rx_reg);
return true;
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/mesh/net.c
^
|
@@ -195,7 +195,7 @@
uint8_t *out;
size_t out_size;
enum _relay_advice relay_advice;
- uint32_t key_id;
+ uint32_t net_key_id;
uint32_t iv_index;
uint16_t len;
bool seen;
@@ -210,7 +210,7 @@
};
struct net_beacon_data {
- uint32_t key_id;
+ uint32_t net_key_id;
uint32_t ivi;
bool ivu;
bool kr;
@@ -238,19 +238,19 @@
static bool match_key_id(const void *a, const void *b)
{
const struct mesh_subnet *subnet = a;
- uint32_t key_id = L_PTR_TO_UINT(b);
+ uint32_t net_key_id = L_PTR_TO_UINT(b);
- return (key_id == subnet->net_key_cur) ||
- (key_id == subnet->net_key_upd);
+ return (net_key_id == subnet->net_key_cur) ||
+ (net_key_id == subnet->net_key_upd);
}
static bool match_friend_key_id(const void *a, const void *b)
{
const struct mesh_friend *friend = a;
- uint32_t key_id = L_PTR_TO_UINT(b);
+ uint32_t net_key_id = L_PTR_TO_UINT(b);
- return (key_id == friend->net_key_cur) ||
- (key_id == friend->net_key_upd);
+ return (net_key_id == friend->net_key_cur) ||
+ (net_key_id == friend->net_key_upd);
}
static void send_hb_publication(void *data)
@@ -322,9 +322,9 @@
static void frnd_kr_phase1(void *a, void *b)
{
struct mesh_friend *frnd = a;
- uint32_t key_id = L_PTR_TO_UINT(b);
+ uint32_t net_key_id = L_PTR_TO_UINT(b);
- frnd->net_key_upd = net_key_frnd_add(key_id, frnd->lp_addr,
+ frnd->net_key_upd = net_key_frnd_add(net_key_id, frnd->lp_addr,
frnd->net->src_addr, frnd->lp_cnt, frnd->fn_cnt);
}
@@ -918,7 +918,7 @@
}
bool mesh_net_get_key(struct mesh_net *net, bool new_key, uint16_t idx,
- uint32_t *key_id)
+ uint32_t *net_key_id)
{
struct mesh_subnet *subnet;
@@ -931,14 +931,14 @@
return false;
if (!new_key) {
- *key_id = subnet->net_key_cur;
+ *net_key_id = subnet->net_key_cur;
return true;
}
if (!subnet->net_key_upd)
return false;
- *key_id = subnet->net_key_upd;
+ *net_key_id = subnet->net_key_upd;
return true;
}
@@ -1325,7 +1325,6 @@
hdr += (1 << SEGO_HDR_SHIFT);
}
- frnd_msg->u.s12[seg_max].seq = seq;
frnd_msg->cnt_in = seg_max;
frnd_msg->last_len = size % 12;
if (!frnd_msg->last_len)
@@ -1376,7 +1375,7 @@
{
uint32_t hdr = l_get_be32(pkt) &
((SEQ_ZERO_MASK << SEQ_ZERO_HDR_SHIFT) | /* Preserve SeqZero */
- (true << RELAY_HDR_SHIFT)); /* Preserve Relay bit */
+ ((uint32_t) 0x01 << RELAY_HDR_SHIFT)); /* Preserve Relay bit */
uint32_t flags = l_get_be32(pkt + 3);
struct mesh_friend_msg frnd_ack = {
.ctl = true,
@@ -1411,14 +1410,14 @@
expected = 0xffffffff >> (31 - SEG_TOTAL(hdr));
/* Clear Hdr bits that don't apply to Seg ACK */
- hdr &= ~((true << SEG_HDR_SHIFT) |
+ hdr &= ~(((uint32_t) 0x01 << SEG_HDR_SHIFT) |
(OPCODE_MASK << OPCODE_HDR_SHIFT) |
- (true << SZMIC_HDR_SHIFT) |
+ ((uint32_t) 0x01 << SZMIC_HDR_SHIFT) |
(SEG_MASK << SEGO_HDR_SHIFT) |
(SEG_MASK << SEGN_HDR_SHIFT));
hdr |= NET_OP_SEG_ACKNOWLEDGE << OPCODE_HDR_SHIFT;
- hdr |= true << RELAY_HDR_SHIFT;
+ hdr |= (uint32_t) 0x01 << RELAY_HDR_SHIFT;
/* Clear all unexpected bits */
flags &= expected;
@@ -1455,7 +1454,7 @@
hdr |= sar->seqZero << SEQ_ZERO_HDR_SHIFT;
if (is_lpn_friend(net, src))
- hdr |= true << RELAY_HDR_SHIFT;
+ hdr |= (uint32_t) 0x01 << RELAY_HDR_SHIFT;
l_put_be32(hdr, msg);
l_put_be32(flags, msg + 3);
@@ -1727,7 +1726,7 @@
}
if (szmic || size > 15) {
- hdr |= true << SEG_HDR_SHIFT;
+ hdr |= (uint32_t) 0x01 << SEG_HDR_SHIFT;
hdr |= szmic << SZMIC_HDR_SHIFT;
hdr |= (seqZero & SEQ_ZERO_MASK) << SEQ_ZERO_HDR_SHIFT;
hdr |= SEG_MAX(true, size) << SEGN_HDR_SHIFT;
@@ -1764,7 +1763,7 @@
return true;
}
-static uint16_t key_id_to_net_idx(struct mesh_net *net, uint32_t key_id)
+static uint16_t key_id_to_net_idx(struct mesh_net *net, uint32_t net_key_id)
{
struct mesh_subnet *subnet;
struct mesh_friend *friend;
@@ -1773,19 +1772,19 @@
return NET_IDX_INVALID;
subnet = l_queue_find(net->subnets, match_key_id,
- L_UINT_TO_PTR(key_id));
+ L_UINT_TO_PTR(net_key_id));
if (subnet)
return subnet->idx;
friend = l_queue_find(net->friends, match_friend_key_id,
- L_UINT_TO_PTR(key_id));
+ L_UINT_TO_PTR(net_key_id));
if (friend)
return friend->net_idx;
friend = l_queue_find(net->negotiations, match_friend_key_id,
- L_UINT_TO_PTR(key_id));
+ L_UINT_TO_PTR(net_key_id));
if (friend)
return friend->net_idx;
@@ -2029,7 +2028,7 @@
return false;
}
-static bool ctl_received(struct mesh_net *net, uint16_t key_id,
+static bool ctl_received(struct mesh_net *net, uint32_t net_key_id,
uint32_t iv_index, uint8_t ttl,
uint32_t seq,
uint16_t src, uint16_t dst,
@@ -2079,7 +2078,7 @@
return false;
print_packet("Rx-NET_OP_FRND_REQUEST", pkt, len);
- net_idx = key_id_to_net_idx(net, key_id);
+ net_idx = key_id_to_net_idx(net, net_key_id);
friend_request(net, net_idx, src, pkt[0], pkt[1],
l_get_be32(pkt + 1) & 0xffffff,
l_get_be16(pkt + 5), pkt[7],
@@ -2270,13 +2269,13 @@
}
static enum _relay_advice packet_received(void *user_data,
- uint32_t key_id, uint32_t iv_index,
+ uint32_t net_key_id, uint32_t iv_index,
const void *data, uint8_t size, int8_t rssi)
{
struct mesh_net *net = user_data;
const uint8_t *msg = data;
uint8_t app_msg_len;
- uint8_t net_ttl, net_key_id, net_segO, net_segN, net_opcode;
+ uint8_t net_ttl, key_aid, net_segO, net_segN, net_opcode;
uint32_t net_seq, cache_cookie;
uint16_t net_src, net_dst, net_seqZero;
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/mesh/net.h
^
|
@@ -37,7 +37,7 @@
#define SEGMENTED 0x80
#define UNSEGMENTED 0x00
#define SEG_HDR_SHIFT 31
-#define IS_SEGMENTED(hdr) (!!((hdr) & (true << SEG_HDR_SHIFT)))
+#define IS_SEGMENTED(hdr) (!!((hdr) & ((uint32_t) 0x1 << SEG_HDR_SHIFT)))
#define KEY_ID_MASK 0x7f
#define KEY_AID_MASK 0x3f
@@ -45,7 +45,7 @@
#define KEY_AID_SHIFT 0
#define AKF_HDR_SHIFT 30
#define KEY_HDR_SHIFT 24
-#define HAS_APP_KEY(hdr) (!!((hdr) & (true << AKF_HDR_SHIFT)))
+#define HAS_APP_KEY(hdr) (!!((hdr) & ((uint32_t) 0x1 << AKF_HDR_SHIFT)))
#define OPCODE_MASK 0x7f
#define OPCODE_HDR_SHIFT 24
@@ -55,8 +55,8 @@
#define SZMIC_HDR_SHIFT 23
#define SEQ_ZERO_MASK 0x1fff
#define SEQ_ZERO_HDR_SHIFT 10
-#define IS_RELAYED(hdr) (!!((hdr) & (true << RELAY_HDR_SHIFT)))
-#define HAS_MIC64(hdr) (!!((hdr) & (true << SZMIC_HDR_SHIFT)))
+#define IS_RELAYED(hdr) (!!((hdr) & ((uint32_t) 0x1 << RELAY_HDR_SHIFT)))
+#define HAS_MIC64(hdr) (!!((hdr) & ((uint32_t) 0x1 << SZMIC_HDR_SHIFT)))
#define SEG_MASK 0x1f
#define SEGO_HDR_SHIFT 5
@@ -186,31 +186,6 @@
} u;
};
-struct mesh_frnd_pkt {
- uint32_t iv_index;
- uint32_t seq;
- uint16_t src;
- uint16_t dst;
- uint16_t size;
- uint8_t segN;
- uint8_t segO;
- uint8_t ttl;
- uint8_t tc;
- bool szmict;
- union {
- struct {
- uint8_t key_id;
- } m;
- struct {
- uint16_t seq0;
- } a;
- struct {
- uint8_t opcode;
- } c;
- } u;
- uint8_t data[];
-};
-
struct mesh_friend_seg_one {
uint32_t hdr;
uint32_t seq;
@@ -261,7 +236,7 @@
uint16_t mesh_net_get_address(struct mesh_net *net);
bool mesh_net_register_unicast(struct mesh_net *net,
uint16_t unicast, uint8_t num_ele);
-void net_local_beacon(uint32_t key_id, uint8_t *beacon);
+void net_local_beacon(uint32_t net_key_id, uint8_t *beacon);
bool mesh_net_set_beacon_mode(struct mesh_net *net, bool enable);
bool mesh_net_set_proxy_mode(struct mesh_net *net, bool enable);
bool mesh_net_set_relay_mode(struct mesh_net *net, bool enable, uint8_t cnt,
@@ -278,23 +253,23 @@
void mesh_net_get_snb_state(struct mesh_net *net,
uint8_t *flags, uint32_t *iv_index);
bool mesh_net_get_key(struct mesh_net *net, bool new_key, uint16_t idx,
- uint32_t *key_id);
+ uint32_t *net_key_id);
bool mesh_net_attach(struct mesh_net *net, struct mesh_io *io);
struct mesh_io *mesh_net_detach(struct mesh_net *net);
struct l_queue *mesh_net_get_app_keys(struct mesh_net *net);
-void mesh_net_transport_send(struct mesh_net *net, uint32_t key_id,
+void mesh_net_transport_send(struct mesh_net *net, uint32_t net_key_id,
uint16_t net_idx, uint32_t iv_index,
uint8_t ttl, uint32_t seq, uint16_t src,
uint16_t dst, const uint8_t *msg,
uint16_t msg_len);
bool mesh_net_app_send(struct mesh_net *net, bool frnd_cred, uint16_t src,
- uint16_t dst, uint8_t key_id, uint16_t net_idx,
+ uint16_t dst, uint8_t key_aid, uint16_t net_idx,
uint8_t ttl, uint8_t cnt, uint16_t interval,
uint32_t seq, uint32_t iv_index, bool segmented,
bool szmic, const void *msg, uint16_t msg_len);
-void mesh_net_ack_send(struct mesh_net *net, uint32_t key_id,
+void mesh_net_ack_send(struct mesh_net *net, uint32_t net_key_id,
uint32_t iv_index, uint8_t ttl, uint32_t seq,
uint16_t src, uint16_t dst, bool rly,
uint16_t seqZero, uint32_t ack_flags);
@@ -317,7 +292,7 @@
uint8_t transition);
int mesh_net_key_refresh_phase_get(struct mesh_net *net, uint16_t net_idx,
uint8_t *phase);
-void mesh_net_send_seg(struct mesh_net *net, uint32_t key_id,
+void mesh_net_send_seg(struct mesh_net *net, uint32_t net_key_id,
uint32_t iv_index, uint8_t ttl, uint32_t seq,
uint16_t src, uint16_t dst, uint32_t hdr,
const void *seg, uint16_t seg_len);
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/mesh/rpl.c
^
|
@@ -80,7 +80,7 @@
iv_index--;
snprintf(src_file, PATH_MAX, "%s%s/%8.8x/%4.4x", node_path, rpl_dir,
iv_index, src);
- if (remove(src_file) < 0)
+ if (remove(src_file) < 0 && errno != ENOENT)
l_error("Failed to remove(%d): %s", errno, src_file);
return result;
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/monitor/analyze.c
^
|
@@ -161,7 +161,8 @@
break;
}
- conn->tx_pkt_med = conn->tx_bytes / conn->tx_num;
+ if (conn->tx_num > 0)
+ conn->tx_pkt_med = conn->tx_bytes / conn->tx_num;
printf(" Found %s connection with handle %u\n", str, conn->handle);
/* TODO: Store address type */
|
[-]
[+]
|
Added |
_service:tar_git:bluez5-5.65+git1.tar.gz/monitor/att.c
^
|
@@ -0,0 +1,2343 @@
+// SPDX-License-Identifier: LGPL-2.1-or-later
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2011-2014 Intel Corporation
+ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org>
+ *
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <inttypes.h>
+#include <stdbool.h>
+#include <errno.h>
+#include <linux/limits.h>
+
+#include "lib/bluetooth.h"
+#include "lib/uuid.h"
+#include "lib/hci.h"
+#include "lib/hci_lib.h"
+
+#include "src/shared/util.h"
+#include "src/shared/queue.h"
+#include "src/shared/att.h"
+#include "src/shared/gatt-db.h"
+#include "src/textfile.h"
+#include "src/settings.h"
+#include "bt.h"
+#include "packet.h"
+#include "display.h"
+#include "l2cap.h"
+#include "att.h"
+
+static void print_uuid(const char *label, const void *data, uint16_t size)
+{
+ const char *str;
+ char uuidstr[MAX_LEN_UUID_STR];
+
+ switch (size) {
+ case 2:
+ str = bt_uuid16_to_str(get_le16(data));
+ print_field("%s: %s (0x%4.4x)", label, str, get_le16(data));
+ break;
+ case 4:
+ str = bt_uuid32_to_str(get_le32(data));
+ print_field("%s: %s (0x%8.8x)", label, str, get_le32(data));
+ break;
+ case 16:
+ sprintf(uuidstr, "%8.8x-%4.4x-%4.4x-%4.4x-%8.8x%4.4x",
+ get_le32(data + 12), get_le16(data + 10),
+ get_le16(data + 8), get_le16(data + 6),
+ get_le32(data + 2), get_le16(data + 0));
+ str = bt_uuidstr_to_str(uuidstr);
+ print_field("%s: %s (%s)", label, str, uuidstr);
+ break;
+ default:
+ packet_hexdump(data, size);
+ break;
+ }
+}
+
+static void print_handle_range(const char *label, const void *data)
+{
+ print_field("%s: 0x%4.4x-0x%4.4x", label,
+ get_le16(data), get_le16(data + 2));
+}
+
+static void print_data_list(const char *label, uint8_t length,
+ const void *data, uint16_t size)
+{
+ uint8_t count;
+
+ if (length == 0)
+ return;
+
+ count = size / length;
+
+ print_field("%s: %u entr%s", label, count, count == 1 ? "y" : "ies");
+
+ while (size >= length) {
+ print_field("Handle: 0x%4.4x", get_le16(data));
+ print_hex_field("Value", data + 2, length - 2);
+
+ data += length;
+ size -= length;
+ }
+
+ packet_hexdump(data, size);
+}
+
+static void print_attribute_info(uint16_t type, const void *data, uint16_t len)
+{
+ const char *str = bt_uuid16_to_str(type);
+
+ print_field("%s: %s (0x%4.4x)", "Attribute type", str, type);
+
+ switch (type) {
+ case 0x2800: /* Primary Service */
+ case 0x2801: /* Secondary Service */
+ print_uuid(" UUID", data, len);
+ break;
+ case 0x2802: /* Include */
+ if (len < 4) {
+ print_hex_field(" Value", data, len);
+ break;
+ }
+ print_handle_range(" Handle range", data);
+ print_uuid(" UUID", data + 4, len - 4);
+ break;
+ case 0x2803: /* Characteristic */
+ if (len < 3) {
+ print_hex_field(" Value", data, len);
+ break;
+ }
+ print_field(" Properties: 0x%2.2x", *((uint8_t *) data));
+ print_field(" Handle: 0x%2.2x", get_le16(data + 1));
+ print_uuid(" UUID", data + 3, len - 3);
+ break;
+ default:
+ print_hex_field("Value", data, len);
+ break;
+ }
+}
+
+static const char *att_opcode_to_str(uint8_t opcode);
+
+static void att_error_response(const struct l2cap_frame *frame)
+{
+ const struct bt_l2cap_att_error_response *pdu = frame->data;
+ const char *str;
+
+ switch (pdu->error) {
+ case 0x01:
+ str = "Invalid Handle";
+ break;
+ case 0x02:
+ str = "Read Not Permitted";
+ break;
+ case 0x03:
+ str = "Write Not Permitted";
+ break;
+ case 0x04:
+ str = "Invalid PDU";
+ break;
+ case 0x05:
+ str = "Insufficient Authentication";
+ break;
+ case 0x06:
+ str = "Request Not Supported";
+ break;
+ case 0x07:
+ str = "Invalid Offset";
+ break;
+ case 0x08:
+ str = "Insufficient Authorization";
+ break;
+ case 0x09:
+ str = "Prepare Queue Full";
+ break;
+ case 0x0a:
+ str = "Attribute Not Found";
+ break;
+ case 0x0b:
+ str = "Attribute Not Long";
+ break;
+ case 0x0c:
+ str = "Insufficient Encryption Key Size";
+ break;
+ case 0x0d:
+ str = "Invalid Attribute Value Length";
+ break;
+ case 0x0e:
+ str = "Unlikely Error";
+ break;
+ case 0x0f:
+ str = "Insufficient Encryption";
+ break;
+ case 0x10:
+ str = "Unsupported Group Type";
+ break;
+ case 0x11:
+ str = "Insufficient Resources";
+ break;
+ case 0x12:
+ str = "Database Out of Sync";
+ break;
+ case 0x13:
+ str = "Value Not Allowed";
+ break;
+ case 0xfd:
+ str = "CCC Improperly Configured";
|
[-]
[+]
|
Added |
_service:tar_git:bluez5-5.65+git1.tar.gz/monitor/att.h
^
|
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2011-2014 Intel Corporation
+ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org>
+ *
+ *
+ */
+
+#include <stdint.h>
+#include <stdbool.h>
+
+void att_packet(uint16_t index, bool in, uint16_t handle, uint16_t cid,
+ const void *data, uint16_t size);
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/monitor/avctp.c
^
|
@@ -1192,7 +1192,7 @@
for (; num > 0; num--) {
uint32_t attr;
- if (!l2cap_frame_get_le32(frame, &attr))
+ if (!l2cap_frame_get_be32(frame, &attr))
return false;
print_field("%*cAttributeID: 0x%08x (%s)", (indent - 8),
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/monitor/broadcom.c
^
|
@@ -220,23 +220,24 @@
print_field("UART clock: %s (0x%2.2x)", str, clock);
}
-static void null_cmd(const void *data, uint8_t size)
+static void null_cmd(uint16_t index, const void *data, uint8_t size)
{
}
-static void status_rsp(const void *data, uint8_t size)
+static void status_rsp(uint16_t index, const void *data, uint8_t size)
{
uint8_t status = get_u8(data);
print_status(status);
}
-static void write_bd_addr_cmd(const void *data, uint8_t size)
+static void write_bd_addr_cmd(uint16_t index, const void *data, uint8_t size)
{
packet_print_addr("Address", data, 0x00);
}
-static void update_uart_baud_rate_cmd(const void *data, uint8_t size)
+static void update_uart_baud_rate_cmd(uint16_t index, const void *data,
+ uint8_t size)
{
uint16_t enc_rate = get_le16(data);
uint32_t exp_rate = get_le32(data + 2);
@@ -249,7 +250,8 @@
print_field("Explicit baud rate: %u Mbps", exp_rate);
}
-static void write_sco_pcm_int_param_cmd(const void *data, uint8_t size)
+static void write_sco_pcm_int_param_cmd(uint16_t index, const void *data,
+ uint8_t size)
{
uint8_t routing = get_u8(data);
uint8_t rate = get_u8(data + 1);
@@ -264,7 +266,8 @@
print_clock_mode(clock_mode);
}
-static void read_sco_pcm_int_param_rsp(const void *data, uint8_t size)
+static void read_sco_pcm_int_param_rsp(uint16_t index, const void *data,
+ uint8_t size)
{
uint8_t status = get_u8(data);
uint8_t routing = get_u8(data + 1);
@@ -281,7 +284,8 @@
print_clock_mode(clock_mode);
}
-static void set_sleepmode_param_cmd(const void *data, uint8_t size)
+static void set_sleepmode_param_cmd(uint16_t index, const void *data,
+ uint8_t size)
{
uint8_t mode = get_u8(data);
@@ -290,7 +294,8 @@
packet_hexdump(data + 1, size - 1);
}
-static void read_sleepmode_param_rsp(const void *data, uint8_t size)
+static void read_sleepmode_param_rsp(uint16_t index, const void *data,
+ uint8_t size)
{
uint8_t status = get_u8(data);
uint8_t mode = get_u8(data + 1);
@@ -301,7 +306,8 @@
packet_hexdump(data + 2, size - 2);
}
-static void enable_radio_cmd(const void *data, uint8_t size)
+static void enable_radio_cmd(uint16_t index, const void *data,
+ uint8_t size)
{
uint8_t mode = get_u8(data);
const char *str;
@@ -321,7 +327,8 @@
print_field("Mode: %s (0x%2.2x)", str, mode);
}
-static void enable_usb_hid_emulation_cmd(const void *data, uint8_t size)
+static void enable_usb_hid_emulation_cmd(uint16_t index, const void *data,
+ uint8_t size)
{
uint8_t enable = get_u8(data);
const char *str;
@@ -341,7 +348,8 @@
print_field("Enable: %s (0x%2.2x)", str, enable);
}
-static void read_uart_clock_setting_rsp(const void *data, uint8_t size)
+static void read_uart_clock_setting_rsp(uint16_t index, const void *data,
+ uint8_t size)
{
uint8_t status = get_u8(data);
uint8_t clock = get_u8(data + 1);
@@ -350,21 +358,22 @@
print_clock_setting(clock);
}
-static void write_uart_clock_setting_cmd(const void *data, uint8_t size)
+static void write_uart_clock_setting_cmd(uint16_t index, const void *data,
+ uint8_t size)
{
uint8_t clock = get_u8(data);
print_clock_setting(clock);
}
-static void read_raw_rssi_cmd(const void *data, uint8_t size)
+static void read_raw_rssi_cmd(uint16_t index, const void *data, uint8_t size)
{
uint16_t handle = get_le16(data);
print_handle(handle);
}
-static void read_raw_rssi_rsp(const void *data, uint8_t size)
+static void read_raw_rssi_rsp(uint16_t index, const void *data, uint8_t size)
{
uint8_t status = get_u8(data);
uint16_t handle = get_le16(data + 1);
@@ -375,7 +384,7 @@
print_rssi(rssi);
}
-static void write_ram_cmd(const void *data, uint8_t size)
+static void write_ram_cmd(uint16_t index, const void *data, uint8_t size)
{
uint32_t addr = get_le32(data);
@@ -384,7 +393,7 @@
packet_hexdump(data + 4, size - 4);
}
-static void read_ram_cmd(const void *data, uint8_t size)
+static void read_ram_cmd(uint16_t index, const void *data, uint8_t size)
{
uint32_t addr = get_le32(data);
uint8_t length = get_u8(data + 4);
@@ -393,7 +402,7 @@
print_field("Length: %u", length);
}
-static void read_ram_rsp(const void *data, uint8_t size)
+static void read_ram_rsp(uint16_t index, const void *data, uint8_t size)
{
uint8_t status = get_u8(data);
@@ -402,14 +411,14 @@
packet_hexdump(data + 1, size - 1);
}
-static void launch_ram_cmd(const void *data, uint8_t size)
+static void launch_ram_cmd(uint16_t index, const void *data, uint8_t size)
{
uint32_t addr = get_le32(data);
print_field("Address: 0x%8.8x", addr);
}
-static void read_vid_pid_rsp(const void *data, uint8_t size)
+static void read_vid_pid_rsp(uint16_t index, const void *data, uint8_t size)
{
uint8_t status = get_u8(data);
uint16_t vid = get_le16(data + 1);
@@ -419,7 +428,8 @@
print_field("Product: %4.4x:%4.4x", vid, pid);
}
-static void write_high_priority_connection_cmd(const void *data, uint8_t size)
+static void write_high_priority_connection_cmd(uint16_t index, const void *data,
+ uint8_t size)
{
uint16_t handle = get_le16(data);
uint8_t priority = get_u8(data + 2);
@@ -480,7 +490,8 @@
"(0x%16.16" PRIx64 ")", mask);
}
-static void read_controller_features_rsp(const void *data, uint8_t size)
+static void read_controller_features_rsp(uint16_t index, const void *data,
+ uint8_t size)
{
uint8_t status = get_u8(data);
@@ -488,7 +499,8 @@
print_features(data + 1);
}
-static void read_verbose_version_info_rsp(const void *data, uint8_t size)
+static void read_verbose_version_info_rsp(uint16_t index, const void *data,
+ uint8_t size)
{
uint8_t status = get_u8(data);
uint8_t chip_id = get_u8(data + 1);
@@ -517,7 +529,7 @@
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/monitor/bt.h
^
|
@@ -488,6 +488,7 @@
struct bt_hci_acl_hdr {
uint16_t handle;
uint16_t dlen;
+ uint8_t data[];
} __attribute__ ((packed));
struct bt_hci_sco_hdr {
@@ -498,11 +499,13 @@
struct bt_hci_iso_hdr {
uint16_t handle;
uint16_t dlen;
+ uint8_t data[];
} __attribute__ ((packed));
struct bt_hci_iso_data_start {
uint16_t sn;
uint16_t slen;
+ uint8_t data[];
} __attribute__ ((packed));
struct bt_hci_evt_hdr {
@@ -2426,24 +2429,24 @@
#define BT_HCI_CMD_LE_CLEAR_ADV_SETS 0x203d
-#define BT_HCI_CMD_LE_SET_PERIODIC_ADV_PARAMS 0x203e
-struct bt_hci_cmd_le_set_periodic_adv_params {
+#define BT_HCI_CMD_LE_SET_PA_PARAMS 0x203e
+struct bt_hci_cmd_le_set_pa_params {
uint8_t handle;
uint16_t min_interval;
uint16_t max_interval;
uint16_t properties;
} __attribute__ ((packed));
-#define BT_HCI_CMD_LE_SET_PERIODIC_ADV_DATA 0x203f
-struct bt_hci_cmd_le_set_periodic_adv_data {
+#define BT_HCI_CMD_LE_SET_PA_DATA 0x203f
+struct bt_hci_cmd_le_set_pa_data {
uint8_t handle;
uint8_t operation;
uint8_t data_len;
uint8_t data[0];
} __attribute__ ((packed));
-#define BT_HCI_CMD_LE_SET_PERIODIC_ADV_ENABLE 0x2040
-struct bt_hci_cmd_le_set_periodic_adv_enable {
+#define BT_HCI_CMD_LE_SET_PA_ENABLE 0x2040
+struct bt_hci_cmd_le_set_pa_enable {
uint8_t enable;
uint8_t handle;
} __attribute__ ((packed));
@@ -2489,8 +2492,8 @@
uint16_t max_length;
} __attribute__ ((packed));
-#define BT_HCI_CMD_LE_PERIODIC_ADV_CREATE_SYNC 0x2044
-struct bt_hci_cmd_le_periodic_adv_create_sync {
+#define BT_HCI_CMD_LE_PA_CREATE_SYNC 0x2044
+struct bt_hci_cmd_le_pa_create_sync {
uint8_t options;
uint8_t sid;
uint8_t addr_type;
@@ -2500,31 +2503,31 @@
uint8_t sync_cte_type;
} __attribute__ ((packed));
-#define BT_HCI_CMD_LE_PERIODIC_ADV_CREATE_SYNC_CANCEL 0x2045
+#define BT_HCI_CMD_LE_PA_CREATE_SYNC_CANCEL 0x2045
-#define BT_HCI_CMD_LE_PERIODIC_ADV_TERM_SYNC 0x2046
-struct bt_hci_cmd_le_periodic_adv_term_sync {
+#define BT_HCI_CMD_LE_PA_TERM_SYNC 0x2046
+struct bt_hci_cmd_le_pa_term_sync {
uint16_t sync_handle;
} __attribute__ ((packed));
-#define BT_HCI_CMD_LE_ADD_DEV_PERIODIC_ADV_LIST 0x2047
-struct bt_hci_cmd_le_add_dev_periodic_adv_list {
+#define BT_HCI_CMD_LE_ADD_DEV_PA_LIST 0x2047
+struct bt_hci_cmd_le_add_dev_pa_list {
uint8_t addr_type;
uint8_t addr[6];
uint8_t sid;
} __attribute__ ((packed));
-#define BT_HCI_CMD_LE_REMOVE_DEV_PERIODIC_ADV_LIST 0x2048
-struct bt_hci_cmd_le_remove_dev_periodic_adv_list {
+#define BT_HCI_CMD_LE_REMOVE_DEV_PA_LIST 0x2048
+struct bt_hci_cmd_le_remove_dev_pa_list {
uint8_t addr_type;
uint8_t addr[6];
uint8_t sid;
} __attribute__ ((packed));
-#define BT_HCI_CMD_LE_CLEAR_PERIODIC_ADV_LIST 0x2049
+#define BT_HCI_CMD_LE_CLEAR_PA_LIST 0x2049
-#define BT_HCI_CMD_LE_READ_PERIODIC_ADV_LIST_SIZE 0x204a
-struct bt_hci_rsp_le_read_dev_periodic_adv_list_size {
+#define BT_HCI_CMD_LE_READ_PA_LIST_SIZE 0x204a
+struct bt_hci_rsp_le_read_dev_pa_list_size {
uint8_t status;
uint8_t list_size;
} __attribute__ ((packed));
@@ -2581,28 +2584,28 @@
uint8_t antenna_ids[0];
} __attribute__ ((packed));
-#define BT_HCI_CMD_SET_PERIODIC_ADV_REC_ENABLE 0x2059
-struct bt_hci_cmd_set_periodic_adv_rec_enable {
+#define BT_HCI_CMD_SET_PA_REC_ENABLE 0x2059
+struct bt_hci_cmd_set_pa_rec_enable {
uint16_t sync_handle;
uint8_t enable;
} __attribute__ ((packed));
-#define BT_HCI_CMD_PERIODIC_SYNC_TRANS 0x205a
+#define BT_HCI_CMD_PERIODIC_SYNC_TRANS 0x205a
struct bt_hci_cmd_periodic_sync_trans {
uint16_t handle;
uint16_t service_data;
uint16_t sync_handle;
} __attribute__ ((packed));
-#define BT_HCI_CMD_PERIODIC_ADV_SET_INFO_TRANS 0x205b
-struct bt_hci_cmd_periodic_adv_set_info_trans {
+#define BT_HCI_CMD_PA_SET_INFO_TRANS 0x205b
+struct bt_hci_cmd_pa_set_info_trans {
uint16_t handle;
uint16_t service_data;
uint16_t adv_handle;
} __attribute__ ((packed));
-#define BT_HCI_CMD_PERIODIC_ADV_SYNC_TRANS_PARAMS 0x205c
-struct bt_hci_cmd_periodic_adv_sync_trans_params {
+#define BT_HCI_CMD_PA_SYNC_TRANS_PARAMS 0x205c
+struct bt_hci_cmd_pa_sync_trans_params {
uint16_t handle;
uint8_t mode;
uint16_t skip;
@@ -2610,8 +2613,8 @@
uint8_t cte_type;
} __attribute__ ((packed));
-#define BT_HCI_CMD_DEFAULT_PERIODIC_ADV_SYNC_TRANS_PARAMS 0x205d
-struct bt_hci_cmd_default_periodic_adv_sync_trans_params {
+#define BT_HCI_CMD_DEFAULT_PA_SYNC_TRANS_PARAMS 0x205d
+struct bt_hci_cmd_default_pa_sync_trans_params {
uint8_t mode;
uint16_t skip;
uint16_t sync_timeout;
@@ -2757,7 +2760,7 @@
uint8_t handle;
uint8_t adv_handle;
uint8_t num_bis;
- struct bt_hci_bis bis[0];
+ struct bt_hci_bis bis;
} __attribute__ ((packed));
#define BT_HCI_CMD_LE_CREATE_BIG_TEST 0x2069
@@ -2796,6 +2799,7 @@
#define BT_HCI_CMD_LE_BIG_CREATE_SYNC 0x206b
#define BT_HCI_BIT_LE_BIG_CREATE_SYNC BT_HCI_CMD_BIT(43, 0)
struct bt_hci_bis_sync {
+ uint8_t index;
} __attribute__ ((packed));
struct bt_hci_cmd_le_big_create_sync {
@@ -2815,6 +2819,11 @@
uint8_t handle;
} __attribute__ ((packed));
+struct bt_hci_rsp_le_big_term_sync {
+ uint8_t status;
+ uint8_t handle;
+} __attribute__ ((packed));
+
#define BT_HCI_CMD_LE_REQ_PEER_SCA 0x206d
#define BT_HCI_BIT_LE_REQ_PEER_SCA BT_HCI_CMD_BIT(43, 2)
struct bt_hci_cmd_le_req_peer_sca {
@@ -3496,7 +3505,7 @@
uint8_t data[0];
} __attribute__ ((packed));
-#define BT_HCI_EVT_LE_PER_SYNC_ESTABLISHED 0x0e
+#define BT_HCI_EVT_LE_PA_SYNC_ESTABLISHED 0x0e
struct bt_hci_evt_le_per_sync_established {
uint8_t status;
uint16_t handle;
@@ -3508,8 +3517,36 @@
uint8_t clock_accuracy;
} __attribute__ ((packed));
-#define BT_HCI_EVT_LE_PER_ADV_REPORT 0x0f
-struct bt_hci_le_per_adv_report {
+struct bt_hci_le_pa_base_codec {
+ uint8_t id;
+ uint16_t cid;
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/monitor/display.h
^
|
@@ -76,6 +76,20 @@
return mask;
}
+static inline void print_hex_field(const char *label, const uint8_t *data,
+ uint8_t len)
+{
+ char str[len * 2 + 1];
+ uint8_t i;
+
+ str[0] = '\0';
+
+ for (i = 0; i < len; i++)
+ sprintf(str + (i * 2), "%2.2x", data[i]);
+
+ print_field("%s: %s", label, str);
+}
+
void set_default_pager_num_columns(int num_columns);
int num_columns(void);
|
[-]
[+]
|
Added |
_service:tar_git:bluez5-5.65+git1.tar.gz/monitor/emulator.h
^
|
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2011-2014 Intel Corporation
+ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org>
+ *
+ *
+ */
+
+#define EMU_SUBCMD_TEST_EVENT 0x00
+
+struct emu_cmd_test_event {
+ uint8_t subcmd;
+ uint8_t evt;
+ uint8_t data[];
+} __attribute__((packed));
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/monitor/intel.c
^
|
@@ -86,18 +86,18 @@
print_field("Module: %s (0x%2.2x)", str, module);
}
-static void null_cmd(const void *data, uint8_t size)
+static void null_cmd(uint16_t index, const void *data, uint8_t size)
{
}
-static void status_rsp(const void *data, uint8_t size)
+static void status_rsp(uint16_t index, const void *data, uint8_t size)
{
uint8_t status = get_u8(data);
print_status(status);
}
-static void reset_cmd(const void *data, uint8_t size)
+static void reset_cmd(uint16_t index, const void *data, uint8_t size)
{
uint8_t reset_type = get_u8(data);
uint8_t patch_enable = get_u8(data + 1);
@@ -326,7 +326,7 @@
}
}
-static void read_version_rsp(const void *data, uint8_t size)
+static void read_version_rsp(uint16_t index, const void *data, uint8_t size)
{
uint8_t status = get_u8(data);
uint8_t hw_platform = get_u8(data + 1);
@@ -363,7 +363,7 @@
print_field("Firmware patch: %u", fw_patch);
}
-static void read_version_cmd(const void *data, uint8_t size)
+static void read_version_cmd(uint16_t index, const void *data, uint8_t size)
{
char *str;
uint8_t type;
@@ -406,7 +406,8 @@
}
}
-static void set_uart_baudrate_cmd(const void *data, uint8_t size)
+static void set_uart_baudrate_cmd(uint16_t index, const void *data,
+ uint8_t size)
{
uint8_t baudrate = get_u8(data);
const char *str;
@@ -465,7 +466,7 @@
print_field("Baudrate: %s (0x%2.2x)", str, baudrate);
}
-static void secure_send_cmd(const void *data, uint8_t size)
+static void secure_send_cmd(uint16_t index, const void *data, uint8_t size)
{
uint8_t type = get_u8(data);
const char *str;
@@ -493,7 +494,8 @@
packet_hexdump(data + 1, size - 1);
}
-static void manufacturer_mode_cmd(const void *data, uint8_t size)
+static void manufacturer_mode_cmd(uint16_t index, const void *data,
+ uint8_t size)
{
uint8_t mode = get_u8(data);
uint8_t reset = get_u8(data + 1);
@@ -531,7 +533,7 @@
print_field("Reset behavior: %s (0x%2.2x)", str, reset);
}
-static void write_bd_data_cmd(const void *data, uint8_t size)
+static void write_bd_data_cmd(uint16_t index, const void *data, uint8_t size)
{
uint8_t features[8];
@@ -548,7 +550,7 @@
packet_hexdump(data + 21, size - 21);
}
-static void read_bd_data_rsp(const void *data, uint8_t size)
+static void read_bd_data_rsp(uint16_t index, const void *data, uint8_t size)
{
uint8_t status = get_u8(data);
@@ -557,12 +559,12 @@
packet_hexdump(data + 7, size - 7);
}
-static void write_bd_address_cmd(const void *data, uint8_t size)
+static void write_bd_address_cmd(uint16_t index, const void *data, uint8_t size)
{
packet_print_addr("Address", data, 0x00);
}
-static void act_deact_traces_cmd(const void *data, uint8_t size)
+static void act_deact_traces_cmd(uint16_t index, const void *data, uint8_t size)
{
uint8_t tx = get_u8(data);
uint8_t tx_arq = get_u8(data + 1);
@@ -573,7 +575,8 @@
print_field("Receive traces: 0x%2.2x", rx);
}
-static void stimulate_exception_cmd(const void *data, uint8_t size)
+static void stimulate_exception_cmd(uint16_t index, const void *data,
+ uint8_t size)
{
uint8_t type = get_u8(data);
const char *str;
@@ -609,7 +612,7 @@
{ }
};
-static void set_event_mask_cmd(const void *data, uint8_t size)
+static void set_event_mask_cmd(uint16_t index, const void *data, uint8_t size)
{
const uint8_t *events_array = data;
uint64_t mask, events = 0;
@@ -634,7 +637,7 @@
"(0x%16.16" PRIx64 ")", mask);
}
-static void ddc_config_write_cmd(const void *data, uint8_t size)
+static void ddc_config_write_cmd(uint16_t index, const void *data, uint8_t size)
{
while (size > 0) {
uint8_t param_len = get_u8(data);
@@ -648,7 +651,7 @@
}
}
-static void ddc_config_write_rsp(const void *data, uint8_t size)
+static void ddc_config_write_rsp(uint16_t index, const void *data, uint8_t size)
{
uint8_t status = get_u8(data);
uint16_t param_id = get_le16(data + 1);
@@ -657,7 +660,7 @@
print_field("Identifier: 0x%4.4x", param_id);
}
-static void memory_write_cmd(const void *data, uint8_t size)
+static void memory_write_cmd(uint16_t index, const void *data, uint8_t size)
{
uint32_t addr = get_le32(data);
uint8_t mode = get_u8(data + 4);
@@ -687,14 +690,16 @@
packet_hexdump(data + 6, size - 6);
}
-static void read_supported_features_cmd(const void *data, uint8_t size)
+static void read_supported_features_cmd(uint16_t index, const void *data,
+ uint8_t size)
{
uint8_t page = get_u8(data);
print_field("Page: 0x%2.2x", page);
}
-static void read_supported_features_rsp(const void *data, uint8_t size)
+static void read_supported_features_rsp(uint16_t index, const void *data,
+ uint8_t size)
{
uint8_t status = get_u8(data);
uint8_t page = get_u8(data + 1);
@@ -788,11 +793,11 @@
return NULL;
}
-static void startup_evt(const void *data, uint8_t size)
+static void startup_evt(uint16_t index, const void *data, uint8_t size)
{
}
-static void fatal_exception_evt(const void *data, uint8_t size)
+static void fatal_exception_evt(uint16_t index, const void *data, uint8_t size)
{
uint16_t line = get_le16(data);
uint8_t module = get_u8(data + 2);
@@ -803,7 +808,7 @@
print_field("Reason: 0x%2.2x", reason);
}
-static void bootup_evt(const void *data, uint8_t size)
+static void bootup_evt(uint16_t index, const void *data, uint8_t size)
{
uint8_t zero = get_u8(data);
uint8_t num_packets = get_u8(data + 1);
@@ -906,7 +911,7 @@
print_field("DDC status: %s (0x%2.2x)", str, ddc_status);
}
-static void default_bd_data_evt(const void *data, uint8_t size)
+static void default_bd_data_evt(uint16_t index, const void *data, uint8_t size)
{
uint8_t mem_status = get_u8(data);
const char *str;
@@ -923,7 +928,8 @@
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/monitor/jlink.c
^
|
@@ -107,9 +107,12 @@
!jlink.tif_select || !jlink.setspeed ||
!jlink.connect || !jlink.getsn ||
!jlink.emu_getproductname ||
- !jlink.rtterminal_control || !jlink.rtterminal_read)
+ !jlink.rtterminal_control || !jlink.rtterminal_read) {
+ dlclose(so);
return -EIO;
+ }
+ /* don't dlclose(so) here cause symbols from it are in use now */
return 0;
}
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/monitor/l2cap.c
^
|
@@ -33,7 +33,7 @@
#include "avdtp.h"
#include "rfcomm.h"
#include "bnep.h"
-
+#include "att.h"
#define L2CAP_MODE_BASIC 0x00
#define L2CAP_MODE_RETRANS 0x01
@@ -1331,7 +1331,7 @@
const struct bt_l2cap_pdu_ecred_conn_req *pdu = frame->data;
uint16_t scid;
- l2cap_frame_pull((void *)frame, frame, sizeof(pdu));
+ l2cap_frame_pull((void *)frame, frame, sizeof(*pdu));
print_psm(pdu->psm);
print_field("MTU: %u", le16_to_cpu(pdu->mtu));
@@ -1538,7 +1538,7 @@
{ },
};
-static void l2cap_frame_init(struct l2cap_frame *frame, uint16_t index, bool in,
+void l2cap_frame_init(struct l2cap_frame *frame, uint16_t index, bool in,
uint16_t handle, uint8_t ident,
uint16_t cid, uint16_t psm,
const void *data, uint16_t size)
@@ -2123,632 +2123,6 @@
opcode_data->func(&frame);
}
-static void print_hex_field(const char *label, const uint8_t *data,
- uint8_t len)
-{
- char str[len * 2 + 1];
- uint8_t i;
-
- str[0] = '\0';
-
- for (i = 0; i < len; i++)
- sprintf(str + (i * 2), "%2.2x", data[i]);
-
- print_field("%s: %s", label, str);
-}
-
-static void print_uuid(const char *label, const void *data, uint16_t size)
-{
- const char *str;
- char uuidstr[MAX_LEN_UUID_STR];
-
- switch (size) {
- case 2:
- str = bt_uuid16_to_str(get_le16(data));
- print_field("%s: %s (0x%4.4x)", label, str, get_le16(data));
- break;
- case 4:
- str = bt_uuid32_to_str(get_le32(data));
- print_field("%s: %s (0x%8.8x)", label, str, get_le32(data));
- break;
- case 16:
- sprintf(uuidstr, "%8.8x-%4.4x-%4.4x-%4.4x-%8.8x%4.4x",
- get_le32(data + 12), get_le16(data + 10),
- get_le16(data + 8), get_le16(data + 6),
- get_le32(data + 2), get_le16(data + 0));
- str = bt_uuidstr_to_str(uuidstr);
- print_field("%s: %s (%s)", label, str, uuidstr);
- break;
- default:
- packet_hexdump(data, size);
- break;
- }
-}
-
-static void print_handle_range(const char *label, const void *data)
-{
- print_field("%s: 0x%4.4x-0x%4.4x", label,
- get_le16(data), get_le16(data + 2));
-}
-
-static void print_data_list(const char *label, uint8_t length,
- const void *data, uint16_t size)
-{
- uint8_t count;
-
- if (length == 0)
- return;
-
- count = size / length;
-
- print_field("%s: %u entr%s", label, count, count == 1 ? "y" : "ies");
-
- while (size >= length) {
- print_field("Handle: 0x%4.4x", get_le16(data));
- print_hex_field("Value", data + 2, length - 2);
-
- data += length;
- size -= length;
- }
-
- packet_hexdump(data, size);
-}
-
-static void print_attribute_info(uint16_t type, const void *data, uint16_t len)
-{
- const char *str = bt_uuid16_to_str(type);
-
- print_field("%s: %s (0x%4.4x)", "Attribute type", str, type);
-
- switch (type) {
- case 0x2800: /* Primary Service */
- case 0x2801: /* Secondary Service */
- print_uuid(" UUID", data, len);
- break;
- case 0x2802: /* Include */
- if (len < 4) {
- print_hex_field(" Value", data, len);
- break;
- }
- print_handle_range(" Handle range", data);
- print_uuid(" UUID", data + 4, len - 4);
- break;
- case 0x2803: /* Characteristic */
- if (len < 3) {
- print_hex_field(" Value", data, len);
- break;
- }
- print_field(" Properties: 0x%2.2x", *((uint8_t *) data));
- print_field(" Handle: 0x%2.2x", get_le16(data + 1));
- print_uuid(" UUID", data + 3, len - 3);
- break;
- default:
- print_hex_field("Value", data, len);
- break;
- }
-}
-
-static const char *att_opcode_to_str(uint8_t opcode);
-
-static void att_error_response(const struct l2cap_frame *frame)
-{
- const struct bt_l2cap_att_error_response *pdu = frame->data;
- const char *str;
-
- switch (pdu->error) {
- case 0x01:
- str = "Invalid Handle";
- break;
- case 0x02:
- str = "Read Not Permitted";
- break;
- case 0x03:
- str = "Write Not Permitted";
- break;
- case 0x04:
- str = "Invalid PDU";
- break;
- case 0x05:
- str = "Insufficient Authentication";
- break;
- case 0x06:
- str = "Request Not Supported";
- break;
- case 0x07:
- str = "Invalid Offset";
- break;
- case 0x08:
- str = "Insufficient Authorization";
- break;
- case 0x09:
- str = "Prepare Queue Full";
- break;
- case 0x0a:
- str = "Attribute Not Found";
- break;
- case 0x0b:
- str = "Attribute Not Long";
- break;
- case 0x0c:
- str = "Insufficient Encryption Key Size";
- break;
- case 0x0d:
- str = "Invalid Attribute Value Length";
- break;
- case 0x0e:
- str = "Unlikely Error";
- break;
- case 0x0f:
- str = "Insufficient Encryption";
- break;
- case 0x10:
- str = "Unsupported Group Type";
- break;
- case 0x11:
- str = "Insufficient Resources";
- break;
- case 0x12:
- str = "Database Out of Sync";
- break;
- case 0x13:
- str = "Value Not Allowed";
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/monitor/l2cap.h
^
|
@@ -26,8 +26,13 @@
uint16_t size;
};
-static inline void l2cap_frame_pull(struct l2cap_frame *frame,
- const struct l2cap_frame *source, uint16_t len)
+void l2cap_frame_init(struct l2cap_frame *frame, uint16_t index, bool in,
+ uint16_t handle, uint8_t ident,
+ uint16_t cid, uint16_t psm,
+ const void *data, uint16_t size);
+
+static inline void l2cap_frame_clone(struct l2cap_frame *frame,
+ const struct l2cap_frame *source)
{
if (frame != source) {
frame->index = source->index;
@@ -38,10 +43,26 @@
frame->psm = source->psm;
frame->chan = source->chan;
frame->mode = source->mode;
+ frame->data = source->data;
+ frame->size = source->size;
}
+}
+
+static inline void *l2cap_frame_pull(struct l2cap_frame *frame,
+ const struct l2cap_frame *source, uint16_t len)
+{
+ void *data;
+
+ l2cap_frame_clone(frame, source);
+ if (source->size < len)
+ return NULL;
+
+ data = (void *)frame->data;
frame->data = source->data + len;
frame->size = source->size - len;
+
+ return data;
}
static inline bool l2cap_frame_get_u8(struct l2cap_frame *frame, uint8_t *value)
@@ -57,6 +78,21 @@
return true;
}
+static inline bool l2cap_frame_print_u8(struct l2cap_frame *frame,
+ const char *label)
+{
+ uint8_t u8;
+
+ if (!l2cap_frame_get_u8(frame, &u8)) {
+ print_text(COLOR_ERROR, "%s: invalid size", label);
+ return false;
+ }
+
+ print_field("%s: 0x%2.2x", label, u8);
+
+ return true;
+}
+
static inline bool l2cap_frame_get_be16(struct l2cap_frame *frame,
uint16_t *value)
{
@@ -71,6 +107,21 @@
return true;
}
+static inline bool l2cap_frame_print_be16(struct l2cap_frame *frame,
+ const char *label)
+{
+ uint16_t u16;
+
+ if (!l2cap_frame_get_be16(frame, &u16)) {
+ print_text(COLOR_ERROR, "%s: invalid size", label);
+ return false;
+ }
+
+ print_field("%s: 0x%4.4x", label, u16);
+
+ return true;
+}
+
static inline bool l2cap_frame_get_le16(struct l2cap_frame *frame,
uint16_t *value)
{
@@ -85,6 +136,79 @@
return true;
}
+static inline bool l2cap_frame_print_le16(struct l2cap_frame *frame,
+ const char *label)
+{
+ uint16_t u16;
+
+ if (!l2cap_frame_get_le16(frame, &u16)) {
+ print_text(COLOR_ERROR, "%s: invalid size", label);
+ return false;
+ }
+
+ print_field("%s: 0x%4.4x", label, u16);
+
+ return true;
+}
+
+static inline bool l2cap_frame_get_be24(struct l2cap_frame *frame,
+ uint32_t *value)
+{
+ if (frame->size < sizeof(uint24_t))
+ return false;
+
+ if (value)
+ *value = get_be24(frame->data);
+
+ l2cap_frame_pull(frame, frame, sizeof(uint24_t));
+
+ return true;
+}
+
+static inline bool l2cap_frame_print_be24(struct l2cap_frame *frame,
+ const char *label)
+{
+ uint32_t u24;
+
+ if (!l2cap_frame_get_be24(frame, &u24)) {
+ print_text(COLOR_ERROR, "%s: invalid size", label);
+ return false;
+ }
+
+ print_field("%s: 0x%6.6x", label, u24);
+
+ return true;
+}
+
+static inline bool l2cap_frame_get_le24(struct l2cap_frame *frame,
+ uint32_t *value)
+{
+ if (frame->size < sizeof(uint24_t))
+ return false;
+
+ if (value)
+ *value = get_le24(frame->data);
+
+ l2cap_frame_pull(frame, frame, sizeof(uint24_t));
+
+ return true;
+}
+
+static inline bool l2cap_frame_print_le24(struct l2cap_frame *frame,
+ const char *label)
+{
+ uint32_t u24;
+
+ if (!l2cap_frame_get_le24(frame, &u24)) {
+ print_text(COLOR_ERROR, "%s: invalid size", label);
+ return false;
+ }
+
+ print_field("%s: 0x%6.6x", label, u24);
+
+ return true;
+}
+
static inline bool l2cap_frame_get_be32(struct l2cap_frame *frame,
uint32_t *value)
{
@@ -99,6 +223,21 @@
return true;
}
+static inline bool l2cap_frame_print_be32(struct l2cap_frame *frame,
+ const char *label)
+{
+ uint32_t u32;
+
+ if (!l2cap_frame_get_be32(frame, &u32)) {
+ print_text(COLOR_ERROR, "%s: invalid size", label);
+ return false;
+ }
+
+ print_field("%s: 0x%8.8x", label, u32);
+
+ return true;
+}
+
static inline bool l2cap_frame_get_le32(struct l2cap_frame *frame,
uint32_t *value)
{
@@ -113,6 +252,21 @@
return true;
}
+static inline bool l2cap_frame_print_le32(struct l2cap_frame *frame,
+ const char *label)
+{
+ uint32_t u32;
+
+ if (!l2cap_frame_get_le32(frame, &u32)) {
+ print_text(COLOR_ERROR, "%s: invalid size", label);
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/monitor/msft.c
^
|
@@ -219,7 +219,7 @@
{ }
};
-static void msft_cmd(const void *data, uint8_t size)
+static void msft_cmd(uint16_t index, const void *data, uint8_t size)
{
uint8_t code = get_u8(data);
const char *code_color, *code_str = NULL;
@@ -253,7 +253,7 @@
packet_hexdump(data + 1, size - 1);
}
-static void msft_rsp(const void *data, uint8_t size)
+static void msft_rsp(uint16_t index, const void *data, uint8_t size)
{
uint8_t status = get_u8(data);
uint8_t code = get_u8(data + 1);
@@ -299,7 +299,7 @@
return &vendor_ocf_entry;
}
-static void msft_evt(const void *data, uint8_t size)
+static void msft_evt(uint16_t index, const void *data, uint8_t size)
{
packet_hexdump(data, size);
}
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/monitor/packet.c
^
|
@@ -169,21 +169,27 @@
#define MAX_CONN 16
-struct conn_data {
- uint16_t handle;
- uint8_t type;
-};
-
-static struct conn_data conn_list[MAX_CONN];
+static struct packet_conn_data conn_list[MAX_CONN];
-static void assign_handle(uint16_t handle, uint8_t type)
+static void assign_handle(uint16_t index, uint16_t handle, uint8_t type,
+ uint8_t *dst, uint8_t dst_type)
{
int i;
for (i = 0; i < MAX_CONN; i++) {
if (conn_list[i].handle == 0x0000) {
+ if (hci_devba(index, (bdaddr_t *)conn_list[i].src) < 0)
+ return;
+
+ conn_list[i].index = index;
conn_list[i].handle = handle;
conn_list[i].type = type;
+
+ if (!dst)
+ break;
+
+ memcpy(conn_list[i].dst, dst, sizeof(conn_list[i].dst));
+ conn_list[i].dst_type = dst_type;
break;
}
}
@@ -195,23 +201,36 @@
for (i = 0; i < MAX_CONN; i++) {
if (conn_list[i].handle == handle) {
- conn_list[i].handle = 0x0000;
- conn_list[i].type = 0x00;
+ if (conn_list[i].destroy)
+ conn_list[i].destroy(conn_list[i].data);
+
+ memset(&conn_list[i], 0, sizeof(conn_list[i]));
break;
}
}
}
-static uint8_t get_type(uint16_t handle)
+struct packet_conn_data *packet_get_conn_data(uint16_t handle)
{
int i;
for (i = 0; i < MAX_CONN; i++) {
if (conn_list[i].handle == handle)
- return conn_list[i].type;
+ return &conn_list[i];
}
- return 0xff;
+ return NULL;
+}
+
+static uint8_t get_type(uint16_t handle)
+{
+ struct packet_conn_data *conn;
+
+ conn = packet_get_conn_data(handle);
+ if (!conn)
+ return 0xff;
+
+ return conn->type;
}
bool packet_has_filter(unsigned long filter)
@@ -739,7 +758,17 @@
static void print_handle_native(uint16_t handle)
{
- print_field("Handle: %d", handle);
+ struct packet_conn_data *conn;
+ char label[25];
+
+ conn = packet_get_conn_data(handle);
+ if (!conn) {
+ print_field("Handle: %d", handle);
+ return;
+ }
+
+ sprintf(label, "Handle: %d Address", handle);
+ print_addr(label, conn->dst, conn->dst_type);
}
static void print_handle(uint16_t handle)
@@ -1337,6 +1366,9 @@
case 0x05:
str = "mSBC";
break;
+ case 0x06:
+ str = "LC3";
+ break;
case 0xff:
str = "Vendor specific";
break;
@@ -1348,6 +1380,11 @@
print_field("%s: %s (0x%2.2x)", label, str, codec);
}
+void packet_print_codec_id(const char *label, uint8_t codec)
+{
+ print_codec_id(label, codec);
+}
+
static const struct bitfield_data codec_transport_table[] = {
{ 0, "Codec supported over BR/EDR ACL" },
{ 1, "Codec supported over BR/EDR SCO and eSCO"},
@@ -1752,20 +1789,6 @@
print_field("Key size: %d", key_size);
}
-static void print_hex_field(const char *label, const uint8_t *data,
- uint8_t len)
-{
- char str[len * 2 + 1];
- uint8_t i;
-
- str[0] = '\0';
-
- for (i = 0; i < len; i++)
- sprintf(str + (i * 2), "%2.2x", data[i]);
-
- print_field("%s: %s", label, str);
-}
-
static void print_key(const char *label, const uint8_t *link_key)
{
print_hex_field(label, link_key, 16);
@@ -2816,7 +2839,8 @@
static void print_le_states(const uint8_t *states_array)
{
uint64_t mask, states = 0;
- int i, n;
+ int i = 0;
+ size_t n = 0;
for (i = 0; i < 8; i++)
states |= ((uint64_t) states_array[i]) << (i * 8);
@@ -2828,12 +2852,12 @@
for (i = 0; le_states_comb_table[i].states; i++) {
uint64_t val = (((uint64_t) 1) << le_states_comb_table[i].bit);
const char *str[3] = { NULL, };
- int num = 0;
+ size_t num = 0;
if (!(states & val))
continue;
- for (n = 0; n < 16; n++) {
+ for (n = 0; n < ARRAY_SIZE(le_states_desc_table); n++) {
if (le_states_comb_table[i].states & (1 << n))
str[num++] = le_states_desc_table[n].str;
}
@@ -3300,6 +3324,223 @@
}
}
+static void *iov_pull(struct iovec *iov, size_t len)
+{
+ void *data;
+
+ if (iov->iov_len < len)
+ return NULL;
+
+ data = iov->iov_base;
+ iov->iov_base += len;
+ iov->iov_len -= len;
+
+ return data;
+}
+
+static struct packet_ltv_decoder*
+get_ltv_decoder(struct packet_ltv_decoder *decoder, size_t num, uint8_t type)
+{
+ size_t i;
+
+ if (!decoder || !num)
+ return NULL;
+
+ for (i = 0; i < num; i++) {
+ struct packet_ltv_decoder *dec = &decoder[i];
+
+ if (dec->type == type)
+ return dec;
+ }
+
+ return NULL;
+}
+
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/monitor/packet.h
^
|
@@ -23,6 +23,19 @@
#define PACKET_FILTER_SHOW_A2DP_STREAM (1 << 6)
#define PACKET_FILTER_SHOW_MGMT_SOCKET (1 << 7)
+struct packet_conn_data {
+ uint16_t index;
+ uint8_t src[6];
+ uint16_t handle;
+ uint8_t type;
+ uint8_t dst[6];
+ uint8_t dst_type;
+ void *data;
+ void (*destroy)(void *data);
+};
+
+struct packet_conn_data *packet_get_conn_data(uint16_t handle);
+
bool packet_has_filter(unsigned long filter);
void packet_set_filter(unsigned long filter);
void packet_add_filter(unsigned long filter);
@@ -49,6 +62,21 @@
void packet_print_channel_map_ll(const uint8_t *map);
void packet_print_io_capability(uint8_t capability);
void packet_print_io_authentication(uint8_t authentication);
+void packet_print_codec_id(const char *label, uint8_t codec);
+
+#define LTV_DEC(_type, _func) \
+{ \
+ .type = _type, \
+ .func = _func, \
+}
+
+struct packet_ltv_decoder {
+ uint8_t type;
+ void (*func)(const uint8_t *data, uint8_t len);
+};
+
+void packet_print_ltv(const char *label, const uint8_t *data, uint8_t len,
+ struct packet_ltv_decoder *decoder, size_t num);
void packet_control(struct timeval *tv, struct ucred *cred,
uint16_t index, uint16_t opcode,
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/monitor/sdp.c
^
|
@@ -494,7 +494,7 @@
cont_list[n].data = NULL;
cont_list[n].size = 0;
} else
- memcpy(cont_list[i].cont, data + bytes, data[bytes] + 1);
+ memcpy(cont_list[n].cont, data + bytes, data[bytes] + 1);
}
static uint16_t common_rsp(const struct l2cap_frame *frame,
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/monitor/vendor.h
^
|
@@ -14,10 +14,10 @@
struct vendor_ocf {
uint16_t ocf;
const char *str;
- void (*cmd_func) (const void *data, uint8_t size);
+ void (*cmd_func) (uint16_t index, const void *data, uint8_t size);
uint8_t cmd_size;
bool cmd_fixed;
- void (*rsp_func) (const void *data, uint8_t size);
+ void (*rsp_func) (uint16_t index, const void *data, uint8_t size);
uint8_t rsp_size;
bool rsp_fixed;
};
@@ -25,7 +25,7 @@
struct vendor_evt {
uint8_t evt;
const char *str;
- void (*evt_func) (const void *data, uint8_t size);
+ void (*evt_func) (uint16_t index, const void *data, uint8_t size);
uint8_t evt_size;
bool evt_fixed;
};
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/obexd/client/pbap.c
^
|
@@ -925,10 +925,11 @@
return g_dbus_create_error(message,
ERROR_INTERFACE ".InvalidArguments", NULL);
- if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_STRING)
+ if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_STRING) {
+ g_obex_apparam_free(apparam);
return g_dbus_create_error(message,
ERROR_INTERFACE ".InvalidArguments", NULL);
-
+ }
dbus_message_iter_get_basic(&args, &value);
dbus_message_iter_next(&args);
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/obexd/client/session.c
^
|
@@ -950,7 +950,7 @@
{
struct obc_session *session = user_data;
- if (err != 0)
+ if (err)
goto fail;
session_notify_complete(session, transfer);
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/obexd/client/transfer.c
^
|
@@ -666,7 +666,10 @@
else
transfer_set_status(transfer, TRANSFER_STATUS_COMPLETE);
- if (callback)
+ if (callback == NULL)
+ return;
+
+ if (callback->func)
callback->func(transfer, err, callback->data);
}
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/obexd/src/obex.c
^
|
@@ -40,6 +40,7 @@
#include "mimetype.h"
#include "service.h"
#include "transport.h"
+#include "src/shared/util.h"
typedef struct {
uint8_t version;
@@ -145,7 +146,7 @@
os->path = NULL;
}
if (os->apparam) {
- g_free(os->apparam);
+ free(os->apparam);
os->apparam = NULL;
os->apparam_len = 0;
}
@@ -594,7 +595,7 @@
if (!g_obex_header_get_bytes(hdr, &apparam, &len))
return;
- os->apparam = g_memdup(apparam, len);
+ os->apparam = util_memdup(apparam, len);
os->apparam_len = len;
DBG("APPARAM");
}
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/peripheral/main.c
^
|
@@ -25,13 +25,13 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/mount.h>
-#include <sys/random.h>
#ifndef WAIT_ANY
#define WAIT_ANY (-1)
#endif
#include "src/shared/mainloop.h"
+#include "src/shared/util.h"
#include "peripheral/efivars.h"
#include "peripheral/attach.h"
#include "peripheral/gap.h"
@@ -192,7 +192,7 @@
addr, 6) < 0) {
printf("Generating new persistent static address\n");
- if (getrandom(addr, sizeof(addr), 0) < 0) {
+ if (util_getrandom(addr, sizeof(addr), 0) < 0) {
perror("Failed to get random static address");
return EXIT_FAILURE;
}
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/plugins/autopair.c
^
|
@@ -17,7 +17,6 @@
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
-#include <sys/random.h>
#include <glib.h>
@@ -29,6 +28,7 @@
#include "src/device.h"
#include "src/log.h"
#include "src/storage.h"
+#include "src/shared/util.h"
/*
* Plugin to handle automatic pairing of devices with reduced user
@@ -131,7 +131,7 @@
if (attempt >= 4)
return 0;
- if (getrandom(&val, sizeof(val), 0) < 0) {
+ if (util_getrandom(&val, sizeof(val), 0) < 0) {
error("Failed to get a random pincode");
return 0;
}
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/plugins/neard.c
^
|
@@ -30,6 +30,7 @@
#include "src/eir.h"
#include "src/agent.h"
#include "src/btd.h"
+#include "src/shared/util.h"
#define NEARD_NAME "org.neard"
#define NEARD_PATH "/"
@@ -71,7 +72,7 @@
g_free(params->name);
g_free(params->hash);
g_free(params->randomizer);
- g_free(params->pin);
+ free(params->pin);
}
static DBusMessage *error_reply(DBusMessage *msg, int error)
@@ -407,10 +408,10 @@
remote->name = g_strndup((char *)n->name, n->name_len);
if (marker == 0x01) {
- remote->pin = g_memdup(n->authentication, 4);
+ remote->pin = util_memdup(n->authentication, 4);
remote->pin_len = 4;
} else if (marker == 0x02) {
- remote->pin = g_memdup(n->authentication, 16);
+ remote->pin = util_memdup(n->authentication, 16);
remote->pin_len = 16;
}
@@ -439,7 +440,7 @@
if (n->name_len > 0)
remote->name = g_strndup((char *)n->name, n->name_len);
- remote->pin = g_memdup(n->authentication, 4);
+ remote->pin = util_memdup(n->authentication, 4);
remote->pin_len = 4;
return 0;
@@ -574,14 +575,12 @@
if (process_nokia_com_bt(data, size, remote))
goto error;
} else if (strcasecmp(key, "State") == 0) {
- DBusMessageIter array;
const char *state;
if (dbus_message_iter_get_arg_type(&value) !=
DBUS_TYPE_STRING)
goto error;
- dbus_message_iter_recurse(&value, &array);
dbus_message_iter_get_basic(&value, &state);
remote->power_state = process_state(state);
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/plugins/policy.c
^
|
@@ -32,6 +32,7 @@
#include "src/profile.h"
#include "src/btd.h"
#include "src/shared/timeout.h"
+#include "src/shared/util.h"
#define CONTROL_CONNECT_TIMEOUT 2
#define SOURCE_RETRY_TIMEOUT 2
@@ -855,7 +856,7 @@
reconnect_attempts = default_attempts;
reconnect_intervals_len = sizeof(default_intervals) /
sizeof(*reconnect_intervals);
- reconnect_intervals = g_memdup(default_intervals,
+ reconnect_intervals = util_memdup(default_intervals,
sizeof(default_intervals));
goto done;
}
@@ -886,12 +887,16 @@
g_clear_error(&gerr);
reconnect_intervals_len = sizeof(default_intervals) /
sizeof(*reconnect_intervals);
- reconnect_intervals = g_memdup(default_intervals,
+ reconnect_intervals = util_memdup(default_intervals,
sizeof(default_intervals));
}
auto_enable = g_key_file_get_boolean(conf, "Policy", "AutoEnable",
- NULL);
+ &gerr);
+ if (gerr) {
+ g_clear_error(&gerr);
+ auto_enable = true;
+ }
resume_delay = g_key_file_get_integer(
conf, "Policy", "ResumeDelay", &gerr);
@@ -919,7 +924,7 @@
if (reconnect_uuids)
g_strfreev(reconnect_uuids);
- g_free(reconnect_intervals);
+ free(reconnect_intervals);
g_slist_free_full(reconnects, reconnect_destroy);
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/plugins/sixaxis.c
^
|
@@ -424,10 +424,15 @@
cp = get_pairing_type_for_device(udevice, &bus, &sysfs_path);
if (!cp || (cp->type != CABLE_PAIRING_SIXAXIS &&
- cp->type != CABLE_PAIRING_DS4))
+ cp->type != CABLE_PAIRING_DS4)) {
+ g_free(sysfs_path);
return;
- if (bus != BUS_USB)
+ }
+
+ if (bus != BUS_USB) {
+ g_free(sysfs_path);
return;
+ }
info("sixaxis: compatible device connected: %s (%04X:%04X %s)",
cp->name, cp->vid, cp->pid, sysfs_path);
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/profiles/audio/a2dp.c
^
|
@@ -40,6 +40,7 @@
#include "src/service.h"
#include "src/log.h"
#include "src/sdpd.h"
+#include "src/textfile.h"
#include "src/shared/queue.h"
#include "src/shared/timeout.h"
#include "src/shared/util.h"
@@ -244,6 +245,15 @@
cb->setup = setup;
cb->id = ++cb_id;
+ return cb;
+}
+
+static struct a2dp_setup_cb *setup_cb_add(struct a2dp_setup *setup)
+{
+ struct a2dp_setup_cb *cb;
+
+ cb = setup_cb_new(setup);
+
setup->cb = g_slist_append(setup->cb, cb);
return cb;
}
@@ -820,14 +830,12 @@
char *data;
gsize length = 0;
- if (queue_isempty(chan->seps))
- return;
-
ba2str(device_get_address(device), dst_addr);
- snprintf(filename, PATH_MAX, STORAGEDIR "/%s/cache/%s",
+ create_filename(filename, PATH_MAX, "/%s/cache/%s",
btd_adapter_get_storage_dir(device_get_adapter(device)),
dst_addr);
+
key_file = g_key_file_new();
if (!g_key_file_load_from_file(key_file, filename, 0, &gerr)) {
error("Unable to load key file from %s: (%s)", filename,
@@ -863,12 +871,10 @@
static void invalidate_remote_cache(struct a2dp_setup *setup,
struct avdtp_error *err)
{
- if (err->category == AVDTP_ERRNO ||
- err->err.error_code != AVDTP_UNSUPPORTED_CONFIGURATION)
+ if (err->category == AVDTP_ERRNO)
return;
- /* Attempt to unregister Remote SEP if configuration
- * fails with Unsupported Configuration and it was
+ /* Attempt to unregister Remote SEP if configuration fails and it was
* loaded from cache.
*/
if (setup->rsep && setup->rsep->from_cache) {
@@ -999,9 +1005,10 @@
ba2str(device_get_address(chan->device), dst_addr);
- snprintf(filename, PATH_MAX, STORAGEDIR "/%s/cache/%s",
+ create_filename(filename, PATH_MAX, "/%s/cache/%s",
btd_adapter_get_storage_dir(device_get_adapter(chan->device)),
dst_addr);
+
key_file = g_key_file_new();
if (!g_key_file_load_from_file(key_file, filename, 0, &gerr)) {
error("Unable to load key file from %s: (%s)", filename,
@@ -1841,11 +1848,16 @@
GSList *l;
int err;
+ /* Check SEP not used by a different session */
+ if (lsep->stream && chan->session &&
+ !avdtp_has_stream(chan->session, lsep->stream))
+ return -EBUSY;
+
setup = a2dp_setup_get(chan->session);
if (!setup)
return -ENOMEM;
- cb_data = setup_cb_new(setup);
+ cb_data = setup_cb_add(setup);
cb_data->config_cb = reconfig_cb;
cb_data->user_data = user_data;
@@ -1869,8 +1881,10 @@
if (tmp->stream) {
/* Only allow switching sep from the same sender */
if (strcmp(sender, tmp->endpoint->get_name(tmp,
- tmp->user_data)))
- return -EPERM;
+ tmp->user_data))) {
+ err = -EPERM;
+ goto fail;
+ }
/* Check if stream is for the channel */
if (!avdtp_has_stream(chan->session, tmp->stream))
@@ -2072,6 +2086,11 @@
if (sep)
return sep;
+ if (!avdtp_get_codec(rsep)) {
+ error("Unable to get remote sep codec");
+ return NULL;
+ }
+
sep = new0(struct a2dp_remote_sep, 1);
sep->chan = chan;
sep->sep = rsep;
@@ -2146,6 +2165,7 @@
struct avdtp_remote_sep *rsep;
uint8_t lseid, rseid;
char *value;
+ bool update = false;
if (!seids)
return;
@@ -2204,10 +2224,19 @@
}
sep = register_remote_sep(rsep, chan);
- if (sep)
- sep->from_cache = true;
+ if (!sep) {
+ avdtp_unregister_remote_sep(chan->session, rsep);
+ update = true;
+ continue;
+ }
+
+ sep->from_cache = true;
}
+ /* Update cache */
+ if (update)
+ store_remote_seps(chan);
+
value = g_key_file_get_string(key_file, "Endpoints", "LastUsed", NULL);
if (!value)
return;
@@ -2248,9 +2277,10 @@
ba2str(device_get_address(device), dst_addr);
- snprintf(filename, PATH_MAX, STORAGEDIR "/%s/cache/%s",
+ create_filename(filename, PATH_MAX, "/%s/cache/%s",
btd_adapter_get_storage_dir(device_get_adapter(device)),
dst_addr);
+
key_file = g_key_file_new();
if (!g_key_file_load_from_file(key_file, filename, 0, &gerr)) {
error("Unable to load key file from %s: (%s)", filename,
@@ -2664,8 +2694,6 @@
sep->codec = codec;
sep->type = type;
sep->delay_reporting = delay_reporting;
- sep->user_data = user_data;
- sep->destroy = destroy;
if (type == AVDTP_SEP_TYPE_SOURCE) {
l = &server->sources;
@@ -2709,6 +2737,9 @@
add:
*l = g_slist_append(*l, sep);
+ sep->user_data = user_data;
+ sep->destroy = destroy;
+
if (err)
*err = 0;
return sep;
@@ -2883,12 +2914,17 @@
if (!setup)
return 0;
+ /* Don't add cb since avdtp_discover can end up disconnecting the
+ * session causing the cb to be freed.
+ */
cb_data = setup_cb_new(setup);
cb_data->discover_cb = cb;
cb_data->user_data = user_data;
- if (avdtp_discover(session, discover_cb, setup) == 0)
+ if (avdtp_discover(session, discover_cb, setup) == 0) {
+ setup->cb = g_slist_append(setup->cb, cb_data);
return cb_data->id;
+ }
setup_cb_free(cb_data);
return 0;
@@ -2916,7 +2952,7 @@
if (!setup)
return 0;
- cb_data = setup_cb_new(setup);
+ cb_data = setup_cb_add(setup);
cb_data->select_cb = cb;
cb_data->user_data = user_data;
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/profiles/audio/avctp.c
^
|
@@ -40,6 +40,7 @@
#include "src/log.h"
#include "src/error.h"
#include "src/shared/timeout.h"
+#include "src/shared/util.h"
#include "avctp.h"
#include "avrcp.h"
@@ -760,7 +761,7 @@
NULL, 0, req->user_data);
done:
- g_free(req->operands);
+ free(req->operands);
g_free(req);
}
@@ -776,7 +777,7 @@
req->func(session, NULL, 0, req->user_data);
done:
- g_free(req->operands);
+ free(req->operands);
g_free(req);
}
@@ -1727,7 +1728,7 @@
req->subunit = subunit;
req->op = opcode;
req->func = func;
- req->operands = g_memdup(operands, operand_count);
+ req->operands = util_memdup(operands, operand_count);
req->operand_count = operand_count;
req->user_data = user_data;
@@ -1765,7 +1766,7 @@
req = g_new0(struct avctp_browsing_req, 1);
req->func = func;
- req->operands = g_memdup(operands, operand_count);
+ req->operands = util_memdup(operands, operand_count);
req->operand_count = operand_count;
req->user_data = user_data;
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/profiles/audio/avdtp.c
^
|
@@ -497,7 +497,9 @@
single.signal_id = signal_id;
memcpy(session->buf, &single, sizeof(single));
- memcpy(session->buf + sizeof(single), data, len);
+
+ if (data)
+ memcpy(session->buf + sizeof(single), data, len);
return try_send(sock, session->buf, sizeof(single) + len);
}
@@ -569,7 +571,7 @@
if (req->timeout)
timeout_remove(req->timeout);
- g_free(req->data);
+ free(req->data);
g_free(req);
}
@@ -1333,7 +1335,7 @@
break;
}
- cpy = btd_malloc(sizeof(*cpy) + cap->length);
+ cpy = util_malloc(sizeof(*cpy) + cap->length);
memcpy(cpy, cap, sizeof(*cap) + cap->length);
size -= sizeof(*cap) + cap->length;
@@ -2697,7 +2699,7 @@
return 0;
failed:
- g_free(req->data);
+ free(req->data);
g_free(req);
return err;
}
@@ -2715,8 +2717,7 @@
req = g_new0(struct pending_req, 1);
req->signal_id = signal_id;
- req->data = g_malloc(size);
- memcpy(req->data, buffer, size);
+ req->data = util_memdup(buffer, size);
req->data_size = size;
req->stream = stream;
@@ -2774,8 +2775,11 @@
ret = send_request(session, TRUE, NULL, getcap_cmd,
&req, sizeof(req));
- if (ret < 0)
+ if (ret < 0) {
+ session->seps = g_slist_remove(session->seps, sep);
+ g_free(sep);
break;
+ }
getcap_pending = TRUE;
}
@@ -3333,7 +3337,9 @@
cap = g_malloc(sizeof(struct avdtp_service_capability) + length);
cap->category = category;
cap->length = length;
- memcpy(cap->data, data, length);
+
+ if (data)
+ memcpy(cap->data, data, length);
return cap;
}
@@ -3436,6 +3442,9 @@
if (err == 0) {
session->discover->cb = cb;
session->discover->user_data = user_data;
+ } else if (session->discover) {
+ g_free(session->discover);
+ session->discover = NULL;
}
return err;
@@ -3530,6 +3539,9 @@
if (!(lsep && rsep))
return -EINVAL;
+ if (lsep->stream)
+ return -EBUSY;
+
DBG("%p: int_seid=%u, acp_seid=%u", session,
lsep->info.seid, rsep->seid);
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/profiles/audio/avrcp.c
^
|
@@ -835,7 +835,7 @@
}
done:
- pdu->params_len = htons(size);
+ pdu->params_len = cpu_to_be16(size);
for (l = player->sessions; l; l = l->next) {
struct avrcp *session = l->data;
@@ -933,15 +933,17 @@
return attr_len;
}
+struct avrcp_media_attribute_hdr {
+ uint32_t id;
+ uint16_t charset;
+ uint16_t len;
+} __attribute__ ((packed));
+
static GList *player_fill_media_attribute(struct avrcp_player *player,
GList *attr_ids, uint8_t *buf,
uint16_t *pos, uint16_t *offset)
{
- struct media_attribute_header {
- uint32_t id;
- uint16_t charset;
- uint16_t len;
- } *hdr = NULL;
+ struct avrcp_media_attribute_hdr *hdr = NULL;
GList *l;
for (l = attr_ids; l != NULL; l = g_list_delete_link(l, l)) {
@@ -953,9 +955,9 @@
break;
hdr = (void *) &buf[*pos];
- hdr->id = htonl(attr);
+ hdr->id = cpu_to_be32(attr);
/* Always use UTF-8 */
- hdr->charset = htons(AVRCP_CHARSET_UTF8);
+ hdr->charset = cpu_to_be16(AVRCP_CHARSET_UTF8);
*pos += sizeof(*hdr);
}
@@ -963,7 +965,7 @@
pos, offset);
if (hdr != NULL)
- hdr->len = htons(attr_len);
+ hdr->len = cpu_to_be16(attr_len);
if (*offset > 0)
break;
@@ -1062,7 +1064,7 @@
struct avrcp_header *pdu,
uint8_t transaction)
{
- uint16_t len = ntohs(pdu->params_len);
+ uint16_t len = be16_to_cpu(pdu->params_len);
unsigned int i;
if (len != 1)
@@ -1077,7 +1079,8 @@
company_ids[i]);
}
- pdu->params_len = htons(2 + (3 * G_N_ELEMENTS(company_ids)));
+ pdu->params_len = cpu_to_be16(2 +
+ (3 * G_N_ELEMENTS(company_ids)));
pdu->params[1] = G_N_ELEMENTS(company_ids);
return AVC_CTYPE_STABLE;
@@ -1090,12 +1093,12 @@
}
}
- pdu->params_len = htons(2 + pdu->params[1]);
+ pdu->params_len = cpu_to_be16(2 + pdu->params[1]);
return AVC_CTYPE_STABLE;
}
err:
- pdu->params_len = htons(1);
+ pdu->params_len = cpu_to_be16(1);
pdu->params[0] = AVRCP_STATUS_INVALID_PARAM;
return AVC_CTYPE_REJECTED;
@@ -1114,11 +1117,11 @@
uint8_t transaction)
{
struct avrcp_player *player = target_get_player(session);
- uint16_t len = ntohs(pdu->params_len);
+ uint16_t len = be16_to_cpu(pdu->params_len);
unsigned int i;
if (len != 0) {
- pdu->params_len = htons(1);
+ pdu->params_len = cpu_to_be16(1);
pdu->params[0] = AVRCP_STATUS_INVALID_PARAM;
return AVC_CTYPE_REJECTED;
}
@@ -1136,7 +1139,7 @@
done:
pdu->params[0] = len;
- pdu->params_len = htons(len + 1);
+ pdu->params_len = cpu_to_be16(len + 1);
return AVC_CTYPE_STABLE;
}
@@ -1146,7 +1149,7 @@
uint8_t transaction)
{
struct avrcp_player *player = target_get_player(session);
- uint16_t len = ntohs(pdu->params_len);
+ uint16_t len = be16_to_cpu(pdu->params_len);
unsigned int i;
if (len != 1)
@@ -1161,12 +1164,12 @@
pdu->params[i] = i;
pdu->params[0] = len;
- pdu->params_len = htons(len + 1);
+ pdu->params_len = cpu_to_be16(len + 1);
return AVC_CTYPE_STABLE;
err:
- pdu->params_len = htons(1);
+ pdu->params_len = cpu_to_be16(1);
pdu->params[0] = AVRCP_STATUS_INVALID_PARAM;
return AVC_CTYPE_REJECTED;
}
@@ -1215,7 +1218,7 @@
uint8_t transaction)
{
struct avrcp_player *player = target_get_player(session);
- uint16_t len = ntohs(pdu->params_len);
+ uint16_t len = be16_to_cpu(pdu->params_len);
uint64_t identifier = get_le64(&pdu->params[0]);
uint16_t pos;
uint8_t nattr;
@@ -1273,11 +1276,11 @@
}
pdu->params[0] = len;
- pdu->params_len = htons(pos);
+ pdu->params_len = cpu_to_be16(pos);
return AVC_CTYPE_STABLE;
err:
- pdu->params_len = htons(1);
+ pdu->params_len = cpu_to_be16(1);
pdu->params[0] = AVRCP_STATUS_INVALID_PARAM;
return AVC_CTYPE_REJECTED;
}
@@ -1287,7 +1290,7 @@
uint8_t transaction)
{
struct avrcp_player *player = target_get_player(session);
- uint16_t len = ntohs(pdu->params_len);
+ uint16_t len = be16_to_cpu(pdu->params_len);
uint8_t *settings;
unsigned int i;
@@ -1298,7 +1301,7 @@
* Save a copy of requested settings because we can override them
* while responding
*/
- settings = g_memdup(&pdu->params[1], pdu->params[0]);
+ settings = util_memdup(&pdu->params[1], pdu->params[0]);
len = 0;
/*
@@ -1323,11 +1326,11 @@
pdu->params[++len] = val;
}
- g_free(settings);
+ free(settings);
if (len) {
pdu->params[0] = len / 2;
- pdu->params_len = htons(len + 1);
+ pdu->params_len = cpu_to_be16(len + 1);
return AVC_CTYPE_STABLE;
}
@@ -1335,7 +1338,7 @@
error("No valid attributes in request");
err:
- pdu->params_len = htons(1);
+ pdu->params_len = cpu_to_be16(1);
pdu->params[0] = AVRCP_STATUS_INVALID_PARAM;
return AVC_CTYPE_REJECTED;
@@ -1346,7 +1349,7 @@
uint8_t transaction)
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/profiles/audio/media.c
^
|
@@ -244,6 +244,16 @@
return NULL;
}
+static void endpoint_remove_transport(struct media_endpoint *endpoint,
+ struct media_transport *transport)
+{
+ if (!endpoint || !transport)
+ return;
+
+ endpoint->transports = g_slist_remove(endpoint->transports, transport);
+ media_transport_destroy(transport);
+}
+
static void clear_configuration(struct media_endpoint *endpoint,
struct media_transport *transport)
{
@@ -263,8 +273,7 @@
DBUS_TYPE_INVALID);
g_dbus_send_message(btd_get_dbus_connection(), msg);
done:
- endpoint->transports = g_slist_remove(endpoint->transports, transport);
- media_transport_destroy(transport);
+ endpoint_remove_transport(endpoint, transport);
}
static void clear_endpoint(struct media_endpoint *endpoint)
@@ -304,12 +313,8 @@
if (dbus_message_is_method_call(request->msg,
MEDIA_ENDPOINT_INTERFACE,
- "SetConfiguration")) {
- if (request->transport == NULL)
- error("Expected to destroy transport");
- else
- media_transport_destroy(request->transport);
- }
+ "SetConfiguration"))
+ endpoint_remove_transport(endpoint, request->transport);
dbus_error_free(&err);
goto done;
@@ -454,11 +459,11 @@
target_player = avrcp_get_target_player_by_device(device);
if (!target_player)
- return -1;
+ goto done;
adapter = find_adapter(device);
if (!adapter)
- return -1;
+ goto done;
for (l = adapter->players; l; l = l->next) {
struct media_player *mp = l->data;
@@ -467,7 +472,9 @@
return mp->volume;
}
- return -1;
+done:
+ /* If media_player doesn't exists use device_volume */
+ return btd_device_get_volume(device);
}
static gboolean set_configuration(struct media_endpoint *endpoint,
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/profiles/audio/player.c
^
|
@@ -85,7 +85,6 @@
char *status;
uint32_t position;
GTimer *progress;
- guint process_id;
struct player_callback *cb;
GSList *pending;
GSList *folders;
@@ -1233,9 +1232,6 @@
if (mp->settings)
g_hash_table_unref(mp->settings);
- if (mp->process_id > 0)
- g_source_remove(mp->process_id);
-
if (mp->scope)
g_dbus_unregister_interface(btd_get_dbus_connection(),
mp->path,
@@ -1308,9 +1304,10 @@
g_hash_table_replace(mp->track, g_strdup("Duration"), value);
- g_dbus_emit_property_changed(btd_get_dbus_connection(),
+ g_dbus_emit_property_changed_full(btd_get_dbus_connection(),
mp->path, MEDIA_PLAYER_INTERFACE,
- "Track");
+ "Track",
+ G_DBUS_PROPERTY_CHANGED_FLAG_FLUSH);
}
void media_player_set_position(struct media_player *mp, uint32_t position)
@@ -1395,26 +1392,20 @@
g_timer_start(mp->progress);
}
-static gboolean process_metadata_changed(void *user_data)
+static gboolean remove_metadata(void *key, void *value, void *user_data)
{
- struct media_player *mp = user_data;
- const char *item;
-
- mp->process_id = 0;
-
- g_dbus_emit_property_changed(btd_get_dbus_connection(),
- mp->path, MEDIA_PLAYER_INTERFACE,
- "Track");
-
- item = g_hash_table_lookup(mp->track, "Item");
- if (item == NULL)
+ if (!strcmp(key, "Duration"))
return FALSE;
- g_dbus_emit_property_changed(btd_get_dbus_connection(),
- item, MEDIA_ITEM_INTERFACE,
- "Metadata");
+ return strcmp(key, "Item") ? TRUE : FALSE;
+}
+
+void media_player_clear_metadata(struct media_player *mp)
+{
+ if (!mp)
+ return;
- return FALSE;
+ g_hash_table_foreach_remove(mp->track, remove_metadata, NULL);
}
void media_player_set_metadata(struct media_player *mp,
@@ -1433,14 +1424,31 @@
return;
}
- if (mp->process_id == 0) {
- g_hash_table_remove_all(mp->track);
- mp->process_id = g_idle_add(process_metadata_changed, mp);
- }
-
g_hash_table_replace(mp->track, g_strdup(key), value);
}
+void media_player_metadata_changed(struct media_player *mp)
+{
+ char *item;
+
+ if (!mp)
+ return;
+
+ g_dbus_emit_property_changed_full(btd_get_dbus_connection(),
+ mp->path, MEDIA_PLAYER_INTERFACE,
+ "Track",
+ G_DBUS_PROPERTY_CHANGED_FLAG_FLUSH);
+
+ item = g_hash_table_lookup(mp->track, "Item");
+ if (item == NULL)
+ return;
+
+ g_dbus_emit_property_changed_full(btd_get_dbus_connection(),
+ item, MEDIA_ITEM_INTERFACE,
+ "Metadata",
+ G_DBUS_PROPERTY_CHANGED_FLAG_FLUSH);
+}
+
void media_player_set_type(struct media_player *mp, const char *type)
{
if (g_strcmp0(mp->type, type) == 0)
@@ -1962,6 +1970,7 @@
{
struct media_folder *folder = mp->playlist;
struct media_item *item;
+ char *path;
DBG("%" PRIu64 "", uid);
@@ -1980,16 +1989,11 @@
mp->track = g_hash_table_ref(item->metadata);
}
- if (item == g_hash_table_lookup(mp->track, "Item"))
+ path = g_hash_table_lookup(mp->track, "Item");
+ if (path && !strcmp(path, item->path))
return item;
- if (mp->process_id == 0) {
- g_hash_table_remove_all(mp->track);
- mp->process_id = g_idle_add(process_metadata_changed, mp);
- }
-
- g_hash_table_replace(mp->track, g_strdup("Item"),
- g_strdup(item->path));
+ g_hash_table_replace(mp->track, g_strdup("Item"), g_strdup(item->path));
return item;
}
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/profiles/audio/player.h
^
|
@@ -70,9 +70,11 @@
const char *value);
const char *media_player_get_status(struct media_player *mp);
void media_player_set_status(struct media_player *mp, const char *status);
+void media_player_clear_metadata(struct media_player *mp);
void media_player_set_metadata(struct media_player *mp,
struct media_item *item, const char *key,
void *data, size_t len);
+void media_player_metadata_changed(struct media_player *mp);
void media_player_set_type(struct media_player *mp, const char *type);
void media_player_set_subtype(struct media_player *mp, const char *subtype);
void media_player_set_name(struct media_player *mp, const char *name);
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/profiles/audio/transport.c
^
|
@@ -949,6 +949,7 @@
if (dev == NULL)
return -1;
+ /* Attempt to locate the transport to get its volume */
for (l = transports; l; l = l->next) {
struct media_transport *transport = l->data;
if (transport->device != dev)
@@ -959,7 +960,8 @@
return media_transport_get_volume(transport);
}
- return 0;
+ /* If transport volume doesn't exists use device_volume */
+ return btd_device_get_volume(dev);
}
void media_transport_update_device_volume(struct btd_device *dev,
@@ -970,13 +972,19 @@
if (dev == NULL || volume < 0)
return;
+ /* Attempt to locate the transport to set its volume */
for (l = transports; l; l = l->next) {
struct media_transport *transport = l->data;
if (transport->device != dev)
continue;
/* Volume is A2DP only */
- if (media_endpoint_get_sep(transport->endpoint))
+ if (media_endpoint_get_sep(transport->endpoint)) {
media_transport_update_volume(transport, volume);
+ return;
+ }
}
+
+ /* If transport volume doesn't exists add to device_volume */
+ btd_device_set_volume(dev, volume);
}
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/profiles/battery/bas.c
^
|
@@ -62,7 +62,7 @@
{
bt_bas_detach(bas);
- g_free(bas->primary);
+ free(bas->primary);
queue_destroy(bas->gatt_op, (void *) destroy_gatt_req);
free(bas);
}
@@ -75,7 +75,7 @@
bas->gatt_op = queue_new();
if (primary)
- bas->primary = g_memdup(primary, sizeof(*bas->primary));
+ bas->primary = util_memdup(primary, sizeof(*bas->primary));
return bt_bas_ref(bas);
}
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/profiles/battery/battery.c
^
|
@@ -66,7 +66,7 @@
gatt_db_unref(batt->db);
bt_gatt_client_unref(batt->client);
btd_device_unref(batt->device);
- g_free (batt->initial_value);
+ free(batt->initial_value);
if (batt->battery)
btd_battery_unregister(batt->battery);
g_free(batt);
@@ -159,7 +159,7 @@
if (!length)
return;
- batt->initial_value = g_memdup(value, length);
+ batt->initial_value = util_memdup(value, length);
/* request notify */
batt->batt_level_cb_id =
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/profiles/deviceinfo/dis.c
^
|
@@ -72,7 +72,7 @@
{
bt_dis_detach(dis);
- g_free(dis->primary);
+ free(dis->primary);
queue_destroy(dis->gatt_op, (void *) destroy_gatt_req);
g_free(dis);
}
@@ -143,7 +143,7 @@
dis->gatt_op = queue_new();
if (primary)
- dis->primary = g_memdup(primary, sizeof(*dis->primary));
+ dis->primary = util_memdup(primary, sizeof(*dis->primary));
return bt_dis_ref(dis);
}
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/profiles/gap/gas.c
^
|
@@ -142,10 +142,10 @@
static void handle_appearance(struct gas *gas, uint16_t value_handle)
{
- uint16_t value;
+ uint16_t value;
- if (!device_get_appearance(gas->device, &value))
- return;
+ if (!device_get_appearance(gas->device, &value))
+ return;
if (!bt_gatt_client_read_value(gas->client, value_handle,
read_appearance_cb, gas, NULL))
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/profiles/health/hdp.c
^
|
@@ -16,7 +16,6 @@
#include <stdint.h>
#include <stdbool.h>
#include <unistd.h>
-#include <sys/random.h>
#include <glib.h>
@@ -33,6 +32,7 @@
#include "src/device.h"
#include "src/sdpd.h"
#include "src/shared/timeout.h"
+#include "src/shared/util.h"
#include "btio/btio.h"
#include "hdp_types.h"
@@ -1490,7 +1490,7 @@
if (!buf)
return NULL;
- if (getrandom(buf, HDP_ECHO_LEN, 0) < 0) {
+ if (util_getrandom(buf, HDP_ECHO_LEN, 0) < 0) {
g_free(buf);
return NULL;
}
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/profiles/health/mcap.c
^
|
@@ -19,7 +19,6 @@
#include <errno.h>
#include <unistd.h>
#include <time.h>
-#include <sys/random.h>
#include <glib.h>
@@ -28,6 +27,7 @@
#include "btio/btio.h"
#include "src/log.h"
#include "src/shared/timeout.h"
+#include "src/shared/util.h"
#include "mcap.h"
@@ -1905,7 +1905,7 @@
mcl->state = MCL_IDLE;
bacpy(&mcl->addr, addr);
set_default_cb(mcl);
- if (getrandom(&val, sizeof(val), 0) < 0) {
+ if (util_getrandom(&val, sizeof(val), 0) < 0) {
mcap_instance_unref(mcl->mi);
g_free(mcl);
return FALSE;
@@ -2049,7 +2049,7 @@
mcl->mi = mcap_instance_ref(mi);
bacpy(&mcl->addr, &dst);
set_default_cb(mcl);
- if (getrandom(&val, sizeof(val), 0) < 0) {
+ if (util_getrandom(&val, sizeof(val), 0) < 0) {
mcap_instance_unref(mcl->mi);
g_free(mcl);
goto drop;
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/profiles/input/device.c
^
|
@@ -593,6 +593,13 @@
if (idev->intr_io && !(cond & G_IO_NVAL))
g_io_channel_shutdown(idev->intr_io, TRUE, NULL);
+ /* It's possible this is triggered while the intr channel is not even
+ * connected yet, therefore we are still in the connecting state.
+ */
+ if (btd_service_get_state(idev->service) ==
+ BTD_SERVICE_STATE_CONNECTING)
+ btd_service_connecting_complete(idev->service, -EIO);
+
if (!idev->intr_io && idev->virtual_cable_unplug)
virtual_cable_unplug(idev);
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/profiles/input/hog-lib.c
^
|
@@ -23,6 +23,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
+#include <inttypes.h>
#include <glib.h>
@@ -80,7 +81,8 @@
struct bt_uhid *uhid;
int uhid_fd;
bool uhid_created;
- gboolean has_report_id;
+ bool uhid_start;
+ uint64_t uhid_flags;
uint16_t bcdhid;
uint8_t bcountrycode;
uint16_t proto_mode_handle;
@@ -90,6 +92,7 @@
uint16_t getrep_id;
unsigned int setrep_att;
uint16_t setrep_id;
+ unsigned int report_map_id;
struct bt_scpp *scpp;
struct bt_dis *dis;
struct queue *bas;
@@ -97,6 +100,7 @@
struct queue *gatt_op;
struct gatt_db *gatt_db;
struct gatt_db_attribute *report_map_attr;
+ struct queue *input;
};
struct report_map {
@@ -106,6 +110,7 @@
struct report {
struct bt_hog *hog;
+ bool numbered;
uint8_t id;
uint8_t type;
uint16_t handle;
@@ -146,13 +151,34 @@
return queue_push_head(hog->gatt_op, req);
}
-static void destroy_gatt_req(struct gatt_request *req)
+static void destroy_gatt_req(void *data)
{
- queue_remove(req->hog->gatt_op, req);
+ struct gatt_request *req = data;
+
bt_hog_unref(req->hog);
free(req);
}
+static void read_report_map(struct bt_hog *hog);
+
+static void remove_gatt_req(struct gatt_request *req, uint8_t status)
+{
+ struct bt_hog *hog = req->hog;
+
+ queue_remove(hog->gatt_op, req);
+
+ if (!status && queue_isempty(hog->gatt_op)) {
+ /* Report Map must be read last since that can result
+ * in uhid being created and the driver may start to
+ * use UHID_SET_REPORT which requires the report->id to
+ * be known what attribute to send to.
+ */
+ read_report_map(hog);
+ }
+
+ destroy_gatt_req(req);
+}
+
static void write_char(struct bt_hog *hog, GAttrib *attrib, uint16_t handle,
const uint8_t *value, size_t vlen,
GAttribResultFunc func,
@@ -178,27 +204,31 @@
}
}
-static void read_char(struct bt_hog *hog, GAttrib *attrib, uint16_t handle,
- GAttribResultFunc func, gpointer user_data)
+static unsigned int read_char(struct bt_hog *hog, GAttrib *attrib,
+ uint16_t handle, GAttribResultFunc func,
+ gpointer user_data)
{
struct gatt_request *req;
unsigned int id;
req = create_request(hog, user_data);
if (!req)
- return;
+ return 0;
id = gatt_read_char(attrib, handle, func, req);
if (!id) {
error("hog: Could not read char");
- return;
+ return 0;
}
if (!set_and_store_gatt_req(hog, req, id)) {
error("hog: Failed to queue read char req");
g_attrib_cancel(attrib, id);
free(req);
+ return 0;
}
+
+ return id;
}
static void discover_desc(struct bt_hog *hog, GAttrib *attrib,
@@ -318,7 +348,14 @@
ev.type = UHID_INPUT;
buf = ev.u.input.data;
- if (hog->has_report_id) {
+ /* BLUETOOTH SPECIFICATION Page 16 of 26
+ * HID Service Specification
+ *
+ * Report ID shall be nonzero in a Report Reference characteristic
+ * descriptor where there is more than one instance of the Report
+ * characteristic for any given Report Type.
+ */
+ if (report->numbered && report->id) {
buf[0] = report->id;
len = MIN(len, sizeof(ev.u.input.data) - 1);
memcpy(buf + 1, pdu, len);
@@ -329,11 +366,18 @@
ev.u.input.size = len;
}
- err = bt_uhid_send(hog->uhid, &ev);
- if (err < 0) {
- error("bt_uhid_send: %s (%d)", strerror(-err), -err);
+ /* If uhid had not sent UHID_START yet queue up the input */
+ if (!hog->uhid_created || !hog->uhid_start) {
+ if (!hog->input)
+ hog->input = queue_new();
+
+ queue_push_tail(hog->input, util_memdup(&ev, sizeof(ev)));
return;
}
+
+ err = bt_uhid_send(hog->uhid, &ev);
+ if (err < 0)
+ error("bt_uhid_send: %s (%d)", strerror(-err), -err);
}
static void report_ccc_written_cb(guint8 status, const guint8 *pdu,
@@ -343,16 +387,14 @@
struct report *report = req->user_data;
struct bt_hog *hog = report->hog;
- destroy_gatt_req(req);
-
if (status != 0) {
error("Write report characteristic descriptor failed: %s",
att_ecode2str(status));
- return;
+ goto remove;
}
if (report->notifyid)
- return;
+ goto remove;
report->notifyid = g_attrib_register(hog->attrib,
ATT_OP_HANDLE_NOTIFY,
@@ -360,6 +402,9 @@
report_value_cb, report, NULL);
DBG("Report characteristic descriptor written: notifications enabled");
+
+remove:
+ remove_gatt_req(req, status);
}
static void write_ccc(struct bt_hog *hog, GAttrib *attrib, uint16_t handle,
@@ -379,14 +424,15 @@
struct gatt_request *req = user_data;
struct report *report = req->user_data;
- destroy_gatt_req(req);
-
if (status != 0) {
error("Error reading CCC value: %s", att_ecode2str(status));
- return;
+ goto remove;
}
write_ccc(report->hog, report->hog->attrib, report->ccc_handle, report);
+
+remove:
+ remove_gatt_req(req, status);
}
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/profiles/scanparam/scpp.c
^
|
@@ -91,7 +91,7 @@
{
bt_scpp_detach(scan);
- g_free(scan->primary);
+ free(scan->primary);
queue_destroy(scan->gatt_op, NULL); /* cleared in bt_scpp_detach */
g_free(scan);
}
@@ -110,7 +110,7 @@
scan->gatt_op = queue_new();
if (primary)
- scan->primary = g_memdup(primary, sizeof(*scan->primary));
+ scan->primary = util_memdup(primary, sizeof(*scan->primary));
return bt_scpp_ref(scan);
}
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/src/adapter.c
^
|
@@ -62,7 +62,6 @@
#include "attrib/gattrib.h"
#include "attrib/att.h"
#include "attrib/gatt.h"
-#include "attrib-server.h"
#include "gatt-database.h"
#include "advertising.h"
#include "adv_monitor.h"
@@ -142,6 +141,13 @@
.str = "a6695ace-ee7f-4fb9-881a-5fac66c629af"
};
+/* 6fbaf188-05e0-496a-9885-d6ddfdb4e03e */
+static const struct mgmt_exp_uuid iso_socket_uuid = {
+ .val = { 0x3e, 0xe0, 0xb4, 0xfd, 0xdd, 0xd6, 0x85, 0x98,
+ 0x6a, 0x49, 0xe0, 0x05, 0x88, 0xf1, 0xba, 0x6f },
+ .str = "6fbaf188-05e0-496a-9885-d6ddfdb4e03e"
+};
+
static DBusConnection *dbus_conn = NULL;
static uint32_t kernel_features = 0;
@@ -312,15 +318,6 @@
struct oob_handler *oob_handler;
- unsigned int load_ltks_id;
- unsigned int load_ltks_timeout;
-
- unsigned int confirm_name_id;
- unsigned int confirm_name_timeout;
-
- unsigned int pair_device_id;
- unsigned int pair_device_timeout;
-
unsigned int db_id; /* Service event handler for GATT db */
bool is_default; /* true if adapter is default one */
@@ -545,9 +542,8 @@
g_key_file_set_string(key_file, "General", "Alias",
adapter->stored_alias);
- snprintf(filename, PATH_MAX, STORAGEDIR "/%s/settings",
+ create_filename(filename, PATH_MAX, "/%s/settings",
btd_adapter_get_storage_dir(adapter));
-
create_file(filename, 0600);
str = g_key_file_to_data(key_file, &length, NULL);
@@ -827,10 +823,6 @@
g_dbus_emit_property_changed(dbus_conn, adapter->path,
ADAPTER_INTERFACE, "Alias");
-
- attrib_gap_set(adapter, GATT_CHARAC_DEVICE_NAME,
- (const uint8_t *) adapter->current_alias,
- strlen(adapter->current_alias));
}
static void set_local_name_complete(uint8_t status, uint16_t length,
@@ -1234,6 +1226,13 @@
{
int ret;
+ /*
+ * If the controller does not support BR/EDR operation,
+ * there is no point in trying to add SDP records.
+ */
+ if (btd_opts.mode == BT_MODE_LE)
+ return -ENOTSUP;
+
DBG("%s", adapter->path);
ret = add_record_to_server(&adapter->bdaddr, rec);
@@ -1247,10 +1246,17 @@
void adapter_service_remove(struct btd_adapter *adapter, uint32_t handle)
{
- sdp_record_t *rec = sdp_record_find(handle);
+ sdp_record_t *rec;
+ /*
+ * If the controller does not support BR/EDR operation,
+ * there is no point in trying to remote SDP records.
+ */
+ if (btd_opts.mode == BT_MODE_LE)
+ return;
DBG("%s", adapter->path);
+ rec = sdp_record_find(handle);
if (!rec)
return;
@@ -1993,7 +1999,7 @@
return true;
/* Reset discoverable filter if already set */
- if (enable && (adapter->current_settings & MGMT_OP_SET_DISCOVERABLE))
+ if (enable && (adapter->current_settings & MGMT_SETTING_DISCOVERABLE))
return true;
adapter->discovery_discoverable = enable;
@@ -2229,7 +2235,7 @@
/* Only attempt to overwrite current discoverable setting when not
* discoverable.
*/
- if (!(adapter->current_settings & MGMT_OP_SET_DISCOVERABLE)) {
+ if (!(adapter->current_settings & MGMT_SETTING_DISCOVERABLE)) {
GSList *l;
for (l = adapter->discovery_list; l; l = g_slist_next(l)) {
@@ -3445,7 +3451,7 @@
/* continue with service discovery and connection */
btd_device_set_temporary(device, false);
- device_update_last_seen(device, data->dst_type);
+ device_update_last_seen(device, data->dst_type, true);
if (data->dst_type != BDADDR_BREDR){
g_io_channel_set_close_on_unref(io, FALSE);
@@ -3608,16 +3614,14 @@
static guint bt_uuid_hash(gconstpointer key)
{
const bt_uuid_t *uuid = key;
- bt_uuid_t uuid_128;
- uint64_t *val;
+ uint64_t uuid_128[2];
if (!uuid)
return 0;
- bt_uuid_to_uuid128(uuid, &uuid_128);
- val = (uint64_t *)&uuid_128.value.u128;
+ bt_uuid_to_uuid128(uuid, (bt_uuid_t *)uuid_128);
- return g_int64_hash(val) ^ g_int64_hash(val+1);
+ return g_int64_hash(uuid_128) ^ g_int64_hash(uuid_128+1);
}
static gboolean bt_uuid_equal(gconstpointer v1, gconstpointer v2)
@@ -3983,7 +3987,7 @@
char *str_irk;
int ret;
- snprintf(filename, PATH_MAX, STORAGEDIR "/%s/identity",
+ create_filename(filename, PATH_MAX, "/%s/identity",
btd_adapter_get_storage_dir(adapter));
key_file = g_key_file_new();
@@ -4140,21 +4144,6 @@
adapter->dev_id);
}
-static bool load_ltks_timeout(gpointer user_data)
-{
- struct btd_adapter *adapter = user_data;
-
- btd_error(adapter->dev_id, "Loading LTKs timed out for hci%u",
- adapter->dev_id);
-
- adapter->load_ltks_timeout = 0;
-
- mgmt_cancel(adapter->mgmt, adapter->load_ltks_id);
- adapter->load_ltks_id = 0;
-
- return FALSE;
-}
-
static void load_ltks_complete(uint8_t status, uint16_t length,
const void *param, void *user_data)
{
@@ -4166,11 +4155,6 @@
adapter->dev_id, mgmt_errstr(status), status);
}
- adapter->load_ltks_id = 0;
-
- timeout_remove(adapter->load_ltks_timeout);
- adapter->load_ltks_timeout = 0;
-
DBG("LTKs loaded for hci%u", adapter->dev_id);
}
@@ -4243,27 +4227,18 @@
}
}
- adapter->load_ltks_id = mgmt_send(adapter->mgmt,
- MGMT_OP_LOAD_LONG_TERM_KEYS,
- adapter->dev_id, cp_size, cp,
- load_ltks_complete, adapter, NULL);
-
- g_free(cp);
-
- if (adapter->load_ltks_id == 0) {
- btd_error(adapter->dev_id, "Failed to load LTKs for hci%u",
- adapter->dev_id);
- return;
- }
-
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/src/adapter.h
^
|
@@ -254,6 +254,17 @@
bool btd_le_connect_before_pairing(void);
+enum experimental_features {
+ EXP_FEAT_DEBUG = 1 << 0,
+ EXP_FEAT_LE_SIMULT_ROLES = 1 << 1,
+ EXP_FEAT_BQR = 1 << 2,
+ EXP_FEAT_RPA_RESOLUTION = 1 << 3,
+ EXP_FEAT_CODEC_OFFLOAD = 1 << 4,
+ EXP_FEAT_ISO_SOCKET = 1 << 5,
+};
+
+bool btd_adapter_has_exp_feature(struct btd_adapter *adapter, uint32_t feature);
+
enum kernel_features {
KERNEL_CONN_CONTROL = 1 << 0,
KERNEL_BLOCKED_KEYS_SUPPORTED = 1 << 1,
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/src/advertising.c
^
|
@@ -533,7 +533,15 @@
dbus_message_iter_get_basic(iter, &name);
free(client->name);
- client->name = strdup(name);
+
+ /* Treat empty string the same as omitting since there is no point on
+ * adding a empty name as AD data as it just take space that could be
+ * used for something else.
+ */
+ if (name[0] != '\0')
+ client->name = strdup(name);
+ else
+ client->name = NULL;
return true;
}
@@ -768,6 +776,18 @@
bt_ad_add_appearance(client->data, appearance);
}
+ /* Scan response shall not be used when connectable and setting a
+ * secondary PHY since that would end up using EA types instead of
+ * legacy which doesn't support being connectable and scannable
+ * simultaneously.
+ */
+ if ((*flags & MGMT_ADV_FLAG_CONNECTABLE) &&
+ (*flags & MGMT_ADV_FLAG_SEC_MASK) &&
+ client->name) {
+ *flags &= ~MGMT_ADV_FLAG_LOCAL_NAME;
+ bt_ad_add_name(client->data, client->name);
+ }
+
return bt_ad_generate(client->data, len);
}
@@ -799,6 +819,15 @@
return false;
}
+ /* Scan response shall not be used when connectable and setting a
+ * secondary PHY since that would end up using EA types instead of
+ * legacy which doesn't support being connectable and scannable
+ * simultaneously.
+ */
+ if (flags & MGMT_ADV_FLAG_CONNECTABLE &&
+ flags & MGMT_ADV_FLAG_SEC_MASK)
+ return false;
+
return true;
}
@@ -1242,7 +1271,7 @@
uint8_t *adv_data = NULL;
size_t adv_data_len;
uint8_t *scan_rsp = NULL;
- size_t scan_rsp_len = -1;
+ size_t scan_rsp_len = 0;
uint32_t flags = 0;
unsigned int mgmt_ret;
dbus_int16_t tx_power;
@@ -1273,11 +1302,13 @@
goto fail;
}
- scan_rsp = generate_scan_rsp(client, &flags, &scan_rsp_len);
- if ((!scan_rsp && scan_rsp_len) ||
- scan_rsp_len > rp->max_scan_rsp_len) {
- error("Scan data couldn't be generated.");
- goto fail;
+ if (adv_client_has_scan_response(client, flags)) {
+ scan_rsp = generate_scan_rsp(client, &flags, &scan_rsp_len);
+ if ((!scan_rsp && scan_rsp_len) ||
+ scan_rsp_len > rp->max_scan_rsp_len) {
+ error("Scan data couldn't be generated.");
+ goto fail;
+ }
}
param_len = sizeof(struct mgmt_cp_add_advertising) + adv_data_len +
@@ -1293,7 +1324,9 @@
cp->adv_data_len = adv_data_len;
cp->scan_rsp_len = scan_rsp_len;
memcpy(cp->data, adv_data, adv_data_len);
- memcpy(cp->data + adv_data_len, scan_rsp, scan_rsp_len);
+
+ if (scan_rsp)
+ memcpy(cp->data + adv_data_len, scan_rsp, scan_rsp_len);
free(adv_data);
free(scan_rsp);
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/src/bluetooth.service.in
^
|
@@ -15,8 +15,26 @@
Restart=on-failure
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
LimitNPROC=1
+
+# Filesystem lockdown
ProtectHome=true
-ProtectSystem=full
+ProtectSystem=strict
+PrivateTmp=true
+ProtectKernelTunables=true
+ProtectControlGroups=true
+StateDirectory=bluetooth
+StateDirectoryMode=0700
+ConfigurationDirectory=bluetooth
+ConfigurationDirectoryMode=0555
+
+# Execute Mappings
+MemoryDenyWriteExecute=true
+
+# Privilege escalation
+NoNewPrivileges=true
+
+# Real-time
+RestrictRealtime=true
[Install]
WantedBy=bluetooth.target
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/src/bluetoothd.rst.in
^
|
@@ -67,6 +67,10 @@
-E, --experimental Enable experimental interfaces. Those interfaces are not
guaranteed to be compatible or present in future releases.
+-K, --kernel=<uuid1>,<uuid2>,...
+ Enable Kernel experimental features. Kernel experimental features are
+ considered unstable and may be removed from future kernel releases.
+
FILES
=====
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/src/btd.h
^
|
@@ -113,7 +113,8 @@
gboolean debug_keys;
gboolean fast_conn;
gboolean refresh_discovery;
- struct queue *experimental;
+ gboolean experimental;
+ struct queue *kernel;
uint16_t did_source;
uint16_t did_vendor;
@@ -121,6 +122,7 @@
uint16_t did_version;
bt_mode_t mode;
+ uint16_t max_adapters;
bt_gatt_cache_t gatt_cache;
uint16_t gatt_mtu;
uint8_t gatt_channels;
@@ -144,6 +146,6 @@
void rfkill_exit(void);
GKeyFile *btd_get_main_conf(void);
-bool btd_experimental_enabled(const char *uuid);
+bool btd_kernel_experimental_enabled(const char *uuid);
void btd_exit(void);
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/src/device.c
^
|
@@ -62,8 +62,8 @@
#include "agent.h"
#include "textfile.h"
#include "storage.h"
-#include "attrib-server.h"
#include "eir.h"
+#include "settings.h"
#define DISCONNECT_TIMER 2
#define DISCOVERY_TIMER 1
@@ -75,11 +75,6 @@
#define RSSI_THRESHOLD 8
-#define GATT_PRIM_SVC_UUID_STR "2800"
-#define GATT_SND_SVC_UUID_STR "2801"
-#define GATT_INCLUDE_UUID_STR "2802"
-#define GATT_CHARAC_UUID_STR "2803"
-
static DBusConnection *dbus_conn = NULL;
static unsigned service_state_cb_id;
@@ -167,6 +162,9 @@
bool bonded;
bool connected;
bool svc_resolved;
+ bool initiator;
+ bool connectable;
+ time_t last_seen;
};
struct csrk_info {
@@ -187,6 +185,7 @@
uint8_t conn_bdaddr_type;
bdaddr_t bdaddr;
uint8_t bdaddr_type;
+ bool rpa;
char *path;
bool bredr;
bool le;
@@ -266,9 +265,6 @@
sdp_list_t *tmp_records;
- time_t bredr_seen;
- time_t le_seen;
-
gboolean trusted;
gboolean blocked;
gboolean auto_connect;
@@ -283,6 +279,8 @@
guint store_id;
time_t name_resolve_failed_time;
+
+ int8_t volume;
};
static const uint16_t uuid_list[] = {
@@ -305,6 +303,16 @@
return &dev->le_state;
}
+static bool get_initiator(struct btd_device *dev)
+{
+ if (dev->le_state.connected)
+ return dev->le_state.initiator;
+ if (dev->bredr_state.connected)
+ return dev->bredr_state.initiator;
+
+ return false;
+}
+
static GSList *find_service_with_profile(GSList *list, struct btd_profile *p)
{
GSList *l;
@@ -402,7 +410,7 @@
device->store_id = 0;
ba2str(&device->bdaddr, device_addr);
- snprintf(filename, PATH_MAX, STORAGEDIR "/%s/%s/info",
+ create_filename(filename, PATH_MAX, "/%s/%s/info",
btd_adapter_get_storage_dir(device->adapter),
device_addr);
create_file(filename, 0600);
@@ -545,7 +553,7 @@
}
ba2str(&dev->bdaddr, d_addr);
- snprintf(filename, PATH_MAX, STORAGEDIR "/%s/cache/%s",
+ create_filename(filename, PATH_MAX, "/%s/cache/%s",
btd_adapter_get_storage_dir(dev->adapter), d_addr);
create_file(filename, 0600);
@@ -594,7 +602,7 @@
}
ba2str(&dev->bdaddr, d_addr);
- snprintf(filename, PATH_MAX, STORAGEDIR "/%s/cache/%s",
+ create_filename(filename, PATH_MAX, "/%s/cache/%s",
btd_adapter_get_storage_dir(dev->adapter), d_addr);
create_file(filename, 0600);
@@ -1052,6 +1060,22 @@
return TRUE;
}
+static gboolean dev_property_get_bonded(const GDBusPropertyTable *property,
+ DBusMessageIter *iter, void *data)
+{
+ struct btd_device *dev = data;
+ dbus_bool_t val;
+
+ if (dev->bredr_state.bonded || dev->le_state.bonded)
+ val = TRUE;
+ else
+ val = FALSE;
+
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_BOOLEAN, &val);
+
+ return TRUE;
+}
+
static gboolean dev_property_get_legacy(const GDBusPropertyTable *property,
DBusMessageIter *iter, void *data)
{
@@ -1441,6 +1465,12 @@
void device_set_wake_support(struct btd_device *device, bool wake_support)
{
+ if (device->rpa && !btd_adapter_has_exp_feature(device->adapter,
+ EXP_FEAT_RPA_RESOLUTION)) {
+ warn("Unable to set wake_support without RPA resolution");
+ return;
+ }
+
device->wake_support = wake_support;
/* If wake configuration has not been made yet, set the initial
@@ -1560,6 +1590,8 @@
return;
}
+ dbus_message_iter_get_basic(value, &b);
+
/* Emit busy or success depending on current value. */
if (b == device->pending_wake_allowed) {
if (device->wake_allowed == device->pending_wake_allowed)
@@ -1572,7 +1604,6 @@
return;
}
- dbus_message_iter_get_basic(value, &b);
device_set_wake_override(device, b);
device_set_wake_allowed(device, b, id);
}
@@ -2250,14 +2281,14 @@
if (dev->bdaddr_type == BDADDR_LE_RANDOM)
return dev->bdaddr_type;
- if (dev->bredr_seen) {
- bredr_last = current - dev->bredr_seen;
+ if (dev->bredr_state.last_seen) {
+ bredr_last = current - dev->bredr_state.last_seen;
if (bredr_last > SEEN_TRESHHOLD)
bredr_last = NVAL_TIME;
}
- if (dev->le_seen) {
- le_last = current - dev->le_seen;
+ if (dev->le_state.last_seen) {
+ le_last = current - dev->le_state.last_seen;
if (le_last > SEEN_TRESHHOLD)
le_last = NVAL_TIME;
}
@@ -2438,7 +2469,7 @@
ba2str(&device->bdaddr, dst_addr);
- snprintf(filename, PATH_MAX, STORAGEDIR "/%s/%s/attributes",
+ create_filename(filename, PATH_MAX, "/%s/%s/attributes",
btd_adapter_get_storage_dir(device->adapter),
dst_addr);
key_file = g_key_file_new();
@@ -2490,171 +2521,10 @@
g_key_file_free(key_file);
}
-struct gatt_saver {
- struct btd_device *device;
- uint16_t ext_props;
- GKeyFile *key_file;
-};
-
-static void db_hash_read_value_cb(struct gatt_db_attribute *attrib,
- int err, const uint8_t *value,
- size_t length, void *user_data)
-{
- const uint8_t **hash = user_data;
-
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/src/device.h
^
|
@@ -28,11 +28,13 @@
bool device_is_name_resolve_allowed(struct btd_device *device);
void device_name_resolve_fail(struct btd_device *device);
void device_set_class(struct btd_device *device, uint32_t class);
+void device_set_rpa(struct btd_device *device, bool value);
void device_update_addr(struct btd_device *device, const bdaddr_t *bdaddr,
uint8_t bdaddr_type);
void device_set_bredr_support(struct btd_device *device);
void device_set_le_support(struct btd_device *device, uint8_t bdaddr_type);
-void device_update_last_seen(struct btd_device *device, uint8_t bdaddr_type);
+void device_update_last_seen(struct btd_device *device, uint8_t bdaddr_type,
+ bool connectable);
void device_merge_duplicate(struct btd_device *dev, struct btd_device *dup);
uint32_t btd_device_get_class(struct btd_device *device);
uint16_t btd_device_get_vendor(struct btd_device *device);
@@ -121,7 +123,8 @@
void device_cancel_authentication(struct btd_device *device, gboolean aborted);
gboolean device_is_authenticating(struct btd_device *device);
void device_add_connection(struct btd_device *dev, uint8_t bdaddr_type);
-void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type);
+void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type,
+ bool *remove);
void device_request_disconnect(struct btd_device *device, DBusMessage *msg);
bool device_is_disconnecting(struct btd_device *device);
void device_set_ltk_enc_size(struct btd_device *device, uint8_t enc_size);
@@ -186,3 +189,6 @@
void btd_device_update_allowed_services(struct btd_device *dev);
void btd_device_init(void);
void btd_device_cleanup(void);
+
+void btd_device_set_volume(struct btd_device *dev, int8_t volume);
+int8_t btd_device_get_volume(struct btd_device *dev);
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/src/eir.c
^
|
@@ -53,9 +53,9 @@
eir->services = NULL;
g_free(eir->name);
eir->name = NULL;
- g_free(eir->hash);
+ free(eir->hash);
eir->hash = NULL;
- g_free(eir->randomizer);
+ free(eir->randomizer);
eir->randomizer = NULL;
g_slist_free_full(eir->msd_list, g_free);
eir->msd_list = NULL;
@@ -323,13 +323,13 @@
case EIR_SSP_HASH:
if (data_len < 16)
break;
- eir->hash = g_memdup(data, 16);
+ eir->hash = util_memdup(data, 16);
break;
case EIR_SSP_RANDOMIZER:
if (data_len < 16)
break;
- eir->randomizer = g_memdup(data, 16);
+ eir->randomizer = util_memdup(data, 16);
break;
case EIR_DEVICE_ID:
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/src/error.h
^
|
@@ -27,7 +27,7 @@
"argument"
#define ERR_BREDR_CONN_ADAPTER_NOT_POWERED "br-connection-adapter-not-"\
"powered"
-#define ERR_BREDR_CONN_NOT_SUPPORTED "br-connection-not-suuported"
+#define ERR_BREDR_CONN_NOT_SUPPORTED "br-connection-not-supported"
#define ERR_BREDR_CONN_BAD_SOCKET "br-connection-bad-socket"
#define ERR_BREDR_CONN_MEMORY_ALLOC "br-connection-memory-"\
"allocation"
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/src/gatt-database.c
^
|
@@ -38,6 +38,8 @@
#include "dbus-common.h"
#include "profile.h"
#include "service.h"
+#include "textfile.h"
+#include "settings.h"
#define GATT_MANAGER_IFACE "org.bluez.GattManager1"
#define GATT_PROFILE_IFACE "org.bluez.GattProfile1"
@@ -378,6 +380,18 @@
return true;
}
+static struct device_state *
+find_device_state_by_att(struct btd_gatt_database *database, struct bt_att *att)
+{
+ bdaddr_t bdaddr;
+ uint8_t bdaddr_type;
+
+ if (!get_dst_info(att, &bdaddr, &bdaddr_type))
+ return NULL;
+
+ return find_device_state(database, &bdaddr, bdaddr_type);
+}
+
static struct device_state *get_device_state(struct btd_gatt_database *database,
struct bt_att *att)
{
@@ -1018,13 +1032,6 @@
goto done;
}
- ccc_cb = queue_find(database->ccc_callbacks, ccc_cb_match_handle,
- UINT_TO_PTR(gatt_db_attribute_get_handle(attrib)));
- if (!ccc_cb) {
- ecode = BT_ATT_ERROR_UNLIKELY;
- goto done;
- }
-
if (len == 1)
val = *value;
else
@@ -1034,7 +1041,9 @@
if (val == ccc->value)
goto done;
- if (ccc_cb->callback) {
+ ccc_cb = queue_find(database->ccc_callbacks, ccc_cb_match_handle,
+ UINT_TO_PTR(gatt_db_attribute_get_handle(attrib)));
+ if (ccc_cb) {
struct pending_op *op;
op = pending_ccc_new(att, attrib, val,
@@ -1056,6 +1065,22 @@
gatt_db_attribute_write_result(attrib, id, ecode);
}
+static void ccc_add_cb(struct btd_gatt_database *database,
+ struct gatt_db_attribute *ccc,
+ btd_gatt_database_ccc_write_t callback,
+ void *user_data, btd_gatt_database_destroy_t destroy)
+{
+ struct ccc_cb_data *ccc_cb;
+
+ ccc_cb = new0(struct ccc_cb_data, 1);
+ ccc_cb->handle = gatt_db_attribute_get_handle(ccc);
+ ccc_cb->callback = callback;
+ ccc_cb->destroy = destroy;
+ ccc_cb->user_data = user_data;
+
+ queue_push_tail(database->ccc_callbacks, ccc_cb);
+}
+
static struct gatt_db_attribute *
service_add_ccc(struct gatt_db_attribute *service,
struct btd_gatt_database *database,
@@ -1064,34 +1089,14 @@
btd_gatt_database_destroy_t destroy)
{
struct gatt_db_attribute *ccc;
- struct ccc_cb_data *ccc_cb;
- bt_uuid_t uuid;
-
- ccc_cb = new0(struct ccc_cb_data, 1);
- /*
- * Provide a way for the permissions on a characteristic to dictate
- * the permissions on the CCC
- */
- perm |= BT_ATT_PERM_READ | BT_ATT_PERM_WRITE;
-
- bt_uuid16_create(&uuid, GATT_CLIENT_CHARAC_CFG_UUID);
- ccc = gatt_db_service_add_descriptor(service, &uuid, perm,
- gatt_ccc_read_cb, gatt_ccc_write_cb, database);
- if (!ccc) {
- error("Failed to create CCC entry in database");
- free(ccc_cb);
- return NULL;
- }
-
- gatt_db_attribute_set_fixed_length(ccc, 2);
-
- ccc_cb->handle = gatt_db_attribute_get_handle(ccc);
- ccc_cb->callback = write_callback;
- ccc_cb->destroy = destroy;
- ccc_cb->user_data = user_data;
+ ccc = gatt_db_service_add_ccc(service, perm);
+ if (!ccc)
+ return ccc;
- queue_push_tail(database->ccc_callbacks, ccc_cb);
+ /* Only add ccc_cb if callback is set */
+ if (write_callback)
+ ccc_add_cb(database, ccc, write_callback, user_data, destroy);
return ccc;
}
@@ -1308,13 +1313,6 @@
database_add_record(database, service);
}
-static void register_core_services(struct btd_gatt_database *database)
-{
- populate_gap_service(database);
- populate_gatt_service(database);
- populate_devinfo_service(database);
-}
-
static void conf_cb(void *user_data)
{
GDBusProxy *proxy = user_data;
@@ -1438,6 +1436,49 @@
}
}
+static void gatt_notify_cb(struct gatt_db_attribute *attrib,
+ struct gatt_db_attribute *ccc,
+ const uint8_t *value, size_t len,
+ struct bt_att *att, void *user_data)
+{
+ struct btd_gatt_database *database = user_data;
+ struct notify notify;
+
+ memset(¬ify, 0, sizeof(notify));
+
+ notify.database = database;
+ notify.handle = gatt_db_attribute_get_handle(attrib);
+ notify.ccc_handle = gatt_db_attribute_get_handle(ccc);
+ notify.value = (void *) value;
+ notify.len = len;
+
+ if (attrib == database->svc_chngd)
+ notify.conf = service_changed_conf;
+
+ /* If a specific att is provided notify only to that device */
+ if (att) {
+ struct device_state *state;
+
+ state = find_device_state_by_att(database, att);
+ if (!state)
+ return;
+
+ send_notification_to_device(state, ¬ify);
+ } else
+ queue_foreach(database->device_states,
+ send_notification_to_device, ¬ify);
+}
+
+static void register_core_services(struct btd_gatt_database *database)
+{
+ gatt_db_ccc_register(database->db, gatt_ccc_read_cb, gatt_ccc_write_cb,
+ gatt_notify_cb, database);
+
+ populate_gap_service(database);
+ populate_gatt_service(database);
+ populate_devinfo_service(database);
+}
+
static void send_notification_to_devices(struct btd_gatt_database *database,
uint16_t handle, uint8_t *value,
uint16_t len, uint16_t ccc_handle,
@@ -1484,8 +1525,20 @@
put_le16(start, value);
put_le16(end, value + 2);
- send_notification_to_devices(database, handle, value, sizeof(value),
- ccc_handle, service_changed_conf, NULL);
+ if (!gatt_db_attribute_notify(database->svc_chngd, value, sizeof(value),
+ NULL))
+ error("Failed to notify Service Changed");
+}
+
+static void database_store(struct btd_gatt_database *database)
+{
+ char filename[PATH_MAX];
+
+ create_filename(filename, PATH_MAX, "/%s/attributes",
+ btd_adapter_get_storage_dir(database->adapter));
+ create_file(filename, 0600);
+
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/src/log.h
^
|
@@ -9,6 +9,7 @@
*/
#include <stdint.h>
+#include <stdbool.h>
void info(const char *format, ...) __attribute__((format(printf, 1, 2)));
@@ -52,10 +53,11 @@
.file = __FILE__, .flags = BTD_DEBUG_FLAG_DEFAULT, \
}; \
if (__btd_debug_desc.flags & BTD_DEBUG_FLAG_PRINT) \
- btd_debug(idx, "%s:%s() " fmt, __FILE__, __func__ , ## arg); \
+ btd_debug(idx, fmt, ## arg); \
} while (0)
-#define DBG(fmt, arg...) DBG_IDX(0xffff, fmt, ## arg)
+#define DBG(fmt, arg...) \
+ DBG_IDX(0xffff, "%s:%s() " fmt, __FILE__, __func__, ## arg)
#define error(fmt, arg...) \
btd_error(0xffff, "%s:%s() " fmt, __FILE__, __func__, ## arg)
#define warn(fmt, arg...) \
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/src/main.c
^
|
@@ -64,7 +64,7 @@
struct btd_opts btd_opts;
static GKeyFile *main_conf;
-static char *main_conf_file_path;
+static char main_conf_file_path[PATH_MAX];
static const char *supported_options[] = {
"Name",
@@ -77,12 +77,14 @@
"NameResolving",
"DebugKeys",
"ControllerMode",
+ "MaxControllers"
"MultiProfile",
"FastConnectable",
"Privacy",
"JustWorksRepairing",
"TemporaryTimeout",
"Experimental",
+ "KernelExperimental",
"RemoteNameRequestRetryDelay",
NULL
};
@@ -174,18 +176,41 @@
return main_conf;
}
-static GKeyFile *load_config(const char *file)
+static GKeyFile *load_config(const char *name)
{
GError *err = NULL;
GKeyFile *keyfile;
+ int len;
+
+ if (name)
+ snprintf(main_conf_file_path, PATH_MAX, "%s", name);
+ else {
+ const char *configdir = getenv("CONFIGURATION_DIRECTORY");
+
+ /* Check if running as service */
+ if (configdir) {
+ /* Check if there multiple paths given */
+ if (strstr(configdir, ":"))
+ len = strstr(configdir, ":") - configdir;
+ else
+ len = strlen(configdir);
+ } else {
+ configdir = CONFIGDIR;
+ len = strlen(configdir);
+ }
+
+ snprintf(main_conf_file_path, PATH_MAX, "%*s/main.conf", len,
+ configdir);
+ }
keyfile = g_key_file_new();
g_key_file_set_list_separator(keyfile, ',');
- if (!g_key_file_load_from_file(keyfile, file, 0, &err)) {
+ if (!g_key_file_load_from_file(keyfile, main_conf_file_path, 0, &err)) {
if (!g_error_matches(err, G_FILE_ERROR, G_FILE_ERROR_NOENT))
- error("Parsing %s failed: %s", file, err->message);
+ error("Parsing %s failed: %s", main_conf_file_path,
+ err->message);
g_error_free(err);
g_key_file_free(keyfile);
return NULL;
@@ -353,13 +378,22 @@
for (i = 0; i < params_len; ++i) {
GError *err = NULL;
- int val = g_key_file_get_integer(config, group,
- params[i].val_name, &err);
+ char *str;
+
+ str = g_key_file_get_string(config, group, params[i].val_name,
+ &err);
if (err) {
DBG("%s", err->message);
g_clear_error(&err);
} else {
- info("%s=%d", params[i].val_name, val);
+ char *endptr = NULL;
+ int val;
+
+ val = strtol(str, &endptr, 0);
+ if (!endptr || *endptr != '\0')
+ continue;
+
+ info("%s=%s(%d)", params[i].val_name, str, val);
val = MAX(val, params[i].min);
val = MIN(val, params[i].max);
@@ -559,12 +593,12 @@
return !strcasecmp(value, uuid);
}
-bool btd_experimental_enabled(const char *uuid)
+bool btd_kernel_experimental_enabled(const char *uuid)
{
- if (!btd_opts.experimental)
+ if (!btd_opts.kernel)
false;
- return queue_find(btd_opts.experimental, match_experimental, uuid);
+ return queue_find(btd_opts.kernel, match_experimental, uuid);
}
static const char *valid_uuids[] = {
@@ -573,27 +607,28 @@
"15c0a148-c273-11ea-b3de-0242ac130004",
"330859bc-7506-492d-9370-9a6f0614037f",
"a6695ace-ee7f-4fb9-881a-5fac66c629af",
+ "6fbaf188-05e0-496a-9885-d6ddfdb4e03e",
"*"
};
-static void btd_parse_experimental(char **list)
+static void btd_parse_kernel_experimental(char **list)
{
int i;
- if (btd_opts.experimental) {
- warn("Unable to parse Experimental: list already set");
+ if (btd_opts.kernel) {
+ warn("Unable to parse KernelExperimental: list already set");
return;
}
- btd_opts.experimental = queue_new();
+ btd_opts.kernel = queue_new();
for (i = 0; list[i]; i++) {
size_t j;
const char *uuid = list[i];
if (!strcasecmp("false", uuid) || !strcasecmp("off", uuid)) {
- queue_destroy(btd_opts.experimental, free);
- btd_opts.experimental = NULL;
+ queue_destroy(btd_opts.kernel, free);
+ btd_opts.kernel = NULL;
}
if (!strcasecmp("true", uuid) || !strcasecmp("on", uuid))
@@ -606,13 +641,13 @@
/* Ignored if UUID is considered invalid */
if (j == ARRAY_SIZE(valid_uuids)) {
- warn("Invalid Experimental UUID: %s", uuid);
+ warn("Invalid KernelExperimental UUID: %s", uuid);
continue;
}
DBG("%s", uuid);
- queue_push_tail(btd_opts.experimental, strdup(uuid));
+ queue_push_tail(btd_opts.kernel, strdup(uuid));
}
}
@@ -665,6 +700,7 @@
DBG("%s", err->message);
g_clear_error(&err);
btd_opts.privacy = 0x00;
+ btd_opts.device_privacy = true;
} else {
DBG("privacy=%s", str);
@@ -688,6 +724,7 @@
btd_opts.device_privacy = true;
} else if (!strcmp(str, "off")) {
btd_opts.privacy = 0x00;
+ btd_opts.device_privacy = true;
} else {
DBG("Invalid privacy option: %s", str);
btd_opts.privacy = 0x00;
@@ -779,6 +816,14 @@
g_free(str);
}
+ val = g_key_file_get_integer(config, "General", "MaxControllers", &err);
+ if (err) {
+ g_clear_error(&err);
+ } else {
+ DBG("MaxControllers=%d", val);
+ btd_opts.max_adapters = val;
+ }
+
str = g_key_file_get_string(config, "General", "MultiProfile", &err);
if (err) {
g_clear_error(&err);
@@ -809,12 +854,20 @@
else
btd_opts.refresh_discovery = boolean;
- strlist = g_key_file_get_string_list(config, "General", "Experimental",
+ boolean = g_key_file_get_boolean(config, "General", "Experimental",
+ &err);
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/src/main.conf
^
|
@@ -51,6 +51,10 @@
# Possible values: "dual", "bredr", "le"
#ControllerMode = dual
+# Maximum number of controllers allowed to be exposed to the system.
+# Default=0 (unlimited)
+#MaxControllers=0
+
# Enables Multi Profile Specification support. This allows to specify if
# system supports only Multiple Profiles Single Device (MPSD) configuration
# or both Multiple Profiles Single Device (MPSD) and Multiple Profiles Multiple
@@ -107,7 +111,11 @@
# profile is connected. Defaults to true.
#RefreshDiscovery = true
-# Enables experimental features and interfaces, alternatively a list of UUIDs
+# Enables D-Bus experimental interfaces
+# Possible values: true or false
+#Experimental = false
+
+# Enables kernel experimental features, alternatively a list of UUIDs
# can be given.
# Possible values: true,false,<UUID List>
# Possible UUIDS:
@@ -116,8 +124,9 @@
# 15c0a148-c273-11ea-b3de-0242ac130004 (BlueZ Experimental LL privacy)
# 330859bc-7506-492d-9370-9a6f0614037f (BlueZ Experimental Bluetooth Quality Report)
# a6695ace-ee7f-4fb9-881a-5fac66c629af (BlueZ Experimental Offload Codecs)
+# 6fbaf188-05e0-496a-9885-d6ddfdb4e03e (BlueZ Experimental ISO socket)
# Defaults to false.
-#Experimental = false
+#KernelExperimental = false
# The duration to avoid retrying to resolve a peer's name, if the previous
# try failed.
@@ -272,8 +281,8 @@
# AutoEnable defines option to enable all controllers when they are found.
# This includes adapters present on start as well as adapters that are plugged
-# in later on. Defaults to 'false'.
-#AutoEnable=false
+# in later on. Defaults to 'true'.
+#AutoEnable=true
# Audio devices that were disconnected due to suspend will be reconnected on
# resume. ResumeDelay determines the delay between when the controller
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/src/service.c
^
|
@@ -172,7 +172,7 @@
btd_service_unref(service);
}
-int service_accept(struct btd_service *service)
+int service_accept(struct btd_service *service, bool initiator)
{
char addr[18];
int err;
@@ -198,6 +198,8 @@
return -ECONNABORTED;
}
+ service->initiator = initiator;
+
err = service->profile->accept(service);
if (!err)
goto done;
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/src/service.h
^
|
@@ -35,7 +35,7 @@
int service_probe(struct btd_service *service);
void service_remove(struct btd_service *service);
-int service_accept(struct btd_service *service);
+int service_accept(struct btd_service *service, bool initiator);
int service_set_connecting(struct btd_service *service);
/* Connection control API */
|
[-]
[+]
|
Added |
_service:tar_git:bluez5-5.65+git1.tar.gz/src/settings.c
^
|
@@ -0,0 +1,510 @@
+// SPDX-License-Identifier: LGPL-2.1-or-later
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2022 Intel Corporation.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdbool.h>
+#include <errno.h>
+
+#include <glib.h>
+
+#include "lib/bluetooth.h"
+#include "lib/uuid.h"
+
+#include "log.h"
+#include "src/shared/queue.h"
+#include "src/shared/att.h"
+#include "src/shared/gatt-db.h"
+#include "settings.h"
+
+#define GATT_PRIM_SVC_UUID_STR "2800"
+#define GATT_SND_SVC_UUID_STR "2801"
+#define GATT_INCLUDE_UUID_STR "2802"
+#define GATT_CHARAC_UUID_STR "2803"
+
+static ssize_t str2val(const char *str, uint8_t *val, size_t len)
+{
+ const char *pos = str;
+ size_t i;
+
+ for (i = 0; i < len; i++) {
+ if (sscanf(pos, "%2hhx", &val[i]) != 1)
+ break;
+ pos += 2;
+ }
+
+ return i;
+}
+
+static void load_desc_value(struct gatt_db_attribute *attrib, int err,
+ void *user_data)
+{
+}
+
+static int load_desc(struct gatt_db *db, char *handle, char *value,
+ struct gatt_db_attribute *service)
+{
+ char uuid_str[MAX_LEN_UUID_STR];
+ struct gatt_db_attribute *att;
+ uint16_t handle_int;
+ uint16_t val;
+ bt_uuid_t uuid, ext_uuid;
+
+ if (sscanf(handle, "%04hx", &handle_int) != 1)
+ return -EIO;
+
+ /* Check if there is any value stored, otherwise it is just the UUID */
+ if (sscanf(value, "%04hx:%36s", &val, uuid_str) != 2) {
+ if (sscanf(value, "%36s", uuid_str) != 1)
+ return -EIO;
+ val = 0;
+ }
+
+ DBG("loading descriptor handle: 0x%04x, value: 0x%04x, value uuid: %s",
+ handle_int, val, uuid_str);
+
+ bt_string_to_uuid(&uuid, uuid_str);
+ bt_uuid16_create(&ext_uuid, GATT_CHARAC_EXT_PROPER_UUID);
+
+ /* If it is CEP then it must contain the value */
+ if (!bt_uuid_cmp(&uuid, &ext_uuid) && !val)
+ return -EIO;
+
+ att = gatt_db_service_insert_descriptor(service, handle_int, &uuid,
+ 0, NULL, NULL, NULL);
+ if (!att || gatt_db_attribute_get_handle(att) != handle_int)
+ return -EIO;
+
+ if (val) {
+ if (!gatt_db_attribute_write(att, 0, (uint8_t *)&val,
+ sizeof(val), 0, NULL,
+ load_desc_value, NULL))
+ return -EIO;
+ }
+
+ return 0;
+}
+
+static int load_chrc(struct gatt_db *db, char *handle, char *value,
+ struct gatt_db_attribute *service)
+{
+ uint16_t properties, value_handle, handle_int;
+ char uuid_str[MAX_LEN_UUID_STR];
+ struct gatt_db_attribute *att;
+ char val_str[33];
+ uint8_t val[16];
+ size_t val_len;
+ bt_uuid_t uuid;
+
+ if (sscanf(handle, "%04hx", &handle_int) != 1)
+ return -EIO;
+
+ /* Check if there is any value stored */
+ if (sscanf(value, GATT_CHARAC_UUID_STR ":%04hx:%02hx:%32s:%36s",
+ &value_handle, &properties, val_str, uuid_str) != 4) {
+ if (sscanf(value, GATT_CHARAC_UUID_STR ":%04hx:%02hx:%36s",
+ &value_handle, &properties, uuid_str) != 3)
+ return -EIO;
+ val_len = 0;
+ } else
+ val_len = str2val(val_str, val, sizeof(val));
+
+ bt_string_to_uuid(&uuid, uuid_str);
+
+ /* Log debug message. */
+ DBG("loading characteristic handle: 0x%04x, value handle: 0x%04x, "
+ "properties 0x%04x value: %s uuid: %s",
+ handle_int, value_handle,
+ properties, val_len ? val_str : "", uuid_str);
+
+ att = gatt_db_service_insert_characteristic(service, value_handle,
+ &uuid, 0, properties,
+ NULL, NULL, NULL);
+ if (!att || gatt_db_attribute_get_handle(att) != value_handle)
+ return -EIO;
+
+ if (val_len) {
+ if (!gatt_db_attribute_write(att, 0, val, val_len, 0, NULL,
+ load_desc_value, NULL))
+ return -EIO;
+ }
+
+ return 0;
+}
+
+static int load_incl(struct gatt_db *db, char *handle, char *value,
+ struct gatt_db_attribute *service)
+{
+ char uuid_str[MAX_LEN_UUID_STR];
+ struct gatt_db_attribute *att;
+ uint16_t start, end;
+
+ if (sscanf(handle, "%04hx", &start) != 1)
+ return -EIO;
+
+ if (sscanf(value, GATT_INCLUDE_UUID_STR ":%04hx:%04hx:%36s", &start,
+ &end, uuid_str) != 3)
+ return -EIO;
+
+ /* Log debug message. */
+ DBG("loading included service: 0x%04x, end: 0x%04x, uuid: %s",
+ start, end, uuid_str);
+
+ att = gatt_db_get_attribute(db, start);
+ if (!att)
+ return -EIO;
+
+ att = gatt_db_service_add_included(service, att);
+ if (!att)
+ return -EIO;
+
+ return 0;
+}
+
+static int load_service(struct gatt_db *db, char *handle, char *value)
+{
+ struct gatt_db_attribute *att;
+ uint16_t start, end;
+ char type[MAX_LEN_UUID_STR], uuid_str[MAX_LEN_UUID_STR];
+ bt_uuid_t uuid;
+ bool primary;
+
+ if (sscanf(handle, "%04hx", &start) != 1)
+ return -EIO;
+
+ if (sscanf(value, "%[^:]:%04hx:%36s", type, &end, uuid_str) != 3)
+ return -EIO;
+
+ if (g_str_equal(type, GATT_PRIM_SVC_UUID_STR))
+ primary = true;
+ else if (g_str_equal(type, GATT_SND_SVC_UUID_STR))
+ primary = false;
+ else
+ return -EIO;
+
+ bt_string_to_uuid(&uuid, uuid_str);
+
+ /* Log debug message. */
+ DBG("loading service: 0x%04x, end: 0x%04x, uuid: %s", start, end,
+ uuid_str);
+
+ att = gatt_db_insert_service(db, start, &uuid, primary,
|
[-]
[+]
|
Added |
_service:tar_git:bluez5-5.65+git1.tar.gz/src/settings.h
^
|
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2022 Intel Corporation.
+ *
+ */
+
+int btd_settings_gatt_db_load(struct gatt_db *db, const char *filename);
+void btd_settings_gatt_db_store(struct gatt_db *db, const char *filename);
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/src/shared/att.c
^
|
@@ -307,11 +307,13 @@
va_end(va);
}
-#define att_debug(_att, _format, _arg...) \
- att_log(_att, BT_ATT_DEBUG, _format, ## _arg)
-
-#define att_verbose(_att, _format, _arg...) \
- att_log(_att, BT_ATT_DEBUG_VERBOSE, _format, ## _arg)
+#define DBG(_att, _format, _arg...) \
+ att_log(_att, BT_ATT_DEBUG, "%s:%s() " _format, __FILE__, __func__,\
+ ## _arg)
+
+#define VERBOSE(_att, _format, _arg...) \
+ att_log(_att, BT_ATT_DEBUG_VERBOSE, "%s:%s() " _format, __FILE__, \
+ __func__, ## _arg)
static void att_hexdump(struct bt_att *att, char dir, const void *data,
size_t len)
@@ -357,7 +359,7 @@
sign_cnt, &((uint8_t *) op->pdu)[1 + length])))
return true;
- att_debug(att, "ATT unable to generate signature");
+ DBG(att, "ATT unable to generate signature");
fail:
free(op->pdu);
@@ -486,7 +488,7 @@
if (!op)
return false;
- att_debug(att, "(chan %p) Operation timed out: 0x%02x", chan,
+ DBG(att, "(chan %p) Operation timed out: 0x%02x", chan,
op->opcode);
if (att->timeout_callback)
@@ -522,11 +524,11 @@
iov.iov_base = (void *) pdu;
iov.iov_len = len;
- att_verbose(att, "(chan %p) ATT op 0x%02x", chan, opcode);
+ VERBOSE(att, "(chan %p) ATT op 0x%02x", chan, opcode);
ret = io_send(chan->io, &iov, 1);
if (ret < 0) {
- att_debug(att, "(chan %p) write failed: %s", chan,
+ DBG(att, "(chan %p) write failed: %s", chan,
strerror(-ret));
return ret;
}
@@ -659,12 +661,12 @@
len = sizeof(err);
if (getsockopt(chan->fd, SOL_SOCKET, SO_ERROR, &err, &len) < 0) {
- att_debug(att, "(chan %p) Failed to obtain disconnect "
+ DBG(att, "(chan %p) Failed to obtain disconnect "
"error: %s", chan, strerror(errno));
err = 0;
}
- att_debug(att, "Channel %p disconnected: %s", chan, strerror(err));
+ DBG(att, "Channel %p disconnected: %s", chan, strerror(err));
/* Dettach channel */
queue_remove(att->chans, chan);
@@ -793,7 +795,7 @@
op->timeout_id = 0;
}
- att_debug(att, "(chan %p) Retrying operation %p", chan, op);
+ DBG(att, "(chan %p) Retrying operation %p", chan, op);
chan->pending_req = NULL;
@@ -816,7 +818,7 @@
* the bearer.
*/
if (!op) {
- att_debug(att, "(chan %p) Received unexpected ATT response",
+ DBG(att, "(chan %p) Received unexpected ATT response",
chan);
io_shutdown(chan->io);
return;
@@ -848,7 +850,7 @@
goto done;
fail:
- att_debug(att, "(chan %p) Failed to handle response PDU; opcode: "
+ DBG(att, "(chan %p) Failed to handle response PDU; opcode: "
"0x%02x", chan, opcode);
rsp_opcode = BT_ATT_OP_ERROR_RSP;
@@ -873,7 +875,7 @@
* invalid.
*/
if (!op || pdu_len) {
- att_debug(att, "(chan %p) Received unexpected/invalid ATT "
+ DBG(att, "(chan %p) Received unexpected/invalid ATT "
"confirmation", chan);
io_shutdown(chan->io);
return;
@@ -947,7 +949,7 @@
return true;
fail:
- att_debug(att, "ATT failed to verify signature: 0x%02x", opcode);
+ DBG(att, "ATT failed to verify signature: 0x%02x", opcode);
return false;
}
@@ -1030,7 +1032,7 @@
if (bytes_read < 0)
return false;
- att_verbose(att, "(chan %p) ATT received: %zd", chan, bytes_read);
+ VERBOSE(att, "(chan %p) ATT received: %zd", chan, bytes_read);
att_hexdump(att, '>', chan->buf, bytes_read);
@@ -1045,12 +1047,12 @@
/* Act on the received PDU based on the opcode type */
switch (get_op_type(opcode)) {
case ATT_OP_TYPE_RSP:
- att_verbose(att, "(chan %p) ATT response received: 0x%02x",
+ VERBOSE(att, "(chan %p) ATT response received: 0x%02x",
chan, opcode);
handle_rsp(chan, opcode, pdu + 1, bytes_read - 1);
break;
case ATT_OP_TYPE_CONF:
- att_verbose(att, "(chan %p) ATT confirmation received: 0x%02x",
+ VERBOSE(att, "(chan %p) ATT confirmation received: 0x%02x",
chan, opcode);
handle_conf(chan, pdu + 1, bytes_read - 1);
break;
@@ -1061,7 +1063,7 @@
* promptly notify the upper layer via disconnect handlers.
*/
if (chan->in_req) {
- att_debug(att, "(chan %p) Received request while "
+ DBG(att, "(chan %p) Received request while "
"another is pending: 0x%02x",
chan, opcode);
io_shutdown(chan->io);
@@ -1081,7 +1083,7 @@
/* For all other opcodes notify the upper layer of the PDU and
* let them act on it.
*/
- att_debug(att, "(chan %p) ATT PDU received: 0x%02x", chan,
+ DBG(att, "(chan %p) ATT PDU received: 0x%02x", chan,
opcode);
handle_notify(chan, pdu, bytes_read);
break;
@@ -1235,7 +1237,7 @@
io_set_close_on_destroy(chan->io, att->close_on_unref);
- att_debug(att, "Channel %p attached", chan);
+ DBG(att, "Channel %p attached", chan);
wakeup_chan_writer(chan, NULL);
}
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/src/shared/btsnoop.c
^
|
@@ -336,7 +336,7 @@
break;
case BTSNOOP_FORMAT_MONITOR:
- flags = (index << 16) | opcode;
+ flags = ((uint32_t)index << 16) | opcode;
break;
default:
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/src/shared/gatt-client.c
^
|
@@ -37,6 +37,8 @@
#define GATT_SVC_UUID 0x1801
#define SVC_CHNGD_UUID 0x2a05
+#define DBG(_client, _format, arg...) \
+ gatt_log(_client, "%s:%s() " _format, __FILE__, __func__, ## arg)
struct ready_cb {
bt_gatt_client_callback_t callback;
@@ -376,6 +378,18 @@
static bool read_db_hash(struct discovery_op *op);
+static void gatt_log(struct bt_gatt_client *client, const char *format, ...)
+{
+ va_list ap;
+
+ if (!client || !format || !client->debug_callback)
+ return;
+
+ va_start(ap, format);
+ util_debug_va(client->debug_callback, client->debug_data, format, ap);
+ va_end(ap);
+}
+
static void discovery_op_complete(struct discovery_op *op, bool success,
uint8_t err)
{
@@ -406,9 +420,8 @@
gatt_db_attribute_get_service_data(attr, &start, &end,
NULL, NULL);
- util_debug(op->client->debug_callback, op->client->debug_data,
- "service disappeared: start 0x%04x end 0x%04x",
- start, end);
+ DBG(op->client, "service disappeared: start 0x%04x end 0x%04x",
+ start, end);
gatt_db_remove_service(op->client->db, attr);
}
@@ -542,9 +555,7 @@
if (includes_count == 0)
goto failed;
- util_debug(client->debug_callback, client->debug_data,
- "Included services found: %u",
- includes_count);
+ DBG(client, "Included services found: %u", includes_count);
for (i = 0; i < includes_count; i++) {
if (!bt_gatt_iter_next_included_service(&iter, &handle, &start,
@@ -555,13 +566,12 @@
/* Log debug message */
bt_uuid_to_string(&uuid, uuid_str, sizeof(uuid_str));
- util_debug(client->debug_callback, client->debug_data,
- "handle: 0x%04x, start: 0x%04x, end: 0x%04x,"
+ DBG(client, "handle: 0x%04x, start: 0x%04x, end: 0x%04x,"
"uuid: %s", handle, start, end, uuid_str);
attr = gatt_db_get_attribute(client->db, start);
if (!attr) {
- util_debug(client->debug_callback, client->debug_data,
+ DBG(client,
"Unable to find attribute at 0x%04x: skipping",
start);
continue;
@@ -569,7 +579,7 @@
attr = gatt_db_insert_included(client->db, handle, attr);
if (!attr) {
- util_debug(client->debug_callback, client->debug_data,
+ DBG(client,
"Unable to add include attribute at 0x%04x",
handle);
goto failed;
@@ -582,7 +592,7 @@
* attribute.
*/
if (gatt_db_attribute_get_handle(attr) != handle) {
- util_debug(client->debug_callback, client->debug_data,
+ DBG(client,
"Invalid attribute 0x%04x expect it at 0x%04x",
gatt_db_attribute_get_handle(attr), handle);
goto failed;
@@ -604,8 +614,8 @@
if (client->discovery_req)
return;
- util_debug(client->debug_callback, client->debug_data,
- "Failed to start characteristic discovery");
+ DBG(client, "Failed to start characteristic discovery");
+
discovery_op_unref(op);
failed:
discovery_op_complete(op, false, att_ecode);
@@ -656,7 +666,7 @@
NULL, NULL, NULL);
if (!attr) {
- util_debug(client->debug_callback, client->debug_data,
+ DBG(client,
"Failed to insert characteristic at 0x%04x",
chrc_data->value_handle);
@@ -729,8 +739,8 @@
goto done;
}
- util_debug(client->debug_callback, client->debug_data,
- "Failed to start descriptor discovery");
+ DBG(client, "Failed to start descriptor discovery");
+
discovery_op_unref(op);
goto failed;
@@ -750,8 +760,7 @@
{
struct bt_gatt_client *client = user_data;
- util_debug(client->debug_callback, client->debug_data,
- "Value set status: %d", err);
+ DBG(client, "Value set status: %d", err);
}
static void ext_prop_read_cb(bool success, uint8_t att_ecode,
@@ -790,8 +799,7 @@
if (!success)
goto done;
- util_debug(client->debug_callback, client->debug_data,
- "Ext. prop value: 0x%04x", (uint16_t)value[0]);
+ DBG(client, "Ext. prop value: 0x%04x", (uint16_t)value[0]);
desc_attr = queue_pop_head(op->ext_prop_desc);
if (!desc_attr)
@@ -857,8 +865,7 @@
if (desc_count == 0)
goto failed;
- util_debug(client->debug_callback, client->debug_data,
- "Descriptors found: %u", desc_count);
+ DBG(client, "Descriptors found: %u", desc_count);
bt_uuid16_create(&ext_prop_uuid, GATT_CHARAC_EXT_PROPER_UUID);
@@ -867,9 +874,8 @@
/* Log debug message */
bt_uuid_to_string(&uuid, uuid_str, sizeof(uuid_str));
- util_debug(client->debug_callback, client->debug_data,
- "handle: 0x%04x, uuid: %s",
- handle, uuid_str);
+
+ DBG(client, "handle: 0x%04x, uuid: %s", handle, uuid_str);
attr = gatt_db_insert_descriptor(client->db, handle,
&uuid, 0, NULL, NULL,
@@ -880,8 +886,7 @@
gatt_db_attribute_get_type(attr)))
continue;
- util_debug(client->debug_callback, client->debug_data,
- "Failed to insert descriptor at 0x%04x",
+ DBG(client, "Failed to insert descriptor at 0x%04x",
handle);
goto failed;
}
@@ -947,8 +952,8 @@
goto failed;
chrc_count = bt_gatt_result_characteristic_count(result);
- util_debug(client->debug_callback, client->debug_data,
- "Characteristics found: %u", chrc_count);
+
+ DBG(client, "Characteristics found: %u", chrc_count);
if (chrc_count == 0)
goto failed;
@@ -959,8 +964,7 @@
/* Log debug message */
bt_uuid_to_string(&uuid, uuid_str, sizeof(uuid_str));
- util_debug(client->debug_callback, client->debug_data,
- "start: 0x%04x, end: 0x%04x, value: 0x%04x, "
+ DBG(client, "start: 0x%04x, end: 0x%04x, value: 0x%04x, "
"props: 0x%02x, uuid: %s",
start, end, value, properties, uuid_str);
@@ -997,8 +1001,7 @@
if (client->discovery_req)
return;
- util_debug(client->debug_callback, client->debug_data,
- "Failed to start included services discovery");
+ DBG(client, "Failed to start included services discovery");
discovery_op_unref(op);
@@ -1110,8 +1113,7 @@
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/src/shared/gatt-db.c
^
|
@@ -43,6 +43,15 @@
.value.u16 = GATT_INCLUDE_UUID };
static const bt_uuid_t ext_desc_uuid = { .type = BT_UUID16,
.value.u16 = GATT_CHARAC_EXT_PROPER_UUID };
+static const bt_uuid_t ccc_uuid = { .type = BT_UUID16,
+ .value.u16 = GATT_CLIENT_CHARAC_CFG_UUID };
+
+struct gatt_db_ccc {
+ gatt_db_read_t read_func;
+ gatt_db_write_t write_func;
+ gatt_db_notify_t notify_func;
+ void *user_data;
+};
struct gatt_db {
int ref_count;
@@ -57,6 +66,8 @@
gatt_db_authorize_cb_t authorize;
void *authorize_data;
+
+ struct gatt_db_ccc *ccc;
};
struct notify {
@@ -101,6 +112,7 @@
gatt_db_read_t read_func;
gatt_db_write_t write_func;
+ gatt_db_notify_t notify_func;
void *user_data;
unsigned int read_id;
@@ -444,6 +456,7 @@
timeout_remove(db->hash_id);
queue_destroy(db->services, gatt_db_service_destroy);
+ free(db->ccc);
free(db);
}
@@ -1038,6 +1051,71 @@
user_data);
}
+static void find_ccc_value(struct gatt_db_attribute *attrib, void *user_data)
+{
+ uint16_t *handle = user_data;
+
+ gatt_db_attribute_get_char_data(attrib, NULL, handle, NULL, NULL, NULL);
+}
+
+struct gatt_db_attribute *
+gatt_db_service_add_ccc(struct gatt_db_attribute *attrib, uint32_t permissions)
+{
+ struct gatt_db *db;
+ struct gatt_db_attribute *ccc;
+ struct gatt_db_attribute *value;
+ uint16_t handle = 0;
+
+ if (!attrib)
+ return NULL;
+
+ db = attrib->service->db;
+
+ if (!db->ccc)
+ return NULL;
+
+ /* Locate value handle */
+ gatt_db_service_foreach_char(attrib, find_ccc_value, &handle);
+
+ if (!handle)
+ return NULL;
+
+ value = gatt_db_get_attribute(db, handle);
+ if (!value || value->notify_func)
+ return NULL;
+
+ ccc = service_insert_descriptor(attrib->service, 0, &ccc_uuid,
+ permissions,
+ db->ccc->read_func,
+ db->ccc->write_func,
+ db->ccc->user_data);
+ if (!ccc)
+ return ccc;
+
+ gatt_db_attribute_set_fixed_length(ccc, 2);
+ ccc->notify_func = db->ccc->notify_func;
+ value->notify_func = db->ccc->notify_func;
+
+ return ccc;
+}
+
+void gatt_db_ccc_register(struct gatt_db *db, gatt_db_read_t read_func,
+ gatt_db_write_t write_func,
+ gatt_db_notify_t notify_func,
+ void *user_data)
+{
+ if (!db)
+ return;
+
+ if (!db->ccc)
+ db->ccc = new0(struct gatt_db_ccc, 1);
+
+ db->ccc->read_func = read_func;
+ db->ccc->write_func = write_func;
+ db->ccc->notify_func = notify_func;
+ db->ccc->user_data = user_data;
+}
+
static struct gatt_db_attribute *
service_insert_included(struct gatt_db_service *service, uint16_t handle,
struct gatt_db_attribute *include)
@@ -1450,32 +1528,71 @@
gatt_db_service_foreach(attrib, &characteristic_uuid, func, user_data);
}
+static int gatt_db_attribute_get_index(const struct gatt_db_attribute *attrib)
+{
+ struct gatt_db_service *service;
+ int index;
+
+ if (!attrib)
+ return -1;
+
+ service = attrib->service;
+ for (index = 0; index < service->num_handles; index++) {
+ if (service->attributes[index] == attrib)
+ return index;
+ }
+
+ return -1;
+}
+
+static struct gatt_db_attribute *
+gatt_db_attribute_get_value(struct gatt_db_attribute *attrib)
+{
+ struct gatt_db_service *service;
+ int index;
+
+ if (!attrib)
+ return NULL;
+
+ index = gatt_db_attribute_get_index(attrib);
+ if (index < 0)
+ return NULL;
+
+ service = attrib->service;
+
+ if (!bt_uuid_cmp(&characteristic_uuid, &attrib->uuid))
+ index++;
+ else if (bt_uuid_cmp(&characteristic_uuid,
+ &service->attributes[index - 1]->uuid))
+ return NULL;
+
+ return service->attributes[index];
+}
+
void gatt_db_service_foreach_desc(struct gatt_db_attribute *attrib,
gatt_db_attribute_cb_t func,
void *user_data)
{
struct gatt_db_service *service;
struct gatt_db_attribute *attr;
+ int index;
uint16_t i;
if (!attrib || !func)
return;
- /* Return if this attribute is not a characteristic declaration */
- if (bt_uuid_cmp(&characteristic_uuid, &attrib->uuid))
+ attrib = gatt_db_attribute_get_value(attrib);
+ if (!attrib)
+ return;
+
+ index = gatt_db_attribute_get_index(attrib);
+ if (index < 0)
return;
service = attrib->service;
/* Start from the attribute following the value handle */
- for (i = 0; i < service->num_handles; i++) {
- if (service->attributes[i] == attrib) {
- i += 2;
- break;
- }
- }
-
- for (; i < service->num_handles; i++) {
+ for (i = index + 1; i < service->num_handles; i++) {
attr = service->attributes[i];
if (!attr)
continue;
@@ -1736,8 +1853,18 @@
if (!attrib)
return false;
- if (bt_uuid_cmp(&characteristic_uuid, &attrib->uuid))
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/src/shared/gatt-db.h
^
|
@@ -47,6 +47,10 @@
const uint8_t *value, size_t len,
uint8_t opcode, struct bt_att *att,
void *user_data);
+typedef void (*gatt_db_notify_t) (struct gatt_db_attribute *attrib,
+ struct gatt_db_attribute *ccc,
+ const uint8_t *value, size_t len,
+ struct bt_att *att, void *user_data);
struct gatt_db_attribute *
gatt_db_service_add_characteristic(struct gatt_db_attribute *attrib,
@@ -92,6 +96,7 @@
gatt_db_read_t read_func,
gatt_db_write_t write_func,
void *user_data);
+
struct gatt_db_attribute *
gatt_db_service_insert_descriptor(struct gatt_db_attribute *attrib,
uint16_t handle,
@@ -102,6 +107,9 @@
void *user_data);
struct gatt_db_attribute *
+gatt_db_service_add_ccc(struct gatt_db_attribute *attrib, uint32_t permissions);
+
+struct gatt_db_attribute *
gatt_db_insert_included(struct gatt_db *db, uint16_t handle,
struct gatt_db_attribute *include);
@@ -192,6 +200,11 @@
gatt_db_destroy_func_t destroy);
bool gatt_db_unregister(struct gatt_db *db, unsigned int id);
+void gatt_db_ccc_register(struct gatt_db *db, gatt_db_read_t read_func,
+ gatt_db_write_t write_func,
+ gatt_db_notify_t notify_func,
+ void *user_data);
+
typedef uint8_t (*gatt_db_authorize_cb_t)(struct gatt_db_attribute *attrib,
uint8_t opcode, struct bt_att *att,
void *user_data);
@@ -268,6 +281,13 @@
bool gatt_db_attribute_write_result(struct gatt_db_attribute *attrib,
unsigned int id, int err);
+struct gatt_db_attribute *
+gatt_db_attribute_get_ccc(struct gatt_db_attribute *attrib);
+
+bool gatt_db_attribute_notify(struct gatt_db_attribute *attrib,
+ const uint8_t *value, size_t len,
+ struct bt_att *att);
+
bool gatt_db_attribute_reset(struct gatt_db_attribute *attrib);
void *gatt_db_attribute_get_user_data(struct gatt_db_attribute *attrib);
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/src/shared/gatt-server.c
^
|
@@ -41,6 +41,9 @@
#define NFY_MULT_TIMEOUT 10
+#define DBG(_server, _format, arg...) \
+ gatt_log(_server, "%s:%s() " _format, __FILE__, __func__, ## arg)
+
struct async_read_op {
struct bt_att_chan *chan;
struct bt_gatt_server *server;
@@ -118,11 +121,26 @@
struct nfy_mult_data *nfy_mult;
};
+static void notify_multiple_free(struct bt_gatt_server *server)
+{
+ if (!server->nfy_mult)
+ return;
+
+ if (server->nfy_mult->id)
+ timeout_remove(server->nfy_mult->id);
+
+ free(server->nfy_mult->pdu);
+ free(server->nfy_mult);
+ server->nfy_mult = NULL;
+}
+
static void bt_gatt_server_free(struct bt_gatt_server *server)
{
if (server->debug_destroy)
server->debug_destroy(server->debug_data);
+ notify_multiple_free(server);
+
bt_att_unregister(server->att, server->mtu_id);
bt_att_unregister(server->att, server->read_by_grp_type_id);
bt_att_unregister(server->att, server->read_by_type_id);
@@ -233,6 +251,18 @@
return true;
}
+static void gatt_log(struct bt_gatt_server *server, const char *format, ...)
+{
+ va_list ap;
+
+ if (!server || !format || !server->debug_callback)
+ return;
+
+ va_start(ap, format);
+ util_debug_va(server->debug_callback, server->debug_data, format, ap);
+ va_end(ap);
+}
+
static void read_by_grp_type_cb(struct bt_att_chan *chan, uint8_t opcode,
const void *pdu, uint16_t length,
void *user_data)
@@ -259,9 +289,7 @@
end = get_le16(pdu + 2);
get_uuid_le(pdu + 4, length - 4, &type);
- util_debug(server->debug_callback, server->debug_data,
- "Read By Grp Type - start: 0x%04x end: 0x%04x",
- start, end);
+ DBG(server, "Read By Grp Type - start: 0x%04x end: 0x%04x", start, end);
if (!start || !end) {
ecode = BT_ATT_ERROR_INVALID_HANDLE;
@@ -483,9 +511,7 @@
end = get_le16(pdu + 2);
get_uuid_le(pdu + 4, length - 4, &type);
- util_debug(server->debug_callback, server->debug_data,
- "Read By Type - start: 0x%04x end: 0x%04x",
- start, end);
+ DBG(server, "Read By Type - start: 0x%04x end: 0x%04x", start, end);
if (!start || !end) {
ecode = BT_ATT_ERROR_INVALID_HANDLE;
@@ -605,9 +631,7 @@
start = get_le16(pdu);
end = get_le16(pdu + 2);
- util_debug(server->debug_callback, server->debug_data,
- "Find Info - start: 0x%04x end: 0x%04x",
- start, end);
+ DBG(server, "Find Info - start: 0x%04x end: 0x%04x", start, end);
if (!start || !end) {
ecode = BT_ATT_ERROR_INVALID_HANDLE;
@@ -708,9 +732,10 @@
end = get_le16(pdu + 2);
uuid16 = get_le16(pdu + 4);
- util_debug(server->debug_callback, server->debug_data,
- "Find By Type Value - start: 0x%04x end: 0x%04x uuid: 0x%04x",
- start, end, uuid16);
+ DBG(server,
+ "Find By Type Value - start: 0x%04x end: 0x%04x uuid: 0x%04x",
+ start, end, uuid16);
+
ehandle = start;
if (start > end) {
data.ecode = BT_ATT_ERROR_INVALID_HANDLE;
@@ -756,8 +781,7 @@
return;
}
- util_debug(server->debug_callback, server->debug_data,
- "Write Complete: err %d", err);
+ DBG(server, "Write Complete: err %d", err);
handle = gatt_db_attribute_get_handle(attr);
@@ -818,10 +842,8 @@
goto error;
}
- util_debug(server->debug_callback, server->debug_data,
- "Write %s - handle: 0x%04x",
- (opcode == BT_ATT_OP_WRITE_REQ) ? "Req" : "Cmd",
- handle);
+ DBG(server, "Write %s - handle: 0x%04x",
+ (opcode == BT_ATT_OP_WRITE_REQ) ? "Req" : "Cmd", handle);
ecode = check_length(length, 0);
if (ecode)
@@ -885,8 +907,7 @@
uint16_t mtu;
uint16_t handle;
- util_debug(server->debug_callback, server->debug_data,
- "Read Complete: err %d", err);
+ DBG(server, "Read Complete: err %d", err);
mtu = bt_att_get_mtu(server->att);
handle = gatt_db_attribute_get_handle(attr);
@@ -922,10 +943,8 @@
goto error;
}
- util_debug(server->debug_callback, server->debug_data,
- "Read %sReq - handle: 0x%04x",
- opcode == BT_ATT_OP_READ_BLOB_REQ ? "Blob " : "",
- handle);
+ DBG(server, "Read %sReq - handle: 0x%04x",
+ opcode == BT_ATT_OP_READ_BLOB_REQ ? "Blob " : "", handle);
ecode = check_permissions(server, attr, BT_ATT_PERM_READ_MASK);
if (ecode)
@@ -1125,8 +1144,7 @@
handle = data->handles[0];
- util_debug(server->debug_callback, server->debug_data,
- "%s Req - %zu handles, 1st: 0x%04x",
+ DBG(server, "%s Req - %zu handles, 1st: 0x%04x",
data->opcode == BT_ATT_OP_READ_MULT_REQ ?
"Read Multiple" : "Read Multiple Variable Length",
data->num_handles, handle);
@@ -1312,8 +1330,7 @@
goto error;
}
- util_debug(server->debug_callback, server->debug_data,
- "Prep Write Req - handle: 0x%04x", handle);
+ DBG(server, "Prep Write Req - handle: 0x%04x", handle);
ecode = check_length(length, offset);
if (ecode)
@@ -1433,8 +1450,7 @@
flags = ((uint8_t *) pdu)[0];
- util_debug(server->debug_callback, server->debug_data,
- "Exec Write Req - flags: 0x%02x", flags);
+ DBG(server, "Exec Write Req - flags: 0x%02x", flags);
if (flags == 0x00)
write = false;
@@ -1505,8 +1521,7 @@
server->mtu = final_mtu;
bt_att_set_mtu(server->att, final_mtu);
- util_debug(server->debug_callback, server->debug_data,
- "MTU exchange complete, with MTU: %u", final_mtu);
+ DBG(server, "MTU exchange complete, with MTU: %u", final_mtu);
}
static bool gatt_server_register_att_handlers(struct bt_gatt_server *server)
@@ -1695,17 +1710,26 @@
return true;
}
+static void notify_multiple_timeout_remove(struct bt_gatt_server *server)
+{
+ if (!server->nfy_mult->id)
+ return;
+
+ timeout_remove(server->nfy_mult->id);
+ server->nfy_mult->id = 0;
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/src/shared/mgmt.c
^
|
@@ -25,6 +25,10 @@
#include "src/shared/queue.h"
#include "src/shared/util.h"
#include "src/shared/mgmt.h"
+#include "src/shared/timeout.h"
+
+#define DBG(_mgmt, _format, arg...) \
+ mgmt_log(_mgmt, "%s:%s() " _format, __FILE__, __func__, ## arg)
struct mgmt {
int ref_count;
@@ -49,6 +53,7 @@
};
struct mgmt_request {
+ struct mgmt *mgmt;
unsigned int id;
uint16_t opcode;
uint16_t index;
@@ -57,6 +62,8 @@
mgmt_request_func_t callback;
mgmt_destroy_func_t destroy;
void *user_data;
+ int timeout;
+ unsigned int timeout_id;
};
struct mgmt_notify {
@@ -81,6 +88,9 @@
if (request->destroy)
request->destroy(request->user_data);
+ if (request->timeout_id)
+ timeout_remove(request->timeout_id);
+
free(request->buf);
free(request);
}
@@ -150,6 +160,38 @@
mgmt->writer_active = false;
}
+static bool request_timeout(void *data)
+{
+ struct mgmt_request *request = data;
+
+ if (!request)
+ return false;
+
+ request->timeout_id = 0;
+
+ queue_remove_if(request->mgmt->pending_list, NULL, request);
+
+ if (request->callback)
+ request->callback(MGMT_STATUS_TIMEOUT, 0, NULL,
+ request->user_data);
+
+ destroy_request(request);
+
+ return false;
+}
+
+static void mgmt_log(struct mgmt *mgmt, const char *format, ...)
+{
+ va_list ap;
+
+ if (!mgmt || !format || !mgmt->debug_callback)
+ return;
+
+ va_start(ap, format);
+ util_debug_va(mgmt->debug_callback, mgmt->debug_data, format, ap);
+ va_end(ap);
+}
+
static bool send_request(struct mgmt *mgmt, struct mgmt_request *request)
{
struct iovec iov;
@@ -160,8 +202,8 @@
ret = io_send(mgmt->io, &iov, 1);
if (ret < 0) {
- util_debug(mgmt->debug_callback, mgmt->debug_data,
- "write failed: %s", strerror(-ret));
+ DBG(mgmt, "write failed: %s", strerror(-ret));
+
if (request->callback)
request->callback(MGMT_STATUS_FAILED, 0, NULL,
request->user_data);
@@ -169,12 +211,13 @@
return false;
}
- util_debug(mgmt->debug_callback, mgmt->debug_data,
- "[0x%04x] command 0x%04x",
- request->index, request->opcode);
+ if (request->timeout)
+ request->timeout_id = timeout_add_seconds(request->timeout,
+ request_timeout,
+ request,
+ NULL);
- util_hexdump('<', request->buf, ret, mgmt->debug_callback,
- mgmt->debug_data);
+ DBG(mgmt, "[0x%04x] command 0x%04x", request->index, request->opcode);
queue_push_tail(mgmt->pending_list, request);
@@ -250,9 +293,7 @@
request = queue_remove_if(mgmt->pending_list,
match_request_opcode_index, &match);
if (!request) {
- util_debug(mgmt->debug_callback, mgmt->debug_data,
- "Unable to find request for opcode 0x%04x",
- opcode);
+ DBG(mgmt, "Unable to find request for opcode 0x%04x", opcode);
/* Attempt to remove with no opcode */
request = queue_remove_if(mgmt->pending_list,
@@ -329,9 +370,6 @@
if (bytes_read < 0)
return false;
- util_hexdump('>', mgmt->buf, bytes_read,
- mgmt->debug_callback, mgmt->debug_data);
-
if (bytes_read < MGMT_HDR_SIZE)
return true;
@@ -350,8 +388,7 @@
cc = mgmt->buf + MGMT_HDR_SIZE;
opcode = btohs(cc->opcode);
- util_debug(mgmt->debug_callback, mgmt->debug_data,
- "[0x%04x] command 0x%04x complete: 0x%02x",
+ DBG(mgmt, "[0x%04x] command 0x%04x complete: 0x%02x",
index, opcode, cc->status);
request_complete(mgmt, cc->status, opcode, index, length - 3,
@@ -361,15 +398,13 @@
cs = mgmt->buf + MGMT_HDR_SIZE;
opcode = btohs(cs->opcode);
- util_debug(mgmt->debug_callback, mgmt->debug_data,
- "[0x%04x] command 0x%02x status: 0x%02x",
+ DBG(mgmt, "[0x%04x] command 0x%02x status: 0x%02x",
index, opcode, cs->status);
request_complete(mgmt, cs->status, opcode, index, 0, NULL);
break;
default:
- util_debug(mgmt->debug_callback, mgmt->debug_data,
- "[0x%04x] event 0x%04x", index, event);
+ DBG(mgmt, "[0x%04x] event 0x%04x", index, event);
process_notify(mgmt, event, index, length,
mgmt->buf + MGMT_HDR_SIZE);
@@ -566,7 +601,8 @@
static struct mgmt_request *create_request(struct mgmt *mgmt, uint16_t opcode,
uint16_t index, uint16_t length,
const void *param, mgmt_request_func_t callback,
- void *user_data, mgmt_destroy_func_t destroy)
+ void *user_data, mgmt_destroy_func_t destroy,
+ int timeout)
{
struct mgmt_request *request;
struct mgmt_hdr *hdr;
@@ -598,12 +634,18 @@
hdr->index = htobs(index);
hdr->len = htobs(length);
+ /* Use a weak reference so requests don't prevent mgmt_unref to
+ * cancel requests and free in case of the last reference is dropped by
+ * the user.
+ */
+ request->mgmt = mgmt;
request->opcode = opcode;
request->index = index;
request->callback = callback;
request->destroy = destroy;
request->user_data = user_data;
+ request->timeout = timeout;
return request;
}
@@ -735,10 +777,11 @@
return ret;
}
-unsigned int mgmt_send(struct mgmt *mgmt, uint16_t opcode, uint16_t index,
- uint16_t length, const void *param,
- mgmt_request_func_t callback,
- void *user_data, mgmt_destroy_func_t destroy)
+unsigned int mgmt_send_timeout(struct mgmt *mgmt, uint16_t opcode,
+ uint16_t index, uint16_t length,
+ const void *param, mgmt_request_func_t callback,
+ void *user_data, mgmt_destroy_func_t destroy,
+ int timeout)
{
struct mgmt_request *request;
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/src/shared/mgmt.h
^
|
@@ -55,6 +55,11 @@
uint16_t length, const void *param,
mgmt_request_func_t callback,
void *user_data, mgmt_destroy_func_t destroy);
+unsigned int mgmt_send_timeout(struct mgmt *mgmt, uint16_t opcode,
+ uint16_t index, uint16_t length,
+ const void *param, mgmt_request_func_t callback,
+ void *user_data, mgmt_destroy_func_t destroy,
+ int timeout);
unsigned int mgmt_send_nowait(struct mgmt *mgmt, uint16_t opcode, uint16_t index,
uint16_t length, const void *param,
mgmt_request_func_t callback,
@@ -63,6 +68,11 @@
uint16_t length, const void *param,
mgmt_request_func_t callback,
void *user_data, mgmt_destroy_func_t destroy);
+unsigned int mgmt_reply_timeout(struct mgmt *mgmt, uint16_t opcode,
+ uint16_t index, uint16_t length,
+ const void *param, mgmt_request_func_t callback,
+ void *user_data, mgmt_destroy_func_t destroy,
+ int timeout);
bool mgmt_cancel(struct mgmt *mgmt, unsigned int id);
bool mgmt_cancel_index(struct mgmt *mgmt, uint16_t index);
bool mgmt_cancel_all(struct mgmt *mgmt);
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/src/shared/shell.c
^
|
@@ -139,14 +139,22 @@
return bt_shell_noninteractive_quit(EXIT_SUCCESS);
}
-static const struct bt_shell_menu *find_menu(const char *name, size_t len)
+static const struct bt_shell_menu *find_menu(const char *name, size_t len,
+ int *index)
{
const struct queue_entry *entry;
+ int i;
- for (entry = queue_get_entries(data.submenus); entry;
- entry = entry->next) {
+ for (i = 0, entry = queue_get_entries(data.submenus); entry;
+ entry = entry->next, i++) {
struct bt_shell_menu *menu = entry->data;
+ if (index) {
+ if (i < *index)
+ continue;
+ (*index)++;
+ }
+
if (!strncmp(menu->name, name, len))
return menu;
}
@@ -188,7 +196,7 @@
return bt_shell_noninteractive_quit(EXIT_FAILURE);
}
- menu = find_menu(argv[1], strlen(argv[1]));
+ menu = find_menu(argv[1], strlen(argv[1]), NULL);
if (!menu) {
bt_shell_printf("Unable find menu with name: %s\n", argv[1]);
return bt_shell_noninteractive_quit(EXIT_FAILURE);
@@ -485,7 +493,7 @@
len = name - argv[0];
name[0] = '\0';
- submenu = find_menu(argv[0], strlen(argv[0]));
+ submenu = find_menu(argv[0], strlen(argv[0]), NULL);
if (!submenu)
return -ENOENT;
@@ -678,7 +686,6 @@
static void rl_handler(char *input)
{
- wordexp_t w;
HIST_ENTRY *last;
if (!input) {
@@ -703,16 +710,8 @@
if (data.monitor)
bt_log_printf(0xffff, data.name, LOG_INFO, "%s", input);
- if (wordexp(input, &w, WRDE_NOCMD))
- goto done;
+ bt_shell_exec(input);
- if (w.we_wordc == 0) {
- wordfree(&w);
- goto done;
- }
-
- shell_exec(w.we_wordc, w.we_wordv);
- wordfree(&w);
done:
free(input);
}
@@ -744,7 +743,7 @@
static char *cmd_generator(const char *text, int state)
{
static int index;
- static bool default_menu_enabled, submenu_enabled;
+ static bool default_menu_enabled, menu_enabled, submenu_enabled;
static const struct bt_shell_menu *menu;
char *cmd;
@@ -763,9 +762,22 @@
index = 0;
menu = data.menu;
default_menu_enabled = false;
+
+ if (data.main == data.menu)
+ menu_enabled = true;
}
}
+ if (menu_enabled) {
+ menu = find_menu(text, strlen(text), &index);
+ if (menu)
+ return strdup(menu->name);
+
+ index = 0;
+ menu = data.menu;
+ menu_enabled = false;
+ }
+
if (!submenu_enabled) {
cmd = find_cmd(text, menu->entries, &index);
if (cmd || menu != data.main)
@@ -775,7 +787,7 @@
if (!cmd)
return NULL;
- menu = find_menu(text, cmd - text);
+ menu = find_menu(text, cmd - text, NULL);
if (!menu)
return NULL;
@@ -899,6 +911,26 @@
return matches;
}
+static char **submenu_completion(const char *text, int argc, char *input_cmd)
+{
+ const struct bt_shell_menu *menu;
+ char *cmd;
+
+ if (data.main != data.menu)
+ return NULL;
+
+ cmd = strrchr(input_cmd, '.');
+ if (!cmd)
+ return NULL;
+
+ menu = find_menu(input_cmd, cmd - input_cmd, NULL);
+ if (!menu)
+ return NULL;
+
+ return menu_completion(menu->entries, text, argc,
+ input_cmd + strlen(menu->name) + 1);
+}
+
static char **shell_completion(const char *text, int start, int end)
{
char **matches = NULL;
@@ -916,10 +948,14 @@
matches = menu_completion(default_menu, text, w.we_wordc,
w.we_wordv[0]);
- if (!matches)
+ if (!matches) {
matches = menu_completion(data.menu->entries, text,
w.we_wordc,
w.we_wordv[0]);
+ if (!matches)
+ matches = submenu_completion(text, w.we_wordc,
+ w.we_wordv[0]);
+ }
wordfree(&w);
} else {
@@ -1178,6 +1214,29 @@
return status;
}
+int bt_shell_exec(const char *input)
+{
+ wordexp_t w;
+ int err;
+
+ if (!input)
+ return 0;
+
+ if (wordexp(input, &w, WRDE_NOCMD))
+ return -ENOEXEC;
+
+ if (w.we_wordc == 0) {
+ wordfree(&w);
+ return -ENOEXEC;
+ }
+
+ err = shell_exec(w.we_wordc, w.we_wordv);
+
+ wordfree(&w);
+
+ return err;
+}
+
void bt_shell_cleanup(void)
{
bt_shell_release_prompt("");
@@ -1234,6 +1293,9 @@
if (!menu)
return false;
+ if (!data.main)
+ return bt_shell_set_menu(menu);
+
if (!data.submenus)
data.submenus = queue_new();
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/src/shared/shell.h
^
|
@@ -55,6 +55,7 @@
void bt_shell_init(int argc, char **argv, const struct bt_shell_opt *opt);
int bt_shell_run(void);
+int bt_shell_exec(const char *input);
void bt_shell_quit(int status);
void bt_shell_noninteractive_quit(int status);
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/src/shared/util.c
^
|
@@ -13,6 +13,7 @@
#endif
#define _GNU_SOURCE
+#include <fcntl.h>
#include <stdio.h>
#include <ctype.h>
#include <stdbool.h>
@@ -23,9 +24,13 @@
#include <limits.h>
#include <string.h>
+#ifdef HAVE_SYS_RANDOM_H
+#include <sys/random.h>
+#endif
+
#include "src/shared/util.h"
-void *btd_malloc(size_t size)
+void *util_malloc(size_t size)
{
if (__builtin_expect(!!size, 1)) {
void *ptr;
@@ -41,6 +46,22 @@
return NULL;
}
+void *util_memdup(const void *src, size_t size)
+{
+ void *cpy;
+
+ if (!src || !size)
+ return NULL;
+
+ cpy = util_malloc(size);
+ if (!cpy)
+ return NULL;
+
+ memcpy(cpy, src, size);
+
+ return cpy;
+}
+
void util_debug_va(util_debug_func_t function, void *user_data,
const char *format, va_list va)
{
@@ -122,6 +143,26 @@
return DT_UNKNOWN;
}
+/* Helper for getting a random in case getrandom unavailable (glibc < 2.25) */
+ssize_t util_getrandom(void *buf, size_t buflen, unsigned int flags)
+{
+#ifdef HAVE_GETRANDOM
+ return getrandom(buf, buflen, flags);
+#else
+ int fd;
+ ssize_t bytes;
+
+ fd = open("/dev/urandom", O_CLOEXEC);
+ if (fd < 0)
+ return -1;
+
+ bytes = read(fd, buf, buflen);
+ close(fd);
+
+ return bytes;
+#endif
+}
+
/* Helpers for bitfield operations */
/* Find unique id in range from 1 to max but no bigger than 64. */
@@ -1108,6 +1149,8 @@
{ "330859bc-7506-492d-9370-9a6f0614037f",
"BlueZ Experimental Bluetooth Quality Report" },
{ "a6695ace-ee7f-4fb9-881a-5fac66c629af", "BlueZ Offload Codecs"},
+ { "6fbaf188-05e0-496a-9885-d6ddfdb4e03e",
+ "BlueZ Experimental ISO Socket"},
{ }
};
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/src/shared/util.h
^
|
@@ -14,6 +14,7 @@
#include <alloca.h>
#include <byteswap.h>
#include <string.h>
+#include <sys/types.h>
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
#define BIT(n) (1 << (n))
@@ -75,7 +76,7 @@
size_t __n = (size_t) (count); \
size_t __s = sizeof(type); \
void *__p; \
- __p = btd_malloc(__n * __s); \
+ __p = util_malloc(__n * __s); \
memset(__p, 0, __n * __s); \
__p; \
}))
@@ -86,7 +87,8 @@
char *strdelimit(char *str, char *del, char c);
int strsuffix(const char *str, const char *suffix);
-void *btd_malloc(size_t size);
+void *util_malloc(size_t size);
+void *util_memdup(const void *src, size_t size);
typedef void (*util_debug_func_t)(const char *str, void *user_data);
@@ -102,6 +104,8 @@
unsigned char util_get_dt(const char *parent, const char *name);
+ssize_t util_getrandom(void *buf, size_t buflen, unsigned int flags);
+
uint8_t util_get_uid(uint64_t *bitmap, uint8_t max);
void util_clear_uid(uint64_t *bitmap, uint8_t id);
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/src/storage.c
^
|
@@ -43,21 +43,11 @@
char *pattern;
};
-static inline int create_filename(char *buf, size_t size,
- const bdaddr_t *bdaddr, const char *name)
-{
- char addr[18];
-
- ba2str(bdaddr, addr);
-
- return create_name(buf, size, STORAGEDIR, addr, name);
-}
-
int read_discoverable_timeout(const char *src, int *timeout)
{
char filename[PATH_MAX], *str;
- create_name(filename, PATH_MAX, STORAGEDIR, src, "config");
+ create_name(filename, PATH_MAX, src, "config");
str = textfile_get(filename, "discovto");
if (!str)
@@ -77,7 +67,7 @@
{
char filename[PATH_MAX], *str;
- create_name(filename, PATH_MAX, STORAGEDIR, src, "config");
+ create_name(filename, PATH_MAX, src, "config");
str = textfile_get(filename, "pairto");
if (!str)
@@ -97,7 +87,7 @@
{
char filename[PATH_MAX], *str;
- create_name(filename, PATH_MAX, STORAGEDIR, src, "config");
+ create_name(filename, PATH_MAX, src, "config");
str = textfile_get(filename, "onmode");
if (!str)
@@ -115,8 +105,11 @@
{
char filename[PATH_MAX], *str;
int len;
+ char addr[18];
+
+ ba2str(bdaddr, addr);
- create_filename(filename, PATH_MAX, bdaddr, "config");
+ create_filename(filename, PATH_MAX, "/%s/config", addr);
str = textfile_get(filename, "name");
if (!str)
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/src/textfile.c
^
|
@@ -19,6 +19,7 @@
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
+#include <stdarg.h>
#include <string.h>
#include <sys/file.h>
#include <sys/stat.h>
@@ -27,6 +28,42 @@
#include "textfile.h"
+int create_filename(char *str, size_t size, const char *fmt, ...)
+{
+ static const char *prefix;
+ static int prefix_len;
+ char suffix[PATH_MAX];
+ va_list ap;
+ int err;
+
+ if (!prefix) {
+ const char *statedir = getenv("STATE_DIRECTORY");
+
+ /* Check if running as service */
+ if (statedir) {
+ prefix = statedir;
+
+ /* Check if there multiple paths given */
+ if (strstr(prefix, ":"))
+ prefix_len = strstr(prefix, ":") - prefix;
+ else
+ prefix_len = strlen(prefix);
+ } else {
+ prefix = STORAGEDIR;
+ prefix_len = strlen(prefix);
+ }
+ }
+
+ va_start(ap, fmt);
+ err = vsnprintf(suffix, sizeof(suffix), fmt, ap);
+ va_end(ap);
+
+ if (err < 0)
+ return err;
+
+ return snprintf(str, size, "%*s%s", prefix_len, prefix, suffix);
+}
+
static int create_dirs(const char *filename, const mode_t mode)
{
struct stat st;
@@ -76,9 +113,9 @@
return 0;
}
-int create_name(char *buf, size_t size, const char *path, const char *address, const char *name)
+int create_name(char *buf, size_t size, const char *address, const char *name)
{
- return snprintf(buf, size, "%s/%s/%s", path, address, name);
+ return create_filename(buf, size, "/%s/%s", address, name);
}
static inline char *find_key(char *map, size_t size, const char *key, size_t len, int icase)
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/src/textfile.h
^
|
@@ -8,9 +8,10 @@
*
*/
+int create_filename(char *str, size_t size, const char *fmt, ...)
+ __attribute__((format(printf, 3, 4)));
int create_file(const char *filename, const mode_t mode);
-int create_name(char *buf, size_t size, const char *path,
- const char *address, const char *name);
+int create_name(char *buf, size_t size, const char *address, const char *name);
int textfile_put(const char *pathname, const char *key, const char *value);
int textfile_del(const char *pathname, const char *key);
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/test/list-devices
^
|
@@ -32,10 +32,10 @@
objects = manager.GetManagedObjects()
-all_devices = (str(path) for path, interfaces in objects.iteritems() if
+all_devices = (str(path) for path, interfaces in objects.items() if
"org.bluez.Device1" in interfaces.keys())
-for path, interfaces in objects.iteritems():
+for path, interfaces in objects.items():
if "org.bluez.Adapter1" not in interfaces.keys():
continue
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/test/map-client
^
|
@@ -33,7 +33,7 @@
return tuple(map(unwrap, x))
if isinstance(x, dict):
- return dict([(unwrap(k), unwrap(v)) for k, v in x.iteritems()])
+ return dict([(unwrap(k), unwrap(v)) for k, v in x.items()])
for t in [unicode, str, long, int, float, bool]:
if isinstance(x, t):
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/test/monitor-bluetooth
^
|
@@ -14,17 +14,17 @@
def property_changed(interface, changed, invalidated, path):
iface = interface[interface.rfind(".") + 1:]
- for name, value in changed.iteritems():
+ for name, value in changed.items():
val = str(value)
print("{%s.PropertyChanged} [%s] %s = %s" % (iface, path, name,
val))
def interfaces_added(path, interfaces):
- for iface, props in interfaces.iteritems():
+ for iface, props in interfaces.items():
if not(iface in relevant_ifaces):
continue
print("{Added %s} [%s]" % (iface, path))
- for name, value in props.iteritems():
+ for name, value in props.items():
print(" %s = %s" % (name, value))
def interfaces_removed(path, interfaces):
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/test/test-adapter
^
|
@@ -61,7 +61,7 @@
om = dbus.Interface(bus.get_object("org.bluez", "/"),
"org.freedesktop.DBus.ObjectManager")
objects = om.GetManagedObjects()
- for path, interfaces in objects.iteritems():
+ for path, interfaces in objects.items():
if "org.bluez.Adapter1" not in interfaces:
continue
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/test/test-device
^
|
@@ -49,7 +49,7 @@
"org.freedesktop.DBus.ObjectManager")
objects = om.GetManagedObjects()
- for path, interfaces in objects.iteritems():
+ for path, interfaces in objects.items():
if "org.bluez.Device1" not in interfaces:
continue
properties = interfaces["org.bluez.Device1"]
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/test/test-discovery
^
|
@@ -19,7 +19,7 @@
name = ""
address = "<unknown>"
- for key, value in properties.iteritems():
+ for key, value in properties.items():
if type(value) is dbus.String:
value = unicode(value).encode('ascii', 'replace')
if (key == "Name"):
@@ -153,7 +153,7 @@
om = dbus.Interface(bus.get_object("org.bluez", "/"),
"org.freedesktop.DBus.ObjectManager")
objects = om.GetManagedObjects()
- for path, interfaces in objects.iteritems():
+ for path, interfaces in objects.items():
if "org.bluez.Device1" in interfaces:
devices[path] = interfaces["org.bluez.Device1"]
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/test/test-health
^
|
@@ -147,7 +147,7 @@
objects = manager.GetManagedObjects()
adapters = []
-for path, ifaces in objects.iteritems():
+for path, ifaces in objects.items():
if ifaces.has_key(ADAPTER_INTERFACE):
adapters.append(path)
@@ -172,7 +172,7 @@
adapter = dbus.Interface(bus.get_object(BUS_NAME, select), ADAPTER_INTERFACE)
devices = []
-for path, interfaces in objects.iteritems():
+for path, interfaces in objects.items():
if "org.bluez.Device1" not in interfaces:
continue
properties = interfaces["org.bluez.Device1"]
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/test/test-health-sink
^
|
@@ -41,7 +41,7 @@
objects = manager.GetManagedObjects()
adapters = []
-for path, ifaces in objects.iteritems():
+for path, ifaces in objects.items():
if ifaces.has_key(ADAPTER_INTERFACE):
adapters.append(path)
@@ -67,7 +67,7 @@
ADAPTER_INTERFACE)
devices = []
-for path, interfaces in objects.iteritems():
+for path, interfaces in objects.items():
if "org.bluez.Device1" not in interfaces:
continue
properties = interfaces["org.bluez.Device1"]
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/tools/bluetooth-player.c
^
|
@@ -15,33 +15,29 @@
#define _GNU_SOURCE
#include <stdio.h>
#include <stdbool.h>
+#include <stdint.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
+#include <fcntl.h>
#include <string.h>
+#include <sys/uio.h>
#include <glib.h>
#include "gdbus/gdbus.h"
-#include "src/shared/shell.h"
-/* String display constants */
-#define COLORED_NEW COLOR_GREEN "NEW" COLOR_OFF
-#define COLORED_CHG COLOR_YELLOW "CHG" COLOR_OFF
-#define COLORED_DEL COLOR_RED "DEL" COLOR_OFF
+#include "lib/bluetooth.h"
+#include "lib/uuid.h"
+
+#include "src/shared/util.h"
+#include "src/shared/shell.h"
+#include "client/player.h"
#define PROMPT_ON COLOR_BLUE "[bluetooth]" COLOR_OFF "# "
#define PROMPT_OFF "[bluetooth]# "
-#define BLUEZ_MEDIA_PLAYER_INTERFACE "org.bluez.MediaPlayer1"
-#define BLUEZ_MEDIA_FOLDER_INTERFACE "org.bluez.MediaFolder1"
-#define BLUEZ_MEDIA_ITEM_INTERFACE "org.bluez.MediaItem1"
-
static DBusConnection *dbus_conn;
-static GDBusProxy *default_player;
-static GList *players = NULL;
-static GList *folders = NULL;
-static GList *items = NULL;
static void connect_handler(DBusConnection *connection, void *user_data)
{
@@ -55,1076 +51,29 @@
bt_shell_set_prompt(PROMPT_OFF);
}
-static bool check_default_player(void)
-{
- if (!default_player) {
- bt_shell_printf("No default player available\n");
- return FALSE;
- }
-
- return TRUE;
-}
-
-static char *generic_generator(const char *text, int state, GList *source)
-{
- static int index = 0;
-
- if (!state) {
- index = 0;
- }
-
- return g_dbus_proxy_path_lookup(source, &index, text);
-}
-
-static char *player_generator(const char *text, int state)
-{
- return generic_generator(text, state, players);
-}
-
-static char *item_generator(const char *text, int state)
-{
- return generic_generator(text, state, items);
-}
-
-static void play_reply(DBusMessage *message, void *user_data)
-{
- DBusError error;
-
- dbus_error_init(&error);
-
- if (dbus_set_error_from_message(&error, message) == TRUE) {
- bt_shell_printf("Failed to play: %s\n", error.name);
- dbus_error_free(&error);
- return bt_shell_noninteractive_quit(EXIT_FAILURE);
- }
-
- bt_shell_printf("Play successful\n");
-
- return bt_shell_noninteractive_quit(EXIT_FAILURE);
-}
-
-static void cmd_play(int argc, char *argv[])
-{
- GDBusProxy *proxy;
-
- if (argc > 1) {
- proxy = g_dbus_proxy_lookup(items, NULL, argv[1],
- BLUEZ_MEDIA_ITEM_INTERFACE);
- if (proxy == NULL) {
- bt_shell_printf("Item %s not available\n", argv[1]);
- return bt_shell_noninteractive_quit(EXIT_FAILURE);
- }
- } else {
- if (!check_default_player())
- return bt_shell_noninteractive_quit(EXIT_FAILURE);
- proxy = default_player;
- }
-
- if (g_dbus_proxy_method_call(proxy, "Play", NULL, play_reply,
- NULL, NULL) == FALSE) {
- bt_shell_printf("Failed to play\n");
- return bt_shell_noninteractive_quit(EXIT_FAILURE);
- }
-
- bt_shell_printf("Attempting to play %s\n", argv[1] ? : "");
-}
-
-static void pause_reply(DBusMessage *message, void *user_data)
-{
- DBusError error;
-
- dbus_error_init(&error);
-
- if (dbus_set_error_from_message(&error, message) == TRUE) {
- bt_shell_printf("Failed to pause: %s\n", error.name);
- dbus_error_free(&error);
- return bt_shell_noninteractive_quit(EXIT_FAILURE);
- }
-
- bt_shell_printf("Pause successful\n");
-
- return bt_shell_noninteractive_quit(EXIT_SUCCESS);
-}
-
-static void cmd_pause(int argc, char *argv[])
-{
- if (!check_default_player())
- return bt_shell_noninteractive_quit(EXIT_FAILURE);
-
- if (g_dbus_proxy_method_call(default_player, "Pause", NULL,
- pause_reply, NULL, NULL) == FALSE) {
- bt_shell_printf("Failed to play\n");
- return bt_shell_noninteractive_quit(EXIT_FAILURE);
- }
-
- bt_shell_printf("Attempting to pause\n");
-}
-
-static void stop_reply(DBusMessage *message, void *user_data)
-{
- DBusError error;
-
- dbus_error_init(&error);
-
- if (dbus_set_error_from_message(&error, message) == TRUE) {
- bt_shell_printf("Failed to stop: %s\n", error.name);
- dbus_error_free(&error);
- return bt_shell_noninteractive_quit(EXIT_FAILURE);
- }
-
- bt_shell_printf("Stop successful\n");
-
- return bt_shell_noninteractive_quit(EXIT_SUCCESS);
-}
-
-static void cmd_stop(int argc, char *argv[])
-{
- if (!check_default_player())
- return bt_shell_noninteractive_quit(EXIT_FAILURE);
-
- if (g_dbus_proxy_method_call(default_player, "Stop", NULL, stop_reply,
- NULL, NULL) == FALSE) {
- bt_shell_printf("Failed to stop\n");
- return bt_shell_noninteractive_quit(EXIT_FAILURE);
- }
-
- bt_shell_printf("Attempting to stop\n");
-}
-
-static void next_reply(DBusMessage *message, void *user_data)
-{
- DBusError error;
-
- dbus_error_init(&error);
-
- if (dbus_set_error_from_message(&error, message) == TRUE) {
- bt_shell_printf("Failed to jump to next: %s\n", error.name);
- dbus_error_free(&error);
- return bt_shell_noninteractive_quit(EXIT_FAILURE);
- }
-
- bt_shell_printf("Next successful\n");
-
- return bt_shell_noninteractive_quit(EXIT_SUCCESS);
-}
-
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/tools/btgatt-client.c
^
|
@@ -1355,12 +1355,16 @@
return;
}
- if ((read = getline(&line, &len, stdin)) == -1)
+ read = getline(&line, &len, stdin);
+ if (read < 0) {
+ free(line);
return;
+ }
if (read <= 1) {
cmd_help(cli, NULL);
print_prompt();
+ free(line);
return;
}
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/tools/btgatt-server.c
^
|
@@ -20,7 +20,6 @@
#include <getopt.h>
#include <unistd.h>
#include <errno.h>
-#include <sys/random.h>
#include "lib/bluetooth.h"
#include "lib/hci.h"
@@ -287,7 +286,7 @@
uint32_t cur_ee;
uint32_t val;
- if (getrandom(&val, sizeof(val), 0) < 0)
+ if (util_getrandom(&val, sizeof(val), 0) < 0)
return false;
pdu[0] = 0x06;
@@ -1081,12 +1080,15 @@
}
read = getline(&line, &len, stdin);
- if (read < 0)
+ if (read < 0) {
+ free(line);
return;
+ }
if (read <= 1) {
cmd_help(server, NULL);
print_prompt();
+ free(line);
return;
}
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/tools/btiotest.c
^
|
@@ -29,6 +29,25 @@
#define DEFAULT_ACCEPT_TIMEOUT 2
static int opt_update_sec = 0;
+#define DEFAULT_IO_QOS \
+{ \
+ .interval = 10000, \
+ .latency = 10, \
+ .sdu = 40, \
+ .phy = 0x02, \
+ .rtn = 2, \
+}
+
+struct bt_iso_qos qos = {
+ .cig = BT_ISO_QOS_CIG_UNSET,
+ .cis = BT_ISO_QOS_CIG_UNSET,
+ .sca = 0x07,
+ .packing = 0x00,
+ .framing = 0x00,
+ .in = DEFAULT_IO_QOS,
+ .out = DEFAULT_IO_QOS,
+};
+
struct io_data {
guint ref;
GIOChannel *io;
@@ -36,6 +55,7 @@
int disconn;
int accept;
int voice;
+ struct bt_iso_qos *qos;
};
static void io_data_unref(struct io_data *data)
@@ -67,6 +87,7 @@
data->reject = reject;
data->disconn = disconn;
data->accept = accept;
+ data->qos = &qos;
return io_data_ref(data);
}
@@ -530,9 +551,88 @@
g_io_channel_unref(sco_srv);
}
+static void iso_connect(const char *src, const char *dst, int disconn)
+{
+ struct io_data *data;
+ GError *err = NULL;
+
+ printf("Connecting ISO to %s\n", dst);
+
+ data = io_data_new(NULL, -1, disconn, -1);
+
+ if (src)
+ data->io = bt_io_connect(connect_cb, data,
+ (GDestroyNotify) io_data_unref,
+ &err,
+ BT_IO_OPT_SOURCE, src,
+ BT_IO_OPT_DEST, dst,
+ BT_IO_OPT_MODE, BT_IO_MODE_ISO,
+ BT_IO_OPT_QOS, data->qos,
+ BT_IO_OPT_INVALID);
+ else
+ data->io = bt_io_connect(connect_cb, data,
+ (GDestroyNotify) io_data_unref,
+ &err,
+ BT_IO_OPT_DEST, dst,
+ BT_IO_OPT_MODE, BT_IO_MODE_ISO,
+ BT_IO_OPT_QOS, data->qos,
+ BT_IO_OPT_INVALID);
+
+ if (!data->io) {
+ printf("Connecting to %s failed: %s\n", dst, err->message);
+ g_error_free(err);
+ exit(EXIT_FAILURE);
+ }
+}
+
+static void iso_listen(const char *src, gboolean defer, int reject,
+ int disconn, int accept)
+{
+ struct io_data *data;
+ BtIOConnect conn;
+ BtIOConfirm cfm;
+ GIOChannel *iso_srv;
+ GError *err = NULL;
+
+ printf("Listening for ISO connections\n");
+
+ if (defer) {
+ conn = NULL;
+ cfm = confirm_cb;
+ } else {
+ conn = connect_cb;
+ cfm = NULL;
+ }
+
+ data = io_data_new(NULL, reject, disconn, accept);
+
+ if (src)
+ iso_srv = bt_io_listen(conn, cfm, data,
+ (GDestroyNotify) io_data_unref,
+ &err,
+ BT_IO_OPT_SOURCE, src,
+ BT_IO_OPT_MODE, BT_IO_MODE_ISO,
+ BT_IO_OPT_INVALID);
+ else
+ iso_srv = bt_io_listen(conn, cfm, data,
+ (GDestroyNotify) io_data_unref,
+ &err,
+ BT_IO_OPT_MODE, BT_IO_MODE_ISO,
+ BT_IO_OPT_INVALID);
+
+ if (!iso_srv) {
+ printf("Listening failed: %s\n", err->message);
+ g_error_free(err);
+ exit(EXIT_FAILURE);
+ }
+
+ g_io_channel_unref(iso_srv);
+}
+
static int opt_channel = -1;
static int opt_psm = 0;
static gboolean opt_sco = FALSE;
+static gboolean opt_iso = FALSE;
static gboolean opt_defer = FALSE;
static gint opt_voice = 0;
static char *opt_dev = NULL;
@@ -559,6 +659,8 @@
"(0 BR/EDR 1 LE Public 2 LE Random" },
{ "sco", 's', 0, G_OPTION_ARG_NONE, &opt_sco,
"Use SCO" },
+ { "iso", 'o', 0, G_OPTION_ARG_NONE, &opt_iso,
+ "Use ISO" },
{ "defer", 'd', 0, G_OPTION_ARG_NONE, &opt_defer,
"Use DEFER_SETUP for incoming connections" },
{ "voice", 'V', 0, G_OPTION_ARG_INT, &opt_voice,
@@ -637,6 +739,14 @@
opt_disconn, opt_accept, opt_voice);
}
+ if (opt_iso) {
+ if (argc > 1)
+ iso_connect(opt_dev, argv[1], opt_disconn);
+ else
+ iso_listen(opt_dev, opt_defer, opt_reject,
+ opt_disconn, opt_accept);
+ }
+
signal(SIGTERM, sig_term);
signal(SIGINT, sig_term);
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/tools/btmgmt.c
^
|
@@ -2696,7 +2696,6 @@
}
}
- argc -= optind;
argv += optind;
optind = 0;
@@ -2856,8 +2855,6 @@
}
}
- argc -= optind;
- argv += optind;
optind = 0;
cp = (void *) buf;
@@ -2931,8 +2928,6 @@
}
}
- argc -= optind;
- argv += optind;
optind = 0;
memset(&cp, 0, sizeof(cp));
@@ -2997,8 +2992,6 @@
}
}
- argc -= optind;
- argv += optind;
optind = 0;
memset(&cp, 0, sizeof(cp));
@@ -3258,7 +3251,7 @@
struct mgmt_cp_unpair_device cp;
uint8_t type = BDADDR_BREDR;
int opt;
- uint16_t index = mgmt_index;
+ uint16_t index;
while ((opt = getopt_long(argc, argv, "+t:h", unpair_options,
NULL)) != -1) {
@@ -3447,8 +3440,6 @@
}
}
- argc -= optind;
- argv += optind;
optind = 0;
cp->irk_count = cpu_to_le16(count);
@@ -4819,8 +4810,11 @@
memcpy(cp->data + 2, uuids, uuid_bytes - 2);
}
- memcpy(cp->data + uuid_bytes, adv_data, adv_len);
- memcpy(cp->data + uuid_bytes + adv_len, scan_rsp, scan_rsp_len);
+ if (adv_len)
+ memcpy(cp->data + uuid_bytes, adv_data, adv_len);
+
+ if (scan_rsp_len)
+ memcpy(cp->data + uuid_bytes + adv_len, scan_rsp, scan_rsp_len);
if (!mgmt_send(mgmt, MGMT_OP_ADD_ADVERTISING, index, cp_len, cp,
add_adv_rsp, NULL, NULL)) {
@@ -4891,6 +4885,380 @@
cmd_rm_adv(2, rm_argv);
}
+static void add_ext_adv_params_rsp(uint8_t status, uint16_t len,
+ const void *param, void *user_data)
+{
+ const struct mgmt_rp_add_ext_adv_params *rp = param;
+
+ if (status != 0) {
+ error("Add Ext Adv Params failed status 0x%02x (%s)",
+ status, mgmt_errstr(status));
+ return bt_shell_noninteractive_quit(EXIT_FAILURE);
+ }
+
+ if (len != sizeof(*rp)) {
+ error("Invalid Add Ext Adv Params response length (%u)", len);
+ return bt_shell_noninteractive_quit(EXIT_FAILURE);
+ }
+
+ print("Instance added: %u", rp->instance);
+ print("Tx Power: %u", rp->tx_power);
+ print("Max adv data len: %u", rp->max_adv_data_len);
+ print("Max scan resp len: %u", rp->max_scan_rsp_len);
+
+ return bt_shell_noninteractive_quit(EXIT_SUCCESS);
+}
+
+static void add_ext_adv_params_usage(void)
+{
+ bt_shell_usage();
+ print("Options:\n"
+ "\t -d, --duration <duration> Duration in seconds\n"
+ "\t -t, --timeout <timeout> Timeout in seconds\n"
+ "\t -r, --min-interval <valr> Minimum interval\n"
+ "\t -x, --max-interval <valr> Maximum interval\n"
+ "\t -w, --tx-power <power> Tx power\n"
+ "\t -P, --phy <phy> Phy type, Specify 1M/2M/CODED\n"
+ "\t -c, --connectable \"connectable\" flag\n"
+ "\t -g, --general-discov \"general-discoverable\" flag\n"
+ "\t -l, --limited-discov \"limited-discoverable\" flag\n"
+ "\t -m, --managed-flags \"managed-flags\" flag\n"
+ "\t -p, --add-tx-power \"tx-power\" flag\n"
+ "\t -a, --scan-rsp-appearance \"appearance\" flag\n"
+ "\t -n, --scan-rsp-local-name \"local-name\" flag\n"
+ "\t -s, --adv-scan-rsp \"scan resp in adv\" flag\n"
+ "\t -h, --help Show help\n"
+ "e.g.:\n"
+ "\tadd-ext-adv-params -r 0x801 -x 0x802 -P 2M -g 1");
+}
+
+static struct option add_ext_adv_params_options[] = {
+ { "help", 0, 0, 'h' },
+ { "duration", 1, 0, 'd' },
+ { "timeout", 1, 0, 't' },
+ { "min-internal", 1, 0, 'r' },
+ { "max-interval", 1, 0, 'x' },
+ { "tx-power", 1, 0, 'w' },
+ { "phy", 1, 0, 'P' },
+ { "connectable", 0, 0, 'c' },
+ { "general-discov", 0, 0, 'g' },
+ { "limited-discov", 0, 0, 'l' },
+ { "scan-rsp-local-name", 0, 0, 'n' },
+ { "scan-rsp-appearance", 0, 0, 'a' },
+ { "managed-flags", 0, 0, 'm' },
+ { "add-tx-power", 0, 0, 'p' },
+ { "adv-scan-rsp", 0, 0, 's' },
+ { 0, 0, 0, 0}
+};
+
+static void cmd_add_ext_adv_params(int argc, char **argv)
+{
+ struct mgmt_cp_add_ext_adv_params *cp = NULL;
+ int opt;
+ uint16_t timeout = 0, duration = 0;
+ uint8_t instance;
+ bool success = false;
+ bool quit = true;
+ uint32_t flags = 0;
+ uint32_t min_interval = 0;
+ uint32_t max_interval = 0;
+ uint8_t tx_power = 0;
+ uint16_t index;
+
+ while ((opt = getopt_long(argc, argv, "d:t:r:x:w:P:cglmpansh",
+ add_ext_adv_params_options, NULL)) != -1) {
+ switch (opt) {
+ case 'd':
+ duration = strtol(optarg, NULL, 0);
+ flags |= MGMT_ADV_PARAM_DURATION;
+ break;
+ case 't':
+ timeout = strtol(optarg, NULL, 0);
+ flags |= MGMT_ADV_PARAM_TIMEOUT;
+ break;
+ case 'r':
+ min_interval = strtol(optarg, NULL, 0);
+ break;
+ case 'x':
+ max_interval = strtol(optarg, NULL, 0);
+ break;
+ case 'w':
+ tx_power = strtol(optarg, NULL, 0);
+ flags |= MGMT_ADV_PARAM_TX_POWER;
+ break;
+ case 'P':
+ if (strcasecmp(optarg, "1M") == 0)
+ flags |= MGMT_ADV_FLAG_SEC_1M;
+ else if (strcasecmp(optarg, "2M") == 0)
+ flags |= MGMT_ADV_FLAG_SEC_2M;
+ else if (strcasecmp(optarg, "CODED") == 0)
+ flags |= MGMT_ADV_FLAG_SEC_CODED;
+ else
+ goto done;
+ break;
+ case 'c':
+ flags |= MGMT_ADV_FLAG_CONNECTABLE;
+ break;
+ case 'g':
+ flags |= MGMT_ADV_FLAG_DISCOV;
+ break;
+ case 'l':
+ flags |= MGMT_ADV_FLAG_LIMITED_DISCOV;
+ break;
+ case 'n':
+ flags |= MGMT_ADV_FLAG_LOCAL_NAME;
+ break;
+ case 'a':
+ flags |= MGMT_ADV_FLAG_APPEARANCE;
+ break;
+ case 'm':
+ flags |= MGMT_ADV_FLAG_MANAGED_FLAGS;
+ break;
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/tools/btproxy.c
^
|
@@ -47,8 +47,10 @@
unsigned short hci_channel;
};
#define HCI_CHANNEL_USER 1
+#define HCI_INDEX_NONE 0xffff
+#define HCI_INDEX_MAX 16
-static uint16_t hci_index = 0;
+static uint64_t hci_index = HCI_INDEX_NONE;
static bool client_active = false;
static bool debug_enabled = false;
static bool emulate_ecc = false;
@@ -532,12 +534,20 @@
return true;
}
-static int open_channel(uint16_t index)
+static int open_channel(uint64_t hci_index)
{
struct sockaddr_hci addr;
- int fd;
+ int fd, err;
+ uint8_t index;
+
+ index = util_get_uid(&hci_index, HCI_INDEX_MAX);
+ if (index == 0) {
+ perror("No controller available");
+ return -1;
+ }
+ index--;
- printf("Opening user channel for hci%u\n", hci_index);
+ printf("Opening user channel for hci%u\n", index);
fd = socket(PF_BLUETOOTH, SOCK_RAW | SOCK_CLOEXEC, BTPROTO_HCI);
if (fd < 0) {
@@ -551,7 +561,15 @@
addr.hci_channel = HCI_CHANNEL_USER;
if (bind(fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
+ err = -errno;
close(fd);
+
+ /* Open next available controller if the error indicates
+ * that the controller is in use.
+ */
+ if (err == -EBUSY || err == -EUSERS)
+ return open_channel(hci_index);
+
perror("Failed to bind Bluetooth socket");
return -1;
}
@@ -588,12 +606,6 @@
return;
}
- if (client_active) {
- fprintf(stderr, "Active client already present\n");
- close(host_fd);
- return;
- }
-
dev_fd = open_channel(hci_index);
if (dev_fd < 0) {
close(host_fd);
@@ -787,6 +799,7 @@
for (;;) {
int opt;
+ int index;
opt = getopt_long(argc, argv, "rc:l::u::p:i:aezdvh",
main_options, NULL);
@@ -831,7 +844,13 @@
usage();
return EXIT_FAILURE;
}
- hci_index = atoi(str);
+ index = atoi(str) + 1;
+ if (index > HCI_INDEX_MAX) {
+ fprintf(stderr, "Invalid controller index\n");
+ usage();
+ return EXIT_FAILURE;
+ }
+ util_clear_uid(&hci_index, index);
break;
case 'a':
type = HCI_AMP;
@@ -871,6 +890,9 @@
return EXIT_FAILURE;
}
+ if (hci_index == HCI_INDEX_NONE)
+ hci_index = 0;
+
mainloop_init();
if (connect_address || use_redirect) {
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/tools/btsnoop.c
^
|
@@ -193,7 +193,7 @@
flags = be32toh(input_pkt[select_input].flags);
len = read(input_fd[select_input], buf, toread);
- if (len < 0 || len != (ssize_t) toread) {
+ if (toread == 0 || len < 0 || len != (ssize_t) toread) {
close(input_fd[select_input]);
input_fd[select_input] = -1;
goto next_packet;
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/tools/cltest.c
^
|
@@ -72,6 +72,7 @@
return false;
}
+ close(fd);
return true;
}
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/tools/create-image.c
^
|
@@ -97,12 +97,13 @@
map = mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
if (!map || map == MAP_FAILED) {
- close(fd);
- fd = -1;
map = NULL;
st.st_size = 0;
}
+ close(fd);
+ fd = -1;
+
done:
fprintf(fp, HDR_FMT, HDR_MAGIC, ino, mode, 0, 0, 1, 0,
(uintmax_t) st.st_size, 0, 0, 0, 0, namelen + 1, 0, name);
@@ -117,9 +118,7 @@
pad = 3 - ((st.st_size + 3) % 4);
for (i = 0; i < pad; i++)
fputc(0, fp);
-
munmap(map, st.st_size);
- close(fd);
}
}
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/tools/gatt-service.c
^
|
@@ -26,6 +26,7 @@
#include "gdbus/gdbus.h"
#include "src/error.h"
+#include "src/shared/util.h"
#define GATT_MGR_IFACE "org.bluez.GattManager1"
#define GATT_SERVICE_IFACE "org.bluez.GattService1"
@@ -126,8 +127,8 @@
static void desc_write(struct descriptor *desc, const uint8_t *value, int len)
{
- g_free(desc->value);
- desc->value = g_memdup(value, len);
+ free(desc->value);
+ desc->value = util_memdup(value, len);
desc->vlen = len;
g_dbus_emit_property_changed(connection, desc->path,
@@ -264,8 +265,8 @@
static void chr_write(struct characteristic *chr, const uint8_t *value, int len)
{
- g_free(chr->value);
- chr->value = g_memdup(value, len);
+ free(chr->value);
+ chr->value = util_memdup(value, len);
chr->vlen = len;
g_dbus_emit_property_changed(connection, chr->path, GATT_CHR_IFACE,
@@ -388,7 +389,7 @@
g_free(chr->uuid);
g_free(chr->service);
- g_free(chr->value);
+ free(chr->value);
g_free(chr->path);
g_free(chr);
}
@@ -398,7 +399,7 @@
struct descriptor *desc = user_data;
g_free(desc->uuid);
- g_free(desc->value);
+ free(desc->value);
g_free(desc->path);
g_free(desc);
}
@@ -592,7 +593,7 @@
chr = g_new0(struct characteristic, 1);
chr->uuid = g_strdup(chr_uuid);
- chr->value = g_memdup(value, vlen);
+ chr->value = util_memdup(value, vlen);
chr->vlen = vlen;
chr->props = props;
chr->service = g_strdup(service_path);
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/tools/hciattach_tialt.c
^
|
@@ -221,7 +221,8 @@
((brf_chip > 7) ? "unknown" : c_brf_chip[brf_chip]),
brf_chip);
- sprintf(fw, "/etc/firmware/%s.bin", c_brf_chip[brf_chip]);
+ sprintf(fw, "/etc/firmware/%s.bin",
+ (brf_chip > 7) ? "unknown" : c_brf_chip[brf_chip]);
texas_load_firmware(fd, fw);
texas_change_speed(fd, speed);
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/tools/hciconfig.c
^
|
@@ -80,7 +80,11 @@
static void print_link_policy(struct hci_dev_info *di)
{
- printf("\tLink policy: %s\n", hci_lptostr(di->link_policy));
+ char *str;
+
+ str = hci_lptostr(di->link_policy);
+ printf("\tLink policy: %s\n", str);
+ bt_free(str);
}
static void print_link_mode(struct hci_dev_info *di)
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/tools/hex2hcd.c
^
|
@@ -248,7 +248,7 @@
memset(ver, 0, sizeof(*ver));
- if (sscanf(pathname, "%[A-Z0-9]_%3c.%3c.%3c.%4c.%4c.hex",
+ if (sscanf(pathname, "%19[A-Z0-9]_%3c.%3c.%3c.%4c.%4c.hex",
ver->name, ver->major, ver->minor,
ver->build, dummy1, dummy2) != 6) {
printf("\t/* failed to parse %s */\n", pathname);
|
[-]
[+]
|
Added |
_service:tar_git:bluez5-5.65+git1.tar.gz/tools/iso-tester.c
^
|
@@ -0,0 +1,1702 @@
+// SPDX-License-Identifier: LGPL-2.1-or-later
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2022 Intel Corporation.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+#include <poll.h>
+#include <stdbool.h>
+
+#include <glib.h>
+
+#include "lib/bluetooth.h"
+#include "lib/iso.h"
+#include "lib/mgmt.h"
+
+#include "monitor/bt.h"
+#include "emulator/bthost.h"
+#include "emulator/hciemu.h"
+
+#include "src/shared/tester.h"
+#include "src/shared/mgmt.h"
+#include "src/shared/util.h"
+
+#define QOS_IO(_interval, _latency, _sdu, _phy, _rtn) \
+{ \
+ .interval = _interval, \
+ .latency = _latency, \
+ .sdu = _sdu, \
+ .phy = _phy, \
+ .rtn = _rtn, \
+}
+
+#define QOS_FULL(_cig, _cis, _in, _out) \
+{ \
+ .cig = _cig, \
+ .cis = _cis, \
+ .sca = 0x07, \
+ .packing = 0x00, \
+ .framing = 0x00, \
+ .in = _in, \
+ .out = _out, \
+}
+
+#define QOS(_interval, _latency, _sdu, _phy, _rtn) \
+ QOS_FULL(BT_ISO_QOS_CIG_UNSET, BT_ISO_QOS_CIS_UNSET, \
+ QOS_IO(_interval, _latency, _sdu, _phy, _rtn), \
+ QOS_IO(_interval, _latency, _sdu, _phy, _rtn))
+
+#define QOS_1(_interval, _latency, _sdu, _phy, _rtn) \
+ QOS_FULL(0x01, BT_ISO_QOS_CIS_UNSET, \
+ QOS_IO(_interval, _latency, _sdu, _phy, _rtn), \
+ QOS_IO(_interval, _latency, _sdu, _phy, _rtn))
+
+#define QOS_1_1(_interval, _latency, _sdu, _phy, _rtn) \
+ QOS_FULL(0x01, 0x01, \
+ QOS_IO(_interval, _latency, _sdu, _phy, _rtn), \
+ QOS_IO(_interval, _latency, _sdu, _phy, _rtn))
+
+#define QOS_OUT(_interval, _latency, _sdu, _phy, _rtn) \
+ QOS_FULL(BT_ISO_QOS_CIG_UNSET, BT_ISO_QOS_CIS_UNSET, \
+ {}, QOS_IO(_interval, _latency, _sdu, _phy, _rtn))
+
+#define QOS_OUT_1(_interval, _latency, _sdu, _phy, _rtn) \
+ QOS_FULL(0x01, BT_ISO_QOS_CIS_UNSET, \
+ {}, QOS_IO(_interval, _latency, _sdu, _phy, _rtn))
+
+#define QOS_OUT_1_1(_interval, _latency, _sdu, _phy, _rtn) \
+ QOS_FULL(0x01, 0x01, \
+ {}, QOS_IO(_interval, _latency, _sdu, _phy, _rtn))
+
+#define QOS_IN(_interval, _latency, _sdu, _phy, _rtn) \
+ QOS_FULL(BT_ISO_QOS_CIG_UNSET, BT_ISO_QOS_CIS_UNSET, \
+ QOS_IO(_interval, _latency, _sdu, _phy, _rtn), {})
+
+/* QoS Configuration settings for low latency audio data */
+#define QOS_8_1_1 QOS(7500, 8, 26, 0x02, 2)
+#define QOS_8_2_1 QOS(10000, 10, 30, 0x02, 2)
+#define QOS_16_1_1 QOS(7500, 8, 30, 0x02, 2)
+#define QOS_16_2_1 QOS(10000, 10, 40, 0x02, 2)
+#define QOS_1_16_2_1 QOS_1(10000, 10, 40, 0x02, 2)
+#define QOS_1_1_16_2_1 QOS_1_1(10000, 10, 40, 0x02, 2)
+#define QOS_24_1_1 QOS(7500, 8, 45, 0x02, 2)
+#define QOS_24_2_1 QOS(10000, 10, 60, 0x02, 2)
+#define QOS_32_1_1 QOS(7500, 8, 60, 0x02, 2)
+#define QOS_32_2_1 QOS(10000, 10, 80, 0x02, 2)
+#define QOS_44_1_1 QOS_OUT(8163, 24, 98, 0x02, 5)
+#define QOS_44_2_1 QOS_OUT(10884, 31, 130, 0x02, 5)
+#define QOS_48_1_1 QOS_OUT(7500, 15, 75, 0x02, 5)
+#define QOS_48_2_1 QOS_OUT(10000, 20, 100, 0x02, 5)
+#define QOS_48_3_1 QOS_OUT(7500, 15, 90, 0x02, 5)
+#define QOS_48_4_1 QOS_OUT(10000, 20, 120, 0x02, 5)
+#define QOS_48_5_1 QOS_OUT(7500, 15, 117, 0x02, 5)
+#define QOS_48_6_1 QOS_OUT(10000, 20, 155, 0x02, 5)
+/* QoS Configuration settings for high reliability audio data */
+#define QOS_8_1_2 QOS(7500, 45, 26, 0x02, 41)
+#define QOS_8_2_2 QOS(10000, 60, 30, 0x02, 53)
+#define QOS_16_1_2 QOS(7500, 45, 30, 0x02, 41)
+#define QOS_16_2_2 QOS(10000, 60, 40, 0x02, 47)
+#define QOS_24_1_2 QOS(7500, 45, 45, 0x02, 35)
+#define QOS_24_2_2 QOS(10000, 60, 60, 0x02, 41)
+#define QOS_32_1_2 QOS(7500, 45, 60, 0x02, 29)
+#define QOS_32_2_2 QOS(10000, 60, 80, 0x02, 35)
+#define QOS_44_1_2 QOS_OUT(8163, 54, 98, 0x02, 23)
+#define QOS_44_2_2 QOS_OUT(10884, 71, 130, 0x02, 23)
+#define QOS_48_1_2 QOS_OUT(7500, 45, 75, 0x02, 23)
+#define QOS_48_2_2 QOS_OUT(10000, 60, 100, 0x02, 23)
+#define QOS_48_3_2 QOS_OUT(7500, 45, 90, 0x02, 23)
+#define QOS_48_4_2 QOS_OUT(10000, 60, 120, 0x02, 23)
+#define QOS_48_5_2 QOS_OUT(7500, 45, 117, 0x02, 23)
+#define QOS_48_6_2 QOS_OUT(10000, 60, 155, 0x02, 23)
+
+#define QOS_OUT_16_2_1 QOS_OUT(10000, 10, 40, 0x02, 2)
+#define QOS_OUT_1_16_2_1 QOS_OUT_1(10000, 10, 40, 0x02, 2)
+#define QOS_OUT_1_1_16_2_1 QOS_OUT_1_1(10000, 10, 40, 0x02, 2)
+#define QOS_IN_16_2_1 QOS_IN(10000, 10, 40, 0x02, 2)
+
+struct test_data {
+ const void *test_data;
+ struct mgmt *mgmt;
+ uint16_t mgmt_index;
+ struct hciemu *hciemu;
+ enum hciemu_type hciemu_type;
+ uint16_t handle;
+ uint16_t acl_handle;
+ GIOChannel *io;
+ unsigned int io_id[2];
+ uint8_t client_num;
+ int step;
+};
+
+struct iso_client_data {
+ struct bt_iso_qos qos;
+ int expect_err;
+ const struct iovec *send;
+ const struct iovec *recv;
+ bool server;
+ bool bcast;
+ bool defer;
+};
+
+static void mgmt_debug(const char *str, void *user_data)
+{
+ const char *prefix = user_data;
+
+ tester_print("%s%s", prefix, str);
+}
+
+static void read_info_callback(uint8_t status, uint16_t length,
+ const void *param, void *user_data)
+{
+ struct test_data *data = tester_get_data();
+ const struct mgmt_rp_read_info *rp = param;
+ char addr[18];
+ uint16_t manufacturer;
+ uint32_t supported_settings, current_settings;
+
+ tester_print("Read Info callback");
+ tester_print(" Status: 0x%02x", status);
+
+ if (status || !param) {
+ tester_pre_setup_failed();
+ return;
+ }
+
+ ba2str(&rp->bdaddr, addr);
+ manufacturer = btohs(rp->manufacturer);
+ supported_settings = btohl(rp->supported_settings);
+ current_settings = btohl(rp->current_settings);
+
+ tester_print(" Address: %s", addr);
+ tester_print(" Version: 0x%02x", rp->version);
+ tester_print(" Manufacturer: 0x%04x", manufacturer);
+ tester_print(" Supported settings: 0x%08x", supported_settings);
+ tester_print(" Current settings: 0x%08x", current_settings);
+ tester_print(" Class: 0x%02x%02x%02x",
+ rp->dev_class[2], rp->dev_class[1], rp->dev_class[0]);
+ tester_print(" Name: %s", rp->name);
+ tester_print(" Short name: %s", rp->short_name);
+
+ if (strcmp(hciemu_get_address(data->hciemu), addr)) {
+ tester_pre_setup_failed();
+ return;
+ }
+
+ tester_pre_setup_complete();
+}
+
+static void index_added_callback(uint16_t index, uint16_t length,
+ const void *param, void *user_data)
|
[-]
[+]
|
Added |
_service:tar_git:bluez5-5.65+git1.tar.gz/tools/isotest.c
^
|
@@ -0,0 +1,1217 @@
+// SPDX-License-Identifier: LGPL-2.1-or-later
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2022 Intel Corporation.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <errno.h>
+#include <stdbool.h>
+#include <ctype.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <getopt.h>
+#include <syslog.h>
+#include <signal.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <sys/uio.h>
+#include <linux/sockios.h>
+#include <time.h>
+
+#include "lib/bluetooth.h"
+#include "lib/hci.h"
+#include "lib/hci_lib.h"
+#include "lib/mgmt.h"
+#include "lib/iso.h"
+
+#include "src/shared/util.h"
+
+#define NSEC_USEC(_t) (_t / 1000L)
+#define SEC_USEC(_t) (_t * 1000000L)
+#define TS_USEC(_ts) (SEC_USEC((_ts)->tv_sec) + NSEC_USEC((_ts)->tv_nsec))
+
+/* Test modes */
+enum {
+ SEND,
+ RECV,
+ RECONNECT,
+ MULTY,
+ DUMP,
+ CONNECT
+};
+
+static unsigned char *buf;
+
+/* Default data size */
+static long data_size = 251;
+
+static int mgmt_index = MGMT_INDEX_NONE;
+static bdaddr_t bdaddr;
+static int bdaddr_type = BDADDR_LE_PUBLIC;
+
+static int defer_setup;
+static int sndbuf;
+static struct timeval sndto;
+static bool quiet;
+
+struct bt_iso_qos *iso_qos;
+static bool inout;
+
+struct lookup_table {
+ const char *name;
+ int flag;
+};
+
+static struct lookup_table bdaddr_types[] = {
+ { "le_public", BDADDR_LE_PUBLIC },
+ { "le_random", BDADDR_LE_RANDOM },
+ { NULL, 0 },
+};
+
+static int get_lookup_flag(struct lookup_table *table, char *name)
+{
+ int i;
+
+ for (i = 0; table[i].name; i++)
+ if (!strcasecmp(table[i].name, name))
+ return table[i].flag;
+
+ return -1;
+}
+
+static void print_lookup_values(struct lookup_table *table, char *header)
+{
+ int i;
+
+ printf("%s\n", header);
+
+ for (i = 0; table[i].name; i++)
+ printf("\t%s\n", table[i].name);
+}
+
+static float tv2fl(struct timeval tv)
+{
+ return (float)tv.tv_sec + (float)(tv.tv_usec/1000000.0);
+}
+
+static const uint8_t set_iso_socket_param[] = {
+ 0x3e, 0xe0, 0xb4, 0xfd, 0xdd, 0xd6, 0x85, 0x98, /* UUID - ISO Socket */
+ 0x6a, 0x49, 0xe0, 0x05, 0x88, 0xf1, 0xba, 0x6f,
+ 0x01, /* Action - enable */
+};
+
+static int mgmt_recv(int fd)
+{
+ uint8_t buf[1024];
+
+ return read(fd, buf, sizeof(buf));
+}
+
+static int mgmt_send_cmd(int fd, uint16_t op, uint16_t id, const void *data,
+ size_t len)
+{
+ struct mgmt_hdr hdr;
+ struct iovec iov[2];
+ int ret;
+
+ memset(&hdr, 0, sizeof(hdr));
+ hdr.opcode = htobs(op);
+ hdr.index = htobs(id);
+ hdr.len = htobs(len);
+
+ iov[0].iov_base = &hdr;
+ iov[0].iov_len = sizeof(hdr);
+
+ iov[1].iov_base = (void *)data;
+ iov[1].iov_len = len;
+
+ ret = writev(fd, iov, 2);
+ if (ret < 0)
+ return ret;
+
+ /* Wait for MGMT to respond */
+ ret = mgmt_recv(fd);
+ if (ret < 0)
+ return ret;
+
+ return 0;
+}
+
+static int mgmt_open(void)
+{
+ union {
+ struct sockaddr common;
+ struct sockaddr_hci hci;
+ } addr;
+ int fd, err;
+
+ fd = socket(PF_BLUETOOTH, SOCK_RAW | SOCK_CLOEXEC | SOCK_NONBLOCK,
+ BTPROTO_HCI);
+ if (fd < 0) {
+ syslog(LOG_ERR, "Can't create mgmt socket: %s (%d)",
+ strerror(errno), errno);
+ return -errno;
+ }
+
+ syslog(LOG_ERR, "mgmt socket: fd %d", fd);
+
+ memset(&addr, 0, sizeof(addr));
+ addr.hci.hci_family = AF_BLUETOOTH;
+ addr.hci.hci_dev = HCI_DEV_NONE;
+ addr.hci.hci_channel = HCI_CHANNEL_CONTROL;
+
+ if (bind(fd, &addr.common, sizeof(addr.hci)) < 0) {
+ syslog(LOG_ERR, "Can't bind mgmt socket: %s (%d)",
+ strerror(errno), errno);
+ err = -errno;
+ close(fd);
+ return err;
+ }
+
+ return fd;
+}
+
+
+static const uint8_t set_le_param[] = {
+ 0x01, /* Action - enable */
+};
+
+static int mgmt_set_le(int fd)
+{
+ int err, index;
+
+ index = mgmt_index;
+ if (index == MGMT_INDEX_NONE)
+ index = 0;
+
|
[-]
[+]
|
Added |
_service:tar_git:bluez5-5.65+git1.tar.gz/tools/isotest.rst
^
|
@@ -0,0 +1,202 @@
+=======
+isotest
+=======
+
+-----------
+ISO testing
+-----------
+
+:Authors: - Luiz Augusto Von Dentz <luiz.von.dentz@intel.com>
+:Version: BlueZ
+:Copyright: Free use of this software is granted under ther terms of the GNU
+ Lesser General Public Licenses (LGPL).
+:Date: May 4, 2022
+:Manual section: 1
+:Manual group: Linux System Administration
+
+SYNOPSIS
+========
+
+**isotest** <*MODE*> [*OPTIONS*] [*bdaddr*] [*bdaddr1*]...
+
+DESCRIPTION
+===========
+
+**isotest(1)** is used to test Isochronous (CIS/BIS) communications on the
+BlueZ stack
+
+MODES
+=====
+
+-d, --dump=[FILE] Listen and dump incoming data
+ (CIS server/BIS broadcaster) and optionally save the
+ contents to *FILE*.
+
+-c, --reconnect Reconnect (CIS client).
+
+-m, --multiple Multiple connects (CIS client).
+
+-r, --receive=[FILE] Receive (CIS server/BIS broadcast receiver) and
+ optionally save the contents to *FILE*.
+
+-s, --send=[FILE] Connect and send (CIS client/BIS broadcaster), can
+ optionally use contents from *FILE*.
+
+-n, --silent Connect and be silent (CIS client/BIS broadcaster).
+
+OPTIONS
+=======
+
+-b, --bytes=<SIZE> Send or Receive packet size
+
+-i, --index=<NUM> Select the specified HCI device index. *hciNUM* is
+ also acceptable.
+
+-j, --jitter=<JITTER> Socket jitter buffer.
+
+-h, --help
+
+-q, --quiet Disables packet logging.
+
+-t, --timeout=<USEC> Socket send timeout.
+
+-C, --continue Continuously send packets starting over in case of a
+ file.
+
+-W, --defer=<SEC> Enable deferred setup.
+
+-M, --mtu=<SDU> Socket QoS SDU.
+
+-S, --sca/adv-interval=<SCA/INTERVAL>
+ Socket QoS CIS SCA/BIS advertising interval.
+
+-P, --packing=<PACKING> Socket QoS Packing.
+
+.. list-table::
+ :header-rows: 1
+ :widths: auto
+ :stub-columns: 1
+ :align: left
+
+ * - *PACKING*
+ - Description
+
+ * - **0x00**
+ - Sequential
+
+ * - **0x01**
+ - Interleaved
+
+-F, --framing=<FRAMING> Socket QoS Framing.
+
+.. list-table::
+ :header-rows: 1
+ :widths: auto
+ :stub-columns: 1
+ :align: left
+
+ * - *FRAMING*
+ - Description
+
+ * - **0x00**
+ - Unframed
+
+ * - **0x01**
+ - Framed
+
+-I, --interval=<USEC> Socket QoS Interval.
+
+-L, --latency=<MSEC> Socket QoS Latency.
+
+-Y, --phy=<PHY> Socket QoS PHY.
+
+.. list-table::
+ :header-rows: 1
+ :widths: auto
+ :stub-columns: 1
+ :align: left
+
+ * - *PHY*
+ - Description
+
+ * - **0x01**
+ - LE 1M
+
+ * - **0x02**
+ - LE 2M
+
+ * - **0x03**
+ - LE Coded
+
+-R, --rtn=<NUM> Socket QoS retransmissions.
+
+-B, --preset=<PRESET> Socket QoS preset.
+
+-G, --CIG/BIG=<ID> Socket QoS CIG/BIG ID.
+
+-T, --CIS/BIS=<ID> Socket QoS CIS/BIS ID.
+
+-V, --type=<TYPE> Socket destination address type:
+
+.. list-table::
+ :header-rows: 1
+ :widths: auto
+ :stub-columns: 1
+ :align: left
+
+ * - *TYPE*
+ - Description
+
+ * - **le_public**
+ - LE Public Address
+
+ * - **le_random**
+ - LE Random Address
+
+EXAMPLES
+========
+
+Unicast Central
+---------------
+
+.. code-block::
+
+ $ tools/isotest -s XX:XX:XX:XX:XX:XX
+
+Unicast Central connecting to 2 peers using CIG 0x01
+----------------------------------------------------
+
+.. code-block::
+
+ $ tools/isotest -G 0x01 -s XX:XX:XX:XX:XX:XX YY:YY:YY:YY:YY:YY
+
+Unicast Peripheral
+------------------
+
+.. code-block::
+
+ $ tools/isotest -d
+
+Broadcaster
+-----------
+
+.. code-block::
+
+ $ tools/isotest -s 00:00:00:00:00:00
+
+Broadcast Receiver using hci1
+-----------------------------
+
+.. code-block::
+
+ $ tools/isotest -i hci1 -d XX:XX:XX:XX:XX:XX
+
+RESOURCES
+=========
+
+http://www.bluez.org
+
+REPORTING BUGS
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/tools/l2cap-tester.c
^
|
@@ -1709,6 +1709,7 @@
if (!check_mtu(data, new_sk)) {
tester_test_failed();
+ close(new_sk);
return FALSE;
}
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/tools/mesh-cfgtest.c
^
|
@@ -21,6 +21,7 @@
#include <ftw.h>
#include <getopt.h>
#include <libgen.h>
+#include <limits.h>
#include <signal.h>
#include <stdio.h>
#include <time.h>
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/tools/mesh-gatt/gatt.c
^
|
@@ -24,6 +24,7 @@
#include "src/shared/io.h"
#include "src/shared/shell.h"
+#include "src/shared/util.h"
#include "gdbus/gdbus.h"
#include "lib/bluetooth.h"
#include "lib/uuid.h"
@@ -86,7 +87,7 @@
{
struct write_data *data = user_data;
- g_free(data->gatt_data);
+ free(data->gatt_data);
free(data);
}
@@ -338,7 +339,7 @@
/* TODO: should keep in queue in case we need to cancel write? */
data->gatt_len = len;
- data->gatt_data = g_memdup(buf, len);
+ data->gatt_data = util_memdup(buf, len);
data->gatt_data[0] &= GATT_TYPE_MASK;
data->iov.iov_base = data->gatt_data;
data->iov.iov_len = len;
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/tools/mesh-gatt/prov-db.c
^
|
@@ -859,7 +859,8 @@
set_local_iv_index(jmain, iv_index, update);
prov_file_write(jmain, false);
- }
+ } else
+ return true;
res = true;
done:
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/tools/mesh/cfgcli.c
^
|
@@ -1291,7 +1291,7 @@
if (!remote_has_composition(target)) {
bt_shell_printf("Node composition is unknown\n");
- bt_shell_printf("Call \"get-composition\" first\n");
+ bt_shell_printf("Call \"composition-get\" first\n");
return bt_shell_noninteractive_quit(EXIT_FAILURE);
}
@@ -1493,7 +1493,7 @@
if (!remote_has_composition(target)) {
bt_shell_printf("Node composition is unknown\n");
- bt_shell_printf("Call \"get-composition\" first\n");
+ bt_shell_printf("Call \"composition-get\" first\n");
return bt_shell_noninteractive_quit(EXIT_FAILURE);
}
@@ -1593,7 +1593,7 @@
if (!remote_has_composition(target)) {
bt_shell_printf("Node composition is unknown\n");
- bt_shell_printf("Call \"get-composition\" first\n");
+ bt_shell_printf("Call \"composition-get\" first\n");
return bt_shell_noninteractive_quit(EXIT_FAILURE);
}
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/tools/mesh/mesh-db.c
^
|
@@ -2007,7 +2007,7 @@
if (!cfg || !cfg->jcfg)
return false;
- jarray = json_object_object_get(cfg->jcfg, "provisioniers");
+ jarray = json_object_object_get(cfg->jcfg, "provisioners");
if (!jarray || json_object_get_type(jarray) != json_type_array)
return false;
@@ -2041,7 +2041,7 @@
}
/*
- * This is a simplistic implementation onf allocated range, where
+ * This is a simplistic implementation of allocated range, where
* the range is one contiguous chunk of the address space.
*/
static bool add_range(json_object *jobj, const char *keyword, uint16_t low,
@@ -2384,6 +2384,8 @@
sz = read(fd, str, st.st_size);
if (sz != st.st_size) {
+ close(fd);
+ l_free(str);
l_error("Failed to read configuration file %s", fname);
return false;
}
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/tools/meshctl.c
^
|
@@ -2015,7 +2015,6 @@
fail:
bt_shell_cleanup();
- g_free(mesh_dir);
return EXIT_FAILURE;
}
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/tools/mgmt-tester.c
^
|
@@ -282,6 +282,7 @@
const void *setup_send_param;
uint16_t setup_send_len;
const struct setup_mgmt_cmd *setup_mgmt_cmd_arr;
+ size_t setup_mgmt_cmd_arr_size;
bool send_index_none;
const void *setup_discovery_param;
uint16_t send_opcode;
@@ -1861,11 +1862,6 @@
.send_opcode = MGMT_OP_SET_LOCAL_NAME,
.send_param = set_adv_set_local_name_param,
.send_len = sizeof(set_adv_set_local_name_param),
- },
- { /* last element should always have opcode 0x00 */
- .send_opcode = 0x00,
- .send_param = NULL,
- .send_len = 0,
}
};
@@ -1887,6 +1883,7 @@
static const struct generic_data set_adv_on_local_name_appear_test_1 = {
.setup_settings = settings_powered_le,
.setup_mgmt_cmd_arr = set_advertising_mgmt_cmd_arr,
+ .setup_mgmt_cmd_arr_size = ARRAY_SIZE(set_advertising_mgmt_cmd_arr),
.send_opcode = MGMT_OP_SET_ADVERTISING,
.send_param = set_adv_on_param,
.expect_param = set_adv_settings_param_2,
@@ -5620,11 +5617,6 @@
.send_opcode = MGMT_OP_ADD_UUID,
.send_param = add_spp_uuid_param,
.send_len = sizeof(add_spp_uuid_param),
- },
- { /* last element should always have opcode 0x00 */
- .send_opcode = 0x00,
- .send_param = NULL,
- .send_len = 0,
}
};
@@ -5653,6 +5645,7 @@
static const struct generic_data read_ext_ctrl_info2 = {
.setup_settings = settings_powered_le,
.setup_mgmt_cmd_arr = set_dev_class_cmd_arr1,
+ .setup_mgmt_cmd_arr_size = ARRAY_SIZE(set_dev_class_cmd_arr1),
.send_opcode = MGMT_OP_READ_EXT_INFO,
.expect_status = MGMT_STATUS_SUCCESS,
.expect_param = ext_ctrl_info2,
@@ -5745,11 +5738,6 @@
.send_opcode = MGMT_OP_SET_LOCAL_NAME,
.send_param = &set_local_name_cp,
.send_len = sizeof(set_local_name_cp),
- },
- { /* last element should always have opcode 0x00 */
- .send_opcode = 0x00,
- .send_param = NULL,
- .send_len = 0,
}
};
@@ -5781,6 +5769,7 @@
static const struct generic_data read_ext_ctrl_info5 = {
.setup_settings = settings_powered_le,
.setup_mgmt_cmd_arr = set_dev_class_cmd_arr2,
+ .setup_mgmt_cmd_arr_size = ARRAY_SIZE(set_dev_class_cmd_arr2),
.send_opcode = MGMT_OP_READ_EXT_INFO,
.expect_status = MGMT_STATUS_SUCCESS,
.expect_param = ext_ctrl_info5,
@@ -6167,6 +6156,23 @@
setup_bthost();
}
+/* Generic callback for checking the mgmt evnet status
+ */
+static void generic_mgmt_status_callback(uint8_t status, uint16_t length,
+ const void *param, void *user_data)
+{
+ bool bthost = PTR_TO_INT(user_data);
+
+ if (status != MGMT_STATUS_SUCCESS) {
+ tester_setup_failed();
+ return;
+ }
+
+ if (bthost)
+ setup_bthost();
+}
+
+
static void setup_powered_callback(uint8_t status, uint16_t length,
const void *param, void *user_data)
{
@@ -7001,6 +7007,66 @@
NULL, NULL);
}
+static const uint8_t hci_set_ext_adv_data_name[] = {
+ 0x01, /* Handle */
+ 0x03, /* Operation */
+ 0x01, /* Complete name */
+ 0x06, 0x05, 0x08, 0x74, 0x65, 0x73, 0x74
+};
+
+static const struct generic_data add_ext_adv_scan_resp_off_on = {
+ .send_opcode = MGMT_OP_ADD_EXT_ADV_DATA,
+ .send_param = ext_adv_data_valid,
+ .send_len = sizeof(ext_adv_data_valid),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_param = ext_adv_data_mgmt_rsp_valid,
+ .expect_len = sizeof(ext_adv_data_mgmt_rsp_valid),
+ .expect_hci_command = BT_HCI_CMD_LE_SET_EXT_SCAN_RSP_DATA,
+ .expect_hci_param = hci_set_ext_adv_data_name,
+ .expect_hci_len = sizeof(hci_set_ext_adv_data_name),
+};
+
+static void setup_add_ext_adv_on_off(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ unsigned char param[] = { 0x01 };
+ int enable_bthost = 1;
+
+ mgmt_send(data->mgmt, MGMT_OP_SET_LE, data->mgmt_index,
+ sizeof(param), ¶m,
+ NULL, NULL, NULL);
+
+ mgmt_send(data->mgmt, MGMT_OP_SET_POWERED, data->mgmt_index,
+ sizeof(param), ¶m,
+ generic_mgmt_status_callback,
+ NULL, NULL);
+
+ mgmt_send(data->mgmt, MGMT_OP_ADD_EXT_ADV_PARAMS, data->mgmt_index,
+ sizeof(ext_adv_params_valid),
+ &ext_adv_params_valid,
+ generic_mgmt_status_callback,
+ NULL, NULL);
+
+ mgmt_send(data->mgmt, MGMT_OP_ADD_EXT_ADV_DATA, data->mgmt_index,
+ sizeof(ext_adv_data_valid),
+ &ext_adv_data_valid,
+ generic_mgmt_status_callback,
+ NULL, NULL);
+
+ mgmt_send(data->mgmt, MGMT_OP_REMOVE_ADVERTISING, data->mgmt_index,
+ sizeof(remove_advertising_param_1),
+ &remove_advertising_param_1,
+ generic_mgmt_status_callback,
+ NULL, NULL);
+
+ mgmt_send(data->mgmt, MGMT_OP_ADD_EXT_ADV_PARAMS, data->mgmt_index,
+ sizeof(ext_adv_params_valid),
+ &ext_adv_params_valid,
+ generic_mgmt_status_callback,
+ INT_TO_PTR(enable_bthost), NULL);
+
+}
+
static void pin_code_request_callback(uint16_t index, uint16_t length,
const void *param, void *user_data)
{
@@ -7476,7 +7542,7 @@
const struct generic_data *test = data->test_data;
const void *send_param = test->setup_send_param;
uint16_t send_len = test->setup_send_len;
- size_t i = 0;
+ size_t i;
if (test->setup_expect_hci_command) {
tester_print("Registering setup expected HCI command callback");
@@ -7500,11 +7566,8 @@
}
tester_print("Sending setup opcode array");
- for (; test->setup_mgmt_cmd_arr + i; ++i) {
- const struct setup_mgmt_cmd *cmd = test->setup_mgmt_cmd_arr + i;
-
- if (cmd->send_opcode == 0x00)
- break;
+ for (i = 0; i < test->setup_mgmt_cmd_arr_size; ++i) {
+ const struct setup_mgmt_cmd *cmd = &test->setup_mgmt_cmd_arr[i];
tester_print("Setup sending %s (0x%04x)",
mgmt_opstr(cmd->send_opcode),
@@ -7882,11 +7945,6 @@
.send_opcode = MGMT_OP_SET_LOCAL_NAME,
.send_param = &set_local_name_cp,
.send_len = sizeof(set_local_name_cp),
- },
- { /* last element should always have opcode 0x00 */
- .send_opcode = 0x00,
- .send_param = NULL,
- .send_len = 0,
}
};
@@ -7909,6 +7967,7 @@
static const struct generic_data add_advertising_name_data_appear = {
.setup_settings = settings_powered_le,
.setup_mgmt_cmd_arr = add_advertising_mgmt_cmd_arr,
+ .setup_mgmt_cmd_arr_size = ARRAY_SIZE(add_advertising_mgmt_cmd_arr),
.send_opcode = MGMT_OP_ADD_ADVERTISING,
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/tools/mpris-proxy.c
^
|
@@ -1978,7 +1978,7 @@
player->conn = g_dbus_setup_private(DBUS_BUS_SESSION, player->bus_name,
NULL);
- if (!session) {
+ if (!player->conn) {
fprintf(stderr, "Could not register bus name %s",
player->bus_name);
goto fail;
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/tools/obex-client-tool.c
^
|
@@ -312,6 +312,7 @@
if (connect(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
err = errno;
g_printerr("connect: %s (%d)\n", strerror(err), err);
+ close(sk);
return NULL;
}
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/tools/obexctl.c
^
|
@@ -114,6 +114,7 @@
struct connect_args {
char *dev;
char *target;
+ uint8_t channel;
};
static void connect_args_free(void *data)
@@ -139,13 +140,14 @@
DBUS_DICT_ENTRY_END_CHAR_AS_STRING,
&dict);
- if (args->target == NULL)
- goto done;
-
- g_dbus_dict_append_entry(&dict, "Target",
+ if (args->target)
+ g_dbus_dict_append_entry(&dict, "Target",
DBUS_TYPE_STRING, &args->target);
-done:
+ if (args->channel)
+ g_dbus_dict_append_entry(&dict, "Channel",
+ DBUS_TYPE_BYTE, &args->channel);
+
dbus_message_iter_close_container(iter, &dict);
}
@@ -153,6 +155,7 @@
{
struct connect_args *args;
const char *target = "opp";
+ int channel = 0;
if (!client) {
bt_shell_printf("Client proxy not available\n");
@@ -162,9 +165,20 @@
if (argc > 2)
target = argv[2];
+ if (argc > 3) {
+ char *endptr = NULL;
+
+ channel = strtol(argv[3], &endptr, 0);
+ if (!endptr || *endptr != '\0' || channel > UINT8_MAX) {
+ bt_shell_printf("Invalid channel\n");
+ return bt_shell_noninteractive_quit(EXIT_FAILURE);
+ }
+ }
+
args = g_new0(struct connect_args, 1);
args->dev = g_strdup(argv[1]);
args->target = g_strdup(target);
+ args->channel = channel;
if (g_dbus_proxy_method_call(client, "CreateSession", connect_setup,
connect_reply, args, connect_args_free) == FALSE) {
@@ -1832,7 +1846,8 @@
static const struct bt_shell_menu main_menu = {
.name = "main",
.entries = {
- { "connect", "<dev> [uuid]", cmd_connect, "Connect session" },
+ { "connect", "<dev> [uuid] [channel]", cmd_connect,
+ "Connect session" },
{ "disconnect", "[session]", cmd_disconnect, "Disconnect session",
session_generator },
{ "list", NULL, cmd_list, "List available sessions" },
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/tools/rfcomm-tester.c
^
|
@@ -37,8 +37,11 @@
struct hciemu *hciemu;
enum hciemu_type hciemu_type;
const void *test_data;
+ GIOChannel *io;
unsigned int io_id;
uint16_t conn_handle;
+ uint16_t send_len;
+ uint16_t recv_len;
};
struct rfcomm_client_data {
@@ -197,6 +200,9 @@
data->io_id = 0;
}
+ if (data->io)
+ g_io_channel_unref(data->io);
+
hciemu_unref(data->hciemu);
data->hciemu = NULL;
}
@@ -297,7 +303,24 @@
.server_channel = 0x0c,
.client_channel = 0x0c,
.data_len = sizeof(data),
- .send_data = data
+ .send_data = data,
+};
+
+const uint8_t data_32k[32768] = { [0 ... 4095] = 0x00,
+ [4096 ... 8191] = 0x01,
+ [8192 ... 12287] = 0x02,
+ [12288 ... 16383] = 0x03,
+ [16384 ... 20479] = 0x04,
+ [20480 ... 24575] = 0x05,
+ [24576 ... 28671] = 0x06,
+ [28672 ... 32767] = 0x07,
+};
+
+const struct rfcomm_client_data connect_send_32k_success = {
+ .server_channel = 0x0c,
+ .client_channel = 0x0c,
+ .data_len = sizeof(data_32k),
+ .send_data = data_32k,
};
const struct rfcomm_client_data connect_read_success = {
@@ -420,6 +443,44 @@
return false;
}
+static gboolean rc_write_data(GIOChannel *io, GIOCondition cond,
+ gpointer user_data)
+{
+ struct test_data *data = user_data;
+ const struct rfcomm_client_data *cli = data->test_data;
+ int sk;
+ ssize_t ret;
+
+ if (cond & G_IO_NVAL)
+ return false;
+
+ if (cond & (G_IO_HUP | G_IO_ERR))
+ goto done;
+
+ tester_print("Writing %u bytes of data",
+ cli->data_len - data->send_len);
+
+ sk = g_io_channel_unix_get_fd(io);
+
+ ret = write(sk, cli->send_data + data->send_len,
+ cli->data_len - data->send_len);
+ if (ret < 0) {
+ tester_warn("Failed to write %u bytes: %s (%d)",
+ cli->data_len, strerror(errno), errno);
+ tester_test_failed();
+ goto done;
+ }
+
+ data->send_len += ret;
+
+ tester_print("Written %u/%u bytes", data->send_len, cli->data_len);
+
+ /* Don't retry write since that seems to block bthost from receiving */
+done:
+ data->io_id = 0;
+ return false;
+}
+
static gboolean rc_connect_cb(GIOChannel *io, GIOCondition cond,
gpointer user_data)
{
@@ -445,17 +506,9 @@
}
if (cli->send_data) {
- ssize_t ret;
-
- tester_print("Writing %u bytes of data", cli->data_len);
-
- ret = write(sk, cli->send_data, cli->data_len);
- if (cli->data_len != ret) {
- tester_warn("Failed to write %u bytes: %s (%d)",
- cli->data_len, strerror(errno), errno);
- tester_test_failed();
- }
-
+ data->io = g_io_channel_ref(io);
+ cond = G_IO_OUT | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
+ data->io_id = g_io_add_watch(io, cond, rc_write_data, data);
return false;
} else if (cli->read_data) {
g_io_add_watch(io, G_IO_IN, client_received_data, NULL);
@@ -483,16 +536,35 @@
tester_print("bthost received %u bytes of data", len);
- if (cli->data_len != len) {
+ if (test_data->recv_len + len > cli->data_len) {
+ tester_print("received more data than expected");
tester_test_failed();
return;
}
- ret = memcmp(cli->send_data, data, len);
- if (ret)
+ ret = memcmp(cli->send_data + test_data->recv_len, data, len);
+ if (ret) {
tester_test_failed();
- else
- tester_test_passed();
+ return;
+ }
+
+ test_data->recv_len += len;
+
+ tester_print("bthost received progress %u/%u", test_data->recv_len,
+ cli->data_len);
+
+ if (cli->data_len != test_data->recv_len) {
+ if (cli->data_len != test_data->send_len)
+ test_data->io_id = g_io_add_watch(test_data->io,
+ G_IO_OUT | G_IO_HUP |
+ G_IO_ERR | G_IO_NVAL,
+ rc_write_data, test_data);
+ return;
+ }
+
+ test_data->recv_len = 0;
+
+ tester_test_passed();
}
static void server_hook_func(const void *data, uint16_t len,
@@ -735,6 +807,9 @@
test_rfcomm("Basic RFCOMM Socket Client - Write Success",
&connect_send_success, setup_powered_client,
test_connect);
+ test_rfcomm("Basic RFCOMM Socket Client - Write 32k Success",
+ &connect_send_32k_success, setup_powered_client,
+ test_connect);
test_rfcomm("Basic RFCOMM Socket Client - Read Success",
&connect_read_success, setup_powered_client,
test_connect);
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/tools/rfcomm.c
^
|
@@ -298,6 +298,7 @@
if (setsockopt(sk, SOL_SOCKET, SO_LINGER, &l, sizeof(l)) < 0) {
perror("Can't set linger option");
+ close(sk);
return;
}
}
@@ -466,6 +467,7 @@
if (getsockname(nsk, (struct sockaddr *)&laddr, &alen) < 0) {
perror("Can't get RFCOMM socket name");
close(nsk);
+ close(sk);
return;
}
@@ -475,6 +477,7 @@
if (setsockopt(nsk, SOL_SOCKET, SO_LINGER, &l, sizeof(l)) < 0) {
perror("Can't set linger option");
close(nsk);
+ close(sk);
return;
}
}
@@ -490,6 +493,7 @@
dev = ioctl(nsk, RFCOMMCREATEDEV, &req);
if (dev < 0) {
perror("Can't create RFCOMM TTY");
+ close(nsk);
close(sk);
return;
}
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/tools/test-runner.c
^
|
@@ -47,10 +47,14 @@
static bool run_auto = false;
static bool start_dbus = false;
+static bool start_dbus_session;
+static bool start_daemon = false;
+static bool start_emulator = false;
static bool start_monitor = false;
static int num_devs = 0;
static const char *qemu_binary = NULL;
static const char *kernel_image = NULL;
+static bool audio_support;
static const char *qemu_table[] = {
"qemu-system-x86_64",
@@ -188,7 +192,6 @@
"-machine", "type=q35,accel=kvm:tcg",
"-m", "192M",
"-nographic",
- "-vga", "none",
"-net", "none",
"-no-acpi",
"-no-hpet",
@@ -245,22 +248,51 @@
snprintf(cmdline, sizeof(cmdline),
"console=ttyS0,115200n8 earlyprintk=serial "
"rootfstype=9p "
- "rootflags=trans=virtio,version=9p2000.L "
+ "rootflags=trans=virtio,version=9p2000.u "
"acpi=off pci=noacpi noapic quiet ro init=%s "
- "bluetooth.enable_ecred=1"
- "TESTHOME=%s TESTDBUS=%u TESTMONITOR=%u "
- "TESTDEVS=%d TESTAUTO=%u TESTARGS=\'%s\'",
- initcmd, cwd, start_dbus, start_monitor,
- num_devs, run_auto, testargs);
+ "bluetooth.enable_ecred=1 "
+ "TESTHOME=%s TESTDBUS=%u TESTDAEMON=%u "
+ "TESTDBUSSESSION=%u XDG_RUNTIME_DIR=/run/user/0 "
+ "TESTAUDIO=%u "
+ "TESTMONITOR=%u TESTEMULATOR=%u TESTDEVS=%d "
+ "TESTAUTO=%u TESTARGS=\'%s\'",
+ initcmd, cwd, start_dbus, start_daemon,
+ start_dbus_session, audio_support,
+ start_monitor, start_emulator, num_devs,
+ run_auto, testargs);
argv = alloca(sizeof(qemu_argv) +
+ (audio_support ? 4 : 0) +
(sizeof(char *) * (4 + (num_devs * 4))));
memcpy(argv, qemu_argv, sizeof(qemu_argv));
pos = (sizeof(qemu_argv) / sizeof(char *)) - 1;
+ /* Make sure qemu_binary is not null */
+ if (!qemu_binary) {
+ fprintf(stderr, "No QEMU binary is set\n");
+ exit(1);
+ }
argv[0] = (char *) qemu_binary;
+ if (audio_support) {
+ char *xdg_runtime_dir, *audiodev;
+
+ xdg_runtime_dir = getenv("XDG_RUNTIME_DIR");
+ if (!xdg_runtime_dir) {
+ fprintf(stderr, "XDG_RUNTIME_DIR not set\n");
+ exit(1);
+ }
+ audiodev = alloca(40 + strlen(xdg_runtime_dir));
+ sprintf(audiodev, "id=audio,driver=pa,server=%s/pulse/native",
+ xdg_runtime_dir);
+
+ argv[pos++] = "-audiodev";
+ argv[pos++] = audiodev;
+ argv[pos++] = "-device";
+ argv[pos++] = "AC97,audiodev=audio";
+ }
+
argv[pos++] = "-kernel";
argv[pos++] = (char *) kernel_image;
argv[pos++] = "-append";
@@ -416,19 +448,69 @@
mkdir("/run/dbus", 0755);
}
-static pid_t start_dbus_daemon(void)
+static void create_dbus_session_conf(void)
+{
+ FILE *fp;
+
+ fp = fopen("/etc/dbus-1/session.conf", "we");
+ if (!fp)
+ return;
+
+ fputs("<!DOCTYPE busconfig PUBLIC "
+ "\"-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN\" "
+ "\"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd\">\n", fp);
+ fputs("<busconfig>\n", fp);
+ fputs("<type>session</type>\n", fp);
+ fputs("<listen>unix:path=/run/user/0/bus</listen>\n", fp);
+ fputs("<policy context=\"default\">\n", fp);
+ fputs("<allow user=\"*\"/>\n", fp);
+ fputs("<allow own=\"*\"/>\n", fp);
+ fputs("<allow send_type=\"method_call\"/>\n", fp);
+ fputs("<allow send_type=\"signal\"/>\n", fp);
+ fputs("<allow send_type=\"method_return\"/>\n", fp);
+ fputs("<allow send_type=\"error\"/>\n", fp);
+ fputs("<allow receive_type=\"method_call\"/>\n", fp);
+ fputs("<allow receive_type=\"signal\"/>\n", fp);
+ fputs("<allow receive_type=\"method_return\"/>\n", fp);
+ fputs("<allow receive_type=\"error\"/>\n", fp);
+ fputs("</policy>\n", fp);
+ fputs("</busconfig>\n", fp);
+
+ fclose(fp);
+
+ if (symlink("/etc/dbus-1/session.conf",
+ "/usr/share/dbus-1/session.conf") < 0)
+ perror("Failed to create session.conf symlink");
+
+ if (mkdir("/run/user", 0755) < 0) {
+ fprintf(stderr, "unable to create /run/user directory\n");
+ return;
+ }
+ if (mkdir("/run/user/0", 0755) < 0) {
+ fprintf(stderr, "unable to create /run/user/0 directory\n");
+ return;
+ }
+}
+
+static pid_t start_dbus_daemon(bool session)
{
char *argv[3], *envp[1];
pid_t pid;
int i;
+ char *bus_type = session ? "session" : "system";
+ char *socket_path = session ?
+ "/run/user/0/bus" : "/run/dbus/system_bus_socket";
argv[0] = "/usr/bin/dbus-daemon";
- argv[1] = "--system";
+ if (session)
+ argv[1] = "--session";
+ else
+ argv[1] = "--system";
argv[2] = NULL;
envp[0] = NULL;
- printf("Starting D-Bus daemon\n");
+ printf("Starting D-Bus %s daemon\n", bus_type);
pid = fork();
if (pid < 0) {
@@ -441,20 +523,20 @@
exit(EXIT_SUCCESS);
}
- printf("D-Bus daemon process %d created\n", pid);
+ printf("D-Bus %s daemon process %d created\n", bus_type, pid);
for (i = 0; i < 20; i++) {
struct stat st;
- if (!stat("/run/dbus/system_bus_socket", &st)) {
- printf("Found D-Bus daemon socket\n");
- break;
+ if (!stat(socket_path, &st)) {
+ printf("Found D-Bus %s daemon socket\n", bus_type);
+ return pid;
}
- usleep(25 * 1000);
+ sleep(1);
}
- return pid;
+ return -1;
}
static const char *daemon_table[] = {
@@ -531,6 +613,7 @@
"l2cap-tester",
"rfcomm-tester",
"sco-tester",
+ "iso-tester",
"bnep-tester",
"check-selftest",
"tools/mgmt-tester",
@@ -538,6 +621,7 @@
"tools/l2cap-tester",
"tools/rfcomm-tester",
"tools/sco-tester",
+ "tools/iso-tester",
"tools/bnep-tester",
"tools/check-selftest",
NULL
@@ -600,12 +684,132 @@
return pid;
}
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/unit/test-avctp.c
^
|
@@ -53,7 +53,7 @@
#define raw_pdu(args...) \
{ \
.valid = true, \
- .data = g_memdup(data(args), sizeof(data(args))), \
+ .data = util_memdup(data(args), sizeof(data(args))), \
.size = sizeof(data(args)), \
}
@@ -64,7 +64,7 @@
}; \
static struct test_data data; \
data.test_name = g_strdup(name); \
- data.pdu_list = g_memdup(pdus, sizeof(pdus)); \
+ data.pdu_list = util_memdup(pdus, sizeof(pdus)); \
tester_add(name, &data, NULL, function, NULL); \
} while (0)
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/unit/test-avdtp.c
^
|
@@ -48,7 +48,7 @@
#define raw_pdu(args...) \
{ \
.valid = true, \
- .data = g_memdup(data(args), sizeof(data(args))), \
+ .data = util_memdup(data(args), sizeof(data(args))), \
.size = sizeof(data(args)), \
}
@@ -56,7 +56,7 @@
{ \
.valid = true, \
.fragmented = true, \
- .data = g_memdup(data(args), sizeof(data(args))), \
+ .data = util_memdup(data(args), sizeof(data(args))), \
.size = sizeof(data(args)), \
}
@@ -67,7 +67,7 @@
}; \
static struct test_data data; \
data.test_name = g_strdup(name); \
- data.pdu_list = g_memdup(pdus, sizeof(pdus)); \
+ data.pdu_list = util_memdup(pdus, sizeof(pdus)); \
tester_add(name, &data, NULL, function, NULL); \
} while (0)
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/unit/test-avrcp.c
^
|
@@ -61,7 +61,7 @@
#define raw_pdu(args...) \
{ \
.valid = true, \
- .data = g_memdup(data(args), sizeof(data(args))), \
+ .data = util_memdup(data(args), sizeof(data(args))), \
.size = sizeof(data(args)), \
}
@@ -69,7 +69,7 @@
{ \
.valid = true, \
.browse = true, \
- .data = g_memdup(data(args), sizeof(data(args))), \
+ .data = util_memdup(data(args), sizeof(data(args))), \
.size = sizeof(data(args)), \
}
@@ -77,7 +77,7 @@
{ \
.valid = true, \
.fragmented = true, \
- .data = g_memdup(data(args), sizeof(data(args))), \
+ .data = util_memdup(data(args), sizeof(data(args))), \
.size = sizeof(data(args)), \
}
@@ -85,7 +85,7 @@
{ \
.valid = true, \
.continuing = true, \
- .data = g_memdup(data(args), sizeof(data(args))), \
+ .data = util_memdup(data(args), sizeof(data(args))), \
.size = sizeof(data(args)), \
}
@@ -96,7 +96,7 @@
}; \
static struct test_data data; \
data.test_name = g_strdup(name); \
- data.pdu_list = g_memdup(pdus, sizeof(pdus)); \
+ data.pdu_list = util_memdup(pdus, sizeof(pdus)); \
tester_add(name, &data, NULL, function, NULL); \
} while (0)
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/unit/test-gatt.c
^
|
@@ -73,7 +73,7 @@
#define raw_pdu(args...) \
{ \
.valid = true, \
- .data = g_memdup(data(args), sizeof(data(args))), \
+ .data = util_memdup(data(args), sizeof(data(args))), \
.size = sizeof(data(args)), \
}
@@ -94,7 +94,7 @@
data.uuid = bt_uuid; \
data.step = test_step; \
data.source_db = db; \
- data.pdu_list = g_memdup(pdus, sizeof(pdus)); \
+ data.pdu_list = util_memdup(pdus, sizeof(pdus)); \
tester_add(name, &data, NULL, function, NULL); \
} while (0)
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/unit/test-hfp.c
^
|
@@ -17,6 +17,7 @@
#include <glib.h>
#include "src/shared/hfp.h"
#include "src/shared/tester.h"
+#include "src/shared/util.h"
struct context {
guint watch_id;
@@ -50,7 +51,7 @@
#define raw_pdu(args...) \
{ \
.valid = true, \
- .data = g_memdup(data(args), sizeof(data(args))), \
+ .data = util_memdup(data(args), sizeof(data(args))), \
.size = sizeof(data(args)), \
}
@@ -62,7 +63,7 @@
#define type_pdu(cmd_type, args...) \
{ \
.valid = true, \
- .data = g_memdup(data(args), sizeof(data(args))), \
+ .data = util_memdup(data(args), sizeof(data(args))), \
.size = sizeof(data(args)), \
.type = cmd_type, \
}
@@ -70,7 +71,7 @@
#define frg_pdu(args...) \
{ \
.valid = true, \
- .data = g_memdup(data(args), sizeof(data(args))), \
+ .data = util_memdup(data(args), sizeof(data(args))), \
.size = sizeof(data(args)), \
.fragmented = true, \
}
@@ -82,7 +83,7 @@
}; \
static struct test_data data; \
data.test_name = g_strdup(name); \
- data.pdu_list = g_memdup(pdus, sizeof(pdus)); \
+ data.pdu_list = util_memdup(pdus, sizeof(pdus)); \
data.result_func = result_function; \
tester_add(name, &data, NULL, function, NULL); \
data.test_handler = test_handler; \
@@ -96,7 +97,7 @@
}; \
static struct test_data data; \
data.test_name = g_strdup(name); \
- data.pdu_list = g_memdup(pdus, sizeof(pdus)); \
+ data.pdu_list = util_memdup(pdus, sizeof(pdus)); \
data.hf_result_func = result_func; \
data.response_func = response_function; \
tester_add(name, &data, NULL, function, NULL); \
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/unit/test-hog.c
^
|
@@ -59,24 +59,24 @@
#define raw_pdu(args...) \
{ \
.valid = true, \
- .data = g_memdup(data(args), sizeof(data(args))), \
+ .data = util_memdup(data(args), sizeof(data(args))), \
.size = sizeof(data(args)), \
}
-#define false_pdu() \
-{ \
- .valid = false, \
+#define false_pdu() \
+{ \
+ .valid = false, \
}
-#define define_test(name, function, args...) \
- do { \
- const struct test_pdu pdus[] = { \
- args, { } \
- }; \
- static struct test_data data; \
- data.test_name = g_strdup(name); \
- data.pdu_list = g_memdup(pdus, sizeof(pdus)); \
- tester_add(name, &data, NULL, function, NULL); \
+#define define_test(name, function, args...) \
+ do { \
+ const struct test_pdu pdus[] = { \
+ args, { } \
+ }; \
+ static struct test_data data; \
+ data.test_name = g_strdup(name); \
+ data.pdu_list = util_memdup(pdus, sizeof(pdus));\
+ tester_add(name, &data, NULL, function, NULL); \
} while (0)
static gboolean context_quit(gpointer user_data)
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/unit/test-sdp.c
^
|
@@ -47,14 +47,16 @@
#define raw_pdu(args...) \
{ \
.valid = true, \
- .raw_data = g_memdup(raw_data(args), sizeof(raw_data(args))), \
+ .raw_data = util_memdup(raw_data(args), \
+ sizeof(raw_data(args))), \
.raw_size = sizeof(raw_data(args)), \
}
#define raw_pdu_cont(cont, args...) \
{ \
.valid = true, \
- .raw_data = g_memdup(raw_data(args), sizeof(raw_data(args))), \
+ .raw_data = util_memdup(raw_data(args), \
+ sizeof(raw_data(args))), \
.raw_size = sizeof(raw_data(args)), \
.cont_len = cont, \
}
@@ -66,7 +68,7 @@
}; \
static struct test_data data; \
data.mtu = _mtu; \
- data.pdu_list = g_memdup(pdus, sizeof(pdus)); \
+ data.pdu_list = util_memdup(pdus, sizeof(pdus)); \
tester_add(name, &data, NULL, test_sdp, NULL); \
} while (0)
@@ -92,7 +94,7 @@
#define define_test_de_attr(name, input, exp) \
do { \
static struct test_data_de data; \
- data.input_data = g_memdup(input, sizeof(input)); \
+ data.input_data = util_memdup(input, sizeof(input)); \
data.input_size = sizeof(input); \
data.expected = exp; \
tester_add("/sdp/DE/ATTR/" name, &data, NULL, \
|
[-]
[+]
|
Changed |
_service:tar_git:bluez5-5.65+git1.tar.gz/unit/test-uhid.c
^
|
@@ -61,7 +61,7 @@
}; \
static struct test_data data; \
data.test_name = g_strdup(name); \
- data.pdu_list = g_memdup(pdus, sizeof(pdus)); \
+ data.pdu_list = util_memdup(pdus, sizeof(pdus)); \
tester_add(name, &data, NULL, function, NULL); \
} while (0)
|
[-]
[+]
|
Changed |
_service:tar_git:mpris-proxy.service
^
|
@@ -6,6 +6,8 @@
[Service]
Type=simple
ExecStart=/usr/bin/mpris-proxy
+Restart=always
+RestartSec=5
[Install]
WantedBy=post-user-session.target
|