imsd, engine, ImsdBus, packaging, README: SMS over IP behind SMS_OVER_IMS=1, net.catcrafts.IMS1.Messaging

With the modem's own IMS client off, a carrier that carries SMS over IMS
only leaves the phone no path for texts but imsd; on one with SMS over
NAS the +g.3gpp.smsip 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 off by default: SMS_OVER_IMS=1
advertises the tag (Context::smsOverIp), reads the service centre from
EF_SMSP record 1 at bring-up — SMSC= instead — and opens Send on a
second interface, net.catcrafts.IMS1.Messaging, beside the frozen one,
gated by a polkit action of its own (Gated's Action parameter; the Voice
action's callers are unchanged). The shell keeps one message in flight
on the flow and queues the rest, routes the in-flight MESSAGE's final
to it (OnSmsResponse; a submit report reaches it through OnSmsMessage),
seeds and advances the TP-MR, RP-MR and concatenation counters, answers an inbound
MESSAGE outside a call through OnSmsMessage (one inside the call's
dialog stays the CallMachine's, and is not the MESSAGE of any sentence
below) — the message to the bus as
Received, the delivery report on the flow with its final logged, a
status report matched by TP-MR and recipient to the message that asked
for one — and reports a message's fate as StateChanged. A Send is judged
when the engine takes its command up: unregistered or with the flow down
then, it fails with that reason.
The journal names a delivered message's sender, size and time — a text
reaches it only as the body of a MESSAGE whose Content-Type does not
contain application/vnd.3gpp.sms or as the hex of a body that is no RP
message or of an unusable TPDU; DUMP_SIP adds the two MESSAGE dumps.

While the knob is off a network may deliver a short message over IP
regardless; answering it 200 and acknowledging it would count it
delivered to nobody, so it is refused with 480 Temporarily Unavailable,
which lets the IP-SM-GW try the modem's path where the network has one
(TS 24.341 5.3.3.4.2 NOTE 2); a MESSAGE outside a call's dialog whose
Content-Type does not contain application/vnd.3gpp.sms (letter case
ignored) is still answered 200 and logged with its body — the 200 in
BuildResponse's shape now, the line with the content type. A
retransmitted MESSAGE — the same
Call-ID, CSeq and Via branch (the value of the first `branch=` of its
first Via line; a MESSAGE with none or an empty one is never taken for a
copy) within 32 s of our final, in the same run of the daemon — is
answered again and not handled again (the engine's RecentTransactions, a
table in memory), where a repeated RP-DATA would otherwise,
with SMS over IP on, be handled again: a second delivery report where
the first got one and, of a text in one segment, a second text.

The Messaging signals carry a text's content, and a D-Bus broadcast
reaches every account the bus policy lets receive from imsd — which
polkit cannot narrow — so they are never broadcast: Subscribe, behind the
same action as Send, records the caller's unique name, and Received and
StateChanged go unicast to each subscriber (the submission's sent or
failed also to the Send caller), which the bus delivers to those
connections — root's busctl monitor sees them as well. A subscription
ends with its connection; a consumer
subscribes at start and again when imsd's name reappears. GetStatus
answers `enabled` from the daemon's configuration, not from the
registration snapshot, so an asker before the first registration reads
the truth.

A message's id holds the run's token, eight hex digits drawn from
std::random_device at the daemon's start, ahead of a second and a
count: `ims-sms-<run>-<start>-<N>` for
a sent text, with the start second and a counter, and
`ims-sms-in-<run>-<epoch>-<N>` for a received one, with its second. A
counter starts over with the daemon, and the phone's wall clock reads
1970 until the first time sync, so a second repeats across runs: the
token is what tells one run's ids from another's, and a client keys by id
(RunToken, SentSmsId and ReceivedSmsId, pinned by tests/Engine).

Tested on the dev phone on KPN (2026-10-17; the fp6 journal's
2026-10-17-sms-over-ip-bench capture) on sms-branch builds ahead of this
history (195e91b, then c57765a with the retransmission absorption): the
tag on a resumed and on a fresh registration, Sends to 202 and their
submit reports in one and two segments and in UCS-2, texts received in
one and two segments and in UCS-2, every delivery report answered 202
but one of the two for the 01:23 text, refused 488 on the build before
the absorption, and a same-second retransmission absorbed under c57765a
(01:44) — AGENTS.md §5 has the record and §13 the network facts,
among them that the modem was CS-detached that night. On the host's
session bus in dev mode:
two Sends answered with ids and failed "imsd is not registered"
(2026-10-16), and three connections — a subscriber, a match-rule-only
listener, an unsubscribed sender — where only the subscriber and the
sender heard the StateChanged and the subscription ended with its
connection (2026-10-17); with the knob off, GetStatus's `enabled` false,
Send refused NotSupported and Subscribe answered (a private session bus,
this commit's host build, 2026-11-19; its sha256 begins 98e30a9522409d99).
The SMSC= override ran on 2026-10-18 from 02:17
(smsc-override-2026-10-18-0217):
the EF_SMSP number as an override and a Send through it to sent, and
SMSC=abc stopped at bring-up with "is not a number" (ForNumber dials
digits, * and # only; the bench's first run, on a build outside this
history that dialled the BCD table's a, b and c, submitted with them and
got an RP-ERROR back, RP cause 28).

A status report is matched to the message that asked for one by its TP-MR
and the recipient's number — among this run's messages: the book is in
memory — and the message gets a word for the whole (StatusReportBook,
pinned), by TS 23.040 9.2.3.15's classes of TP-ST: delivery-failed at the
first report in which the SC is not making any more transfer attempts (a
permanent error or a temporary one; a reserved value too, read as
"Service Rejected" as the clause has the MS read it), delivered when the
last of its segments is reported in the completed class (the SC's word
in the reason) — never a later segment's word over an earlier failure.
The next TP-MR is kept in
<state dir>/sms-tpmr across restarts, so the TP-MRs continue instead of
starting over at random: a reuse needs a full 256-segment wrap, not a
restart (a report can be days late) — as long as the file's last write
reached the disk: it is neither checked nor synced.

One message's StateChanged words come in the order they mean, which is
not the order imsd learns them: the service centre can deliver and report
on segment 1 while segment 2 is still on its way. SmsWordOrder
(Imsd:Engine, pure) gives the order §8.4 states: the submission's word
first — `sent`, or `failed`, after which nothing follows — and a
report's only after `sent`. A report's word on the message in flight is
held until the submission ends (the latest word; one message is in
flight at a time) and posted after `sent`. A submission that fails after
the centre reported every segment delivered posts `sent`, the failure in
its reason, and then `delivered`. A `failed` otherwise drops the held
word and StatusReportBook::ForgetMessage forgets the message's TP-MRs, so
a later report on a part that went matches nothing and is logged.
tests/Engine pins the book's forgetting and each of these orders.

BuildResponse (the messages commit) is the final of the inbound MESSAGE
path from here on — the 200, the 480 and the 488; BuildResponse200's hop-by-hop
shape stays for the other answers that had it.

The reassembler's 30-minute age-out is judged in the run loop beside the
SMS deadline, whether or not another MESSAGE ever comes.

The MESSAGE's target is the service centre's own international number
(ScPsi), not RuriFor's dialled-number guess, whose trunk-0 rule is
Dutch: a national SMSC= of nine or more characters starting with 0 would
have become a +31 number, a 00-prefixed one +<the rest>, any other
non-international value a phone-context URI at the home domain; a service
centre ScPsi makes nothing of (national, 00-prefixed, or a '*' or '#'
among the digits, which ForNumber dials) is refused at bring-up on that same
predicate with a journal line, never announced, and Send then fails
with no service centre.

A failed submission's StateChanged reason can hold the network's text (a
refused final's, RefusalSummary); a D-Bus string must be valid UTF-8, so
the emission makes it so (g_utf8_make_valid: bytes that are not become
U+FFFD, and a NUL byte ends the string).
This commit is contained in:
Jorijn van der Graaf 2026-10-16 23:30:25 +02:00
commit aa3c394041
Signed by: jorijnvdgraaf
GPG key ID: 2937E59CDCC1BCFB
11 changed files with 1269 additions and 78 deletions

475
AGENTS.md
View file

@ -18,7 +18,9 @@ firmware on such phones brings up the IMS PDN but cannot carry call audio, so
imsd does the whole IMS client itself: SIP registration with USIM AKA
authentication over kernel IPsec (ESP), call signalling for outgoing and
incoming calls, and the RTP media plane (AMR-WB, AMR, G.711) wired into
PipeWire. A stock mobile dialer — Plasma Dialer, or GNOME Calls under Phosh
PipeWire, and since 1.2.0 short messages over IMS (TS 24.341: the SIP MESSAGE
carrying an RP-DATA, 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.
@ -44,10 +46,10 @@ PipeWire. The verified device/carrier combinations are in the README.
| `interfaces/Imsd-Sms.cppm` | `imsd::sms` — the short message codecs SMS over IP rides on (TS 24.341 carries the bytes a 2G/3G phone puts in an RP-DATA, in a SIP MESSAGE body): the GSM 7-bit default alphabet with its extension table and the septet packing, UCS-2 (TS 23.038); the SM-TL PDUs (TS 23.040: SMS-SUBMIT built, one per segment with the concatenation header when the text needs more than one; SMS-DELIVER, SMS-STATUS-REPORT and SMS-SUBMIT-REPORT parsed; the SMS-DELIVER-REPORT that acknowledges a delivery; the user-data header — concatenation, application ports — and the `Reassembler` of a concatenated message); the SM-RL messages (TS 24.011: RP-DATA, RP-ACK, RP-ERROR in both directions, the cause values); EF_SMSP (TS 31.102 §4.2.27), where the (U)SIM names the service centre, and qmicli's hex dump of it. Byte-level only: no SIP, no clock, no I/O. |
| `interfaces/Imsd-Aka.cppm` | `imsd::aka` — USIM AKA glue: the AKAv1-MD5 digest (RFC 3310), IMPI/IMPU/realm from IMSI + MCC/MNC, parsers for `qmicli --uim-get-card-status` and `mmcli` output, the AUTHENTICATE APDU and its response. |
| `interfaces/Imsd-Ipsec.cppm` | `imsd::ipsec` — the two ESP SA pairs (TS 33.203) as `ip xfrm` argv lists, the Security-Server mechanism selection, and the reader that reconstructs SPIs/ports from `ip xfrm state`/`policy` text for a warm resume, and (1.0.0) `SaPeer`, the P-CSCF the kernel's pair is to, read from the `dir out` policies that carry imsd's fingerprint, `OwnXfrmDeleteCommands`, the deletes by exact key of what two rules select — the policies carrying imsd's fingerprint and the reqid-1/2 transport-mode ESP states in their direction or on the UE's ims-PDN address, whoever installed them (§12), and `FileNamesAnotherPair`, whether a state file's `spi_uc`/`spi_us` name the kernel's pair (unknown on either side decides nothing). |
| `interfaces/Imsd-Messages.cppm` | `imsd::msg` — every SIP request and response imsd sends, built from an explicit `Context` and per-request variables so the builders are pure functions; `tests/Messages` is their suite, which calls every builder but `BuildInviteResponse` (`tests/Engine` checks the responses `CallMachine` builds with it). 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 `OnSmsMessage` builds for the MESSAGE it is handed (the 200, the 488): each `Via:` line echoed in order (the text layer reads long header names only, not RFC 3261 7.3.3's compact forms) and the To echoed with a tag added unless it already holds `tag=` (RFC 3261 8.2.6.2); 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 (TS 24.341): `SmsOutbound` (one short message of ours on its way to the service centre, segment by segment, returning `SmsAction`s) and `OnSmsMessage` (what an inbound MESSAGE outside a call's dialog leads to: its final, the message or status report it delivered, the delivery report to send), and `RecentTransactions` (the final remembered for an inbound request by Call-ID, CSeq and Via branch — the value of the first `branch=` of its first `Via:` line; nothing is remembered for a request with none or an empty one — for 32 s (`TimerJ`), for a caller to answer a retransmission with it and not handle it again). |
| `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, which calls every builder but `BuildInviteResponse` (`tests/Engine` checks the responses `CallMachine` builds with it). 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:` line echoed in order (the text layer reads long header names only, not RFC 3261 7.3.3's compact forms) and the To echoed with a tag added unless it already holds `tag=` (RFC 3261 8.2.6.2); 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 (TS 24.341): `SmsOutbound` (one short message of ours on its way to the service centre, segment by segment, returning `SmsAction`s) and `OnSmsMessage` (what an inbound MESSAGE outside a call's dialog leads to: its final, the message or status report it delivered, the delivery report to send), and `RecentTransactions` (an inbound request's retransmission — the same Call-ID, CSeq and Via branch within 32 s (`TimerJ`), the branch being the value of the first `branch=` of its first `Via:` line and a request with none or an empty one never matched — answered with the same final and not handled again); `SameRecipient` and `StatusReportBook`, a status report's match to the message that asked for one — TP-MR and recipient — and its word for the whole message, with `SmsWordOrder`, the order of a message's words: the submission's first, a report's held until then (§7.9); `RunToken`, `SentSmsId` and `ReceivedSmsId`, the ids (§8.4). |
| `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, shared by imsd and imsd-ofonod. GLib, so outside `imsd-core`. |
| `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. |
@ -60,7 +62,8 @@ PipeWire. The verified device/carrier combinations are in the README.
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.
the subscriber's IMSI/MSISDN and network addresses — and, of SMS over IP's
state, `sms-tpmr*` (the next TP-MR).
## 3. Build products
@ -71,7 +74,7 @@ in every source but the re-exporting `Imsd.cppm`, clang + libc++ + lld.
|---|---|---|---|---|
| `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`) 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-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`. |
@ -82,7 +85,7 @@ 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 0.3.10, 0.3.11, 0.3.12 or 1.0.0: the P-CSCF in
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
@ -135,7 +138,27 @@ 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.
`Imsd:Engine` is the holds file's. 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, 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, is theirs), and the report's match to the message
that asked for one `SameRecipient`
and `StatusReportBook`, all with tests.
## 4. Building
@ -341,12 +364,30 @@ What the suites pin:
ended; ours once its segment was superseded), 200 for one without
In-Reply-To for no message, an unusable TPDU acknowledged with an
RP-ERROR, a body that is no RP message, a page-mode text 200'd and
logged;
logged, a short message while SMS over IP is off refused with 480;
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;
and `RecentTransactions`: a retransmitted request gets its final again,
for 32 s (`TimerJ`); no branch, no match.
@ -535,6 +576,84 @@ Rules:
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, the RP-ACK delivery report sent and answered 202); 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 was
handled twice, two delivery reports, one of them refused 488, which is where the retransmission
absorption (`RecentTransactions`) came from; 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 (SC time stamp 01:40:26, the whole logged at 01:40:28: 240 bytes of
text in 2 segments, `journal-0133-mo-benches-and-0140-mt-concat`); 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, a one-character UCS-2 text arrived at 01:44 (3 bytes of text,
`journal-0144-checkmark-and-absorbed-retransmission`); that one-character text's MESSAGE
retransmitted (01:44:24) and absorbed: answered again, not handled again
— 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`): a refused final to a submission's MESSAGE, an RP-ERROR this
code sends (the cause-96 unusable-TPDU path; 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 and the report's
running out, 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 (the 488) or one without
In-Reply-To for no message in flight (the 200), a page-mode MESSAGE, a
body that is no RP message, a delivery that names no gateway, 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). 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
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).
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).
- `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,
@ -609,10 +728,14 @@ Beyond the rules:
`/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` (`packaging/net.catcrafts.IMS1.policy`, shaped like
`net.catcrafts.IMS1.Voice`, sending a short message over IP and subscribing
to the message signals `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`) stay open, as ModemManager's are to every local account: the call
`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 signal.
@ -621,7 +744,8 @@ 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 status snapshot live (main thread only). The Messaging interface's
`Subscribe` keeps its subscriber set on the main thread as well (§7.9).
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
@ -690,7 +814,9 @@ The daemon's own bring-up (`BringUp()` in `main.cpp`):
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. `mmcli --location-get` fills
the IMPI/IMPU/realm are derived; 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
@ -1020,8 +1146,10 @@ 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; the
keepalive refresh gate, the CRLF keepalive and the reg-event retry and
renewal timers run on the steady clock and count awake seconds only.
keepalive refresh gate, the CRLF keepalive, the reg-event retry and
renewal timers and the times SMS over IP measures (§7.9: its two waits,
the 30-minute age-out, the retransmission table's 32 s) run on the steady
clock and count awake seconds only.
The **reg-event subscription** (RFC 3680; the network's own view of the
binding) is one live dialog per registration, subscribed anew ahead of the
@ -1230,6 +1358,7 @@ account `user`, its old default.
| `/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) |
| `$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
@ -1326,7 +1455,62 @@ Lines the operator (and the scripts) look for, all prefixed `imsd: `:
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`, 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 32 s`, `no submit report for segment i/n within
40 s of the final`, `segment i/n not sent: the flow to the P-CSCF is
down`) 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)`, `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|RP-ERROR) In-Reply-To …: no MESSAGE of ours in flight; 488`,
`submit report (…, RP-MR n) for no message in flight; 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.
- `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
@ -1349,6 +1533,166 @@ Y` (the configured address or the first discovered), `wrote
/run/imsd.env: DEV=… LOCAL=… PCSCF_DISCOVERED=… PCSCF_DISCOVERY=…` —,
`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). Every header of a MESSAGE
is read by its long name, on one line with the colon straight after the
name: a compact form (RFC 3261 7.3.3) is not seen, so
a `c:` line is no `Content-Type`, an `i:` line no Call-ID and a `v:` line
no `Via`; nor is a name with white space before its colon, and of a value
folded onto further lines the first is read (7.3.1 allows both).
- **A retransmitted MESSAGE** (the same Call-ID, CSeq and Via branch — the
value of the first `branch=` of its first `Via:` line; 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 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. One message on the
flow at a time, segment by segment: the MESSAGE with the
RP-DATA, its final within 32 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 40 s of a 2xx final (a length TS 24.011
10.1 allows TR1M, which 6.3.1 sets when the RP-DATA is transferred); then the
next segment. Every
segment's RP-ACK: `sent`, with the SC's time stamp when its submit
report carries one; a refused final, an RP-ERROR (its cause and the
submit report's TP-FCS), a wait that runs out or a flow that is down:
`failed` with the reason; a wait is judged at the run loop's passes,
after the server ports are read, so an answer read before that counts
however late. No retransmission (9.2.3.6's repeat with
TP-RD is not done): the sender retries. 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), 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)
and handed to the bus whole as
`Received`; each segment
is 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 no MESSAGE of ours in flight is answered 488 — one that
is not ours (5.3.1.2), or ours once the message has ended (its report's wait run out, judged by
the shell; a failure; sent) or its segment was superseded by the next, which
gets the same answer; one without In-Reply-To for no message in flight,
200. Nothing is stored: a message that reaches the bus while no app
listens is in the journal (sender, size, time — never the text) and
nowhere else but `DUMP_SIP`'s raw dump of the last MESSAGE. Class 2 messages are not written to the (U)SIM; RP-SMMA
(memory available) is never sent; nothing 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 handed over like any text, its `pid` (0x40) the
consumer's to act on, a Replace Short Message type replaces nothing and
a (U)SIM data download is not passed to the card; a class 0 message is
handed over 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` and `Subscribe` 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: a messaging app has to speak this one.
## 8. D-Bus ABI and desktop integration
### 8.1 `net.catcrafts.IMS1` (frozen)
@ -1374,7 +1718,9 @@ new translation daemon, not a change here.
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`.
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`)
@ -1465,6 +1811,42 @@ sandbox: §4.1):
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. 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), `registered` (b), `subscribers` (u) |
| `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 |
| `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, `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) |
`Send` and `Subscribe` 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
@ -1561,7 +1943,7 @@ documentation: the tables are in the README.
### 10.1 imsd
The README's first table. The protected client/server ports are fixed at
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
@ -1580,8 +1962,9 @@ resume.
### 10.2 imsd-media (per call, set through imsd's environment)
The README's second table. These are not configuration and are left out
there:
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 |
|---|---|---|
@ -1636,11 +2019,14 @@ only the imsd side of its bus choice.
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.
## 12. Security considerations
- imsd runs as root (xfrm, qmicli). Its attack surface on the bus is the
frozen ABI; the writes are polkit-gated (§7.1, §8.1). Do not add an
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). 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
@ -1677,6 +2063,24 @@ only the imsd side of its bus choice.
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.
- 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.
`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
@ -1774,6 +2178,10 @@ the related code.
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
@ -1788,3 +2196,30 @@ the related code.
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.