@@ -342,17 +342,30 @@ static struct bt_avdtp_sep *avdtp_get_sep(uint8_t stream_endpoint_id)
342
342
return sep ;
343
343
}
344
344
345
- static struct bt_avdtp_sep * avdtp_get_cmd_sep (struct net_buf * buf , uint8_t * error_code )
345
+ static struct bt_avdtp_sep * avdtp_get_cmd_sep (struct net_buf * buf , uint8_t * error_code ,
346
+ uint8_t * seid )
346
347
{
347
348
struct bt_avdtp_sep * sep ;
349
+ uint8_t id ;
348
350
349
351
if (buf -> len < 1U ) {
350
352
* error_code = BT_AVDTP_BAD_LENGTH ;
353
+ LOG_WRN ("Malformed packet" );
354
+ return NULL ;
355
+ }
356
+
357
+ id = net_buf_pull_u8 (buf ) >> 2 ;
358
+ if ((id < BT_AVDTP_MIN_SEID ) || (id > BT_AVDTP_MAX_SEID )) {
359
+ * error_code = BT_AVDTP_BAD_ACP_SEID ;
351
360
LOG_WRN ("Invalid ACP SEID" );
352
361
return NULL ;
353
362
}
354
363
355
- sep = avdtp_get_sep (net_buf_pull_u8 (buf ) >> 2 );
364
+ if (seid != NULL ) {
365
+ * seid = id ;
366
+ }
367
+
368
+ sep = avdtp_get_sep (id );
356
369
return sep ;
357
370
}
358
371
@@ -364,7 +377,7 @@ static void avdtp_get_caps_cmd_internal(struct bt_avdtp *session, struct net_buf
364
377
struct bt_avdtp_sep * sep ;
365
378
uint8_t error_code = 0 ;
366
379
367
- sep = avdtp_get_cmd_sep (buf , & error_code );
380
+ sep = avdtp_get_cmd_sep (buf , & error_code , NULL );
368
381
369
382
if ((sep == NULL ) || (session -> ops -> get_capabilities_ind == NULL )) {
370
383
err = - ENOTSUP ;
@@ -539,7 +552,7 @@ static void avdtp_process_configuration_cmd(struct bt_avdtp *session, struct net
539
552
struct net_buf_simple_state state ;
540
553
uint8_t service_category = 0 ;
541
554
542
- sep = avdtp_get_cmd_sep (buf , & avdtp_err_code );
555
+ sep = avdtp_get_cmd_sep (buf , & avdtp_err_code , NULL );
543
556
avdtp_sep_lock (sep );
544
557
545
558
if (sep == NULL ) {
@@ -692,7 +705,7 @@ static void avdtp_open_cmd(struct bt_avdtp *session, struct net_buf *buf, uint8_
692
705
struct net_buf * rsp_buf ;
693
706
uint8_t avdtp_err_code = 0 ;
694
707
695
- sep = avdtp_get_cmd_sep (buf , & avdtp_err_code );
708
+ sep = avdtp_get_cmd_sep (buf , & avdtp_err_code , NULL );
696
709
avdtp_sep_lock (sep );
697
710
698
711
if ((sep == NULL ) || (session -> ops -> open_ind == NULL )) {
@@ -787,8 +800,10 @@ static void avdtp_start_cmd(struct bt_avdtp *session, struct net_buf *buf, uint8
787
800
struct bt_avdtp_sep * sep ;
788
801
struct net_buf * rsp_buf ;
789
802
uint8_t avdtp_err_code = 0 ;
803
+ uint8_t acp_seid = 0 ;
804
+
805
+ sep = avdtp_get_cmd_sep (buf , & avdtp_err_code , & acp_seid );
790
806
791
- sep = avdtp_get_cmd_sep (buf , & avdtp_err_code );
792
807
avdtp_sep_lock (sep );
793
808
794
809
if ((sep == NULL ) || (session -> ops -> start_ind == NULL )) {
@@ -815,7 +830,7 @@ static void avdtp_start_cmd(struct bt_avdtp *session, struct net_buf *buf, uint8
815
830
}
816
831
817
832
LOG_DBG ("start err code:%d" , avdtp_err_code );
818
- net_buf_add_u8 (rsp_buf , sep -> sep_info . id << 2 );
833
+ net_buf_add_u8 (rsp_buf , acp_seid );
819
834
net_buf_add_u8 (rsp_buf , avdtp_err_code );
820
835
}
821
836
@@ -866,7 +881,7 @@ static void avdtp_close_cmd(struct bt_avdtp *session, struct net_buf *buf, uint8
866
881
struct net_buf * rsp_buf ;
867
882
uint8_t avdtp_err_code = 0 ;
868
883
869
- sep = avdtp_get_cmd_sep (buf , & avdtp_err_code );
884
+ sep = avdtp_get_cmd_sep (buf , & avdtp_err_code , NULL );
870
885
avdtp_sep_lock (sep );
871
886
872
887
if ((sep == NULL ) || (session -> ops -> close_ind == NULL )) {
@@ -943,8 +958,9 @@ static void avdtp_suspend_cmd(struct bt_avdtp *session, struct net_buf *buf, uin
943
958
struct bt_avdtp_sep * sep ;
944
959
struct net_buf * rsp_buf ;
945
960
uint8_t avdtp_err_code = 0 ;
961
+ uint8_t acp_seid = 0 ;
946
962
947
- sep = avdtp_get_cmd_sep (buf , & avdtp_err_code );
963
+ sep = avdtp_get_cmd_sep (buf , & avdtp_err_code , & acp_seid );
948
964
avdtp_sep_lock (sep );
949
965
950
966
if ((sep == NULL ) || (session -> ops -> suspend_ind == NULL )) {
@@ -971,7 +987,7 @@ static void avdtp_suspend_cmd(struct bt_avdtp *session, struct net_buf *buf, uin
971
987
}
972
988
973
989
LOG_DBG ("suspend err code:%d" , avdtp_err_code );
974
- net_buf_add_u8 (rsp_buf , sep -> sep_info . id << 2 );
990
+ net_buf_add_u8 (rsp_buf , acp_seid );
975
991
net_buf_add_u8 (rsp_buf , avdtp_err_code );
976
992
}
977
993
@@ -1022,7 +1038,7 @@ static void avdtp_abort_cmd(struct bt_avdtp *session, struct net_buf *buf, uint8
1022
1038
struct net_buf * rsp_buf ;
1023
1039
uint8_t avdtp_err_code = 0 ;
1024
1040
1025
- sep = avdtp_get_cmd_sep (buf , & avdtp_err_code );
1041
+ sep = avdtp_get_cmd_sep (buf , & avdtp_err_code , NULL );
1026
1042
avdtp_sep_lock (sep );
1027
1043
1028
1044
if ((sep == NULL ) || (session -> ops -> abort_ind == NULL )) {
0 commit comments