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
46
AGENTS.md
46
AGENTS.md
|
|
@ -41,7 +41,7 @@ PipeWire. The verified device/carrier combinations are in the README.
|
|||
| `project.cpp` | The canonical build description, for [Crafter Build](https://forgejo.catcrafts.net/Catcrafts/Crafter.Build). Chooses the product by `--product=`. |
|
||||
| `interfaces/Imsd.cppm` | The primary module interface of `imsd-core`: `export import`s the nine partitions below. |
|
||||
| `interfaces/Imsd-Util.cppm` | `imsd::util` — SIP tokens, IPv6 host/port formatting, the RFC 5952 §4 IPv6 text (`CanonicalIp6`/`CanonicalAddr`; an IPv4-mapped address spelled in hex stays hex, where §5 and `inet_ntop` write it dotted) and the comma-separated address-list parser (`ParseAddressList`), hex/base64, MD5 (RFC 1321), the fixed protected ports `PortUc`/`PortUs` (45061/45062). |
|
||||
| `interfaces/Imsd-Sip.cppm` | `imsd::sip` — SIP as a text layer plus TCP framing: header extraction (from the header section only: a read ends at the first empty line after the start line, empty lines before it skipped; a header is asked for by its long name and found under that or its compact form — RFC 3261 7.3.3: the RFC's ten, and `o` for Event and `x` for Session-Expires — with or without white space before the colon; `HeaderUri`: the party a header names; `Body`, moved here out of `CallMachine`), status codes, the granted lifetime, `ResponseOf` transaction matching (the Call-ID, and the CSeq as its number and its method, whatever spaces or tabs part them and whatever zeros stand before the number), `CutShortRequest`: the header section of a request — any but an ACK or a CANCEL — whose datagram has fewer body bytes than the Content-Length read from it says, which its 400 is built from. Not a full RFC 3261 parser, deliberately. |
|
||||
| `interfaces/Imsd-Sip.cppm` | `imsd::sip` — SIP as a text layer plus TCP framing: header extraction (from the header section only: a read ends at the first empty line after the start line, empty lines before it skipped; a header is asked for by its long name and found under that or its compact form — RFC 3261 7.3.3: the RFC's ten, and `o` for Event and `x` for Session-Expires — with or without white space before the colon; `Unfolded`, by which the framers hand a message on with its folded header lines — 7.3.1 — joined; `HeaderUri`: the party a header names; `Body`, moved here out of `CallMachine`), status codes, the granted lifetime, `ResponseOf` transaction matching (the Call-ID, and the CSeq as its number and its method, whatever spaces or tabs part them and whatever zeros stand before the number), `CutShortRequest`: the header section of a request — any but an ACK or a CANCEL — whose datagram has fewer body bytes than the Content-Length read from it says, which its 400 is built from. Not a full RFC 3261 parser, deliberately. |
|
||||
| `interfaces/Imsd-Sdp.cppm` | `imsd::sdp` — SDP offer/answer: the AMR-WB + AMR + telephone-event offer (optional IR.92 preconditions; `OfferedTelephoneEventPt` names its telephone-event numbers), the parser the media plane needs (the codec, its payload type and mode, and the telephone-event payload type the m-line lists at that codec's clock), `BuildAnswer` for the terminating side, the `CODECS` override. |
|
||||
| `interfaces/Imsd-Sms.cppm` | `imsd::sms` — the short message codecs SMS over IP rides on (TS 24.341 carries the bytes a 2G/3G phone puts in an RP-DATA, in a SIP MESSAGE body): the GSM 7-bit default alphabet with its extension table and the septet packing, UCS-2 (TS 23.038); the SM-TL PDUs (TS 23.040: SMS-SUBMIT built, one per segment with the concatenation header when the text needs more than one; SMS-DELIVER, SMS-STATUS-REPORT and SMS-SUBMIT-REPORT parsed; the SMS-DELIVER-REPORT that acknowledges a delivery; the user-data header — concatenation, application ports — and the `Reassembler` of a concatenated message); the SM-RL messages (TS 24.011: RP-DATA, RP-ACK, RP-ERROR in both directions, the cause values); EF_SMSP (TS 31.102 §4.2.27), where the (U)SIM names the service centre, and qmicli's hex dump of it. Byte-level only: no SIP, no clock, no I/O. |
|
||||
| `interfaces/Imsd-Aka.cppm` | `imsd::aka` — USIM AKA glue: the AKAv1-MD5 digest (RFC 3310), IMPI/IMPU/realm from IMSI + MCC/MNC, parsers for `qmicli --uim-get-card-status` and `mmcli` output, the AUTHENTICATE APDU and its response. |
|
||||
|
|
@ -298,7 +298,7 @@ What the suites pin:
|
|||
skipped), the Content-Length the two framers read (zeros before its
|
||||
number no part of it; a number past any that fits not read as zero; a
|
||||
value that begins with no digit read as none), `CutShortRequest` (the
|
||||
header section of a request with fewer body bytes than the
|
||||
header section, unfolded, of a request with fewer body bytes than the
|
||||
Content-Length read from it says, its version in upper or in lower case; none for a
|
||||
body that is all there, for no Content-Length, no end of headers, a
|
||||
response in either letter case, a status line whose phrase ends like a
|
||||
|
|
@ -317,7 +317,12 @@ What the suites pin:
|
|||
counted, its own `rport` counted, last before the comma too; a comma
|
||||
in a quoted string no end of it, the comma behind the closing quote
|
||||
its end) —, white space before the colon (RFC 3261 7.3.1's four
|
||||
spellings),
|
||||
spellings), `Unfolded` (7.3.1's own example, a tab, a bare LF, a value
|
||||
begun on the next line, a line break that nothing follows kept) and both
|
||||
framers on a 401 whose WWW-Authenticate goes over four lines — the
|
||||
header section unfolded, a folded Content-Length framing the body, the
|
||||
body as it came —, and `ViaResponsePort` on a Via list folded after its
|
||||
comma, as the datagram framer hands it on,
|
||||
`ResponseOf` (the transaction's own 100 Trying; a final whose CSeq parts
|
||||
its number and its method by two spaces, by a tab or by both, or has
|
||||
zeros before its number: the
|
||||
|
|
@ -381,7 +386,8 @@ What the suites pin:
|
|||
a delivered MESSAGE whose header names come in compact form — the 200 and
|
||||
the delivery report of its long form, its retransmission key, the 480
|
||||
while SMS over IP is off — and a final in compact form taken by the
|
||||
message in flight;
|
||||
message in flight; a delivered MESSAGE whose Content-Type came folded,
|
||||
taken for a short message once the datagram framer has unfolded it;
|
||||
a submit report before the MESSAGE's own final taken — the message sent
|
||||
and the late final nobody's; with two segments the second goes out under
|
||||
its own Call-ID — a text past 255 segments failed at once naming the fit,
|
||||
|
|
@ -738,6 +744,24 @@ Rules:
|
|||
text by a packet counter, none over TCP: `checks.log`); a MESSAGE the
|
||||
phone sent to its own server port with a Content-Length larger than
|
||||
its body was answered 400 (`inject-bench.log`).
|
||||
The unfolding ran in the same benches: the stand-in's 401 with its
|
||||
WWW-Authenticate over four lines and its Security-Server over three
|
||||
gave the Security-Server whole (at the commit before, its first line,
|
||||
and the bring-up deferred: `Security-Server carries no
|
||||
spi-c/spi-s/port-c/port-s`); a request whose Content-Type and
|
||||
Content-Length stood on continuation lines came out of the server
|
||||
ports unfolded and framed by that length, as a datagram and over a
|
||||
connection (at the commit before, the datagram kept the bytes after
|
||||
its body); a request cut short of a folded Content-Length, its Via on a continuation
|
||||
line, was answered 400 with its Via whole, on a server port and, in
|
||||
`cut-short`, on the client flow (at the commit before, its folded
|
||||
length was not read and it was handed on as it came); a request on a
|
||||
server port whose Via row held a list folded after its comma, `rport`
|
||||
on its lower value, was answered by the way to the port its top value
|
||||
names, as at the commit before. On the
|
||||
phone the 401 of the fresh registration came from KPN, whose 401 of
|
||||
2026-07-18 had its WWW-Authenticate over four lines (§13; the fresh one was not
|
||||
dumped).
|
||||
- `imsd-pcscf` ran on the dev phone (KPN) on 2026-10-11 against the live ims
|
||||
bearer: the `--mux 1 --profile 2 -v` sequence, a plain run, and `OutOfCall`
|
||||
on an unbound mux (the fp6 journal's `2026-10-11-pcscf-pco-probe` capture,
|
||||
|
|
@ -1645,9 +1669,10 @@ still answered 200 and logged with its body: the 200 is `BuildResponse`'s
|
|||
now and the line names the content type (§7.8). A header imsd reads is
|
||||
found under its long name or, where it has one, its compact form (RFC
|
||||
3261 7.3.3: a `c:` line is a `Content-Type`, an `i:` line a Call-ID, a
|
||||
`v:` line a Via), with or without white space before the colon; of a
|
||||
value folded onto further lines the first line is read (7.3.1 allows the
|
||||
fold). A datagram on a server port or on the init port is
|
||||
`v:` line a Via), with or without white space before the colon, and a
|
||||
value folded onto further lines (7.3.1) whole: a received message's
|
||||
header section is unfolded where it is framed (`Unfolded`), each line
|
||||
break in it that a space or a tab follows becoming, with the white space after it, one space. A datagram on a server port or on the init port is
|
||||
framed as one on the client flow is (RFC 3261 18.3): bytes past the
|
||||
Content-Length read from it are discarded, and one that has no end of headers is
|
||||
ignored with a line (`UDP: … on server socket <port> — ignored`, `UDP: …
|
||||
|
|
@ -2383,3 +2408,10 @@ the related code.
|
|||
01:17:41–45, 28–36 min after their SC time stamps; what held them is
|
||||
unknown. The registrar echoes `+g.3gpp.smsip` in the reg-event reginfo
|
||||
(`<unknown-param name="+g.3gpp.smsip"/>`) on both AORs.
|
||||
- **A folded `WWW-Authenticate`** — the 401 to the unprotected REGISTER
|
||||
came with its `WWW-Authenticate` over four lines on KPN (2026-07-18)
|
||||
and on Odido (2026-07-13), the nonce on the second (RFC 3261 7.3.1; one
|
||||
401 of each: the fp6 journal's `2026-11-20-issues-2-5` capture,
|
||||
`folded-401`); the `Security-Server` of both was one line. imsd finds the nonce by a search
|
||||
of the whole message, and unfolds every received message where it is
|
||||
framed (§7.9).
|
||||
|
|
|
|||
Loading…
Reference in a new issue