sip: a header is found under its compact form, and with white space before the colon
RFC 3261 7.3.3 lets a sender write a header name in its one-letter form at any time and has every implementation accept both forms. The text layer matched the long name only, so to every reader a header sent in compact form was absent: the TCP framer took no body length from `l:` and read the body as the start of the next message, a response with `i:` matched no transaction and a request no call, the finals imsd builds left out a Via, From, To or Call-ID that came in compact form, and a short message whose content type came as `c:` was answered 200 and logged instead of taken (issue #2). MatchHeaderLine now takes a line under the name it is asked for or under that name's compact form: the ten RFC 3261 defines, and `o` for Event (RFC 6665) and `x` for Session-Expires (RFC 4028), the two extension headers imsd reads that have one. Every reader goes through it — Header, Headers, the framer, DatagramMessage — so no reader changes for it. It also takes white space between the name and the colon, which the same grammar allows (25.1's HCOLON; 7.3.1's "Subject : lunch") and the matcher refused. A value folded onto further lines is still read by its first line. One reader is changed for the rows it is now handed. ViaResponsePort gives the port the top Via names, to which the answer to a request that came in a datagram on a server port goes (RFC 3261 18.2.2), and none where that Via carries `rport` (RFC 3581): the answer then goes back to the port the request came from. It took `rport` for present where those five letters, in lower case, stood anywhere behind the row's first semicolon. Parameter names are case-insensitive (7.3.1), and a request whose top Via came as `v: …;RPORT`, a row 1.2.0 passed over, would have been answered to the port that Via names, its `rport` not seen. ViaResponsePort now reads the Via's parameters one by one, each to the next semicolon outside a quoted string, and `rport` is one by its name, in any case: not those letters in a value or in a longer name. Read so, the last parameter of the top value would run on into the next value where a row holds a list — `rport, SIP/2.0/UDP …` is no `rport`, and 1.2.0's search of the letters found it —, so the top value is cut from the row first, at the first comma outside a quoted string. With that cut a lower value's `rport` no longer counts for the top one's, as it did in 1.2.0 for a list on one line. Tested by the suites: tests/Sip pins each of the twelve forms through Header, in lower and in upper case, and through Headers, `l:` through the framer and DatagramMessage, 7.3.1's four spellings of the colon, and ViaResponsePort's reading of a Via row, `rport` by its name and of a list on one line the top value alone; tests/Engine drives an incoming call from an INVITE in compact form, an outgoing call from responses in compact form and a delivered MESSAGE in compact form through the reducers; tests/Messages builds BuildResponse, BuildResponse200 and BuildInviteResponse for a request in compact form. On the workstation's loopback (the fp6 journal's 2026-11-20-issues-2-5 capture, server-ports, at this commit and at the one before) a request on a server port whose Via row is a list on one line with `rport` on its lower value is answered from the client-port socket, the way to the port its top value names, where the commit before answered it from the socket it had come on. On the dev phone the binary of this range's last commit answered a MESSAGE the phone sent to its own protected server port from the client-port socket where its Via row was such a list, and from the socket it had come on where its one Via came as `v: …;RPORT` (the capture's phone-form6, inject-bench.log).
This commit is contained in:
parent
5c1fca12b9
commit
1267fe1ada
6 changed files with 367 additions and 48 deletions
|
|
@ -5,7 +5,8 @@
|
|||
// compared byte-for-byte against a reference message cross-generated from the
|
||||
// Python VoLTE stack with pinned tags/branches/SPIs; their variants and the other
|
||||
// builders against a message written here or by their lines (BuildInviteResponse
|
||||
// is not called). A divergence here is a wire-format change, i.e. a
|
||||
// by the lines of one 180 and by its answers to an INVITE in long and in
|
||||
// compact form). A divergence here is a wire-format change, i.e. a
|
||||
// registration or call that the commercial IMS core may reject; these are the
|
||||
// hardest pins in the project. Two deliberate post-parity divergences:
|
||||
// the REGISTER Contact carries +sip.instance and the MMTEL ICSI feature tag
|
||||
|
|
@ -501,6 +502,56 @@ int main() {
|
|||
"Content-Length: 0\r\n\r\n", "a 488 for an inbound MESSAGE echoes every Via and tags To");
|
||||
const std::string tagged = "MESSAGE sip:me@ims SIP/2.0\r\nVia: SIP/2.0/UDP [2001:db8::105]:6000;branch=z9hG4bKnet2\r\nFrom: <sip:ipsmgw@ims>;tag=N2\r\nTo: <sip:me@ims>;tag=had\r\nCall-ID: in2@net\r\nCSeq: 1 MESSAGE\r\nContent-Length: 0\r\n\r\n";
|
||||
Check(BuildResponse(c, tagged, 200, "OK", "unused").contains("\r\nTo: <sip:me@ims>;tag=had\r\n"), "a To that already carries a tag is echoed as it is");
|
||||
// a request whose header names come in compact form (RFC 3261 7.3.3): the finals echo them under the long names
|
||||
const std::string compact =
|
||||
"MESSAGE sip:me@[2001:db8::db43]:45062 SIP/2.0\r\n"
|
||||
"v: SIP/2.0/UDP [2001:db8::105]:6000;branch=z9hG4bKnet1\r\n"
|
||||
"V: SIP/2.0/UDP [2001:db8::77]:5060;branch=z9hG4bKgw0\r\n"
|
||||
"f: <sip:ipsmgw@ims>;tag=N1\r\n"
|
||||
"t: <sip:me@ims>\r\n"
|
||||
"i: in1@net\r\n"
|
||||
"CSeq: 9 MESSAGE\r\n"
|
||||
"l: 0\r\n\r\n";
|
||||
Eq(BuildResponse(c, compact, 488, "Not Acceptable Here", "T488"), BuildResponse(c, inbound, 488, "Not Acceptable Here", "T488"), "a 488 for a MESSAGE in compact form is the one for its long form");
|
||||
Eq(BuildResponse200(c, compact), BuildResponse200(c, inbound), "the hop-by-hop 200 for a request in compact form is the one for its long form");
|
||||
Check(BuildResponse200(c, compact).contains("\r\nFrom: <sip:ipsmgw@ims>;tag=N1\r\nTo: <sip:me@ims>\r\nCall-ID: in1@net\r\nCSeq: 9 MESSAGE\r\n"), "with its `f:`, `t:` and `i:` under the long names");
|
||||
// BuildInviteResponse reads the same names: an INVITE in compact form gets the responses of its long form
|
||||
const std::string invite =
|
||||
"INVITE sip:me@[2001:db8::db43]:45062 SIP/2.0\r\n"
|
||||
"Via: SIP/2.0/TCP [2001:db8::105]:6000;branch=z9hG4bKnet3\r\n"
|
||||
"Via: SIP/2.0/UDP [2001:db8::77]:5060;branch=z9hG4bKgw3\r\n"
|
||||
"Record-Route: <sip:[2001:db8::105]:6000;lr>\r\n"
|
||||
"From: <sip:caller@ims>;tag=N3\r\n"
|
||||
"To: <sip:me@ims>\r\n"
|
||||
"Call-ID: call3@net\r\n"
|
||||
"CSeq: 1 INVITE\r\n"
|
||||
"Content-Length: 0\r\n\r\n";
|
||||
const std::string compactInvite =
|
||||
"INVITE sip:me@[2001:db8::db43]:45062 SIP/2.0\r\n"
|
||||
"v: SIP/2.0/TCP [2001:db8::105]:6000;branch=z9hG4bKnet3\r\n"
|
||||
"V: SIP/2.0/UDP [2001:db8::77]:5060;branch=z9hG4bKgw3\r\n"
|
||||
"Record-Route: <sip:[2001:db8::105]:6000;lr>\r\n"
|
||||
"f: <sip:caller@ims>;tag=N3\r\n"
|
||||
"t: <sip:me@ims>\r\n"
|
||||
"i: call3@net\r\n"
|
||||
"CSeq: 1 INVITE\r\n"
|
||||
"l: 0\r\n\r\n";
|
||||
const std::string ringing = BuildInviteResponse(c, invite, 180, "Ringing", "T180");
|
||||
Eq(ringing,
|
||||
"SIP/2.0 180 Ringing\r\n"
|
||||
"Via: SIP/2.0/TCP [2001:db8::105]:6000;branch=z9hG4bKnet3\r\n"
|
||||
"Via: SIP/2.0/UDP [2001:db8::77]:5060;branch=z9hG4bKgw3\r\n"
|
||||
"Record-Route: <sip:[2001:db8::105]:6000;lr>\r\n"
|
||||
"From: <sip:caller@ims>;tag=N3\r\n"
|
||||
"To: <sip:me@ims>;tag=T180\r\n"
|
||||
"Call-ID: call3@net\r\n"
|
||||
"CSeq: 1 INVITE\r\n"
|
||||
"Contact: <sip:001010123456789@[2001:db8::db43]:45062>\r\n"
|
||||
"Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, PRACK, UPDATE, MESSAGE, REFER\r\n"
|
||||
"Content-Length: 0\r\n\r\n", "a 180 for an INVITE echoes every Via and the Record-Route, tags To and carries our Contact and Allow");
|
||||
Eq(BuildInviteResponse(c, compactInvite, 180, "Ringing", "T180"), ringing, "a 180 for an INVITE in compact form is the one for its long form");
|
||||
Eq(BuildInviteResponse(c, compactInvite, 486, "Busy Here", "T486"), BuildInviteResponse(c, invite, 486, "Busy Here", "T486"), "and so is a 486");
|
||||
Check(BuildInviteResponse(c, invite, 486, "Busy Here", "T486").contains("\r\nTo: <sip:me@ims>;tag=T486\r\n") && !BuildInviteResponse(c, invite, 486, "Busy Here", "T486").contains("Record-Route"), "a 486 tags To and returns no Record-Route");
|
||||
{
|
||||
const std::string body = "hi\r\nVia: SIP/2.0/UDP 192.0.2.66;branch=z9hG4bKx";
|
||||
const std::string tail = "Content-Length: 0\r\n\r\n";
|
||||
|
|
|
|||
Loading…
Reference in a new issue