int stream_input_descriptor_imp::proc_get_rx_state_resp(void *¬ification_id, const uint8_t *frame, uint16_t frame_len, int &status) { struct jdksavdecc_frame *cmd_frame; int acmp_cmd_get_rx_state_resp_returned; uint32_t msg_type; cmd_frame = (struct jdksavdecc_frame *)malloc(sizeof(struct jdksavdecc_frame)); memcpy(cmd_frame->payload, frame, frame_len); acmp_cmd_get_rx_state_resp_returned = jdksavdecc_acmpdu_read(&acmp_cmd_get_rx_state_resp, frame, ETHER_HDR_SIZE, frame_len); if(acmp_cmd_get_rx_state_resp_returned < 0) { log_imp_ref->post_log_msg(LOGGING_LEVEL_ERROR, "acmp_cmd_get_rx_state_read error"); assert(acmp_cmd_get_rx_state_resp_returned >= 0); return -1; } msg_type = acmp_cmd_get_rx_state_resp.header.message_type; status = acmp_cmd_get_rx_state_resp.header.status; acmp_controller_state_machine_ref->state_resp(notification_id, msg_type, cmd_frame); free(cmd_frame); return 0; }
int stream_input_descriptor_imp::proc_get_rx_state_resp(void *& notification_id, const uint8_t * frame, size_t frame_len, int & status) { struct jdksavdecc_frame cmd_frame; struct jdksavdecc_acmpdu acmp_cmd_get_rx_state_resp; // Store the response received after sending a GET_RX_STATE command. ssize_t acmp_cmd_get_rx_state_resp_returned; memcpy(cmd_frame.payload, frame, frame_len); acmp_cmd_get_rx_state_resp_returned = jdksavdecc_acmpdu_read(&acmp_cmd_get_rx_state_resp, frame, ETHER_HDR_SIZE, frame_len); if (acmp_cmd_get_rx_state_resp_returned < 0) { log_imp_ref->post_log_msg(LOGGING_LEVEL_ERROR, "acmp_cmd_get_rx_state_read error"); assert(acmp_cmd_get_rx_state_resp_returned >= 0); return -1; } store_cmd_resp_frame(GET_RX_STATE_RESPONSE, frame, ETHER_HDR_SIZE, frame_len); status = acmp_cmd_get_rx_state_resp.header.status; acmp_controller_state_machine_ref->state_resp(notification_id, &cmd_frame); return 0; }
int proc_connect_rx_resp( const uint8_t *frame, size_t frame_len, int *status) { struct jdksavdecc_frame cmd_frame; ssize_t acmp_cmd_connect_rx_resp_returned; struct jdksavdecc_acmpdu acmp_cmd_connect_rx_resp; // Store the response received after sending a CONNECT_RX command. memset(&acmp_cmd_connect_rx_resp, 0, sizeof(struct jdksavdecc_acmpdu)); cmd_frame.length = frame_len; memcpy(cmd_frame.payload, frame, frame_len); acmp_cmd_connect_rx_resp_returned = jdksavdecc_acmpdu_read(&acmp_cmd_connect_rx_resp, frame, ZERO_OFFSET_IN_PAYLOAD, frame_len); if(acmp_cmd_connect_rx_resp_returned < 0) { DEBUG_INFO( "LOGGING_LEVEL_ERROR:acmp_cmd_connect_rx_read error" ); assert(acmp_cmd_connect_rx_resp_returned >= 0); return -1; } *status = acmp_cmd_connect_rx_resp.header.status; acmp_proc_state_resp( &cmd_frame ); return 0; }
int stream_input_descriptor_imp::proc_disconnect_rx_resp(void *& notification_id, const uint8_t * frame, size_t frame_len, int & status) { struct jdksavdecc_frame cmd_frame; ssize_t acmp_cmd_disconnect_rx_resp_returned; memcpy(cmd_frame.payload, frame, frame_len); acmp_cmd_disconnect_rx_resp_returned = jdksavdecc_acmpdu_read(&acmp_cmd_disconnect_rx_resp, frame, ETHER_HDR_SIZE, frame_len); if (acmp_cmd_disconnect_rx_resp_returned < 0) { log_imp_ref->post_log_msg(LOGGING_LEVEL_ERROR, "acmp_cmd_disconnect_rx_read error"); assert(acmp_cmd_disconnect_rx_resp_returned >= 0); return -1; } status = acmp_cmd_disconnect_rx_resp.header.status; acmp_controller_state_machine_ref->state_resp(notification_id, &cmd_frame); return 0; }
int proc_get_tx_state_resp( const uint8_t *frame, size_t frame_len,uint16_t desc_index, int *status) { struct jdksavdecc_frame cmd_frame; ssize_t acmp_cmd_get_tx_state_resp_returned; struct jdksavdecc_acmpdu acmp_cmd_get_tx_state_resp; memset(&acmp_cmd_get_tx_state_resp, 0, sizeof(struct jdksavdecc_acmpdu)); cmd_frame.length = frame_len; memcpy(cmd_frame.payload, frame, frame_len); acmp_cmd_get_tx_state_resp_returned = jdksavdecc_acmpdu_read(&acmp_cmd_get_tx_state_resp, frame, ZERO_OFFSET_IN_PAYLOAD, frame_len ); if(acmp_cmd_get_tx_state_resp_returned < 0) { DEBUG_INFO( "LOGGING_LEVEL_ERROR:acmp_cmd_get_tx_state_read error" ); assert(acmp_cmd_get_tx_state_resp_returned >= 0); return -1; } *status = acmp_cmd_get_tx_state_resp.header.status; acmp_update_output_stream_descriptor( desc_index, &acmp_cmd_get_tx_state_resp); set_stream_output_tx_state_resp( true ); acmp_proc_state_resp( &cmd_frame ); return 0; }
int acmp_callback( uint32_t notification_flag, uint8_t *frame, uint16_t frame_len ) { uint32_t msg_type = jdksavdecc_common_control_header_get_control_data(frame, ZERO_OFFSET_IN_PAYLOAD); uint16_t seq_id = jdksavdecc_acmpdu_get_sequence_id(frame, ZERO_OFFSET_IN_PAYLOAD); uint32_t status = jdksavdecc_common_control_header_get_status(frame, ZERO_OFFSET_IN_PAYLOAD); uint64_t end_station_entity_id; struct jdksavdecc_eui64 stream_entity_station = jdksavdecc_common_control_header_get_stream_id( frame, ZERO_OFFSET_IN_PAYLOAD ); uint64_t end_stream_id = jdksavdecc_uint64_get(&stream_entity_station, 0); subject_data_elem elem; // acmp info struct jdksavdecc_acmpdu node_acmpdu; jdksavdecc_acmpdu_read( &node_acmpdu, frame, ZERO_OFFSET_IN_PAYLOAD, frame_len ); if((notification_flag == CMD_WITH_NOTIFICATION) && ((msg_type == JDKSAVDECC_ACMP_MESSAGE_TYPE_GET_TX_STATE_RESPONSE) || (msg_type == JDKSAVDECC_ACMP_MESSAGE_TYPE_GET_TX_CONNECTION_RESPONSE))) { struct jdksavdecc_eui64 _end_station_entity_id = jdksavdecc_acmpdu_get_talker_entity_id(frame, ZERO_OFFSET_IN_PAYLOAD); struct jdksavdecc_eui64 listener_entity = jdksavdecc_acmpdu_get_listener_entity_id(frame, ZERO_OFFSET_IN_PAYLOAD); end_station_entity_id = jdksavdecc_uint64_get(&_end_station_entity_id, 0); uint64_t listener_id = jdksavdecc_uint64_get(&listener_entity, 0); if (status == ACMP_STATUS_SUCCESS) { if (NULL != gp_log_imp) gp_log_imp->log.post_log_msg( &gp_log_imp->log, LOGGING_LEVEL_DEBUG, " [ RESPONSE_RECEIVED: %d 0x%016llx (talker), %d, %d, %d, %s ]", RESPONSE_RECEIVED, end_station_entity_id, (uint16_t)msg_type + CMD_LOOKUP, 0, 0, acmp_cmd_status_value_to_name(status)); } else { if (NULL != gp_log_imp) gp_log_imp->log.post_log_msg( &gp_log_imp->log, LOGGING_LEVEL_ERROR, "[ RESPONSE_RECEIVED, 0x%016llx (talker), %s, %s, %s, %s, %d ]", end_station_entity_id, acmp_cmd_value_to_name(msg_type), "NULL", "NULL", acmp_cmd_status_value_to_name(status), seq_id ); acmp_recv_resp_err = true; } // add notification of get_tx_state command to obserber if (msg_type == JDKSAVDECC_ACMP_MESSAGE_TYPE_GET_TX_STATE_RESPONSE) { subject_data_elem elem; elem.listener_id = listener_id; elem.listener_index = node_acmpdu.listener_unique_id; elem.tarker_id = end_stream_id; elem.tarker_index = node_acmpdu.talker_unique_id; elem.ctrl_msg.data_type = JDKSAVDECC_SUBTYPE_ACMP; elem.ctrl_msg.msg_type = msg_type; elem.ctrl_msg.msg_resp_status = status;// -1 means timeout status. elem.data_frame = NULL;// set data frame elem.data_frame_len = 0; set_subject_data( elem, &gconnector_subjector ); notify_observer( &gconnector_subjector ); } } else if((notification_flag == CMD_WITH_NOTIFICATION) && ((msg_type == JDKSAVDECC_ACMP_MESSAGE_TYPE_CONNECT_RX_RESPONSE) || (msg_type == JDKSAVDECC_ACMP_MESSAGE_TYPE_DISCONNECT_RX_RESPONSE) || (msg_type == JDKSAVDECC_ACMP_MESSAGE_TYPE_GET_RX_STATE_RESPONSE))) { struct jdksavdecc_eui64 _end_station_entity_id = jdksavdecc_acmpdu_get_listener_entity_id( frame, ZERO_OFFSET_IN_PAYLOAD ); struct jdksavdecc_eui64 _tarker_id = jdksavdecc_acmpdu_get_talker_entity_id( frame, ZERO_OFFSET_IN_PAYLOAD ); uint64_t tarker_id = jdksavdecc_uint64_get( &_tarker_id, 0 ); end_station_entity_id = jdksavdecc_uint64_get(&_end_station_entity_id, 0); if( (status == ACMP_STATUS_SUCCESS) &&\ ((msg_type == JDKSAVDECC_ACMP_MESSAGE_TYPE_CONNECT_RX_RESPONSE) || \ (msg_type == JDKSAVDECC_ACMP_MESSAGE_TYPE_DISCONNECT_RX_RESPONSE)))// udpate system descriptor connect list { if (NULL != gp_log_imp) gp_log_imp->log.post_log_msg( &gp_log_imp->log, LOGGING_LEVEL_DEBUG, " [ RESPONSE_RECEIVED: %d 0x%016llx (listener)-0x%016llx(tarker), %d, %d, %d, %s ]", RESPONSE_RECEIVED, end_station_entity_id, tarker_id, (uint16_t)msg_type + CMD_LOOKUP, 0, 0, acmp_cmd_status_value_to_name(status)); elem.connect_flag = (msg_type == JDKSAVDECC_ACMP_MESSAGE_TYPE_CONNECT_RX_RESPONSE)?true:false; elem.listener_id = end_station_entity_id; elem.listener_index = node_acmpdu.listener_unique_id; elem.tarker_id = tarker_id; elem.tarker_index = node_acmpdu.talker_unique_id; elem.ctrl_msg.data_type = JDKSAVDECC_SUBTYPE_ACMP; elem.ctrl_msg.msg_type = msg_type; elem.ctrl_msg.msg_resp_status = status; elem.data_frame = NULL;// set data frame elem.data_frame_len = 0; set_subject_data( elem, &gconnector_subjector ); notify_observer( &gconnector_subjector ); } else if( (status == ACMP_STATUS_SUCCESS) && \ (msg_type == JDKSAVDECC_ACMP_MESSAGE_TYPE_GET_RX_STATE_RESPONSE)) { if (NULL != gp_log_imp) gp_log_imp->log.post_log_msg( &gp_log_imp->log, LOGGING_LEVEL_DEBUG, "[ RESPONSE_RECEIVED: %d 0x%016llx (listener), %d, %d, %d, %s ]", RESPONSE_RECEIVED, end_station_entity_id, (uint16_t)msg_type + CMD_LOOKUP, 0, 0, acmp_cmd_status_value_to_name(status)); elem.listener_id = end_station_entity_id; elem.listener_index = node_acmpdu.listener_unique_id; elem.tarker_id = tarker_id; elem.tarker_index = node_acmpdu.talker_unique_id; elem.ctrl_msg.data_type = JDKSAVDECC_SUBTYPE_ACMP; elem.ctrl_msg.msg_type = msg_type; elem.ctrl_msg.msg_resp_status = status; elem.data_frame = NULL;// set data frame elem.data_frame_len = 0; set_subject_data( elem, &gconnector_subjector ); notify_observer( &gconnector_subjector ); } else if( status != ACMP_STATUS_SUCCESS ) { if (NULL != gp_log_imp) gp_log_imp->log.post_log_msg( &gp_log_imp->log, LOGGING_LEVEL_ERROR, "[ 0x%016llx (listener), %s, %s, %s, %s, %d ]", end_station_entity_id, acmp_cmd_value_to_name(msg_type), "NULL", "NULL", acmp_cmd_status_value_to_name(status), seq_id); elem.connect_flag = false; elem.listener_id = end_station_entity_id; elem.listener_index = node_acmpdu.listener_unique_id; elem.tarker_id = tarker_id; elem.tarker_index = node_acmpdu.talker_unique_id; elem.ctrl_msg.data_type = JDKSAVDECC_SUBTYPE_ACMP; elem.ctrl_msg.msg_type = msg_type; elem.ctrl_msg.msg_resp_status = status; elem.data_frame = NULL;// set data frame elem.data_frame_len = 0; set_subject_data( elem, &gconnector_subjector ); notify_observer( &gconnector_subjector ); acmp_recv_resp_err = true; } } else if((msg_type == JDKSAVDECC_ACMP_MESSAGE_TYPE_GET_TX_STATE_RESPONSE) || (msg_type == JDKSAVDECC_ACMP_MESSAGE_TYPE_GET_TX_CONNECTION_RESPONSE)) { struct jdksavdecc_eui64 _end_station_entity_id = jdksavdecc_acmpdu_get_talker_entity_id(frame, ZERO_OFFSET_IN_PAYLOAD); end_station_entity_id = jdksavdecc_uint64_get(&_end_station_entity_id, 0); gp_log_imp->log.post_log_msg( &gp_log_imp->log, LOGGING_LEVEL_DEBUG, "[RESPONSE_RECEIVED, 0x%016llx (talker), %s, %s, %s, %s, %d]", end_station_entity_id, acmp_cmd_value_to_name(msg_type), "NULL", "NULL", acmp_cmd_status_value_to_name(status), seq_id); } else { struct jdksavdecc_eui64 _end_station_entity_id = jdksavdecc_acmpdu_get_listener_entity_id(frame, ZERO_OFFSET_IN_PAYLOAD); end_station_entity_id = jdksavdecc_uint64_get(&_end_station_entity_id, 0); if (NULL != gp_log_imp) gp_log_imp->log.post_log_msg( &gp_log_imp->log, LOGGING_LEVEL_DEBUG, "[ COMMAND_SENT, 0x%016llx listener, %s, %s, %s, %s, %d ]", end_station_entity_id, acmp_cmd_value_to_name(msg_type), "NULL", "NULL", acmp_cmd_status_value_to_name(status), seq_id ); } return 0; }
void acmp_inflight_station_timeouts( inflight_plist acmp_sta, inflight_plist hdr ) { bool is_retried = false; inflight_plist acmp_pstation = NULL; uint8_t *frame = NULL; uint16_t frame_len = 0; uint32_t interval_time = 0; if( acmp_sta != NULL ) { acmp_pstation = acmp_sta; is_retried = is_inflight_cmds_retried( acmp_pstation ); frame = acmp_pstation->host_tx.inflight_frame.frame; frame_len = acmp_pstation->host_tx.inflight_frame.inflight_frame_len; } else { acmp_machine_debug( "noting to be proccessed by aecp timeout" ); return; } assert( frame && acmp_sta != NULL ); if( is_retried ) { struct jdksavdecc_eui64 _end_station_entity_id = jdksavdecc_acmpdu_get_listener_entity_id( frame, ZERO_OFFSET_IN_PAYLOAD ); struct jdksavdecc_eui64 _end_station_tarker_id = jdksavdecc_acmpdu_get_talker_entity_id( frame, ZERO_OFFSET_IN_PAYLOAD ); uint64_t end_station_entity_id = jdksavdecc_uint64_get( &_end_station_entity_id, 0 ); uint64_t tarker_id = jdksavdecc_uint64_get( &_end_station_tarker_id, 0 ); uint32_t msg_type = jdksavdecc_common_control_header_get_control_data( frame, 0 ); if (NULL != gp_log_imp) gp_log_imp->log.post_log_msg( &gp_log_imp->log, LOGGING_LEVEL_ERROR, " [ COMMAND TIMEOUT: 0x%016llx, %s, %s,%d ]", end_station_entity_id, acmp_cmd_value_to_name(msg_type), "NULL", acmp_pstation->host_tx.inflight_frame.seq_id); struct jdksavdecc_acmpdu node_acmpdu; jdksavdecc_acmpdu_read( &node_acmpdu, frame, ZERO_OFFSET_IN_PAYLOAD, frame_len ); subject_data_elem elem; elem.connect_flag = false; elem.listener_id = end_station_entity_id; elem.listener_index = node_acmpdu.listener_unique_id; elem.tarker_id = tarker_id; elem.tarker_index = node_acmpdu.talker_unique_id; elem.ctrl_msg.data_type = JDKSAVDECC_SUBTYPE_ACMP; elem.ctrl_msg.msg_type = msg_type; elem.ctrl_msg.msg_resp_status = -1;// -1 means timeout status. elem.data_frame = NULL;// set data frame elem.data_frame_len = 0; set_subject_data( elem, &gconnector_subjector ); notify_observer( &gconnector_subjector ); // free inflight command node in the system release_heap_space( &acmp_pstation->host_tx.inflight_frame.frame); delect_inflight_dblist_node( &acmp_pstation ); is_inflight_timeout = true; // 设置超时 acmp_machine_debug( "is_inflight_timeout = %d", is_inflight_timeout ); } else { if (NULL != gp_log_imp) gp_log_imp->log.post_log_msg( &gp_log_imp->log, LOGGING_LEVEL_DEBUG, "[ acmp Date resend ]" ); transmit_acmp_packet_network( frame, frame_len, acmp_pstation, true, acmp_pstation->host_tx.inflight_frame.raw_dest.value, false, &interval_time ); } }