From 02887b50e7d0041a15ee9594897b58f99db9da5b Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Tue, 3 Nov 2026 06:32:25 -0647 Subject: [PATCH 1/9] omamobile-modem-sit: whole WAP pushes for MMS, and the internet bearer's address for the bridge An MMS notification is a WAP push, often in several parts, and only the first part carries the WAP port. Stored parts now keep their port (old partial records are migrated), and a joined binary message is delivered as data only when its port is the WAP push one; any other is replaced by a short notice. The codec keeps a binary part without a port when it's one of a concatenated set. sitd's status for authorised clients now carries the internet bearer's device (the one omamobile-sit-data found), address and DNS, so the bridge can give mmsd-tng the bearer it fetches MMS over where the MMS APN is the internet APN. state.json doesn't carry them; the bridge's Ip4Config, like ModemManager's, is readable on the system bus. (cherry picked from commit 35d7a1e418336260c75907f30af05336e53c4ee4) --- packages/omamobile-modem-sit/lib/service.py | 36 +++++++++++- packages/omamobile-modem-sit/lib/sms_codec.py | 2 +- .../omamobile-modem-sit/test/test_service.py | 56 +++++++++++++++++++ 3 files changed, 90 insertions(+), 4 deletions(-) diff --git a/packages/omamobile-modem-sit/lib/service.py b/packages/omamobile-modem-sit/lib/service.py index cacfc0508..ad2582e4b 100644 --- a/packages/omamobile-modem-sit/lib/service.py +++ b/packages/omamobile-modem-sit/lib/service.py @@ -46,6 +46,7 @@ from calls import call_status, dial_payload, ring import data_call from data_call import paths as bearer_paths +from data_network import configuration as internet_addresses from ims import REGISTRATION, record_registration from inbox import persist_sms from sit import Sit, ModemError @@ -92,6 +93,24 @@ def signal_percent(rsrp): SUBSCRIBERS = 8 +def internet_config(): + """The internet bearer's device, address and the carrier's DNS, for the + bridge's copy of the bearer (MMS goes over it where the MMS APN is the + internet APN). The device is the one omamobile-sit-data found carrying + it; none recorded means the data network isn't up yet. It goes in the + status for authorised clients only, not in state.json; the bridge then + publishes it in the bearer's Ip4Config, which, as ModemManager's, any + client on the system bus can read.""" + try: + address, dns = internet_addresses(bearer_paths(data_call.INTERNET_CID)[1].read_bytes()) + interface = (paths.RUN / 'data-interface').read_text().strip() + except (OSError, ValueError): + return {} + if not interface: + return {} + return dict(interface=interface, address=address, dns=dns) + + class UnconfirmedRelease(RuntimeError): """Fatal call ownership failure; never turn this into a socket reply.""" @@ -163,6 +182,11 @@ def database(path): for table in ('received', 'parts'): if 'data' not in {c[1] for c in db.execute(f'PRAGMA table_info({table})')}: db.execute(f"ALTER TABLE {table} ADD COLUMN data TEXT NOT NULL DEFAULT ''") + if 'port' not in {c[1] for c in db.execute('PRAGMA table_info(parts)')}: + db.execute('ALTER TABLE parts ADD COLUMN port INTEGER') + # Before this migration, only recognised WAP fragments had Data. + # Preserve a first fragment received before upgrading the daemon. + db.execute("UPDATE parts SET port=2948 WHERE data<>''") # A request interrupted by a process restart must never be retried blindly. db.execute("UPDATE outgoing SET state='unknown', error='Delivery uncertain after service restart; check with the recipient' WHERE state='sending'") db.commit() @@ -330,17 +354,22 @@ def ingest(self, path): return concat = sms.pop('concat') data = sms.pop('data').hex() - sms.pop('port') + port = sms.pop('port') if concat: ref, total, seq = concat - self.db.execute('INSERT OR IGNORE INTO parts(id,sender,reference,total,seq,text,timestamp,received,data) VALUES (?,?,?,?,?,?,?,?,?)', - (key, sms['number'], ref, total, seq, sms['text'], sms['timestamp'], time.time(), data)) + self.db.execute('INSERT OR IGNORE INTO parts(id,sender,reference,total,seq,text,timestamp,received,data,port) VALUES (?,?,?,?,?,?,?,?,?,?)', + (key, sms['number'], ref, total, seq, sms['text'], sms['timestamp'], time.time(), data, port)) parts = self.db.execute('SELECT * FROM parts WHERE sender=? AND reference=? AND total=? AND received>? ORDER BY received', (sms['number'], ref, total, time.time()-86400)).fetchall() by_seq = {p['seq']: p for p in parts} if len(by_seq) == total: sms['text'] = ''.join(by_seq[i]['text'] for i in range(1, total+1)) data = ''.join(by_seq[i]['data'] for i in range(1, total+1)) + # Only the first fragment of a WAP push carries the port. + ports = {p['port'] for p in by_seq.values() if p['port'] is not None} + if data and ports != {2948}: + data = '' + sms['text'] = 'Received an unsupported binary message.' sms['timestamp'] = by_seq[1]['timestamp'] self.db.execute('INSERT OR IGNORE INTO received(id,number,text,timestamp,data) VALUES (?,?,?,?,?)', (key, sms['number'], sms['text'], sms['timestamp'], data)) @@ -579,6 +608,7 @@ def status(self, *, public=False): return dict(modem=modem, calls=calls, sms=dict(unread=unread), updated=int(time.time())) received = [r[0] for r in self.db.execute('SELECT id FROM received WHERE consumed=0 ORDER BY rowid')] return dict(modem=modem, calls=calls, sms=dict(received=['sit:' + i for i in received]), + internet=internet_config() if data else {}, audio=dict(available=True, running=self.audio is not None, mute=self.muted, speaker=getattr(self.audio, 'tegu', False) is True, speaker_available=False, error=self.audio_error)) diff --git a/packages/omamobile-modem-sit/lib/sms_codec.py b/packages/omamobile-modem-sit/lib/sms_codec.py index 054d97dcc..effab0141 100644 --- a/packages/omamobile-modem-sit/lib/sms_codec.py +++ b/packages/omamobile-modem-sit/lib/sms_codec.py @@ -125,7 +125,7 @@ def bcd(x): return (x&15)*10+(x>>4) elif alphabet==2: if length>len(data) or lengthlen(data) or length Date: Tue, 3 Nov 2026 06:33:30 -0647 Subject: [PATCH 2/9] omamobile-mmd: the internet bearer's device, address and DNS for mmsd-tng mmsd-tng fetches MMS over a ModemManager bearer whose APN is the MMS APN, binds to its Interface and resolves the MMSC through the DNS in its Ip4Config. Where the MMS APN is the internet APN, that's the internet bearer, so the bridge now gives it the device omamobile-sit-data found (rmnet0 until sitd knows) and, while data is up, its address and the carrier's DNS from sitd's status. (cherry picked from commit 7b2622dfef30f11e675e1536fc74f722563a8ddc) --- packages/omamobile-mmd/lib/bridge.py | 21 +++++++++++++++++++-- packages/omamobile-mmd/test/test_bridge.py | 20 ++++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/packages/omamobile-mmd/lib/bridge.py b/packages/omamobile-mmd/lib/bridge.py index b02e80f3a..949ff5e08 100644 --- a/packages/omamobile-mmd/lib/bridge.py +++ b/packages/omamobile-mmd/lib/bridge.py @@ -189,7 +189,8 @@ def update_modem(self, d): if d['data'] and not self.bearer: self.create_bearer(d) if self.bearer: - self.x.set(self.bearer, mm.BEARER, Connected=d['data']) + self.x.set(self.bearer, mm.BEARER, Connected=d['data'], Interface=self.internet_interface(), + Ip4Config=self.internet_ipv4(d)) for name in d['interfaces']: if not self.x.has(self.modem, name): self.x.add_interface(self.modem, name, self.interface_props(name, d)) @@ -285,11 +286,27 @@ def sim_dynamic(self, d): OperatorIdentifier=d['plmn'] if d['home'] else '', OperatorName=d['operator_name'] if d['home'] else '') + def internet_interface(self): + # The device omamobile-sit-data found carrying the internet bearer, + # which isn't always rmnet; rmnet0 until sitd knows. + return ((self.status or {}).get('internet') or {}).get('interface') or 'rmnet0' + + def internet_ipv4(self, d): + # The address and the carrier's DNS, as MM gives them: mmsd-tng + # resolves the MMSC through these where MMS goes over this bearer. + net = (self.status or {}).get('internet') or {} + if not d['data'] or not net.get('address'): + return {} + return {'method': GLib.Variant('u', 2), 'address': GLib.Variant('s', net['address']), + 'prefix': GLib.Variant('u', 32), + **{'dns' + str(i): GLib.Variant('s', value) for i, value in enumerate(net.get('dns', [])[:3], 1)}} + def create_bearer(self, d): self.bearer = self.path('Bearer') apn, ip_type = self.apn_settings() self.x.add(self.bearer, {mm.BEARER: dict( - Interface='rmnet0', Connected=d['data'], IpTimeout=20, BearerType=mm.BEARER_DEFAULT, + Interface=self.internet_interface(), Connected=d['data'], Ip4Config=self.internet_ipv4(d), + IpTimeout=20, BearerType=mm.BEARER_DEFAULT, ProfileId=-1, Properties={'apn': GLib.Variant('s', apn), 'ip-type': GLib.Variant('u', IP_TYPES.get(ip_type, mm.IP_V4V6))})}, self.handle_bearer) diff --git a/packages/omamobile-mmd/test/test_bridge.py b/packages/omamobile-mmd/test/test_bridge.py index 23d5917f1..0e33c3b7e 100644 --- a/packages/omamobile-mmd/test/test_bridge.py +++ b/packages/omamobile-mmd/test/test_bridge.py @@ -771,5 +771,25 @@ def test_denied_and_allowed(self): self.assertEqual(self.sitd.actions(), [], 'nothing reached sitd without authorisation') +class InternetBearer(BridgeTests): + """The internet bearer's device, address and DNS from sitd, which + mmsd-tng fetches MMS through where the MMS APN is the internet APN.""" + status = staticmethod(lambda: registered_status(data=True)) + + def before_mmd(self): + self.sitd.status['internet'] = dict(interface='rmnet5', address='192.0.2.7', + dns=['192.0.2.53', '192.0.2.54']) + + def test_the_found_device_address_and_dns(self): + bearer = self.client.call(MODEM0, mm.MODEM, 'ListBearers')[0][0] + self.assertEqual(self.client.prop(bearer, mm.BEARER, 'Interface'), 'rmnet5') + self.assertEqual(self.client.prop(bearer, mm.BEARER, 'Ip4Config'), + dict(method=2, address='192.0.2.7', prefix=32, dns1='192.0.2.53', dns2='192.0.2.54')) + self.sitd.status['modem']['data'] = False + self.push() + wait_until(lambda: not self.client.prop(bearer, mm.BEARER, 'Connected'), 5, 'bearer down') + self.assertEqual(self.client.prop(bearer, mm.BEARER, 'Ip4Config'), {}) + + if __name__ == '__main__': unittest.main() From 9aee17151279ed8a1a2227d14261ffffe7443cb0 Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Mon, 2 Nov 2026 20:02:52 -0647 Subject: [PATCH 3/9] mmsd-tng 2.6.4: package the MMS daemon, and plan MMS over the internet bearer mmsd-tng 2.6.4 for aarch64 from upstream's tag, with four small patches (the own number when ModemManager exports none, a socket closed on a failed interface bind, modern libphonenumber linkage) and meson test in check(). Nothing is enabled and no carrier settings ship; the example config is the owner's to fill in. TELEPHONY-APPS-PLAN 1.7 now says what's ready for MMS on the 9a, where the MMS APN is the internet APN and MMS goes over the internet bearer, and gives an attended runbook, receive first. (cherry picked from commit 876e4071362d633231367f383f7541d84b7be018) --- docs/TELEPHONY-APPS-PLAN.md | 20 ++++++-- ...igured-number-with-empty-own-numbers.patch | 16 ++++++ ...ose-socket-on-interface-bind-failure.patch | 17 +++++++ ...k-modern-libphonenumber-dependencies.patch | 25 ++++++++++ ...tional-own-number-with-redacted-IMSI.patch | 42 ++++++++++++++++ packages/mmsd-tng/PKGBUILD | 49 +++++++++++++++++++ packages/mmsd-tng/README.md | 49 +++++++++++++++++++ packages/mmsd-tng/config/mms.example | 16 ++++++ packages/mmsd-tng/systemd/mmsd-tng.service | 12 +++++ packages/mmsd-tng/test/all | 27 ++++++++++ 10 files changed, 270 insertions(+), 3 deletions(-) create mode 100644 packages/mmsd-tng/0001-use-configured-number-with-empty-own-numbers.patch create mode 100644 packages/mmsd-tng/0002-close-socket-on-interface-bind-failure.patch create mode 100644 packages/mmsd-tng/0004-link-modern-libphonenumber-dependencies.patch create mode 100644 packages/mmsd-tng/0005-accept-international-own-number-with-redacted-IMSI.patch create mode 100644 packages/mmsd-tng/PKGBUILD create mode 100644 packages/mmsd-tng/README.md create mode 100644 packages/mmsd-tng/config/mms.example create mode 100644 packages/mmsd-tng/systemd/mmsd-tng.service create mode 100755 packages/mmsd-tng/test/all diff --git a/docs/TELEPHONY-APPS-PLAN.md b/docs/TELEPHONY-APPS-PLAN.md index 1e4011606..02a456d54 100644 --- a/docs/TELEPHONY-APPS-PLAN.md +++ b/docs/TELEPHONY-APPS-PLAN.md @@ -163,13 +163,27 @@ Today `omamobile-sit-data` puts `rmnet0` behind Wi-Fi with metric 700, and Netwo | Need | How | Ready? | | --- | --- | --- | -| WAP push (the MMS notification) arrives as a binary SMS | sitd passes the PDU's user data through; the bridge exports an `Sms` with `Data` set and `Text` empty, which mmsd-tng picks up | No: the codec keeps the bytes but nothing passes them on (T0, T3) | -| An APN that carries MMS | mmsd-tng's `MMS_APN` must match the connected bearer's APN. mmsd-tng supports no separate MMS bearer ("limitations of Modem Manager", its README), so the carrier must allow MMS on the internet APN. Many US carriers do; check ours (Q8) | Our config has one APN (`[network] apn`) | +| WAP push (the MMS notification) arrives as a binary SMS | sitd passes the PDU's user data through; the bridge exports an `Sms` with `Data` set and `Text` empty, which mmsd-tng picks up | Yes for the 9a's stack (#380): sitd keeps each part's WAP port and delivers a joined push as data; the bridge exports it with `Data` | +| An APN that carries MMS | mmsd-tng's `MMS_APN` must match the connected bearer's APN. mmsd-tng supports no separate MMS bearer ("limitations of Modem Manager", its README), so the carrier must allow MMS on the internet APN. Many US carriers do; check ours (Q8) | On the palmtop's carrier the MMS APN is the internet APN. A second bearer on it took the IMS bearer down (2026-11-02), so sitd sets up none | | Fetch from the MMSC over mobile data, even with Wi-Fi up | mmsd-tng binds HTTP to the bearer's interface (`SO_BINDTODEVICE`, `src/service.c:3720-3732`) and resolves through that interface's DNS (c-ares or systemd-resolved with the ifindex). Needs `CarrierMMSC`, `CarrierMMSProxy`, or `http://mms.invalid` to look them up in mobile-broadband-provider-info | **Depends on M4.3:** rmnet0 is configured IPv4 only (MODEM-CLIENT §1.3). If the carrier's bearer is IPv6-only (common on T-Mobile's network [I]), MMS needs IPv6 on rmnet0 first. The packet processor (MODEM-PLAN 6.3) is built but untested on hardware; the legacy buffers carry data meanwhile | | Sending MMS | mmsd-tng posts the M-Send.req to the MMSC the same way | as above | -| Storage and UI | mmsd-tng stores messages and serves `org.ofono.mms` on the session bus; Chatty and our app are its clients | install `mmsd-tng` (T3) | +| Storage and UI | mmsd-tng stores messages and serves `org.ofono.mms` on the session bus; Chatty and our app are its clients | `packages/mmsd-tng` (2.6.4, #380), not enabled; Messages' side is in the omatel apps (T3) | | Group MMS | MMS with several recipients; mmsd-tng handles the PDUs | with the above | +**The bearer for mmsd-tng (#380):** sitd reports the internet bearer's device (the one omamobile-sit-data found), address and DNS in its private status, and the bridge publishes them on the bearer (`Interface`, `Ip4Config`). mmsd-tng binds to that device and resolves the MMSC through those servers, so MMS goes over cellular with Wi-Fi up, without touching the system's routes or DNS. + +**Attended runbook, receive first (9a, not yet run):** + +| Step / risk | Commands or action | Expect / pass | Stop condition | Rollback | +| --- | --- | --- | --- | --- | +| 1. Read-only / none | `uname -r`; `pacman -Q omamobile-modem-sit omamobile-mmd mmsd-tng`; `omamobile-sit status`; `busctl --system get-property org.freedesktop.ModemManager1 org.freedesktop.ModemManager1.Bearer Interface Ip4Config` | Registered with data; the bearer's Interface is the found device and Ip4Config has an address and DNS | No address or DNS, no data | None | +| 2. Settings / low | As the session user, `~/.mms/modemmanager/mms` (mode 0600) from `/usr/share/mmsd-tng/mms.example`: the carrier's MMSC, the APN (the internet APN), the proxy or `NULL`, the palmtop's number; `ForceCAres=true` | A private file, nothing started | Credentials or an IPv6-only MMS bearer needed | Remove the file | +| 3. Daemon / low | `systemctl --user start mmsd-tng.service` (never `-d`) | `org.ofono.mms` on the session bus | Startup errors | `systemctl --user stop mmsd-tng.service` | +| 4. Receive / medium | The owner sends one small picture to the palmtop, Wi-Fi up | One WAP push, one downloaded message in mmsd-tng's store, calls and texts unchanged | A download or routing failure, a second WAP consumer | Stop the daemon; keep its store | +| 5. Send / medium (after the apps' T3 changes) | One small picture from Messages to the owner | One copy received | An uncertain send: don't press Send again | Stop the daemon | + +Never publish the MMSC, the APN, numbers, message URLs, WAP bytes or attachments, or mmsd-tng's debug output. + **What our data path still lacks for MMS** (MODEM-PLAN 6.3 and MODEM-CLIENT §1.3): M4.3 passing on the phone, IPv6 on `rmnet0` (or proof that the carrier gives IPv4), and the bearer exported as a Bearer object. Throughput isn't an issue for MMS (messages are a few hundred kB), so the packet processor isn't a prerequisite. ### 1.8 Requirements against MODEM-PLAN diff --git a/packages/mmsd-tng/0001-use-configured-number-with-empty-own-numbers.patch b/packages/mmsd-tng/0001-use-configured-number-with-empty-own-numbers.patch new file mode 100644 index 000000000..ec66b5c36 --- /dev/null +++ b/packages/mmsd-tng/0001-use-configured-number-with-empty-own-numbers.patch @@ -0,0 +1,16 @@ +From: W4HO <87742609+W4HO-ham@users.noreply.github.com> +Subject: [PATCH] MMS: apply the configured number when OwnNumbers is empty + +--- a/plugins/modemmanager.c ++++ b/plugins/modemmanager.c +@@ -1761,6 +1761,10 @@ + } + } + ++ /* An empty OwnNumbers array never enters the loop above. */ ++ if (!modem->modem_number_known && modem->modem_number) ++ mms_service_set_own_number (modem->service, modem->modem_number); ++ + gdbus_modem = MM_GDBUS_MODEM (modem->modem); + + modem->modem_state_watch_id = g_signal_connect (gdbus_modem, diff --git a/packages/mmsd-tng/0002-close-socket-on-interface-bind-failure.patch b/packages/mmsd-tng/0002-close-socket-on-interface-bind-failure.patch new file mode 100644 index 000000000..25532cb99 --- /dev/null +++ b/packages/mmsd-tng/0002-close-socket-on-interface-bind-failure.patch @@ -0,0 +1,17 @@ +From: W4HO <87742609+W4HO-ham@users.noreply.github.com> +Subject: [PATCH] MMS: fail closed if the bearer interface cannot be bound + +--- a/src/service.c ++++ b/src/service.c +@@ -3735,7 +3735,10 @@ + if (return_code == 0) + DBG ("Socket is bound to %s", request->service->interface); + else +- DBG ("Socket could not be bound! Error: %d", return_code); ++ { ++ g_warning ("MMS interface binding failed; closing socket"); ++ g_socket_close (msg_socket, NULL); ++ } + + g_signal_handler_disconnect (msg, + request->soupmessage_network_event_signal_id); diff --git a/packages/mmsd-tng/0004-link-modern-libphonenumber-dependencies.patch b/packages/mmsd-tng/0004-link-modern-libphonenumber-dependencies.patch new file mode 100644 index 000000000..181f41e38 --- /dev/null +++ b/packages/mmsd-tng/0004-link-modern-libphonenumber-dependencies.patch @@ -0,0 +1,25 @@ +From: W4HO <87742609+W4HO-ham@users.noreply.github.com> +Subject: [PATCH] build: link dependencies used by modern libphonenumber headers + +--- a/meson.build ++++ b/meson.build +@@ -119,6 +119,8 @@ + dependency('libsoup-3.0'), + dependency('libcares', version : '>=1.18.1'), + cc.find_library('dl'), ++ dependency('protobuf'), ++ dependency('absl_absl_check'), + cc.find_library('phonenumber', required: true) + ] + +--- a/unit/meson.build ++++ b/unit/meson.build +@@ -3,6 +3,8 @@ + dependency('mm-glib', version : '>=1.14'), + dependency('libcares', version : '>1.17'), + cc.find_library('dl'), ++ dependency('protobuf'), ++ dependency('absl_absl_check'), + cc.find_library('phonenumber', required: true) + ] + diff --git a/packages/mmsd-tng/0005-accept-international-own-number-with-redacted-IMSI.patch b/packages/mmsd-tng/0005-accept-international-own-number-with-redacted-IMSI.patch new file mode 100644 index 000000000..c00183f3b --- /dev/null +++ b/packages/mmsd-tng/0005-accept-international-own-number-with-redacted-IMSI.patch @@ -0,0 +1,42 @@ +From: W4HO <87742609+W4HO-ham@users.noreply.github.com> +Subject: [PATCH] MMS: accept an international own number with a redacted IMSI + +--- a/src/service.c ++++ b/src/service.c +@@ -3159,6 +3159,10 @@ + g_warning ("mms_service_set_own_number(): Number is NULL!"); + return FALSE; + } ++ /* A redacted IMSI supplies no region. An international own number ++ * can still be parsed without guessing a country for national numbers. */ ++ if (service->country_code == NULL && own_number[0] == '+') ++ service->country_code = g_strdup ("ZZ"); + if (service->country_code == NULL) + { + g_warning ("Country Code is NULL!"); +--- a/unit/test-phone-utils.c ++++ b/unit/test-phone-utils.c +@@ -113,6 +113,15 @@ + g_assert_cmpstr (output, ==, carrer_vvm_test3); + } + ++static void ++international_number_without_imsi (void) ++{ ++ g_autofree char *number = phone_utils_format_number_e164 ("+12025550123", "ZZ", FALSE); ++ g_autofree char *national = phone_utils_format_number_e164 ("2025550123", "ZZ", FALSE); ++ g_assert_cmpstr (number, ==, "+12025550123"); ++ g_assert_null (national); ++} ++ + int + main (int argc, + char **argv) +@@ -123,5 +132,7 @@ + NULL, test_number_decode); + + ++ g_test_add_func ("/mmsutil/international-number-without-imsi", ++ international_number_without_imsi); + return g_test_run (); + } diff --git a/packages/mmsd-tng/PKGBUILD b/packages/mmsd-tng/PKGBUILD new file mode 100644 index 000000000..60ad178ae --- /dev/null +++ b/packages/mmsd-tng/PKGBUILD @@ -0,0 +1,49 @@ +# SPDX-License-Identifier: MIT +# Maintainer: W4HO <87742609+W4HO-ham@users.noreply.github.com> +pkgname=mmsd-tng +pkgver=2.6.4 +pkgrel=1 +pkgdesc="MMS daemon using ModemManager, with an opt-in user service" +arch=(aarch64) +url="https://gitlab.com/kop316/mmsd" +license=('GPL-2.0-only') +depends=(c-ares mobile-broadband-provider-info 'libmm-glib>=1.24' libsoup3 libphonenumber glib2 glibc gcc-libs protobuf abseil-cpp) +makedepends=(meson ninja pkgconf) +provides=(mmsd) +conflicts=(mmsd mmsd-tng-git) +options=('!lto') +source=("$pkgname-$pkgver.tar.gz::$url/-/archive/$pkgver/mmsd-$pkgver.tar.gz" + '0001-use-configured-number-with-empty-own-numbers.patch' + '0002-close-socket-on-interface-bind-failure.patch' + '0004-link-modern-libphonenumber-dependencies.patch' + '0005-accept-international-own-number-with-redacted-IMSI.patch') +sha256sums=('5772d4d1830664404d8f6ed96d9c35f6e7a53c60b1ac5571cd2a6183c7e633ed' + '2bddbd5812356656162920a8cf145a69a529f6e33a2109633de6b508aee99d8e' + '4c0a0997edfb936c50807459c51b97b55be6a404faf51bbcf7c993faf5041add' + '9875223ed387fc778d05e1624237fc94732822a09f9e847c52ce8be26a427008' + '6f1aedf09714b94415a608e591aefaa72e7539823b580ac493ce19022a5c7896') + +prepare() { + cd "mmsd-$pkgver" + patch -Np1 -i "$srcdir/0001-use-configured-number-with-empty-own-numbers.patch" + patch -Np1 -i "$srcdir/0002-close-socket-on-interface-bind-failure.patch" + patch -Np1 -i "$srcdir/0004-link-modern-libphonenumber-dependencies.patch" + patch -Np1 -i "$srcdir/0005-accept-international-own-number-with-redacted-IMSI.patch" +} + +build() { + arch-meson "mmsd-$pkgver" build -Dbuild-mmsctl=false + meson compile -C build +} + +check() { + meson test -C build --print-errorlogs + "$startdir/test/all" +} + +package() { + DESTDIR="$pkgdir" meson install -C build + install -Dm644 "$startdir/systemd/mmsd-tng.service" "$pkgdir/usr/lib/systemd/user/mmsd-tng.service" + install -Dm644 "$startdir/config/mms.example" "$pkgdir/usr/share/mmsd-tng/mms.example" + install -Dm644 "$startdir/README.md" "$pkgdir/usr/share/doc/mmsd-tng/README.md" +} diff --git a/packages/mmsd-tng/README.md b/packages/mmsd-tng/README.md new file mode 100644 index 000000000..ef0511313 --- /dev/null +++ b/packages/mmsd-tng/README.md @@ -0,0 +1,49 @@ + +# mmsd-tng + +An opt-in, per-user MMS daemon using ModemManager's D-Bus API. It never +starts the modem or sitd. This package alone does not enable picture +messages in Messages: omatel-agent and omamessages need their T3 changes +in their own repositories. See `docs/TELEPHONY-APPS-PLAN.md` section 1.7b. + +The AUR has `mmsd-tng-git`, advertising 2.5.0.r0.g6529119-1 in its cached +package metadata while building upstream HEAD. Neither Arch's exact-name +search nor Arch Linux ARM's aarch64 core/extra indexes contained mmsd-tng +when checked on 2026-11-03. This recipe uses upstream's stable 2.6.4 tag +and the AUR runtime dependency set, with a checked source checksum and a +single Meson build directory. Modern libphonenumber headers additionally +need explicit protobuf and Abseil linkage. + +Sources: [AUR recipe](https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=mmsd-tng-git), +[upstream 2.6.4](https://gitlab.com/kop316/mmsd/-/tree/2.6.4), +[Arch Linux ARM package indexes](https://de3.mirror.archlinuxarm.org/aarch64/extra/). +Upstream is GPL-2.0; its LGPL components retain their notices. Patches use +the corresponding upstream file's license. + +The patches apply the configured own number when MM's OwnNumbers array is +empty, including E.164 parsing without an IMSI-derived region; close HTTP +sockets on interface-binding failure; and link the dependencies required by +current libphonenumber. + +mmsd-tng fetches MMS over a connected bearer whose APN is its `MMS_APN`, +bound to that bearer's device and resolving through the DNS in its +`Ip4Config`. On the 9a that's the internet bearer, where the carrier's MMS +APN is the internet APN: omamobile-mmd gives it the device sitd's data +network found and the carrier's DNS (see docs/TELEPHONY-APPS-PLAN.md 1.7). +Nothing is set up just for MMS, and the system's routes and DNS aren't +touched. A carrier with a separate MMS APN isn't supported yet. + +Owner configuration, before the first start: copy +`/usr/share/mmsd-tng/mms.example` to `~/.mms/modemmanager/mms` (mode 0600) +as the same session user as omatel-agent, and replace ``, `` (the +internet APN) and ``. Keep `ForceCAres=true` so DNS goes to the +bearer's servers. Set the MMS proxy to the carrier's `host:port`, or `NULL` +when there's none. Then `systemctl --user start mmsd-tng.service`. + +No unit is enabled or D-Bus activated by this package. No carrier settings +are shipped. Do not enable upstream debug logging on the phone: it can +print numbers, message URLs, settings and message content. Never publish +its journal, settings, message store, WAP bytes or attachments. + +IPv4 only for now (including an IPv4v6 bearer's IPv4 address and DNS); +IPv6-only MMS, modem suspend and carrier acceptance need attended runs. diff --git a/packages/mmsd-tng/config/mms.example b/packages/mmsd-tng/config/mms.example new file mode 100644 index 000000000..e7a22ed6a --- /dev/null +++ b/packages/mmsd-tng/config/mms.example @@ -0,0 +1,16 @@ +# SPDX-License-Identifier: MIT +# Copy to ~/.mms/modemmanager/mms with mode 0600, before starting mmsd-tng. +# Replace placeholders privately. The APN is the internet APN ([network] apn). +[Modem Manager] +CarrierMMSC= +MMS_APN= +# NULL means no proxy. Otherwise use the carrier's host:port, without a URL scheme. +CarrierMMSProxy=NULL +# Fill in your own phone number; omamobile-mmd deliberately exports no OwnNumbers. +ModemNumber= +AutoProcessOnConnection=true +AutoProcessSMSWAP=true + +[Settings] +# Use only the bearer's DNS and interface, without changing system DNS. +ForceCAres=true diff --git a/packages/mmsd-tng/systemd/mmsd-tng.service b/packages/mmsd-tng/systemd/mmsd-tng.service new file mode 100644 index 000000000..9e52fd558 --- /dev/null +++ b/packages/mmsd-tng/systemd/mmsd-tng.service @@ -0,0 +1,12 @@ +# SPDX-License-Identifier: MIT +[Unit] +Description=MMS transport for the current user +After=dbus.service + +[Service] +ExecStart=/usr/bin/mmsdtng +Restart=no +UMask=0077 + +[Install] +WantedBy=default.target diff --git a/packages/mmsd-tng/test/all b/packages/mmsd-tng/test/all new file mode 100755 index 000000000..fe6cd60d3 --- /dev/null +++ b/packages/mmsd-tng/test/all @@ -0,0 +1,27 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT +set -euo pipefail +cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." +bash -n PKGBUILD +python3 - <<'PY' +import configparser +import hashlib +from pathlib import Path +import re +text = Path('PKGBUILD').read_text() +assert 'arch=(aarch64)' in text +assert 'meson test -C build --print-errorlogs' in text +assert 'arch-meson "mmsd-$pkgver" build' in text +assert 'SKIP' not in text +for path in Path('.').glob('*.patch'): + assert hashlib.sha256(path.read_bytes()).hexdigest() in text, path +unit = Path('systemd/mmsd-tng.service').read_text() +assert 'ExecStart=/usr/bin/mmsdtng\n' in unit and 'Restart=no' in unit +assert not re.search(r'^(Requires|Wants|BindsTo|ExecStartPre|ExecStartPost)=', unit, re.M) +config = configparser.ConfigParser(interpolation=None) +config.read('config/mms.example') +assert config['Modem Manager']['CarrierMMSC'] == '' +assert config['Modem Manager']['MMS_APN'] == '' +assert config['Settings'].getboolean('ForceCAres') +print('ok - pinned source, patches, aarch64 recipe and opt-in configuration') +PY From 621a265109c0cac3fe6d8129fa8e1bc2e69de49a Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Tue, 3 Nov 2026 08:28:07 -0647 Subject: [PATCH 4/9] omamobile-mmd: bearer IP configs always carry a method, and the first MMS received mmsd-tng logged "Couldn't create IP config from dictionary: 'method not given'" for the bearer's empty Ip6Config. An empty config is now method 0 (unknown), as libmm-glib expects. TELEPHONY-APPS-PLAN records the first picture received on the palmtop over the internet bearer. (cherry picked from commit 388eed891acdd4fd4512c675258624bfa298ee4c) --- docs/TELEPHONY-APPS-PLAN.md | 4 +++- packages/omamobile-mmd/lib/bridge.py | 10 ++++++++-- packages/omamobile-mmd/test/test_bridge.py | 3 ++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/docs/TELEPHONY-APPS-PLAN.md b/docs/TELEPHONY-APPS-PLAN.md index 02a456d54..079c9700c 100644 --- a/docs/TELEPHONY-APPS-PLAN.md +++ b/docs/TELEPHONY-APPS-PLAN.md @@ -172,7 +172,9 @@ Today `omamobile-sit-data` puts `rmnet0` behind Wi-Fi with metric 700, and Netwo **The bearer for mmsd-tng (#380):** sitd reports the internet bearer's device (the one omamobile-sit-data found), address and DNS in its private status, and the bridge publishes them on the bearer (`Interface`, `Ip4Config`). mmsd-tng binds to that device and resolves the MMSC through those servers, so MMS goes over cellular with Wi-Fi up, without touching the system's routes or DNS. -**Attended runbook, receive first (9a, not yet run):** +**Received on 2026-11-03** (the palmtop, the daily kernel `7.3.0-rc6-omamobile-tegu-s2mpg15-m1-g991042e2eff3-dirty`, this stack): one picture from the owner's iPhone. The WAP push arrived as a binary SMS during a call, sitd stored it, the bridge exported it with the internet bearer's device and DNS, and mmsd-tng, started afterwards, fetched the 708 KB message over `rmnet0` with Wi-Fi up (state `received`, a PNG inside). It logged one complaint, an IP config without a method, fixed in the bridge since. Messages doesn't show it yet (T3 in the apps). + +**Attended runbook, receive first (9a; steps 1 to 4 passed on 2026-11-03):** | Step / risk | Commands or action | Expect / pass | Stop condition | Rollback | | --- | --- | --- | --- | --- | diff --git a/packages/omamobile-mmd/lib/bridge.py b/packages/omamobile-mmd/lib/bridge.py index 949ff5e08..6add91442 100644 --- a/packages/omamobile-mmd/lib/bridge.py +++ b/packages/omamobile-mmd/lib/bridge.py @@ -103,6 +103,9 @@ def is_emergency(number, d): return re.sub(r'[\s().-]', '', number) in d['emergency_numbers'] +# MM_BEARER_IP_METHOD_UNKNOWN: a bearer IP config with nothing in it. +NO_IP_CONFIG = {'method': GLib.Variant('u', 0)} + class Bridge: def __init__(self, exporter, link, settings): self.x = exporter @@ -190,7 +193,7 @@ def update_modem(self, d): self.create_bearer(d) if self.bearer: self.x.set(self.bearer, mm.BEARER, Connected=d['data'], Interface=self.internet_interface(), - Ip4Config=self.internet_ipv4(d)) + Ip4Config=self.internet_ipv4(d), Ip6Config=NO_IP_CONFIG) for name in d['interfaces']: if not self.x.has(self.modem, name): self.x.add_interface(self.modem, name, self.interface_props(name, d)) @@ -296,7 +299,9 @@ def internet_ipv4(self, d): # resolves the MMSC through these where MMS goes over this bearer. net = (self.status or {}).get('internet') or {} if not d['data'] or not net.get('address'): - return {} + # libmm-glib rejects an IP config without a method (mmsd-tng + # logged "method not given"): unknown, as MM reports no config. + return NO_IP_CONFIG return {'method': GLib.Variant('u', 2), 'address': GLib.Variant('s', net['address']), 'prefix': GLib.Variant('u', 32), **{'dns' + str(i): GLib.Variant('s', value) for i, value in enumerate(net.get('dns', [])[:3], 1)}} @@ -306,6 +311,7 @@ def create_bearer(self, d): apn, ip_type = self.apn_settings() self.x.add(self.bearer, {mm.BEARER: dict( Interface=self.internet_interface(), Connected=d['data'], Ip4Config=self.internet_ipv4(d), + Ip6Config=NO_IP_CONFIG, IpTimeout=20, BearerType=mm.BEARER_DEFAULT, ProfileId=-1, Properties={'apn': GLib.Variant('s', apn), 'ip-type': GLib.Variant('u', IP_TYPES.get(ip_type, mm.IP_V4V6))})}, diff --git a/packages/omamobile-mmd/test/test_bridge.py b/packages/omamobile-mmd/test/test_bridge.py index 0e33c3b7e..659b1ebb5 100644 --- a/packages/omamobile-mmd/test/test_bridge.py +++ b/packages/omamobile-mmd/test/test_bridge.py @@ -788,7 +788,8 @@ def test_the_found_device_address_and_dns(self): self.sitd.status['modem']['data'] = False self.push() wait_until(lambda: not self.client.prop(bearer, mm.BEARER, 'Connected'), 5, 'bearer down') - self.assertEqual(self.client.prop(bearer, mm.BEARER, 'Ip4Config'), {}) + self.assertEqual(self.client.prop(bearer, mm.BEARER, 'Ip4Config'), dict(method=0)) + self.assertEqual(self.client.prop(bearer, mm.BEARER, 'Ip6Config'), dict(method=0)) if __name__ == '__main__': From 724ca795c2d925a11d6034d8f10568673f65187b Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Fri, 6 Nov 2026 08:34:32 -0643 Subject: [PATCH 5/9] omamobile-mmd: the internet bearer's interface stays empty until sitd reports its device Before sitd had reported a device, the bridge named rmnet0. On the 7 Pro, with a different attach APN, rmnet0 can briefly be another bearer's device, so mmsd-tng could bind to the wrong one. MM itself leaves a bearer's interface empty until it has one. (cherry picked from commit c1fc4a96d1085100503947bf1afbcf01dec00949) --- packages/omamobile-mmd/lib/bridge.py | 6 ++++-- packages/omamobile-mmd/test/test_bridge.py | 6 +++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/omamobile-mmd/lib/bridge.py b/packages/omamobile-mmd/lib/bridge.py index 6add91442..ad4a0240b 100644 --- a/packages/omamobile-mmd/lib/bridge.py +++ b/packages/omamobile-mmd/lib/bridge.py @@ -291,8 +291,10 @@ def sim_dynamic(self, d): def internet_interface(self): # The device omamobile-sit-data found carrying the internet bearer, - # which isn't always rmnet; rmnet0 until sitd knows. - return ((self.status or {}).get('internet') or {}).get('interface') or 'rmnet0' + # which isn't always rmnet; empty until sitd reports it, as + # MM leaves a bearer's interface empty before it has one (a guess + # such as rmnet0 can be another bearer's device for a while). + return ((self.status or {}).get('internet') or {}).get('interface') or '' def internet_ipv4(self, d): # The address and the carrier's DNS, as MM gives them: mmsd-tng diff --git a/packages/omamobile-mmd/test/test_bridge.py b/packages/omamobile-mmd/test/test_bridge.py index 659b1ebb5..c5360ae68 100644 --- a/packages/omamobile-mmd/test/test_bridge.py +++ b/packages/omamobile-mmd/test/test_bridge.py @@ -228,8 +228,12 @@ def test_registration_states_and_signals(self): bearers = self.modem('Bearers') self.assertEqual(len(bearers), 1) bearer = self.client.props(bearers[0], mm.BEARER) + # No device until sitd reports one: never a guessed rmnet0. self.assertEqual((bearer['Interface'], bearer['Connected'], bearer['Properties']['apn']), - ('rmnet0', True, 'internet.example')) + ('', True, 'internet.example')) + self.sitd.status['internet'] = dict(interface='rmnet1') + self.sitd.push() + wait_until(lambda: self.client.props(bearers[0], mm.BEARER)['Interface'] == 'rmnet1', 5, 'the bearer device') changes = [s for s in self.client.named('PropertiesChanged') if s[0] == MODEM0 and s[3][0] == mm.MODEM] self.assertTrue(any('State' in s[3][1] for s in changes)) self.assertEqual(self.sitd.actions(), []) From 869caa08165852f0635b0401d65a37f01eab1ca9 Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Fri, 13 Nov 2026 10:01:05 -0644 Subject: [PATCH 6/9] omamobile-modem-sit: the status names only a kept bearer device, and tests for the binary-message rules omamobile-sit-data writes data-interface before it probes a candidate, so that a killed run can be cleaned up, and sitd's status read that file: for the seconds of a probe it reported a device that might not carry the bearer (rmnet0 on the Pixel 7 Pro, where rmnet1 does). The data service now writes a second record, data-interface-kept, only once a candidate has answered, removes it before it takes the configuration down, and the status reads that one. A test reads the status during each probe. Tests pin what goes on as data: a concatenated 8-bit message with no port in any part, or with another port in its first part, is not data; nor is a WAP push in the reserved alphabet or with compressed content. Each fails when its condition is removed. --- .../omamobile-modem-sit/lib/data_network.py | 12 ++++- packages/omamobile-modem-sit/lib/service.py | 6 ++- .../test/test_data_network.py | 50 ++++++++++++++++++- .../omamobile-modem-sit/test/test_service.py | 25 ++++++++++ .../test/test_sms_codec.py | 29 +++++++++++ 5 files changed, 117 insertions(+), 5 deletions(-) diff --git a/packages/omamobile-modem-sit/lib/data_network.py b/packages/omamobile-modem-sit/lib/data_network.py index be7b4fd35..9b90c41a6 100644 --- a/packages/omamobile-modem-sit/lib/data_network.py +++ b/packages/omamobile-modem-sit/lib/data_network.py @@ -40,6 +40,10 @@ RESOLVER = Path('/etc/resolv.conf') INTERFACE = paths.RUN / 'data-interface' +# Written only once a candidate has answered and is kept: what the phone +# service reports as the internet bearer's device. data-interface names a +# candidate from before its probe, so that a killed run can be cleaned up. +KEPT = paths.RUN / 'data-interface-kept' # rmnet0-rmnet7 are tried; CPIF creates 30, a phone uses a handful. CANDIDATES = 8 @@ -200,6 +204,7 @@ def put_back(dev, address=None): def clear_stale(): """A device recorded by a run that ended without its cleanup (killed, or stopped before 0.3.12 while probing): put it back before anything else.""" + KEPT.unlink(missing_ok=True) try: dev = INTERFACE.read_text().strip() except OSError: @@ -217,7 +222,9 @@ def find_device(address, cid, probe=None, stopped=lambda: False): keeps its address and route. Every other one is put back as it was, also when a step fails or the service is stopped in the middle (the record in data-interface is written before the device is touched, so a run that is - killed outright is cleaned up by the next start).""" + killed outright is cleaned up by the next start). data-interface-kept is + written only for the one that answered: a device that is merely being + tried is never reported as the bearer's.""" probe = probe or answers for dev in candidates(cid): if stopped(): @@ -243,6 +250,7 @@ def find_device(address, cid, probe=None, stopped=lambda: False): INTERFACE.unlink(missing_ok=True) if kept: print('Bearer CID', cid, 'carried by', dev, flush=True) + KEPT.write_text(dev + '\n') return dev if stopped(): raise InterruptedError('Stopped while looking for the bearer device') @@ -330,6 +338,8 @@ def watch(): # Stopped while probing: find_device has put the candidate back. pass finally: + # The status stops naming the device before its configuration goes. + KEPT.unlink(missing_ok=True) if resolver: resolver.restore() if dev: diff --git a/packages/omamobile-modem-sit/lib/service.py b/packages/omamobile-modem-sit/lib/service.py index ad2582e4b..7d91b3b20 100644 --- a/packages/omamobile-modem-sit/lib/service.py +++ b/packages/omamobile-modem-sit/lib/service.py @@ -97,13 +97,15 @@ def internet_config(): """The internet bearer's device, address and the carrier's DNS, for the bridge's copy of the bearer (MMS goes over it where the MMS APN is the internet APN). The device is the one omamobile-sit-data found carrying - it; none recorded means the data network isn't up yet. It goes in the + it and kept (data-interface-kept, written after its probe answered; a + candidate still being probed is not it); none recorded means the data + network isn't up yet. It goes in the status for authorised clients only, not in state.json; the bridge then publishes it in the bearer's Ip4Config, which, as ModemManager's, any client on the system bus can read.""" try: address, dns = internet_addresses(bearer_paths(data_call.INTERNET_CID)[1].read_bytes()) - interface = (paths.RUN / 'data-interface').read_text().strip() + interface = (paths.RUN / 'data-interface-kept').read_text().strip() except (OSError, ValueError): return {} if not interface: diff --git a/packages/omamobile-modem-sit/test/test_data_network.py b/packages/omamobile-modem-sit/test/test_data_network.py index cab69046b..2176bbf8a 100644 --- a/packages/omamobile-modem-sit/test/test_data_network.py +++ b/packages/omamobile-modem-sit/test/test_data_network.py @@ -1,6 +1,7 @@ # SPDX-License-Identifier: MIT import env # noqa: F401 (paths and sys.path first) from pathlib import Path +import struct import subprocess import tempfile import unittest @@ -65,7 +66,9 @@ def undo(args, **kwargs): patch.object(data_network, 'run', run), \ patch.object(data_network.subprocess, 'run', undo), \ patch.object(data_network.paths, 'RUN', Path(temp)), \ - patch.object(data_network, 'INTERFACE', Path(temp) / 'data-interface'): + patch.object(data_network, 'INTERFACE', Path(temp) / 'data-interface'), \ + patch.object(data_network, 'KEPT', Path(temp) / 'data-interface-kept'): + self.run_dir = Path(temp) try: dev = data_network.find_device('192.0.2.10', cid, probe=probe or (lambda d: d == carrier), stopped=stopped) @@ -73,6 +76,8 @@ def undo(args, **kwargs): dev = None recorded = (Path(temp) / 'data-interface').read_text().strip() \ if (Path(temp) / 'data-interface').exists() else None + self.kept = (Path(temp) / 'data-interface-kept').read_text().strip() \ + if (Path(temp) / 'data-interface-kept').exists() else None return dev, recorded, commands def test_stock_name_first_then_the_others(self): @@ -90,6 +95,44 @@ def test_the_device_that_answers_is_kept_and_recorded(self): self.assertEqual(commands[-1], ('ip', 'route', 'add', 'default', 'dev', 'rmnet1', 'src', '192.0.2.10', 'metric', '700')) + def test_the_status_names_no_device_while_one_is_only_being_tried(self): + # The Pixel 7 Pro's case: rmnet0 is tried first and doesn't answer, + # rmnet1 does. The phone service's status, read during each probe, + # must not name the candidate; it names rmnet1 once that is kept. + import data_call + import service as app_service + result = bytearray(132) + struct.pack_into(' Date: Fri, 13 Nov 2026 10:01:05 -0644 Subject: [PATCH 7/9] omamobile-mmd: a WAP push is a placeholder text where no MMS daemon is installed omatel-agent leaves a message with data and no text for the MMS service, so on a phone without mmsd-tng a picture message's notification showed nothing in Messages. On main only a multi-part one showed the "cannot display yet" placeholder, because its later parts decoded as text; with whole pushes delivered as data that went too. The bridge now exports the placeholder as the text, with no data, unless /usr/bin/mmsdtng exists. --mms-daemon sets that path for the tests. --- packages/omamobile-mmd/lib/bridge.py | 14 +++++++++++++- packages/omamobile-mmd/lib/main.py | 7 ++++++- packages/omamobile-mmd/test/env.py | 3 +++ packages/omamobile-mmd/test/test_bridge.py | 18 ++++++++++++++++++ 4 files changed, 40 insertions(+), 2 deletions(-) diff --git a/packages/omamobile-mmd/lib/bridge.py b/packages/omamobile-mmd/lib/bridge.py index ad4a0240b..7e0ca7d52 100644 --- a/packages/omamobile-mmd/lib/bridge.py +++ b/packages/omamobile-mmd/lib/bridge.py @@ -22,6 +22,7 @@ """ import hashlib import itertools +from pathlib import Path import re import uuid @@ -43,6 +44,12 @@ DEVICE = '/sys/devices/platform/cpif' LIVE = (mm.CALL_DIALING, mm.CALL_RINGING_OUT, mm.CALL_RINGING_IN, mm.CALL_ACTIVE, mm.CALL_HELD, mm.CALL_WAITING) +# A WAP push (an MMS notification) goes to clients as binary data only where +# something can fetch the message: mmsd-tng, by its binary. Elsewhere the +# owner at least learns that a message came. +MMS_DAEMON = Path('/usr/bin/mmsdtng') +NO_MMS_TEXT = 'Received a multimedia or binary message that this phone cannot display yet.' + NOT_YET = { 'data': 'Mobile data through ModemManager (T3); omamobile-sit-data owns rmnet0 for now', 'pin': 'SIM PIN entry (T8); take the PIN lock off in another phone', @@ -477,9 +484,14 @@ def fetched(self, result, error): if sid not in wanted or sid in self.sitd_sms: continue data = bytes.fromhex(message.get('data') or '') + text = message.get('text', '') + if data and not text and not MMS_DAEMON.exists(): + # Nothing on this phone takes a WAP push: Messages would show + # nothing at all, so it gets the placeholder as a text. + text, data = NO_MMS_TEXT, b'' path = self.new_message(dict( sid=sid, State=mm.SMS_RECEIVED, PduType=mm.PDU_DELIVER, Number=message.get('number', ''), - Text=message.get('text', ''), Data=data, Timestamp=message.get('timestamp', ''), + Text=text, Data=data, Timestamp=message.get('timestamp', ''), Storage=mm.STORAGE_ME), received) print(f'SMS {path} received{" (binary data: a WAP push)" if data else ""}', flush=True) if any(i not in self.sitd_sms for i in self.status.get('sms', {}).get('received', [])): diff --git a/packages/omamobile-mmd/lib/main.py b/packages/omamobile-mmd/lib/main.py index 170348afe..c11a857a9 100644 --- a/packages/omamobile-mmd/lib/main.py +++ b/packages/omamobile-mmd/lib/main.py @@ -7,7 +7,7 @@ see a modem. It never talks to the modem itself: sitd stays the only owner of the SIT channel, and nothing here starts the modem or sitd. - omamobile-mmd [--socket PATH] [--sit-config PATH] [--no-polkit] + omamobile-mmd [--socket PATH] [--sit-config PATH] [--mms-daemon PATH] [--no-polkit] --no-polkit skips the polkit checks (offline tests on a private bus only; the shipped unit keeps them). DBUS_SYSTEM_BUS_ADDRESS picks another bus. @@ -15,11 +15,13 @@ import argparse import configparser import os +from pathlib import Path import signal import sys from gi.repository import Gio, GLib +import bridge as bridge_module import mm_api from bridge import Bridge from exporter import Exporter @@ -50,8 +52,11 @@ def main(argv=None): parser = argparse.ArgumentParser(description="ModemManager's D-Bus API in front of omamobile-sitd") parser.add_argument('--socket', default=os.path.join(RUN, 'socket'), help="omamobile-sitd's socket") parser.add_argument('--sit-config', default=SIT_CONFIG, help="omamobile-sitd's settings (the APN)") + parser.add_argument('--mms-daemon', default=str(bridge_module.MMS_DAEMON), + help='the MMS daemon whose presence makes a WAP push binary data (tests)') parser.add_argument('--no-polkit', action='store_true', help='skip polkit (offline tests only)') args = parser.parse_args(argv) + bridge_module.MMS_DAEMON = Path(args.mms_daemon) loop = GLib.MainLoop() state = dict(bridge=None, link=None, code=0) diff --git a/packages/omamobile-mmd/test/env.py b/packages/omamobile-mmd/test/env.py index 20506a623..07953cc59 100644 --- a/packages/omamobile-mmd/test/env.py +++ b/packages/omamobile-mmd/test/env.py @@ -213,6 +213,9 @@ def __init__(self, bus, socket_path, directory, *args): f.write('[network]\napn = internet.example\nip_type = ipv4v6\n') with open(self.log, 'w') as log: polkit = [] if '--polkit' in args else ['--no-polkit'] + # As on a phone with mmsd-tng installed, unless a test says otherwise. + if '--mms-daemon' not in args: + polkit += ['--mms-daemon', sys.executable] self.proc = subprocess.Popen( [sys.executable, BIN, '--socket', socket_path, *polkit, '--sit-config', os.path.join(directory, 'sit.conf'), *[a for a in args if a != '--polkit']], diff --git a/packages/omamobile-mmd/test/test_bridge.py b/packages/omamobile-mmd/test/test_bridge.py index c5360ae68..5f2d4f543 100644 --- a/packages/omamobile-mmd/test/test_bridge.py +++ b/packages/omamobile-mmd/test/test_bridge.py @@ -729,6 +729,24 @@ def test_introspection(self): ''' +class NoMmsDaemon(BridgeTests): + """A phone without mmsd-tng: nothing would take a WAP push, so it goes + to Messages as the placeholder text.""" + status = staticmethod(registered_status) + mmd_args = ('--mms-daemon', '/nonexistent/mmsdtng') + + def test_mms_notification_is_a_placeholder_text(self): + wap = bytes.fromhex('0106226170706c69636174696f6e2f766e642e7761702e6d6d732d6d65737361676500') + b'x' + messages = [dict(id='sit:b', number=SENDER, text='', timestamp='2026-09-29T12:35:00+00:00', + data=wap.hex(), state='received')] + self.sitd.handlers.update(**{'sms-list': lambda r: messages, 'sms-delete': lambda r: {}}) + self.sitd.status['sms'] = dict(received=['sit:b']) + self.push() + wait_until(lambda: len(self.client.named('Added')) == 1, 5, 'WAP push') + push = self.client.props(self.modem('Messages', mm.MESSAGING)[0], mm.SMS) + self.assertEqual((push['Text'], bytes(push['Data'])), (bridge.NO_MMS_TEXT, b'')) + + class Polkit(BridgeTests): """The shipped behaviour: methods with an action go through polkit for a caller that isn't root (the test's own uid here). A fake authority on From 50e1a313c1f65c39d4c4f4616133e252af461d6c Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Fri, 13 Nov 2026 10:01:05 -0644 Subject: [PATCH 8/9] mmsd-tng, omamobile-mmd, TELEPHONY-APPS-PLAN: patch numbers, the upstream merge requests, the bridge's dependency The patches are numbered 0001 to 0004, and the README says which two are offered upstream (mmsd!133, mmsd!134), so the next version bump knows what to drop; its paragraph on the AUR recipe is one sentence, and it points at section 1.7. The plan says #697 where it said #380. omamobile-mmd depends on the modem-sit that reports the bearer; the number is a placeholder for the one set at merge. --- docs/TELEPHONY-APPS-PLAN.md | 6 ++-- ...-modern-libphonenumber-dependencies.patch} | 0 ...ional-own-number-with-redacted-IMSI.patch} | 0 packages/mmsd-tng/PKGBUILD | 8 +++--- packages/mmsd-tng/README.md | 28 +++++++++++-------- packages/omamobile-mmd/PKGBUILD | 5 +++- 6 files changed, 27 insertions(+), 20 deletions(-) rename packages/mmsd-tng/{0004-link-modern-libphonenumber-dependencies.patch => 0003-link-modern-libphonenumber-dependencies.patch} (100%) rename packages/mmsd-tng/{0005-accept-international-own-number-with-redacted-IMSI.patch => 0004-accept-international-own-number-with-redacted-IMSI.patch} (100%) diff --git a/docs/TELEPHONY-APPS-PLAN.md b/docs/TELEPHONY-APPS-PLAN.md index 079c9700c..d5a67a99b 100644 --- a/docs/TELEPHONY-APPS-PLAN.md +++ b/docs/TELEPHONY-APPS-PLAN.md @@ -163,14 +163,14 @@ Today `omamobile-sit-data` puts `rmnet0` behind Wi-Fi with metric 700, and Netwo | Need | How | Ready? | | --- | --- | --- | -| WAP push (the MMS notification) arrives as a binary SMS | sitd passes the PDU's user data through; the bridge exports an `Sms` with `Data` set and `Text` empty, which mmsd-tng picks up | Yes for the 9a's stack (#380): sitd keeps each part's WAP port and delivers a joined push as data; the bridge exports it with `Data` | +| WAP push (the MMS notification) arrives as a binary SMS | sitd passes the PDU's user data through; the bridge exports an `Sms` with `Data` set and `Text` empty, which mmsd-tng picks up; on a phone without mmsd-tng installed the bridge exports the placeholder text instead, so Messages shows that a message came | Yes for the 9a's stack (#697): sitd keeps each part's WAP port and delivers a joined push as data; the bridge exports it with `Data` | | An APN that carries MMS | mmsd-tng's `MMS_APN` must match the connected bearer's APN. mmsd-tng supports no separate MMS bearer ("limitations of Modem Manager", its README), so the carrier must allow MMS on the internet APN. Many US carriers do; check ours (Q8) | On the palmtop's carrier the MMS APN is the internet APN. A second bearer on it took the IMS bearer down (2026-11-02), so sitd sets up none | | Fetch from the MMSC over mobile data, even with Wi-Fi up | mmsd-tng binds HTTP to the bearer's interface (`SO_BINDTODEVICE`, `src/service.c:3720-3732`) and resolves through that interface's DNS (c-ares or systemd-resolved with the ifindex). Needs `CarrierMMSC`, `CarrierMMSProxy`, or `http://mms.invalid` to look them up in mobile-broadband-provider-info | **Depends on M4.3:** rmnet0 is configured IPv4 only (MODEM-CLIENT §1.3). If the carrier's bearer is IPv6-only (common on T-Mobile's network [I]), MMS needs IPv6 on rmnet0 first. The packet processor (MODEM-PLAN 6.3) is built but untested on hardware; the legacy buffers carry data meanwhile | | Sending MMS | mmsd-tng posts the M-Send.req to the MMSC the same way | as above | -| Storage and UI | mmsd-tng stores messages and serves `org.ofono.mms` on the session bus; Chatty and our app are its clients | `packages/mmsd-tng` (2.6.4, #380), not enabled; Messages' side is in the omatel apps (T3) | +| Storage and UI | mmsd-tng stores messages and serves `org.ofono.mms` on the session bus; Chatty and our app are its clients | `packages/mmsd-tng` (2.6.4, #697), not enabled; Messages' side is in the omatel apps (T3) | | Group MMS | MMS with several recipients; mmsd-tng handles the PDUs | with the above | -**The bearer for mmsd-tng (#380):** sitd reports the internet bearer's device (the one omamobile-sit-data found), address and DNS in its private status, and the bridge publishes them on the bearer (`Interface`, `Ip4Config`). mmsd-tng binds to that device and resolves the MMSC through those servers, so MMS goes over cellular with Wi-Fi up, without touching the system's routes or DNS. +**The bearer for mmsd-tng (#697):** sitd reports the internet bearer's device (the one omamobile-sit-data found and kept: a candidate still being probed isn't reported), address and DNS in its private status, and the bridge publishes them on the bearer (`Interface`, `Ip4Config`). mmsd-tng binds to that device and resolves the MMSC through those servers, so MMS goes over cellular with Wi-Fi up, without touching the system's routes or DNS. **Received on 2026-11-03** (the palmtop, the daily kernel `7.3.0-rc6-omamobile-tegu-s2mpg15-m1-g991042e2eff3-dirty`, this stack): one picture from the owner's iPhone. The WAP push arrived as a binary SMS during a call, sitd stored it, the bridge exported it with the internet bearer's device and DNS, and mmsd-tng, started afterwards, fetched the 708 KB message over `rmnet0` with Wi-Fi up (state `received`, a PNG inside). It logged one complaint, an IP config without a method, fixed in the bridge since. Messages doesn't show it yet (T3 in the apps). diff --git a/packages/mmsd-tng/0004-link-modern-libphonenumber-dependencies.patch b/packages/mmsd-tng/0003-link-modern-libphonenumber-dependencies.patch similarity index 100% rename from packages/mmsd-tng/0004-link-modern-libphonenumber-dependencies.patch rename to packages/mmsd-tng/0003-link-modern-libphonenumber-dependencies.patch diff --git a/packages/mmsd-tng/0005-accept-international-own-number-with-redacted-IMSI.patch b/packages/mmsd-tng/0004-accept-international-own-number-with-redacted-IMSI.patch similarity index 100% rename from packages/mmsd-tng/0005-accept-international-own-number-with-redacted-IMSI.patch rename to packages/mmsd-tng/0004-accept-international-own-number-with-redacted-IMSI.patch diff --git a/packages/mmsd-tng/PKGBUILD b/packages/mmsd-tng/PKGBUILD index 60ad178ae..22674210f 100644 --- a/packages/mmsd-tng/PKGBUILD +++ b/packages/mmsd-tng/PKGBUILD @@ -15,8 +15,8 @@ options=('!lto') source=("$pkgname-$pkgver.tar.gz::$url/-/archive/$pkgver/mmsd-$pkgver.tar.gz" '0001-use-configured-number-with-empty-own-numbers.patch' '0002-close-socket-on-interface-bind-failure.patch' - '0004-link-modern-libphonenumber-dependencies.patch' - '0005-accept-international-own-number-with-redacted-IMSI.patch') + '0003-link-modern-libphonenumber-dependencies.patch' + '0004-accept-international-own-number-with-redacted-IMSI.patch') sha256sums=('5772d4d1830664404d8f6ed96d9c35f6e7a53c60b1ac5571cd2a6183c7e633ed' '2bddbd5812356656162920a8cf145a69a529f6e33a2109633de6b508aee99d8e' '4c0a0997edfb936c50807459c51b97b55be6a404faf51bbcf7c993faf5041add' @@ -27,8 +27,8 @@ prepare() { cd "mmsd-$pkgver" patch -Np1 -i "$srcdir/0001-use-configured-number-with-empty-own-numbers.patch" patch -Np1 -i "$srcdir/0002-close-socket-on-interface-bind-failure.patch" - patch -Np1 -i "$srcdir/0004-link-modern-libphonenumber-dependencies.patch" - patch -Np1 -i "$srcdir/0005-accept-international-own-number-with-redacted-IMSI.patch" + patch -Np1 -i "$srcdir/0003-link-modern-libphonenumber-dependencies.patch" + patch -Np1 -i "$srcdir/0004-accept-international-own-number-with-redacted-IMSI.patch" } build() { diff --git a/packages/mmsd-tng/README.md b/packages/mmsd-tng/README.md index ef0511313..b5468f1a9 100644 --- a/packages/mmsd-tng/README.md +++ b/packages/mmsd-tng/README.md @@ -4,15 +4,11 @@ An opt-in, per-user MMS daemon using ModemManager's D-Bus API. It never starts the modem or sitd. This package alone does not enable picture messages in Messages: omatel-agent and omamessages need their T3 changes -in their own repositories. See `docs/TELEPHONY-APPS-PLAN.md` section 1.7b. +in their own repositories. See `docs/TELEPHONY-APPS-PLAN.md` section 1.7. -The AUR has `mmsd-tng-git`, advertising 2.5.0.r0.g6529119-1 in its cached -package metadata while building upstream HEAD. Neither Arch's exact-name -search nor Arch Linux ARM's aarch64 core/extra indexes contained mmsd-tng -when checked on 2026-11-03. This recipe uses upstream's stable 2.6.4 tag -and the AUR runtime dependency set, with a checked source checksum and a -single Meson build directory. Modern libphonenumber headers additionally -need explicit protobuf and Abseil linkage. +Neither Arch nor Arch Linux ARM packages mmsd-tng (checked 2026-11-03), so +this recipe builds upstream's 2.6.4 tag with the AUR recipe's runtime +dependencies and a checked source checksum. Sources: [AUR recipe](https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=mmsd-tng-git), [upstream 2.6.4](https://gitlab.com/kop316/mmsd/-/tree/2.6.4), @@ -20,10 +16,18 @@ Sources: [AUR recipe](https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=mms Upstream is GPL-2.0; its LGPL components retain their notices. Patches use the corresponding upstream file's license. -The patches apply the configured own number when MM's OwnNumbers array is -empty, including E.164 parsing without an IMSI-derived region; close HTTP -sockets on interface-binding failure; and link the dependencies required by -current libphonenumber. +The patches, and what drops each at a later version bump: + +- `0001` uses the configured own number when ModemManager's OwnNumbers is + empty. Offered upstream as + [mmsd!133](https://gitlab.com/kop316/mmsd/-/merge_requests/133). +- `0002` closes the HTTP socket when it can't be bound to the interface. + Offered upstream as + [mmsd!134](https://gitlab.com/kop316/mmsd/-/merge_requests/134). +- `0003` links protobuf and Abseil, which current libphonenumber headers + need. Not offered upstream yet. +- `0004` parses an international own number without a region taken from the + IMSI. Not offered upstream yet. mmsd-tng fetches MMS over a connected bearer whose APN is its `MMS_APN`, bound to that bearer's device and resolving through the DNS in its diff --git a/packages/omamobile-mmd/PKGBUILD b/packages/omamobile-mmd/PKGBUILD index faba84561..815f24afb 100644 --- a/packages/omamobile-mmd/PKGBUILD +++ b/packages/omamobile-mmd/PKGBUILD @@ -7,7 +7,10 @@ pkgdesc="Omarchy Mobile ModemManager-compatible bridge: org.freedesktop.ModemMan arch=(aarch64) url="https://github.com/derekross/omarchy-mobile" license=(MIT) -depends=(python python-gobject glib2 dbus polkit 'omamobile-modem-sit>=0.3.0') +# modem-sit from the version that reports the internet bearer's device, +# address and DNS in its status: with an older one the bearer's Interface +# would stay empty for good. (The number is set with the versions at merge.) +depends=(python python-gobject glib2 dbus polkit 'omamobile-modem-sit>=0.3.36') checkdepends=(dbus) # It owns ModemManager's bus name and ships its bus policy and polkit # actions. Nothing in Arch or Arch Linux ARM hard-depends on modemmanager From 24bbeb50be6154aa4d27ea73d99f2ca0d45aa6c5 Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Fri, 13 Nov 2026 12:58:36 -0644 Subject: [PATCH 9/9] omamobile-modem-sit 0.3.37, omamobile-mmd: the version after main's 0.3.36 Main took 0.3.36 for nr_after_radio_on, so the status that names the internet bearer's device, address and DNS is 0.3.37, and the bridge depends on that one. --- packages/omamobile-mmd/PKGBUILD | 4 ++-- packages/omamobile-modem-sit/version | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/omamobile-mmd/PKGBUILD b/packages/omamobile-mmd/PKGBUILD index 815f24afb..c1f3cf099 100644 --- a/packages/omamobile-mmd/PKGBUILD +++ b/packages/omamobile-mmd/PKGBUILD @@ -9,8 +9,8 @@ url="https://github.com/derekross/omarchy-mobile" license=(MIT) # modem-sit from the version that reports the internet bearer's device, # address and DNS in its status: with an older one the bearer's Interface -# would stay empty for good. (The number is set with the versions at merge.) -depends=(python python-gobject glib2 dbus polkit 'omamobile-modem-sit>=0.3.36') +# would stay empty for good. +depends=(python python-gobject glib2 dbus polkit 'omamobile-modem-sit>=0.3.37') checkdepends=(dbus) # It owns ModemManager's bus name and ships its bus policy and polkit # actions. Nothing in Arch or Arch Linux ARM hard-depends on modemmanager diff --git a/packages/omamobile-modem-sit/version b/packages/omamobile-modem-sit/version index 851786c85..ba61ff307 100644 --- a/packages/omamobile-modem-sit/version +++ b/packages/omamobile-modem-sit/version @@ -1 +1 @@ -0.3.36 +0.3.37