From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH v2 1/9] adapter: Add btd_adapter_find_device_by_fd
Date: Fri, 26 Aug 2022 16:20:23 -0700 [thread overview]
Message-ID: <20220826232031.20391-2-luiz.dentz@gmail.com> (raw)
In-Reply-To: <20220826232031.20391-1-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds btd_adapter_find_device_by_fd that lookup a device by a fd
socket destination address.
---
src/adapter.c | 33 +++++++++++++++++++++++++++++++++
src/adapter.h | 1 +
2 files changed, 34 insertions(+)
diff --git a/src/adapter.c b/src/adapter.c
index b453e86a03c1..51b099daefdf 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -1383,6 +1383,39 @@ struct btd_device *btd_adapter_get_device(struct btd_adapter *adapter,
return adapter_create_device(adapter, addr, addr_type);
}
+struct btd_device *btd_adapter_find_device_by_fd(int fd)
+{
+ bdaddr_t src, dst;
+ uint8_t dst_type;
+ GIOChannel *io = NULL;
+ GError *gerr = NULL;
+ struct btd_adapter *adapter;
+
+ io = g_io_channel_unix_new(fd);
+ if (!io)
+ return NULL;
+
+ bt_io_get(io, &gerr,
+ BT_IO_OPT_SOURCE_BDADDR, &src,
+ BT_IO_OPT_DEST_BDADDR, &dst,
+ BT_IO_OPT_DEST_TYPE, &dst_type,
+ BT_IO_OPT_INVALID);
+ if (gerr) {
+ error("bt_io_get: %s", gerr->message);
+ g_error_free(gerr);
+ g_io_channel_unref(io);
+ return NULL;
+ }
+
+ g_io_channel_unref(io);
+
+ adapter = adapter_find(&src);
+ if (!adapter)
+ return NULL;
+
+ return btd_adapter_find_device(adapter, &dst, dst_type);
+}
+
sdp_list_t *btd_adapter_get_services(struct btd_adapter *adapter)
{
return adapter->services;
diff --git a/src/adapter.h b/src/adapter.h
index b09044edda70..f38f473b79d7 100644
--- a/src/adapter.h
+++ b/src/adapter.h
@@ -86,6 +86,7 @@ struct btd_device *btd_adapter_find_device(struct btd_adapter *adapter,
uint8_t dst_type);
struct btd_device *btd_adapter_find_device_by_path(struct btd_adapter *adapter,
const char *path);
+struct btd_device *btd_adapter_find_device_by_fd(int fd);
void btd_adapter_update_found_device(struct btd_adapter *adapter,
const bdaddr_t *bdaddr,
--
2.37.2
next prev parent reply other threads:[~2022-08-26 23:20 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-26 23:20 [PATCH v2 0/9] Initial BAP support Luiz Augusto von Dentz
2022-08-26 23:20 ` Luiz Augusto von Dentz [this message]
2022-08-27 0:20 ` bluez.test.bot
2022-08-26 23:20 ` [PATCH v2 2/9] lib/uuid: Add PACS/ASCS UUIDs Luiz Augusto von Dentz
2022-08-26 23:20 ` [PATCH v2 3/9] shared/bap: Add initial code for handling BAP Luiz Augusto von Dentz
2022-08-26 23:20 ` [PATCH v2 4/9] profiles: Add initial code for bap plugin Luiz Augusto von Dentz
2022-08-26 23:20 ` [PATCH v2 5/9] shared: Add definition for LC3 codec Luiz Augusto von Dentz
2022-08-26 23:20 ` [PATCH v2 6/9] media-api: Add SelectProperties Luiz Augusto von Dentz
2022-08-26 23:20 ` [PATCH v2 7/9] test/simple-endpoint: Add support for LC3 endpoints Luiz Augusto von Dentz
2022-08-26 23:20 ` [PATCH v2 8/9] client/player: Add support for PACS endpoints Luiz Augusto von Dentz
2022-08-26 23:20 ` [PATCH v2 9/9] client/player: Use QoS interval on transport.send Luiz Augusto von Dentz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220826232031.20391-2-luiz.dentz@gmail.com \
--to=luiz.dentz@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox