diff --git a/docs/spec/blocks/datastream_payload.adoc b/docs/spec/blocks/datastream_payload.adoc index c8767c1..2cc138c 100644 --- a/docs/spec/blocks/datastream_payload.adoc +++ b/docs/spec/blocks/datastream_payload.adoc @@ -19,6 +19,7 @@ For other data types, the payload layout is specific to the data type. typedef struct DataStreamPayloadHeader { uint32_t identifier; ///< Block identifier, must be BlockType::DataStreamPayloadBlock (0x4C505344). + uint16_t dataType; ///< Data type classification (value from DataType), e.g., FluxData or BitstreamData. uint16_t compression; ///< Compression type (0 = None, 1 = Lzma). uint32_t cmpLength; ///< Compressed length in bytes (includes LZMA properties if compressed). uint32_t length; ///< Uncompressed length in bytes. @@ -40,6 +41,11 @@ typedef struct DataStreamPayloadHeader |identifier |The data stream payload block identifier, always `DSPL` (`0x4C505344`) +|uint16_t +|2 bytes +|dataType +|The data type contained in this block (value from DataType), e.g., FluxData or BitstreamData. See Annex B. + |uint16_t |2 bytes |compression diff --git a/include/aaruformat/structs/flux.h b/include/aaruformat/structs/flux.h index 61befd9..f8f8f08 100644 --- a/include/aaruformat/structs/flux.h +++ b/include/aaruformat/structs/flux.h @@ -201,6 +201,12 @@ typedef struct FluxCaptureMapEntry FluxCaptureMapEntry; * may be compressed using LZMA compression. Currently used for flux capture data, but * can be used for other data streams such as bitstreams or PNG data. * + * **Data Type:** + * The dataType field identifies the type of data stored in the payload. Common values include: + * - FluxData: Flux capture data (data and index buffers) + * - BitstreamData: Bitstream data + * This field enables the block to be self-describing and allows validation of the payload content. + * * **Compression:** * The compression field indicates whether the payload is compressed: * - 0 (None): Payload is stored uncompressed @@ -226,6 +232,7 @@ typedef struct FluxCaptureMapEntry FluxCaptureMapEntry; typedef struct DataStreamPayloadHeader { uint32_t identifier; ///< Block identifier, must be BlockType::DataStreamPayloadBlock (0x4C505344, "DSPL"). + uint16_t dataType; ///< Data type classification (value from \ref DataType), e.g., FluxData or BitstreamData. uint16_t compression; ///< Compression type: 0 = None, 1 = Lzma. uint32_t cmpLength; ///< Compressed length in bytes (includes LZMA properties if compression = Lzma). uint32_t length; ///< Uncompressed length in bytes. diff --git a/src/blocks/flux.c b/src/blocks/flux.c index 7a7bfec..23470db 100644 --- a/src/blocks/flux.c +++ b/src/blocks/flux.c @@ -832,6 +832,14 @@ static int32_t read_flux_payload_header(const aaruformat_context *ctx, uint64_t return AARUF_ERROR_CANNOT_READ_BLOCK; } + if(header->dataType != FluxData) + { + FATAL("Incorrect data type %u for flux payload at offset %" PRIu64 " (expected FluxData)", header->dataType, + payload_offset); + TRACE("Exiting read_flux_payload_header() = AARUF_ERROR_CANNOT_READ_BLOCK\n"); + return AARUF_ERROR_CANNOT_READ_BLOCK; + } + return AARUF_STATUS_OK; } diff --git a/src/close.c b/src/close.c index 958662a..5d15f30 100644 --- a/src/close.c +++ b/src/close.c @@ -4468,6 +4468,7 @@ static int32_t write_flux_capture_payload(aaruformat_context *ctx, FluxCaptureRe DataStreamPayloadHeader payload_header = {0}; payload_header.identifier = DataStreamPayloadBlock; + payload_header.dataType = FluxData; payload_header.compression = (uint16_t)compression; payload_header.cmpLength = cmp_length; payload_header.length = (uint32_t)raw_length; diff --git a/templates/aaruformat.hexpat b/templates/aaruformat.hexpat index f59fe65..adffe1d 100644 --- a/templates/aaruformat.hexpat +++ b/templates/aaruformat.hexpat @@ -1164,6 +1164,7 @@ struct FluxDataBlock struct DataStreamPayloadHeader { BlockType identifier; + u16 dataType; u16 compression; u32 cmpLength; u32 length;