void aecp_controller_state_machine::common_hdr_init(int message_type, struct jdksavdecc_frame *cmd_frame, uint64_t target_entity_id, uint32_t cd_len)
    {
        struct jdksavdecc_aecpdu_common_control_header aecpdu_common_ctrl_hdr;
        ssize_t aecpdu_common_ctrl_hdr_returned;

        /************************************** 1722 Protocol Header **************************************/
        aecpdu_common_ctrl_hdr.cd = 1;
        aecpdu_common_ctrl_hdr.subtype = JDKSAVDECC_SUBTYPE_AECP;
        aecpdu_common_ctrl_hdr.sv = 0;
        aecpdu_common_ctrl_hdr.version = 0;
        aecpdu_common_ctrl_hdr.message_type = message_type;
        aecpdu_common_ctrl_hdr.status = JDKSAVDECC_AEM_STATUS_SUCCESS;
        aecpdu_common_ctrl_hdr.control_data_length = cd_len;
        jdksavdecc_uint64_write(target_entity_id, &aecpdu_common_ctrl_hdr.target_entity_id, 0, sizeof(uint64_t));

        /********************** Fill frame payload with AECP Common Control Header information *********************/
        aecpdu_common_ctrl_hdr_returned = jdksavdecc_aecpdu_common_control_header_write(&aecpdu_common_ctrl_hdr,
                                                                                        cmd_frame->payload,
                                                                                        ETHER_HDR_SIZE, // Offset to write the field to
                                                                                        sizeof(cmd_frame->payload));

        if(aecpdu_common_ctrl_hdr_returned < 0)
        {
            log_imp_ref->post_log_msg(LOGGING_LEVEL_ERROR, "common_hdr_init error");
            assert(aecpdu_common_ctrl_hdr_returned >= 0);
        }
    }
