Endpoints drop responses with multiple entries in a single Via header field. This appears to be because the multiple valued Via header is parsed incorrectly by TransactionKey::from_response so the transaction is unmatched.
Example:
#[cfg(test)]
mod tests {
#[test]
fn test_generate_transaction_key() {
let raw_message = format!(
"{}\r\n",
&[
"SIP/2.0 401 Unauthorized",
"Via: SIP/2.0/UDP 172.22.22.80:5062;received=172.22.22.80;rport=5062;branch=z9hG4bKkwpQ8Rq2RRoi,SIP/2.0/TCP 10.0.13.70:5060;branch=z9hG4bK20ede05124e2b786dbfbe11b",
"From: <sip:001010000000001@ims.example.com>;tag=e80c1d8c",
"To: <sip:001010000000001@ims.example.com>;tag=2e518",
"Call-ID: 9e353fc94f78064f@10.0.13.70",
"CSeq: 1 REGISTER",
"Content-Length: 0",
"",
]
.join("\r\n")
);
let resp = rsipstack::sip::Response::try_from(raw_message).unwrap();
let key = rsipstack::transaction::key::TransactionKey::from_response(
&resp,
rsipstack::transaction::key::TransactionRole::Client,
)
.unwrap();
assert_eq!(
key.to_string(),
"c.REGISTER_1_9e353fc94f78064f@10.0.13.70_e80c1d8c_z9hG4bKkwpQ8Rq2RRoi"
);
}
}
This test fails with the following output:
---- tests::test_generate_transaction_key stdout ----
thread 'tests::test_generate_transaction_key' (9238547) panicked at ***:
assertion `left == right` failed
left: "c.REGISTER_1_9e353fc94f78064f@10.0.13.70_e80c1d8c_z9hG4bKkwpQ8Rq2RRoi,SIP/2.0/TCP 10.0.13.70:5060"
right: "c.REGISTER_1_9e353fc94f78064f@10.0.13.70_e80c1d8c_z9hG4bKkwpQ8Rq2RRoi"
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Furthermore, it appears that the order of header parameters matters. If rport immediately precedes comma, then typed::Via::parse() fails with an error, but (as in the example above) there is no error if branch is the final header parameter before the comma.
Endpoints drop responses with multiple entries in a single
Viaheader field. This appears to be because the multiple valuedViaheader is parsed incorrectly byTransactionKey::from_responseso the transaction is unmatched.Example:
This test fails with the following output:
Furthermore, it appears that the order of header parameters matters. If
rportimmediately precedes comma, thentyped::Via::parse()fails with an error, but (as in the example above) there is no error ifbranchis the final header parameter before the comma.