Skip to content

BUG: Use only odd presentation context IDs#552

Merged
Enet4 merged 3 commits intoEnet4:masterfrom
naterichman:presentation-context-id
Aug 6, 2024
Merged

BUG: Use only odd presentation context IDs#552
Enet4 merged 3 commits intoEnet4:masterfrom
naterichman:presentation-context-id

Conversation

@naterichman
Copy link
Copy Markdown
Contributor

Not really sure why, but I had an SCP I was talking to and trying to pass multiple presentation context IDs and it was failing. I tried with a different implementation (pydicom) and it worked, looking at a packet capture the only difference was that they passed a couple of other transfer syntaxes (explicit VR big endian, and deflated), and that they only used odd numbers for presentation context ids.

I couldn't find anything in the standard to support that, but I tried changing it and it worked...

Code to reproduce:

pub fn establish_ae(
) -> (ClientAssociation, &'static TransferSyntax, u8){
    let options = ClientAssociationOptions::new()
        .with_abstract_syntax(uids::PATIENT_ROOT_QUERY_RETRIEVE_INFORMATION_MODEL_FIND)
        .with_abstract_syntax(uids::PATIENT_ROOT_QUERY_RETRIEVE_INFORMATION_MODEL_MOVE)
        .called_ae_title("MYAE".to_string())
        .calling_ae_title("FWRECEIVER".to_string())
        .read_timeout(Duration::from_secs(120))
        .write_timeout(Duration::from_secs(120));

    let scu = options
        .establish_with("10.0.1.1:104").unwrap();
    let pc_selected = if let Some(pc_selected) = scu.presentation_contexts().first() {
        pc_selected
    } else {
        let _ = scu.abort();
        std::process::exit(-2);
    };
    let pc_selected_id = pc_selected.id;
    let ts = if let Some(ts) = TransferSyntaxRegistry.get(&pc_selected.transfer_syntax) {
        ts
    } else {
        let _ = scu.abort();
        std::process::exit(-2);
    };
    return (scu, ts, pc_selected_id)
}
fn main(){
    let (assoc, ts, pc) = establish_ae();
    println!("{:?}", assoc);
}

Before the change, output:

thread 'main' panicked at src/bin/association.rs:21:45:
called `Result::unwrap()` on an `Err` value: Rejected { association_rj: AssociationRJ { result: Permanent, source: ServiceProviderASCE(NoReasonGiven) }, backtrace: Backtrace(()) }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

after:

ClientAssociation { presentation_contexts: [PresentationContextResult { id: 1, reason: Acceptance, transfer_syntax: "1.2.840.10008.1.2.1" }, PresentationContextResult { id: 3, reason: Acceptance, transfer_syntax: "1.2.840.10008.1.2.1" }], requestor_max_pdu_length: 16384, acceptor_max_pdu_length: 65536, socket: TcpStream { addr: 10.128.0.54:42656, peer: 10.37.235.21:104, fd: 3 }, buffer: [], strict: true }

@naterichman
Copy link
Copy Markdown
Contributor Author

Ah, found this: https://dicom.nema.org/medical/dicom/current/output/chtml/part08/sect_9.3.2.2.html

Presentation-context-ID values shall be odd integers between 1 and 255, encoded as an unsigned binary number. For a complete description of the use of this field see Section 7.1.1.13.

@naterichman naterichman changed the title MAIN: Use only odd presentation context IDs BUG: Use only odd presentation context IDs Aug 5, 2024
@Enet4 Enet4 added bug This is a bug A-lib Area: library C-ul Crate: dicom-ul labels Aug 6, 2024
Copy link
Copy Markdown
Owner

@Enet4 Enet4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great finding, @naterichman! 👍

@Enet4 Enet4 merged commit 334273d into Enet4:master Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-lib Area: library bug This is a bug C-ul Crate: dicom-ul

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants