btio: Add support for getsockopt(BT_ISO_BASE)
authorClaudia Draghicescu <claudia.rosu@nxp.com>
Tue, 8 Aug 2023 11:50:35 +0000 (14:50 +0300)
committerAyush Garg <ayush.garg@samsung.com>
Fri, 5 Jan 2024 13:34:03 +0000 (19:04 +0530)
This adds the posibility for a broadcast sink to retrieve the
BASE information received from a source afeter a PA synchronization,
using the getsockopt(BT_ISO_BASE) function.
This needs the patch from bluetooth-next:
Bluetooth: ISO: Add support for periodic adv reports processing

btio/btio.c

index f7eb2c86d38362f8845236df84570a752f5e198b..96f0d2c81dd42e3574943f5163ae610ae199478e 100755 (executable)
@@ -1638,6 +1638,7 @@ 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;
+       struct bt_iso_base base;
        socklen_t len;
        uint32_t phy;
 
@@ -1648,6 +1649,11 @@ static gboolean iso_get(int sock, GError **err, BtIOOption opt1, va_list args)
                return FALSE;
        }
 
+       if (getsockopt(sock, SOL_BLUETOOTH, BT_ISO_BASE, &base, &len) < 0) {
+               ERROR_FAILED(err, "getsockopt(BT_ISO_BASE)", errno);
+               return FALSE;
+       }
+
        if (!get_src(sock, &src, sizeof(src), err))
                return FALSE;
 
@@ -1694,6 +1700,8 @@ static gboolean iso_get(int sock, GError **err, BtIOOption opt1, va_list args)
                        *(va_arg(args, struct bt_iso_qos *)) = qos;
                        break;
                case BT_IO_OPT_BASE:
+                       *(va_arg(args, struct bt_iso_base *)) = base;
+                       break;
                case BT_IO_OPT_HANDLE:
                case BT_IO_OPT_CLASS:
                case BT_IO_OPT_DEFER_TIMEOUT:
@@ -1896,8 +1904,9 @@ static GIOChannel *create_io(gboolean server, struct set_opts *opts,
                        goto failed;
                if (!iso_set_qos(sock, &opts->qos, err))
                        goto failed;
-               if (!iso_set_base(sock, &opts->base, err))
-                       goto failed;
+               if (opts->base.base_len)
+                       if (!iso_set_base(sock, &opts->base, err))
+                               goto failed;
                break;
        case BT_IO_INVALID:
        default: