ssize_t jdksavdecc_common_control_header_write( struct jdksavdecc_common_control_header const *p, void *base, ssize_t pos, size_t len ) { ssize_t r = jdksavdecc_validate_range( pos, len, JDKSAVDECC_COMMON_CONTROL_HEADER_LEN ); if ( r >= 0 ) { jdksavdecc_common_control_header_set_cd( p->cd, base, pos ); jdksavdecc_common_control_header_set_subtype( (uint8_t)p->subtype, base, pos ); jdksavdecc_common_control_header_set_sv( (bool)p->sv, base, pos); jdksavdecc_common_control_header_set_version( (uint8_t)p->version, base, pos); jdksavdecc_common_control_header_set_control_data ((uint8_t)p->control_data, base, pos); jdksavdecc_common_control_header_set_status( (uint8_t)p->status, base, pos); jdksavdecc_common_control_header_set_control_data_length( (uint16_t)p->control_data_length, base, pos); jdksavdecc_common_control_header_set_stream_id( p->stream_id, base, pos ); } return r; }
int send_controller_avail_response(const uint8_t *frame, size_t frame_len, const uint8_t dst_mac[6], const uint8_t src_mac[6] ) { int send_frame_returned = 0; size_t pos = 0; uint8_t ether_type[2] = {0x22, 0xf0}; uint8_t * tx_frame = (uint8_t*)malloc( frame_len + ETHER_HDR_SIZE ); if ( tx_frame == NULL ) { if (NULL != gp_log_imp) gp_log_imp->log.post_log_msg( &gp_log_imp->log, LOGGING_LEVEL_ERROR, "unable to allocate response frame"); return -1; } memcpy( tx_frame, dst_mac, DEST_MAC_SIZE ); memcpy( tx_frame + DEST_MAC_SIZE, src_mac, SRC_MAC_SIZE); memcpy( tx_frame + DEST_MAC_SIZE + SRC_MAC_SIZE, ether_type, ETHER_PROTOCOL_SIZE); memcpy( tx_frame + ETHER_HDR_SIZE, frame, frame_len ); jdksavdecc_common_control_header_set_control_data( JDKSAVDECC_AECP_MESSAGE_TYPE_AEM_RESPONSE, tx_frame, pos + ETHER_HDR_SIZE ); send_frame_returned = controller_machine_1722_network_send(gp_controller_machine, tx_frame, (int)(frame_len + ETHER_HDR_SIZE)); if(send_frame_returned < 0) { if (NULL != gp_log_imp) gp_log_imp->log.post_log_msg( &gp_log_imp->log, LOGGING_LEVEL_ERROR, "LOGGING_LEVEL_ERROR: netif_send_frame error"); assert(send_frame_returned >= 0); } release_heap_space( &tx_frame ); return 0; }