|
PACS System 0.1.0
PACS DICOM system library
|
Decoder for DICOM PDU (Protocol Data Unit) messages. More...
#include <pdu_decoder.h>

Static Public Member Functions | |
General Decoding | |
| static DecodeResult< pdu > | decode (std::span< const uint8_t > data) |
| Decode any PDU from bytes. | |
| static std::optional< size_t > | pdu_length (std::span< const uint8_t > data) |
| Check if a complete PDU is available in the buffer. | |
| static std::optional< pdu_type > | peek_pdu_type (std::span< const uint8_t > data) |
| Get the PDU type from buffer without full decoding. | |
Specific Decoders | |
| static DecodeResult< associate_rq > | decode_associate_rq (std::span< const uint8_t > data) |
| Decode an A-ASSOCIATE-RQ PDU. | |
| static DecodeResult< associate_ac > | decode_associate_ac (std::span< const uint8_t > data) |
| Decode an A-ASSOCIATE-AC PDU. | |
| static DecodeResult< associate_rj > | decode_associate_rj (std::span< const uint8_t > data) |
| Decode an A-ASSOCIATE-RJ PDU. | |
| static DecodeResult< p_data_tf_pdu > | decode_p_data_tf (std::span< const uint8_t > data) |
| Decode a P-DATA-TF PDU. | |
| static DecodeResult< release_rq_pdu > | decode_release_rq (std::span< const uint8_t > data) |
| Decode an A-RELEASE-RQ PDU. | |
| static DecodeResult< release_rp_pdu > | decode_release_rp (std::span< const uint8_t > data) |
| Decode an A-RELEASE-RP PDU. | |
| static DecodeResult< abort_pdu > | decode_abort (std::span< const uint8_t > data) |
| Decode an A-ABORT PDU. | |
Static Private Member Functions | |
Helper Functions | |
| static uint16_t | read_uint16_be (std::span< const uint8_t > data, size_t offset) |
| Read a 16-bit unsigned integer in big-endian format. | |
| static uint32_t | read_uint32_be (std::span< const uint8_t > data, size_t offset) |
| Read a 32-bit unsigned integer in big-endian format. | |
| static std::string | read_ae_title (std::span< const uint8_t > data, size_t offset) |
| Read an AE Title (16 bytes, space-trimmed). | |
| static std::string | read_uid (std::span< const uint8_t > data, size_t offset, size_t length) |
| Read a UID string (trim trailing null/space padding). | |
| static DecodeResult< uint32_t > | validate_pdu_header (std::span< const uint8_t > data, uint8_t expected_type=0) |
| Validate PDU header and extract length. | |
| static DecodeResult< std::tuple< std::string, std::vector< presentation_context_rq >, std::vector< presentation_context_ac >, user_information > > | decode_variable_items (std::span< const uint8_t > data, bool is_rq) |
| Decode variable items from ASSOCIATE-RQ/AC PDUs. | |
| static DecodeResult< user_information > | decode_user_info_item (std::span< const uint8_t > data) |
| Decode User Information sub-items. | |
Decoder for DICOM PDU (Protocol Data Unit) messages.
This class provides static methods to decode various PDU types according to DICOM PS3.8 Upper Layer Protocol.
PDU Structure:
Definition at line 127 of file pdu_decoder.h.
|
staticnodiscard |
Decode any PDU from bytes.
| data | Input byte buffer |
Automatically detects PDU type from the first byte and dispatches to the appropriate specific decoder.
Definition at line 172 of file pdu_decoder.cpp.
References decode_abort(), decode_associate_ac(), decode_associate_rj(), decode_associate_rq(), decode_p_data_tf(), decode_release_rp(), decode_release_rq(), kcenon::pacs::network::incomplete_header, and kcenon::pacs::network::invalid_pdu_type.

|
staticnodiscard |
Decode an A-ABORT PDU.
| data | Input byte buffer |
Definition at line 294 of file pdu_decoder.cpp.
References kcenon::pacs::network::abort, kcenon::pacs::network::incomplete_pdu, kcenon::pacs::network::abort_pdu::source, and validate_pdu_header().
Referenced by decode().


|
staticnodiscard |
Decode an A-ASSOCIATE-AC PDU.
| data | Input byte buffer |
Definition at line 626 of file pdu_decoder.cpp.
References kcenon::pacs::network::associate_ac::application_context, kcenon::pacs::network::associate_ac::called_ae_title, kcenon::pacs::network::associate_ac::calling_ae_title, decode_variable_items(), kcenon::pacs::network::DICOM_PROTOCOL_VERSION, kcenon::pacs::network::invalid_protocol_version, kcenon::pacs::network::malformed_pdu, pdu_length(), kcenon::pacs::network::associate_ac::presentation_contexts, read_ae_title(), read_uint16_be(), kcenon::pacs::network::associate_ac::user_info, and validate_pdu_header().
Referenced by decode().


|
staticnodiscard |
Decode an A-ASSOCIATE-RJ PDU.
| data | Input byte buffer |
Definition at line 239 of file pdu_decoder.cpp.
References kcenon::pacs::network::incomplete_pdu, kcenon::pacs::network::associate_rj::reason, kcenon::pacs::network::associate_rj::result, kcenon::pacs::network::associate_rj::source, and validate_pdu_header().
Referenced by decode().


|
staticnodiscard |
Decode an A-ASSOCIATE-RQ PDU.
| data | Input byte buffer |
Definition at line 570 of file pdu_decoder.cpp.
References kcenon::pacs::network::associate_rq::application_context, kcenon::pacs::network::associate_rq::called_ae_title, kcenon::pacs::network::associate_rq::calling_ae_title, decode_variable_items(), kcenon::pacs::network::DICOM_PROTOCOL_VERSION, kcenon::pacs::network::invalid_protocol_version, kcenon::pacs::network::malformed_pdu, pdu_length(), kcenon::pacs::network::associate_rq::presentation_contexts, read_ae_title(), read_uint16_be(), kcenon::pacs::network::associate_rq::user_info, and validate_pdu_header().
Referenced by decode(), and kcenon::pacs::network::v2::dicom_association_handler::handle_associate_rq().


|
staticnodiscard |
Decode a P-DATA-TF PDU.
| data | Input byte buffer |
Definition at line 315 of file pdu_decoder.cpp.
References kcenon::pacs::network::buffer_overflow, kcenon::pacs::network::presentation_data_value::context_id, kcenon::pacs::network::presentation_data_value::data, kcenon::pacs::network::presentation_data_value::is_command, kcenon::pacs::network::presentation_data_value::is_last, kcenon::pacs::network::malformed_pdu, pdu_length(), kcenon::pacs::network::p_data_tf_pdu::pdvs, read_uint32_be(), and validate_pdu_header().
Referenced by decode(), and kcenon::pacs::network::v2::dicom_association_handler::handle_p_data_tf().


|
staticnodiscard |
Decode an A-RELEASE-RP PDU.
| data | Input byte buffer |
Definition at line 279 of file pdu_decoder.cpp.
References validate_pdu_header().
Referenced by decode().


|
staticnodiscard |
Decode an A-RELEASE-RQ PDU.
| data | Input byte buffer |
Definition at line 264 of file pdu_decoder.cpp.
References validate_pdu_header().
Referenced by decode().


|
staticnodiscardprivate |
Decode User Information sub-items.
Definition at line 508 of file pdu_decoder.cpp.
References kcenon::pacs::network::user_information::implementation_class_uid, kcenon::pacs::network::user_information::implementation_version_name, kcenon::pacs::network::user_information::max_pdu_length, read_uid(), read_uint16_be(), read_uint32_be(), kcenon::pacs::network::user_information::role_selections, and kcenon::pacs::network::scp_scu_role_selection::sop_class_uid.
Referenced by decode_variable_items().


|
staticnodiscardprivate |
Decode variable items from ASSOCIATE-RQ/AC PDUs.
Definition at line 385 of file pdu_decoder.cpp.
References kcenon::pacs::network::presentation_context_rq::abstract_syntax, kcenon::pacs::network::application_context, kcenon::pacs::network::buffer_overflow, decode_user_info_item(), kcenon::pacs::network::presentation_context_ac::id, kcenon::pacs::network::presentation_context_rq::id, kcenon::pacs::network::malformed_pdu, read_uid(), read_uint16_be(), kcenon::pacs::network::presentation_context_ac::result, kcenon::pacs::network::presentation_context_ac::transfer_syntax, and kcenon::pacs::network::presentation_context_rq::transfer_syntaxes.
Referenced by decode_associate_ac(), and decode_associate_rq().


|
staticnodiscard |
Check if a complete PDU is available in the buffer.
| data | Input byte buffer |
Returns the total PDU length (header + data) if at least one complete PDU is present in the buffer. Useful for streaming protocols where data arrives in chunks.
Definition at line 140 of file pdu_decoder.cpp.
References read_uint32_be().
Referenced by decode_associate_ac(), decode_associate_rq(), decode_p_data_tf(), kcenon::pacs::network::v2::dicom_association_handler::process_buffer(), and validate_pdu_header().


|
staticnodiscard |
Get the PDU type from buffer without full decoding.
| data | Input byte buffer (must have at least 1 byte) |
Definition at line 155 of file pdu_decoder.cpp.
References kcenon::pacs::network::abort, kcenon::pacs::network::associate_ac, kcenon::pacs::network::associate_rj, kcenon::pacs::network::associate_rq, kcenon::pacs::network::p_data_tf, kcenon::pacs::network::release_rp, and kcenon::pacs::network::release_rq.
Referenced by kcenon::pacs::network::v2::dicom_association_handler::process_buffer().

|
staticnodiscardprivate |
Read an AE Title (16 bytes, space-trimmed).
Definition at line 79 of file pdu_decoder.cpp.
References kcenon::pacs::network::AE_TITLE_LENGTH.
Referenced by decode_associate_ac(), and decode_associate_rq().

|
staticnodiscardprivate |
Read a UID string (trim trailing null/space padding).
Definition at line 92 of file pdu_decoder.cpp.
References uid.
Referenced by decode_user_info_item(), and decode_variable_items().

|
staticnodiscardprivate |
Read a 16-bit unsigned integer in big-endian format.
Definition at line 66 of file pdu_decoder.cpp.
Referenced by decode_associate_ac(), decode_associate_rq(), decode_user_info_item(), and decode_variable_items().

|
staticnodiscardprivate |
Read a 32-bit unsigned integer in big-endian format.
Definition at line 72 of file pdu_decoder.cpp.
Referenced by decode_p_data_tf(), decode_user_info_item(), pdu_length(), and validate_pdu_header().

|
staticnodiscardprivate |
Validate PDU header and extract length.
| data | Input data |
| expected_type | Expected PDU type (0 for any) |
Definition at line 102 of file pdu_decoder.cpp.
References kcenon::pacs::network::incomplete_header, kcenon::pacs::network::incomplete_pdu, kcenon::pacs::network::invalid_pdu_type, kcenon::pacs::network::malformed_pdu, pdu_length(), and read_uint32_be().
Referenced by decode_abort(), decode_associate_ac(), decode_associate_rj(), decode_associate_rq(), decode_p_data_tf(), decode_release_rp(), and decode_release_rq().

