sip: a received message's header section is unfolded where it is framed
RFC 3261 7.3.1 lets a header value go on over further lines, each begun
with a space or a tab: "The line break and the whitespace at the
beginning of the next line are treated as a single SP character." The
text layer read a header from one line, so of a folded value it had the
first line only. Networks fold: KPN's 401 to the unprotected REGISTER
of 2026-07-18 and Odido's of 2026-07-13 had the WWW-Authenticate over
four lines (AGENTS.md §13; imsd finds a 401's nonce by a search of the
whole message, on a continuation line as on any other). A
Security-Server folded the same way would be read by its first line
alone, without the SPIs and ports on the further lines, and the
bring-up deferred; a short message whose Content-Type stands on a
continuation line would be taken for a page-mode text, answered 200
and never shown; a folded Content-Length on a connection would frame
no body, and the body's bytes begin the next message.
Unfolded takes the folds out of a header section, and the two framers
— FrameBuffer::TryExtract for a stream, DatagramMessage for a datagram
— hand a message on with its header section unfolded and its body as
it came; the Content-Length that frames the body is read from the
unfolded section. CutShortRequest reads its Content-Length so too, and
the header section it gives for the 400 is unfolded. Every socket imsd
reads SIP from goes through one of the two framers, so each reader of
a header still reads one line. A DUMP_SIP dump of a received message
holds it as framed.
Jorijn's decision of 2026-11-21 ("Unfold now").
Tested by tests/Sip — Unfolded on 7.3.1's own example, a tab, a bare LF,
a value begun on the next line and a line break that nothing follows;
both framers on a 401 whose WWW-Authenticate goes over four lines and
whose Content-Length is folded; CutShortRequest on a request cut short
of a folded Content-Length; ViaResponsePort on a Via list folded after
its comma, through the datagram framer — and by tests/Engine, a
delivered MESSAGE whose Content-Type came folded. On the workstation's
loopback (the fp6 journal's 2026-11-20-issues-2-5 capture, init-port,
server-ports and cut-short, at this commit and at the one before): a
stand-in's 401 with its Security-Server over three lines gives the whole
value, where the commit before deferred the bring-up for want of SPIs; a
request with its Content-Type and Content-Length on continuation lines
comes out of the server ports unfolded and framed by that length, as a
datagram and over a connection; a request cut short of a folded
Content-Length, its Via on a continuation line, is answered 400 with its
Via whole, on a server port and on the client flow, where the commit
before did not read the folded length and handed the request on as it
came; a request on a server port whose Via row is a list folded after
its comma, `rport` on its lower value, is answered from the client-port
socket, the way to the port its top value names, as at the commit
before. On the dev phone the binary of this range's last commit
registered fresh on KPN after a reboot; the 401 was not dumped, so
whether it came folded that time is not on record. A MESSAGE the phone
sent to its own protected server port, its Via row a list folded after
its comma with `rport` on the lower value, was answered from the
client-port socket (the capture's phone-form6, fresh-check.log and
inject-bench.log).
This commit is contained in:
parent
5f01b46909
commit
9333621c66
6 changed files with 178 additions and 47 deletions
|
|
@ -41,7 +41,8 @@
|
|||
// unusable TPDU acknowledged with an RP-ERROR, a body that is no RP
|
||||
// message, a page-mode text 200'd and logged, a short message while SMS
|
||||
// over IP is off refused with 480, a delivered MESSAGE and a final whose
|
||||
// header names come in compact form), and the store's record codec
|
||||
// header names come in compact form, a delivered MESSAGE whose
|
||||
// Content-Type came folded), and the store's record codec
|
||||
// (FormatStoredSms/ParseStoredSms: a full record round trip, defaults
|
||||
// for absent keys, a value that does not parse or a missing id refused) and order
|
||||
// (StoredSmsBefore: the arrival second, then within a run the sequence
|
||||
|
|
@ -1557,6 +1558,20 @@ int main() {
|
|||
const auto* repo = findSms(ro.actions, SmsAction::Type::SendClient);
|
||||
Check(repo && repo->text.starts_with("MESSAGE sip:ipsmgw@ims.mnc001.mcc001.3gppnetwork.org SIP/2.0\r\n"), "inbound: with a From that names another, the report still goes to the P-Asserted-Identity");
|
||||
}
|
||||
// the same delivery with its Content-Type folded onto a second line (RFC 3261 7.3.1), as a framer hands it on
|
||||
{
|
||||
const std::string longForm = inbound("011107911356131313F3001E040B911346610089F60000208062917314080CC8F71D14969741F977FD07");
|
||||
std::string folded = longForm;
|
||||
folded.replace(folded.find("Content-Type: "), 14, "Content-Type:\r\n\t");
|
||||
const auto framed = imsd::sip::DatagramMessage(folded);
|
||||
Check(folded.contains("\r\nContent-Type:\r\n\tapplication/vnd.3gpp.sms\r\n") && framed == longForm, "folded MESSAGE: the datagram framer hands the long form's message on");
|
||||
imsd::util::Rng rng(80), rngLong(80);
|
||||
Reassembler re, reLong;
|
||||
auto r = OnSmsMessage(c, rng, framed.value_or(""), re, nullptr, 50.0);
|
||||
auto want = OnSmsMessage(c, rngLong, longForm, reLong, nullptr, 50.0);
|
||||
const auto* rec = findSms(r.actions, SmsAction::Type::Received);
|
||||
Check(rec && rec->received.text == "How are you?" && r.response == want.response && hasSms(r.actions, SmsAction::Type::SendClient), "folded MESSAGE: taken for a short message, answered and reported on as its long form");
|
||||
}
|
||||
// the same delivery with its header names in compact form (RFC 3261 7.3.3): `c:` is the content type, `i:` the Call-ID, `v:` the Via
|
||||
{
|
||||
const std::string longForm = inbound("011107911356131313F3001E040B911346610089F60000208062917314080CC8F71D14969741F977FD07");
|
||||
|
|
|
|||
Loading…
Reference in a new issue