sms: the short message codecs of TS 23.038, 23.040 and 24.011, and EF_SMSP

SMS over IP (TS 24.341) carries the bytes a 2G/3G phone puts in an
RP-DATA inside a SIP MESSAGE body of type application/vnd.3gpp.sms, so
imsd needs the whole stack below SIP once it owns SMS on a carrier whose
modem IMS is off: the GSM 7-bit default alphabet with its extension table
and the septet packing, UCS-2 for everything else (TS 23.038); SMS-SUBMIT
built per segment with the concatenation header, SMS-DELIVER,
SMS-STATUS-REPORT and SMS-SUBMIT-REPORT parsed, the SMS-DELIVER-REPORT
that acknowledges a delivery, the user-data header and the reassembly of
a concatenated message (TS 23.040); RP-DATA, RP-ACK and RP-ERROR in both
directions with their causes (TS 24.011); and EF_SMSP, where the (U)SIM
names the service centre the RP-DATA is addressed to (TS 31.102 4.2.27,
the KPN SIM's record read on the dev phone on 2026-10-16: +31653131313).

A new partition, Imsd:Sms, pure std with no SIP, clock or I/O; tests/Sms
checks it against the classic
public PDU vectors ("hellohello", the "How are you?" SMS-DELIVER) and
vectors cross-generated by an independent Python reference.

A concatenated set with one alphabet throughout is decoded from its
segments' joined units — the septets, or the UTF-16BE octets — not from
the segments' texts, so a surrogate pair or an escape pair a sender cut
at a segment boundary comes out whole; a U+0000 in UCS-2 decodes as
U+FFFD, since no text means it and a D-Bus string cannot carry it.

A status report's TP-ST is read as TS 23.040 9.2.3.15 has the MS read it:
a reserved value, any with bit 7 set among them, as "Service Rejected" —
a temporary error after which the SC is not making any more transfer
attempts (StatusAsRead, pinned over all 256 values; StatusText has the
clause's four classes in words). Three more readings follow their
clauses the same way, each pinned: a time stamp semi-octet that is no
digit reads as 0 (9.2.3.11); `1111` before an address's last semi-octet
is skipped, not taken for its end (9.1.2.3); an SMS-SUBMIT-REPORT for
RP-ERROR with an unused bit of its first octet set gives TP-FCS 0xFF,
unspecified, with nothing else examined (9.2.2.2a).
This commit is contained in:
Jorijn van der Graaf 2026-10-16 23:11:24 +02:00
commit c88de31a0a
Signed by: jorijnvdgraaf
GPG key ID: 2937E59CDCC1BCFB
5 changed files with 1474 additions and 9 deletions

View file

@ -158,7 +158,7 @@ extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> a
}
// imsd-core — the engine as a static library of pure C++ modules (SIP,
// SDP, later AKA/IPsec/media/engine). Deliberately GLib-free so every
// SDP, SMS, AKA/IPsec/QMI/engine). Deliberately GLib-free so every
// piece is unit-testable without a bus or a phone.
static auto Core = std::make_unique<Configuration>();
Core->path = "./";
@ -167,7 +167,7 @@ extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> a
ApplyStandardArgs(*Core, args);
Core->type = ConfigurationType::LibraryStatic;
{
std::array<fs::path, 9> ifaces = {
std::array<fs::path, 10> ifaces = {
"interfaces/Imsd",
"interfaces/Imsd-Util",
"interfaces/Imsd-Aka",
@ -175,6 +175,7 @@ extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> a
"interfaces/Imsd-Qmi",
"interfaces/Imsd-Sip",
"interfaces/Imsd-Sdp",
"interfaces/Imsd-Sms",
"interfaces/Imsd-Messages",
"interfaces/Imsd-Engine",
};
@ -226,6 +227,7 @@ extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> a
cfg.AddTest("Engine").Dependencies({ Core.get() });
cfg.AddTest("Sip").Dependencies({ Core.get() });
cfg.AddTest("Sdp").Dependencies({ Core.get() });
cfg.AddTest("Sms").Dependencies({ Core.get() });
LintRules::AddRules(cfg);