sip, engine: the retry of an INVITE refused 422
imsd asks for a session interval of 1800 s in a call's first INVITE. A 422 (Session Interval Too Small) is a server's answer to an interval below its minimum and carries that minimum in a Min-SE (RFC 4028 6); TS 24.229 5.1.2A.1.1 has a UE that supports RFC 4028 retry an INVITE so refused in accordance with RFC 4028 7.4. imsd announces "timer" and took a 422 for any other refusal: on a reporter's phone on AT&T's network each of the five calls of one boot ended "INVITE final 422" (AGENTS.md §13). The call machine now sends the INVITE again in the same call: a new transaction under the Call-ID, with the next sequence number, the 422's Min-SE and a session interval no smaller. AGENTS.md §7.6 has when it does not, and what becomes of an answer to an INVITE it has replaced. Tested: the suites, and the daemon of this commit on the workstation against a stand-in network that answers 422 (the fp6 journal's 2026-12-01-min-se-retry capture, bench/).
This commit is contained in:
parent
3d702ec1f1
commit
0026213073
6 changed files with 459 additions and 39 deletions
69
AGENTS.md
69
AGENTS.md
|
|
@ -44,7 +44,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`), the count of seconds a setting names (`WholeSeconds`), 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; `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-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, `MinSe` (the interval a `Min-SE` names), `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) and `RpCauseIsTemporary`, the causes of a submission after which imsd sends the segment again; 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` — the card's side of a registration: 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; since 1.2.3 the ISIM: the application of the slot in use out of the card status (`ParseIsimApp`, in whatever state the modem lists it), the SELECT and the two READ commands its identity files are read with, a card's answer (`ApduAnswer`: `90 00`, `91 XX` and `92 XX` are its normal endings; `HoldsRead` takes a read's data under `62 82` as well) and the command it asks for next (`ApduFollowUp`, for an answer without data: GET RESPONSE for `61 XX`, a command without data again for `6C XX`), the value a file holds (`ParseIsimValue`: the data object with tag `80`, the `FF` bytes at the end of its length cut, no blank and no byte outside printable ASCII) and `IsimIdentity`, the check of the three values — an `@` between two parts, a domain of labels of letters, digits and inner hyphens, 63 characters a label and 253 in all at most, a `sip:` at the start and more after it, the two identities 255 characters at most, no blank, no byte outside printable ASCII and no `"`, `\`, `<` or `>` — before they replace the derived names. |
|
||||
|
|
@ -168,7 +168,7 @@ answers' reading, the follow-up, the value of a file and the check of the
|
|||
identity are `Imsd:Aka`'s, with tests; the shell's part ran against
|
||||
stand-ins on the workstation (§5). A call whose client flow is found dead
|
||||
before any response to its INVITE (1.2.4, §7.6) has its decisions in
|
||||
`CallMachine`, with tests: which attempt is sent again, with which bytes,
|
||||
`CallMachine`, with tests: which INVITE is sent again, with which bytes,
|
||||
and when the call ends instead. The shell's part (`MaybeResendInvite`: the dead flow closed
|
||||
without a FIN's exchange, the one connect, the policy's word on whether the
|
||||
old registration may be reconnected over) ran against a stand-in network on
|
||||
|
|
@ -410,7 +410,9 @@ What the suites pin:
|
|||
zeros before its number: the
|
||||
transaction's; another number, another method, a method in other letter
|
||||
case, a CSeq without one of the two: not), refused finals with reason
|
||||
headers,
|
||||
headers, `MinSe` (the number a `Min-SE` begins with, zeros before it
|
||||
aside, whatever parameter follows; none for no such header, for a value
|
||||
that begins with no digit and for a number of more than nine digits),
|
||||
reginfo documents, `HeaderUri` and `Body`. A change that flips one of
|
||||
those tests is a behaviour change, not a cleanup.
|
||||
- `Sdp` — the offer's exact bytes, the parser (the telephone-event payload
|
||||
|
|
@ -442,9 +444,22 @@ What the suites pin:
|
|||
(reliable 18x/PRACK, 2xx ACK + media start, far-end hangup, CANCEL/answer
|
||||
races, busy/error finals, the terminating side's 100/180/200/486/487/488,
|
||||
G.711-only and AMR-NB gateway offers, ring timeout, BYE both ways, the
|
||||
emergency chain, an attempt's INVITE with no response and no CANCEL yet
|
||||
sent again over a flow the shell reopened, byte for byte and once per
|
||||
attempt, and its call ended where the flow is lost (an emergency call's
|
||||
emergency chain, an INVITE refused 422 sent again in the same call (the
|
||||
Call-ID, the From and the To kept, the number after the refused
|
||||
INVITE's or after a PRACK's sent since, a branch of its own, the
|
||||
refusal's `Min-SE` as its `Min-SE` and a session interval no smaller;
|
||||
an answer with the replaced INVITE's number dropped; the PRACK numbered
|
||||
after the second INVITE and naming it, the ACKs with its number; the
|
||||
second INVITE starting without the first's ringing state, PRACKed 18x,
|
||||
early answer, route and target, and with a resend of its own; the
|
||||
journal's line with the minimum and the refusal's `Reason`; not sent
|
||||
again for a `Min-SE` no larger than the one sent, for none that is
|
||||
read, after three, after a hang-up's CANCEL or after the answer, nor
|
||||
for a refusal that is no 422; an emergency attempt's INVITE sent again
|
||||
like any other, and its fallback counting anew), an INVITE with no
|
||||
response and no CANCEL yet sent again over a flow the shell reopened,
|
||||
byte for byte and once per INVITE, and its call ended where the flow is
|
||||
lost (an emergency call's
|
||||
first attempt too), DTMF — sent to the leg on an active call that negotiated
|
||||
telephone-event, dropped with the reason before the answer, after the
|
||||
call, without the negotiation, for a character that is no tone or for a
|
||||
|
|
@ -1982,12 +1997,14 @@ sent, emit this D-Bus state change, arm this deadline). States and reasons are t
|
|||
- Outgoing: INVITE with the SDP offer (AMR-WB + AMR + telephone-event by
|
||||
default; `CODECS` restricts and orders; `PRECOND=1` adds IR.92
|
||||
preconditions), reliable 18x with PRACK, 2xx ACK and media start, CANCEL
|
||||
before answer, BYE after. Busy and error finals end the call with
|
||||
`refused-or-busy` or `error`. Where the client flow is found dead after
|
||||
before answer, BYE after. Busy and error finals end the call, unless
|
||||
the emergency chain or the session timer (both below) has another
|
||||
INVITE follow. Where the client flow is found dead after
|
||||
an attempt's INVITE was sent and before any response to it (a 100
|
||||
included) or a CANCEL of it, the shell closes the dead socket without a
|
||||
FIN's exchange, reopens the flow with one connect and the same INVITE
|
||||
goes out again, once per attempt of the emergency chain, the setup
|
||||
goes out again, once for each INVITE a call sends (an attempt of the
|
||||
emergency chain's, or one sent again for a 422, below), the setup
|
||||
deadline running from then (`MaybeResendInvite`). No REGISTER goes
|
||||
first: the registration and its SAs stand (where a reg-event NOTIFY has
|
||||
ended the binding, §7.4, nothing is reopened), and TS 33.203 7.1 has a
|
||||
|
|
@ -2054,6 +2071,33 @@ sent, emit this D-Bus state change, arm this deadline). States and reasons are t
|
|||
a plain INVITE answered `380 Alternative Service` with an emergency body is
|
||||
re-attempted as `urn:service:sos`. An attempt whose client flow is lost
|
||||
(above) ends the call there: no fallback follows it.
|
||||
- Session timer (RFC 4028): the first INVITE of a dialog announces
|
||||
`timer` and asks for a session interval of 1800 s with `refresher=uac`
|
||||
and a `Min-SE` of 90. The shell hands a call every response on the
|
||||
client flow to an INVITE under its Call-ID; of a call imsd places the
|
||||
machine takes those whose sequence number is its current INVITE's
|
||||
(`ResponseOf`) and drops the others. Where the current INVITE awaits
|
||||
its final (no CANCEL of it out, no answer taken) and is answered `422`
|
||||
with a `Min-SE` (what `imsd::sip::MinSe` reads of it: a number of up to
|
||||
nine digits, zeros before it aside) above the one it carried, the
|
||||
INVITE goes out again in the same call (TS 24.229 5.1.2A.1.1; RFC 4028
|
||||
7.3, 7.4), at most three times under one Call-ID (`MinSeAgainMax`,
|
||||
imsd's own bound): the Call-ID, the From with its tag and the To as
|
||||
they were, a new branch and the 422's `Min-SE` as its `Min-SE`
|
||||
(`CallMachine::AgainWithMinSe`). The session interval it asks for is
|
||||
the one asked for before, or that `Min-SE` where the interval was
|
||||
smaller. Its sequence number is the next the Call-ID has not carried:
|
||||
RFC 4028 7.3 has "one higher than the previous", which imsd takes as
|
||||
the one after the refused INVITE's; where a PRACK followed that INVITE
|
||||
imsd takes the one after the last PRACK's instead. The setup deadline
|
||||
runs anew from each INVITE. Any other 422 to the current INVITE is a
|
||||
refusal like any other, to a call and to an attempt of the emergency
|
||||
chain, whose fallback is a new dialog and starts at 1800 and 90 again.
|
||||
What answers an INVITE the call has replaced is dropped with the
|
||||
others: its 422 coming a second time is not acknowledged again. In a
|
||||
call it places imsd asks to be the refresher and sends no session
|
||||
refresh of its own (the call machine sends no UPDATE and no re-INVITE;
|
||||
one from the far side is answered).
|
||||
- DTMF (`SendDtmf`): the tones go out as RFC 4733 telephone-event packets
|
||||
on the call's RTP stream, at the payload type the SDP negotiated for the
|
||||
codec's clock (`MediaLeg::dtmfPt`: the answer's for an outgoing call, the
|
||||
|
|
@ -2246,6 +2290,11 @@ Lines the operator (and the scripts) look for, all prefixed `imsd: `:
|
|||
- `call X: the client flow died before any response to the INVITE; reopening it` and, when the connect
|
||||
succeeded, `call X: the INVITE again over the reopened flow` (§7.6); `call X ended: error — the client flow
|
||||
died before any response to the INVITE` where the call ends instead.
|
||||
- `call X: INVITE final 422, Min-SE N — the INVITE again with Session-Expires S` when an INVITE goes out again
|
||||
for a 422 (§7.6). A 422 that is a refusal like any other has what was read of it in the line it leaves, as
|
||||
`INVITE final 422, Min-SE N` or `INVITE final 422, no Min-SE read`: the call's `ended:` line, or an
|
||||
emergency attempt's `— retrying as plain INVITE of the digits`. In each of the three a `Reason` header of
|
||||
the 422 follows the `Min-SE` part (`…, Reason: …`).
|
||||
- `sleep is held off while the call lasts (logind's inhibitor)` when the
|
||||
calls table's first call has its lock and `sleep is no longer held off
|
||||
(no call)` when that lock is released, the table's last call gone
|
||||
|
|
@ -3642,7 +3691,7 @@ the related code.
|
|||
Service-Route, with a `tel:` P-Associated-URI and a `sip:` one at
|
||||
`one.att.net`, and a binding of `expires=2112`; two refreshes within
|
||||
the hour. Each of the five calls placed in that boot ended `INVITE
|
||||
final 422`.
|
||||
final 422` (§7.6).
|
||||
- **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
|
||||
|
|
|
|||
Loading…
Reference in a new issue