A request that came in on a server port (the protected ports' TCP listeners and UDP sockets) was answered through a closure that kept a descriptor's number: its connection's over TCP, a socket's over UDP. The daemon closes a connection's descriptor when the peer has ended the connection, and the kernel gives a closed descriptor's number out again. A call's later answers go through the closure of the call's latest request when the user answers or refuses or the ringing ends (the 200 of an Accept, a 486, a 480): they were written to that number, whatever had it by then, the connection of whoever had connected since among them. A closure now keeps the port its request came in on and the peer it came from, or which of the two UDP ports its answer leaves by. Over TCP an answer is written to the newest connection the daemon holds from that peer to that port, and is not sent where it holds none: the journal says so once in a run. Over UDP it leaves from the socket its port has at that moment, if it has one. Tested: the daemon of this commit on the workstation against a stand-in network that closes the connection its INVITE came on while the call rings and then connects from another host, from another port, from the same port to the daemon's other port or from the same port to the same one, and one that resets the connection right behind its INVITE and makes it again (the fp6 journal's 2026-12-04-pani-in-dialog capture, bench/); and on the dev phone on KPN, where it answered a call that came in and the two requests that a text to the phone's own number brings (the journal's 2026-12-04-imsd-1.2.7-range-on-dev-phone capture).
3760 lines
265 KiB
Markdown
3760 lines
265 KiB
Markdown
<!-- SPDX-License-Identifier: GPL-3.0-only -->
|
||
<!-- SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts® -->
|
||
|
||
# AGENTS.md — working on imsd
|
||
|
||
This file is for coding agents and for anyone changing imsd: what the
|
||
repository contains, how it is built, tested and packaged, how the daemon
|
||
behaves at runtime, and the conventions a change has to follow. The README
|
||
is for users: what imsd is, how to install and configure it. The
|
||
configuration variables are documented there, not here (§10).
|
||
Where this file and the code disagree, the code is right and this file has a
|
||
bug — fix it in the same change.
|
||
|
||
## 1. What imsd is
|
||
|
||
imsd is a userspace IMS/VoLTE client for mainline Linux phones. The modem
|
||
firmware on such phones brings up the IMS PDN but cannot carry call audio, so
|
||
imsd does the whole IMS client itself: SIP registration — by default under
|
||
the identity the card's ISIM holds, else the one derived from the IMSI, with
|
||
AKA authentication in that ISIM, else in the USIM (§7.2) — over
|
||
kernel IPsec (ESP), call signalling for outgoing and
|
||
incoming calls, and the RTP media plane (AMR-WB, AMR, G.711) wired into
|
||
PipeWire, and since 1.2.0 short messages over IMS (TS 24.341: the SIP MESSAGE
|
||
carrying an RP-DATA, a store, the Messaging interface —
|
||
§7.9). A stock mobile dialer — Plasma Dialer, or GNOME Calls under Phosh
|
||
and GNOME Mobile — places and receives real VoLTE calls on a commercial
|
||
network through it.
|
||
|
||
It talks to the modem through ModemManager (`mmcli`) and `qmicli` over QRTR
|
||
(the AKA run and the read of an ISIM's identity files go through UIM logical
|
||
channels) and, for the P-CSCF list
|
||
the network put in the ims PDN's PCO, through its own QMI WDS client
|
||
(`imsd-pcscf`, a raw QRTR socket bound to the bearer's mux data port — §13),
|
||
installs its security
|
||
associations with `ip xfrm`, and plays and records audio with the PipeWire
|
||
tools (`pw-play`, `pw-record`). In practice that means a Qualcomm modem on a
|
||
mainline kernel with working WWAN/ModemManager integration, kernel ESP, and
|
||
PipeWire. The verified device/carrier combinations are in the README.
|
||
|
||
## 2. Repository layout
|
||
|
||
| Path | What it is |
|
||
|---|---|
|
||
| `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, `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. |
|
||
| `interfaces/Imsd-Ipsec.cppm` | `imsd::ipsec` — the two ESP SA pairs (TS 33.203) as `ip xfrm` argv lists, the ESP ciphers offered (`ParseEalgOffer`, `DefaultEalgOffer`), 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, since 1.2.1 a segment that gets no answer, or an RP-ERROR with cause 41, sent once more with TP-RD set — TS 23.040 9.2.3.6 —, 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. Since 1.2.5 also `WakeAt`: when the phone has to be awake for imsd (§7.10). |
|
||
| `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. |
|
||
| `implementations/media.cpp` | `imsd-media`, the per-call RTP leg, DTMF included (RFC 4733 events out, queued by `dtmf <tones>` lines on its stdin; the far end's events in, played as tones). Pure std + POSIX, dlopen's the AMR codecs. |
|
||
| `implementations/pcscf.cpp` | `imsd-pcscf`, the P-CSCF reader: the AF_QIPCRTR socket, the WDS service lookup and the Bind Mux Data Port / Set IP Family / Get Current Settings sequence around `Imsd:Qmi` (plus Get Profile Settings with `--profile`, Get Packet Service Status with `-v`). std + POSIX + the Linux QRTR UAPI (`<linux/qrtr.h>`), no GLib; never Start/Stop Network. |
|
||
| `implementations/dialerd.cpp` | `imsd-dialerd`, the Plasma Mobile session-bus backend (`org.kde.telephony.*`). |
|
||
| `implementations/ofonod.cpp` | `imsd-ofonod`, the GNOME Calls system-bus backend (`org.ofono`). |
|
||
| `tests/<Suite>/main.cpp` | The nine unit-test suites: `Util`, `Aka`, `Ipsec`, `Qmi`, `Messages`, `Engine`, `Sip`, `Sdp`, `Sms`. |
|
||
| `packaging/` | systemd units, the bring-up and upgrade scripts, D-Bus and polkit policies, presets, the gschema override, `APKBUILD.binary` and the CI helpers (§9). |
|
||
| `.forgejo/workflows/package.yml` | CI: builds the aarch64 apks on every push to `main` and publishes them to the Forgejo Alpine registry (§9.4). |
|
||
| `bin/`, `build/` | crafter-build's outputs and intermediates. Ignored. |
|
||
|
||
Also ignored by `.gitignore`, and never to be committed: `*.raw`, `*.rtp`,
|
||
`*.stats`, `imsreg.state`, `imsd-*.tar.gz` — captures and runtime state carry
|
||
the subscriber's IMSI/MSISDN and network addresses — and, of SMS over IP's
|
||
state, `sms-tpmr*` (the next TP-MR), `*.msg` and `*.msg.tmp` (the store's
|
||
records, the texts with their numbers).
|
||
|
||
## 3. Build products
|
||
|
||
Seven products come out of the tree. C++26 modules throughout, `import std;`
|
||
in every source but the re-exporting `Imsd.cppm`, clang + libc++ + lld.
|
||
|
||
| Product | Kind | Built from | Links | Notes |
|
||
|---|---|---|---|---|
|
||
| `imsd-core` | static library | the `Imsd` module and its nine partitions | — | Pure `import std` C++, no GLib, no I/O side effects: every message, digest, SA command and call-state decision is here and unit-testable on any dev box without a bus, a modem or a phone. |
|
||
| `imsd` | executable | `implementations/main.cpp` | `imsd-core`, `imsd-bus`, gio-2.0, pthread | The daemon. Default product. |
|
||
| `imsd-bus` | static library | `interfaces/ImsdBus.cppm` | gio-2.0 | The polkit gate (`net.catcrafts.IMS1.Voice`; since 1.2.0 `net.catcrafts.IMS1.Messaging` too) imsd and imsd-ofonod both link. A translation daemon that runs as root on the system bus reaches imsd as root, which polkit always allows, so it gates its own callers through this or it is a bypass. |
|
||
| `imsd-media` | executable | `implementations/media.cpp` | `-ldl -lpthread` | The RTP/AMR data plane, spawned once per call. No GLib, no core. A separate process for crash isolation and for the far-end-hangup exit-code contract (§7.6). `-- --product=media`. |
|
||
| `imsd-dialerd` | executable | `implementations/dialerd.cpp` | gio-2.0 | Plasma Mobile integration: a session daemon owning `org.kde.telephony.{CallUtils,DeviceUtils,UssdUtils}`, bridging to imsd. GDBus translation only. A separate process because those are per-user session-bus names a root system daemon cannot own. `-- --product=dialerd`. |
|
||
| `imsd-ofonod` | executable | `implementations/ofonod.cpp` | `imsd-bus`, gio-2.0 | GNOME Calls integration: a system daemon owning `org.ofono`, presenting imsd as an oFono modem. GDBus translation plus the polkit gate on its own callers. `-- --product=ofonod`. |
|
||
| `imsd-pcscf` | executable | `implementations/pcscf.cpp` | `imsd-core` | The P-CSCF reader `ims-pdn-up.sh` runs once the ims PDN is up (§7.3): one QMI WDS client over a raw QRTR socket, bound to the bearer's mux data port, asking for the call's runtime settings. Prints the PCO's P-CSCF list; never sends Start Network or Stop Network (its writes are its own client's mux binding and IP family, §12), and the call stayed connected and the registration stood after it (§13). Built with `-- --product=pcscf`. |
|
||
|
||
The rule behind the split: **`imsd-core` stays GLib-free and free of I/O so
|
||
that every decision in it has a unit test.** New protocol logic goes into a
|
||
partition with a test. The shell (`main.cpp`; from 1.0.0 also `pcscf.cpp`'s
|
||
QRTR control lookup and its matching of answers by type, transaction and
|
||
message id) holds protocol decisions no
|
||
test reaches — some older than 0.3.10, some added by a release since: the P-CSCF in
|
||
use (`pcscf_`: the kernel's SA peer at a resume, `PCSCF=` or the first of
|
||
`PCSCF_DISCOVERED=` at a fresh registration, the move between them and back —
|
||
§7.2); the reg-event
|
||
subscription schedule (§7.4: its retry
|
||
ladder, Retry-After clamp, Timer F, renewal point and RFC 6665 reasons); the
|
||
registration sequence and its transactions (`AwaitFinal`/`AwaitInitialFinal`:
|
||
which message is a REGISTER's final, the dispatch of requests arriving
|
||
meanwhile and the routing of our reg-event SUBSCRIBE's final read there, the
|
||
12 s wait restarted on a provisional); the reregistration's headers and its
|
||
answer to a challenge (`Reregister`: the stored challenge answer, or the empty
|
||
digest for a pre-0.3.11 state file, the new SPIs, `PortUcNext`; a 401 thrown
|
||
as a refusal carrying its status; and, since 1.2.5, the number it takes,
|
||
used and written to the state file once the REGISTER is sent, §7.2
|
||
step 5 and §5); the state-file round trip
|
||
(`PersistState`/`LoadState`: the `security_server` key, written empty for a
|
||
value with a quote, a backslash or a newline — the choice between that list
|
||
and the entry rebuilt from the SA is `Imsd:Ipsec`'s, with a test); the
|
||
inputs to `RegRecovery` — `SipFlow::Connect`'s split of failures into local
|
||
refusals and network silence, and the catch sites that sort a failed refresh
|
||
(the keepalive's, `ReconnectCycle`'s) and a failed fresh attempt
|
||
(`FreshRecover`, `DeferBringUp`) into Refused, Silent or Throttled with the
|
||
status, the Retry-After and `saReplaced_`, the bring-up resume's catch (a
|
||
refusal's Retry-After fed as a hold, the old registration written off after
|
||
a failed resume that a fresh registration follows; with no fresh target only
|
||
a pair nothing can resume is written off — a 403 once fresh is due or a
|
||
binding a NOTIFY terminated under the attempt counts as one by the engine's
|
||
rule, and so does a resume it gives up: a 401, a refusal with a Retry-After,
|
||
the second refusal, the count travelling in the holds (`Reconnectable()` and
|
||
`Fresh()`, decided once after both catch arms) — and taken out of the kernel,
|
||
§7.2 step 1), the `OnLink` read that writes the old registration off
|
||
when its address has left the netdev (`FreshRecover` after a failed move,
|
||
`AddressGone`), `PacketServiceUp`'s read of
|
||
ModemManager before a silent cycle is counted and, since 1.2.5, before
|
||
every reconnect cycle and every fresh registration of the recovery
|
||
(`NoService`; a bring-up's registrations and the connect for a call's
|
||
resend do not ask), and the shell's word that the network has answered,
|
||
which starts a coverage gap's counts over (`OnNetworkAnswered`: an
|
||
answered TCP connect of the resume or of a reconnect, a response to a
|
||
REGISTER); the no-target reads and
|
||
reactions (1.0.0): the kernel text behind `SaPeer`, the holds' `old_gone`
|
||
and the script's `PCSCF_DISCOVERY=` — whether a pair is resumable (`SaPeer`
|
||
finds one and the holds' `old_gone` does not write it off: `!peer ||
|
||
writtenOff` in `main()`) and the choice of the idle or the fatal are shell
|
||
code — at `main()`'s idle before the bus name (a pair the holds wrote off
|
||
taken out of the kernel on the way) and at the no-target bring-up's write-off
|
||
of a dead pair, its removal and the idle or the fatal that follows (§7.3);
|
||
and the xfrm deletes the SA setup and the dead pair's teardown run —
|
||
`OwnXfrmDeleteCommands` builds them from the kernel text, with a test; the
|
||
shell reads that text and runs them (§12);
|
||
the shell's reaction to a NOTIFY
|
||
terminating our binding (the flow closed at once, or kept under a call and
|
||
closed when the call ends, a reconnect cycle's or the bring-up resume's wait
|
||
ended by it — the reducer's verdict is pinned, the reaction is not); and the
|
||
holds file's codec (`PersistHolds`/`LoadHolds`: aging by boot seconds, the
|
||
pdn/boot match, defaults for absent keys — proven on the phone only, captures
|
||
45- and 70- of 2026-09-25-polkit-voice; the `pdn` compare in canonical form on
|
||
both sides (1.0.0) is unbenched: no capture stages a holds file whose `pdn` is
|
||
spelled unlike `LOCAL`). For the schedule, a reducer next to
|
||
`RegRecovery`, with a Subscription-State parser in `Imsd:Sip` pinned by
|
||
`tests/Sip`, is the follow-up that moves it; a pure format/parse pair in
|
||
`Imsd:Engine` is the holds file's. The card's side (1.2.3, §7.2 step 2)
|
||
keeps in the shell the choice of the identity (`BringUp`: `ISIM=0`, no ISIM
|
||
application in the USIM's slot, an ISIM that gave none, and `FreshRecover`'s
|
||
asking of such an ISIM again), the read itself
|
||
(`ReadIsimIdentity`: the three files and their order, record 1 of EF_IMPU,
|
||
a SELECT's `61 XX` taken for the file selected, what its `why` says), the
|
||
channel (`UimChannel`: the open, the exchanges, the two follow-ups at most,
|
||
the close), the application the challenge goes to with its
|
||
fall-back to the USIM and the journal's words for an answer that is no
|
||
result (`Authenticate`, `AkaIn`), and which identity a
|
||
registration carries: the card's at a fresh registration, the one it was
|
||
made under at a resume (`TryResume`: the state file's three names, the
|
||
derived ones for a file that has none; `FreshRegister`'s restore after a
|
||
failed attempt) — the commands, the
|
||
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 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
|
||
the workstation and on the dev phone (§5). The sleep inhibitor for a call
|
||
(1.2.5, §7.6) is all in the shell (`HoldSleepOff` and its callers);
|
||
what of it ran against a stand-in logind on the workstation and what on
|
||
the dev phone is in §5. The registration through a
|
||
sleep (1.2.5, §7.10) is the shell's but for when the phone has to be
|
||
awake (`WakeAt`) and the policy's wake after a local wait
|
||
(`RegRecovery::WakeTime`), which are `Imsd:Engine`'s, with tests; §7.10
|
||
has what the shell does for it, and §5 what of that ran against
|
||
stand-ins on the workstation and what on the dev phone. Where an answer
|
||
goes that the server ports send (§12: the connection found by its port
|
||
and its peer, an answer that is not sent, the socket a datagram leaves
|
||
from) is the shell's (`ServerPorts`); §5 has what of it ran against a
|
||
stand-in network on the workstation and what on the dev phone. SMS over IP
|
||
(1.2.0, §7.9) keeps in the
|
||
shell, among others, the service centre's source (`SMSC=` over EF_SMSP, `LoadSmsParameters`),
|
||
the three counters (TP-MR, RP-MR, the concatenation reference), their
|
||
seeding and the TP-MR file, the routing of an inbound MESSAGE
|
||
(`DispatchRequest`: to the call when it carries the live call's Call-ID,
|
||
else through `OnInboundMessage` to `OnSmsMessage`), the one-at-a-time
|
||
queue, a `Send` failed when the engine takes it up unregistered or with
|
||
the flow down, a queued message started without that check, the
|
||
status-report book's entries (made at a message's start, and only for one
|
||
that asked for a report: `StartNextSms`), the routing of a MESSAGE
|
||
final to the message in flight (`OnSmsResponse` — ahead of the reg-event
|
||
subscription's handler in the run loop, after it inside `AwaitFinal`), the
|
||
judgement of the final's wait and of the report's after the server ports' drain and the read of what
|
||
the client flow already holds, the reassembler's
|
||
30-minute age-out in the run loop, the retransmission check around
|
||
`OnSmsMessage`, the delivery reports' finals (`reportCallIds_`), a send
|
||
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, 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,
|
||
the sweep of `.tmp` files at the engine's start, `Delete`'s id check and its
|
||
answers by the removal's outcome, `List`'s skip of a file that is no record, its `IOError`
|
||
for a store it could not read, the count the `stored` line loses for one, and the delivery
|
||
report a store failure leaves unchanged; the record codec and `List`'s
|
||
order are the core's, with tests.
|
||
|
||
## 4. Building
|
||
|
||
### 4.1 Native, with crafter-build
|
||
|
||
crafter-build is the Crafter.Build Flatpak. It carries its own clang, lld and
|
||
libc++, and its SDK (org.freedesktop.Sdk, from Flathub) has the gio-2.0
|
||
headers, so the host needs Flatpak and nothing else:
|
||
|
||
```sh
|
||
flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
|
||
flatpak remote-add --if-not-exists catcrafts https://flatpak.catcrafts.net/catcrafts.flatpakrepo
|
||
flatpak install catcrafts net.catcrafts.CrafterBuild//stable
|
||
mkdir -p ~/.local/bin
|
||
printf '#!/bin/sh\nexec flatpak run net.catcrafts.CrafterBuild//stable "$@"\n' > ~/.local/bin/crafter-build
|
||
chmod +x ~/.local/bin/crafter-build
|
||
```
|
||
|
||
`crafter-build` is a script and not an alias so that the name also resolves in
|
||
a shell that has not defined the alias (a fresh `bash -c`, a CI step);
|
||
`~/.local/bin` has to be on `PATH` (any directory on it will do). The
|
||
sandbox does not see the host's `/tmp`: keep the checkout under `/home`, or
|
||
grant its directory with `flatpak run --filesystem=<dir>`.
|
||
|
||
```sh
|
||
crafter-build # bin/imsd-<target>-<march>-<mtune>-<id>/imsd
|
||
crafter-build -- --product=media # bin/imsd-media-…/imsd-media
|
||
crafter-build -- --product=dialerd # bin/imsd-dialerd-…/imsd-dialerd
|
||
crafter-build -- --product=ofonod # bin/imsd-ofonod-…/imsd-ofonod
|
||
crafter-build -- --product=pcscf # bin/imsd-pcscf-…/imsd-pcscf
|
||
crafter-build test # the nine unit-test suites
|
||
```
|
||
|
||
Output directories under `bin/` are named `<product>-<target>-<march>-<mtune>-<id>`;
|
||
the `./bin/imsd-*/imsd` globs in §8.3 rely on that.
|
||
|
||
A host-native binary built this way links the Flatpak's libc++ through an
|
||
rpath into `/app/lib`: run it inside the sandbox (`flatpak run --command=sh
|
||
net.catcrafts.CrafterBuild//stable`, with `--socket=session-bus` for §8.3's
|
||
daemons — the sandbox's own session bus is a filter that refuses their names;
|
||
`crafter-build test` runs the suites there
|
||
anyway). A sysroot
|
||
build (§4.2) gets no such rpath — it links the sysroot's libc++.
|
||
|
||
### 4.2 Cross-compiling for a phone (aarch64 Alpine / postmarketOS)
|
||
|
||
```sh
|
||
packaging/make-sysroot.sh # one-time: Alpine aarch64 sysroot from the CDN (edge)
|
||
crafter-build -- --target=aarch64-alpine-linux-musl \
|
||
--sysroot=$HOME/.cache/imsd/sysroot-aarch64-alpine \
|
||
--march=armv8.6-a+fp16fml+aes+sha3+sm4 --mtune=cortex-a720
|
||
# `crafter-build test` with the same flags fails: its runner is qemu-aarch64,
|
||
# which the Flatpak's sandbox does not have. Test host-native (§4.1).
|
||
```
|
||
|
||
`make-sysroot.sh` needs no root, qemu or device: it downloads
|
||
`apk-tools-static` and the Alpine keys and populates a minimal rootfs (musl,
|
||
libc++ with its std module source, glib and their headers, compiler-rt,
|
||
libunwind, linux-headers for `imsd-pcscf`'s `<linux/qrtr.h>`, gcc for its
|
||
`crtbeginS.o`/libgcc, which clang's `*-alpine-linux-musl` driver links
|
||
against). In a cross build `project.cpp` does not ask the host's pkg-config
|
||
(it would answer for the wrong architecture); it adds `-I=/usr/include/glib-2.0`
|
||
and `-I=/usr/lib/glib-2.0/include`, which clang resolves inside the sysroot.
|
||
crafter-build compiles the std module against the sysroot's libc++ headers
|
||
from the sysroot's own source — Alpine's `llvm-runtimes`, the same release
|
||
as its libc++, which `make-sysroot.sh` installs (`libc++-dev` ships none);
|
||
run over an existing sysroot the script upgrades its packages (`apk add
|
||
--upgrade`).
|
||
Without that source it falls back to the toolchain's source for the same libc++
|
||
major release, then to the sources Crafter.Build carries for other
|
||
releases. This is the flow CI runs (§9.4).
|
||
|
||
## 5. Tests
|
||
|
||
`crafter-build test` runs the nine suites. Each suite
|
||
is a plain `main()` with a `Check(bool, message)` counter: failures print
|
||
`FAIL: …`, success prints `<Suite>: all tests passed`, and the exit status is
|
||
1 after any failure. `crafter-build test` ending in `9 passed`, on every
|
||
commit of a range (§11), is the project's definition of green.
|
||
|
||
What the suites pin:
|
||
|
||
- `Util` — tokens, IPv6 detection and host/port formatting, the RFC 5952 §4
|
||
form (the RFC's §4.1–4.2.3 examples, idempotence on `inet_ntop`-shaped
|
||
text, what is refused), the address-list parser, the count of seconds
|
||
a setting names (`WholeSeconds`: digits and nothing else; a sign, a
|
||
unit, a fraction, a blank, `0x1e`, `1e2`, `nan`, `inf` and a number too
|
||
large are refused), hex/base64, MD5.
|
||
- `Aka` — the AKAv1-MD5 digest, identity derivation, the `qmicli`/`mmcli`
|
||
text parsers, the AUTHENTICATE APDU and its response parser, the class
|
||
byte of a command on a logical channel (the channel itself for 0 to 3,
|
||
`4X` for 4 to 19 — TS 102 221 10.1.1; AUTHENTICATE on channels 3 and
|
||
4, GET RESPONSE on channel 7); the ISIM application of a slot (a card with a `ready` USIM and
|
||
a `detected` ISIM in one slot, in either order — the applications, states
|
||
and AIDs the fp6 journal's probe read off a reporter's card, 2026-11-23,
|
||
in the lines qmicli prints for an application —; another slot's ISIM not
|
||
taken, a twelve-byte AID, a CSIM, a missing state line) and the slot of
|
||
a line whose number does not parse, the SELECT and the READ
|
||
commands byte for byte on standard and extended channels, a card's answer
|
||
and its follow-up (`61 XX`, `6C XX` to a read and to a command with
|
||
data, an error, data with `61 XX`; `91 XX` and `92 XX` normal endings,
|
||
`90 01` and `93 00` none; a read's data
|
||
taken under `62 82`, not under `62 81` or `63 82`), `ParseIsimValue` (the
|
||
three length forms, the padding after the object and `FF` at the end of
|
||
its length, an unused record, another tag, a length past the data, a
|
||
blank, a line break, a NUL, an `FF` before the value's end, a byte above
|
||
ASCII) and `IsimIdentity` (names unlike the derived ones, the derived
|
||
ones themselves, and what is refused: a private identity without an `@`
|
||
between two parts, a domain that is not labels of letters, digits and
|
||
inner hyphens or that has a label of 64 characters or 254 characters in
|
||
all, a public identity that does not begin `sip:` or
|
||
is that alone, a private or a public identity of 256 characters, a
|
||
quote, a backslash, an angle bracket, a blank or a line break in one of
|
||
the three).
|
||
- `Ipsec` — the exact `ip xfrm` argv lists for the SA pairs, the `EALG`
|
||
setting, the Security-Server mechanism selection against one offered
|
||
cipher and against two (KPN's entry and Odido's, O2's six with the SPIs
|
||
on the null entry and on the aes-cbc one, a list whose every entry
|
||
carries them), the SA reader (the entry it
|
||
rebuilds names the pair's integrity algorithm and cipher, read from the
|
||
lines the kernel prints for them), the SA peer
|
||
(`SaPeer`: the one address a reqid-1 and a reqid-2 `dir out` transport
|
||
policy both name with imsd's protected port as the selector's sport — the
|
||
fingerprint —, the pair kept beside a VPN's policies;
|
||
a lone or disagreeing policy names no
|
||
peer), `FileNamesAnotherPair` (the pair's own SPIs, other SPIs, one
|
||
differing, no keys, a 0 from a missing inbound state, zeros in the file),
|
||
and `OwnXfrmDeleteCommands` (our pair's eight deletes byte-exact on
|
||
the fixture in the registered FP6's shape (synthetic addresses and keys), a VPN's tunnel SA and policies beside it
|
||
untouched, another transport-mode user's pair on other ports and addresses
|
||
untouched — its reqid-1 ESP state on the UE's address deleted, its AH state
|
||
left —, a policy-less state on the UE's address deleted, one between
|
||
other addresses left).
|
||
- `Qmi` — the request bytes `imsd-pcscf` sends (four of the five the probe's,
|
||
byte for byte; Get Profile Settings is the helper's own, answered by the
|
||
modem on the dev phone in the probe capture's `--profile 2 -v` run and on the dev phone's bring-up
|
||
discoveries (the 2026-10-11/12 KPN bench), which pass `--profile` when the
|
||
ims profile index is known — the `profile-pcscf-via-pco` flag line),
|
||
the parser on the modem's 163-byte Get Current Settings answer in its exact
|
||
TLV shape (addresses re-encoded to `2001:db8::/32`), the OutOfCall answer,
|
||
the IPv4/FQDN list readers on synthetic lists, the tolerance of a count
|
||
that disagrees with a length, short and overrunning buffers, the
|
||
packet-service-status and profile PCSCF-via-PCO readers (present and absent
|
||
TLVs) and the error names (OutOfCall, NoEffect, an unknown code as `?`).
|
||
- `Messages` — the outgoing SIP messages: the initial and the protected
|
||
REGISTER, the reg-event SUBSCRIBE and the INVITEs byte-for-byte, their
|
||
variants (a Security-Client for another offer among them; the two
|
||
REGISTERs of an identity an ISIM holds, byte for byte the pinned ones
|
||
with the card's names for the derived ones, and `RuriFor` at an
|
||
ISIM's home domain; the INVITE, its CANCEL and its two ACKs for a dialog
|
||
whose sequence number, session interval and `Min-SE` are not 1, 1800
|
||
and 90), the in-dialog
|
||
requests, the ACKs, the CANCEL and
|
||
`BuildResponse200` by their lines, `BuildInviteResponse` by the lines of
|
||
one 180 and by a 486 without a Record-Route (`tests/Engine` checks the
|
||
responses `CallMachine` builds with it); the
|
||
SMS over IP shapes (the
|
||
`+g.3gpp.smsip` tag, the MESSAGE with an RP-DATA, the delivery report
|
||
with In-Reply-To, a 488) pinned against TS 24.341's clauses; `BuildResponse`,
|
||
`BuildResponse200` and `BuildInviteResponse` on a request whose header
|
||
names come in compact form; `BuildBadRequest` by the lines of one 400
|
||
(every Via row echoed; the To tag sixteen hex digits of the MD5 of a
|
||
secret and the header section, the expected one from Python's hashlib;
|
||
the same request, the same 400; another request, another tag; another
|
||
secret, another tag; a To's own tag kept).
|
||
- `Sip` — the text layer's edge cases (empty header values, line anchoring,
|
||
keepalive discards, a header read that stops at the first empty line — a
|
||
body line spelling a header name picks nothing, leading empty lines are
|
||
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, 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
|
||
version, a first line that ends in another version, in seven other
|
||
bytes or in more than the version, bytes that are no SIP, an ACK or a
|
||
CANCEL; for a MESSAGE, a header section exactly where
|
||
`DatagramMessage` calls the datagram truncated), the twelve compact forms (each through `Header`, in lower and
|
||
in upper case, and through `Headers`; no other letter taken for a
|
||
header name the suite lists; `l:` through the framer and
|
||
`DatagramMessage`), `ViaResponsePort`'s reading of a Via row — `rport` by its name (in
|
||
another case, with white space around it, with a value; those letters
|
||
in a value, in a longer name or in a quoted string not; a quoted string
|
||
ended by its closing quote — not by a quoted pair in it, and by the
|
||
quote behind an escaped backslash —), and of a row that holds a list
|
||
the top value alone (its port, a later value's `rport` and port not
|
||
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), `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
|
||
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, `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
|
||
type at the chosen codec's clock among it), `BuildAnswer` at the offer's
|
||
own payload types and octet-align mode, the `CODECS` override.
|
||
- `Sms` — the short message codecs byte for byte: the GSM 7-bit alphabet,
|
||
its extension table and the septet packing (the classic "hellohello"
|
||
vector), UCS-2 with surrogate pairs (and U+0000 as U+FFFD), the address fields (international,
|
||
a short code, `*`/`#`, an alphanumeric sender), SMS-SUBMIT (the classic
|
||
tutorial PDU, UCS-2, one with TP-RD, the concatenated pair for a
|
||
161-character text and the one for a 71-character text in UCS-2, an
|
||
escape pair and a surrogate pair kept whole at a segment boundary, the
|
||
160/70-character fits), SMS-DELIVER (the classic "How are you?" PDU; a
|
||
header with fill bits, a 16-bit concatenation reference, class 0,
|
||
port-addressed 8-bit data, a negative time zone — the vectors
|
||
cross-generated by the fp6 journal's Python reference,
|
||
`utilities/smsref.py` — and short user data, the 'Test' vector with its
|
||
TP-UDL raised by hand), the DCS groups, SMS-STATUS-REPORT (its TP-ST as
|
||
TS 23.040 9.2.3.15 has the MS read it: every reserved value, bit 7 set
|
||
among them, as "Service Rejected") and
|
||
SMS-SUBMIT-REPORT, RP-DATA / RP-ACK / RP-ERROR both ways (a type read
|
||
against its direction refused), which RP causes of a submission have the
|
||
segment sent again (all 128 values), EF_SMSP on the KPN SIM's record (dev
|
||
phone, 2026-10-16) straight from qmicli's dump, and the `Reassembler`
|
||
(segments out of order, a lone message, a set dropped by `Purge`, a
|
||
surrogate pair and an escape pair split across two segments whole
|
||
again).
|
||
- `Engine` — the call state machine driven through recorded network dialogs
|
||
(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 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
|
||
string past `DtmfMaxTones`; the receive payload type: our offer's on a
|
||
renumbered answer, the answer's when the audio took ours, the echoed
|
||
offer's on an incoming call; an incoming call from an INVITE, and an
|
||
outgoing call from responses, whose header names come in compact form) and
|
||
`RegRecovery` (thresholds, backoffs, the throttle
|
||
schedule, Retry-After, which waits a Dial may cut short, when the old
|
||
registration counts as gone, the holds a restart takes over, a binding the
|
||
network terminated; the look after a local wait: 5 s after the
|
||
refusal is reported, and the time a sleeping phone is to be woken for
|
||
it, 10 s to 15 min by value, counted for no packet service from the
|
||
modem's first such word since the network's last answer and for the
|
||
kernel's refusals (the kind of a refusal that names none) from the
|
||
first since the modem was last without service or the network last
|
||
answered, where what starts a count over is the shell's word of an
|
||
answer, a refused reconnect, a refused or throttled fresh attempt or
|
||
a terminated binding, and not a silent cycle or attempt (a success
|
||
starts everything over); a step that
|
||
follows no local wait, and a
|
||
registration written off meanwhile, at the policy's own time) and
|
||
`WakeAt` (when the phone has to be awake for imsd: now while a call
|
||
or a text is in flight; with a registration on a live flow the
|
||
refresh's due time or the subscription's renewal, whichever comes
|
||
first; with a dead flow under a registration the recovery's word,
|
||
a due step as now; never where nothing waits);
|
||
and SMS over IP (TS 24.341): `SmsOutbound` through a
|
||
submission — the MESSAGE with the RP-DATA to the SC's PSI, its 202, the
|
||
RP-ACK ending it as sent with the SC's time stamp; a refused final; an
|
||
RP-ERROR with its cause and TP-FCS; the final's wait and the report's
|
||
running out (128 s and 130 s), each followed by the segment's repeat — the same
|
||
SMS-SUBMIT with TP-RD set and no other bit changed, under a Call-ID and
|
||
an RP-MR of its own — and the repeat accepted, rejected as a duplicate
|
||
(sent, with RP cause 41 as with another) or ended in its turn (failed,
|
||
both ends in the reason); a
|
||
duplicate rejection of a first attempt, a refusal like any other (RP
|
||
cause 21: failed), and one of a repeat whose first attempt an RP-ERROR
|
||
had refused, before the repeat went out or after (failed, both refusals
|
||
in the reason); the first attempt's
|
||
RP-ACK after the repeat went out taken by In-Reply-To and by RP-MR, its
|
||
RP-ERROR then — cause 41 or 28 — leaving the segment to the repeat's
|
||
answer (sent on its RP-ACK; failed on its wait, that RP-ERROR named as
|
||
the first attempt's end); an RP-ERROR with cause 41 repeated, and one
|
||
with a cause part 1 does not list (0, 2); one with 38, 42 or 47 failing
|
||
at once; a first segment's RP-ERROR not weighing
|
||
on the second segment's repeat; a 408 and a 504 final repeated,
|
||
a 403, a 480, a 500 and a 503 failing at once; a repeat the flow could
|
||
not send; a
|
||
failed send; two segments with consecutive RP-MR/TP-MR, the second sent
|
||
on the first's RP-ACK, a repeat under the next RP-MR; a destination that is no number; no service
|
||
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), 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
|
||
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; a delivered MESSAGE whose Content-Type came folded,
|
||
taken for a short message once the datagram framer has unfolded it;
|
||
a class 2 message kept from the bus and refused with an RP-ERROR (cause
|
||
111, TP-FCS 0xFF) — a (U)SIM data download, a text, a segment of a set —
|
||
or, naming no gateway, kept from the bus with no report; the other
|
||
classes, TP-PID 0x7F without class 2, and a short message type 0 with a
|
||
class 2 coding, received;
|
||
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,
|
||
a delivery with no gateway for its report handed over with the absence
|
||
logged;
|
||
`StatusReportBook` and `SameRecipient`: a two-segment message delivered
|
||
with its last segment, a delivered TP-MR forgotten, another recipient no
|
||
match, a temporary status pending with the entry kept, a permanent
|
||
failure the message's last word (a later segment finds nothing), a
|
||
reused TP-MR forgetting the older message whole, a message forgotten
|
||
whole by its id (`ForgetMessage`) with the other left on record; a number dialled
|
||
with a trunk 0, with `00` or — a US number — without its country code
|
||
matched against its international form; another number, `+31612345678`
|
||
against `+49612345678`, a short code against a longer number that ends in
|
||
it and an empty one not;
|
||
`SmsWordOrder`: a report on a message whose submission ended posted at
|
||
once, one on the message in flight held and posted after `sent`, a
|
||
`failed` after a held `delivered` posted as `sent` then `delivered`, any
|
||
other `failed` posted alone with the message to forget, another
|
||
message's submission leaving the held word alone; the ids (`RunToken`,
|
||
`SentSmsId`, `ReceivedSmsId`): eight zero-padded hex digits, the sent
|
||
and the received shape, two tokens' ids apart at the same second and
|
||
counter, the longest received id no longer than 64 bytes;
|
||
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 `List`'s order (`StoredSmsBefore`: the arrival
|
||
second, then within a run the sequence number — -9 before -10);
|
||
and `RecentTransactions`: a retransmitted request gets its final again,
|
||
for 32 s (`TimerJ`); no branch, no match.
|
||
|
||
Rules:
|
||
|
||
- A decision in `imsd-core` gets a test in the suite that owns the partition.
|
||
Fixtures are recorded network traffic where any exists, inline fixtures
|
||
only where no recording exists.
|
||
- Behaviour that lives in the shell (`main.cpp`: timers, the reg-event
|
||
subscription schedule, the audio-session resolution, the hand-over scripts)
|
||
is proven on a phone where a bench can reach it; the commit message says
|
||
in one sentence that it was tested, and the arms no bench has reached are
|
||
named here. The known gaps: the reg-event subscription schedule (the
|
||
arming and KPN's
|
||
`noresource` closure have run on hardware, the 60 s retry only on a
|
||
pre-fix build that renewed that closure, and the renewal firing on
|
||
the workstation, with the boot clock set ahead, 1.2.5's record below;
|
||
the retry on this code, Timer F, the doubling, a SUBSCRIBE
|
||
`Retry-After`, the
|
||
renew arm and the back-off's survival across a refresh have run nowhere —
|
||
§3, §7.4); a `Dial` bringing a recovery step
|
||
forward (imsd-ofonod refuses the `Dial` itself and imsd-dialerd forwards
|
||
it) has run on the workstation in a coverage gap, where the step it
|
||
brought forward was the look at the modem (1.2.5's record below); one
|
||
that brings a reconnect, or a fresh attempt that is due, forward is
|
||
pinned in `tests/Engine` only;
|
||
the escalation by one refused refresh that carries a `Retry-After` — the
|
||
escalation to a fresh registration is pinned in `tests/Engine` only; a
|
||
resume echoing a multi-mechanism Security-Server list on the wire (the
|
||
choice of the stored list is pinned in `tests/Ipsec` with O2's recorded
|
||
list; KPN's has one mechanism, so on the bench the stored value and the
|
||
rebuilt one are the same bytes; O2's six-entry list has not resumed on
|
||
this code, and the state-file round trip is shell code no test
|
||
reaches); a resume whose rebuilt entry names another algorithm than
|
||
`hmac-sha-1-96` or another cipher than `aes-cbc` (pinned in `tests/Ipsec`
|
||
on the lines `ip xfrm state` prints; no such pair has been resumed on a
|
||
network); a list that marks one of two offered ciphers (pinned in
|
||
`tests/Ipsec` with two of O2's recorded lists, each its answer to an
|
||
offer of one cipher, and run against a stand-in P-CSCF that marks the
|
||
lower-q of the two as far as the `SA:` line; no capture holds O2's
|
||
answer to imsd offering two); the default offer's null cipher taken
|
||
by a network (KPN named `aes-cbc` to the two-cipher offer at a fresh
|
||
registration and answered a reregistration that carried it 200: the dev
|
||
phone, 2026-11-22, an earlier build of this change, on 1.2.0; the
|
||
selection of a null entry is pinned in `tests/Ipsec` with Odido's answer
|
||
of 2026-07-13 to the Python stack's offer of the null cipher and ran
|
||
against a stand-in P-CSCF on the workstation as far as the `SA:` line;
|
||
no capture holds a registration of imsd's over a null SA pair); an
|
||
ISIM's identity and an AKA in an ISIM (1.2.3; the dev phone's card has no
|
||
ISIM: the daemon ran its registration on the workstation against a
|
||
stand-in for qmicli and a stand-in network that answers a first REGISTER
|
||
of any other names than its subscriber's 480 and tells the two
|
||
applications' answers to the challenge apart — the fp6 journal's
|
||
`2026-11-23-isim-identity` capture, 46 scenarios: a card without an
|
||
ISIM, an ISIM that holds names of the operator's own and one that holds
|
||
the derived names, `ISIM=0`, another slot's ISIM, an ISIM listed `ready`
|
||
or with no state; an ISIM that gives no identity (no channel, no answer
|
||
to a SELECT, to a read or to the GET RESPONSE after one, no EF_DOMAIN,
|
||
a refused read, an
|
||
unused or a `tel:` first record of EF_IMPU, a private identity without
|
||
a realm); reads answered `6C XX` or `61 XX` first, one after the other,
|
||
or `61 XX` to every GET RESPONSE (two are sent, then the read counts as
|
||
failed), reads that end `91 XX` or `62 82`, and a length that counts
|
||
the padding in; channels 4 and 5; an ISIM that refuses the AUTHENTICATE
|
||
or answers a
|
||
synchronisation failure, the USIM asked after it; no application giving
|
||
a result (both refusing; a USIM with no channel, with an answer of one
|
||
byte, of bytes that are no result, with no answer to the AUTHENTICATE
|
||
or to the GET RESPONSE after it); the registration
|
||
made again over UDP; a second bring-up in one run at which the ISIM
|
||
gives none; resumes — of a registration of a card without an ISIM, of
|
||
one made under the ISIM's names, with and without `ISIM=0` at the
|
||
restart, of one 1.2.2 made under the derived names on a card whose ISIM
|
||
holds others (kept under the derived names; refused by a network that
|
||
knows the card's names only, and registered fresh under those), of a
|
||
state file whose identity fails the check, with a fresh target and
|
||
without (also under a forced `SIP_TRANSPORT` that is not the file's), or
|
||
lacks one of the three names — and, in a run that resumed, a
|
||
fresh registration the network refuses (the reconnect after it goes out
|
||
under the standing registration's names) and fresh registrations before
|
||
which an ISIM that gave none at the bring-up is read again: giving its
|
||
identity at the first, or none again at the first and its identity at
|
||
the second. On real cards: the reads' commands ran on two reporters'
|
||
cards in the journal's probe, and a reporter's journal has this daemon
|
||
read the US card's ISIM, register under its names on AT&T's network
|
||
and refresh that registration, with no `AKA:` line (§13)); a
|
||
Security-Server list `PersistState` writes empty (one with
|
||
a quote, a backslash or a newline — neither KPN's nor O2's list has
|
||
one; the resume of such a file ran with a hand-edited empty key,
|
||
2026-10-11); a state write of a standing registration after a fresh
|
||
attempt that had its 401 and aborted before its SA setup
|
||
(`RegState::securityServer`,
|
||
not the attempt's `ss_`: since 1.2.5 the write is made when a
|
||
re-REGISTER is sent, so on KPN it follows the old SA's first retry
|
||
after a throttled attempt, which KPN has answered 403, 2026-10-03, and
|
||
480, 2026-11-25; no daemon that writes at the send has had a throttled
|
||
attempt); the window that leaves a state file naming another
|
||
SA pair than the kernel's (a stop or a crash between a fresh attempt's
|
||
SA setup and its 200's state write — the check is pinned in `tests/Ipsec`
|
||
and ran on a hand-edited list, 2026-10-11; the window itself is not
|
||
staged); the write-off of the old
|
||
registration by a recovery's fresh attempt that fails past the SA setup
|
||
(such attempts are on record only as a bring-up's fatal exit, which does
|
||
not pass that arm — pinned in `tests/Engine` only); the address moves
|
||
writing `old_gone` to the holds file (the move benches predate that
|
||
field); a SUBSCRIBE final read inside a REGISTER wait (KPN answers within
|
||
the second); the shell's handling of a NOTIFY that terminates our own
|
||
binding (§3; every captured termination is a previous contact's O2
|
||
`deactivated`, and a deregistration during a call cannot be staged);
|
||
`SipFlow::Connect`'s errno arms — socket() failing, a UDP connect()
|
||
error, a bind() refused while the address is still on the link — which
|
||
no bench reaches without fault injection (§3); a coverage gap on the air
|
||
(no bench stages a radio gap without an RF shield) — the packet-service
|
||
read's rule has run through a fake `mmcli` (2026-10-03: `searching`
|
||
and `detached` not counted, `connecting` with `unknown` counted; the
|
||
bench of 1.2.5's record below: `searching` with `detached`,
|
||
`registered` with `attached`) and against the dev phone's own
|
||
ModemManager (2026-10-03: `connected` with `attached`, two silent
|
||
cycles counted); the read that follows a refresh unanswered over a
|
||
reconnected flow has found no packet service on no run (`refresh
|
||
unanswered while the modem reports no packet service`); and
|
||
`tests/Engine`
|
||
pin what the policy does with the modem's word, nothing
|
||
of the read; the REGISTER wait's diverting arms — a response to
|
||
another transaction ignored, a provisional
|
||
restarting the wait, a request (an INVITE among them) dispatched and
|
||
answered under the wait; an incoming call answered from a session's
|
||
dialer since the polkit gate — imsd-dialerd's `Accept` by the active
|
||
session, or GNOME Calls' `Answer` through imsd-ofonod's gate (imsd's own
|
||
`Accept` gate has run: refused for an account without a seat session and
|
||
for nobody, accepted for root, 2026-10-04); a refused
|
||
final carrying a `Warning`, a `Reason` or a `Server` header (KPN's 403s
|
||
and 482s carried none, its 480s of 2026-11-25 a `Retry-After` and no
|
||
other — the rendering of the three is pinned
|
||
in `tests/Sip` only); an `AUDIO_USER` pin in imsd's own environment that
|
||
names no account (the logind fallback) or an account without a PipeWire
|
||
socket (a silent call) — a pin naming an account with one ran, 2026-10-04.
|
||
`DetectLocal`'s three-tier address ranking for a run without `LOCAL`
|
||
(§10.1) ran through a fake `ip` (2026-10-05: the phone's listing of the
|
||
netdev and two cut-down ones). The 1.0.0 arms no bench has reached: a
|
||
fresh registration moving from the resumed SA peer to `PCSCF=` and back
|
||
when the attempt fails before the SA setup (`FreshRecover`); the
|
||
fresh-target tail of a state file another attempt left behind (its no-target
|
||
tail ran on the tip's host build, bench 23f, with a file naming another SA
|
||
pair; the check itself, `FileNamesAnotherPair`, is pinned in `tests/Ipsec`;
|
||
the window itself is not staged on the phone); another transport-mode reqid 1 + 2 pair
|
||
beside ours on other ports, and two addresses each carrying imsd's
|
||
fingerprint (`tests/Ipsec` only — a VPN's tunnel policy and a transport
|
||
reqid-1 policy beside the live pair, resumed and kept, and a lone one with
|
||
no pair of ours, none found, ran on the dev phone, 2026-10-11/12); the SA
|
||
setup's and the dead pair's deletes with
|
||
another transport-mode user's pair in the kernel (`tests/Ipsec` only — with
|
||
a VPN's tunnel policy and tunnel state there, both left in place through a
|
||
fresh registration and a dead pair's removal, they ran on the dev phone,
|
||
2026-10-12); a no-target resume the network refuses (the reducer's side of
|
||
the count's travel, `Held` → `Restore`, is pinned in `tests/Engine`; the
|
||
holds file's `refusals` key — `PersistHolds`/`LoadHolds`, shell code — and
|
||
the shell's giving the pair up on the engine's verdict are unbenched);
|
||
`FreshRecover`'s restart for want of a fresh target (a resumed no-target
|
||
registration whose recovery needs a fresh one); an empty `Service-Route`
|
||
value in the 200, ignored (KPN's 200 carries none); a no-target resume
|
||
whose refresh goes unanswered (the connect case ran on the tip's host
|
||
build, bench 23f: the pair kept for the restart, `the restart tries the
|
||
resume again`); `RESUME=0` at a no-target start
|
||
(BringUp's removal of the untried pair — the same deletes ran before the
|
||
bus name on the host's kernel, a holds write-off in front of imsd's pair,
|
||
2026-10-13); `RemoveDeadPair`'s no-peer line (`N xfrm entries of imsd's own
|
||
with no pair to resume: removing them`); `RunOwnXfrmDeletes`'
|
||
line for a delete that failed (`… -> rc N`: an entry gone between the read
|
||
and the delete); the holds file's `pdn` compare in canonical form (no
|
||
capture stages a holds file whose `pdn` is spelled unlike `LOCAL`); the
|
||
discovery arms beyond the plain found one — the v4/FQDN `also gave` line,
|
||
the eight-address cap, the IPv4-only and no-mux-id skips, the comma-list
|
||
`PCSCF=` refusal, the reader's rc-0 answer without an address — on the mock
|
||
bench only (S13, S19–S22, S55): KPN's PCO carries two IPv6 addresses and nothing else, so on the
|
||
real PCO the dev phone reached the found arm alone; the configured skip, the
|
||
bracketed refusal and, through the `IMSD_PCSCF` seam, the reader's failure
|
||
and its exit 2 ran on the dev phone too (2026-10-11/12); the script's idle arms (no SIM, a refused ims PDN) with the
|
||
refusal count's reset by a coverage gap, a timeout and a transient cause,
|
||
the no-coverage and locked-SIM retries and the APN-string connect of a
|
||
modem without the profile, on the mock bench only (a SIM-out boot would
|
||
reach the no-SIM idle alone; the others need a SIM-in run against a refusing
|
||
network, an outage, a locked SIM, a modem without the profile) — the daemon's `idle:` exit for
|
||
the script's keys ran on the host build (2026-10-12, exit 0), its own idle
|
||
(nothing to register to), the discovery-failed exit 1, `main()`'s removal
|
||
of a pair the holds wrote off and `imsd-ofonod` starting without waiting
|
||
for imsd on the dev phone (2026-10-12). DTMF ran on the dev phone (KPN,
|
||
2026-10-14 to 16, the fp6 journal's `2026-10-14-dtmf-bench-1` to
|
||
`2026-10-16-dtmf-bench-17-heard`): outgoing calls to voicemail over the bus
|
||
(AMR-WB, telephone-event 98 — three tones, a string with a character
|
||
that is no tone, a wrong call uni: the two drops' lines; benches 1, 5
|
||
to 9 and 11 to 16), 13 keys from GNOME Calls' keypad on a call to a stock phone the
|
||
network answered narrowband (AMR 99, telephone-event 100), heard there
|
||
(bench 2, the first sender; 28 keys from Plasma Dialer's keypad on two
|
||
such calls heard there on the one-sender shape, bench 17); on incoming
|
||
calls from that phone (the offer's 111 at 16 kHz)
|
||
10 and 4 keys sent from the keypad (benches 3 and 4); on Plasma Mobile,
|
||
11 keys from Plasma Dialer's keypad on an incoming call and 3 on an
|
||
outgoing narrowband one, through `imsd-dialerd` (bench 10); the stock
|
||
phone's key presses heard as tones (on GNOME Calls: bench 3's twelve on
|
||
the renderer before the gap fill, bench 4's four on it with the gap
|
||
fill; on Plasma Mobile: bench 10's ten on an incoming wideband call and
|
||
two on an outgoing narrowband one, every received event rendered by the
|
||
leg's own count). Every event of
|
||
ours in benches 1 to 3 and 5 to 17 is in the RFC 4733 shape on the wire
|
||
with the clock shared with the audio, and so are three of bench 4's
|
||
four: the third carried a mic frame after its first packet (seq 1761
|
||
between 1760 and 1762) — the race of the sender's first shape, a thread
|
||
of its own beside the mic's, which the sender's commit closes by having
|
||
the mic thread send the event packets in its own frames' slots (one
|
||
event of bench 4's four raced, none of the 23 live-mic events of benches
|
||
2 and 3; the loopback's mic is a file, paced like a microphone, and has
|
||
not raced it). That first shape also stamped the audio a slot early or
|
||
late per event against the capture clock on the AMR-WB calls measured —
|
||
there pw-record delivers frames in bursts of two (§13) and the thread's
|
||
140 ms window took six to eight of them: the two tones of `2#`, 10 slots
|
||
apart by construction, are 11, 9 and 10 slots apart in benches 5, 12 and
|
||
13, AMR-WB voicemail calls (`analysis-v2-bench-{5,12,13}.txt` beside
|
||
bench 14) — which the one-sender shape of bench 14 cannot (10); on a
|
||
narrowband call the first shape's stamping was not measured.
|
||
Not reached on hardware:
|
||
a network answering without telephone-event (KPN echoes it; an answer that
|
||
keeps the rtpmap off its m-line is pinned in `tests/Sdp`), the drops
|
||
before the answer and after the call and the `DtmfMaxTones` bound
|
||
(these three pinned in `tests/Engine`), the letters A–D and lower case
|
||
(pinned in `tests/Engine` and the selftest), an inbound offer without
|
||
telephone-event at the codec's clock (pinned in `tests/Sdp`), the shell's
|
||
refusal of a line over PIPE_BUF and its `not sent: no control pipe` line
|
||
on a call with no media leg (nothing pins these two), a `pipe()` failure, a write to a
|
||
dead leg's pipe (`DTMF '…' not sent: …`), a full pipe's EAGAIN, G.711
|
||
(the loopback only), a received event with a code past D (dropped
|
||
unrendered) or one whose packet reports more than two seconds the clock
|
||
has not covered (that packet skipped — a long key press renders slot by
|
||
slot), a lost first packet of an event (the renderer starts where the
|
||
clock stands), and an answer that renumbers telephone-event or gives the
|
||
audio our number (`DTMF_RX_PT` — KPN echoes our numbers; pinned in
|
||
`tests/Engine` and by the loopback's collision arm).
|
||
- SMS over IP (§7.9) ran on the dev phone on KPN on 2026-10-17 (the fp6
|
||
journal's `2026-10-17-sms-over-ip-bench` capture; §13 has the network
|
||
facts): the EF_SMSP read at bring-up and the
|
||
`+g.3gpp.smsip` tag on a resumed and on a fresh registration (echoed in
|
||
the reg-event reginfo); three `Send`s over `busctl` (one segment each:
|
||
MESSAGE → 202, the submit report → `sent`; the dump of the 00:53 one shows
|
||
a GSM 7-bit RP-DATA, its report's In-Reply-To naming our Call-ID); five
|
||
texts received at 01:17 (one segment each, GSM 7-bit:
|
||
parsed, stored, the RP-ACK delivery report sent and answered 202,
|
||
`List` reading them back); a sixth (SC time stamp 01:23:10, logged at 01:23:12) that arrived twice within a second
|
||
(`journal-0123-duplicate`; the dump that survives,
|
||
`mt-0123-duplicate-message-in`, came over UDP from the P-CSCF) and became
|
||
two stored texts and two delivery reports, one of them refused 488, which is where the retransmission
|
||
absorption (`RecentTransactions`) came from; the
|
||
store surviving the restart that installed c57765a, a bench build ahead of
|
||
this history carrying the retransmission absorption (between 01:26 and
|
||
01:33: seven records before it, the duplicate's `Delete` over the live
|
||
bus at 01:28 leaving six — `r22-store-backup-and-delete-proof` and
|
||
`r22-sent-texts-2026-10-17-from-the-session-transcript`); a 240-character
|
||
text (01:33) sent as two segments (consecutive
|
||
RP-MR/TP-MR, both 202 + RP-ACK) and received back (01:40) as two
|
||
segments (set 174, 159 + 102 bytes) reassembled byte-identical (SC time
|
||
stamp 01:40:26, the whole logged at 01:40:28; the text sent against the stored record,
|
||
`r22-sent-texts-2026-10-17-from-the-session-transcript` and
|
||
`r22-store-backup-and-delete-proof`); a UCS-2 text
|
||
with ü and ß, ❤, an emoji (surrogate pair) and Ω sent
|
||
(35 units, TP-UDL 70) and received back decoded (DCS 08) — its trailing
|
||
✓ missing in the copy that came back (34 of its 35 units: the text sent,
|
||
`r22-sent-texts-2026-10-17-from-the-session-transcript`, against the
|
||
MESSAGE dump `mt-0140-last-segment-message-in`; origin open); sent on its
|
||
own, the ✓ arrived as a one-character UCS-2 text (its stored record,
|
||
`r22-store-backup-and-delete-proof`); that one-character text's MESSAGE
|
||
retransmitted (01:44:24) and absorbed: answered again, not handled again
|
||
— one stored text, one delivery report, 202; a text from the alphanumeric
|
||
sender AUTHMSG at 01:47 (55 bytes, its report answered 202; the day's every
|
||
arrival and report: `r24-phone-journal-authmsg-status-reports-2306`); and a
|
||
text at 23:08 under a build whose 200, by the capture's heading, echoes
|
||
every Via and carries a To tag (`mt-2308-new-final-shape`): the
|
||
same-second retransmission was answered again and absorbed, the delivery
|
||
report answered 202. No capture of the benches on
|
||
hardware holds a journal line of one of these arms (each arm's line is searched in them in the
|
||
fp6 journal's `2026-11-19-imsd-1.2.0-r32-cut` capture, `searches/arms.out`, and for the phone's
|
||
visits of 2026-11-20 to 2026-11-22 in its `2026-11-20-issues-2-5`
|
||
capture, `phone/arms.out` and `phone-form6/arms.out`): a refused final to a submission's MESSAGE, an RP-ERROR this
|
||
code sends (an RP-ERROR that came in was
|
||
reached: `smsc-override-2026-10-18-0217`, 02:19:41, RP cause 28 + TP-FCS
|
||
0xc1, through `OnReport`), the final's wait running out (the report's ran out on the dev phone: the repeat's benches, below), a dead flow under a `Send`, a status report (one requested
|
||
at 01:33 with TP-SRR; none came in the following 11 minutes — the
|
||
unfiltered journal of 01:33:30–01:45:00,
|
||
`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 (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
|
||
delivery report the flow could not
|
||
send, a concatenated set aged out after its 30 min, a bus object or
|
||
interface that does not register (§7.8), the store's Exists path (a name the store already holds: the next id
|
||
tried), a store failure under this code (`NOT
|
||
stored`, the signal still out, the RP-ACK kept — the one bench,
|
||
`store-refused-2026-10-18-0136`, ran the build that answered RP-ERROR,
|
||
since taken out; the start sweep itself was reached,
|
||
`r14-tip-sanity-2026-10-18-0408`: `sms store: 1 stale temporary file(s)
|
||
removed`). Not searched for, as they write no journal line of their own: a submit report without
|
||
In-Reply-To taken by its RP-MR (the one dumped carries In-Reply-To) or one whose In-Reply-To
|
||
lists ours among several Call-IDs, a delivered MESSAGE whose
|
||
Call-ID holds an ASCII control character or a space, or whose P-Asserted-Identity lists several
|
||
identities in one row or begins with a quoted display name, a MESSAGE final arriving inside a REGISTER wait
|
||
(`AwaitFinal` → `OnSmsResponse`), a queued message started inside a REGISTER wait, a MESSAGE
|
||
inside a call's dialog, a stop with a message queued or in flight. The reducers for the arms of both sentences but the shell
|
||
paths — the final's routing inside `AwaitFinal`, the delivery report the
|
||
flow could not send, `LoadSmsParameters`' refusals, the MESSAGE inside a call's dialog, the queue's two, the store's two and the bus object's registration —
|
||
are pinned in `tests/Engine` — but for EF_SMSP's parser and the reassembler's age-out (`Purge`, given an age), which `tests/Sms` pins, and `HeaderUri`'s reading of a header's value, which `tests/Sip` pins; the Messaging
|
||
interface's `Send`, `GetStatus`, `Subscribe` and `StateChanged` ran on
|
||
the host's session bus in dev mode (2026-10-16: two `Send`s answered
|
||
with ids and failed `imsd is not registered`; 2026-10-17: three
|
||
connections — a subscriber, a match-rule-only listener, an unsubscribed
|
||
sender — where only the subscriber and the sender heard the
|
||
`StateChanged`; 2026-11-19, on a private session bus with the setting
|
||
off: `enabled` false, `Send` refused with `NotSupported`, `Subscribe`
|
||
answered); the store's `List`/`Delete` on the same bus
|
||
(2026-10-17), and in dev mode on a private session bus (2026-11-19)
|
||
`List` skipping a file that is no record, with its journal line, and
|
||
four of `Delete`'s answers: `InvalidArgs` for a string that is no id;
|
||
`IOError` for a record in a store directory
|
||
made unwritable, the record still listed; the removal once it was
|
||
writable; `FileNotFound` for an id with no record.
|
||
A store that cannot be read ran there too (2026-11-20 to 2026-11-22, the fp6 journal's
|
||
`2026-11-20-issues-2-5` capture, `list-io`): `List` answered `IOError`
|
||
with `Permission denied` for a store directory of mode 000, for one of
|
||
mode 400 (its names read, its first record's `stat` refused) and for a
|
||
record of mode 000, and with `Not a directory` for a file where the
|
||
directory should be; it answered an empty list with no store directory,
|
||
and the two records beside a file that is no record, a directory and a
|
||
dangling symbolic link named like records; a start with the directory
|
||
at mode 000 wrote the sweep's `cannot read` line and the daemon
|
||
answered afterwards. On the dev phone (2026-11-22, the
|
||
same capture, `phone-form6`, `checks.log`, the binary of 1.2.1)
|
||
`List` answered an empty list with the store directory
|
||
moved away and `IOError` with `Not a directory` with a file in its
|
||
place, with the journal's `cannot read` line for each of the two calls
|
||
it refused. Not reached by any bench: a directory or a file
|
||
whose read fails part-way, a file removed between the directory's read
|
||
and its own, a process out of descriptors, and the `stored` line
|
||
without its count, which takes a text received, and dev mode receives
|
||
none.
|
||
Reached from 2026-10-18 02:17 (`smsc-override-2026-10-18-0217`): the
|
||
`SMSC=` override — `SMSC=+31653131313` gives `service centre +31653131313
|
||
(SMSC=)` and a `Send` through it reaches `sent`; `SMSC=abc` gives
|
||
`SMSC='abc' is not a number` (`ForNumber` dials digits, `*` and `#` only;
|
||
the bench's first run, on a build outside this history that dialled a, b
|
||
and c, submitted with them and got an RP-ERROR back, RP cause 28).
|
||
`to` and `operator` are in a `List` record from the dev phone (2026-11-20,
|
||
the fp6 journal's `2026-11-20-imsd-1.2.0-frozen-on-dev-phone` capture,
|
||
`checks.log`: a text sent to the own number over the bus, delivered
|
||
back and listed); no capture holds a `Received` with them; the store's
|
||
round trip with each is in `tests/Engine`.
|
||
A segment's repeat ran on the dev phone against KPN (2026-11-22, the fp6
|
||
journal's `2026-11-20-issues-2-5` capture, `phone-form6`,
|
||
`repeat-bench.log`, the binary of 1.2.1): with the
|
||
phone deaf on its protected server port a text to the own number got
|
||
its 202 and no submit report and went out again 130 s after the final,
|
||
under RP-MR 178 after 177, with TP-MR 16 and TP-RD; the repeat got an
|
||
RP-ACK under a time stamp of its own (`sent`), and once the port was
|
||
open again the text came twice, under the two attempts' time stamps;
|
||
the message after it took RP-MR 179. The six benches before it went the
|
||
same way (`phone-form6/visit1` to `visit5`, 2026-11-21 and 2026-11-22,
|
||
on earlier builds; `phone`, 2026-11-20, on one that waited
|
||
40 s). Run on no hardware: a repeat after the final's wait,
|
||
a 408, a 504 or an RP-ERROR; a repeat rejected as a duplicate, and one
|
||
ended in its turn; the first attempt's report after its repeat went
|
||
out.
|
||
`tests/Engine` pins the reducer for each, and the refusal of a class 2
|
||
message: it ran on the dev phone's daemon for MESSAGEs the phone sent
|
||
to its own protected server port (`phone-form6`, `inject-bench.log`), among them one with a line per header
|
||
and one with its Content-Type on a continuation line and bytes after
|
||
its body — each answered 200, refused in the journal, stored nowhere
|
||
and, naming no gateway, reported to nobody. The read of the client flow before a wait is
|
||
judged: `SipFlow`'s two reads ran on the workstation's loopback, the
|
||
daemon's class built around a bench `main` (2026-11-20 to 2026-11-22,
|
||
the fp6 journal's `2026-11-20-issues-2-5` capture, `flow-read`: over TCP and
|
||
over UDP `RecvReady` returns a message the socket holds without
|
||
waiting and none when it holds none, and `RecvMsg` waits its time and
|
||
returns a message when one comes; over TCP `RecvReady` leaves a
|
||
message that is not whole yet; over UDP it passes a keepalive's CRLFs
|
||
over); the run loop around them judged a wait on the dev phone (the
|
||
report's, in the repeat's bench above), and has not run with a final
|
||
waiting unread at that pass.
|
||
- A request cut short of its Content-Length on the client flow ran on the
|
||
workstation's loopback (2026-11-22, the fp6 journal's
|
||
`2026-11-20-issues-2-5` capture, `cut-short`: `SipFlow` built around a
|
||
bench `main`, a peer on ::1 sending datagrams to the flow): a MESSAGE
|
||
with five body bytes of nine, its Content-Length on one line, drew a
|
||
400 with its Via, From, Call-ID and CSeq echoed and its To tagged, and
|
||
the same 400 when it was sent again; a response, an ACK and a CANCEL
|
||
cut short the same way, and a request without an end of headers, were
|
||
ignored with their lines and drew nothing; a whole request sent after
|
||
them was returned by the flow; at the commit before, the cut-short
|
||
request was ignored as they were. Not in that bench: a 400 the flow
|
||
cannot send.
|
||
- The daemon reads SIP from a socket in four places — the client flow,
|
||
the server ports' datagrams, their connections, the init port — and
|
||
each goes through a framer of `Imsd:Sip`. The two datagram reads 1.2.1 put behind `DatagramMessage` ran on the workstation's loopback
|
||
(2026-11-22, the fp6 journal's `2026-11-20-issues-2-5` capture). The
|
||
init port (`init-port`: the daemon in dev mode, its card and modem
|
||
reads answered by stand-ins, a stand-in P-CSCF answering the
|
||
unprotected REGISTER): a datagram of no bytes and one of line
|
||
breaks alone passed over, a 401 cut short of its Content-Length ignored
|
||
with its `UDP: datagram truncated … on the init port` line, and the 401
|
||
after each taken; at the commit before, the empty datagram ended the
|
||
wait (`no 401 to unprotected REGISTER`) and the cut-short 401 was taken
|
||
for the reply. A request sent there, cut short or whole, drew a line
|
||
and no answer at either commit. The server ports (`server-ports`:
|
||
`ServerPorts` built around a bench `main`): a request with bytes after
|
||
its body handed on without them; one whose body is shorter than its
|
||
Content-Length answered 400 on either port, its Via, From, Call-ID and
|
||
CSeq echoed and its To tagged — the Content-Length of each on one line; a response, an ACK and a CANCEL cut
|
||
short so, and a request without an end of headers, ignored with their
|
||
lines; a datagram of line breaks alone passed over, and one of no bytes
|
||
with the request behind it handed on in the same pass; at the commit
|
||
before, those requests were handed on as they came, and the datagram of no
|
||
bytes ended the pass, the request behind it handed on in the next. On
|
||
the dev phone (2026-11-22, the capture's `phone-form6`, the binary of
|
||
1.2.1) the 401 of a fresh registration after a reboot
|
||
came through the init port's read, and the submit report and the
|
||
delivery of each of two texts through the server ports' as datagrams (two per
|
||
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).
|
||
- A call whose client flow is found dead before any response to its
|
||
INVITE (§7.6, 1.2.4).
|
||
The machine's side is pinned in `tests/Engine`; the shell's
|
||
(`MaybeResendInvite`) ran on the workstation against a stand-in network
|
||
(2026-11-24, the fp6 journal's `2026-11-24-crlf-keepalive` capture,
|
||
`bench/bench-dial.sh`: the daemon in dev mode, its card and modem reads
|
||
answered by stand-ins, a Dial put on its bus 25 s after the
|
||
registration, a network that answers a delivered INVITE 486 and can
|
||
drop a flow in several ways). On a flow the network had forgotten,
|
||
which it reset at the INVITE's bytes, the flow was reopened and the
|
||
INVITE delivered in the same second, the call ending `refused-or-busy`
|
||
as on a live flow; 1.2.3's call there ended `error` 100 s after the
|
||
Dial. The same outcome where the network closed the flow at the INVITE
|
||
and no acknowledgement of the daemon's own close reached it (what the
|
||
close without a FIN's exchange is for). Where the flow died on the
|
||
daemon's side at the kernel's retransmission limit, the first INVITE
|
||
never delivered, the second went out about 2 s after the death was
|
||
found and the call ended the same way. Where the network took no new
|
||
connection (it refused the reopen's connect), where it reset the
|
||
reopened flow at the second INVITE, and where a reg-event NOTIFY had
|
||
ended the binding before the reset, the call ended `error` within a
|
||
second of the Dial. Over UDP an ICMP port unreachable ended the flow:
|
||
the INVITE went out once more and the call ended `error` at the second
|
||
ICMP. On the dev phone (KPN, the same day, the capture's `phone3/`, the
|
||
binary of 1.2.4): a call to voicemail answered and hung up; and one
|
||
whose flow was made to die under the INVITE before the INVITE left the
|
||
phone (every segment of the flow dropped on the phone, five in all, and
|
||
the kernel's retransmission limit lowered for the moment; nothing of
|
||
the old connection's end went to the P-CSCF): the flow was reopened
|
||
from the same port, the INVITE went out again 2.1 s after the death was
|
||
found, and the call was answered 0.2 s after that. Not met by a call:
|
||
a P-CSCF that had dropped a flow's state, and one that had received
|
||
the first INVITE before the flow died; a reopen's connect that gets no
|
||
answer at all; the emergency chain on a network.
|
||
- The firewall's rule for ESP (§7.3, §13; 1.2.4) is the bring-up script's,
|
||
which no suite reaches. The script's firewall block ran by itself on the
|
||
workstation against nftables (2026-11-24 and -25, the fp6 journal's
|
||
`2026-11-24-incoming-dropped-without-ping` capture,
|
||
`bench/bench-esp-rule.sh`: two network namespaces, an ESP transport-mode
|
||
SA pair between them, the dev phone's ruleset as read from it loaded in
|
||
the one that stands for the phone, the connection tracker's generic
|
||
timeout at 8 s, plain TCP both ways and no imsd). 1.2.3's block left the
|
||
ruleset as it was, and a connection the network's side opened to port
|
||
45062 11 s after the phone's last packet got no answer: its three ESP
|
||
packets were new to the tracker and none passed the chain. This script's
|
||
block inserted the rule (`nftables: accepting ESP on qmapmux*`; a second
|
||
run inserted nothing), and the same connection, 11 s after the last
|
||
packet, was accepted. An ESP packet whose SPI no SA has passed the chain
|
||
and was dropped by the kernel (`XfrmInNoStates`); a connection through
|
||
the SA to another port got no answer, its SYNs dropped by the chain
|
||
after decapsulation. On that ruleset without imsd's rules the block
|
||
inserted all three above the chain's own; with no `inet filter` table it
|
||
did nothing. After the ruleset was loaded again from its file the
|
||
script's rule was gone and the connection unanswered again; a file that
|
||
carries the rule kept it. ESP on another interface was not accepted and
|
||
neither was an AH packet; ESP over IPv4 on `qmapmux0.0` was accepted,
|
||
and ESP on a second `qmapmux` interface. On that ruleset without imsd's
|
||
rules, as the block left it, connections to both ports were accepted.
|
||
Eleven faults put into the block one at a time, ten in its rule for ESP,
|
||
that rule's check and its journal lines and one in a port rule, were
|
||
each caught by a step (`bench/run-mutations-esp.sh`).
|
||
`bench/bench-esp-pinhole.sh` there has the gap without the script: the
|
||
network's connection accepted a second after the phone's own exchange
|
||
and under a packet of the phone's every 3 s, and unanswered 11 s after
|
||
the last packet. On the dev phone (KPN, the capture's `phone/`), under a
|
||
daemon that sends no ping (the binary of 1.2.4, no `CRLF_KEEPALIVE`):
|
||
the tracker's entry for the P-CSCF's ESP was read counting down after a
|
||
refresh (575 s left 23 s after it, 15 s left 9 min 43 s after it) and
|
||
was gone 10 min 29 s after it (2026-11-24); the script, run at imsd's
|
||
start, inserted the rule above the two port rules it found, and the
|
||
daemon resumed its registration (2026-11-25). Then a text was sent to
|
||
the phone's own number with the tracker's timeout at 0 for the test, so
|
||
that every ESP packet from the network came without an entry: with the
|
||
rule, six such packets came, and the answer to the MESSAGE, the submit
|
||
report and the text's delivery reached the daemon within a second; with
|
||
the rule taken out, 23 came in 20 s and none of the three reached the
|
||
daemon in those 20 s. Not met: a request the network starts after the
|
||
entry has lapsed of itself, 600 s after the phone's last ESP packet (a
|
||
call to the phone from another line).
|
||
- The idle flow (§7.2 step 5; no CRLF keepalive unless `CRLF_KEEPALIVE`
|
||
names an interval, 1.2.4) is shell code no suite reaches; how the
|
||
setting's value is read is `WholeSeconds`, pinned in `tests/Util`. The
|
||
loop ran on the workstation against a stand-in network that prints
|
||
every ping and can close a flow it has heard nothing on, or forget it
|
||
and answer the next bytes on it with a reset (2026-11-24, the fp6
|
||
journal's `2026-11-24-crlf-keepalive` capture,
|
||
`bench/bench-keepalive.sh`: the daemon in dev mode, its card and modem
|
||
reads answered by stand-ins). Left alone for 100 s after its
|
||
registration the daemon sent no ping, 1.2.3's three, and with
|
||
`CRLF_KEEPALIVE=10` nine, behind its start line (§7.8); over UDP with
|
||
that setting it sent none and no empty datagram; with
|
||
`CRLF_KEEPALIVE=0` and with an empty value it sent none and logged
|
||
nothing of the setting; with `CRLF_KEEPALIVE=30s` it logged the value
|
||
as not understood and sent none. A network that closes a flow after
|
||
45 s of silence closed two in 130 s, each reconnected and re-registered
|
||
in the same second; it closed none under 1.2.3's pings or under
|
||
`CRLF_KEEPALIVE=30`, and one that closes after 60 s none under a refresh
|
||
every 40 s. A network that forgets a flow after 45 s of silence reset
|
||
the refresh that came at 60 s, twice in 140 s: `keepalive re-REGISTER
|
||
failed: no reply to re-REGISTER`, then the reconnect and the
|
||
registration in the same second; under `CRLF_KEEPALIVE=30`, as under
|
||
1.2.3's pings, it forgot none and answered both refreshes; one that
|
||
forgets after 20 s reset each of 1.2.3's three pings, and each was
|
||
followed by the reconnect. Under a call the daemon had placed and
|
||
hung up 30 s later, a network that forgets a flow after 20 s of
|
||
silence reset the BYE's bytes, and one that closes it after 20 s had
|
||
closed it: in both the BYE was not delivered, the call ended
|
||
`local-hangup — HangUp; BYE sent`, and the recovery reconnected as
|
||
soon as the call was gone; 1.2.3's BYE was lost the same way on the
|
||
forgetting network (the fp6 journal's `2026-11-24-bye-resend`
|
||
capture, `bench/bench-hangup.sh`, the scenarios named `-not-resent`
|
||
and `hangup-forgotten-before`; §7.6).
|
||
On the dev phone (KPN, the same day; its
|
||
ModemManager has the WDS event reports off while the phone sleeps,
|
||
§13), with the binary of 1.2.4 (the capture's `phone3/`): no packet on
|
||
the ims netdev in two idle minutes, where 1.2.3 put one each way every
|
||
30 s (`phone/`); with `CRLF_KEEPALIVE=30` the start line and a packet
|
||
each way every 30 s; with `CRLF_KEEPALIVE=30s` the line for a value not
|
||
understood and no packet. With builds of this change from before the
|
||
call's resend (two bullets above) was put under it (`phone2/`,
|
||
`phone/`): the netdev's counters stood still for the 1800 awake seconds
|
||
to the refresh, which the P-CSCF answered on the flow, silent until
|
||
then (no reconnect), twice; and two loops of deep suspends with a 150-s
|
||
alarm had no packet on the netdev, of seven sleeps (five ended by the
|
||
alarm, one after 9 s by the ADSP's battery manager, one after 98 s by a
|
||
file-system request of the modem's that no packet had preceded) and of
|
||
six (five ended by the alarm, one after 99 s by the ADSP's battery
|
||
manager). Not met: a real network that closes or forgets an idle flow;
|
||
a flow that dies with neither a close nor a reset; a reg-event
|
||
SUBSCRIBE as the first bytes on a forgotten flow; an incoming call
|
||
whose BYE is the first bytes on such a flow; an incoming text whose
|
||
delivery report is the first bytes on such a flow. A text's MESSAGE as
|
||
the first bytes on a flow the network had dropped was met once, in the
|
||
firewall's test above (2026-11-25): the phone had dropped the P-CSCF's
|
||
packets for 20 s, a text's first MESSAGE had gone unanswered for that,
|
||
and its repeat, 128 s on, was the first thing imsd sent on the flow
|
||
since. The flow was found dead 0.3 s after the repeat went out, the
|
||
recovery reconnected and re-registered 0.2 s after that, and the text
|
||
ended `failed`, its repeat lost with the flow.
|
||
- The CSeq of a re-REGISTER (§7.2 step 5) is the shell's, and no suite
|
||
reaches it. On the workstation the daemon ran against a stand-in network
|
||
that keeps the highest CSeq of the protected REGISTERs it has taken
|
||
per Call-ID, answers a protected REGISTER
|
||
that is not higher `482 Loop Detected`, and can take one refresh
|
||
without answering it or refuse one (the fp6 journal's
|
||
`2026-11-25-refresh-answer-lost`
|
||
capture, `bench/bench-cseq.sh`): after a refresh whose answer is lost
|
||
the reconnect's re-REGISTER carries the next number and is answered
|
||
200, where 1.2.4's carried the lost one's, was refused twice and
|
||
registered fresh; a daemon killed under the wait resumes with the next
|
||
number, the state file having it, where 1.2.4's resume was refused and
|
||
registered fresh; after a refresh the stand-in refused (503) the
|
||
reconnect's re-REGISTER carries the next number, where 1.2.4's carried
|
||
the refused one's again (the stand-in keeps no number for a REGISTER
|
||
it refuses, and answered both 200). On the dev phone (KPN,
|
||
2026-11-25, this commit's
|
||
daemon; the fp6 journal's `2026-11-25-through-sleep` capture,
|
||
`phone/cseqtest-2-a`), with the firewall's rule for ESP taken out and
|
||
the connection tracker's generic timeout at 0 around a refresh, so that
|
||
its answer was dropped: `keepalive re-REGISTER failed: no reply to
|
||
re-REGISTER`, and `reconnected + re-registered` 10 s later. Not run: the
|
||
number after a re-REGISTER whose send failed; a re-REGISTER's answer
|
||
lost over UDP; a restart after a daemon was told to stop (SIGTERM)
|
||
under the wait, where the bench kills it; a resume whose REGISTER gets
|
||
no answer; a state file torn by a kill during its write; and what a
|
||
network makes of a number that skips one, as a REGISTER that was sent
|
||
and never arrived leaves it (the stand-in took one; no phone run tells
|
||
whether its network saw one).
|
||
- The call's sleep inhibitor (§7.6) is the main thread's code, and no suite
|
||
reaches it. On the workstation the daemon ran with a stand-in logind
|
||
on the bench's bus, which prints every `Inhibit` and every lock's
|
||
release and refuses every `Inhibit`, with logind's
|
||
`OperationInProgress` error, while a file says a sleep's
|
||
operation runs (the fp6 journal's `2026-11-25-through-sleep` capture,
|
||
`bench/bench-sleep.sh`): one lock per call, taken within 1.5 s of the
|
||
`Dial` and released within 1.5 s after the call's end, for a call
|
||
answered and hung up, a call the network refused and two calls in a
|
||
row; a call placed while the stand-in refused had its lock within
|
||
0.5 s of the stand-in's `PrepareForSleep(false)`; with no logind on
|
||
the bus the call ran as with one; 1.2.4 asked for no lock. On the dev
|
||
phone (KPN, systemd 262.2, Plasma Mobile, the sleep targets unmasked
|
||
for the test; `phone/` there), under a
|
||
call to the carrier's voicemail placed on the bus: imsd's lock the
|
||
only block inhibitor for sleep in `systemd-inhibit --list`, none in
|
||
the list of PowerDevil's policy agent, `systemctl
|
||
suspend` answered `Operation denied due to active block inhibitor` and
|
||
no suspend counted, the lock gone after the hang-up; and for a call
|
||
placed from a sleep hook at a resume, with logind's operation still
|
||
running: the refusal's line, and the lock when logind had said the
|
||
sleep was over. Not run: a suspend under a call without the lock; an
|
||
incoming call that wakes a sleeping phone; a call announced before
|
||
the bus connection is there; a request at a second row's addition or
|
||
removal (a Dial refused under a call that has no lock); a second
|
||
refusal before a lock is given, which prints no line; an answer of
|
||
logind's without a descriptor; a `PrepareForSleep` whose argument is
|
||
not one boolean; a Dial refused under a call that has its lock, which
|
||
asks nothing, and what logind signals after a suspend told to ignore
|
||
inhibitors under a call (the next entry has such a suspend; its run's
|
||
log has the lock listed before and after it, and no line of logind's
|
||
for the signal); a desktop's own request for a suspend under the lock.
|
||
- The registration through a sleep (§7.10) is shell code but for
|
||
`WakeAt` and the recovery policy's wake after a local wait, which
|
||
`tests/Engine` pins. On the workstation
|
||
(`bench/bench-sleep.sh` of the capture above) the bench's sleep is a
|
||
preloaded `clock_gettime` under which the boot clock runs ahead of the
|
||
steady clock by the seconds a file names: with the boot clock 50 s
|
||
ahead a refresh set for 60 s went out 20 s into the registration, and
|
||
1.2.4's did not; with it 599500 s ahead the reg-event subscription was
|
||
renewed, and 1.2.4's was not; with no jump the refresh came at its
|
||
awake time and not before. The second lock was taken and released
|
||
around a refresh, asked for again at the stand-in logind's
|
||
`PrepareForSleep(false)` where that had refused it at a refresh's
|
||
start, and held from a text's sending to its `failed` where the
|
||
stand-in network answered no MESSAGE (256 s). In a gap of 40 s
|
||
(the stand-in modem without packet service, no SYN let through, the
|
||
flow closed by the network) no connect was tried and no lock taken,
|
||
the modem was asked every 5 s, the daemon's own processor time
|
||
stayed under a second (an earlier build, which kept the dead flow's
|
||
socket through the gap, used 33.9 s of it), and the reconnect came
|
||
3 to 5 s after the gap's end; a `Dial` inside such a gap ended at
|
||
once, with nothing reopened under it, and the reconnect then came
|
||
0.5 to 1.5 s after the gap's end. In a gap of 70 s that let no
|
||
segment through, the daemon had no socket of the old flow at the
|
||
gap's end, and the reconnect came 3 to 5 s after it, 0.5 to 1.5 s
|
||
where a `Dial` had been tried inside the gap. A
|
||
daemon started inside a hold of 60 s held no lock for
|
||
it. With `WAKE_TRACE=1`, a test seam, the daemon writes a line
|
||
whenever the time the alarm is armed for changes (by the second; one
|
||
line for a run of times less than two seconds ahead), with a timer
|
||
or without: in a gap
|
||
that a refresh ran into, with the boot clock put 1000 s ahead inside
|
||
it, the alarm named 900 s ahead; after the gap's end, where the old
|
||
flow's socket had two connects refused, it named no more than 30 s
|
||
ahead, and the reconnect came 15 to 16 s after the gap's end; and
|
||
where the stand-in modem reported service twice inside such a gap,
|
||
the alarm named 900 s ahead again after each. Where the modem still
|
||
reported service when the refresh failed, where the network stayed
|
||
silent for 80 s after the modem's return (two silent cycles, then a
|
||
fresh registration) and over UDP, the alarm named no more than 30 s
|
||
ahead from the modem's return to the recovery. While a step waited
|
||
for the network (a refresh's 12 s without a reply, a connect's 12 s
|
||
without an answer and the 10 s before the next try, a fresh
|
||
registration's two waits with the stand-in network holding its
|
||
answers back) the alarm was named a new time every second, and
|
||
through the connect for a call's resend it was named no time 2 s or
|
||
more ahead. Stopped 1.5 s into a fresh registration's wait for its
|
||
first 401 and continued 2 s later (a stop and a continue end a
|
||
datagram receive under a timeout as a suspend's freeze does, §13),
|
||
the daemon
|
||
registered when the stand-in's held-back 401 came, five runs of five;
|
||
an earlier build and 1.2.4 gave the wait up at the continue, five of
|
||
five each. The bench's
|
||
namespace gives no `CAP_WAKE_ALARM`: every life of this daemon there
|
||
says `no wake
|
||
alarm (Operation not permitted)` and runs on. The alarm is the dev
|
||
phone's (KPN, a 7.3 kernel, this commit's code under the next
|
||
commit's version string, `phone/` there, 2026-11-28), with
|
||
`REFRESH_INTERVAL=120` and deep suspends asked of logind: every
|
||
refresh that fell due under a sleep went out within 3 s of its due
|
||
time, after a resume whose first interrupt was the RTC's alarm
|
||
(1.2.4, in three sleeps of that script as it was on 2026-11-25, on
|
||
the same kernel build, sent no refresh in seven minutes); seven
|
||
recovery steps that fell due under a sleep ran 1.5 to 3 s after
|
||
their time (an earlier build, 2026-11-25); under a call a suspend
|
||
told to ignore inhibitors was refused by the kernel (`alarmtimer`,
|
||
-16), twice, systemd-sleep having tried its second state; and under
|
||
a refresh whose REGISTER the phone itself dropped, such a suspend a
|
||
second into the wait was ended by imsd's alarm (the RTC's the first
|
||
interrupt, 30.6 s in), after which imsd's timer, zero at the test's
|
||
first look, read 29 to 30 s ahead at each of its 32 looks from 0.2 s
|
||
later to the wait's end, which the test saw about 10 s after that
|
||
first look (an earlier build, which set the alarm once
|
||
for the wait, read zero at every reading until the wait had ended;
|
||
in another run, with two more such suspends in that wait, it slept
|
||
to the test's own alarm of 75 s both times). The re-registration
|
||
after that refresh came 71 s after its `no reply`, the kernel
|
||
refusing nine connects over a minute first (the old flow's socket,
|
||
§7.10). Not run: a
|
||
suspend under a fresh registration's first wait with the daemon on a
|
||
phone (the receive's `EINTR` at a resume was seen there with a test
|
||
program, §13); an alarm clock with no RTC behind it (`no RTC that
|
||
can wake the phone`), and a `timerfd_settime` that fails (`wake
|
||
alarm not set`); the alarm's disarming and `wake trace: none`,
|
||
which nothing reaches once the loop runs; a second suspend told to
|
||
ignore
|
||
inhibitors under one wait with this daemon on a phone (the dev
|
||
phone is not to be suspended within ten seconds of a resume: the
|
||
earlier build's run with three did so, and its wifi firmware
|
||
crashed; and the wait the test stages, an unanswered refresh's
|
||
12 s, is over at about that time); the 1.9 s through a connect for
|
||
a call's resend that waits (the bench's is answered at once); a
|
||
fresh registration's look at the modem finding no packet service
|
||
(the reconnect's has run); a bring-up the network defers or refuses,
|
||
and a stop during a bring-up's hold; the work's lock asked for at
|
||
the bus connection's coming (no record tells that request from the
|
||
step's own); a coverage gap on a
|
||
phone, and the wake for its slower look; on a phone, a sleep longer
|
||
than a refresh interval of 1800 s; the alarm at most 30 s ahead
|
||
through a step's wait while a text is in flight, which is read from
|
||
the code;
|
||
the reg-event subscription's renewal on a network.
|
||
- Where an answer goes that the server ports send (§12) is the shell's
|
||
(`ServerPorts`), and no suite reaches it. On the workstation the daemon
|
||
ran against a stand-in network that sends it requests over TCP and UDP
|
||
and can close or reset a connection behind one (the fp6 journal's
|
||
`2026-12-04-pani-in-dialog` capture, `bench/bench-pani.sh`: the daemon
|
||
in dev mode, its card and modem reads answered by stand-ins, an
|
||
incoming call accepted on its bus). Where the network closed the
|
||
connection its INVITE had come on while the call rang, the 200 of the
|
||
Accept arrived on the connection the same peer had made again to the
|
||
same port, also where the network had reset the first right behind its
|
||
INVITE (that call's 100 and 180 did not arrive: the connection they
|
||
were written to had been reset); it was not sent, with the journal's
|
||
line, where the only new connection was another host's, another port's
|
||
of the same host, or the same peer's to the daemon's other port (the
|
||
release before, 1.2.6, wrote it on the other host's connection and on
|
||
the one to the other port; with another port of the same host it was
|
||
not run); and it arrived on the INVITE's own connection where the peer
|
||
made a second one to the other port while the call rang. Two requests
|
||
whose connections the network closed right behind them were not
|
||
answered, with one line. Over UDP five OPTIONS requests were answered
|
||
from the ports the release before answered them from; two of the five
|
||
had no `rport` in their Via and were answered at the port that Via
|
||
names. On the dev phone on KPN (2026-12-04; the fp6 journal's
|
||
`2026-12-04-imsd-1.2.7-range-on-dev-phone` capture: the daemon in the
|
||
packaged one's place, resuming its registration, and the SA pair's
|
||
packets read on the phone) the two requests that a text to the phone's
|
||
own number brings came in over UDP, and each 200 left from 45061 for
|
||
the P-CSCF's protected server port, which their Via names; the text
|
||
was delivered, and the network sent neither request again. A call
|
||
came in there over TCP, on a connection the P-CSCF had made to 45062
|
||
and had sent two NOTIFYs on: the 200s to those, the call's 100, its
|
||
180 and the 200 of the Accept left on that connection, and the 200 to
|
||
its BYE, which came over UDP, from 45061. Of what ran against the
|
||
stand-in network nothing else has been seen on a real one (a
|
||
connection closed or reset behind a request and an answer that is not
|
||
sent among it).
|
||
Not run: an answer given after the daemon has moved to another
|
||
address; a peer on a link-local or an IPv4 address; a connection that
|
||
ends in an error and is made again within one turn of the daemon's
|
||
loop.
|
||
- `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,
|
||
`04-…`). Not reached on hardware: exit 2 (a PCO without an IPv6 list), an
|
||
error answer to Bind Mux Data Port or Set IP Family, a lookup that finds no
|
||
WDS service, the answer timeout, skipped strays and indications, the
|
||
lookup's second send to a local node other than 1, and the `v4`/`fqdn`
|
||
output lines (`tests/Qmi` pins their parsing on synthetic TLVs only). The
|
||
QRTR control lookup and the matching of answers by type, transaction and
|
||
message id are shell code (`pcscf.cpp`) no test reaches.
|
||
- `imsd-media --selftest` round-trips the RFC 4867 payload packing (both
|
||
formats, both AMR codecs), the G.711 tables, and pins the RFC 4733 event
|
||
payload bytes, the keypad-to-event codes and every event's Q.23
|
||
frequency pair. `MIC_SRC=<file>` (raw s16
|
||
PCM at the codec rate, paced in real time) and `PCM_DUMP=1` are test seams
|
||
for driving the leg against a synthetic RTP peer without a phone; the fp6
|
||
journal's `utilities/media_loopback.py` is that peer, and its `--dtmf`
|
||
arm writes a `dtmf <tones>` line to the leg's stdin and checks the events
|
||
on the wire (one timestamp per event, the marker, the growing duration,
|
||
the end bit three times, the shared sequence and timestamp space with the
|
||
audio; with the mic file, or without a mic — `--no-mic`, the silence tick
|
||
carrying the events), and its `--dtmf-rx` arm has the peer send events and checks the
|
||
decoded downlink for each tone's two frequencies where the event sat, the
|
||
stream intact around it — the sender's shape is proven there and on the
|
||
dev phone's wire (the fp6 journal's dtmf benches: their pcaps go through
|
||
the same checks), the renderer's there — and on the dev phone by ear and
|
||
by the leg's count of events rendered (bench 10); what a gateway does
|
||
with the events is proven only by a call to one.
|
||
- `imsd --session` and `imsd-ofonod --session` own their names on the session
|
||
bus for development without root, polkit or a phone (§8.3).
|
||
|
||
## 6. Code style
|
||
|
||
No linter since 1.2.0: the Catcrafts house-style rules (Crafter.LintRules)
|
||
rode in `project.cpp` as a dependency from 0.3.x to 1.1.0, the tree never
|
||
passed them, CI never ran them, and the census kept here was dead weight
|
||
(Jorijn, 2026-10-17: "we are ignoring it anyway"). What holds:
|
||
|
||
- Comments explain constraints the code cannot show — a network's observed
|
||
behaviour, a spec clause, the reason a shape was chosen — and name their
|
||
evidence (a dated bench, a capture) when they rest on one. They do not
|
||
narrate what the code does.
|
||
- Log lines are the operator's interface (§7.8). A new state the daemon can
|
||
be in gets a journal line that names it; existing lines are grepped for by
|
||
scripts (`imsd-handover.sh` reads a pre-0.3.10 daemon's `bring-up deferred: …
|
||
next fresh registration in N min`), so changing one is an interface change.
|
||
- GLib only in `main.cpp`, `dialerd.cpp`, `ofonod.cpp` and `ImsdBus.cppm`.
|
||
`media.cpp` is std + POSIX. The partitions are std only.
|
||
|
||
## 7. How the daemon works
|
||
|
||
### 7.1 Processes and buses
|
||
|
||
`imsd` runs as root on the system bus as `net.catcrafts.IMS1` (object
|
||
`/net/catcrafts/IMS1`, interface `net.catcrafts.IMS1`; the frozen ABI, §8).
|
||
The bus policy `packaging/net.catcrafts.IMS1.conf` lets any local account
|
||
reach it; placing, answering and ending a call is polkit's
|
||
`net.catcrafts.IMS1.Voice`, sending a short message over IP, subscribing
|
||
to the message signals, listing and deleting the stored ones
|
||
`net.catcrafts.IMS1.Messaging` (`packaging/net.catcrafts.IMS1.policy`, both
|
||
shaped like
|
||
ModemManager's Voice action: the active local session and root — not an ssh
|
||
login, an inactive session or a system service account). Reads (`GetStatus`,
|
||
`GetCalls`, the Messaging interface's `GetStatus`) stay open, as
|
||
ModemManager's are to every local account: the call
|
||
signals reach them all anyway, the status (the address, the P-CSCF, the
|
||
phone number) travels in no broadcast signal — `Received` carries the
|
||
phone number (`to`) and the SIM's operator, unicast to the Messaging
|
||
interface's subscribers (§8.4).
|
||
|
||
Two threads: a dedicated engine thread runs the SIP loop (blocking framed
|
||
receive on the protected client flow, the protected-port listeners for
|
||
terminating requests, media reaping, the keepalive refresh); the GLib main
|
||
loop owns the bus. D-Bus method calls push commands to the engine queue;
|
||
engine events reach the bus through `g_idle_add`, where the calls table and
|
||
the status snapshot live (main thread only). The Messaging interface's
|
||
`Subscribe` keeps its subscriber set on the main thread as well, and
|
||
`List` and `Delete` read and unlink the received-message store there while
|
||
the engine thread writes it — safe through the `.tmp` + `link(2)` publish
|
||
(§7.9). On the same bus imsd is a client of logind's
|
||
(`org.freedesktop.login1`): the main thread takes its sleep inhibitors
|
||
there and listens for its `PrepareForSleep` (§7.6, §7.10).
|
||
|
||
Per answered call imsd forks `imsd-media` (`IMSD_MEDIA`, default next to the
|
||
`imsd` binary, else `/usr/libexec/imsd-media`) with the addresses, ports and
|
||
payload type as arguments, the codec and audio knobs in its environment
|
||
(§7.6, §10.2) and its stdin on a pipe from imsd, the control pipe the DTMF
|
||
tones travel down (§7.6).
|
||
|
||
The desktop daemons are translation layers: `imsd-dialerd` runs as the
|
||
session user (autostarted from `/etc/xdg/autostart/imsd-dialerd.desktop` in
|
||
place of plasma-dialer's `modem-daemon`, whose autostart the package hides
|
||
through `/etc/skel/.config/autostart/org.kde.modem.daemon.desktop`);
|
||
`imsd-ofonod` runs as root on the system bus (`imsd-ofonod.service`,
|
||
`Conflicts=ofono.service`). Both consume the frozen ABI and add nothing to it.
|
||
|
||
### 7.2 Bring-up
|
||
|
||
`imsd.service` runs two `ExecStartPre=` steps before the daemon:
|
||
|
||
1. `/usr/libexec/ims-pdn-up.sh` brings the `ims` PDN up through ModemManager,
|
||
reads the P-CSCF list the network put in the PDN's PCO (`imsd-pcscf`;
|
||
skipped when `PCSCF=` is set), gives the first a host route (§7.3) and
|
||
writes `/run/imsd.env` with `DEV=` (the connected netdev), `LOCAL=` (the
|
||
PDN address ModemManager assigned), `PCSCF_DISCOVERED=` (the IPv6 addresses of
|
||
that list, at most eight, comma-separated in the modem's order; IPv4 entries
|
||
and names dropped) and `PCSCF_DISCOVERY=` (how it came to be:
|
||
found, none, failed or skipped, §7.3) — or `IMSD_IDLE=<reason>` alone when
|
||
the bring-up found nothing to do (§7.3).
|
||
2. `/usr/libexec/imsd-handover.sh` (`ExecStartPre=-`, failure-tolerant) hands
|
||
a pre-0.3.10 daemon's throttle wait over (§7.5).
|
||
|
||
The unit then reads `EnvironmentFile=-/run/imsd.env` and
|
||
`EnvironmentFile=-/etc/imsd.env` (the admin's file wins) and starts
|
||
`/usr/bin/imsd`. systemd reads those files anew for every command it spawns,
|
||
so each `ExecStartPre=` already sees the values the previous one wrote.
|
||
`TimeoutStartSec=900` covers the bring-up's worst case (a 2-minute modem wait,
|
||
a 5-minute registration gate, connect retries). `Restart=on-failure`,
|
||
`RestartSec=120`; `KillMode=mixed` with `TimeoutStopSec=10`; `StateDirectory=imsd`
|
||
(`/var/lib/imsd`).
|
||
|
||
The daemon's own bring-up (`BringUp()` in `main.cpp`):
|
||
|
||
1. The P-CSCF a fresh registration goes to is `PCSCF=` when set, else the
|
||
first address of `PCSCF_DISCOVERED=` (the bring-up's reading of the PDN's
|
||
PCO, §7.3); the journal says which (`pcscf: configured …` / `pcscf:
|
||
discovered … (using …)`). A resume needs neither: the kernel's SAs name
|
||
its P-CSCF (step 3). With neither, a bring-up that did not resume ends in
|
||
the fatal `no P-CSCF for a fresh registration: …` and the restart's retry
|
||
when the resume merely failed or the discovery did (`PCSCF_DISCOVERY=failed`,
|
||
§7.3), else in the clean `idle: no P-CSCF …` exit (§7.3) — and since no
|
||
fresh one follows, a resumable pair whose attempt failed (a silent
|
||
connect, an unanswered refresh, a first refusal without a Retry-After —
|
||
the refusal count goes to the holds) is not written off and stays for the
|
||
restart to resume, unless the
|
||
engine's rule ends it: a 401, a refusal with a Retry-After or the second
|
||
refusal (`RefusalsBeforeFresh`; the count travels in the holds, so the
|
||
restart's refusal is the second) give the resume up, a 403 once a fresh
|
||
registration is due or a binding a NOTIFY terminated under the attempt
|
||
write the registration off — either way the pair counts as one nothing
|
||
can resume. A pair nothing can resume (its UE address left the link, no
|
||
state file, a file another attempt left behind or whose identity fails the check, written off before this start or
|
||
given up by the engine during the attempt) is written off (`old_gone` in the holds — written as
|
||
well for a pair `RESUME=0` leaves untried) and taken
|
||
out of the kernel first (`the SA pair to … is nothing to resume: removing
|
||
it` — by exact key, what two rules select — the fingerprinted policies and the reqid-1/2 transport-mode ESP states in their direction or on the UE's ims-PDN address, §12), so the next bring-up
|
||
finds nothing to resume.
|
||
2. `qmicli -d qrtr://0 --uim-get-card-status` finds the ready USIM (slot, AID);
|
||
`mmcli -m any` gives the primary SIM path and the IMEI (for the
|
||
`+sip.instance` URN); `mmcli -i <sim>` gives IMSI and MCC/MNC, from which
|
||
the IMPI/IMPU/realm are derived (TS 23.003 13.2 to 13.4B) — the names
|
||
of a UE without an ISIM (TS 24.229 5.1.1.1A). Since 1.2.3, unless
|
||
`ISIM=0` is set, a card with an ISIM application in the USIM's slot
|
||
(`ParseIsimApp`, in whatever state the modem lists it) is asked for the
|
||
identity that ISIM holds: over a logical channel on the application imsd
|
||
reads EF_IMPI (the private identity), EF_DOMAIN (the home domain) and
|
||
record 1 of EF_IMPU (the public identity to register, GSMA IR.92 2.2.1),
|
||
each with a SELECT by file identifier and a read, and takes the three
|
||
when `IsimIdentity` accepts them (`identity: the ISIM's (application
|
||
state …): …`, with whether they are the names the IMSI gives). Then the
|
||
ISIM is asked for the answer to the challenge (step 4). When the card
|
||
has no ISIM, when `ISIM=0` is set, or when the ISIM gave no identity,
|
||
the derived identity and the USIM stand, as in 1.2.2,
|
||
and the `identity: derived from the IMSI …` line says which of the three
|
||
and, for the last, what was missing (§7.8). The read is made at every
|
||
bring-up of such a card, a resume's too, and at each recovery by a
|
||
fresh registration later in the same run (`FreshRecover`) while no read
|
||
since the bring-up has given one. That is the card's identity, and a fresh
|
||
registration is made under it. A resumed registration keeps the one it
|
||
was made under until its next fresh registration, as it keeps its
|
||
P-CSCF and its address (step 3): the state file records the three names
|
||
since 1.2.3, and a file without them is taken for one made under the
|
||
derived ones (`identity: the registration to
|
||
resume was made under …; it keeps them until the next fresh
|
||
registration, which takes the card's` when they are not the card's;
|
||
`identity: the fresh registration takes the card's: …` when that
|
||
registration comes under other names, and after an attempt that fails
|
||
the names are back that stood before it). The registration's home
|
||
domain is also what `RuriFor` and `ScPsi` take, for an outgoing call's
|
||
Request-URI and for the service centre's address of an SMS submission
|
||
(§12). With SMS over IP on and `SMSC=` unset,
|
||
`qmicli --uim-read-record` of EF_SMSP record 1 names the service centre
|
||
(§7.9). `mmcli --location-get` fills
|
||
`P-Access-Network-Info`.
|
||
3. **Warm resume** when an SA pair is already in the kernel and the state
|
||
file (`STATE_FILE`, default `/var/lib/imsd/imsreg.state`) describes the
|
||
registration: reconnect through the existing SA and send a refresh
|
||
re-REGISTER (`RESUME via existing SA`, then `REGISTERED (resumed +
|
||
true-refreshed)`). This avoids the network's fresh-SA throttle. `RESUME=0`
|
||
forces a fresh registration where there is a fresh target; with none the
|
||
untried pair is taken out and the bring-up ends as step 1 says. A resume the network refuses is not fatal while there is a fresh target:
|
||
the fresh registration follows and replaces its SAs — at once, or after
|
||
the hold the reducer keeps (a Retry-After the refusal carries, the one
|
||
refusal that reaches the reducer with a target; a binding a NOTIFY
|
||
terminated under the resume; a fresh hold kept from before this start);
|
||
with no target every refusal reaches the reducer,
|
||
§7.4; with none it is the fatal and the
|
||
restart, or the idle (step 1). The SA reader, the holds file's `pdn`
|
||
key, `LOCAL` and `PCSCF` compare addresses in RFC 5952 §4 form
|
||
(`imsd::util::CanonicalAddr`: lower-case hex, leading zeros dropped, the
|
||
longest zero run compressed — what `ip xfrm` prints for a plain IPv6
|
||
address; an IPv4-mapped address is read in that hex form only, never with
|
||
the dotted tail `ip` prints), and `PCSCF=` is accepted in that one spelling
|
||
only: upper case, leading zeros or an uncompressed run are refused at
|
||
bring-up with the one to use (`PCSCF='…' is not written as ip prints it;
|
||
use PCSCF=…`), a dotted-quad tail with the rule but no spelling, a
|
||
bracketed value by the bring-up script with the rule (`write the bare
|
||
address, as ip prints it (no brackets)`), a comma-separated `PCSCF=` (a
|
||
list) with its own message (`must be one address`; in the packaged unit the
|
||
bring-up script, which runs first, fails a list before the daemon sees it)
|
||
— one spelling, so the
|
||
bring-up script, which routes the value as typed, and the daemon agree on
|
||
it. Before 1.0.0 an upper-case, zero-padded or uncompressed `PCSCF=` was
|
||
accepted and, compared as text against `ip xfrm`, matched no SA and
|
||
registered fresh at every restart; an upgraded phone with such a setting
|
||
stops at bring-up with the spelling to use. A resume follows the kernel's SA peer (`SaPeer`), not
|
||
`PCSCF=`: a registration made to another P-CSCF than today's setting is
|
||
resumed there (`pcscf: resuming on …`; imsd routes that peer itself once
|
||
`ParseExistingSa` confirms the SAs) and moves at the next fresh
|
||
registration (`the fresh registration moves from P-CSCF X to Y`; an
|
||
attempt that fails before the SA setup goes back while the old registration
|
||
still stands — not written off by its address leaving the link, a NOTIFY
|
||
that terminated the binding or a 403 once a fresh registration was due:
|
||
`back to P-CSCF X: …`).
|
||
A state file written for another SA pair than the kernel's — its
|
||
`spi_uc`/`spi_us` against the pair's (`FileNamesAnotherPair`), a 0.3.x
|
||
file's too: an attempt that got through the SA setup and did not live to
|
||
record, to this or another P-CSCF — is not used; the
|
||
bring-up registers fresh (with no fresh target: the fatal or the idle, step 1). Every fresh registration goes to `PCSCF=`, else the first
|
||
entry of `PCSCF_DISCOVERED=` that `CanonicalIp6` accepts; with neither, a bring-up that cannot resume ends as
|
||
step 1 says (the fatal after a resumable pair's failed attempt or a failed
|
||
discovery, else the clean `idle: no P-CSCF …` exit — a resume the engine
|
||
gave up or wrote off included) and a recovery step that needs one
|
||
restarts the daemon through systemd.
|
||
4. **Fresh registration** otherwise (`FRESH registration`): the target's host
|
||
route (imsd's own `ip -6 route replace`; step 3 says which target), an
|
||
unprotected REGISTER on `PCSCF_PORT` (UDP, always), the 401 with the AKA challenge and
|
||
the `Security-Server` list, the AKA run over a UIM logical channel
|
||
(`--uim-open-logical-channel`, `--uim-send-apdu`) — in the ISIM when the
|
||
card's identity was read from it, else in the USIM; the command is the
|
||
same (AUTHENTICATE with P2 `81`: the 3G context of TS 31.102 7.1.2, the
|
||
IMS AKA context of TS 31.103 7.1.2), and an ISIM that gives no result
|
||
is followed by the same challenge to the card's USIM (`AKA: the ISIM
|
||
application gave no result (…); asking the USIM`). TS 24.229 5.1.1.1A
|
||
has the ISIM used for authentication whenever the card has one: with
|
||
`ISIM=0`, with an ISIM that gave no identity and behind one that gives
|
||
no result imsd asks the USIM —, the SA pair installed
|
||
with `ip xfrm`, the protected REGISTER over the negotiated transport
|
||
(§10.1, `SIP_TRANSPORT`), `REGISTERED (fresh)`. Then the reg-event
|
||
SUBSCRIBE (§7.4).
|
||
5. A keepalive re-REGISTER refresh at half the granted lifetime (of
|
||
3600 s where none was granted), within
|
||
120–1800 s (`REFRESH_INTERVAL`), only while idle; the time runs
|
||
through a suspend, and a sleeping phone is woken for it where imsd
|
||
has its wake alarm (§7.10).
|
||
Besides it an idle
|
||
phone whose registration stands sends what its reg-event subscription
|
||
needs (§7.4). The CRLF keepalive (RFC 5626 4.4.1) imsd sent every 30 s
|
||
until 1.2.3 is off unless `CRLF_KEEPALIVE` names an interval in whole
|
||
seconds (a TCP flow's only; an empty value is as none, any other that
|
||
is no whole number is reported and sends none; §13 has what a ping
|
||
costs a phone). No registration of imsd's negotiates keep-alives: its
|
||
REGISTER has no `outbound` in `Supported` and no `reg-id` (RFC 5626
|
||
4.2.1), and no `keep` in the Via (RFC 6223), which TS 24.229 5.1.1.2.1
|
||
d) has a UE offer unless it is configured not to send keep-alives or
|
||
is directly connected to an IP-CAN for which usage of NAT is not
|
||
defined. What a ping does for a flow, outside a call (none is sent in
|
||
one): sent more often than a P-CSCF's timer for a flow it hears
|
||
nothing on, it keeps that P-CSCF from dropping the flow, and it draws
|
||
the reset of a P-CSCF that has lost the flow. On the phone it also
|
||
kept the connection tracker's entry for the P-CSCF's ESP, which the
|
||
firewall's rule for ESP makes needless (§13). Without the ping: a
|
||
close by the network is answered, outside a call, with a reconnect
|
||
and a refresh (`client flow dead; reconnecting`, §7.4); the reconnect's
|
||
first connect can be refused, the closed flow's socket still in the
|
||
kernel's table (`connect failed; retry in 10s (TIME_WAIT?)`: a user's
|
||
log on O2, 2026-09-24), and its second follows 10 s later. A flow the
|
||
network has dropped without closing, where it answers the next bytes
|
||
on it with a reset, is found at those bytes: where they are this
|
||
refresh's, it fails (`keepalive re-REGISTER failed: …`) and the same
|
||
reconnect follows; where they are a call's INVITE, the shell reopens
|
||
the flow for the call (§7.6); where they are a call's BYE, the BYE
|
||
is lost (§7.6); where they are a text's MESSAGE, it is lost with the
|
||
flow and the text's wait decides (§7.9); where they are the delivery
|
||
report of a text that came in, the report is lost with the flow and
|
||
not sent again. A flow that died with no close and no
|
||
reset reaching the phone is noticed when this refresh's re-REGISTER
|
||
gets no answer, or sooner where TCP gives up on bytes imsd sent on it
|
||
before that (924.6 s or more after them by the kernel's default
|
||
`tcp_retries2` of 15); until 1.2.3 a ping's were among those bytes
|
||
every 30 s outside a call. The refresh of a
|
||
registration this process made fresh is a reregistration as TS 24.229
|
||
5.1.1.4.2 has it: the same Call-ID and Contact, the CSeq one above the
|
||
last REGISTER sent on that Call-ID, answered or not (RFC 3261 10.2;
|
||
the number is used, and in the state file, once the REGISTER is sent:
|
||
§13 has KPN's 482 to re-REGISTERs that, by 1.2.4's code, carried an
|
||
unanswered one's number), the
|
||
Authorization of the last successful authentication verbatim (the 401's
|
||
nonce, our cnonce and response, kept in the state file), a
|
||
Security-Client with new SPIs and a new client port (`PortUcNext`,
|
||
45063) for the SA pairs a re-authentication would set up — the server
|
||
port stays (TS 33.203 7.4.0) — and the Security-Verify (the 401's list).
|
||
A registration resumed from the kernel's SAs sends the same
|
||
Security-Client as that refresh, the Authorization the state file holds
|
||
(a file from before 0.3.11: the empty digest) and the Security-Verify
|
||
from the state file (since 0.3.12); resumed from a file written before
|
||
0.3.12, from one whose list `PersistState` wrote empty, or from one
|
||
whose list names another SA pair than the kernel holds (an attempt the
|
||
process did not live to record: its SAs installed, its 200 not
|
||
written — since 1.0.0 such a file is not resumed at all when its own
|
||
`spi_uc`/`spi_us` are not the pair's, step 3), it sends —
|
||
on the resume's re-REGISTER, the keepalive re-REGISTERs, the reg-event
|
||
SUBSCRIBE and INVITEs, until its next fresh registration — the one
|
||
entry rebuilt from the SA, with the algorithms the kernel prints for it
|
||
(`Imsd:Ipsec`, which makes the choice): KPN's one-entry answer to the
|
||
default offer in the same bytes, not a list such as O2's six, which RFC 3329 §2.3.1 has the server answer with a
|
||
494 when it does not mirror its own; a refused resume registers fresh (with
|
||
no fresh target: the fatal and the restart, or the idle, step 1).
|
||
A 401 to a
|
||
reregistration asks for re-authentication over temporary SAs on the
|
||
proposed ports, which imsd does not implement: it is a refusal and the
|
||
recovery is a fresh registration (§7.4). Every refresh of the pre-0.3.11
|
||
shape on record from O2 UK (an initial registration's empty digest, the
|
||
in-use SPIs) was refused with 503 (§13).
|
||
|
||
The state file is JSON: `callid`, `ftag`, `cseq`, `spi_uc`, `spi_us`,
|
||
`expiry`, `route`, `ppi`, `aor`, `contact_user`, `transport`, since 1.2.3
|
||
`impi`, `domain` and `impu` (the identity the registration was made under,
|
||
which a resume keeps — step 2; all three absent in an older file: the
|
||
derived identity; a file that holds one or two of them, or three that are
|
||
no identity `IsimIdentity` accepts, is not resumed: `the state file's
|
||
identity is not one imsd can register; …`), since 1.0.0
|
||
`pcscf` (the P-CSCF the registration was made to; named in the line that
|
||
reports a file another attempt left behind — the check is the SPIs',
|
||
`FileNamesAnotherPair`), since 0.3.12
|
||
`security_server` (the registration's Security-Verify: the 401's list,
|
||
written empty when it holds a quote, a backslash or a newline; absent,
|
||
empty or naming another SA pair than the kernel's — a file from before
|
||
0.3.12, such a list, or a file an unrecorded attempt left behind — the
|
||
resume rebuilds one mechanism from the SA, logs which, and stores that),
|
||
and since
|
||
0.3.11 `auth_nonce`, `auth_cnonce`, `auth_response` (a registration resumed
|
||
from an older file has none: its reregistrations — the resume's and the
|
||
keepalives', across restarts — carry the empty digest, as before 0.3.11,
|
||
until its next fresh registration, and each such resume logs it).
|
||
|
||
A failed fresh bring-up exits non-zero and systemd retries after
|
||
`RestartSec` — except a bring-up the network refused or throttled, which
|
||
waits in process on the refusal schedule (§7.4) with nothing to reconnect
|
||
over, then tries again (`bring-up deferred: …`). A registered daemon whose
|
||
address leaves the netdev with no PDN address there to move to also exits
|
||
(`engine fatal: … is no longer on qmapmux0.0 — exiting for systemd
|
||
restart`) — not at once: the loss is
|
||
noticed at the next recovery step, the refresh (every 1800 s on KPN's
|
||
7200 s grant), whose
|
||
re-REGISTER gets no reply and whose reconnect cannot bind the address (dev
|
||
phone 2026-10-02, the ims bearer disconnected under a registered daemon:
|
||
14 min from the disconnect to the exit). After `RestartSec` (120 s)
|
||
`ims-pdn-up.sh` runs again and imsd registers on the PDN's address (the
|
||
same bench: a new prefix, `REGISTERED (fresh)` six seconds into the new
|
||
start).
|
||
|
||
### 7.3 The ims PDN (`packaging/ims-pdn-up.sh`)
|
||
|
||
Finds or creates the `ims` bearer through ModemManager, connects it and
|
||
configures the muxed netdev. Idempotent; a non-zero exit fails the unit.
|
||
|
||
- Waits up to 120 s for a modem, then gates the connect attempts on network
|
||
registration (`IMS_REG_TIMEOUT`, default 300 s): some carriers attach ~2 min
|
||
after boot.
|
||
- Idles instead of retrying when there is nothing to do: a modem in the
|
||
`failed` state with a SIM reason (`sim-missing`, `esim-without-profiles`,
|
||
`sim-error`), checked once the modem appears and again while waiting for
|
||
registration, writes `IMSD_IDLE=no-sim` to `/run/imsd.env` and exits 0; a
|
||
profile-indexed connect series refused ten times in a row — each a
|
||
persistent 3GPP cause in ModemManager's typed error
|
||
(`ServiceOptionNotSubscribed`, `MissingOrUnknownApn`,
|
||
`OperatorDeterminedBarring`, `ServiceOptionNotAuthorizedInPlmn`,
|
||
`UserAuthenticationFailed`, `ServiceOptionNotSupported`, `Ipv4OnlyAllowed`,
|
||
`Ipv6OnlyAllowed`) with packet service at the time — writes
|
||
`IMSD_IDLE=no-ims-pdn` (the line carrying the last error). The script's own
|
||
rule, stricter than the daemon's `PacketServiceUp`: a refusal counts only
|
||
while the modem reads `registered`, `connecting` or `connected` with packet
|
||
service not `detached`; any other read (`searching`, `disconnecting`,
|
||
`unknown`, an unanswered `mmcli`), a D-Bus timeout, `esm-proc-timeout`, a
|
||
transient cause (`InsufficientResources`, `ServiceOptionOutOfOrder`,
|
||
`NetworkFailureActivation`) or any other error starts the count again, as a
|
||
coverage gap does — an outage must not idle VoLTE until the next boot. Installing the package and inserting a
|
||
SIM is the opt-in: `/etc/imsd.env` holds overrides only and its existence
|
||
changes nothing here (before 1.0.0 the apk's drop-in made it the switch for
|
||
the whole unit, §9.2). imsd reads the key, logs `idle: …` and exits 0;
|
||
`Restart=on-failure` leaves a clean exit alone, so the unit stays inactive
|
||
until the next boot, a `systemctl start imsd` or a start of `imsd-ofonod`,
|
||
whose `Wants=imsd.service` starts an idle imsd again (the Phosh image: an
|
||
`imsd-ofono` upgrade, its own restart after a crash) — one attempt per
|
||
boot, or per such start. What is not a fact keeps the retry: ten failures
|
||
without coverage — the network found only at the end or lost on the way —
|
||
exit 1 like a disabled radio, as do a SIM still waiting for its PIN (the
|
||
modem `locked`), a modem whose final profile list has no ims APN (the
|
||
APN-string connect is tried; a connected APN-string bearer — a run whose
|
||
lookup failed at boot — is reused and its registration resumed) and an
|
||
APN-string series, which a walled carrier's modem refuses locally.
|
||
The dead end after the PDN is up is the daemon's own, decided in `main()`
|
||
before it takes the bus name with the same clean exit: nothing to register
|
||
to — no `PCSCF=` and nothing discovered: `PCSCF_DISCOVERY=none` (no IPv6
|
||
P-CSCF read from the PCO — the reader's exit 2: the list absent, empty,
|
||
unreadable, or IPv4/FQDN entries only), `skipped` (a netdev without an rmnet
|
||
mux id) or no `PCSCF_DISCOVERY=` at all (a manual run) —
|
||
and no registration of its own to resume (`SaPeer` finds no pair, or the
|
||
holds for this PDN and boot say `old_gone`):
|
||
`idle: no P-CSCF — none configured (PCSCF=), none discovered (see the
|
||
ims-pdn-up lines) — and nothing to resume; set PCSCF= in /etc/imsd.env to
|
||
name one`; a pair the holds wrote off is taken out of the
|
||
kernel by exact key on the way (`the SA pair to … is nothing to resume:
|
||
removing it`, §12), so no start of this boot finds it. The no-target
|
||
bring-up decides the same after its resume attempt: a resumable pair whose attempt failed keeps the fatal
|
||
and the restart; a dead pair is written off, taken out of the kernel (§12)
|
||
and the daemon idles (`RequestIdle`). A reader that did not answer
|
||
(`PCSCF_DISCOVERY=failed`) is no fact: the daemon exits 1 instead — before
|
||
the bus name with `no P-CSCF: discovery failed … — exiting for systemd
|
||
restart`, from the no-target bring-up with `bring-up FAILED: no P-CSCF for a
|
||
fresh registration: …` and `engine fatal: … — exiting for systemd restart` —
|
||
and the unit's restart runs discovery again.
|
||
- Never creates or connects a bearer while the modem is `disabled` — its
|
||
radio is off (airplane mode): a modem still disabled after the wait, or
|
||
disabled when an attempt is due, makes the script exit non-zero (`modem …
|
||
disabled … (radio off): not connecting`) and systemd retries. A bearer
|
||
connect on a disabled modem fails with `no-service` and leaves
|
||
ModemManager's state `enabled` with the modem in low power; switching the
|
||
radio back on then no longer brings it up (dev phone 2026-10-06: not
|
||
registered after 150 s, against 5 s without the attempt; a ModemManager
|
||
disable/enable recovered it).
|
||
- Connects by **3GPP profile index** (`IMS_PROFILE_ID`, default: looked up by
|
||
APN in `qmicli --wds-get-profile-list=3gpp`), not by APN string: a
|
||
profile-indexed request is exempt from the modem's attach-family forcing
|
||
that refuses an APN-string IPv6 request when the attach PDN was granted
|
||
IPv4-only (Odido, O2 UK, Swisscom). An empty profile list is the modem still
|
||
coming up; a list without the APN is final only once the modem is
|
||
registered (the list can be partial while it enables). A leftover
|
||
APN-string bearer is never reused and is deleted when connecting by index.
|
||
- Sets `accept_ra_defrtr=0` on the netdev before link-up: the PDN's router
|
||
advertisement must never make the ims PDN the phone's IPv6 default route (on
|
||
IPv4-only wifi every AAAA-first client would send its SYNs into the IMS
|
||
walled garden and hang). The RA's prefix and MTU still apply. An RA default
|
||
route already present (an imsd restart) is flushed.
|
||
- Sets the PDN MTU ModemManager reports on the link (1280 on the FP6), adds
|
||
the address and waits out DAD.
|
||
- Resolves the P-CSCF: `PCSCF` when set (one IPv6 address; it wins and
|
||
discovery is skipped — a list or a non-IPv6 value exits non-zero), else
|
||
`imsd-pcscf --mux <the netdev's rmnet mux_id> [--profile <index>]` reads
|
||
the list the network put in the PDN's PCO from the modem (§13; the mux id
|
||
from `ip -d link show <netdev>`), not for `IMS_IP_TYPE=ipv4`, which the bring-up does not support (it
|
||
configures only the PDN's IPv6 address). The usable
|
||
addresses — IPv6; IPv4 ones and names are logged and dropped — are handed
|
||
over (at most 8) and the first, the daemon's fresh target, gets a host route
|
||
(`dev <netdev>`, no gateway — a raw-IP netdev without header_ops); imsd
|
||
routes the P-CSCF it uses itself as well — the fresh target before a fresh
|
||
registration, the resumed SA peer once its SAs are confirmed (§7.2 steps 3 and
|
||
4) —, as each call's media peer is. Nothing usable is logged with
|
||
its cause (`nothing usable (…)`), is not the script's failure, and is told
|
||
apart in the hand-off: `PCSCF_DISCOVERY=none` when the reader found no IPv6
|
||
P-CSCF in the PCO (its exit 2: the list absent, empty or unreadable —
|
||
`tests/Qmi` pins the tolerant read) — a fact of this PDN: a registration of imsd's own that
|
||
can be resumed is resumed and stays up (a fresh registration later restarts
|
||
the daemon for want of a target, and that start runs discovery again), a
|
||
bring-up that did not resume ends in the daemon's clean idle (`idle: no
|
||
P-CSCF …`, the idle rule above) or, after a resumable pair's failed
|
||
attempt, in the fatal and the restart; `PCSCF_DISCOVERY=failed` when the
|
||
reader did not answer (an error, a timeout, nothing printed) — no fact: a
|
||
daemon with nothing to resume exits 1 and the unit's restart runs
|
||
discovery again. Anything else on
|
||
the IMS network (its DNS servers, a traceroute target) needs its own host
|
||
route (`ip -6 route add <addr> dev qmapmux0.0`). imsd installs a host route
|
||
per media peer itself, and one to the P-CSCF it registers to or resumes on
|
||
(§7.2 step 3).
|
||
- Opens imsd's protected ports 45061–45062 (TCP and UDP) on `qmapmux*` in
|
||
nftables when a `inet filter` table exists (pmOS's default INPUT chain drops
|
||
inbound on `qmapmux*`, which silently killed every network-initiated
|
||
request after ESP decapsulation), and accepts ESP itself on `qmapmux*`
|
||
(the packet passes the chain before it is decapsulated too; §13). Each
|
||
under its own comment in the chain, `imsd-protected-ports` and `imsd-esp`,
|
||
and only where the chain has no rule under that comment. Best-effort,
|
||
and in the running ruleset only: what the script inserted is gone when
|
||
the ruleset is next loaded from its files (§13).
|
||
- Writes `/run/imsd.env`: `DEV=<netdev>`, `LOCAL=<PDN address>`,
|
||
`PCSCF_DISCOVERED=<list>` (comma-separated in the modem's order; empty when
|
||
nothing was discovered or `PCSCF` is set) and `PCSCF_DISCOVERY=found|none|failed|skipped`
|
||
(how the list came to be: the PCO's answer, the reader's failure, or
|
||
discovery not run — `PCSCF=` set, `IMS_IP_TYPE=ipv4`, no rmnet mux id), and
|
||
logs the line it wrote. imsd
|
||
registers on the address the network assigned, not on the kernel's
|
||
temporary SLAAC address from the RA, which the netdev lists first and
|
||
retires after about two days (the SAs and the Contact would go with it).
|
||
The script never reads `PCSCF_DISCOVERED` from its environment: the unit
|
||
hands it the previous run's file, and a stale discovered value must not
|
||
pass for the admin's `PCSCF=`.
|
||
|
||
Its own settings (read from the environment, else from the file `IMSD_ENV`
|
||
names, `/etc/imsd.env` by default, for manual runs): `IMS_APN` (default
|
||
`ims`), `IMS_IP_TYPE` (`ipv6`), `IMS_PROFILE_ID` (empty = look up; `none` =
|
||
connect by APN string), `IMS_REG_TIMEOUT` (300) and `PCSCF`; from the
|
||
environment only, `IMSD_PCSCF` (the reader's path, default
|
||
`/usr/libexec/imsd-pcscf` — the mock bench's seam) and `IMSD_ENV` (the
|
||
configuration file's path — the bench's seam too).
|
||
|
||
### 7.4 Registration recovery (`RegRecovery`, `Imsd-Engine.cppm`)
|
||
|
||
What the daemon does when the registration stops working after bring-up, as
|
||
a pure reducer the shell feeds with the clock, the network's answers and its
|
||
local waits (a connect the kernel refused, the modem without packet
|
||
service). Two
|
||
kinds of failure reach it: a **refusal** (the network answered a refresh with
|
||
a final other than 200 — a 401, re-authentication, included — or a fresh
|
||
registration's REGISTER with a final other than the expected one: from 300
|
||
up on the unprotected one, whose 401 is the challenge, anything but 200 on
|
||
the protected one) and **silence** (the flow died
|
||
and reconnecting through the SA, or the refresh over it, got no answer).
|
||
Neither is retried for long on the same registration (TS 24.229 5.1.1.4 and
|
||
RFC 5626 have the UE register anew). Before this reducer existed the daemon
|
||
looped reconnect + re-REGISTER on one Call-ID and SA forever (O2 UK,
|
||
2026-09-24: 21 × 503 over 70 min, then 33 unanswered reconnect cycles over
|
||
2 h 39 min).
|
||
|
||
The policy, with its constants:
|
||
|
||
| Step | Rule |
|
||
|---|---|
|
||
| Reconnect | Through the existing SA, then refresh. Back-off 5 s → 5 min (`ReconnectDelayMin`/`Max`). |
|
||
| Escalate to a fresh registration | After one refused refresh whose `Retry-After` is at least a second (the network's considered answer; a `Retry-After` of 0 or one that does not parse counts as none; O2 2026-10-08: the refresh refused 503 with Retry-After 414 s, the refresh after that wait 503 with Retry-After 772 s) or a 401 (re-authentication, which imsd answers with a fresh registration rather than over temporary SAs), after two refused refreshes without one (`RefusalsBeforeFresh`), or two reconnect cycles that end without an answer (`SilentCyclesBeforeFresh`) while the modem reports packet service (`PacketServiceUp`: ModemManager's registration and packet-service state, as `ims-pdn-up.sh` reads them). A cycle that fails during a coverage gap is the phone's silence, not the network's: not counted, retried on the local-refusal pace, so a radio gap across a refresh does not escalate into a fresh registration, which KPN refuses while the registration is live and drops it for (§13). New Call-ID, new challenge, new SA pair (`registering fresh (recovery attempt N)`; with no fresh target the daemon restarts instead, §7.2 step 3). |
|
||
| No packet service | While the modem reports none (`PacketServiceUp`) the recovery tries no reconnect and no fresh attempt and holds no sleep off (§7.10; a bring-up does not ask the modem): the modem is asked again 5 s after each look while the phone is awake and no call is up (`LocalRetry`, the pause after a connect the kernel refuses locally as well), and where imsd has its wake alarm a sleeping phone is woken for the next look after as long again as that kind of wait has lasted, within 10 s and 15 min (`LocalWakeMin`/`Max`): where the modem has no service, since its first such word since the network last answered (an answered TCP connect of the resume or of a reconnect, a response to a REGISTER, a terminated binding, a success); where the kernel refuses the connect, since its first refusal since the modem was last without service or the network last answered, whichever came later. A report of service from the modem starts neither count over. A step that follows no local wait (the rows above and below) is woken for at its own time. A `Dial` on the dead flow meanwhile ends at once: nothing is reopened under it (§7.10). |
|
||
| A refused or throttled fresh attempt | Waits on the **throttle schedule**: 21 min, growing ×1.5 to 60 (`ThrottleMinutesMin`/`Max`). KPN refuses a fresh SA pair on an address whose registration is live (§13), and drops that registration the moment an initial REGISTER arrives. |
|
||
| A silent fresh attempt | Backs off 30 s → 10 min (`FreshDelayMin`/`Max`). |
|
||
| `Retry-After` | Always wins over a shorter wait, honoured up to an hour (`RetryAfterMax`, the schedule's longest wait); a longer one is cut to an hour and the refusal heard again then. On a refused fresh attempt it replaces the schedule's wait, shorter or longer, never below 30 s (`FreshDelayMin`). |
|
||
| A 403 | A refusal like the others: never hammered (the schedule), never abandoned (a SIM that is unbarred registers within the hour). |
|
||
| The old registration is gone | A 403 once a fresh registration is due, a fresh attempt that got past the SA setup, a binding the network terminated (reg-event), an older address that left the netdev, or a bring-up whose resume failed while a fresh registration follows (with no fresh target a resumable pair whose attempt failed is kept for the restart; a pair nothing can resume — given up or written off by the engine, its address off the link, no state file, a file another attempt left behind or whose identity fails the check, left untried by `RESUME=0` — is written off and taken out of the kernel, §7.2 step 1): no reconnect over the old SA from then on. Otherwise the existing SA is still retried on the reconnect back-off while a fresh registration is deferred. |
|
||
| A `Dial` while unregistered | Brings the next recovery step forward (the reconnect, or the fresh attempt once it is due) — never a wait the network imposed (a `Retry-After`, or the schedule after a refused or throttled fresh attempt). imsd-ofonod refuses a `Dial` then and imsd-dialerd lists no modem. |
|
||
| Success | Resets everything. |
|
||
|
||
The network's waits are **holds**, and a restart of imsd (an upgrade restarts
|
||
it) does not cut them short: `PersistHolds` writes them to the holds file
|
||
(`HOLDS_FILE`, default `/run/imsd.holds`) as JSON — `pdn` (the PDN's own
|
||
address), `boot` (the boot id), `written_at` (seconds of uptime), `hold`,
|
||
`fresh_hold`, `throttle_minutes` (the schedule's place), `old_gone` (the old
|
||
registration is gone: a 403 once a fresh registration is due, an attempt past
|
||
the SA setup, a binding the network terminated, an older address that left
|
||
the netdev, and every bring-up that goes on to register fresh — its resume
|
||
failed or there was nothing to resume; a bring-up with no fresh target
|
||
writes `old_gone` when nothing can be resumed — a pair nothing can resume: its UE
|
||
address left the link, no state file, a file another attempt left behind or whose
|
||
identity fails the check, written
|
||
off before this start, given up or written off by the engine during the
|
||
attempt, left untried by `RESUME=0` — never for a pair kept for the restart,
|
||
§7.2 step 1); the reducer's refusal count travels too (`refusals`): a resume
|
||
refused without a Retry-After at a start with no fresh target is one
|
||
refusal, the restart's is the second and `RefusalsBeforeFresh` gives the
|
||
resume up — without it the restart loop would re-REGISTER on the same
|
||
Call-ID every `RestartSec`, the F16 shape — and
|
||
`LoadHolds` takes them
|
||
over at the next start for the same `pdn` and boot id, waiting them out
|
||
before the resume (a refresh's `Retry-After`) or before the fresh
|
||
registration (a fresh attempt's schedule or `Retry-After`, a terminated
|
||
binding's wait); with `old_gone` set the start does not resume over the old SAs at
|
||
all: with a fresh target it waits the fresh hold out and registers fresh,
|
||
with none it removes the pair and ends as §7.2 step 1 says — also after a start
|
||
during an outage, whose resume and fresh attempt both fail without an answer:
|
||
the next start then registers fresh while the network still holds the old
|
||
registration, which KPN refuses (§13; dev phone 2026-10-04: 21 min where
|
||
0.3.9's retried resume would have recovered at once). A file without the key
|
||
reads as not gone; the 0.3.9 hand-over (`imsd-handover.sh`) writes the key as
|
||
true, since the wait it hands over follows a throttled initial REGISTER, at
|
||
which KPN drops the old registration (§13). A reboot or another PDN address
|
||
starts clean. The schedule's place is kept
|
||
even after the holds run out, so a restart does not start it over at 21 min.
|
||
When nothing is held the file is removed — when it is a regular file;
|
||
`/dev/null` switches the knob off and anything that is not a regular file is
|
||
emptied, never unlinked. The recovery policy's waits and the holds are
|
||
measured on the boot clock (`CLOCK_BOOTTIME`), so a suspend counts, and
|
||
so are the keepalive refresh's gate and the reg-event subscription's
|
||
renewal ahead of its granted lifetime's end (§7.10; awake seconds in
|
||
the releases up to 1.2.4); the CRLF keepalive (where `CRLF_KEEPALIVE`
|
||
sets one), the reg-event subscription's Timer F, its retries (after a
|
||
refusal, an unanswered SUBSCRIBE, a send that failed) and its renewal
|
||
after the S-CSCF has ended it, and the times SMS over IP measures
|
||
(§7.9: its two waits, 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
|
||
lifetime the S-CSCF granted. Refused or unanswered, it is retried after 60 s
|
||
doubling to 10 min (a `Retry-After` honoured up to an hour; a registration
|
||
refresh neither brings a scheduled retry forward nor starts its back-off
|
||
over — the back-off resets when a subscription starts afresh or is
|
||
accepted). When the S-CSCF ends it
|
||
for a reason that allows renewal (RFC 6665: `deactivated`, `timeout`,
|
||
`giveup`, `probation`) it is renewed; after any other reason — `noresource`,
|
||
`rejected`, a reason-less end — the next registration refresh subscribes anew. An
|
||
earlier subscription's NOTIFY is still read for the binding's state, but its
|
||
end is not ours to renew (KPN closes a registration's previous subscription
|
||
with `noresource` when a new one replaces it). A NOTIFY that **terminates the
|
||
binding** triggers a fresh registration where there is a fresh target (with none a
|
||
running daemon restarts, and a bring-up whose resume the NOTIFY ended idles
|
||
— exit 1 instead when `PCSCF_DISCOVERY=failed` — §7.2 steps 1 and 3) — at
|
||
once, or after the network's `retry-after` (up to an hour); after the call, when one is up (one exception:
|
||
a REGISTER wait that still gets its 200 after such a NOTIFY, a call having
|
||
kept the flow, leaves that registration standing). After
|
||
`rejected` and `unregistered` it waits on the refusal schedule, a wait no
|
||
`Dial` cuts short: the binding is gone, so nothing is retried meanwhile. One
|
||
termination counts once, however many NOTIFYs report it (a repeated
|
||
`probation` report may extend its hold from its own `retry-after`). The schedule is
|
||
shell code in `main.cpp`, not a reducer (§3); its hardware coverage per arm
|
||
is in §5.
|
||
|
||
A registration resumed on an older address (a pre-0.3.10 temporary one)
|
||
moves to the PDN's own address in place: with its next fresh registration, or
|
||
when the older address leaves the netdev first, which takes that registration
|
||
with it.
|
||
|
||
### 7.5 Upgrades and the 0.3.9 hand-over
|
||
|
||
An apk upgrade (or an `apk add` of a package whose daemon an `apk del` left
|
||
running) restarts `imsd` and `imsd-ofonod` once the transaction is done: the
|
||
packages' `post-upgrade`/`post-install` scripts mark the units
|
||
`needs-restart` (`systemctl set-property … Markers=+needs-restart`, after a
|
||
`daemon-reload` when the unit is not-found because its file was just
|
||
reinstalled) and pmOS's systemd trigger runs `enqueue-marked`. A call in
|
||
progress ends. The restart resumes the registration over its existing SAs,
|
||
or goes on waiting out a hold the network had set (§7.4) — or, with an
|
||
upper-case, zero-padded or uncompressed `PCSCF=` (accepted until 0.3.12),
|
||
stops at bring-up with the spelling to use (§7.2 step 3). A stopped unit
|
||
keeps no marker and `enqueue-marked` leaves it stopped (dev phone, systemd
|
||
262~rc3, 2026-10-03) — so a phone that never had `/etc/imsd.env` (the unit
|
||
never started before 1.0.0) keeps its stopped unit through the upgrade and
|
||
starts at its next boot, registering where §7.3's rule lets it — unless `imsd-ofonod`
|
||
runs there (the Phosh image, `imsd-ofono`): the upgrade restarts that daemon,
|
||
and its `Wants=imsd.service` starts imsd at once (`enqueue-marked` queues the
|
||
marked unit's try-restart, systemd collapses it to a restart for a running
|
||
unit, and a restart job pulls in a start job for each `Wants=` — systemd
|
||
262~rc3, `job_type_collapse` and `transaction_add_job_and_dependencies`; dev
|
||
phone 2026-10-11: a stopped imsd was started in the same second an
|
||
`imsd-ofonod` restart began, two seconds after it had been stopped, and
|
||
resumed) — without waiting for it:
|
||
since 1.0.0 `imsd-ofonod.service` has no `After=imsd.service` (that restart
|
||
would otherwise wait behind the ims PDN bring-up — the whole `ExecStartPre`, up to `TimeoutStartSec=900`), so GNOME
|
||
Calls' backend starts at once and republishes when imsd's name appears (`OnImsdAppeared`; dev
|
||
phone 2026-10-12, bench 30).
|
||
|
||
A daemon older than 0.3.10 kept its bring-up throttle wait in memory only, so
|
||
the restart registered fresh at once instead of waiting the schedule out.
|
||
For that one hop: `imsd.post-upgrade` records the running
|
||
daemon's `InvocationID` in `/run/imsd.handover` (when no holds file exists);
|
||
at the next start `imsd-handover.sh` reads that finished invocation's last
|
||
bring-up line from the journal and, when it is the throttle's (`bring-up
|
||
deferred: fresh-SA throttle active (spi-s=0) — … next fresh registration in
|
||
N min`; the old daemon's other deferrals, after a 401 it could not use, are
|
||
not handed over), ages it on the monotonic clock (`__MONOTONIC_TIMESTAMP` against
|
||
`/proc/timer_list`; the phone's wall clock can read 1970 until its first NTP
|
||
sync, and the monotonic clock stops in a suspend, so the wait can only come
|
||
out long, never short of the network's window), and writes what is left to
|
||
the holds file as 0.3.10 keeps it — for the address this start registers on
|
||
when that is the address the wait was earned on (the old daemon logged its
|
||
`LOCAL=` once at start); on another address — the normal hop, 0.3.9 on the
|
||
kernel's temporary address and 0.3.10 on the PDN's own, which holds no
|
||
registration (§13) — only the verdict that the old registration is gone is
|
||
written and the new start registers fresh at once (dev phone 2026-10-03:
|
||
accepted, registered 16 s after 0.3.9's refused attempt) —
|
||
`LOCAL` as systemd hands it to the unit's commands (the `/etc/imsd.env` pin
|
||
if there is one, else what `ims-pdn-up.sh` just wrote), unquoted the way imsd
|
||
itself gets it. Reading at the start rather than at the upgrade means a wait
|
||
that ended in between — the old daemon making another attempt — is
|
||
read as it ended. When the old address cannot be read the wait is handed
|
||
over anyway; when the wait cannot be timed, or this start has no `LOCAL`, the
|
||
journal says it was not handed over.
|
||
|
||
### 7.6 Calls and the media plane
|
||
|
||
`CallMachine` owns one call's SIP dialog, outgoing or incoming, and never
|
||
touches a socket, a clock or a subprocess: each event returns `Action`s for
|
||
the shell (send this on the client flow, answer that request on the channel
|
||
it came in on, start/stop the media leg, hand it the tones a key press
|
||
sent, emit this D-Bus state change, arm this deadline). States and reasons are the frozen D-Bus vocabulary:
|
||
`dialing` / `ringing` / `incoming` / `active` / `terminated`, with reasons
|
||
`outgoing` / `incoming` / `accepted` / `local-hangup` / `remote-hangup` /
|
||
`refused-or-busy` / `error`.
|
||
|
||
- 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, 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 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
|
||
UE that has no TCP connection towards the P-CSCF set one up before it
|
||
sends a request. Where nothing is reopened, the connect fails (one that
|
||
gets no answer, after 12 s) or the flow dies again before a response,
|
||
the call ends with `error`. Under a call, a flow that died with no
|
||
reset and no close reaching the phone is found dead only when the
|
||
kernel gives up on bytes sent on it that were never acknowledged
|
||
(924.6 s or more after them by its default `tcp_retries2` of 15): an
|
||
attempt whose own INVITE is the first such bytes gets no response and
|
||
is cancelled at its setup deadline, long before that. A flow found dead
|
||
after a response to the INVITE is not reopened.
|
||
- Incoming: an INVITE on a protected-port listener is validated before it is
|
||
announced to the UI; 100 and 180 (reliable when the caller requires
|
||
100rel); `Accept` sends the 200 with the SDP answer at the offer's own
|
||
payload types and octet-align mode, its telephone-event echoed when the
|
||
offer's m-line lists one at the codec's clock; a remote CANCEL gets 200 + 487; an
|
||
unusable offer 488 naming what was offered; ring timeout 480. A landline
|
||
gateway's G.711-only or AMR-NB offer rings and is answered at its own
|
||
payload types.
|
||
- Hang-up: a BYE of imsd's goes out on the client flow, an incoming
|
||
call's too, and the call is over for imsd as the BYE is sent: the
|
||
media leg is stopped (RFC 3261 15.1.1 has the session terminated as
|
||
soon as the BYE is passed to the client transaction) and no response
|
||
to the BYE is waited for. The BYE is not kept and not sent again: on a
|
||
flow the network has closed or dropped it is lost, and the call's line
|
||
in the journal still ends `BYE sent`. A network that closes or drops a
|
||
TCP flow it hears nothing on (§7.2 step 5) can have done so by then:
|
||
under a call no ping goes out (with `CRLF_KEEPALIVE` neither), the
|
||
refresh waits for the call's end and the recovery does not reconnect.
|
||
That network's timer runs from the flow's last bytes. A call the
|
||
daemon placed restarts it with its own requests; an incoming call
|
||
sends none before its BYE, and where until 1.2.3 a ping went out every
|
||
30 s outside a call, without the ping the flow can have been silent,
|
||
or dropped without a close, long before the call came. Shown on the
|
||
workstation for a call the daemon placed (§5); not met on a network.
|
||
- Sleep: nothing of imsd runs while the phone is suspended, so a
|
||
suspend under a call stops the daemon and the call's media leg for as
|
||
long as the phone sleeps; on the dev phone (Plasma Mobile, the sleep
|
||
targets unmasked for the test, a call placed on the bus) logind
|
||
listed one block inhibitor for sleep under a call, imsd's, and
|
||
PowerDevil's policy agent none of its own (§5). While the
|
||
calls table holds a call imsd holds logind's block inhibitor for
|
||
sleep (`Inhibit` with `sleep`, `imsd`, `a call`, `block`;
|
||
`systemd-inhibit --list` shows it): from the call's addition to the
|
||
table, which is an incoming call's announcement and for a `Dial`
|
||
follows the recovery's try on a dead flow (§7.4) and the refresh of
|
||
the `P-Access-Network-Info`, to its removal. Under it logind refused
|
||
a plain `systemctl suspend` on the dev phone (§5); a request can tell
|
||
logind to ignore inhibitors (`systemctl suspend -i`). Where it was
|
||
asked for during a suspend's operation logind refused this lock
|
||
(§13): a lock that was not given and is still wanted is asked for
|
||
again when logind
|
||
sends `PrepareForSleep` with false, and one
|
||
wanted before the bus connection was there when the connection
|
||
comes. Where logind gives none at all (`--session`: the session bus
|
||
has no logind) calls go on without one. For a suspend that is told to
|
||
ignore inhibitors there is the wake alarm: what it holds under a call
|
||
and what it does not is in §7.10.
|
||
- Emergency: a number `IsEmergency` classifies (112, 911, plus
|
||
`EMERGENCY_NUMBERS`; SIM `EF_ECC` is not read yet) is tried as
|
||
`urn:service:sos` first, with one fallback to a plain INVITE of the digits;
|
||
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
|
||
offer's for an incoming one; the leg takes the far end's events at that
|
||
number and at `MediaLeg::dtmfRxPt`, `DTMF_RX_PT` — our own SDP's at that
|
||
clock: our offer's on a call we placed (the answerer sends with the
|
||
offer's numbers, RFC 3264 §6.1), the echoed offer's on one we answered
|
||
(the offerer with the answer's, §5.1); the answer's instead when
|
||
the answer gave the audio our offer's number, which is then the leg's
|
||
audio number — never at the audio's). The
|
||
engine's `OnDtmf` lets them through on an active call that negotiated
|
||
telephone-event and drops them otherwise, with a journal line that says
|
||
why (before the answer, after the call, no telephone-event at the codec's
|
||
clock in the SDP, a character that is no tone or a string past
|
||
`DtmfMaxTones` (128) — then
|
||
the whole string, never part of what was pressed; letters are
|
||
upper-cased, `a` and `A` are one event). There
|
||
is no second method: no SIP INFO, and no tone played into the microphone
|
||
path. The shell writes one `dtmf
|
||
<tones>` line per `SendDtmf` down the leg's control pipe.
|
||
- Incoming calls reach imsd only when the network's T-ADS routes the call to
|
||
the IMS domain; the REGISTER Contact advertises the MMTEL ICSI and
|
||
`+sip.instance` for that. When T-ADS still picks CS, no INVITE arrives —
|
||
a network/modem-integration matter, not a daemon defect.
|
||
|
||
`imsd-media` is one process per call: `imsd-media <local-ip> <rtp-port>
|
||
<remote-ip> <remote-port> <pt> <secs> <out-base>`. It binds the advertised
|
||
RTP port (`RTP_PORT`, default 50004), sends uplink frames from `pw-record`
|
||
through the encoder, captures the downlink, and with `PLAY=1` reconstructs
|
||
the media clock from RTP timestamps so `pw-play` stays real-time-paced
|
||
through far-end DTX silence. Codecs: AMR-WB (16 kHz, the default), AMR
|
||
narrowband and G.711 PCMA/PCMU (8 kHz, what a PSTN gateway offers); AMR
|
||
frames ride RFC 4867 payloads, octet-aligned or bandwidth-efficient
|
||
(`OCTET_ALIGN`, mirrored from the SDP). The AMR codecs are dlopen'd
|
||
(`libvo-amrwbenc` + `libopencore-amrwb` for WB, `libopencore-amrnb` for NB);
|
||
G.711 is a table. DTMF (RFC 4733 telephone-events; `DTMF_PT` names their
|
||
payload type, unset = none; imsd sets it from the SDP and writes the lines
|
||
down the control pipe, §7.1): each `dtmf
|
||
<tones>` line on its stdin queues the tones, and a tone takes seven 20 ms
|
||
slots of the uplink in place of the audio frames — the event's five
|
||
(100 ms at -10 dBm0: the marker bit on the first packet, the duration
|
||
growing a slot at a time, the end bit on the fifth packet) and two in
|
||
which the end packet goes out again (RFC 4733 §2.5.1.4) — then three
|
||
slots of audio before the next tone; the audio's own sender carries the
|
||
events — per captured frame (a silence tick without a mic) the event
|
||
packet goes in the frame's place, one packet per slot — so events and
|
||
audio share the stream's sequence and timestamp space (RFC 4733 §2.1), the
|
||
clock stays the capture's, and the audio after an event is stamped as if
|
||
it had run through it; a line of more than 4096 bytes is
|
||
dropped through its end and the next line goes. The far end's events —
|
||
taken at `DTMF_RX_PT` (our offer's 98 or 100 on a call we placed, the
|
||
number an answerer sends with, RFC 3264 §6.1, whatever the answer
|
||
renumbered ours to; the offer's number we echoed on a call we answered;
|
||
the answer's telephone-event number instead when the answer gave the
|
||
audio our offer's number, which is then the leg's audio number) and at
|
||
`DTMF_PT`, never at the audio's — are played as the tones they stand for
|
||
(ITU-T Q.23's frequency pairs, at the packet's volume), in the playout, in
|
||
step with the audio clock: the gap before the event's start (a stock
|
||
sender's DTX silence often precedes a key press — 0 to 7 slots on the dev
|
||
phone, 2026-10-15) is filled as before an audio frame, each packet reports
|
||
the event's duration so far and what the clock has not covered is
|
||
synthesized, so a retransmitted end packet adds nothing and a lost update
|
||
is caught up by the next; a far end whose audio resumes past the event
|
||
(the stock phone's does, §13) meets the clock with the usual fill. **Exit code 3 means the downlink dried up** for
|
||
`MEDIA_TIMEOUT` seconds (default 6.0) — the far-end-hangup signal, which on
|
||
carriers whose BYE never reaches our SAs is the reliable teardown trigger.
|
||
Per-call stats land in `OUT_DIR` (default the state dir); `RTP_DUMP=1`
|
||
captures the raw downlink next to them.
|
||
|
||
**Audio session.** Call audio goes through the PipeWire of one account.
|
||
imsd resolves it for each call from logind: the user session active on
|
||
seat0 (`loginctl show-seat seat0`; a greeter does not count) when it has a
|
||
`/run/user/<uid>/pipewire-0` socket, and passes it to `imsd-media` as
|
||
`AUDIO_USER`. `AUDIO_USER` set in imsd's own environment pins an account
|
||
instead; one that is not an account falls back to logind. imsd as packaged
|
||
(root, on the system bus) logs the resolution at start and when a call's
|
||
media starts (`audio session: …`), `imsd-media` once per call. An `imsd-media` started without the variable at all (by hand, or
|
||
by an imsd older than 0.3.10 while an upgrade replaces it) tries the
|
||
account `user`, its old default.
|
||
|
||
### 7.7 Runtime files
|
||
|
||
| Path | Written by | Content |
|
||
|---|---|---|
|
||
| `/etc/imsd.env` | the admin | configuration (§10), none required since 1.0.0 where discovery finds a P-CSCF (§7.3): `PCSCF=` overrides what discovery found, and names the P-CSCF where discovery is skipped or finds none; the file's existence changes nothing. Before 1.0.0 the apk's drop-in `ConditionPathExists=/etc/imsd.env` made it the switch for the whole unit (§9.2) |
|
||
| `/run/imsd.env` | `ims-pdn-up.sh` | `DEV=`, `LOCAL=` of the connected PDN, `PCSCF_DISCOVERED=` the IPv6 addresses of the PCO's P-CSCF list in the modem's order, at most eight (IPv4 entries and names are dropped; empty when the PCO gave no IPv6 P-CSCF, when discovery did not run or failed, or when `PCSCF=` is set), `PCSCF_DISCOVERY=found|none|failed|skipped` (how the list came to be: the PCO's answer, the reader's failure, or discovery not run); or `IMSD_IDLE=no-sim` / `no-ims-pdn` alone when the bring-up found nothing to do (§7.3; the daemon decides the dead end after the PDN is up itself) |
|
||
| `/run/imsd.holds` (`HOLDS_FILE`) | imsd, `imsd-handover.sh` | the network's holds, the schedule's place and the reducer's refusal count (§7.4) |
|
||
| `/run/imsd.handover` | `imsd.post-upgrade` | the InvocationID of the daemon an upgrade replaces, written when no holds file exists (§7.5); consumed by `imsd-handover.sh` |
|
||
| `/run/imsd-ofonod.started` | `imsd-ofono-restart-calls.sh` | marker: imsd-ofonod has started once since boot |
|
||
| `/var/lib/imsd/imsreg.state` (`STATE_FILE`) | imsd | the registration context for a warm resume |
|
||
| `/var/lib/imsd/*.stats`, `*.rtp`, `*.raw` | imsd, imsd-media | per-call media stats, raw RTP (`RTP_DUMP`), SIP dumps (`DUMP_SIP`; mode 0600 — they carry the IMSI/MSISDN) |
|
||
| `/var/lib/imsd/sms-tpmr` | imsd | the next TP-MR, one decimal number, written when a message's segments take their TP-MRs (§7.9) |
|
||
| `/var/lib/imsd/sms/<id>.msg` | imsd | received short messages until an app deletes them (§7.9, `List`/`Delete`): the texts, mode 0600 in a 0700 directory |
|
||
| `$XDG_STATE_HOME/imsd/` (else `~/.local/state/imsd/`), `$XDG_RUNTIME_DIR/imsd.holds` (else `/tmp/imsd.holds`) | imsd | the same files for a non-root (`--session`) run |
|
||
|
||
### 7.8 Journal vocabulary
|
||
|
||
Lines the operator (and the scripts) look for, all prefixed `imsd: `:
|
||
|
||
- `LOCAL=… P-CSCF=…`, `SIP transport: …` (behind it `CRLF keepalive: every N s on an idle TCP flow
|
||
(CRLF_KEEPALIVE)` where that setting names an interval), `ESP ciphers offered: …`, `SIM slot=… IMSI=… domain=…` at start
|
||
(the home domain of the card's identity, which the line before names);
|
||
`EALG entry '…' is not a cipher imsd can install; ignored` for a name in `EALG` that imsd cannot install,
|
||
`CRLF_KEEPALIVE=… is not a whole number of seconds; no CRLF keepalive` for a value of that setting, other than an empty one, that is no whole number.
|
||
- Before the `SIM slot=…` line, at every bring-up, where the identity is from (§7.2 step 2): `identity: the
|
||
ISIM's (application state S): private identity P, home domain D, public identity U; the names the IMSI gives`
|
||
or `…; not the names the IMSI gives (home domain D')`, `identity: derived from the IMSI (the card has no
|
||
ISIM application)`, `identity: derived from the IMSI (ISIM=0)`, `identity: derived from the IMSI: the ISIM
|
||
application (state S) gave none — …` with what was missing: `no logical channel opened on it`, `EF_X: the
|
||
SELECT answered <status word>`, `EF_X: the read answered <status word>`, `EF_X: no answer with a status
|
||
word to the SELECT`, `EF_X: an exchange of the read brought no answer with a status word` (the read or a
|
||
command the card asked for after it), `EF_X: no value in the N bytes read`, or `EF_IMPI '…', EF_DOMAIN
|
||
'…' and EF_IMPU record 1 '…' are no identity imsd can register`. At a resume whose
|
||
registration was made under other names than the card gives now: `identity: the registration to resume was
|
||
made under private identity P, home domain D, public identity U; it keeps them until the next fresh
|
||
registration, which takes the card's`; at a fresh registration under other names than the ones in use
|
||
before it: `identity: the fresh registration takes the card's: private identity P, home domain D, public
|
||
identity U`;
|
||
`the state file's identity is not one imsd can register; resume falls back to fresh` (with no fresh target
|
||
`…; nothing can resume it: the pair is removed`) for a file whose three names fail the check or that
|
||
holds one or two of them. At a recovery by a fresh registration, while the ISIM has given none since the
|
||
bring-up, it is read again and the line of that read follows: `identity: the ISIM's …` or
|
||
`… gave none — …`.
|
||
- `AKA: the ISIM application gave no result (…); asking the USIM` and, when no application gave one, `AKA: no
|
||
result (…)` before `USIM AKA failed`: `no logical channel opened`, `an exchange brought no answer with a
|
||
status word` (the AUTHENTICATE or a GET RESPONSE after it),
|
||
`status word <status word>`, `a synchronisation failure, tag DC`, or `N bytes that are no AKA result,
|
||
status word <status word>`.
|
||
- `RESUME via existing SA (cseq N)`, `REGISTERED (resumed + true-refreshed)`,
|
||
`FRESH registration`, `Security-Server: …`, `REGISTERED (fresh)`.
|
||
- `bring-up deferred: …; next: fresh registration in N s` — one line; `in N
|
||
min` from a minute (the pre-0.3.10 form `bring-up deferred: … next fresh
|
||
registration in N min` is what `imsd-handover.sh` reads from an older
|
||
daemon's journal), `a hold the network set before this start stands (…)`,
|
||
`the refusal schedule stands at N min from before this start: …`.
|
||
- `…; next: fresh registration in N s` (`in N min` from a minute, `now`),
|
||
`registering fresh (recovery attempt N)`,
|
||
`fresh registration deferred/refused/failed: …`, `client flow dead; reconnecting`
|
||
(a reconnect over the registration's SAs begins, §7.4) and its
|
||
`reconnected + re-registered`, `recovered by a fresh registration`.
|
||
- `the registration's SAs are on X, not the PDN's own address Y: resuming
|
||
there until the next fresh registration`, `the fresh registration moves
|
||
from X to the PDN's own address Y`, `back on X: the old registration stands
|
||
until the next fresh attempt`, `X has left DEV: the registration on it is
|
||
gone; staying on Y; next: …`, `X is no longer on DEV: the registration on
|
||
it is gone; on the PDN's own address Y now; next: …`.
|
||
- `pcscf: configured X` / `pcscf: configured X; discovery gave Y, Z (ignored:
|
||
PCSCF= wins)` / `pcscf: discovered Y, Z (using Y)` at start, `pcscf:
|
||
PCSCF_DISCOVERED entry '…' is not an IPv6 address; ignored`; `pcscf:
|
||
resuming on X, the registration's SA peer; the next fresh registration
|
||
goes to Y` (+ ` (the peer is not in today's list)`, or `… (no P-CSCF
|
||
configured or discovered)`), `the fresh registration moves from P-CSCF X
|
||
to Y`, `back to P-CSCF X: the old registration stands until the next fresh
|
||
attempt`, `no reg state file; resume falls back to fresh` and `the state file names
|
||
another SA pair (0x…/0x…[ to X]) than the kernel's (0x…/0x… to Y): another
|
||
attempt's; resume falls back to fresh` (` to X` only when the file records a
|
||
P-CSCF — a pre-1.0.0 file does not; with no fresh target both end in
|
||
`nothing can resume it: the pair is removed` instead), `no P-CSCF for a
|
||
fresh registration: none configured (PCSCF=) and none discovered
|
||
(PCSCF_DISCOVERED empty — see the ims-pdn-up lines)`.
|
||
- `PCSCF='…' is not written as ip prints it; use PCSCF=…` (under `bring-up
|
||
FAILED:`) — one accepted spelling of the setting (§7.2 step 3); the
|
||
bring-up script's `ims-pdn-up: PCSCF '…': write the bare address, as ip
|
||
prints it (no brackets)` (its own prefix: a script line) is the same rule
|
||
for a bracketed value.
|
||
- `engine fatal: … — exiting for systemd restart`.
|
||
- `reg-event SUBSCRIBE sent`, and the binding's state from NOTIFY.
|
||
- `the SA pair to X is nothing to resume: removing it` — a bring-up with no
|
||
fresh target that found a pair nothing can resume (§7.2 step 1; `N xfrm
|
||
entries of imsd's own with no pair to resume: removing them` when the
|
||
removal finds entries of imsd's own but no pair `SaPeer` can name —
|
||
policy-less states on the UE's address, a lone or disagreeing fingerprinted
|
||
policy —, §12); a
|
||
resumable pair whose attempt failed is kept for the restart (`resume
|
||
failed: … — the restart tries the resume again`, `resume connect failed;
|
||
the restart tries the resume again`, `state file transport differs from
|
||
SIP_TRANSPORT; the restart tries the resume again` — the last at every
|
||
restart while the forced transport stands; with a fresh target each ends in
|
||
`the next registration is a fresh one`); a registration the engine's rule
|
||
wrote off — a 403 once a fresh registration is due, a binding a NOTIFY
|
||
terminated under the re-REGISTER wait — is removed instead (`resume failed:
|
||
… — written off by the network: the pair is removed`; with a fresh target
|
||
`… — written off by the network: the next registration is a fresh one`),
|
||
and so is a resume
|
||
the engine gives up with no fresh target — a 401, a refusal with a
|
||
Retry-After, the second refusal, the count travelling in the holds (`resume
|
||
failed: … — the resume is given up (the engine's rule): the pair is
|
||
removed`).
|
||
- `audio session: …` at start and at each call's media start; `CODECS override active: …`.
|
||
- `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: …`).
|
||
- `an answer from port N to [address]:port is not sent: no connection from that peer to that port is held
|
||
(said once)` the first time in a run that an answer is given to the channel of a request that came in over
|
||
TCP and `ServerPorts` holds no connection from that request's peer to that port (§12).
|
||
- `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
|
||
(§7.6): where no lock was held, no such line; `no sleep inhibitor from
|
||
logind (…): asked again when it says a sleep is over` where logind gave
|
||
none, once until a call's lock is next given.
|
||
- `wake alarm: a sleeping phone is woken when the registration's refresh
|
||
is due` when the alarm is first armed, `no wake alarm (…): a sleeping
|
||
phone is not woken for the registration's refresh` where the kernel
|
||
gives no such timer (its error) or has no RTC behind it (`no RTC that
|
||
can wake the phone`), `wake alarm not set: …` where setting it fails
|
||
(§7.10).
|
||
- `the modem reports no packet service: the reconnect waits until it has
|
||
it again` (or `the fresh registration waits …`) where a recovery step
|
||
finds the modem without packet service: once, and again after a look
|
||
that found it with service (§7.10). A cycle that was tried and went
|
||
unanswered, the modem then reporting none, has the line it had: `…
|
||
while the modem reports no packet service: not counted; next: …`
|
||
(§7.4). `wake trace: …` only with `WAKE_TRACE=1`, a test seam (§5).
|
||
- `media <codec> pt=N octet=true|false -> [X]:P, telephone-event pt N|none` at a
|
||
call's media start (`… pt N (theirs M)` when `DTMF_RX_PT` differs from
|
||
the one we send with); `call X: DTMF '…' -> media leg (telephone-event pt
|
||
N)` for tones the engine lets through, `call X: DTMF '…' dropped: the call is <state>` /
|
||
`… dropped: no telephone-event negotiated for this call` / `… dropped:
|
||
'c' is not a tone` / `call X: DTMF of N tones dropped: more than 128` for
|
||
tones not sent, `SendDtmf(X, '…') ignored: no such call`; `DTMF '…' not
|
||
sent: no control pipe to the media leg` on a call whose control pipe
|
||
could not be made or that has no media leg, `DTMF '…' not sent: <error>`
|
||
when the control pipe's write fails (`EPIPE`: the leg died under the
|
||
action; `EAGAIN`: it is alive, stopped reading, its pipe full),
|
||
`DTMF of N tones not sent: longer than the control pipe's atomic
|
||
write` (a line the engine's bound should have stopped), `media control
|
||
pipe: …; this call has no DTMF` when the pipe could not be made.
|
||
- A refused REGISTER or SUBSCRIBE is logged with its status line and
|
||
any `Retry-After` / `Warning` / `Reason` / `Server` headers;
|
||
`re-REGISTER challenged: 401 …; re-authentication asked, the next
|
||
registration is a fresh one` for a challenged refresh; `state file holds
|
||
no challenge answer (pre-0.3.11): the refresh carries an empty digest`
|
||
at a resume of a registration made before 0.3.11 — every reregistration
|
||
of it carries the empty digest until its next fresh registration, and
|
||
the line repeats at each later resume of it; `Security-Verify from the
|
||
state file (1 mechanism)` / `(N mechanisms)`, `state file holds no Security-Server (a
|
||
pre-0.3.12 file, or a list the file cannot hold): Security-Verify
|
||
rebuilt from the SA as one mechanism` or `state file's Security-Server
|
||
names another SA pair than the one in the kernel (spi-s N vs M):
|
||
Security-Verify rebuilt from the SA as one mechanism` at every resume.
|
||
- `connect: no answer from the P-CSCF N times (…)` when the protected
|
||
connect series ends unanswered.
|
||
- SMS over IP (§7.9): `SMS over IP: off (SMS_OVER_IMS=1 enables it)` at
|
||
start, or at bring-up `sms: service centre +… (EF_SMSP[ 'alpha'])[,
|
||
validity period 0xnn]` / `sms: service centre +… (SMSC=)` / `sms: no
|
||
service centre: EF_SMSP record 1 unreadable or without one; …` / `sms:
|
||
SMSC='…' is not a number; …` / `sms: SMSC='…' is not an international
|
||
number (+ and digits); …` / `sms: EF_SMSP's service centre '…' is not an
|
||
international number (+ and digits); …` and `SMS over IP: on (+g.3gpp.smsip
|
||
advertised: …)`; per message of ours `sms <id>: segment i/n to <number>
|
||
via <uri>: MESSAGE sent (RP-MR a, TP-MR b, N bytes)`, `sms <id>: segment
|
||
i/n -> <code>; awaiting the submit report`, for a segment's repeat `sms
|
||
<id>: <how the first attempt ended>; sending the segment again, TP-RD
|
||
set` and `sms <id>: segment i/n to <number> via <uri>: MESSAGE sent again
|
||
(RP-MR a, TP-MR b with TP-RD, N bytes)`, and after it `sms <id>: segment
|
||
i/n: the repeat was rejected as a duplicate (RP cause N (…), TP-FCS
|
||
0xc5 (…)): the first attempt is taken for accepted`, `sms <id>: segment i/n: the first attempt's
|
||
submit report came after the repeat went out: accepted` or `sms <id>:
|
||
segment i/n refused by the SC: RP cause N (…)[, TP-FCS 0xNN (…)], in the
|
||
first attempt's report, which came after the repeat went out: the
|
||
repeat's decides`,
|
||
then `sms <id>: sent: …` or
|
||
`sms <id>: failed: …` (the reason: `'…' is not a number`, `no service
|
||
centre …`, `the text does not fit 255 segments`, `imsd is not registered`, `the flow to the P-CSCF is down`,
|
||
`segment i/n refused: <status and its Retry-After / Warning / Reason / Server headers>`, `segment i/n refused
|
||
by the SC: RP cause N (…)[, TP-FCS 0xNN (…)]`, `no answer to the MESSAGE
|
||
of segment i/n within 128 s`, `no submit report for segment i/n within
|
||
130 s of the final`, `segment i/n not sent: the flow to the P-CSCF is
|
||
down`; of a segment that was sent again the reason is the repeat's
|
||
followed by `; the first attempt: <that attempt's>` — for a first
|
||
attempt that an RP-ERROR answered after the repeat went out, `segment
|
||
i/n refused by the SC: RP cause N (…)[, TP-FCS 0xNN (…)], in a report
|
||
that came after the repeat went out`) and, after a status report, `sms <id>: delivered|delivery-pending|
|
||
delivery-failed: <TP-ST in words>` or `sms <id>: a segment delivered
|
||
(TP-MR n); k still to be reported`, and for a report's word on the
|
||
message still in flight `sms <id>: delivered|delivery-pending|
|
||
delivery-failed: <TP-ST in words> — held until the submission ends`; per delivery `short message from
|
||
<sender> via <sc> at <time>[, segment i/n of set r]: text|8-bit data (N
|
||
bytes)` — or, for a class 2 message that is
|
||
refused (§7.9), `… at <time>[, segment i/n of set
|
||
r]: class 2[, a (U)SIM data download] (N bytes), which imsd cannot pass
|
||
to the (U)SIM: refused` —, `sms ims-sms-in-<run>-<epoch>-<N>: from … via …, N bytes of text|8-bit data[ in
|
||
n segments]` once whole, `delivery report RP-ACK|RP-ERROR (RP-MR n) ->
|
||
<uri>` (its final and its failures: the bus and MESSAGE lines below) or,
|
||
for a MESSAGE that names no gateway, `no P-Asserted-Identity or From URI on
|
||
the delivered MESSAGE: no delivery report RP-ACK|RP-ERROR sent`;
|
||
`status report from <sc>: TP-MR n to <number>: … (discharged
|
||
<time>)`, `sms: status report for TP-MR n to <number>: no message of ours on record`;
|
||
`submit report (RP-ACK) In-Reply-To …: sms <id>'s segment i/n, no longer
|
||
in flight; 200` (for an RP-ERROR, `(RP-ERROR, RP cause N (…)[, TP-FCS
|
||
0xNN (…)])` in the brackets),
|
||
`submit report (RP-ACK|RP-ERROR) In-Reply-To …: no MESSAGE of ours on record; 488`,
|
||
`submit report (…, RP-MR n) that no message in flight owns; 200`; `RP-DATA from
|
||
… whose TPDU is unusable (…): RP-ERROR`; `MESSAGE from … (<content
|
||
type>, N bytes):` followed by the body for a MESSAGE outside a call's dialog whose `Content-Type`
|
||
does not contain `application/vnd.3gpp.sms`, letter case ignored
|
||
(`<content type>` its value in lower case, or `no content type`); `MESSAGE from … with N bytes that are no RP message: <hex>`.
|
||
|
||
- SMS over IP's bus and MESSAGE lines (§7.9): `sms: <name> subscribed (N
|
||
subscriber(s))` / `sms: <name> unsubscribed (its connection is gone; N
|
||
subscriber(s))`; `MESSAGE retransmitted (<Call-ID>|<CSeq>|<branch>):
|
||
answered again, not handled again`; `sms: a concatenated text from
|
||
<sender> (set <ref>, <held> of <total> segments held) dropped after 30 min:
|
||
the rest never came`; `short message over IP from <caller id>
|
||
(<n> bytes) while SMS_OVER_IMS is off: 480` — `<caller id>` the number or user a
|
||
P-Asserted-Identity of the MESSAGE gives, else its From's, empty when
|
||
neither gives one: who sent the MESSAGE, not who wrote the text, which is
|
||
not read while the setting is off; `sms: delivery report -> <code>` / `sms: delivery
|
||
report refused: <summary>` / `sms: delivery report not sent: the flow to
|
||
the P-CSCF is down`; `<Method> refused: <bus name> is not authorized for
|
||
net.catcrafts.IMS1.Messaging` / `<Method> refused: <bus name>: polkit did
|
||
not answer: …` for a gated call of the Messaging interface that polkit
|
||
does not grant (the frozen interface's gated calls give the same lines
|
||
with `net.catcrafts.IMS1.Voice`).
|
||
- The bus object at start: `introspection XML: <error>` when the interface
|
||
description does not parse (nothing is registered) and `<interface> not
|
||
registered at /net/catcrafts/IMS1: <error>` for an interface the bus
|
||
refuses; the daemon runs on without it.
|
||
- The store (§7.9): `sms <id>: stored (N kept until an app deletes them)`;
|
||
`sms store: <id> exists already; taking the next id`; `sms store: N stale
|
||
temporary file(s) removed` (at the engine's start); `sms <id>: NOT
|
||
stored — <why>; the bus signal is its only delivery`; `sms <id>: deleted
|
||
from the store`; `sms <id>: not deleted from the store: <reason>`; `sms
|
||
store: <path> is no record; skipped`; `sms store: cannot read <path>:
|
||
<reason>` — the first thing a scan of the store cannot read, for
|
||
another reason than that nothing is there: the store directory, opened
|
||
or read to its end, at any scan; a `.tmp` name's `stat` at the engine's
|
||
start (the sweep); a `.msg` name's `stat`, `open` or `read` at a `List`
|
||
(which answers `IOError`, §8.4) and at the count for the `stored` line,
|
||
which is then `sms <id>: stored` alone.
|
||
- `idle: no SIM — nothing to do; systemctl start imsd when that changes`
|
||
(or `idle: no ims PDN from the network — …` from `IMSD_IDLE`; `idle: no
|
||
P-CSCF — none configured (PCSCF=), none discovered (see the ims-pdn-up
|
||
lines) — and nothing to resume; set PCSCF= in /etc/imsd.env to name one —
|
||
…` the daemon's own, before the bus name or
|
||
from the no-target bring-up), then exit 0; `no P-CSCF: discovery failed
|
||
(see the ims-pdn-up lines) and nothing to resume — exiting for systemd
|
||
restart`, exit 1, when the reader did not answer (`PCSCF_DISCOVERY=failed`).
|
||
|
||
From the scripts: `ims-pdn-up: …` — among them `no SIM (sim-missing): not
|
||
bringing the ims PDN up — systemctl start imsd once one is in`, `bearer
|
||
connect refused 10 times in a row by profile index with packet service and a
|
||
persistent cause (last: …): no ims PDN for this SIM here — systemctl start
|
||
imsd to try again`, `wrote
|
||
/run/imsd.env: IMSD_IDLE=…`, `P-CSCF discovered: a, b
|
||
(pco-requested 1, profile-pcscf-via-pco 1)`, `P-CSCF discovery also gave v4 …
|
||
(not usable on the IPv6-only ims PDN)`, `P-CSCF discovery: nothing usable
|
||
(…)`, `P-CSCF X configured: discovery skipped`, `host route to P-CSCF X dev
|
||
Y` (the configured address or the first discovered), `wrote
|
||
/run/imsd.env: DEV=… LOCAL=… PCSCF_DISCOVERED=… PCSCF_DISCOVERY=…`,
|
||
`nftables: opened protected ports 45061-45062 on qmapmux*` and `nftables:
|
||
accepting ESP on qmapmux*` where the script inserted the rule —,
|
||
`imsd-handover: …`, `imsd-ofono-restart-calls: …`.
|
||
|
||
### 7.9 SMS over IP (TS 24.341)
|
||
|
||
Off unless `SMS_OVER_IMS=1`: with the modem's own IMS client off, a
|
||
network that gives the modem no SMS path leaves the phone none but imsd
|
||
(which networks
|
||
do so for which attach types is unmeasured), while on one whose modem
|
||
still delivers texts over NAS the tag may take them off a path that works
|
||
(the order is operator policy, TS 24.341 5.3.3.4.2 NOTE 2) — so the knob
|
||
is the user's, and the release default leaves the NAS path alone. On, the REGISTER Contact
|
||
carries `+g.3gpp.smsip` (`Context::smsOverIp`, 5.3.2.2) and what the network
|
||
delivers over IP — terminating short messages, submit reports — comes as SIP MESSAGEs with
|
||
an `application/vnd.3gpp.sms` body — the RP message of TS 24.011 a 2G/3G
|
||
phone would see, with the TPDU of TS 23.040 inside (`Imsd:Sms`, §2); a
|
||
status report would come the same way (5.3.3.4.4); a search of the dev phone's
|
||
journal for imsd's status-report lines found none from 2026-10-16 to its reading on 2026-10-19
|
||
03:05 (`r24-phone-journal-authmsg-status-reports-2306`), a span in which at
|
||
least three submissions asked for one (TP-SRR: the three commands of
|
||
`r25-status-report-requests-from-the-session-transcript`). Off, `Send` is refused with `NotSupported`, and a short
|
||
message the network sends anyway outside a call's dialog is refused with 480 Temporarily Unavailable — a 200 and an RP-ACK would
|
||
count it delivered to nobody, a failure lets the
|
||
IP-SM-GW try the SGSN/MSC path, by operator policy (TS 24.341 5.3.3.4.2
|
||
NOTE 2) — where the network gives the modem one. On the dev phone on KPN
|
||
on 2026-10-17 the modem was CS-detached (§13): the one
|
||
text sent before the tag was advertised came over IMS, 36 min after its SC
|
||
time stamp, in a burst with four sent after it (§13); on 2026-08-18 the same subscription sent
|
||
a text over NAS — whether KPN or the phone's attach type decides it is
|
||
unmeasured.
|
||
A MESSAGE outside a call's dialog whose `Content-Type` does not contain
|
||
`application/vnd.3gpp.sms`, letter case ignored — a page-mode MESSAGE — is
|
||
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, 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: …
|
||
on the init port, from port <n> — ignored`); one of no bytes or of line
|
||
breaks alone is passed over without a line, and so is one of other white
|
||
space alone on a server port. A request that reaches the client flow or a
|
||
server port in a datagram with fewer body bytes than the Content-Length
|
||
read from it says is answered 400 (RFC 3261
|
||
18.3: the element "SHOULD generate a 400 (Bad Request) response"; the
|
||
journal has `UDP: datagram truncated (…) — answered 400`, with the
|
||
server port named before the dash). Such a request is known by its first
|
||
line, which ends with the SIP version where a status line begins with
|
||
it (7.1, 7.2), whatever the version's letter case: a datagram cut short
|
||
so that begins with a status line, or with no line of SIP, is ignored,
|
||
its line ending `— ignored`, and so is a request cut short so on the init
|
||
port, which answers no request. imsd keeps nothing of a request it
|
||
answers so: a To tag it adds is made from the request and a secret of
|
||
the run, the same for the same request (`BuildBadRequest`), and an ACK
|
||
or a CANCEL cut short so draws nothing — what RFC 3261 8.2.7 has an element
|
||
do that answers without state.
|
||
|
||
- **A retransmitted MESSAGE** (the same Call-ID, CSeq and Via branch — the
|
||
value of the first `branch=` of its first Via row; a MESSAGE with none
|
||
or an empty one is never taken for a copy — within 32 s of our final:
|
||
`RecentTransactions`, standing in for RFC 3261 17.2.2's server
|
||
transaction) gets that final again and is not
|
||
handled again: no second text, no second delivery report (of the
|
||
bench's two, one was refused with 488, §5). The table is this run's: a copy
|
||
that comes after an imsd restart is handled as a new MESSAGE.
|
||
- **The store.** A received message is written to
|
||
`/var/lib/imsd/sms/<id>.msg` (mode 0600, the directory 0700; whole to a
|
||
`.tmp` beside it, then `link(2)`ed to its name) before the bus hears
|
||
`Received`, and stays until `Delete` — the daemon is the message store
|
||
the way the modem's memory is for ModemManager, so a whole text it
|
||
stores while no app runs, or none exists, is not lost (a concatenated
|
||
one's earlier segments wait in memory until the set is whole — the
|
||
**Receiving** bullet below); `List` is an app's way
|
||
in. The record is key=value lines, the sender, the text, the data and
|
||
the PDU as hex (`FormatStoredSms`/`ParseStoredSms` in `Imsd:Engine`,
|
||
pinned by `tests/Engine`); the id is this run's token (eight hex digits
|
||
drawn once at start), the arrival's epoch second and a per-start
|
||
sequence number — another run gives the same id only with the same
|
||
token, second and number — and the record is published with `link(2)`,
|
||
which refuses a name the store already holds — the next number is
|
||
tried, never a replacement. A `.tmp` a crash left — an orphan, or a
|
||
record's second name — is removed when the engine next starts (`sms store: N stale
|
||
temporary file(s) removed`; a start that exits before the engine runs
|
||
leaves it, and one the sweep cannot unlink stays unreported); `Delete`
|
||
leaves `.tmp` names alone. A store that cannot be read — its directory,
|
||
or the file of a `.msg` or a `.tmp` name in it — is logged (`sms
|
||
store: cannot read …`) by the scan that meets it and ends no process:
|
||
the start's sweep lets the daemon start, the `stored` line goes
|
||
without its count, and `List` answers `IOError` (§8.4), never a shorter
|
||
list — every `List` while the fault lasts, the readable records beside
|
||
an unreadable one with it: the line names the path. No fault, and passed over without a line: a store directory that
|
||
does not exist, which holds nothing, and a name behind which stat(2)
|
||
finds no regular file — a directory — or nothing (`ENOENT`: a dangling
|
||
link, a file removed since the directory was read). A file that reads and is no record is
|
||
skipped with its line, the rest listed. `received` is that wall clock: before a boot's first time
|
||
sync it reads 1970, and `List`'s oldest-first order follows it, so an
|
||
app that cares orders by the SC's `timestamp`. A store failure is logged,
|
||
the signal still goes out, and the delivery report stays an RP-ACK —
|
||
the message is then the listener's or nobody's. Not the protocol's
|
||
refusal, RP-ERROR cause 22 "memory capacity exceeded", because it is
|
||
half of a mechanism — the other half, the UE's memory-available
|
||
notification (RP-SMMA, TS 24.341 5.3.2.5), imsd does not send; a refused last segment would also
|
||
lose its set, since the reassembler forgets a set the moment it is
|
||
whole. The refusal was built and benched on KPN (2026-10-18: the store
|
||
made unwritable, the text refused; the same text came again five
|
||
minutes later, the store writable by then, and was stored, and a later
|
||
text came at once)
|
||
and taken out again; no other core is measured. The refusal with the
|
||
notification and a probe of the store, and a reassembly that survives a
|
||
refused segment, are a later release's work. No cap on the count. Why a store at all
|
||
(Jorijn, 2026-10-17, on the recommendation): the bus queues nothing for
|
||
an absent listener; the 200 goes out first, then the store write, then
|
||
`Received` is handed to the bus thread and after that the RP-ACK, when one goes — the
|
||
signal goes whenever the main loop runs, and neither waits on a listener —
|
||
a signal
|
||
alone loses
|
||
every text that arrives between boot and the session, during an app's
|
||
restart or upgrade, or on a phone whose app is no daemon. The
|
||
storage-free alternative — refuse delivery with RP-ERROR cause 22
|
||
(memory capacity exceeded) while no app is attached and send RP-SMMA
|
||
when one appears — is
|
||
protocol-correct but needs an attach registry; not taken.
|
||
- **The service centre.** `SMSC=` when set, else EF_SMSP record 1 read
|
||
with `qmicli --uim-read-record` at bring-up (`LoadSmsParameters`): its
|
||
TS-Service-Centre-Address is the RP-DATA's destination byte for byte
|
||
and, as a SIP URI with `user=phone` built from its international number
|
||
(`ScPsi` — never a dialled-number guess: `RuriFor`'s trunk 0 is Dutch),
|
||
the MESSAGE's Request-URI and To (5.3.1.2 NOTE 1); its TP-Validity-Period
|
||
goes into every SMS-SUBMIT. A service centre whose number is not `+` and
|
||
digits — a national `SMSC=`, a `*` or `#` in it, an EF_SMSP record whose
|
||
type of number is not international — is refused at bring-up on
|
||
`ScPsi`'s own word (an `SMSC=` is read as a number first: its spaces,
|
||
dashes and dots dropped, one that is no number refused on `ForNumber`'s),
|
||
each with a journal line (§7.8), never announced, and `Send` then fails
|
||
with no service centre. EF_PSISMSC (an
|
||
operator-configured PSI, ahead of EF_SMSP in 5.3.1.2 NOTE 1's order) is
|
||
not read. Without a
|
||
service centre `Send` fails with the reason.
|
||
- **Submitting** (`SmsOutbound`, `Imsd:Engine`): the text as GSM 7-bit
|
||
septets when every character is in the default alphabet or its
|
||
extension, else UCS-2; one SMS-SUBMIT per segment (160/70 septets or
|
||
UTF-16 units alone — an extension character two septets, a character
|
||
beyond the BMP two units — 153/67 with the concatenation header, an
|
||
escape or surrogate pair never split), TP-MR counting up per segment from
|
||
the one in `/var/lib/imsd/sms-tpmr`, random only when the file gives none (TS 23.040 9.2.3.6's
|
||
Last-Used-TP-MR on the (U)SIM is not read or written), RP-MR from a
|
||
counter seeded at random at start, the next for every MESSAGE built
|
||
for a submission, one the flow could not send too. One message on the
|
||
flow at a time, segment by segment: the MESSAGE with the
|
||
RP-DATA, its final within 128 s of the MESSAGE or of its latest provisional (a
|
||
provisional starts the wait over); the submit report — an
|
||
RP-ACK or RP-ERROR in a MESSAGE of its own, matched by In-Reply-To, else
|
||
by RP-MR, answered 200 — within 130 s of a 2xx final; then the
|
||
next segment. The two waits are a UE's (Jorijn, 2026-11-21; 1.2.0 waited
|
||
32 s and 40 s): TS 24.229 table 7.7.1 recommends a UE whose requests name
|
||
one of the accesses clause 7.7 lists in P-Access-Network-Info a T1 of 2 s and a
|
||
timer F of 64*T1,
|
||
and TS 24.341 5.3.1.1 NOTE 1 has an
|
||
SM-over-IP sender's TR1M set to a value greater than timer F — past the
|
||
35 to 45 s of TS 24.011 10.1, and here counted from the final, where
|
||
6.3.1 sets TR1M when the RP-DATA is transferred. A segment that gets no answer, or an RP-ERROR with cause 41, is
|
||
sent once more, as TS 23.040 9.2.3.6 has the MS "automatically repeat
|
||
the SMS-SUBMIT" (one to three times; here once): when the final's wait
|
||
or the report's runs out, when the final is a 408 or a 504 — no
|
||
response in time (RFC 3261 21.4.9: the server "could not produce a
|
||
response within a suitable amount of time"; 21.5.5: it "did not receive
|
||
a timely response from an external server"), which leaves the MESSAGE's
|
||
fate as open as no final — and
|
||
on an RP-ERROR with cause 41, temporary failure, or with a value TS
|
||
24.011 table 8.4's part 1 does not list, which it has "treated as cause
|
||
number 41" (`RpCauseIsTemporary`; of the causes part 1 lists, Annex E-2
|
||
says of 41 alone that the MS "may wish to try another short message
|
||
transfer attempt almost immediately", and of 38 that "immediately
|
||
reattempting the short message transfer is not likely to be
|
||
successful"). The repeat is a MESSAGE of its
|
||
own — its Call-ID, the next RP-MR — carrying the same SMS-SUBMIT, the same
|
||
TP-MR, with TP-RD set, by which a service centre that has the first
|
||
"should discard" it and answer with an RP-ERROR whose TP-FCS is the
|
||
duplicate rejection (0xC5), or with an RP-ACK (9.2.3.6): either ends the
|
||
segment as accepted, and so does the first attempt's own RP-ACK when
|
||
it comes after the repeat went out. The duplicate rejection is taken so
|
||
only where no RP-ERROR has answered the first attempt by then — after
|
||
one it is a refusal like any other —, and an RP-ERROR to the first
|
||
attempt that comes after the repeat went out leaves the segment to the
|
||
repeat's answer; one that comes once the rejection has ended the
|
||
segment is answered and logged (Receiving, below) and changes
|
||
nothing. An RP-ACK to the repeat is an acceptance whatever became
|
||
of the first attempt: the clause lets a service centre answer a repeat
|
||
it discards with an RP-ACK as well ("for backward compatibility … may
|
||
be configured to respond with an RP-ACK"), which nothing tells from an
|
||
acceptance. What the rejection does not say is which SMS-SUBMIT the service
|
||
centre holds: imsd's TP-MR is its own count (above), so an SMS-SUBMIT
|
||
of this subscription that reached the service centre another way — the
|
||
modem's own short message stack — under the same TP-MR can draw the same
|
||
rejection, and where imsd's first attempt never arrived the message is
|
||
then `sent` for a text the service centre does not have (Jorijn,
|
||
2026-11-21: taken as the clause has it). KPN's service centre did not discard it in
|
||
seven benches of seven (2026-11-20 to 2026-11-22, §5): each time it
|
||
took the repeat for a new text — an RP-ACK under a time stamp of its
|
||
own — and delivered both. The repeat is
|
||
sent all the same (Jorijn, 2026-11-20, with the first of those benches
|
||
before him): the clause has the MS repeat
|
||
("shall") and the service centre discard ("should"), and Android's
|
||
framework sends its own retries so (AOSP's `ImsSmsDispatcher` and
|
||
`GsmSMSDispatcher` set TP-RD and the earlier TP-MR; the fp6 journal's
|
||
`2026-11-20-issues-2-5` capture, `repeat-research`). A status report is
|
||
matched by TP-MR, which both copies carry: of two reports under one
|
||
TP-MR the first of the completed class, or of one in which the service
|
||
centre has stopped trying, is taken, and a report after it is logged as
|
||
naming no message of ours — so for a message that ended `sent`, a first
|
||
copy reported failed gives `delivery-failed` though the other may
|
||
still be delivered. Every segment accepted: `sent`, with the SC's
|
||
time stamp from the latest RP-ACK whose submit report carried one; a
|
||
final refused with another status, an RP-ERROR with another cause (its
|
||
cause and the submit report's TP-FCS), a MESSAGE the flow
|
||
cannot send, or a repeat that ends short of an acceptance: `failed` with the
|
||
reason — after a repeat the repeat's end and the first attempt's —, at
|
||
once: a report that still comes for the first attempt is then answered
|
||
and logged (Receiving, below) and changes nothing; a wait is judged at the run loop's passes,
|
||
after the server ports are read and what the client flow already holds
|
||
is (`SipFlow::RecvReady`, without waiting), so a final that
|
||
the flow held when it was read counts, however late. Not done of the clause's repeat: it cannot be switched off
|
||
("should be capable of being disabled through MMI"), and a failed
|
||
message is not kept for the user to send again under its TP-MR — a
|
||
`Send` of the same text is a new message with the next TP-MR, which the
|
||
service centre cannot tell from a new text; and a final refused with
|
||
another status than 408 or 504 is taken for the network's refusal of the
|
||
MESSAGE, not for the clause's "no response", though it brings no RP-ACK
|
||
or RP-ERROR either. A `Send` is judged when the engine
|
||
takes its command up: unregistered or with the flow down at that moment,
|
||
it fails with that reason and is not held for a recovery step; otherwise
|
||
it starts, or queues behind the message in flight, and a queued message
|
||
starts when the one before it ends, without that check again.
|
||
- **Receiving** (`OnSmsMessage`): the MESSAGE is answered 200 on the
|
||
channel it came in on first; an SMS-DELIVER is decoded (7-bit, UCS-2 or
|
||
8-bit data; the class, the ports, a message-waiting indication) and, unless it is refused as a class 2
|
||
message (below), a concatenated one reassembled (`Reassembler`, in memory: a set to
|
||
which no segment has come for 30 min is dropped at the run loop's next pass with a journal line
|
||
naming the sender, the set and the segments held, and an imsd restart between segments —
|
||
an upgrade's, a `Restart=` — loses the set; a store of parts is a later release's work,
|
||
with the refusal of the store bullet) and handed to the bus whole as
|
||
`Received`, each segment acknowledged with an RP-ACK carrying the SMS-DELIVER-REPORT in a
|
||
MESSAGE to the IP-SM-GW — the delivered MESSAGE's P-Asserted-Identity,
|
||
else its From — with In-Reply-To naming it (5.3.2.4; left out when its Call-ID holds an ASCII control
|
||
character or a space); no report goes for
|
||
one that gives neither URI, nor when the flow to the P-CSCF cannot send
|
||
it (it is dropped, not held), and the journal says which; a report's
|
||
final is logged. An SMS-STATUS-REPORT is acknowledged the same way and matched
|
||
to the message that asked for one by TP-MR and the recipient's number
|
||
(the book is in memory: after an imsd restart it holds none of the
|
||
messages sent before),
|
||
and the message gets a word for the whole (`StatusReportBook`), by TS
|
||
23.040 9.2.3.15's four classes of TP-ST:
|
||
`delivery-failed` at the first report in either of the two in which the
|
||
SC is not making any more transfer attempts (a permanent error or a
|
||
temporary one, 0x40–0x7F; the message's other TP-MRs are forgotten with
|
||
it),
|
||
`delivered` when the last of its segments is reported in the completed
|
||
class (received by the SME, forwarded by the SC unconfirmed, replaced,
|
||
or an SC's own value of that class; the reason has the words),
|
||
`delivery-pending` while
|
||
the service centre is still trying one (a segment delivered with others
|
||
outstanding is logged only); a reserved value, any with bit 7 set among
|
||
them, is read as "Service Rejected", a failure, as the clause has the MS
|
||
read it (`StatusAsRead`); a report that matches no message is logged. A
|
||
message's words come in order (`SmsWordOrder`): the submission's first —
|
||
the SC can deliver and report segment 1 while segment 2 is still on its
|
||
way, so a report's word on the message in flight is held until the
|
||
submission ends and posted after `sent`; a submission that fails after
|
||
the SC reported every segment delivered (its last submit report lost or
|
||
late) ends as `sent` and `delivered`, not `failed`; one that fails
|
||
otherwise drops the held word and forgets the message's TP-MRs, so a
|
||
report on a part that went matches nothing. The next TP-MR lives in `/var/lib/imsd/sms-tpmr`
|
||
across restarts (9.2.3.6's intent without EF_SMSS), so across a restart
|
||
the TP-MRs continue instead of starting over at random — a reuse needs a
|
||
full 256-segment wrap, not a restart, while the file's last write reached
|
||
the disk (it is neither checked nor synced); RP-MR and the concatenation
|
||
reference start at random per start. A TPDU that is unusable — a delivery or a
|
||
status report that does not parse, or one of the submit-report type — is
|
||
acknowledged the same way with an RP-ERROR (cause 96, TP-FCS "TPDU not supported"). A submit
|
||
report In-Reply-To a MESSAGE of ours that is no longer in flight — its
|
||
message has ended (its waits run out, judged by the shell; a
|
||
failure; sent) or its segment was followed by the next — is answered 200
|
||
and logged with the message's id and, for an RP-ERROR, its cause, for an
|
||
hour after that MESSAGE went out (`RecentSubmissions`: 5.3.1.2's 200 for
|
||
a report on "a short message submitted by the SM-over-IP sender", whose
|
||
Call-ID its NOTE 3 has the sender store). The bus hears nothing of it:
|
||
`failed` is a message's last word (§8.4), so a text the service centre
|
||
took after its waits had run out stays `failed` there, and the journal's
|
||
line is the record of it. One In-Reply-To no MESSAGE of ours on record —
|
||
a stranger's, ours of more than an hour ago, ours of before a restart —
|
||
is answered 488, which for the last two departs from the clause: it has
|
||
a 200 for every short message the sender submitted, and its NOTE 3 sets
|
||
the stored Call-ID no term; one without In-Reply-To that no message in flight
|
||
owns, 200. The journal names a received message's sender, size and time,
|
||
not its text (§12 has the cases in which a text does reach it); the text
|
||
is in the store (the store bullet above) until
|
||
an app deletes it — unless it was not stored (`NOT stored`, the
|
||
store bullet). A class 2 message is for the (U)SIM — a (U)SIM data
|
||
download (TP-PID 0x7F with a class 2 coding, which TS 23.040 9.2.3.9 has
|
||
the ME pass to the (U)SIM), or a message for the card's EF_SMS — and
|
||
imsd has no way to the card for it, so it is refused, each segment as
|
||
it comes. TS 23.038 4 has the MS
|
||
"ensure that the message has been transferred to the SMS data field in
|
||
the (U)SIM before sending an acknowledgement to the SC" and return
|
||
"protocol error, unspecified" when it "cannot be stored in the (U)SIM
|
||
and there is other short message storage available" (the clause
|
||
excepts a download for an MS that supports the (U)SIM Application
|
||
Toolkit, which imsd does not; its "memory capacity exceeded", for an
|
||
MS whose storage is all in use, imsd never answers: its store has no
|
||
bound of its own). The delivery
|
||
report is an RP-ERROR with that cause, 111, and the TP-FCS 0xFF,
|
||
unspecified error cause; a MESSAGE that names no gateway
|
||
gets none, as with any delivery. The message is neither stored nor
|
||
handed to the bus, and the journal has its sender, service centre and
|
||
time. A short message type 0 (TP-PID 0x40) is no message for the card,
|
||
whatever its class: 9.2.3.9 has it received "irrespective of whether
|
||
there is memory available in the (U)SIM or ME or not", and it goes the
|
||
way of any type 0 (below). Handing a class 2 message to the card from imsd — TS
|
||
31.111 7.1.1's ENVELOPE (SMS-PP DOWNLOAD) for a download, an EF_SMS
|
||
record for the rest — is not done. The dev phone's KPN USIM has both
|
||
services (2026-11-20, the fp6 journal's `2026-11-20-issues-2-5` capture,
|
||
`phone`: its service table lists 28, data download via SMS-PP, and 10,
|
||
short message storage, and EF_SMS holds ten records of 176 bytes; the
|
||
modem's route table has a class 2 message it receives itself stored on
|
||
the card,
|
||
`--wms-get-routes`), and `qmicli` has the APDU route AKA takes
|
||
(`--uim-send-apdu`) and no toolkit command; whether the modem lets an
|
||
ENVELOPE through there has not been tried. RP-SMMA
|
||
(memory available) is never sent; nothing else is done by TP-PID — a short
|
||
message type 0, which TS 23.040 9.2.3.9 has an MS acknowledge, discard
|
||
and not show, is stored and handed over like any text, its `pid` (0x40)
|
||
the consumer's to act on, a Replace Short Message type replaces
|
||
nothing, and TP-PID 0x7F without a class 2 coding is a message like any
|
||
other (9.2.3.9: "handled in the normal way"); a class 0 message
|
||
is stored like any other, its `class` the consumer's to act on; a 7-bit text under a national language shift
|
||
table (TS 23.040 9.2.3.24.15 and 9.2.3.24.16, the header's elements 0x24
|
||
and 0x25) is read with the default tables, and a compressed text (TS
|
||
23.038 4: bit 5 of the coding scheme) as if it were not compressed.
|
||
- **The bus** (§8.4): `net.catcrafts.IMS1.Messaging` on the same object,
|
||
additive to the frozen interface; `Send`, `Subscribe`, `List` and `Delete` gated by
|
||
`net.catcrafts.IMS1.Messaging`, the signals unicast to the subscribed
|
||
connections (the submission's `sent` / `failed` also to the `Send`
|
||
caller's), never broadcast. Spacebar (ModemManager-Qt) and Chatty
|
||
(libmm-glib) read ModemManager's Messaging interface, which imsd cannot
|
||
stand in for; `imsd-messages`, the app built for this interface, speaks
|
||
it (its first run against imsd on the dev phone: 2026-10-18 01:21–01:36)
|
||
— its flatpak on the `flatpak.catcrafts.net` remote accompanies this
|
||
release.
|
||
|
||
### 7.10 A phone that sleeps
|
||
|
||
Nothing of imsd runs while the phone is suspended. What it has to do at
|
||
a certain time the phone has to be awake for, and what it waits for
|
||
must not be cut off by a suspend. This is what sees to that.
|
||
|
||
- **The refresh, and the subscription's renewal ahead of its expiry, run
|
||
on the boot clock.**
|
||
The network counts
|
||
a registration's lifetime while the phone sleeps. The refresh (§7.2
|
||
step 5) is due on `CLOCK_BOOTTIME`, as the recovery policy's waits are
|
||
(§7.4), and so is the renewal of the reg-event subscription ahead of
|
||
its granted lifetime's end. In the releases up to 1.2.4 both counted
|
||
awake seconds, and a registration lapsed on a phone that slept most
|
||
of its two hours (§13).
|
||
- **A wake alarm.** A timer on `CLOCK_BOOTTIME_ALARM` (the kernel's alarm
|
||
timer, which sets the RTC's alarm for a suspend; it takes
|
||
`CAP_WAKE_ALARM`, which the service has) is armed at the end of every
|
||
turn of the loop that takes no command off the queue (a turn that
|
||
takes one handles it and goes straight to the next turn) for the time
|
||
`WakeAt` names (`Imsd:Engine`): now while a call or a text is in
|
||
flight (the hold of the next entry); else, with a
|
||
registration on a live flow the refresh's due time, or the reg-event
|
||
subscription's renewal where that comes first; with a dead flow under
|
||
a registration the recovery policy's word (`RegRecovery::WakeTime`: its
|
||
next step, and the slower look after a local wait, below); and none
|
||
where nothing waits to be done. A bring-up's wait for the policy arms
|
||
the policy's time itself. The timer is never read: the waking is the
|
||
whole of it, and the loop's own clock checks act once the phone is
|
||
awake. Where the kernel gives no such timer, or has no RTC behind it,
|
||
the journal says so once, and nothing wakes the phone for imsd. A
|
||
resume by itself sends nothing: a refresh that is not due does not go
|
||
out.
|
||
- **Work in flight has a lock and the alarm.** Beside the call's lock
|
||
(§7.6) the main thread asks for a second block inhibitor of
|
||
logind's, in the way it asks for the call's
|
||
(its reason `a registration step or a text in flight`), while a step
|
||
of the
|
||
registration exchanges with the network (the refresh, a reconnect, a
|
||
fresh registration, the bring-up: `Engine::Step`) and while a text is
|
||
being sent, whose two waits count awake seconds (§7.9); not while a
|
||
bring-up waits out a hold the network set, which can be an hour
|
||
(§7.4). For a suspend that begins all the same (logind refused such
|
||
a lock where a suspend's operation was already running, §13; a request
|
||
can tell it to ignore inhibitors) there is the alarm. Under a call
|
||
and under a text in
|
||
flight, and where a step is due that the next turn runs (but for the
|
||
look after a local wait, below, which has its own slower time), it
|
||
is set 1.9 s ahead at every such turn, and the kernel refuses a
|
||
suspend under an alarm less than two seconds ahead (§13); that holds
|
||
where there is
|
||
an alarm and while the loop turns or a call's resend waits for its
|
||
connect, not through a turn that takes longer otherwise (a media leg
|
||
being stopped, a helper program) and not through a registration
|
||
step; and the suspend has to come to the kernel's check before the
|
||
alarm set last has fired, after its sync and its freeze of the
|
||
processes (§13). A step keeps the
|
||
alarm at most 30 s ahead while it waits for
|
||
the network, whatever else is in flight: where imsd has its wake
|
||
alarm, a sleep that begins under such a wait ends there, and the
|
||
step goes on (this section's last paragraph has what is left). The
|
||
alarm fires once
|
||
(§13), and a wait can outlast the sleep it ended, so it is set anew
|
||
before every second of a wait for the network (a connect's answer,
|
||
the pause before the next try, a REGISTER's answer): where the wait
|
||
goes on after a wake, it stands again within a second. One of those
|
||
waits, for the fresh registration's first answer, is a receive with a
|
||
timeout, which a suspend's freeze ends with `EINTR` (§13): it is
|
||
taken up again for the rest of its time. A wait for a helper program
|
||
keeps the alarm that stood when it began.
|
||
- **A coverage gap costs little sleep.** While the modem reports no
|
||
packet service the recovery tries no reconnect and no fresh
|
||
registration, and no lock is taken for one: either would wait for
|
||
answers that cannot come. A dead flow's socket that is still open at
|
||
that look is closed there without the FIN's exchange (`Abort`): over
|
||
TCP,
|
||
left open it is readable at every turn of the loop, which would
|
||
spin instead of waiting, and closed with a FIN it would hold the
|
||
address pair against the reconnect after the gap, as the socket of
|
||
a flow does that a step closed after a wait without an answer (the
|
||
kernel's refusals, below). (The refresh that
|
||
runs into the gap waits its 12 s under the lock, once. A bring-up
|
||
does not ask the modem: one that meets a gap makes its attempts
|
||
under the lock. A `Dial` that finds the flow dead in the gap ends
|
||
at once: the recovery's immediate try for it tries nothing either,
|
||
and the INVITE fails on a flow that is gone.) Awake and with no call
|
||
up, the modem is
|
||
asked again every 5 s; a sleeping phone is woken for the next look
|
||
after as long again as the modem has been without service, 10 s at
|
||
the least and 15 min at the most (§7.4's table). That time is
|
||
counted from the modem's first word of no service since the network
|
||
last answered (§7.4's table has what counts as its answer): the
|
||
modem's word for its
|
||
service starts no count over, and where it alternates at the edge
|
||
of coverage an attempt made on it costs its wait under the lock
|
||
(a TCP reconnect's 34 s where nothing answers) while the looks keep
|
||
their pace. Every
|
||
step that follows no local wait is woken for at the policy's own
|
||
time (§7.4's table): a reconnect cycle the network was silent to is
|
||
no local wait where the modem has service, a fresh attempt it was
|
||
silent to never is.
|
||
The kernel refuses a connect locally for as long as the
|
||
old flow's socket holds the address pair, which clears in awake
|
||
seconds (TIME_WAIT's 60, an unanswered FIN's retransmissions): two
|
||
tries 10 s apart under the lock at each look. That is the other
|
||
local wait: awake and with no call up, the next look comes 5 s after
|
||
each; a sleeping phone is woken for it after as long again as the
|
||
kernel's refusals have lasted, 10 s at the least and 15 min at the
|
||
most, counted from its first refusal since the
|
||
modem's last word of no service or the network's last answer,
|
||
whichever came later. The slower look does not know
|
||
the registration's lifetime: a gap that ends shortly before the
|
||
lifetime does can cost the registration.
|
||
|
||
What of the registration's schedule and of the texts' times still
|
||
counts awake seconds is in §7.4's paragraph on the clocks; a step's own
|
||
waits for the network (a connect's answer, the pause before the next
|
||
try, a REGISTER's answer) count them too, under the step's lock.
|
||
Nothing holds a sleep off under the bring-up script, which runs before
|
||
the daemon (§7.3), nor in the wait before a restart after a failure: a
|
||
phone suspended there does not register until it is awake again. And
|
||
from the
|
||
moment the alarm has woken the phone to the step it woke it for, the
|
||
loop's next turn (up to a second where a bring-up waited out a hold),
|
||
there is neither alarm nor lock: a desktop that asked for a suspend
|
||
again within that time would have the phone sleep through the step
|
||
until something else woke it. For up to a second after the alarm has
|
||
ended a sleep under a step's wait it is not set again yet either
|
||
(where the freeze has ended the receive of the fresh registration's
|
||
first wait with time left, §13, it is set at once), and a helper
|
||
program the step goes on to from a wait in that second has none until
|
||
the step's next wait for the network: a suspend told to ignore
|
||
inhibitors that began there would not be ended by imsd.
|
||
|
||
## 8. D-Bus ABI and desktop integration
|
||
|
||
### 8.1 `net.catcrafts.IMS1` (frozen)
|
||
|
||
Object `/net/catcrafts/IMS1`, interface `net.catcrafts.IMS1`. The ABI is
|
||
frozen — the two translation daemons depend on it, and a new desktop needs a
|
||
new translation daemon, not a change here.
|
||
|
||
| Member | Signature |
|
||
|---|---|
|
||
| `Dial(number)` | `s → s` (callUni) |
|
||
| `HangUp(callUni)` | `s` |
|
||
| `Accept(callUni)` | `s` |
|
||
| `SendDtmf(callUni, tones)` | `ss` |
|
||
| `GetCalls()` | `→ aa{sv}` |
|
||
| `GetStatus()` | `→ a{sv}`: `registered` (b), `local` (s), `pcscf` (s), `expiry` (x), `cseq` (x), `ppi` (s) |
|
||
| `CallAdded` | `s a{sv}` |
|
||
| `CallStateChanged` | `s s s` (callUni, state, reason) |
|
||
| `CallDeleted` | `s` |
|
||
| `RegistrationChanged` | `b` |
|
||
|
||
`Dial`, `HangUp`, `Accept` and `SendDtmf` are gated by polkit (§7.1); a
|
||
refused caller gets `org.freedesktop.DBus.Error.AccessDenied`, and polkit not
|
||
answering is logged with the sender. A translation daemon that runs as root
|
||
on the system bus must gate its own callers through `imsd-bus`, or it is a
|
||
bypass of `net.catcrafts.IMS1.Voice`. Since 1.2.0 a second interface,
|
||
`net.catcrafts.IMS1.Messaging`, lives on the same object (§8.4); this one
|
||
is unchanged by it.
|
||
|
||
### 8.2 Plasma Mobile (`imsd-dialerd`)
|
||
|
||
A drop-in for plasma-dialer's `modem-daemon`, owning the same session-bus
|
||
names and objects (`org.kde.telephony.CallUtils` at
|
||
`/org/kde/telephony/CallUtils/tel/mm`, likewise `DeviceUtils` and
|
||
`UssdUtils`; the `/tel/mm` suffix is hard-coded in plasma-dialer's QML plugin
|
||
and kde-telephony-daemon — keep it). plasma-dialer, kde-telephony-daemon and
|
||
spacebar run unmodified. ABI details verified against plasma-dialer 6.7.3 are
|
||
in the header of `implementations/dialerd.cpp` (`CallData` marshalled as a
|
||
struct wrapping `a{sv}`, struct-wrapped int32 enums in MMCallState numbering,
|
||
an empty callUni meaning the active call, `callsChanged` with the full vector
|
||
on every add/delete). It lists no modem while imsd is unregistered.
|
||
|
||
### 8.3 GNOME Calls, Phosh, GNOME Mobile (`imsd-ofonod`)
|
||
|
||
Presents imsd as an oFono modem: `org.ofono` with a `Manager` at `/`, one
|
||
`Modem` + `VoiceCallManager` at `/imsd`, and a `VoiceCall` object per live
|
||
call — what GNOME Calls' bundled `ofono` provider plugin drives; Calls, Phosh
|
||
and GNOME Shell run unmodified. `org.ofono` is the seam because it is the
|
||
only one a third party can implement: `org.gnome.Calls.Call` is what Calls
|
||
*exports* so a shell can observe and control a call that already exists
|
||
(Accept, Hangup, SendDtmf, Silence — no Dial), and Phosh consumes it from
|
||
Calls — its call UI needs nothing extra once Calls has a working origin;
|
||
Calls' own backends are libpeas provider plugins (`mm`, `ofono`, `sip`,
|
||
`dummy`) against private headers no distro installs.
|
||
Consumer-shaped details verified against calls 50.0 are in the header of
|
||
`implementations/ofonod.cpp`. Verified on a Fairphone 6 (postmarketOS,
|
||
dbus-broker) with GNOME Calls 50.0: outgoing and incoming calls with audio
|
||
both ways, answered and hung up through `org.gnome.Calls.Call` — the surface
|
||
Phosh drives. The answered calls predate the polkit gate (§5).
|
||
|
||
Setup: `apk add imsd-ofono` enables `imsd-ofonod.service` by preset and ships
|
||
a gschema override setting `org.gnome.Calls autoload-plugins` to `['ofono']`
|
||
(the per-user equivalent is `gsettings set org.gnome.Calls autoload-plugins
|
||
"['ofono']"`). Drop `mm` rather than adding `ofono` alongside it: the
|
||
ModemManager provider would offer the modem's CS voice path as a second
|
||
origin, and on a phone whose voice path is imsd that origin carries no audio.
|
||
Never run it beside a real `ofonod` (one name, one owner;
|
||
the unit has `Conflicts=ofono.service` and the daemon exits if it loses the
|
||
name). Running `imsd-dialerd` at the same time is fine (different bus,
|
||
different consumer). One dbus-broker
|
||
detail is load-bearing and lives in `packaging/org.ofono.conf`: dbus-broker
|
||
checks a broadcast against the sender's send policy for every name the
|
||
receiver owns, so root (imsd) must be allowed `send_destination="org.ofono"`
|
||
or imsd's call signals never reach the daemon.
|
||
|
||
Known gaps, all inherited rather than introduced:
|
||
|
||
- USSD is refused with `org.ofono.Error.NotSupported` and not advertised in
|
||
the modem's `Interfaces`: the IMS stack has no USSD path.
|
||
- No hold, multiparty, transfer or call waiting (`org.ofono.Error.NotImplemented`):
|
||
imsd is a single-call stack.
|
||
- Per-call caller-ID withholding is refused rather than silently ignored:
|
||
imsd cannot honour a CLIR request, and failing is safer than dialling with
|
||
the caller ID exposed.
|
||
- Phosh's emergency-call screen lists nothing: `imsd-ofonod` publishes
|
||
`org.ofono.VoiceCallManager.EmergencyNumbers` (112, 911, plus
|
||
`EMERGENCY_NUMBERS`), oFono's standard place for it, but Calls' ofono
|
||
provider never reads it: it makes no `GetProperties` call on the VoiceCallManager
|
||
and returns NULL for the origin's `emergency-numbers`, which is what
|
||
`org.gnome.Calls.EmergencyCalls.GetEmergencyContacts` is built from (the
|
||
ModemManager provider fills its equivalent via
|
||
`mm_sim_dup_emergency_numbers()`). An upstream fix would close this.
|
||
Dialling an emergency number from the dialpad is unaffected — that reaches
|
||
imsd's own classifier.
|
||
- Restarting `imsd-ofonod` restarts GNOME Calls with it: when the modem's
|
||
`VoiceCallManager` interface goes away and comes back, Calls 50.0 adds a
|
||
new origin but leaves the old origin's `CallAdded` handler connected, so
|
||
after one such cycle every call is added twice, and after a few the stale handler runs on
|
||
freed memory and Calls dies with SIGBUS in `g_hash_table_lookup` (measured
|
||
on the FP6). Calls-side; an upstream fix belongs in
|
||
`plugins/provider/ofono/calls-ofono-provider.c`. To keep imsd's own
|
||
restarts and registration drops from triggering it, the
|
||
`VoiceCallManager` interface is listed permanently (`Online`
|
||
tracks registration; `Dial` fails with "imsd is not registered" / "imsd is
|
||
not running"), and only this daemon's own restart cycles the origin — after
|
||
which Calls dials nothing until it restarts, so the unit's `ExecStartPost`
|
||
(`imsd-ofono-restart-calls.sh`) restarts the Calls daemon of every user
|
||
running one. The first start since boot leaves a running Calls alone.
|
||
|
||
Development without a phone or root (crafter-build's binaries run inside the
|
||
sandbox: §4.1):
|
||
|
||
```sh
|
||
./bin/imsd-*/imsd --session & # imsd's ABI on the session bus
|
||
./bin/imsd-ofonod-*/imsd-ofonod --session
|
||
busctl --user call org.ofono / org.ofono.Manager GetModems
|
||
```
|
||
|
||
### 8.4 `net.catcrafts.IMS1.Messaging` (since 1.2.0)
|
||
|
||
Short messages over IP (§7.9), on the object `/net/catcrafts/IMS1` beside
|
||
the frozen interface (§8.1's; "the frozen interface" in this document stays
|
||
its name). This one is frozen as of 1.2.0 as well: an app outside this
|
||
repository consumes it (`imsd-messages`). The members, their signatures, the
|
||
keys' names, types and meanings, the state words and the error names stay as
|
||
they are; a dictionary imsd gives may gain a key, which a consumer ignores
|
||
when it does not know it.
|
||
|
||
| Member | Signature |
|
||
|---|---|
|
||
| `Send(number, text, options)` | `ssa{sv} → s` (the message's id, `ims-sms-<run>-<start>-<N>`: this run's token — eight hex digits drawn at the daemon's start —, its start second and a counter; a later run gives the same id only if it draws the same token and starts in the same second, and a received id (`ims-sms-in-<run>-<epoch>-<N>`) only with the same token, arrival second and counter; a client keys `StateChanged` by id); options: `status-report` (b). `org.freedesktop.DBus.Error.NotSupported` while `SMS_OVER_IMS` is off |
|
||
| `GetStatus()` | `→ a{sv}`: `enabled` (b, the daemon's configuration — answered before the first registration too), `smsc` (s, the service centre as of the daemon's last status snapshot, the one the frozen `GetStatus` answers from — so empty before a run's first, and when none is known), `ppi` (s, the own number in that snapshot — the frozen interface's `ppi`, made valid UTF-8 as `to` is, so a consumer needs no second call — empty while the snapshot holds none), `operator` (s, the SIM's operator id — MCC then MNC, as ModemManager gives it, and never the IMSI — empty until the first status after the SIM is read), `registered` (b), `subscribers` (u). No count of the store: `GetStatus` is the open read, and a count would tell any local account when a text arrived; `List`'s length is behind the gate |
|
||
| `Subscribe()` | `→` nothing: the caller's connection receives the two signals below from now on, until it closes. It succeeds while SMS over IP is off too (only `Send` is refused then); a consumer reads `enabled` for that state |
|
||
| `List()` | `→ a(sa{sv})`: the stored messages, by the arrival second on the phone's wall clock, then within a run the sequence number — oldest first on a synced clock (a 1970 second before the first time sync sorts first; the SC's `timestamp` is the chronology, §7.9) — each the id and the same dictionary `Received` carries (its `received` the arrival time); a file in the store that reads and is no record is left out, as is a name behind which stat(2) finds no regular file or nothing (`ENOENT`), and a store directory that does not exist is an empty list. `org.freedesktop.DBus.Error.IOError`, with the system's reason, when the store directory or a record's file could not be read: no list comes then, and none while the fault lasts, so a consumer asks again later and takes no message for deleted |
|
||
| `Delete(id)` | `s`: removes a stored message; `org.freedesktop.DBus.Error.InvalidArgs` for an empty string, one over 64 bytes or one with a character other than an ASCII letter, an ASCII digit or `-`; `org.freedesktop.DBus.Error.FileNotFound` for any other string when the removal found no file; `org.freedesktop.DBus.Error.IOError`, with the system's reason, when the removal failed — a record that is there is kept |
|
||
| `Received` | `s a{sv}` — unicast to each subscriber (id `ims-sms-in-<run>-<epoch>-<N>`; `from` s, `text` s, `timestamp` s (the SC's, with its offset: `2026-10-16T22:50:00+02:00`), `received` x (epoch), `sc` s, `to` s when the daemon held an own number at receipt (the first tel: P-Associated-URI of this run's latest answer to a fresh registration, a resume or a reconnect that carried one — a periodic refresh's answer is not read for it — and, until the first such, the state file's once a resume attempt has taken it up): the subscriber the text arrived for, which a later SIM's status cannot tell, `operator` s when the SIM's operator id was known at receipt: the subscription's country and operator, by which a consumer reads a sender in national form or a short code, `class` i (-1: none), `pid` y, `dcs` y, `segments` i, `message-waiting` b, `port-dst`/`port-src` u when the header addresses a port, `data` ay for 8-bit data, `pdu` ay — the SMS-DELIVER as received; of a concatenated message, the segment that completed the set, the last to arrive) |
|
||
| `StateChanged` | `s s s` — unicast to each subscriber, and the submission's `sent` / `failed` also to the connection that called `Send` (id, state, reason): `sent` / `failed` for the submission, `delivered` / `delivery-pending` / `delivery-failed` from a status report — each speaks for the whole message, never for one segment, and `delivery-pending` can come more than once; `delivered` only when every segment's report is in the completed class (§7.9; the reason carries the SC's status word). The words of one message come in this order: the submission's first — `sent`, or `failed`, after which nothing follows — and a status report's only after `sent` (a report the SC sends while a later segment is still on its way is held until the submission ends; a submission whose every segment the SC reported delivered before its last submit report came ends as `sent` then `delivered`), so a consumer applies each word as it comes. Every string of the two signals is valid UTF-8: a `failed` reason can hold the network's text (a refused final's, `RefusalSummary`), so the emission makes it valid — bytes that are not UTF-8 become U+FFFD, and a NUL byte ends the string (the `Received` strings are the codecs' own; `to` is made valid the same way, and `operator` is digits) |
|
||
|
||
`Send`, `Subscribe`, `List` and `Delete` are gated by polkit's
|
||
`net.catcrafts.IMS1.Messaging` through the same `imsd-bus` gate (`Gated`'s `Action` parameter);
|
||
`GetStatus` is a read. The signals are never broadcast: a D-Bus broadcast
|
||
reaches every account the bus policy lets receive from imsd, which polkit
|
||
cannot narrow, so `Received` and `StateChanged` are emitted unicast to the
|
||
unique names `Subscribe` admitted (and the submission's `sent` / `failed`
|
||
to the `Send` caller's), which the bus delivers to those connections. A
|
||
subscription ends with its connection (imsd watches the name); imsd's own
|
||
restart empties the list, so a consumer subscribes at start and again
|
||
whenever `net.catcrafts.IMS1` reappears on the bus. A `Send` whose
|
||
`StateChanged` had not come when the name left the bus has an unknown fate:
|
||
imsd keeps no queue across a restart, and the message in flight may or may
|
||
not have reached the service centre; nor does it keep its record of the
|
||
messages that asked for a status report, so a report that comes after a
|
||
restart is matched to none of them. Root sees the signals
|
||
with `busctl monitor` as before. With SMS over IP on, the `imsd --session` dev mode answers `Send` with an
|
||
id and a `failed: imsd is not registered` state (2026-10-16,
|
||
`SMS_OVER_IMS=1`, the host's session bus).
|
||
|
||
## 9. Packaging, CI and releases
|
||
|
||
### 9.1 The APKBUILD
|
||
|
||
`packaging/APKBUILD.binary` is **the** packaging since 2026-09-02: it wraps
|
||
a crafter-build binary cross-compiled per §4.2 (bundled by
|
||
`packaging/make-bin-tarball.sh` together with the units, scripts and
|
||
policies) into the apks CI publishes. `pkgver` is taken from the `Version`
|
||
constant in `implementations/main.cpp` by `build-package.sh`.
|
||
Subpackages: `imsd-ofono` (the GNOME Calls backend, opt-in) and
|
||
`imsd-systemd` (the unit files; `install_if` systemd — ordered after
|
||
`imsd-ofono` because `systemd()` amoves all of `usr/lib/systemd/system`).
|
||
There is no from-source recipe: a build needs crafter-build (§4.1).
|
||
|
||
It declares `provides="81voltd=$pkgver-r$pkgrel"`: this satisfies
|
||
`soc-qcom-modem`'s dependency and excludes the real package, because 81voltd
|
||
serves the modem's own ims-PDN requests, races imsd for the PDN and flaps it
|
||
with a new prefix every ~2.5 min — two IMS stacks cannot share one PDN.
|
||
`depends` lists `modemmanager`, the AMR codec libraries, `pipewire-tools` and
|
||
`polkit` (the gate fails closed without it). There is no OpenRC service: the
|
||
unit's sequencing is only tested under systemd.
|
||
|
||
### 9.2 What the package installs and enables
|
||
|
||
`imsd.service` is enabled by preset (`80-imsd.preset`, plus the
|
||
`multi-user.target.wants` link), so VoLTE survives reboots without a manual
|
||
`systemctl enable`. Since 1.0.0 there is no condition on `/etc/imsd.env`:
|
||
the P-CSCF comes from the PDN's PCO, so the unit starts on every phone with
|
||
the package — installing it and inserting a SIM is the opt-in; the file holds
|
||
overrides only — and a phone with nothing to do (no SIM, no ims PDN from the
|
||
network, no P-CSCF in the PCO and nothing to resume) exits cleanly and stays
|
||
inactive (§7.3)
|
||
rather than failing and restarting. `systemctl mask --now imsd` opts out: a
|
||
plain `disable` removes only the [Install] links, and `imsd-ofonod`'s static
|
||
`Wants=imsd.service` (the Phosh image) pulls a disabled imsd back in at every
|
||
boot and at its every restart (dev phone 2026-10-11, the fp6 journal's
|
||
`2026-10-11-0400-bench-kpn` capture: an `imsd-ofonod` restart started a
|
||
stopped and, in the control run, a disabled imsd); the mask
|
||
held through an `imsd-ofonod` restart and a reboot on the dev phone
|
||
(2026-10-11). `systemctl unmask imsd` opts back in. `imsd-ofonod` does not
|
||
wait for imsd (no `After=imsd.service` since 1.0.0, §7.5).
|
||
Until 0.3.12 the apk shipped a drop-in `ConditionPathExists=/etc/imsd.env`;
|
||
the upgrade removes it, and an upgraded phone that never had the file starts
|
||
imsd at its next boot — or during the upgrade itself where `imsd-ofonod`
|
||
runs (§7.5) — and registers where §7.3's rule lets it. `imsd-ofonod.service` is enabled the same way by
|
||
`imsd-ofono`.
|
||
The preset, the `multi-user.target.wants` link and the drop-in no longer
|
||
shipped are the apk's doing (`APKBUILD.binary`'s `package()`); the idle, the
|
||
`Wants=` pull-in and the opt-out are the bring-up script's and the daemon's,
|
||
systemd's and the admin's.
|
||
The main package hides kde-telephony's `modem-daemon` autostart for accounts
|
||
created after it is installed (`/etc/skel/.config/autostart/org.kde.modem.daemon.desktop`)
|
||
because `imsd-dialerd` owns those names.
|
||
|
||
### 9.3 Install scripts
|
||
|
||
`imsd.post-upgrade`, `imsd-ofono.post-upgrade` and `imsd-systemd.post-upgrade`
|
||
mark their units `needs-restart` (§7.5); `imsd.post-upgrade` also records the
|
||
old invocation for the 0.3.9 hand-over. Each `*.post-install` is a symlink to
|
||
its `post-upgrade`: `apk del` leaves the daemon running, so a later `apk add`
|
||
is an upgrade for that daemon and apk runs post-install for it. A first
|
||
install finds no unit active and marks nothing. `imsd-systemd` marks
|
||
`imsd.service` too, since it ships the unit file and apk installs it after
|
||
`imsd`.
|
||
|
||
### 9.4 CI and what a push means
|
||
|
||
`.forgejo/workflows/package.yml` runs on every push to `main` (and on
|
||
dispatch): on the `flatpak` runner label (a privileged runner registered to
|
||
this repository — bubblewrap inside the job container needs the privilege), in an
|
||
`alpine:edge` container, `packaging/build-package.sh` installs the
|
||
Crafter.Build Flatpak (`net.catcrafts.CrafterBuild//stable` from
|
||
flatpak.catcrafts.net — the branch Crafter.Build publishes from its release
|
||
tags, where `beta` follows every push to its master; the build log names its
|
||
commit) and llvm/abuild, builds
|
||
the sysroot, cross-compiles the five products, runs the suite natively inside
|
||
the Flatpak, wraps the result with `APKBUILD.binary`, and the publish step
|
||
uploads the apks to the Forgejo Alpine registry
|
||
(`…/api/packages/Catcrafts/alpine/edge/fp6`) with `PACKAGE_TOKEN`. The
|
||
registry answers 409 for an already-published version and the step treats
|
||
that as "nothing to do", so **a push releases exactly when the `Version`
|
||
constant changes**. This is the only producer of the imsd apk: fp6-img
|
||
images install the published package from the registry, and
|
||
installed phones upgrade with plain `apk upgrade`. **A push to `main` is a
|
||
release to real users' phones.** A release is a range of commits ending in a
|
||
bump commit titled `imsd X.Y.Z` that changes only the `Version` constant.
|
||
|
||
## 10. Configuration reference
|
||
|
||
Everything is environment variables. The packaged unit reads
|
||
`/run/imsd.env` (from `ims-pdn-up.sh`) and then `/etc/imsd.env` (the user's,
|
||
wins on conflict; optional since 1.0.0). The variables are user
|
||
documentation: the tables are in the README.
|
||
|
||
### 10.1 imsd
|
||
|
||
The README's `Full config` table (`SMS_OVER_IMS` and `SMSC` among its rows: §7.9). The protected client/server ports are fixed at
|
||
45061/45062 (`imsd::util::PortUc`/`PortUs`) — changing them in source also
|
||
requires updating the firewall rules `ims-pdn-up.sh` installs. `PCSCF` and
|
||
`PCSCF_DISCOVERED` are read at start (`FreshPcscfFromEnv`, for the start line
|
||
and again by the engine): the first is one address in RFC 5952 form (§7.2 step 3: another spelling is
|
||
refused at bring-up), and wins, the second a comma-separated IPv6 list whose
|
||
first entry `CanonicalIp6` accepts is the fresh target otherwise (an IPv4
|
||
address, a name, a literal with a zone or a dotted-quad tail is skipped — logged by the
|
||
engine when the daemon goes on to register, not by the idle before the bus
|
||
name). A resume goes to the kernel's SA
|
||
peer whatever they say (and routes it itself); beyond the resume's `pcscf:`
|
||
line, having a fresh target decides what a refused or failed resume
|
||
leads to — the fresh registration (a refusal without a Retry-After is not
|
||
counted) or, with none, the pair kept for the restart, removed, or the idle
|
||
(§7.2 step 1) — and a comma-separated `PCSCF=` stops the bring-up before the
|
||
resume. `WAKE_TRACE=1` is a test seam of the wake alarm's (§5, §7.8), no
|
||
configuration, and in none of the README's tables.
|
||
|
||
### 10.2 imsd-media (per call, set through imsd's environment)
|
||
|
||
The imsd-media table under the README's `Full config` (the second
|
||
`Variable | Default | Meaning` table). These are not configuration and are
|
||
left out there:
|
||
|
||
| Variable | Default | Meaning |
|
||
|---|---|---|
|
||
| `CODEC`, `OCTET_ALIGN`, `DTMF_PT`, `DTMF_RX_PT` | *(from the SDP)* | set by imsd from the SDP (`DTMF_PT`: the telephone-event payload type at the codec's clock the leg sends with, empty when none was negotiated; `DTMF_RX_PT`: a second number the leg takes events at — our own SDP's at that clock, or the answer's when the answer gave the audio our offer's number, §7.6); not configuration |
|
||
| `MIC_SRC`, `PCM_DUMP` | *(unset)* | test seams (§5) |
|
||
|
||
### 10.3 ims-pdn-up.sh and imsd-ofonod
|
||
|
||
`IMS_APN`, `IMS_IP_TYPE`, `IMS_PROFILE_ID`, `IMS_REG_TIMEOUT`, `PCSCF`,
|
||
`IMSD_PCSCF` and `IMSD_ENV` (the configuration file's path, a bench seam) for
|
||
the bring-up script (§7.3); `IMSD_IDLE` and `PCSCF_DISCOVERY` are the
|
||
script's word to the daemon, not settings. `imsd-ofonod` reads `EMERGENCY_NUMBERS` (from
|
||
`/etc/imsd.env` through its unit) and `IMSD_BUS=session|system` to override
|
||
only the imsd side of its bus choice.
|
||
|
||
## 11. Making changes
|
||
|
||
- **Commit messages.** Subject `area: what changes` — the area is the module
|
||
partition, program, script or `packaging`/`ci`/`tests`/`README` the change
|
||
lives in (several joined by commas), the rest a short lowercase clause
|
||
with no trailing period, imperative or declarative. The body says why —
|
||
the field incident or the spec clause — and, where the change alters
|
||
behaviour, in one sentence how it was tested. A version bump is a commit
|
||
titled `imsd X.Y.Z` that changes only the `Version` constant and has no
|
||
body.
|
||
- **Versioning.** `MAJOR.MINOR.PATCH`: the patch number counts releases,
|
||
fixes and features alike; the minor number moves when a release changes
|
||
what a user can rely on the daemon for (0.3 added emergency calling), not
|
||
with the size of a release; the major number moves when a release changes
|
||
what an installed phone does without being asked, and it is not an ABI
|
||
change (§8.1: the ABI is frozen). 1.0.0 is the first to move it: the unit
|
||
starts on every phone with the package, with no file to write, and
|
||
registers where `PCSCF=` names the P-CSCF or, on the FP6's `qmapmux0.0`
|
||
(KPN, the one device and network it ran on), where the reader gets the
|
||
PCO's IPv6 list.
|
||
- **No AI attribution trailers.** Commits carry no `Assisted-by:`,
|
||
`Co-Authored-By:` or similar lines, whoever or whatever drafted them.
|
||
- **Signed commits.** Every commit is GPG-signed with the repository's
|
||
configured identity (`git config user.signingkey`, `commit.gpgsign`). Do
|
||
not override the identity from the environment.
|
||
- **One change, one commit; a fix goes into the commit that introduced the
|
||
problem** while a range is unpublished (rebase), never as a follow-up on
|
||
top. Every commit of a range builds and passes the nine suites on its own.
|
||
- **Keep `make-bin-tarball.sh`'s file list and `APKBUILD.binary`'s
|
||
`package()` in sync** when a packaged file is added.
|
||
- **The README and this file follow the code in the same commit.** A new
|
||
knob gets its row in the README's configuration tables; a new state its journal line in §7.8; a new file
|
||
under `/run` or `/var/lib` its row in §7.7.
|
||
- **Compatibility notes are kept where the mechanism lives**, not in a
|
||
changelog the repository does not have: the 0.3.9 hand-over is documented
|
||
in §7.5 because `imsd.post-upgrade` ships in every later package and the
|
||
path stays live for any direct upgrade from an older daemon.
|
||
- **Never commit captures or state** (`*.raw`, `*.rtp`, `*.stats`,
|
||
`imsreg.state`): they carry the subscriber's identity.
|
||
SMS over IP's state stays out likewise: `sms-tpmr`, the next TP-MR, and
|
||
the store's `*.msg`, the texts with their numbers.
|
||
|
||
## 12. Security considerations
|
||
|
||
- imsd runs as root (xfrm, qmicli). Its attack surface on the bus is the
|
||
frozen ABI (§8.1) and, since 1.2.0, the Messaging interface on the same
|
||
object (§8.4), the writes of both polkit-gated (§7.1: the Voice and the
|
||
Messaging action; `Delete` unlinks a record under `/var/lib/imsd/sms` as
|
||
root behind it). Do not add an
|
||
ungated write member, and do not add a root translation daemon that
|
||
forwards calls without gating its own callers through `imsd-bus`.
|
||
- imsd deletes by exact key what two rules select, whoever installed it. A
|
||
fresh registration's SA setup and the dead pair's teardown (`RemoveDeadPair`)
|
||
delete — `ip xfrm state delete src dst proto esp spi`, `ip xfrm policy
|
||
delete <selector> dir` — what two rules select (`OwnXfrmDeleteCommands`): a transport-mode policy with reqid 1 or 2 whose
|
||
selector carries the protected port 45061/45062 on the UE side (imsd's
|
||
fingerprint), and a transport-mode reqid-1/2 ESP state running from such a
|
||
policy's source to its destination or anchored on the UE's ims-PDN address
|
||
(a state whose policy add failed goes too; an AH or IPComp state is not
|
||
selected). Never `ip xfrm state|policy flush`: a policy-based VPN's
|
||
(strongSwan's, libreswan's) SAs and policies, or another transport-mode
|
||
user's pair on other ports and addresses, stay. Before 1.0.0 the setup
|
||
flushed the host's whole xfrm state and policy. Residual: a transport-mode
|
||
policy with reqid 1 and the UE-side port 45061, or reqid 2 and 45062 — alone
|
||
or paired, between any addresses — goes, with the reqid-1/2 transport-mode
|
||
ESP states in its direction, and a reqid-1/2 transport-mode ESP state on the
|
||
UE's ims-PDN address goes whoever made it (`tests/Ipsec` pins both).
|
||
- Whether the signalling is encrypted inside the SAs is the P-CSCF's
|
||
choice (TS 33.203 5.1.3): the default offer names `aes-cbc` and the null
|
||
cipher, and with the null cipher selected the SAs protect the
|
||
signalling's integrity and do not encrypt it. `EALG=aes-cbc` offers
|
||
encryption only; a P-CSCF that answers it with the null cipher alone is
|
||
followed all the same (README, `EALG`: when no entry matches). The
|
||
protected REGISTER repeats the Security-Client for the P-CSCF to compare
|
||
with the first one's (TS 33.203 Annex H).
|
||
- The bus policies deliberately let any local account *reach* both names;
|
||
authorization is polkit's, not the policy file's. Keep it that way: a
|
||
policy that names an account breaks the moment the account is called
|
||
something else.
|
||
- What an ISIM's identity files hold goes into the requests of a
|
||
registration made under it. Its REGISTERs: the home domain as the
|
||
Request-URI's host and in the digest's quoted `realm` and `uri`, the
|
||
private identity inside the quoted `username`, the public identity
|
||
between the angle brackets of From and To. Beyond them: the home domain
|
||
in the address `RuriFor` makes of a dialled number, an outgoing call's
|
||
Request-URI and To (its host, and its phone-context where `RuriFor`
|
||
writes one), and as the host of the service centre's address of an SMS
|
||
submission (`ScPsi`: the MESSAGE's Request-URI and To); the public
|
||
identity, while no
|
||
P-Associated-URI has named another, as the reg-event SUBSCRIBE's
|
||
Request-URI, From and To (`BuildSubscribeReg`) and as the identity of
|
||
imsd's own requests (`CallerId`). `ParseIsimValue` takes no blank and no
|
||
byte outside printable ASCII and `IsimIdentity` no quote, backslash or
|
||
angle bracket, and in the domain nothing but letters, digits, hyphens
|
||
and dots, so a card cannot end a header field or a request line or add
|
||
one; a card whose values fail the check registers the derived names. The
|
||
journal prints the three as it prints the IMSI, and the state file holds
|
||
them.
|
||
- SIP dumps and the state file carry the IMSI, the MSISDN, SPIs and
|
||
addresses, and the state file (since 0.3.11) the last challenge answer —
|
||
nonce, cnonce and response — and (since 0.3.12) the P-CSCF's
|
||
Security-Server list. Dumps are mode 0600 under the state dir, off by default
|
||
(`DUMP_SIP=0`), and never leave the phone in a commit.
|
||
- The ims PDN is a walled garden: `ims-pdn-up.sh` keeps it from becoming
|
||
the default route and gives the P-CSCF a host route — the configured one,
|
||
or the first IPv6 address the modem reports from the PCO (the fresh target; at most eight
|
||
are handed over, IPv4 entries and names dropped); imsd adds one per call for
|
||
the media peer (§7.3) and one for the P-CSCF it registers to or resumes on
|
||
(§7.2 step 3). Nothing else is routed over it.
|
||
A change that routes anything else over it needs a reason and a bench.
|
||
- The fixed protected ports (45061/45062) are opened in nftables for
|
||
`qmapmux*` only, by the bring-up script, and ESP is accepted there: the
|
||
kernel drops an ESP packet no SA matches, and what an SA decapsulates
|
||
passes the chain again, under the same rules as a packet that came
|
||
without ESP.
|
||
- `ServerPorts` (the protected ports' TCP listeners and UDP sockets)
|
||
takes a request from whatever reaches it on the ims PDN (the entry on
|
||
short messages below). The channel of a request that came in there
|
||
over TCP is the newest connection `ServerPorts` holds from that
|
||
request's peer to the port it came in on; where it holds none, an
|
||
answer given to the channel is not sent (§7.8). A connection that has
|
||
ended in an error is held until `Poll` has read its end, and what is
|
||
written to it meanwhile is lost. Over UDP the channel is the socket
|
||
that the port the answer leaves by has when the answer is sent, if it
|
||
has one. A channel keeps no descriptor: the kernel gives a closed
|
||
descriptor's number out again, to a pipe, a file or the connection of
|
||
whoever connects next.
|
||
- Short messages (§7.9): `Send` is behind `net.catcrafts.IMS1.Messaging`
|
||
(an ungated `Send` would let any local account text from the
|
||
subscriber's number); the journal names a delivered message's sender, size and
|
||
time — a text reaches it only as the hex of a body that is no RP message
|
||
or of an unusable TPDU, and as the body of a MESSAGE whose `Content-Type`
|
||
does not contain `application/vnd.3gpp.sms` (§7.9); the
|
||
`DUMP_SIP` MESSAGE dumps do carry texts, mode
|
||
0600 like the rest. A MESSAGE outside a call's dialog whose `Content-Type`
|
||
contains `application/vnd.3gpp.sms` (§7.9) is taken for a short message
|
||
under `SMS_OVER_IMS=1` (refused with 480 without it), from the P-CSCF over the SA
|
||
or in plaintext from any address that reaches the server ports on the ims
|
||
PDN — imsd checks neither the source nor the sender, and `from` is
|
||
the TPDU's TP-OA, decoded and unchecked;
|
||
the store under `/var/lib/imsd/sms` holds the texts, 0600 in a 0700
|
||
directory under a 0700 state directory (`StateDirectoryMode`: even the
|
||
store directory's mtime would tell another account when a text arrived),
|
||
until an app deletes them.
|
||
`Received` and `StateChanged` go unicast to the connections `Subscribe`
|
||
admitted through the Messaging action — a submission's `sent`/`failed`
|
||
also to the connection that called `Send`, admitted by the same action —
|
||
never broadcast: a text's content
|
||
reaches no connection polkit did not allow.
|
||
|
||
- **`imsd-pcscf` holds a QMI WDS client of its own on the modem, as root,
|
||
from `ims-pdn-up.sh`.** It binds to the bearer's mux data port and reads
|
||
the call's runtime settings; it never sends Start Network or Stop Network. Its only writes
|
||
are its own client's mux binding and IP family; the call stayed connected
|
||
and the registration stood after it (§13). One client socket, closed on
|
||
exit (the service lookup's own socket closes when the lookup ends).
|
||
|
||
## 13. Carrier and platform facts the code relies on
|
||
|
||
Observed on real networks and encoded in the policy; cite them when touching
|
||
the related code.
|
||
|
||
- **KPN's fresh-SA throttle** — the `bring-up deferred: fresh-SA throttle
|
||
active (spi-s=0)` case — refuses a fresh SA pair on an address while the
|
||
registration on that address is live, whatever its age or last refresh:
|
||
refused 11 s, 23 min and 2 h 58 min into a registration, 4 and 6.6 min
|
||
after its last refresh (2026-09-19, -20, -24, 2026-10-03). KPN drops that
|
||
registration the moment the initial REGISTER arrives, throttled or not,
|
||
and with it gone accepts a fresh pair there: 5 and 21 min after the
|
||
throttled attempt (2026-10-03). An address that holds no registration is
|
||
accepted while another address's is live (2026-09-26, 2026-10-03), and a
|
||
new prefix's PDN address was accepted 15 s after a throttled attempt on
|
||
the temporary one (the 0.3.9 → 0.3.10 hop, 2026-10-03). An address whose
|
||
registration another address's had replaced was refused 26 s after,
|
||
accepted 141 s and 10 min after (2026-10-03): how soon KPN accepts where a
|
||
registration has just gone is not measured more closely. The schedule's
|
||
21 min is the wait that has never been refused, not a measured minimum;
|
||
imsd resumes rather than registers fresh wherever it can, since on a live
|
||
registration's address the attempt is refused and costs the registration.
|
||
- **KPN refused the two re-REGISTERs that followed an unanswered refresh
|
||
`482 Loop Detected`, before any fresh attempt, and answered 200 where
|
||
the next number was sent** (the dev phone, 2026-11-25; the fp6
|
||
journal's `2026-11-25-refresh-answer-lost` capture). A refresh's answer
|
||
did not reach the phone, whose firewall dropped the network's packets
|
||
for 20 s in a test. The reconnect's re-REGISTER was refused 482 10 s
|
||
after the refresh had failed, and the next one that reached the
|
||
network 66 s after that. That both carried the unanswered one's number
|
||
is read from the code, not seen: it was a test build with 1.2.4's code
|
||
at that place, and the journal prints no number for a REGISTER that
|
||
fails. The fresh registration that followed met the throttle above
|
||
(`spi-s=0`), re-REGISTERs after it were answered `480 Temporarily
|
||
Unavailable` with `Retry-After: 180` (by the same reading of the code
|
||
they carried the unanswered one's number too: the 482 came only
|
||
before the throttled attempt), and the phone registered again
|
||
25 min 55 s after the refresh had failed. With the next number, the
|
||
reconnect's re-REGISTER after a refresh whose answer was dropped the
|
||
same way was answered 200.
|
||
- **O2 UK, 2026-09-24:** a refresh refused 21 × 503 over 70 min, then 33
|
||
unanswered reconnect cycles; a fresh registration was accepted in one
|
||
second. The origin of `RegRecovery`. On 2026-10-08, under 0.3.10 (the
|
||
first release to log a Retry-After), a refresh was refused 503 with
|
||
`Retry-After` 414 s and the refresh after that wait 503 with `Retry-After`
|
||
772 s: the origin of the `Retry-After` escalation. Every refresh of the
|
||
pre-0.3.11 shape — an initial registration's empty digest and the in-use
|
||
SPIs in Security-Client — on record from O2 was refused with 503: 21 on
|
||
2026-09-24 under 0.3.9 and the same loop again that afternoon on a
|
||
stationary phone, two on 2026-10-08 under 0.3.10, and the user never saw
|
||
one succeed, while
|
||
the fresh registrations that followed were accepted: the origin of the
|
||
5.1.1.4.2 refresh shape. KPN accepts both shapes without a challenge.
|
||
- **The security offer.** KPN answered the two-cipher offer with one
|
||
mechanism, `hmac-sha-1-96` with `aes-cbc`, at a fresh registration, and
|
||
answered a reregistration that carried it 200 (the dev phone, 2026-11-22,
|
||
an earlier build of this change, on 1.2.0). Odido answered an offer that
|
||
named the null cipher with one mechanism naming `ealg=null`: the
|
||
Python stack's offer of that one cipher (2026-07-13) and the four
|
||
mechanisms of another Fairphone 6's own IMS client, which then
|
||
registered (2026-07-15). On KPN's ims PDN (MTU 1280) the netdev counted
|
||
one datagram fragmented in two after a boot with one fresh registration,
|
||
with one mechanism offered and with two (the dev phone, 2026-11-22):
|
||
the first REGISTER goes over UDP whatever its size, and KPN challenged
|
||
both.
|
||
- **KPN closes a registration's previous reg-event subscription with
|
||
`noresource`** when a new one replaces it: that end is not renewed.
|
||
- **Modem attach-family forcing** (Odido, O2 UK, Swisscom): an APN-string
|
||
IPv6 bearer request is refused when the attach PDN was granted IPv4-only;
|
||
a profile-indexed request is not.
|
||
- **pw-record delivers 20 ms frames in bursts** — of two on an AMR-WB
|
||
call (1.8 frames per burst on average, the bursts ~37 ms apart; the dev
|
||
phone, 2026-10-15/16: of the uplink's inter-packet gaps 42–45 % are
|
||
under 4 ms and 50–52 % are 30–40 ms, 3–8 % lie between and under 1 %
|
||
above — the fp6 journal's `2026-10-16-dtmf-bench-14/uplink-cadence.txt`
|
||
over benches 4, 5, 13 and 14, counted by the `cadence.py` beside it),
|
||
of three or four on a narrowband one (3.3 on average, ~68 ms apart;
|
||
70 % under 4 ms, 28 % over 40 ms — `2026-10-16-dtmf-bench-17-heard/uplink-cadence-narrowband.txt`,
|
||
bench 17's two calls; the burst sizes of all six legs in `burst-sizes.txt`
|
||
beside it). A sender on a clock of its own cannot count the frames a
|
||
140 ms window holds, so the events ride the frames' own slots (§7.6),
|
||
and an event's packets leave in those bursts: the audio's own spacing,
|
||
which RFC 4733 §2.5.1.2 calls the natural interval for event updates
|
||
(its 50 ms recommendation is for a spacing of the sender's own).
|
||
- **DTMF on KPN (2026-10-14 to 16):** the answer to our offer echoes
|
||
telephone-event at our payload types — 98 at 16 kHz on an AMR-WB call to
|
||
voicemail, 100 at 8 kHz on a phone-to-phone call the network answered
|
||
narrowband AMR at 99 — and a stock phone's terminating INVITE offers
|
||
AMR-WB 107 with telephone-event 111; events of the sender's first shape
|
||
(100 ms, a packet every 20 ms, at least 100 ms apart) were heard on that
|
||
phone (bench 2 the first shape; bench 17 the one-sender shape — 28 keys
|
||
on two narrowband calls, every one heard there). On
|
||
its own AMR-WB calls to us (telephone-event 111 at 16 kHz) that phone
|
||
sends one event of 20 packets per key press (340 ms, -10 dBm0, an update
|
||
every 20 ms, the end packet three times), its audio resuming one to eight
|
||
slots past the event's end and the event preceded by a DTX gap of up to
|
||
seven slots (the fp6 journal's benches 2 to 4 and bench 10's incoming
|
||
call, their `far-end-events-*` files); on a call we placed that the
|
||
network answered narrowband (telephone-event 100 at 8 kHz) its two key
|
||
presses arrived as events of 22 and 19 packets (400 and 340 ms), the
|
||
audio resuming 15.8 and 19 slots (316 and 380 ms) past their ends, the
|
||
first off the stream's 20 ms timestamp grid (bench 10's outgoing call) —
|
||
whether that shape is the phone's or the network's interworking,
|
||
nothing on disk says.
|
||
- **A packet imsd sends on the ims PDN can wake a phone that has gone
|
||
back to sleep, up to twice** (the dev phone, KPN, a mainline-based 7.3
|
||
kernel with the fp6 journal's power lane's test patches;
|
||
`2026-11-20-modem-echo-wakes` there). The bearer comes
|
||
up for it and goes dormant 11 to 13 s later, which the modem reports to
|
||
ModemManager (WDS event reports), and 90 s after the dormancy the modem
|
||
makes a file-system request to rmtfs (what it reads or writes there is
|
||
not known). Each can wake a phone that has
|
||
gone back to sleep; a ModemManager patched to switch those reports off
|
||
for the sleep (on the dev phone since 2026-11-20, not in the fp6 image)
|
||
keeps the first back. Under the CRLF keepalive of imsd up to 1.2.3, one
|
||
every 30 s of a clock that stops in a suspend, the modem ended 29
|
||
sleeps of 29 in a loop of suspends with a 150-s alarm, 15 with the
|
||
report and 14 with that request, and 5 of 8 with the reports off; with imsd
|
||
held still, none of 6 (2026-11-20). Without the ping (two builds of 1.2.4's
|
||
change, §5), with the reports off, the same loop ran twice with no
|
||
packet on the ims netdev: the modem ended none of six sleeps in one
|
||
and one of seven in the other, for a file-system request that no
|
||
packet had preceded (2026-11-24). What an idle phone with a standing
|
||
registration still sends is the refresh, once in 1800 s on KPN, awake or,
|
||
where imsd has its wake alarm, asleep (§7.10; three packets out, the
|
||
dormancy report 11 to 13 s and
|
||
the request 102 to 104 s after them), and what its reg-event
|
||
subscription needs (§7.4): on KPN a renewal once in 599400 s (the grant
|
||
of 600000 s less 600). Awake and idle
|
||
on a 100-mA USB port the dev phone's battery lost 140 mA under 1.2.3's
|
||
ping and 59 mA without it (its own counter over one window of 40 min
|
||
and one of 33; 2026-11-24).
|
||
- **KPN's P-CSCF leaves a flow open that carries nothing**: 44 min 9 s
|
||
lay between a registration's last packet and the refresh, which it
|
||
answered on that flow (the dev phone, 2026-11-24, six suspends in
|
||
between). Where a network's P-CSCF closes or forgets a flow it hears
|
||
nothing on, `CRLF_KEEPALIVE` is that network's setting (§7.2 step 5
|
||
has what imsd does without it).
|
||
- **A registration counted in awake seconds lapsed on a phone that
|
||
slept most of its two hours** (the dev phone, KPN, imsd 1.1.0,
|
||
2026-11-19; the fp6
|
||
journal's power lane, `2026-11-19-wake-tests`): registered at 09:15:48
|
||
with a lifetime of 7200 s, the phone in a loop of suspends from 09:26
|
||
to 11:22, no refresh
|
||
went out; the network's NOTIFY that the binding had expired woke the
|
||
phone at 11:16:37, the fresh registration met the throttle above, and
|
||
the phone registered again at 11:37:38.
|
||
- **The kernel refuses a suspend under an alarm timer less than two
|
||
seconds ahead** (`alarmtimer_suspend`, `kernel/time/alarmtimer.c`,
|
||
read at v7.3: -EBUSY, and a wakeup event of two seconds, where an
|
||
RTC stands behind the alarm timer; without one it lets the suspend
|
||
pass). The check is in the suspend's device phase, after the kernel
|
||
has synced and frozen the processes: an alarm that has fired by then
|
||
is off the queue and refuses nothing. On the dev
|
||
phone (2026-11-25 and 2026-11-28), `systemctl suspend -i` under a call
|
||
or a text in flight: logind let it through, the kernel refused it,
|
||
systemd-sleep tried the next state of its list and was refused again,
|
||
and the phone did not suspend; each refused attempt has its line in
|
||
the kernel's log, `alarmtimer alarmtimer.0.auto: PM: failed to
|
||
suspend: error -16` (six of six in the boot of 2026-11-28 13:22).
|
||
- **A timer on an alarm clock made with `timerfd_create` and set with no
|
||
interval fires once**
|
||
(read at v7.3: `alarmtimer_fired`, `kernel/time/alarmtimer.c`, takes
|
||
the alarm off the kernel's queue and restarts nothing;
|
||
`timerfd_alarmproc`, `fs/timerfd.c`, marks the timer expired, counts
|
||
a tick and wakes whoever waits on the descriptor; an interval would
|
||
be applied only when the timer is next accessed, by a read or by
|
||
`timerfd_gettime`). imsd sets no interval and neither reads nor
|
||
queries its timer: after it has fired there is no alarm of imsd's
|
||
until the next `timerfd_settime`, which is why a wait sets it every
|
||
second (§7.10).
|
||
- **A suspend's freeze ends a datagram receive that has a timeout with
|
||
`EINTR`**
|
||
(read at v7.3: `freeze_task`, `kernel/freezer.c`, wakes a user thread
|
||
that it cannot freeze where it sleeps as a pending signal would; a
|
||
datagram receive sleeps interruptibly and not freezably and leaves
|
||
with `sock_intr_errno`, `net/core/datagram.c` and
|
||
`include/net/sock.h`, which under a finite `SO_RCVTIMEO` is `-EINTR`,
|
||
and that the kernel does not take up again as it does an interrupted
|
||
`poll`). On the dev phone (2026-11-28) a test program's `recvfrom`
|
||
under a timeout returned `EINTR` at the resume from a suspend, in
|
||
pieces of a second and in one long wait alike (the fp6 journal's
|
||
`2026-11-25-through-sleep` capture, `evidence/recv-eintr/`). A stop
|
||
and a continue (`SIGSTOP`, `SIGCONT`) end such a receive the same
|
||
way, which is how the bench stages it (§5). The daemon's wait for a
|
||
fresh registration's first answer is such a receive
|
||
(`AwaitInitialFinal`).
|
||
- **logind refused a block inhibitor for sleep where it was asked for
|
||
during a suspend's operation**
|
||
(systemd 262.2, the dev phone, 2026-11-25 and 2026-11-28): `Inhibit`
|
||
for `sleep` in `block` mode was answered
|
||
`org.freedesktop.login1.OperationInProgress` (`The operation
|
||
inhibition has been requested for is already running`) in a sleep hook
|
||
before the suspend, in one after it, and to imsd 0.1 to 0.3 s after
|
||
systemd-sleep's `System returned from sleep operation`;
|
||
logind's `Operation 'suspend' finished` came 0.03 s after that line
|
||
where the run's sleep hook did nothing after the resume, 0.1 s after
|
||
it where the hook made three bus calls then, and 2.1 s after it where
|
||
it also waited two seconds; a lock asked for after it was given.
|
||
- **pmOS's default nftables** drops inbound on `qmapmux*`; without the
|
||
protected-port rule every network-initiated request (NOTIFY, MT
|
||
INVITE) dies after ESP decapsulation and MT calls fall back to CS. The
|
||
ESP packet passes the same chain before it is decapsulated, and
|
||
without a rule for it the chain accepts it only as an answer to a
|
||
packet the phone sent (`ct state established`): the connection tracker
|
||
has no tracker for ESP, and its generic one keeps the entry for
|
||
`nf_conntrack_generic_timeout` seconds after the last packet either
|
||
way, 600 on the dev phone. A request the network starts later than
|
||
that after the phone's last ESP packet is then dropped, and its
|
||
retransmissions until the phone next sends to that P-CSCF. Until 1.2.3
|
||
imsd's CRLF keepalive every 30 s kept the entry (over TCP and outside
|
||
a call only; since 1.2.4 none goes out unless `CRLF_KEEPALIVE` names
|
||
an interval, §7.2 step 5); the bring-up script's rule for ESP (§7.3,
|
||
1.2.4) makes the entry needless. Shown on the workstation with the dev
|
||
phone's ruleset, and on the dev phone for a text with the tracker's
|
||
timeout at 0 (§5). A firewall without an `inet filter` table with an
|
||
`input` chain gets no rule from the script and needs its own. And the
|
||
script's rules are in the running ruleset only: a reload of the
|
||
ruleset from its files (the nftables unit's `flush ruleset`, and the
|
||
one in `/etc/nftables.nft`) removes them until imsd next starts, so a
|
||
ruleset whose files carry the port rules (fp6-img's `01_imsd.nft`) has
|
||
to carry the rule for ESP in them too.
|
||
- **The kernel's temporary SLAAC address** on the ims netdev is listed first
|
||
and retired after about two days; a registration bound to it dies with it.
|
||
- **systemd reads `EnvironmentFile=` per spawned command** (systemd 262~rc3
|
||
on the FP6, 2026-10-03: an `ExecStart` saw what its `ExecStartPre` had
|
||
just written), and unquotes a quoted value — which is why the hand-over script
|
||
takes `LOCAL` from its environment rather than parsing the files itself.
|
||
- **GNOME Calls 50.0** crashes after an oFono origin withdraw/re-add cycle
|
||
and dials nothing after `org.ofono` restarts until it restarts itself.
|
||
- **dbus-broker** checks broadcasts against the sender's send policy for
|
||
every name the receiver owns (the `org.ofono.conf` detail).
|
||
- **The phone's wall clock reads 1970 until the first NTP sync**; anything
|
||
that ages a journal line uses the monotonic or boot clock.
|
||
- **KPN's EF_SMSP** (the dev phone's SIM, 2026-10-16): one record of 43
|
||
octets, no alpha identifier, parameter indicators 0xED (TP-SCA and TP-VP
|
||
present), TS-Service-Centre-Address `07 91 13 56 13 13 13 F3` =
|
||
+31653131313, TP-VP 0xA9 (3 days). What KPN's IP-SM-GW does with it: the 2026-10-17 bench bullet below.
|
||
- **A WDS client bound to the bearer's mux data port, with IP family 6 set,
|
||
reads the call's runtime settings; one that sent neither the binding nor Set IP Family got
|
||
`OutOfCall`.** ModemManager owns the ims
|
||
bearer's call and never asks the modem for the P-CSCF fields; a second
|
||
client that does Bind Mux Data Port (the netdev's `rmnet mux_id`, endpoint
|
||
embedded/1 for the `ipa` driver — ModemManager's own binding), Set IP
|
||
Family 6 and Get Current Settings gets them: TLV 0x22 = 1, the IPv6 list
|
||
in TLV 0x2E (two addresses on KPN), no IPv4 list, an empty FQDN list. Get Current Settings from a client that sent neither
|
||
Bind Mux Data Port nor Set IP Family answered `OutOfCall` (the control run),
|
||
as did a client bound to a mux with no call (`--mux 7`). The bearer stayed
|
||
connected and the registration stood afterwards (dev phone,
|
||
2026-10-11; the fp6 journal's `2026-10-11-pcscf-pco-probe` capture).
|
||
libqmi does not model 0x2E and qmicli cannot print any of it, hence
|
||
`imsd-pcscf`.
|
||
|
||
- **KPN, SMS over IP (dev phone, KPN eSIM, 2026-10-17 bench — fp6 journal
|
||
`captures/2026-10-17-sms-over-ip-bench/`).** That night the modem was
|
||
CS-detached (NAS: CS detached, LTE domain ps, voice support no, no 2G/3G
|
||
service);
|
||
on 2026-08-18 the same subscription had a NAS SMS path (the MO/MT NAS
|
||
proof) — whether the network or the phone's attach type decides it is
|
||
unmeasured. Submissions: MESSAGE to the EF_SMSP service centre's PSI → 202 within
|
||
a second (79–241 ms over seven MESSAGEs of 2026-10-17 — six submissions,
|
||
one in two segments — by the journal's microsecond stamps,
|
||
`r23-phone-journal-2026-10-17-precise-and-modem-sms`); the one RP-ACK
|
||
submit report whose dump the capture keeps (`mo-loop-test-submit-report-in`) is a
|
||
MESSAGE (From tag `smsavipsmsc03.app.gen.local-…`,
|
||
P-Asserted-Identity +316530850013) with
|
||
`In-Reply-To` and `Accept-Contact: *;+g.3gpp.smsip;require;explicit`, over
|
||
UDP from the P-CSCF to the protected server port. Deliveries: a MESSAGE whose From tag and
|
||
Call-ID begin `smsavipsmsc04.app.gen.local` (P-Asserted-Identity +316530850014),
|
||
`Request-Disposition: no-fork`, the RP-DATA's originator the sending
|
||
subscriber's service centre (+31624000000 for the A16 on Odido, the sender
|
||
of every text delivered on 2026-10-17 but AUTHMSG's, via +31626000230;
|
||
EF_SMSP's +31653131313 for a text from the phone's own KPN number,
|
||
2026-10-18 01:37 and 02:18); our RP-ACK delivery report
|
||
MESSAGE is answered 202 (one of the 01:23 pair was refused 488, §5). One text sent before the tag was advertised and
|
||
four sent after the 00:45:10 registration with it arrived in one burst at
|
||
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.
|
||
- **Cards with an ISIM** (the fp6 journal's read-only probe on two
|
||
reporters' phones; the dev phone's card has none). A US card on AT&T's
|
||
network (operator name "Dark Star", SIM operator 310 280; 2026-11-23) and
|
||
a Norwegian one (Ice, 242 14; 2026-11-21) each list a USIM `ready` and
|
||
an ISIM `detected` in one slot of the Fairphone 6. On both a logical
|
||
channel opened on the ISIM's AID in that state and the probe read
|
||
EF_IMPI, EF_DOMAIN and EF_IMPU's record 1: it sends SELECT by file
|
||
identifier with P2 `04` and takes a `61 XX` for the file selected, sends
|
||
READ BINARY and READ RECORD with Le `00` and follows a `61 XX` or a
|
||
`6C XX` to those (which it got on the way it does not print), and cuts
|
||
`FF` bytes from the end of a value. The US card holds names of the
|
||
operator's own in all three
|
||
(the private identity `<IMSI>@private.att.net`, the home domain
|
||
`one.att.net`, the public identity `sip:<IMSI>@one.att.net`) and has no
|
||
EF_P-CSCF and no EF_IST (`6A 82` to their SELECT); the Norwegian card
|
||
holds the names TS 23.003 derives from the IMSI, an EF_P-CSCF of three
|
||
unused records and an EF_IST of seven zero bytes. On the dev phone's
|
||
USIM (a KPN eSIM, 2026-11-21, by hand) that SELECT answered `61 19` for
|
||
one file and `61 1C` for another, the
|
||
two reads data and `90 00` at once, and the SELECT of a file the
|
||
application does not have `6A 82`. The US card's network answered imsd
|
||
1.1.0's first REGISTER, which carried the derived names
|
||
(`ims.mnc280.mcc310.3gppnetwork.org`), `480 Temporarily Unavailable`
|
||
(2026-11-09: a journal has the answer in the second the REGISTER was
|
||
sent, a dump of such an answer has no Reason, Warning or Retry-After) —
|
||
what TS 24.229 5.3.1.3 has an I-CSCF answer
|
||
when the HSS lookup "cannot be completed". Under the card's own names
|
||
imsd registered on that network (the reporter's phone, 2026-11-25, imsd
|
||
1.2.4 by the reporter's word; the fp6 journal's `2026-12-01-min-se-retry`
|
||
capture): the `identity:` line with the three names above; a
|
||
`Security-Server` of one `ipsec-3gpp` mechanism (`hmac-sha-1-96`,
|
||
`aes-cbc`) to the two-cipher offer; `REGISTERED (fresh)` in the second
|
||
after `FRESH registration`, and no `AKA:` line; a 200 without a
|
||
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` (§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
|
||
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).
|