Example #2
0
    void aecp::aecpdu_common_hdr_init(struct jdksavdecc_frame *ether_frame, uint64_t target_guid)
    {
        struct jdksavdecc_aecpdu_common_control_header aecpdu_common_ctrl_hdr;
        int aecpdu_common_ctrl_hdr_returned;
        size_t aecpdu_common_pos;

        /***** Offset to write the field to ****/
        aecpdu_common_pos = ETHER_HDR_SIZE;

        /************************************** 1722 Protocol Header **************************************/
        aecpdu_common_ctrl_hdr.cd = 1;
        aecpdu_common_ctrl_hdr.subtype = JDKSAVDECC_SUBTYPE_AECP;
        aecpdu_common_ctrl_hdr.sv = 0;
        aecpdu_common_ctrl_hdr.version = 0;
        aecpdu_common_ctrl_hdr.message_type = JDKSAVDECC_AECP_MESSAGE_TYPE_AEM_COMMAND;
        aecpdu_common_ctrl_hdr.status = JDKSAVDECC_AEM_STATUS_SUCCESS;
        aecpdu_common_ctrl_hdr.control_data_length = 20;
        jdksavdecc_uint64_write(target_guid, &aecpdu_common_ctrl_hdr.target_entity_id, 0, sizeof(uint64_t));

        /*********************** Fill frame payload with AECP Common Control Header information **********************/
        aecpdu_common_ctrl_hdr_returned = jdksavdecc_aecpdu_common_control_header_write(&aecpdu_common_ctrl_hdr,
                                                                                        ether_frame->payload,
                                                                                        aecpdu_common_pos,
                                                                                        sizeof(ether_frame->payload));

        if(aecpdu_common_ctrl_hdr_returned < 0)
        {
            log_imp_ref->post_log_msg(LOGGING_LEVEL_ERROR, "adpdu_common_ctrl_hdr_write error");
            assert(aecpdu_common_ctrl_hdr_returned >= 0);
        }
    }
    void adp_discovery_state_machine::common_hdr_init(struct jdksavdecc_frame *cmd_frame, uint64_t target_entity_id)
    {
        struct jdksavdecc_adpdu_common_control_header adpdu_common_ctrl_hdr;
        ssize_t adpdu_common_ctrl_hdr_returned;

        /********************************** 1722 Protocol Header ***********************************/
        adpdu_common_ctrl_hdr.cd = 1;
        adpdu_common_ctrl_hdr.subtype = JDKSAVDECC_SUBTYPE_ADP;
        adpdu_common_ctrl_hdr.sv = 0;
        adpdu_common_ctrl_hdr.version = 0;
        adpdu_common_ctrl_hdr.message_type = 2;
        adpdu_common_ctrl_hdr.valid_time = 0;
        adpdu_common_ctrl_hdr.control_data_length = 56;
        jdksavdecc_uint64_write(target_entity_id, &adpdu_common_ctrl_hdr.entity_id, 0, sizeof(uint64_t));

        /******************** Fill frame payload with AECP Common Control Header information ********************/
        adpdu_common_ctrl_hdr_returned = jdksavdecc_adpdu_common_control_header_write(&adpdu_common_ctrl_hdr,
                                                                                      cmd_frame->payload,
                                                                                      ETHER_HDR_SIZE,
                                                                                      sizeof(cmd_frame->payload));

        if(adpdu_common_ctrl_hdr_returned < 0)
        {
            log_imp_ref->post_log_msg(LOGGING_LEVEL_ERROR, "adpdu_common_ctrl_hdr_write error");
            assert(adpdu_common_ctrl_hdr_returned >= 0);
        }
    }
    int STDCALL stream_input_descriptor_imp::send_disconnect_rx_cmd(void *notification_id, uint64_t talker_guid, uint16_t talker_unique_id)
    {
        struct jdksavdecc_frame *cmd_frame;
        struct jdksavdecc_acmpdu acmp_cmd_disconnect_rx;
        int acmp_cmd_disconnect_rx_returned;
        uint64_t listener_guid = base_end_station_imp_ref->get_entity_desc_by_index(0)->entity_id();

        cmd_frame = (struct jdksavdecc_frame *)malloc(sizeof(struct jdksavdecc_frame));

        /******************************************* ACMP Common Data *******************************************/
        acmp_cmd_disconnect_rx.controller_entity_id = base_end_station_imp_ref->get_adp()->get_controller_guid();
        jdksavdecc_uint64_write(talker_guid, &acmp_cmd_disconnect_rx.talker_entity_id, 0, sizeof(uint64_t));
        jdksavdecc_uint64_write(listener_guid, &acmp_cmd_disconnect_rx.listener_entity_id, 0, sizeof(uint64_t));
        acmp_cmd_disconnect_rx.talker_unique_id = talker_unique_id;
        acmp_cmd_disconnect_rx.listener_unique_id = descriptor_index();
        jdksavdecc_eui48_init(&acmp_cmd_disconnect_rx.stream_dest_mac);
        acmp_cmd_disconnect_rx.connection_count = 0;
        // Fill acmp_cmd_disconnect_rx.sequence_id in AEM Controller State Machine
        acmp_cmd_disconnect_rx.flags = 0;
        acmp_cmd_disconnect_rx.stream_vlan_id = 0;

        /**************** Fill frame payload with AECP data and send the frame ***************/
        acmp_controller_state_machine_ref->ether_frame_init(cmd_frame);
        acmp_cmd_disconnect_rx_returned = jdksavdecc_acmpdu_write(&acmp_cmd_disconnect_rx,
                                                                  cmd_frame->payload,
                                                                  ETHER_HDR_SIZE,
                                                                  sizeof(cmd_frame->payload));

        if(acmp_cmd_disconnect_rx_returned < 0)
        {
            log_imp_ref->post_log_msg(LOGGING_LEVEL_ERROR, "cmd_disconnect_rx_write error\n");
            assert(acmp_cmd_disconnect_rx_returned >= 0);
            return -1;
        }

        acmp_controller_state_machine_ref->common_hdr_init(JDKSAVDECC_ACMP_MESSAGE_TYPE_DISCONNECT_RX_COMMAND, cmd_frame);
        system_queue_tx(notification_id, CMD_WITH_NOTIFICATION, cmd_frame->payload, cmd_frame->length);

        free(cmd_frame);
        return 0;
    }
