sms, engine: a class 2 message is refused, not acknowledged, unless it is a short message type 0

OnSmsMessage acknowledged every SMS-DELIVER it could parse with an
RP-ACK and handed it to the bus, whatever its class. For a class 2
message the acknowledgement said more than was done: 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 TS
23.040 9.2.3.9 has a (U)SIM data download — TP-PID 0x7F with a class 2
coding — passed to the (U)SIM. imsd writes nothing to the card, so the
network had an acknowledgement for something that had not happened
(issue #4).

imsd has no way to the card for such a message yet. TS 23.038 4 names
the answer of an MS that cannot store a class 2 message in the (U)SIM
while other storage is free, "protocol error, unspecified", and excepts
only a download on an MS that supports the (U)SIM Application Toolkit,
which imsd does not. The delivery report of a class 2 message, a
segment of a set included, is now an RP-ERROR with that cause, 111, and
the TP-FCS 0xFF, unspecified error cause; 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) with a class 2 coding is
no part of this: 9.2.3.9 has it received "irrespective of whether there
is memory available in the (U)SIM or ME or not". TP-PID 0x7F without a
class 2 coding stays a message like any other, and so do classes 0, 1
and 3.

What this changes for a consumer: no `Received` comes for a refused
class 2 message, a text of that class among them, which 1.2.0 stored
and handed over (Jorijn, 2026-11-21: the refusal is kept). The
interface's members, keys and words are as they were.

Still open of issue #4: the way to the card itself — TS 31.111 7.1.1's
ENVELOPE (SMS-PP DOWNLOAD) for a download, an EF_SMS record for any
other class 2 message — and with it an acknowledgement made from the
card's answer. Read from the dev phone for it (the fp6 journal's
2026-11-20-issues-2-5 capture, phone): the KPN USIM's service table
lists 28 (data download via SMS-PP) and 10 (short message storage),
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, and qmicli has
the APDU route AKA takes and no toolkit command. Whether the modem lets
an ENVELOPE through that route has not been tried.

Tested by tests/Engine. On the dev phone the daemon, the binary of this
range's last commit, refused five class 2 deliveries that the phone sent
to its own protected server port — answered 200, the journal's line,
nothing stored, and no report, since they named no gateway — and took
six deliveries from KPN as before (the capture's phone-form6).
This commit is contained in:
Jorijn van der Graaf 2026-11-22 17:35:13 +01:00
commit d6d7ba100a
Signed by: jorijnvdgraaf
GPG key ID: 2937E59CDCC1BCFB
5 changed files with 126 additions and 19 deletions

View file

@ -69,11 +69,11 @@ session and root may place, answer and end calls; an ssh login may not.
Off unless `SMS_OVER_IMS=1` is set in `/etc/imsd.env`. On, imsd sends texts
over the IMS registration it already holds, through the SIM's service
centre or the one `SMSC` names, and receives texts the network delivers over IMS;
centre or the one `SMSC` names, and receives texts over IMS;
its store for received texts is `/var/lib/imsd/sms`, and a text in it stays
until a messaging app deletes it. Apps that read ModemManager, such as Spacebar and
Chatty, do not see texts that arrive this way; `imsd-messages`, the app built
for imsd's `net.catcrafts.IMS1.Messaging` interface, shows them. The details are
Chatty, do not see texts that arrive this way; `imsd-messages` is the app built
for imsd's `net.catcrafts.IMS1.Messaging` interface. The details are
in AGENTS.md: the behaviour and the store in §7.9, the interface in §8.4,
what was verified on which network in §5.