avdtp: introduce AVDTP_INVALID_SEP_INDEX and use in init

This commit is contained in:
Matthias Ringwald 2017-05-05 11:21:29 +02:00
parent cde6ece438
commit 6484b28a8c
4 changed files with 14 additions and 13 deletions

View File

@ -263,7 +263,7 @@ static void stream_endpoint_state_machine(avdtp_connection_t * connection, avdtp
stream_endpoint->initiator_config_state = AVDTP_INITIATOR_STREAM_CONFIG_IDLE;
stream_endpoint->remote_seps_num = 0;
memset(stream_endpoint->remote_seps, 0, sizeof(avdtp_sep_t)*MAX_NUM_SEPS);
stream_endpoint->remote_sep_index = 0;
stream_endpoint->remote_sep_index = AVDTP_INVALID_SEP_INDEX;
break;
}
if (stream_endpoint->l2cap_recovery_cid == local_cid){
@ -538,7 +538,7 @@ void avdtp_open_stream(uint16_t con_handle, uint8_t acp_seid, avdtp_context_t *
}
if (stream_endpoint->state < AVDTP_STREAM_ENDPOINT_CONFIGURED) return;
if (stream_endpoint->remote_sep_index == 0xFF) return;
if (stream_endpoint->remote_sep_index == AVDTP_INVALID_SEP_INDEX) return;
connection->initiator_transaction_label++;
connection->acp_seid = acp_seid;
@ -565,7 +565,7 @@ void avdtp_start_stream(uint16_t con_handle, uint8_t acp_seid, avdtp_context_t *
printf("avdtp_media_connect: no stream_endpoint with acp_seid %d found\n", acp_seid);
return;
}
if (stream_endpoint->remote_sep_index == 0xFF) return;
if (stream_endpoint->remote_sep_index == AVDTP_INVALID_SEP_INDEX) return;
if (stream_endpoint->state < AVDTP_STREAM_ENDPOINT_OPENED) return;
connection->initiator_transaction_label++;
connection->acp_seid = acp_seid;
@ -590,7 +590,7 @@ void avdtp_stop_stream(uint16_t con_handle, uint8_t acp_seid, avdtp_context_t *
printf("avdtp_stop_stream: no stream_endpoint with acp seid %d found\n", acp_seid);
return;
}
if (stream_endpoint->remote_sep_index == 0xFF) return;
if (stream_endpoint->remote_sep_index == AVDTP_INVALID_SEP_INDEX) return;
switch (stream_endpoint->state){
case AVDTP_STREAM_ENDPOINT_OPENED:
case AVDTP_STREAM_ENDPOINT_STREAMING:
@ -623,7 +623,7 @@ void avdtp_abort_stream(uint16_t con_handle, uint8_t acp_seid, avdtp_context_t *
printf("avdtp_abort_stream: no stream_endpoint for seid %d found\n", acp_seid);
return;
}
if (stream_endpoint->remote_sep_index == 0xFF) return;
if (stream_endpoint->remote_sep_index == AVDTP_INVALID_SEP_INDEX) return;
switch (stream_endpoint->state){
case AVDTP_STREAM_ENDPOINT_CONFIGURED:
case AVDTP_STREAM_ENDPOINT_CLOSING:
@ -741,7 +741,7 @@ void avdtp_reconfigure(uint16_t con_handle, uint8_t acp_seid, uint16_t configure
if (connection->initiator_connection_state != AVDTP_SIGNALING_CONNECTION_INITIATOR_IDLE) return;
avdtp_stream_endpoint_t * stream_endpoint = avdtp_stream_endpoint_associated_with_acp_seid(acp_seid, context);
if (!stream_endpoint) return;
if (stream_endpoint->remote_sep_index == 0xFF) return;
if (stream_endpoint->remote_sep_index == AVDTP_INVALID_SEP_INDEX) return;
connection->initiator_transaction_label++;
connection->acp_seid = acp_seid;
connection->int_seid = stream_endpoint->sep.seid;
@ -761,7 +761,7 @@ void avdtp_suspend(uint16_t con_handle, uint8_t acp_seid, avdtp_context_t * cont
if (connection->initiator_connection_state != AVDTP_SIGNALING_CONNECTION_INITIATOR_IDLE) return;
avdtp_stream_endpoint_t * stream_endpoint = avdtp_stream_endpoint_associated_with_acp_seid(acp_seid, context);
if (!stream_endpoint) return;
if (stream_endpoint->remote_sep_index == 0xFF) return;
if (stream_endpoint->remote_sep_index == AVDTP_INVALID_SEP_INDEX) return;
connection->initiator_transaction_label++;
connection->acp_seid = acp_seid;
connection->int_seid = stream_endpoint->sep.seid;

View File

@ -214,7 +214,7 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t * connection, uint8_t
}
// find or add sep
int i;
stream_endpoint->remote_sep_index = 0xFF;
stream_endpoint->remote_sep_index = AVDTP_INVALID_SEP_INDEX;
for (i=0; i < stream_endpoint->remote_seps_num; i++){
if (stream_endpoint->remote_seps[i].seid == sep.seid){
stream_endpoint->remote_sep_index = i;
@ -222,7 +222,7 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t * connection, uint8_t
}
printf(" ACP .. seid %d, index %d\n", sep.seid, stream_endpoint->remote_sep_index);
if (stream_endpoint->remote_sep_index != 0xFF){
if (stream_endpoint->remote_sep_index != AVDTP_INVALID_SEP_INDEX){
if (stream_endpoint->remote_seps[stream_endpoint->remote_sep_index].in_use){
// reject if already configured
connection->error_code = SEP_IN_USE;
@ -282,14 +282,14 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t * connection, uint8_t
// find sep or raise error
int i;
stream_endpoint->remote_sep_index = 0xFF;
stream_endpoint->remote_sep_index = AVDTP_INVALID_SEP_INDEX;
for (i = 0; i < stream_endpoint->remote_seps_num; i++){
if (stream_endpoint->remote_seps[i].seid == sep.seid){
stream_endpoint->remote_sep_index = i;
}
}
if (stream_endpoint->remote_sep_index == 0xFF){
if (stream_endpoint->remote_sep_index == AVDTP_INVALID_SEP_INDEX){
printf(" ACP: REJECT AVDTP_SI_RECONFIGURE, BAD_ACP_SEID\n");
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_REJECT_CATEGORY_WITH_ERROR_CODE;
connection->error_code = BAD_ACP_SEID;

View File

@ -57,12 +57,11 @@ void avdtp_initialize_stream_endpoint(avdtp_stream_endpoint_t * stream_endpoint)
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_IDLE;
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_STREAM_CONFIG_IDLE;
stream_endpoint->initiator_config_state = AVDTP_INITIATOR_STREAM_CONFIG_IDLE;
stream_endpoint->remote_sep_index = 0;
stream_endpoint->remote_sep_index = AVDTP_INVALID_SEP_INDEX;
stream_endpoint->media_disconnect = 0;
stream_endpoint->remote_seps_num = 0;
stream_endpoint->sep.in_use = 0;
memset(stream_endpoint->remote_seps, 0, sizeof(stream_endpoint->remote_seps));
stream_endpoint->remote_sep_index = 0;
}
avdtp_stream_endpoint_t * avdtp_stream_endpoint_for_seid(uint16_t seid, avdtp_context_t * context){

View File

@ -52,6 +52,8 @@
extern "C" {
#endif
#define AVDTP_INVALID_SEP_INDEX 0xff
avdtp_connection_t * avdtp_connection_for_bd_addr(bd_addr_t addr, avdtp_context_t * context);
avdtp_connection_t * avdtp_connection_for_con_handle(hci_con_handle_t con_handle, avdtp_context_t * context);
avdtp_connection_t * avdtp_connection_for_l2cap_signaling_cid(uint16_t l2cap_cid, avdtp_context_t * context);