void acmp_tx_state_avail( uint64_t tarker_entity_id, uint16_t tarker_unique_id )
{
	struct jdksavdecc_acmpdu acmp_cmd_get_tx_state;
	struct jdksavdecc_frame frame;
	acmp_frame_init_2( &frame );
	
        jdksavdecc_eui64_init( &acmp_cmd_get_tx_state.listener_entity_id );
        jdksavdecc_uint64_write( tarker_entity_id, &acmp_cmd_get_tx_state.talker_entity_id, 0, sizeof(uint64_t) );
        acmp_cmd_get_tx_state.talker_unique_id = tarker_unique_id;
        jdksavdecc_eui48_init(&acmp_cmd_get_tx_state.stream_dest_mac);

	acmp_form_msg( &frame, &acmp_cmd_get_tx_state,  JDKSAVDECC_ACMP_MESSAGE_TYPE_GET_TX_STATE_COMMAND, \
		acmp_sequence_id++,  acmp_cmd_get_tx_state.talker_entity_id, tarker_unique_id, acmp_cmd_get_tx_state.listener_entity_id, 0,\
		0 );
	
	system_raw_packet_tx( frame.dest_address.value, frame.payload, frame.length, RUNINFLIGHT, TRANSMIT_TYPE_ACMP, false);
}
int STDCALL stream_input_descriptor_imp::send_set_stream_format_cmd(void * notification_id, uint64_t new_stream_format)
{
    struct jdksavdecc_frame cmd_frame;
    struct jdksavdecc_aem_command_set_stream_format aem_cmd_set_stream_format;
    ssize_t aem_cmd_set_stream_format_returned;
    memset(&aem_cmd_set_stream_format, 0, sizeof(aem_cmd_set_stream_format));

    /******************************************** AECP Common Data *********************************************/
    aem_cmd_set_stream_format.aem_header.aecpdu_header.controller_entity_id = base_end_station_imp_ref->get_adp()->get_controller_entity_id();
    // Fill aem_cmd_set_stream_format.sequence_id in AEM Controller State Machine
    aem_cmd_set_stream_format.aem_header.command_type = JDKSAVDECC_AEM_COMMAND_SET_STREAM_FORMAT;

    /**************************************** AECP Message Specific Data *************************************/
    aem_cmd_set_stream_format.descriptor_type = descriptor_type();
    aem_cmd_set_stream_format.descriptor_index = descriptor_index();
    jdksavdecc_uint64_write(new_stream_format, &aem_cmd_set_stream_format.stream_format, 0, sizeof(uint64_t));

    /******************************** Fill frame payload with AECP data and send the frame ***************************/
    aecp_controller_state_machine_ref->ether_frame_init(base_end_station_imp_ref->mac(), &cmd_frame,
                                                        ETHER_HDR_SIZE + JDKSAVDECC_AEM_COMMAND_SET_STREAM_FORMAT_COMMAND_LEN);
    aem_cmd_set_stream_format_returned = jdksavdecc_aem_command_set_stream_format_write(&aem_cmd_set_stream_format,
                                                                                        cmd_frame.payload,
                                                                                        ETHER_HDR_SIZE,
                                                                                        sizeof(cmd_frame.payload));

    if (aem_cmd_set_stream_format_returned < 0)
    {
        log_imp_ref->post_log_msg(LOGGING_LEVEL_ERROR, "aem_cmd_set_stream_format_write error\n");
        assert(aem_cmd_set_stream_format_returned >= 0);
        return -1;
    }

    aecp_controller_state_machine_ref->common_hdr_init(JDKSAVDECC_AECP_MESSAGE_TYPE_AEM_COMMAND,
                                                       &cmd_frame,
                                                       base_end_station_imp_ref->entity_id(),
                                                       JDKSAVDECC_AEM_COMMAND_SET_STREAM_FORMAT_COMMAND_LEN -
                                                           JDKSAVDECC_COMMON_CONTROL_HEADER_LEN);
    system_queue_tx(notification_id, CMD_WITH_NOTIFICATION, cmd_frame.payload, cmd_frame.length);

    return 0;
}
int STDCALL stream_input_descriptor_imp::send_get_rx_state_cmd(void * notification_id)
{
    entity_descriptor_response * entity_resp_ref = base_end_station_imp_ref->get_entity_desc_by_index(0)->get_entity_response();
    struct jdksavdecc_frame cmd_frame;
    struct jdksavdecc_acmpdu acmp_cmd_get_rx_state;
    ssize_t acmp_cmd_get_rx_state_returned;
    uint64_t listener_entity_id = entity_resp_ref->entity_id();

    /******************************************* ACMP Common Data ******************************************/
    acmp_cmd_get_rx_state.controller_entity_id = base_end_station_imp_ref->get_adp()->get_controller_entity_id();
    jdksavdecc_eui64_init(&acmp_cmd_get_rx_state.talker_entity_id);
    jdksavdecc_uint64_write(listener_entity_id, &acmp_cmd_get_rx_state.listener_entity_id, 0, sizeof(uint64_t));
    acmp_cmd_get_rx_state.talker_unique_id = 0;
    acmp_cmd_get_rx_state.listener_unique_id = descriptor_index();
    jdksavdecc_eui48_init(&acmp_cmd_get_rx_state.stream_dest_mac);
    acmp_cmd_get_rx_state.connection_count = 0;
    // Fill acmp_cmd_get_rx_state.sequence_id in AEM Controller State Machine
    acmp_cmd_get_rx_state.flags = 0;
    acmp_cmd_get_rx_state.stream_vlan_id = 0;

    /*************** Fill frame payload with AECP data and send the frame ***************/
    acmp_controller_state_machine_ref->ether_frame_init(&cmd_frame);
    acmp_cmd_get_rx_state_returned = jdksavdecc_acmpdu_write(&acmp_cmd_get_rx_state,
                                                             cmd_frame.payload,
                                                             ETHER_HDR_SIZE,
                                                             sizeof(cmd_frame.payload));

    if (acmp_cmd_get_rx_state_returned < 0)
    {
        log_imp_ref->post_log_msg(LOGGING_LEVEL_ERROR, "cmd_get_rx_state_write error\n");
        assert(acmp_cmd_get_rx_state_returned >= 0);
        return -1;
    }

    acmp_controller_state_machine_ref->common_hdr_init(JDKSAVDECC_ACMP_MESSAGE_TYPE_GET_RX_STATE_COMMAND, &cmd_frame);
    system_queue_tx(notification_id, CMD_WITH_NOTIFICATION, cmd_frame.payload, cmd_frame.length);

    delete entity_resp_ref;
    return 0;
}