avdtp: prefix error codes with AVDTP_ERROR_CODE_

This commit is contained in:
Matthias Ringwald 2021-03-23 18:08:47 +01:00
parent 1ef2d533ff
commit 5b391ed707
3 changed files with 42 additions and 41 deletions

View File

@ -74,31 +74,32 @@ extern "C" {
#define AVDTP_SINK_FEATURE_MASK_AMPLIFIER 0x0008u
// ACP to INT, Signal Response Header Error Codes
#define BAD_HEADER_FORMAT 0x01
#define AVDTP_ERROR_CODE_BAD_HEADER_FORMAT 0x01
// ACP to INT, Signal Response Payload Format Error Codes
#define BAD_LENGTH 0x11
#define BAD_ACP_SEID 0x12
#define SEP_IN_USE 0x13
#define SEP_NOT_IN_USE 0x14
#define BAD_SERV_CATEGORY 0x17
#define BAD_PAYLOAD_FORMAT 0x18
#define NOT_SUPPORTED_COMMAND 0x19
#define INVALID_CAPABILITIES 0x1A
#define AVDTP_ERROR_CODE_BAD_LENGTH 0x11
#define AVDTP_ERROR_CODE_BAD_ACP_SEID 0x12
#define AVDTP_ERROR_CODE_SEP_IN_USE 0x13
#define AVDTP_ERROR_CODE_SEP_NOT_IN_USE 0x14
#define AVDTP_ERROR_CODE_BAD_SERV_CATEGORY 0x17
#define AVDTP_ERROR_CODE_BAD_PAYLOAD_FORMAT 0x18
#define AVDTP_ERROR_CODE_NOT_SUPPORTED_COMMAND 0x19
#define AVDTP_ERROR_CODE_INVALID_CAPABILITIES 0x1A
// ACP to INT, Signal Response Transport Service Capabilities Error Codes
#define BAD_RECOVERY_TYPE 0x22
#define BAD_MEDIA_TRANSPORT_FORMAT 0x23
#define BAD_RECOVERY_FORMAT 0x25
#define BAD_ROHC_FORMAT 0x26
#define BAD_CP_FORMAT 0x27
#define BAD_MULTIPLEXING_FORMAT 0x28
#define UNSUPPORTED_CONFIGURATION 0x29
#define AVDTP_ERROR_CODE_BAD_RECOVERY_TYPE 0x22
#define AVDTP_ERROR_CODE_BAD_MEDIA_TRANSPORT_FORMAT 0x23
#define AVDTP_ERROR_CODE_BAD_RECOVERY_FORMAT 0x25
#define AVDTP_ERROR_CODE_BAD_ROHC_FORMAT 0x26
#define AVDTP_ERROR_CODE_BAD_CP_FORMAT 0x27
#define AVDTP_ERROR_CODE_BAD_MULTIPLEXING_FORMAT 0x28
#define AVDTP_ERROR_CODE_UNSUPPORTED_CONFIGURATION 0x29
// ACP to INT, Procedure Error Codes
#define BAD_STATE 0x31
#define AVDTP_ERROR_CODE_BAD_STATE 0x31
#define AVDTP_INVALID_SEP_SEID 0xFF
// Internal Error Codes
#define AVDTP_INVALID_SEP_SEID 0xFF
// Signal Identifier fields
@ -623,7 +624,7 @@ void avdtp_register_media_handler(void (*callback)(uint8_t local_seid, uint8_t *
/**
* @brief Register media configuration validator. Can reject insuitable configuration or report stream endpoint as currently busy
* @note validator has to return AVDTP error codes like: SEP_IN_USE or UNSUPPORTED_CONFIGURATION
* @note validator has to return AVDTP error codes like: AVDTP_ERROR_CODE_SEP_IN_USE or AVDTP_ERROR_CODE_UNSUPPORTED_CONFIGURATION
* @param callback
*/
void avdtp_register_media_config_validator(uint8_t (*callback)(const avdtp_stream_endpoint_t * stream_endpoint, avdtp_media_codec_type_t media_codec_type, const uint8_t * media_codec_info, uint16_t media_codec_info_len));

View File

@ -125,7 +125,7 @@ avdtp_acceptor_handle_configuration_command(avdtp_connection_t *connection, int
if (is_avdtp_remote_seid_registered(stream_endpoint)){
if (stream_endpoint->remote_sep.in_use){
log_info("remote seid already in use");
connection->error_code = SEP_IN_USE;
connection->error_code = AVDTP_ERROR_CODE_SEP_IN_USE;
// find first registered category and fire the error
connection->reject_service_category = 0;
int i;
@ -163,7 +163,7 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t *connection, uint8_t
avdtp_stream_endpoint_t * stream_endpoint = NULL;
connection->acceptor_transaction_label = connection->acceptor_signaling_packet.transaction_label;
if (!avdtp_acceptor_validate_msg_length(connection->acceptor_signaling_packet.signal_identifier, size)) {
connection->error_code = BAD_LENGTH;
connection->error_code = AVDTP_ERROR_CODE_BAD_LENGTH;
connection->acceptor_connection_state = AVDTP_SIGNALING_CONNECTION_ACCEPTOR_W2_REJECT_WITH_ERROR_CODE;
connection->reject_signal_identifier = connection->acceptor_signaling_packet.signal_identifier;
avdtp_request_can_send_now_acceptor(connection);
@ -192,9 +192,9 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t *connection, uint8_t
stream_endpoint = avdtp_get_stream_endpoint_for_seid(connection->acceptor_local_seid);
if (!stream_endpoint){
log_info("cmd %d - REJECT", connection->acceptor_signaling_packet.signal_identifier);
connection->error_code = BAD_ACP_SEID;
connection->error_code = AVDTP_ERROR_CODE_BAD_ACP_SEID;
if (connection->acceptor_signaling_packet.signal_identifier == AVDTP_SI_OPEN){
connection->error_code = BAD_STATE;
connection->error_code = AVDTP_ERROR_CODE_BAD_STATE;
}
connection->acceptor_connection_state = AVDTP_SIGNALING_CONNECTION_ACCEPTOR_W2_REJECT_WITH_ERROR_CODE;
@ -222,7 +222,7 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t *connection, uint8_t
if (connection->num_suspended_seids == 0) {
log_info("no susspended seids, BAD_ACP_SEID");
connection->error_code = BAD_ACP_SEID;
connection->error_code = AVDTP_ERROR_CODE_BAD_ACP_SEID;
connection->reject_service_category = connection->acceptor_local_seid;
connection->acceptor_connection_state = AVDTP_SIGNALING_CONNECTION_ACCEPTOR_W2_REJECT_CATEGORY_WITH_ERROR_CODE;
connection->reject_signal_identifier = connection->acceptor_signaling_packet.signal_identifier;
@ -234,7 +234,7 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t *connection, uint8_t
stream_endpoint = avdtp_get_stream_endpoint_for_seid(connection->acceptor_local_seid);
if (!stream_endpoint){
log_info("stream_endpoint not found, BAD_ACP_SEID");
connection->error_code = BAD_ACP_SEID;
connection->error_code = AVDTP_ERROR_CODE_BAD_ACP_SEID;
connection->reject_service_category = connection->acceptor_local_seid;
connection->acceptor_connection_state = AVDTP_SIGNALING_CONNECTION_ACCEPTOR_W2_REJECT_CATEGORY_WITH_ERROR_CODE;
connection->reject_signal_identifier = connection->acceptor_signaling_packet.signal_identifier;
@ -292,7 +292,7 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t *connection, uint8_t
log_info("Reject SET_CONFIGURATION BAD_STATE %d", connection->configuration_state);
connection->reject_signal_identifier = connection->acceptor_signaling_packet.signal_identifier;
connection->reject_service_category = 0;
connection->error_code = BAD_STATE;
connection->error_code = AVDTP_ERROR_CODE_BAD_STATE;
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_REJECT_CATEGORY_WITH_ERROR_CODE;
break;
case AVDTP_CONFIGURATION_STATE_LOCAL_CONFIGURED:
@ -300,7 +300,7 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t *connection, uint8_t
log_info("Reject SET_CONFIGURATION SEP_IN_USE");
connection->reject_signal_identifier = connection->acceptor_signaling_packet.signal_identifier;
connection->reject_service_category = 0;
connection->error_code = SEP_IN_USE;
connection->error_code = AVDTP_ERROR_CODE_SEP_IN_USE;
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_REJECT_CATEGORY_WITH_ERROR_CODE;
break;
default:
@ -326,7 +326,7 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t *connection, uint8_t
if (!is_avdtp_remote_seid_registered(stream_endpoint)){
log_info("REJECT AVDTP_SI_RECONFIGURE, BAD_ACP_SEID");
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_REJECT_CATEGORY_WITH_ERROR_CODE;
connection->error_code = BAD_ACP_SEID;
connection->error_code = AVDTP_ERROR_CODE_BAD_ACP_SEID;
connection->reject_signal_identifier = connection->acceptor_signaling_packet.signal_identifier;
break;
}
@ -354,7 +354,7 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t *connection, uint8_t
if (stream_endpoint->state != AVDTP_STREAM_ENDPOINT_CONFIGURED){
log_info("REJECT AVDTP_SI_OPEN, BAD_STATE");
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_REJECT_WITH_ERROR_CODE;
connection->error_code = BAD_STATE;
connection->error_code = AVDTP_ERROR_CODE_BAD_STATE;
connection->reject_signal_identifier = connection->acceptor_signaling_packet.signal_identifier;
break;
}
@ -367,7 +367,7 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t *connection, uint8_t
if (stream_endpoint->state != AVDTP_STREAM_ENDPOINT_OPENED){
log_info("REJECT AVDTP_SI_START, BAD_STATE, state %d", stream_endpoint->state);
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_REJECT_CATEGORY_WITH_ERROR_CODE;
connection->error_code = BAD_STATE;
connection->error_code = AVDTP_ERROR_CODE_BAD_STATE;
connection->reject_signal_identifier = connection->acceptor_signaling_packet.signal_identifier;
break;
}
@ -385,7 +385,7 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t *connection, uint8_t
default:
log_info("AVDTP_SI_CLOSE, bad state %d ", stream_endpoint->state);
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_REJECT_WITH_ERROR_CODE;
connection->error_code = BAD_STATE;
connection->error_code = AVDTP_ERROR_CODE_BAD_STATE;
connection->reject_signal_identifier = connection->acceptor_signaling_packet.signal_identifier;
break;
}
@ -403,7 +403,7 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t *connection, uint8_t
default:
log_info("AVDTP_SI_ABORT, bad state %d ", stream_endpoint->state);
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_REJECT_WITH_ERROR_CODE;
connection->error_code = BAD_STATE;
connection->error_code = AVDTP_ERROR_CODE_BAD_STATE;
connection->reject_signal_identifier = connection->acceptor_signaling_packet.signal_identifier;
break;
}
@ -422,7 +422,7 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t *connection, uint8_t
default:
log_info("AVDTP_SI_SUSPEND, bad state %d", stream_endpoint->state);
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_REJECT_CATEGORY_WITH_ERROR_CODE;
connection->error_code = BAD_STATE;
connection->error_code = AVDTP_ERROR_CODE_BAD_STATE;
connection->reject_signal_identifier = connection->acceptor_signaling_packet.signal_identifier;
break;
}

View File

@ -251,7 +251,7 @@ static int avdtp_unpack_service_capabilities_has_errors(avdtp_connection_t * con
((category == AVDTP_SERVICE_CATEGORY_INVALID_FF) && (signal_identifier == AVDTP_SI_RECONFIGURE))){
log_info(" ERROR: BAD SERVICE CATEGORY %d\n", category);
connection->reject_service_category = category;
connection->error_code = BAD_SERV_CATEGORY;
connection->error_code = AVDTP_ERROR_CODE_BAD_SERV_CATEGORY;
return 1;
}
@ -259,7 +259,7 @@ static int avdtp_unpack_service_capabilities_has_errors(avdtp_connection_t * con
if ( (category != AVDTP_CONTENT_PROTECTION) && (category != AVDTP_MEDIA_CODEC)){
log_info(" ERROR: REJECT CATEGORY, INVALID_CAPABILITIES\n");
connection->reject_service_category = category;
connection->error_code = INVALID_CAPABILITIES;
connection->error_code = AVDTP_ERROR_CODE_INVALID_CAPABILITIES;
return 1;
}
}
@ -269,7 +269,7 @@ static int avdtp_unpack_service_capabilities_has_errors(avdtp_connection_t * con
if (cap_len != 0){
log_info(" ERROR: REJECT CATEGORY, BAD_MEDIA_TRANSPORT\n");
connection->reject_service_category = category;
connection->error_code = BAD_MEDIA_TRANSPORT_FORMAT;
connection->error_code = AVDTP_ERROR_CODE_BAD_MEDIA_TRANSPORT_FORMAT;
return 1;
}
break;
@ -278,7 +278,7 @@ static int avdtp_unpack_service_capabilities_has_errors(avdtp_connection_t * con
if (cap_len != 0){
log_info(" ERROR: REJECT CATEGORY, BAD_LENGTH\n");
connection->reject_service_category = category;
connection->error_code = BAD_LENGTH;
connection->error_code = AVDTP_ERROR_CODE_BAD_LENGTH;
return 1;
}
break;
@ -286,7 +286,7 @@ static int avdtp_unpack_service_capabilities_has_errors(avdtp_connection_t * con
if (cap_len != 3){
log_info(" ERROR: REJECT CATEGORY, BAD_MEDIA_TRANSPORT\n");
connection->reject_service_category = category;
connection->error_code = BAD_RECOVERY_FORMAT;
connection->error_code = AVDTP_ERROR_CODE_BAD_RECOVERY_FORMAT;
return 1;
}
break;
@ -294,7 +294,7 @@ static int avdtp_unpack_service_capabilities_has_errors(avdtp_connection_t * con
if (cap_len < 2){
log_info(" ERROR: REJECT CATEGORY, BAD_CP_FORMAT\n");
connection->reject_service_category = category;
connection->error_code = BAD_CP_FORMAT;
connection->error_code = AVDTP_ERROR_CODE_BAD_CP_FORMAT;
return 1;
}
break;
@ -303,7 +303,7 @@ static int avdtp_unpack_service_capabilities_has_errors(avdtp_connection_t * con
if (cap_len != 1){
log_info(" ERROR: REJECT CATEGORY, BAD_HEADER_COMPRESSION\n");
connection->reject_service_category = category;
connection->error_code = BAD_RECOVERY_FORMAT;
connection->error_code = AVDTP_ERROR_CODE_BAD_RECOVERY_FORMAT;
return 1;
}
break;
@ -333,7 +333,7 @@ uint16_t avdtp_unpack_service_capabilities(avdtp_connection_t * connection, avdt
if (cap_len > to_process){
connection->reject_service_category = category;
connection->error_code = BAD_LENGTH;
connection->error_code = AVDTP_ERROR_CODE_BAD_LENGTH;
return 0;
}