From ef04b473a77d82250d626518a35b9fff3eaaa3bc Mon Sep 17 00:00:00 2001 From: Jorijn van der Graaf Date: Sun, 22 Nov 2026 17:35:12 +0100 Subject: [PATCH] engine, imsd: a submit report for a MESSAGE no longer in flight that this run sent in the last hour is answered 200 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TS 24.341 5.3.1.2 has a submit report answered 200 when its In-Reply-To "indicates that the request corresponds to a short message submitted by the SM-over-IP sender" and 488 when it does not, and its NOTE 3 has the sender store the Call-ID for that. imsd knew only the Call-ID of the segment in flight (OwnsReport): a report that came once its message had ended — the 40 s wait run out — or once its segment was followed by the next was answered 488 like a stranger's, and its line said only "no MESSAGE of ours in flight" (issue #3, the first of its three cases). RecentSubmissions keeps the Call-ID of every MESSAGE a submission goes out in for an hour, with the message's id and the segment. A report In-Reply-To one of them that the message in flight does not take is answered 200, and the journal has `submit report (RP-ACK) In-Reply-To …: sms 's segment i/n, no longer in flight; 200`, an RP-ERROR's with its cause. The 488 is left for an In-Reply-To that names no MESSAGE of ours on record, and its line says so ("on record" for "in flight"). A report without In-Reply-To that no message in flight takes by its RP-MR is answered 200 as before; its line ends `that no message in flight owns; 200` where it ended `for no message in flight; 200`. The bus is told nothing of a late report: the Messaging interface is frozen with `failed` as a message's last word (AGENTS.md §8.4), so a text the service centre took after its wait had run out stays `failed` there; the journal's line is the record of it. Tested by tests/Engine: the table (a Call-ID on record for 3600 s, the first of a list that is ours, each segment's MESSAGE put on record as it goes out) and OnSmsMessage (200 and the line for a report on a segment that was followed by the next, on a message that was sent and, with an RP-ERROR's cause, on one its wait had ended; 488 and its line for a stranger's). On the dev phone, with the binary of this range's last commit, no report came for a MESSAGE no longer in flight (the fp6 journal's 2026-11-20-issues-2-5 capture, phone-form6), so the 200 for one and its line have run in the suite alone. --- AGENTS.md | 52 ++++++++----- implementations/main.cpp | 5 +- interfaces/Imsd-Engine.cppm | 96 +++++++++++++++++++----- tests/Engine/main.cpp | 144 +++++++++++++++++++++--------------- 4 files changed, 203 insertions(+), 94 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 9f42bf4..4a1a256 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -47,7 +47,7 @@ PipeWire. The verified device/carrier combinations are in the README. | `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. | | `interfaces/Imsd-Ipsec.cppm` | `imsd::ipsec` — the two ESP SA pairs (TS 33.203) as `ip xfrm` argv lists, the Security-Server mechanism selection, and the reader that reconstructs SPIs/ports from `ip xfrm state`/`policy` text for a warm resume, and (1.0.0) `SaPeer`, the P-CSCF the kernel's pair is to, read from the `dir out` policies that carry imsd's fingerprint, `OwnXfrmDeleteCommands`, the deletes by exact key of what two rules select — the policies carrying imsd's fingerprint and the reqid-1/2 transport-mode ESP states in their direction or on the UE's ims-PDN address, whoever installed them (§12), and `FileNamesAnotherPair`, whether a state file's `spi_uc`/`spi_us` name the kernel's pair (unknown on either side decides nothing). | | `interfaces/Imsd-Messages.cppm` | `imsd::msg` — every SIP request and response imsd sends, built from an explicit `Context` and per-request variables so the builders are pure functions; `tests/Messages` is their suite. Also `IsEmergency`. Since 1.2.0 the SIP MESSAGE of SMS over IP (`BuildMessageSms`: an RP-DATA to the service centre's PSI, or an RP-ACK/RP-ERROR to the IP-SM-GW with In-Reply-To — TS 24.341 5.3.1.2 and 5.3.2.4), the `+g.3gpp.smsip` Contact tag behind `Context::smsOverIp`, `BuildResponse`, the final for an inbound MESSAGE outside a call's dialog (the 200, the 480, the 488): each Via row echoed in order and the To echoed with a tag added unless it already holds `tag=` (RFC 3261 8.2.6.2); since 1.2.1 `BuildBadRequest`, the 400 to a request cut short of the Content-Length read from it — any but an ACK or a CANCEL, in a call's dialog or not —, in that shape, a To tag it adds made from the request's header section and a secret of the run (RFC 3261 8.2.7); of requests that came whole, in-dialog requests, a MESSAGE among them, and the shell's answers to any other request outside a call — a NOTIFY, an OPTIONS, a method it does not handle; not an INVITE, whose 486 while a call exists is `BuildInviteResponse`'s — keep `BuildResponse200`'s hop-by-hop shape; and `ScPsi`, the service centre's PSI from its international number — never a dialled-number guess. | -| `interfaces/Imsd-Engine.cppm` | `imsd::engine` — the decisions as pure reducers: `CallMachine` (one call's dialog, returning `Action`s for the shell), `RegRecovery` (the registration recovery policy, §7.4) and, since 1.2.0, SMS over IP (§7.9): `SmsOutbound` (one short message of ours on its way to the service centre, segment by segment, returning `SmsAction`s) and `OnSmsMessage` (what an inbound MESSAGE outside a call's dialog leads to: its final, the message or status report it delivered, the delivery report to send), and `RecentTransactions` (an inbound request's retransmission — the same Call-ID, CSeq and Via branch within 32 s (`TimerJ`), the branch being the value of the first `branch=` of its first Via row and a request with none or an empty one never matched — answered with the same final and not handled again); `SameRecipient` and `StatusReportBook`, a status report's match to the message that asked for one — TP-MR and recipient — and its word for the whole message, with `SmsWordOrder`, the order of a message's words: the submission's first, a report's held until then (§7.9); `RunToken`, `SentSmsId` and `ReceivedSmsId`, the ids (§8.4); `StoredSms` with `FormatStoredSms`/`ParseStoredSms`, the record codec of the received-message store, and `StoredSmsBefore`, `List`'s order. | +| `interfaces/Imsd-Engine.cppm` | `imsd::engine` — the decisions as pure reducers: `CallMachine` (one call's dialog, returning `Action`s for the shell), `RegRecovery` (the registration recovery policy, §7.4) and, since 1.2.0, SMS over IP (§7.9): `SmsOutbound` (one short message of ours on its way to the service centre, segment by segment, returning `SmsAction`s) and `OnSmsMessage` (what an inbound MESSAGE outside a call's dialog leads to: its final, the message or status report it delivered, the delivery report to send), and `RecentTransactions` (an inbound request's retransmission — the same Call-ID, CSeq and Via branch within 32 s (`TimerJ`), the branch being the value of the first `branch=` of its first Via row and a request with none or an empty one never matched — answered with the same final and not handled again) and, since 1.2.1, `RecentSubmissions` (the Call-IDs of the MESSAGEs our submissions went out in, an hour each, by which a submit report for one that is no longer in flight is known for ours — TS 24.341 5.3.1.2); `SameRecipient` and `StatusReportBook`, a status report's match to the message that asked for one — TP-MR and recipient — and its word for the whole message, with `SmsWordOrder`, the order of a message's words: the submission's first, a report's held until then (§7.9); `RunToken`, `SentSmsId` and `ReceivedSmsId`, the ids (§8.4); `StoredSms` with `FormatStoredSms`/`ParseStoredSms`, the record codec of the received-message store, and `StoredSmsBefore`, `List`'s order. | | `interfaces/Imsd-Qmi.cppm` | `imsd::qmi` — the QMI WDS request bytes `imsd-pcscf` sends (Bind Mux Data Port, Set IP Family, Get Packet Service Status, Get Current Settings, Get Profile Settings), the message/TLV parser, the P-CSCF list readers (0x22 flag, 0x23 IPv4, 0x24 FQDN, 0x2E IPv6 — the last one libqmi does not model). | | `interfaces/ImsdBus.cppm` | `imsd::bus` — the polkit gate in front of call control and messaging (`Gated`'s `Action` parameter names the action), shared by imsd and imsd-ofonod. GLib, so outside `imsd-core`. | | `implementations/main.cpp` | The `imsd` daemon shell: GLib main loop, GDBus service, sockets, subprocesses, the registration sequence and the run loop that pumps the core. | @@ -157,7 +157,7 @@ judgement of the final's wait and of the report's after the server ports' drain, failure attributed by Call-ID, and the forwarding of a status report's word to the bus — the transactions themselves are `SmsOutbound` and `OnSmsMessage` (a submit report's routing to the message in flight, by -In-Reply-To, else RP-MR, is theirs), and the report's match to the message +In-Reply-To, else RP-MR, and past that to a MESSAGE of ours on record, is theirs), and the report's match to the message that asked for one `SameRecipient` and `StatusReportBook`, all with tests. The received-message store (§7.9) keeps in the shell, among others, the `link(2)` publish and its retry with the next id, @@ -378,10 +378,13 @@ What the suites pin: centre — and `OnSmsMessage`: a delivered message to the bus and its RP-ACK to the IP-SM-GW with In-Reply-To, a concatenated pair handed over once whole and each segment acknowledged, a status report, a submit - report routed to the message in flight (by In-Reply-To, else RP-MR), 488 - for one In-Reply-To no MESSAGE of ours in flight (a stranger's; ours once - ended; ours once its segment was superseded), 200 for one without - In-Reply-To for no message, an unusable TPDU acknowledged with an + report routed to the message in flight (by In-Reply-To, else RP-MR), 200 + and the journal's line for one In-Reply-To a MESSAGE of ours no longer + in flight (ours once ended, an RP-ERROR's cause in the line; ours once + its segment was followed by the next), 488 for a stranger's, 200 for one + without In-Reply-To that no message in flight owns; `RecentSubmissions`: a Call-ID on + record for 3600 s, the first of a list that is ours, each segment's + MESSAGE put on record as it goes out; an 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 whose header names come in compact form — the 200 and @@ -656,8 +659,10 @@ Rules: `r23-phone-journal-2026-10-17-precise-and-modem-sms`; whether KPN's SC sends them over this path is unknown), 8-bit data (an MMS notification), a message while SMS over IP is off (the 480), a submit - report In-Reply-To no MESSAGE of ours in flight (the 488) or one without - In-Reply-To for no message in flight (the 200), a page-mode MESSAGE, a body that is no RP message, a text + report In-Reply-To no MESSAGE of ours in flight (1.2.0's 488: since then + the 200 for one of ours on record and the 488 for one that names none, + each with a line of its own that no bench on hardware has written) or one without + In-Reply-To that no message in flight owns (the 200), a page-mode MESSAGE, a body that is no RP message, a text past 255 segments, an EF_SMSP record 1 that cannot be read or holds no service centre, or one whose service centre is not an international number, a @@ -1264,8 +1269,8 @@ emptied, never unlinked. The recovery policy's waits and the holds are measured on the boot clock (`CLOCK_BOOTTIME`), so a suspend counts; the keepalive refresh gate, the CRLF keepalive, the reg-event retry and renewal timers and the times SMS over IP measures (§7.9: its two waits, -the 30-minute age-out, the retransmission table's 32 s) run on the steady -clock and count awake seconds only. +the 30-minute age-out, the retransmission table's 32 s, the submissions +table's hour) run on the steady clock and count awake seconds only. The **reg-event subscription** (RFC 3680; the network's own view of the binding) is one live dialog per registration, subscribed anew ahead of the @@ -1601,8 +1606,11 @@ Lines the operator (and the scripts) look for, all prefixed `imsd: `: the delivered MESSAGE: no delivery report RP-ACK|RP-ERROR sent`; `status report from : TP-MR n to : … (discharged