btproxy: Attempt to bind the next index
Luiz Augusto von Dentz
maintainerPATCH 1/1 btproxy: Attempt to bind the next index
From: Luiz Augusto von Dentz <[email protected]>
If no specific index is given attempt to bind the next index if the current one is already in use.
--- tools/btproxy.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-)
tools/btproxy.c +17 -4
@@ -47,8 +47,9 @@ struct sockaddr_hci {unsigned short hci_channel; };#define HCI_CHANNEL_USER 1 +#define HCI_INDEX_NONE 0xffff -static uint16_t hci_index =0 ; +static uint16_t hci_index =HCI_INDEX_NONE ;static bool client_active = false;static bool debug_enabled = false;static bool emulate_ecc = false;
@@ -535,9 +536,12 @@ static bool setup_proxy(int host_fd, bool host_shutdown,static int open_channel (uint16_t index) {struct sockaddr_hci addr; -int fd; +int fd, err; + +if (index ==HCI_INDEX_NONE ) + index =0 ; -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 +555,16 @@ static int open_channel(uint16_t index) addr.hci_channel =HCI_CHANNEL_USER ;if (bind (fd, (struct sockaddr *) &addr,sizeof (addr)) <0 ) { + err = -errno;close (fd); + +/* Open next available controller if no specific index was +* provided and the error indicates that the controller. +*/ +if (hci_index ==HCI_INDEX_NONE && + (err == -EBUSY || err == -EUSERS )) +return open_channel (++index); +perror ("Failed to bind Bluetooth socket" );return -1 ; }
@@ -588,7 +601,7 @@ static void server_callback(int fd, uint32_t events, void *user_data)return ; } -if (client_active) { +if (client_active && hci_index !=HCI_INDEX_NONE ) {fprintf (stderr,"Active client already present\n" );close (host_fd);return ;
Signature · 1 line
2.35.1
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=618201
---Test result---
Test Summary:
CheckPatch PASS 1.54 seconds GitLint PASS 1.12 seconds Prep - Setup ELL PASS 49.94 seconds Build - Prep PASS 0.81 seconds Build - Configure PASS 10.22 seconds Build - Make PASS 1453.81 seconds Make Check PASS 12.85 seconds Make Check w/Valgrind PASS 516.33 seconds Make Distcheck PASS 271.07 seconds Build w/ext ELL - Configure PASS 10.39 seconds Build w/ext ELL - Make PASS 1434.14 seconds Incremental Build with patchesPASS 0.00 seconds
---
Regards,
Linux Bluetooth
Luiz Augusto von Dentz
maintainerHi,
Quoted 27 lines · On Sat, Feb 26, 2022 at 12:25 AM <[email protected]> wrote:
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=618201---Test result---
Test Summary:
CheckPatch PASS 1.54 seconds GitLint PASS 1.12 seconds Prep - Setup ELL PASS 49.94 seconds Build - Prep PASS 0.81 seconds Build - Configure PASS 10.22 seconds Build - Make PASS 1453.81 seconds Make Check PASS 12.85 seconds Make Check w/Valgrind PASS 516.33 seconds Make Distcheck PASS 271.07 seconds Build w/ext ELL - Configure PASS 10.39 seconds Build w/ext ELL - Make PASS 1434.14 seconds Incremental Build with patchesPASS 0.00 seconds
Quoted 4 lines
---
Regards,
Linux Bluetooth
Pushed
Signature · 1 line
Luiz Augusto von Dentz