@@ -152,6 +152,30 @@ static bool bis_syncs_unique_or_no_pref(uint32_t requested_bis_syncs,
152
152
return (requested_bis_syncs & aggregated_bis_syncs ) != 0U ;
153
153
}
154
154
155
+ static bool valid_bis_sync_request (uint32_t requested_bis_syncs , uint32_t aggregated_bis_syncs )
156
+ {
157
+ /* Verify that the request BIS sync indexes are unique or no preference */
158
+ if (!bis_syncs_unique_or_no_pref (requested_bis_syncs , aggregated_bis_syncs )) {
159
+ LOG_DBG ("Duplicate BIS index 0x%08x (aggregated %x)" , requested_bis_syncs ,
160
+ aggregated_bis_syncs );
161
+ return false;
162
+ }
163
+
164
+ if (requested_bis_syncs != BT_BAP_BIS_SYNC_NO_PREF &&
165
+ aggregated_bis_syncs == BT_BAP_BIS_SYNC_NO_PREF ) {
166
+ LOG_DBG ("Invalid BIS index 0x%08X mixing BT_BAP_BIS_SYNC_NO_PREF and specific BIS" ,
167
+ requested_bis_syncs );
168
+ return false;
169
+ }
170
+
171
+ if (!valid_bis_syncs (requested_bis_syncs )) {
172
+ LOG_DBG ("Invalid BIS sync: 0x%08X" , requested_bis_syncs );
173
+ return false;
174
+ }
175
+
176
+ return true;
177
+ }
178
+
155
179
static void bt_debug_dump_recv_state (const struct bass_recv_state_internal * recv_state )
156
180
{
157
181
if (recv_state -> active ) {
@@ -710,19 +734,9 @@ static int scan_delegator_add_src(struct bt_conn *conn,
710
734
bis_sync_requested = true;
711
735
}
712
736
713
- /* Verify that the request BIS sync indexes are unique or no preference */
714
- if (!bis_syncs_unique_or_no_pref (internal_state -> requested_bis_sync [i ],
715
- aggregated_bis_syncs )) {
716
- LOG_DBG ("Duplicate BIS index [%d]%x (aggregated %x)" ,
717
- i , internal_state -> requested_bis_sync [i ],
718
- aggregated_bis_syncs );
719
- ret = BT_GATT_ERR (BT_ATT_ERR_VALUE_NOT_ALLOWED );
720
- goto unlock_return ;
721
- }
722
-
723
- if (!valid_bis_syncs (internal_state -> requested_bis_sync [i ])) {
724
- LOG_DBG ("Invalid BIS sync[%d]: 0x%08X" , i ,
725
- internal_state -> requested_bis_sync [i ]);
737
+ if (!valid_bis_sync_request (internal_state -> requested_bis_sync [i ],
738
+ aggregated_bis_syncs )) {
739
+ LOG_DBG ("Invalid BIS Sync request[%d]" , i );
726
740
ret = BT_GATT_ERR (BT_ATT_ERR_VALUE_NOT_ALLOWED );
727
741
goto unlock_return ;
728
742
}
@@ -914,15 +928,9 @@ static int scan_delegator_mod_src(struct bt_conn *conn,
914
928
bis_sync_change_requested = true;
915
929
}
916
930
917
- /* Verify that the request BIS sync indexes are unique or no preference */
918
- if (!bis_syncs_unique_or_no_pref (requested_bis_sync [i ], aggregated_bis_syncs )) {
919
- LOG_DBG ("Duplicate BIS index [%d]%x (aggregated %x)" , i ,
920
- requested_bis_sync [i ], aggregated_bis_syncs );
921
- ret = BT_GATT_ERR (BT_ATT_ERR_VALUE_NOT_ALLOWED );
922
- goto unlock_return ;
923
- }
924
-
925
- if (!valid_bis_syncs (requested_bis_sync [i ])) {
931
+ if (!valid_bis_sync_request (internal_state -> requested_bis_sync [i ],
932
+ aggregated_bis_syncs )) {
933
+ LOG_DBG ("Invalid BIS Sync request[%d]" , i );
926
934
ret = BT_GATT_ERR (BT_ATT_ERR_VALUE_NOT_ALLOWED );
927
935
goto unlock_return ;
928
936
}
0 commit comments