void jdksavdecc_aecp_common_print(struct jdksavdecc_printer *self,
                                  struct jdksavdecc_aecpdu_common const *p) {
    jdksavdecc_aecp_common_control_header_print(self,&p->header);
    jdksavdecc_printer_print_label(self,"controller_entity_id");
    jdksavdecc_printer_print_eui64(self,p->controller_entity_id);
    jdksavdecc_printer_print_eol(self);

    jdksavdecc_printer_print_label(self, "sequence_id");
    jdksavdecc_printer_print_uint16(self, p->sequence_id);
    jdksavdecc_printer_print_eol(self);
}
Ejemplo n.º 2
0
void avdecc_cmd_print_frame_header( struct jdksavdecc_printer *self, const struct jdksavdecc_frame *frame )
{
    jdksavdecc_printer_print_label( self, "DA" );
    jdksavdecc_printer_print_eui48( self, frame->dest_address );
    jdksavdecc_printer_print_eol( self );
    jdksavdecc_printer_print_label( self, "SA" );
    jdksavdecc_printer_print_eui48( self, frame->src_address );
    jdksavdecc_printer_print_eol( self );
    jdksavdecc_printer_print_label( self, "EtherType" );
    jdksavdecc_printer_print_uint16( self, frame->ethertype );
    jdksavdecc_printer_print_eol( self );
    jdksavdecc_printer_print_label( self, "Payload Length" );
    jdksavdecc_printer_print_uint16( self, frame->length );
    jdksavdecc_printer_print_eol( self );
}
void jdksavdecc_aecp_common_control_header_print(struct jdksavdecc_printer *self,
                                                 struct jdksavdecc_aecpdu_common_control_header const *p) {
    struct jdksavdecc_uint16_name *status_name_table=jdksavdecc_aecp_print_status;
    jdksavdecc_printer_print_label(self, "message_type");
    jdksavdecc_printer_print_uint16_name(self, jdksavdecc_aecp_print_message_type, p->message_type);
    jdksavdecc_printer_print_eol(self);

    jdksavdecc_printer_print_label(self, "status");
    switch( p->message_type ) {
    case JDKSAVDECC_AECP_MESSAGE_TYPE_AEM_COMMAND:
    case JDKSAVDECC_AECP_MESSAGE_TYPE_AEM_RESPONSE:
        status_name_table = jdksavdecc_aecp_aem_print_status;
        break;
    case JDKSAVDECC_AECP_MESSAGE_TYPE_ADDRESS_ACCESS_COMMAND:
    case JDKSAVDECC_AECP_MESSAGE_TYPE_ADDRESS_ACCESS_RESPONSE:
        status_name_table = jdksavdecc_aecp_aa_print_status;
        break;
    case JDKSAVDECC_AECP_MESSAGE_TYPE_AVC_COMMAND:
    case JDKSAVDECC_AECP_MESSAGE_TYPE_AVC_RESPONSE:
        status_name_table = jdksavdecc_aecp_avc_print_status;
        break;
    case JDKSAVDECC_AECP_MESSAGE_TYPE_HDCP_APM_COMMAND:
    case JDKSAVDECC_AECP_MESSAGE_TYPE_HDCP_APM_RESPONSE:
        status_name_table = jdksavdecc_aecp_hdcp_apm_print_status;
        break;
    case JDKSAVDECC_AECP_MESSAGE_TYPE_VENDOR_UNIQUE_COMMAND:
    case JDKSAVDECC_AECP_MESSAGE_TYPE_VENDOR_UNIQUE_RESPONSE:
        status_name_table = jdksavdecc_aecp_vendor_print_status;
        break;
    case JDKSAVDECC_AECP_MESSAGE_TYPE_EXTENDED_COMMAND:
    case JDKSAVDECC_AECP_MESSAGE_TYPE_EXTENDED_RESPONSE:
        status_name_table = jdksavdecc_aecp_print_status;
        break;
    default:
        status_name_table = jdksavdecc_aecp_print_status;
        break;
    }
    jdksavdecc_printer_print_uint16_name(self,status_name_table,p->status);
    jdksavdecc_printer_print_eol(self);

    jdksavdecc_printer_print_label(self, "control_data_length");
    jdksavdecc_printer_print_uint16(self, p->control_data_length);
    jdksavdecc_printer_print_eol(self);

    jdksavdecc_printer_print_label(self, "target_entity_id");
    jdksavdecc_printer_print_eui64(self, p->target_entity_id);
    jdksavdecc_printer_print_eol(self);
}
void jdksavdecc_adpdu_print_common_control_header(struct jdksavdecc_printer *self,
                                                  struct jdksavdecc_adpdu_common_control_header const *p) {
    jdksavdecc_printer_print_label(self, "message_type");
    jdksavdecc_printer_print_uint16_name(self, jdksavdecc_adpdu_print_message_type, p->message_type);
    jdksavdecc_printer_print_eol(self);

    jdksavdecc_printer_print_label(self, "valid_time (seconds)");
    jdksavdecc_printer_print_uint16(self, p->valid_time * 2);
    jdksavdecc_printer_print_eol(self);

    jdksavdecc_printer_print_label(self, "control_data_length");
    jdksavdecc_printer_print_uint16(self, p->control_data_length);
    jdksavdecc_printer_print_eol(self);

    jdksavdecc_printer_print_label(self, "entity_id");
    jdksavdecc_printer_print_eui64(self, p->entity_id);
    jdksavdecc_printer_print_eol(self);
}
Ejemplo n.º 5
0
void jdksavdecc_printer_print_block(
    struct jdksavdecc_printer *self, const uint8_t *p, size_t sz, size_t start_pos, size_t end_pos )
{
    size_t pos;
    for ( pos = start_pos; pos < end_pos && pos < sz; ++pos )
    {
        jdksavdecc_printer_print_hexdigits( self, p[pos] );
        jdksavdecc_printer_printc( self, ' ' );
    }
    jdksavdecc_printer_print_eol( self );
}
void jdksavdecc_frame_print(struct jdksavdecc_printer *self, struct jdksavdecc_frame const *p, int dump_payload) {
    jdksavdecc_printer_print_label(self, "time (seconds)");

    jdksavdecc_printer_print_uint64(self, p->time / 1000000);
    jdksavdecc_printer_printc(self, '.');
    jdksavdecc_printer_print_uint64(self, p->time % 1000000);
    jdksavdecc_printer_print_eol(self);

    jdksavdecc_printer_print_label(self, "dest_address");
    jdksavdecc_printer_print_eui48(self, p->dest_address);
    jdksavdecc_printer_print_eol(self);

    jdksavdecc_printer_print_label(self, "src_address");
    jdksavdecc_printer_print_eui48(self, p->src_address);
    jdksavdecc_printer_print_eol(self);

    jdksavdecc_printer_print_label(self, "ethertype");
    jdksavdecc_printer_print_uint16(self, p->ethertype);
    jdksavdecc_printer_print_eol(self);

    jdksavdecc_printer_print_label(self, "tpid");
    jdksavdecc_printer_print_uint16(self, p->tpid);
    jdksavdecc_printer_print_eol(self);

    jdksavdecc_printer_print_label(self, "pcp");
    jdksavdecc_printer_print_uint16(self, p->pcp);
    jdksavdecc_printer_print_eol(self);

    jdksavdecc_printer_print_label(self, "dei");
    jdksavdecc_printer_print_uint16(self, p->dei);
    jdksavdecc_printer_print_eol(self);

    jdksavdecc_printer_print_label(self, "vid");
    jdksavdecc_printer_print_uint16(self, p->vid);
    jdksavdecc_printer_print_eol(self);

    jdksavdecc_printer_print_label(self, "length");
    jdksavdecc_printer_print_uint16(self, p->length);
    jdksavdecc_printer_print_eol(self);

    if (dump_payload) {
        jdksavdecc_printer_print_label(self, "payload");
        jdksavdecc_printer_print_block(self, p->payload, p->length, 0, p->length);
    }
}
Ejemplo n.º 7
0
void jdksavdecc_pdu_print( struct jdksavdecc_printer *self, const uint8_t *p, size_t len, int dump_payload )
{
    if ( len > 12 )
    {
        int cd = jdksavdecc_common_control_header_get_cd( p, 0 );
        uint8_t version = (uint8_t)jdksavdecc_common_control_header_get_version( p, 0 );

        jdksavdecc_printer_print_label( self, "version" );
        jdksavdecc_printer_print_uint8( self, version );
        jdksavdecc_printer_print_eol( self );

        jdksavdecc_printer_print_label( self, "cd and subtype" );
        jdksavdecc_printer_print_uint16_name( self, jdksavdecc_pdu_print_cd_subtype, p[0] );
        jdksavdecc_printer_print_eol( self );

        if ( version == 0 )
        {
            jdksavdecc_printer_print_label( self, "sv" );
            if ( jdksavdecc_common_control_header_get_sv( p, 0 ) )
            {
                jdksavdecc_printer_print( self, "valid" );
            }
            else
            {
                jdksavdecc_printer_print( self, "not valid" );
            }
            jdksavdecc_printer_print_eol( self );

            if ( cd == 0 ) // version 0 stream data
            {
                jdksavdecc_printer_print_label( self, "mr" );
                jdksavdecc_printer_print_uint8( self, (uint8_t)jdksavdecc_common_stream_header_get_mr( p, 0 ) );
                jdksavdecc_printer_print_eol( self );

                jdksavdecc_printer_print_label( self, "gv" );
                jdksavdecc_printer_print_uint8( self, (uint8_t)jdksavdecc_common_stream_header_get_gv( p, 0 ) );
                jdksavdecc_printer_print_eol( self );

                jdksavdecc_printer_print_label( self, "tv" );
                jdksavdecc_printer_print_uint8( self, (uint8_t)jdksavdecc_common_stream_header_get_tv( p, 0 ) );
                jdksavdecc_printer_print_eol( self );

                jdksavdecc_printer_print_label( self, "sequence_num" );
                jdksavdecc_printer_print_uint8( self, (uint8_t)jdksavdecc_common_stream_header_get_sequence_num( p, 0 ) );
                jdksavdecc_printer_print_eol( self );

                jdksavdecc_printer_print_label( self, "tu" );
                jdksavdecc_printer_print_uint8( self, (uint8_t)jdksavdecc_common_stream_header_get_tu( p, 0 ) );
                jdksavdecc_printer_print_eol( self );

                jdksavdecc_printer_print_label( self, "stream_id" );
                jdksavdecc_printer_print_streamid( self, jdksavdecc_common_stream_header_get_stream_id( p, 0 ) );
                jdksavdecc_printer_print_eol( self );

                jdksavdecc_printer_print_label( self, "avtp_timestamp" );
                jdksavdecc_printer_print_uint32( self, jdksavdecc_common_stream_header_get_avtp_timestamp( p, 0 ) );
                jdksavdecc_printer_print_eol( self );

                jdksavdecc_printer_print_label( self, "gateway_info" );
                jdksavdecc_printer_print_uint32( self, jdksavdecc_common_stream_header_get_gateway_info( p, 0 ) );
                jdksavdecc_printer_print_eol( self );

                jdksavdecc_printer_print_label( self, "stream_data_length" );
                jdksavdecc_printer_print_uint16( self, jdksavdecc_common_stream_header_get_stream_data_length( p, 0 ) );
                jdksavdecc_printer_print_eol( self );

                jdksavdecc_printer_print_label( self, "protocol_specific_header" );
                jdksavdecc_printer_print_uint16( self, jdksavdecc_common_stream_header_get_protocol_specific_header( p, 0 ) );
                jdksavdecc_printer_print_eol( self );

                if ( dump_payload && len > JDKSAVDECC_COMMON_STREAM_HEADER_LEN )
                {
                    jdksavdecc_printer_print_label( self, "stream_data_payload" );
                    jdksavdecc_printer_print_block( self, p, len, JDKSAVDECC_COMMON_STREAM_HEADER_LEN, len );
                }
            }
            else // version 0 control data
            {
                jdksavdecc_printer_print_label( self, "control_data" );
                jdksavdecc_printer_print_uint8( self, (uint8_t)jdksavdecc_common_control_header_get_control_data( p, 0 ) );
                jdksavdecc_printer_print_eol( self );

                jdksavdecc_printer_print_label( self, "status" );
                jdksavdecc_printer_print_uint8( self, (uint8_t)jdksavdecc_common_control_header_get_status( p, 0 ) );
                jdksavdecc_printer_print_eol( self );

                jdksavdecc_printer_print_label( self, "control_data_length" );
                jdksavdecc_printer_print_uint16( self,
                                                 (uint16_t)jdksavdecc_common_control_header_get_control_data_length( p, 0 ) );
                jdksavdecc_printer_print_eol( self );

                jdksavdecc_printer_print_label( self, "stream_id" );
                jdksavdecc_printer_print_streamid( self, jdksavdecc_common_control_header_get_stream_id( p, 0 ) );
                jdksavdecc_printer_print_eol( self );
            }

            if ( dump_payload && len > JDKSAVDECC_COMMON_CONTROL_HEADER_LEN )
            {
                jdksavdecc_printer_print_label( self, "payload" );
                jdksavdecc_printer_print_block( self, p, len, JDKSAVDECC_COMMON_CONTROL_HEADER_LEN, len );
            }
        }
    }
}
void jdksavdecc_aecp_print(struct jdksavdecc_printer *self,
                           struct jdksavdecc_aecpdu_common const *msg,
                           void const *p,
                           ssize_t pos,
                           size_t len) {
    jdksavdecc_aecp_common_print(self,msg);
    switch( msg->header.message_type ) {
    // Todo: put more detail into printing of non-aem messages
    case JDKSAVDECC_AECP_MESSAGE_TYPE_AEM_COMMAND:
    {
        struct jdksavdecc_aecpdu_aem aem;
        if( jdksavdecc_aecpdu_aem_read(&aem,p,pos,len) > 0 ) {
            jdksavdecc_aem_command_print(self,&aem,p,pos,len);
        }
        break;
    }
    case JDKSAVDECC_AECP_MESSAGE_TYPE_AEM_RESPONSE:
    {
        struct jdksavdecc_aecpdu_aem aem;
        if( jdksavdecc_aecpdu_aem_read(&aem,p,pos,len) > 0 ) {
            jdksavdecc_aem_response_print(self,&aem,p,pos,len);
        }
        break;
    }
    case JDKSAVDECC_AECP_MESSAGE_TYPE_ADDRESS_ACCESS_COMMAND:
    case JDKSAVDECC_AECP_MESSAGE_TYPE_ADDRESS_ACCESS_RESPONSE:
        jdksavdecc_aecp_common_print(self,msg);
        jdksavdecc_printer_print_label(self,"tlv_count");
        jdksavdecc_printer_print_uint16(self,jdksavdecc_aecp_aa_get_tlv_count(p,pos));
        jdksavdecc_printer_print_eol(self);
        jdksavdecc_printer_print_label(self,"payload");
        jdksavdecc_printer_print_block(self,p,len,pos+JDKSAVDECC_AECPDU_AA_LEN,pos+msg->header.control_data_length-(JDKSAVDECC_AECPDU_AA_LEN -JDKSAVDECC_COMMON_CONTROL_HEADER_LEN) );
        jdksavdecc_printer_print_eol(self);
        break;
    case JDKSAVDECC_AECP_MESSAGE_TYPE_AVC_COMMAND:
    case JDKSAVDECC_AECP_MESSAGE_TYPE_AVC_RESPONSE:
        jdksavdecc_aecp_common_print(self,msg);
        jdksavdecc_printer_print_label(self,"payload");
        jdksavdecc_printer_print_block(self,p,len,pos+JDKSAVDECC_AECPDU_COMMON_LEN,pos+msg->header.control_data_length-(JDKSAVDECC_AECPDU_COMMON_LEN -JDKSAVDECC_COMMON_CONTROL_HEADER_LEN) );
        jdksavdecc_printer_print_eol(self);
        break;
    case JDKSAVDECC_AECP_MESSAGE_TYPE_HDCP_APM_COMMAND:
    case JDKSAVDECC_AECP_MESSAGE_TYPE_HDCP_APM_RESPONSE:
        jdksavdecc_aecp_common_print(self,msg);
        jdksavdecc_printer_print_label(self,"payload");
        jdksavdecc_printer_print_block(self,p,len,pos+JDKSAVDECC_AECPDU_COMMON_LEN,pos+msg->header.control_data_length-(JDKSAVDECC_AECPDU_COMMON_LEN -JDKSAVDECC_COMMON_CONTROL_HEADER_LEN) );
        jdksavdecc_printer_print_eol(self);
        break;
    case JDKSAVDECC_AECP_MESSAGE_TYPE_VENDOR_UNIQUE_COMMAND:
    case JDKSAVDECC_AECP_MESSAGE_TYPE_VENDOR_UNIQUE_RESPONSE:
        jdksavdecc_aecp_common_print(self,msg);
        jdksavdecc_printer_print_label(self,"payload");
        jdksavdecc_printer_print_block(self,p,len,pos+JDKSAVDECC_AECPDU_COMMON_LEN,pos+msg->header.control_data_length-(JDKSAVDECC_AECPDU_COMMON_LEN -JDKSAVDECC_COMMON_CONTROL_HEADER_LEN) );
        jdksavdecc_printer_print_eol(self);
        break;
    case JDKSAVDECC_AECP_MESSAGE_TYPE_EXTENDED_COMMAND:
    case JDKSAVDECC_AECP_MESSAGE_TYPE_EXTENDED_RESPONSE:
        jdksavdecc_aecp_common_print(self,msg);
        jdksavdecc_printer_print_label(self,"payload");
        jdksavdecc_printer_print_block(self,p,len,pos+JDKSAVDECC_AECPDU_COMMON_LEN,pos+msg->header.control_data_length-(JDKSAVDECC_AECPDU_COMMON_LEN -JDKSAVDECC_COMMON_CONTROL_HEADER_LEN) );
        jdksavdecc_printer_print_eol(self);
        break;
    default:
        jdksavdecc_aecp_common_print(self,msg);
        jdksavdecc_printer_print_label(self,"payload");
        jdksavdecc_printer_print_block(self,p,len,pos+JDKSAVDECC_AECPDU_COMMON_LEN,pos+msg->header.control_data_length-(JDKSAVDECC_AECPDU_COMMON_LEN -JDKSAVDECC_COMMON_CONTROL_HEADER_LEN) );
        jdksavdecc_printer_print_eol(self);
        break;
    }
}
void jdksavdecc_adpdu_print(struct jdksavdecc_printer *self, struct jdksavdecc_adpdu const *p) {
    jdksavdecc_adpdu_print_common_control_header(self, &p->header);

    if (p->header.message_type != JDKSAVDECC_ADP_MESSAGE_TYPE_ENTITY_DISCOVER) {
        if (p->header.message_type != JDKSAVDECC_ADP_MESSAGE_TYPE_ENTITY_DEPARTING) {
            jdksavdecc_printer_print_label(self, "available_index");
            jdksavdecc_printer_print_uint32(self, p->available_index);
            jdksavdecc_printer_print_eol(self);
        }

        jdksavdecc_printer_print_label(self, "entity_model_id");
        jdksavdecc_printer_print_eui64(self, p->entity_model_id);
        jdksavdecc_printer_print_eol(self);

        jdksavdecc_printer_print_label(self, "entity_capabilities");
        jdksavdecc_printer_print_32bit_names(self, jdksavdecc_adpdu_print_entity_capabilities, p->entity_capabilities);
        jdksavdecc_printer_print_eol(self);

        if (p->talker_stream_sources > 0 && (p->talker_capabilities & JDKSAVDECC_ADP_TALKER_CAPABILITY_IMPLEMENTED) != 0) {
            jdksavdecc_printer_print_label(self, "talker_stream_sources");
            jdksavdecc_printer_print_uint16(self, p->talker_stream_sources);
            jdksavdecc_printer_print_eol(self);

            jdksavdecc_printer_print_label(self, "talker_capabilities");
            jdksavdecc_printer_print_16bit_names(self, jdksavdecc_adpdu_print_talker_capabilities, p->talker_capabilities);
            jdksavdecc_printer_print_eol(self);
        }

        if (p->listener_stream_sinks > 0) {
            jdksavdecc_printer_print_label(self, "listener_stream_sinks");
            jdksavdecc_printer_print_uint16(self, p->listener_stream_sinks);
            jdksavdecc_printer_print_eol(self);

            jdksavdecc_printer_print_label(self, "listener_capabilities");
            jdksavdecc_printer_print_16bit_names(self, jdksavdecc_adpdu_print_listener_capabilities, p->listener_capabilities);
            jdksavdecc_printer_print_eol(self);
        }

        if ((p->controller_capabilities & JDKSAVDECC_ADP_CONTROLLER_CAPABILITY_IMPLEMENTED) != 0) {
            jdksavdecc_printer_print_label(self, "controller_capabilities");
            jdksavdecc_printer_print_32bit_names(
                self, jdksavdecc_adpdu_print_controller_capabilities, p->controller_capabilities);
            jdksavdecc_printer_print_eol(self);
        }

        if ((p->entity_capabilities & JDKSAVDECC_ADP_ENTITY_CAPABILITY_GPTP_SUPPORTED) != 0) {
            jdksavdecc_printer_print_label(self, "gptp_grandmaster_id");
            jdksavdecc_printer_print_eui64(self, p->gptp_grandmaster_id);
            jdksavdecc_printer_print_eol(self);

            jdksavdecc_printer_print_label(self, "gptp_domain_number");
            jdksavdecc_printer_print_uint16(self, p->gptp_domain_number);
            jdksavdecc_printer_print_eol(self);
        }

        if ((p->entity_capabilities & JDKSAVDECC_ADP_ENTITY_CAPABILITY_AEM_IDENTIFY_CONTROL_INDEX_VALID) != 0) {
            jdksavdecc_printer_print_label(self, "identify_control_index");
            jdksavdecc_printer_print_uint16(self, p->identify_control_index);
            jdksavdecc_printer_print_eol(self);
        }

        if ((p->entity_capabilities & JDKSAVDECC_ADP_ENTITY_CAPABILITY_AEM_INTERFACE_INDEX_VALID) != 0) {
            jdksavdecc_printer_print_label(self, "interface_index");
            jdksavdecc_printer_print_uint16(self, p->interface_index);
            jdksavdecc_printer_print_eol(self);
        }

        if ((p->entity_capabilities & JDKSAVDECC_ADP_ENTITY_CAPABILITY_ASSOCIATION_ID_VALID) != 0) {
            jdksavdecc_printer_print_label(self, "association_id");
            jdksavdecc_printer_print_eui64(self, p->association_id);
            jdksavdecc_printer_print_eol(self);
        }
    }
}