Commit 6b73e119 authored by Clayton Craft's avatar Clayton Craft Committed by Michał Polański
Browse files

community/modemmanager: include patches to support transfer-route MT

These patches are merged upstream, but are not yet in a release. They
are required for transfer-route MT messages to work, which allows
recieving MMS on some modems/systems.
parent 568fe66e
From 39f9ec004e859291a7049def431abf3bcff5d2d5 Mon Sep 17 00:00:00 2001
From: Clayton Craft <clayton@craftyguy.net>
Date: Sat, 17 Apr 2021 00:53:27 -0700
Subject: [PATCH 1/2] broadband-modem-qmi: Handle transfer-route MT messages
This handles transfer-route MT messages, automatically ACKing any that
need to be ACKed.
Based on work by Angus Ainslie and Elias Rudberg
---
src/mm-broadband-modem-qmi.c | 74 +++++++++++++++++++++++++++++++++++-
1 file changed, 73 insertions(+), 1 deletion(-)
diff --git a/src/mm-broadband-modem-qmi.c b/src/mm-broadband-modem-qmi.c
index b910a585..70d1ac57 100644
--- a/src/mm-broadband-modem-qmi.c
+++ b/src/mm-broadband-modem-qmi.c
@@ -6082,6 +6082,21 @@ wms_indication_raw_read_ready (QmiClientWms *client,
indication_raw_read_context_free (ctx);
}
+static void
+wms_send_ack_ready (QmiClientWms *client,
+ GAsyncResult *res,
+ MMBroadbandModemQmi *self)
+{
+ g_autoptr(QmiMessageWmsSendAckOutput) output = NULL;
+ g_autoptr(GError) error= NULL;
+
+ output = qmi_client_wms_send_ack_finish (client, res, &error);
+ if (!output) {
+ mm_obj_dbg (self, "QMI operation failed: '%s'", error->message);
+ }
+ g_object_unref (self);
+}
+
static void
messaging_event_report_indication_cb (QmiClientNas *client,
QmiIndicationWmsEventReportOutput *output,
@@ -6089,8 +6104,65 @@ messaging_event_report_indication_cb (QmiClientNas *client,
{
QmiWmsStorageType storage;
guint32 memory_index;
+ QmiWmsAckIndicator ack_ind;
+ guint32 transaction_id;
+ QmiWmsMessageFormat msg_format;
+ QmiWmsMessageTagType tag;
+ GArray *raw_data = NULL;
+
+ /* Handle transfer-route MT messages */
+ if (qmi_indication_wms_event_report_output_get_transfer_route_mt_message (
+ output,
+ &ack_ind,
+ &transaction_id,
+ &msg_format,
+ &raw_data,
+ NULL)) {
+ mm_obj_dbg (self, "Got transfer-route MT message");
+ /* If this is the first of a multi-part message, send an ACK to get the
+ * second part */
+ if (ack_ind == QMI_WMS_ACK_INDICATOR_SEND) {
+ g_autoptr(QmiMessageWmsSendAckInput) ack_input = NULL;
+ QmiWmsMessageProtocol message_protocol;
+ /* Need to ack message */
+ mm_obj_dbg (self, "Need to ACK indicator");
+ switch (msg_format) {
+ case QMI_WMS_MESSAGE_FORMAT_CDMA:
+ message_protocol = QMI_WMS_MESSAGE_PROTOCOL_CDMA;
+ break;
+ case QMI_WMS_MESSAGE_FORMAT_MWI:
+ case QMI_WMS_MESSAGE_FORMAT_GSM_WCDMA_POINT_TO_POINT:
+ case QMI_WMS_MESSAGE_FORMAT_GSM_WCDMA_BROADCAST:
+ default:
+ message_protocol = QMI_WMS_MESSAGE_PROTOCOL_WCDMA;
+ break;
+ }
+ ack_input = qmi_message_wms_send_ack_input_new();
+ qmi_message_wms_send_ack_input_set_information (ack_input,
+ transaction_id,
+ message_protocol,
+ TRUE,
+ NULL);
+ qmi_client_wms_send_ack (QMI_CLIENT_WMS (client),
+ ack_input,
+ 180,
+ NULL,
+ (GAsyncReadyCallback)wms_send_ack_ready,
+ g_object_ref (self));
+ }
- /* Currently ignoring transfer-route MT messages */
+ /* Defaults for transfer-route messages, which are not stored anywhere */
+ storage = QMI_WMS_STORAGE_TYPE_NONE;
+ memory_index = 0;
+ tag = QMI_WMS_MESSAGE_TAG_TYPE_MT_NOT_READ;
+ add_new_read_sms_part (MM_IFACE_MODEM_MESSAGING (self),
+ storage,
+ memory_index,
+ tag,
+ msg_format,
+ raw_data);
+ return;
+ }
if (qmi_indication_wms_event_report_output_get_mt_message (
output,
--
2.31.1
From 62b440b34c8e00cd9e136c0c5d9cb0a11291511f Mon Sep 17 00:00:00 2001
From: Clayton Craft <clayton@craftyguy.net>
Date: Fri, 16 Apr 2021 20:42:15 -0700
Subject: [PATCH 2/2] sms-part-3gpp: add flag for indicating PDU is
transfer-route message
When the message is a transfer-route MT, there is no SMSC address to
parse out. This flag allows indicating when the PDU is one such message.
---
src/mm-broadband-modem-mbim.c | 1 +
src/mm-broadband-modem-qmi.c | 5 +++++
src/mm-sms-part-3gpp.c | 42 +++++++++++++++++++----------------
src/mm-sms-part-3gpp.h | 1 +
4 files changed, 30 insertions(+), 19 deletions(-)
diff --git a/src/mm-broadband-modem-mbim.c b/src/mm-broadband-modem-mbim.c
index df9fc15a..7513ab18 100644
--- a/src/mm-broadband-modem-mbim.c
+++ b/src/mm-broadband-modem-mbim.c
@@ -5361,6 +5361,7 @@ add_sms_part (MMBroadbandModemMbim *self,
pdu->pdu_data,
pdu->pdu_data_size,
self,
+ FALSE,
&error);
if (part) {
mm_obj_dbg (self, "correctly parsed PDU (%d)", pdu->message_index);
diff --git a/src/mm-broadband-modem-qmi.c b/src/mm-broadband-modem-qmi.c
index 70d1ac57..21fe4118 100644
--- a/src/mm-broadband-modem-qmi.c
+++ b/src/mm-broadband-modem-qmi.c
@@ -5637,6 +5637,7 @@ add_new_read_sms_part (MMIfaceModemMessaging *self,
guint32 index,
QmiWmsMessageTagType tag,
QmiWmsMessageFormat format,
+ gboolean transfer_route,
GArray *data)
{
MMSmsPart *part = NULL;
@@ -5657,6 +5658,7 @@ add_new_read_sms_part (MMIfaceModemMessaging *self,
(guint8 *)data->data,
data->len,
self,
+ transfer_route,
&error);
break;
case QMI_WMS_MESSAGE_FORMAT_MWI:
@@ -5723,6 +5725,7 @@ wms_raw_read_ready (QmiClientWms *client,
message->memory_index,
tag,
format,
+ FALSE,
data);
}
@@ -6073,6 +6076,7 @@ wms_indication_raw_read_ready (QmiClientWms *client,
ctx->memory_index,
tag,
format,
+ FALSE,
data);
}
@@ -6160,6 +6164,7 @@ messaging_event_report_indication_cb (QmiClientNas *client,
memory_index,
tag,
msg_format,
+ TRUE,
raw_data);
return;
}
diff --git a/src/mm-sms-part-3gpp.c b/src/mm-sms-part-3gpp.c
index fbf8e114..51f2cfeb 100644
--- a/src/mm-sms-part-3gpp.c
+++ b/src/mm-sms-part-3gpp.c
@@ -355,7 +355,7 @@ mm_sms_part_3gpp_new_from_pdu (guint index,
return NULL;
}
- return mm_sms_part_3gpp_new_from_binary_pdu (index, pdu, pdu_len, log_object, error);
+ return mm_sms_part_3gpp_new_from_binary_pdu (index, pdu, pdu_len, log_object, FALSE, error);
}
MMSmsPart *
@@ -363,6 +363,7 @@ mm_sms_part_3gpp_new_from_binary_pdu (guint index,
const guint8 *pdu,
gsize pdu_len,
gpointer log_object,
+ gboolean transfer_route,
GError **error)
{
MMSmsPart *sms_part;
@@ -404,25 +405,28 @@ mm_sms_part_3gpp_new_from_binary_pdu (guint index,
offset = 0;
- /* ---------------------------------------------------------------------- */
- /* SMSC, in address format, precedes the TPDU
- * First byte represents the number of BYTES for the address value */
- PDU_SIZE_CHECK (1, "cannot read SMSC address length");
- smsc_addr_size_bytes = pdu[offset++];
- if (smsc_addr_size_bytes > 0) {
- PDU_SIZE_CHECK (offset + smsc_addr_size_bytes, "cannot read SMSC address");
- /* SMSC may not be given in DELIVER PDUs */
- address = sms_decode_address (&pdu[1], 2 * (smsc_addr_size_bytes - 1), error);
- if (!address) {
- g_prefix_error (error, "Couldn't read SMSC address: ");
- mm_sms_part_free (sms_part);
- return NULL;
- }
- mm_sms_part_take_smsc (sms_part, g_steal_pointer (&address));
- mm_obj_dbg (log_object, " SMSC address parsed: '%s'", mm_sms_part_get_smsc (sms_part));
- offset += smsc_addr_size_bytes;
+ if (!transfer_route) {
+ /* ---------------------------------------------------------------------- */
+ /* SMSC, in address format, precedes the TPDU
+ * First byte represents the number of BYTES for the address value */
+ PDU_SIZE_CHECK (1, "cannot read SMSC address length");
+ smsc_addr_size_bytes = pdu[offset++];
+ if (smsc_addr_size_bytes > 0) {
+ PDU_SIZE_CHECK (offset + smsc_addr_size_bytes, "cannot read SMSC address");
+ /* SMSC may not be given in DELIVER PDUs */
+ address = sms_decode_address (&pdu[1], 2 * (smsc_addr_size_bytes - 1), error);
+ if (!address) {
+ g_prefix_error (error, "Couldn't read SMSC address: ");
+ mm_sms_part_free (sms_part);
+ return NULL;
+ }
+ mm_sms_part_take_smsc (sms_part, g_steal_pointer (&address));
+ mm_obj_dbg (log_object, " SMSC address parsed: '%s'", mm_sms_part_get_smsc (sms_part));
+ offset += smsc_addr_size_bytes;
+ } else
+ mm_obj_dbg (log_object, " no SMSC address given");
} else
- mm_obj_dbg (log_object, " no SMSC address given");
+ mm_obj_dbg (log_object, " This is a transfer-route message");
/* ---------------------------------------------------------------------- */
diff --git a/src/mm-sms-part-3gpp.h b/src/mm-sms-part-3gpp.h
index bef416fa..c6f4cf3f 100644
--- a/src/mm-sms-part-3gpp.h
+++ b/src/mm-sms-part-3gpp.h
@@ -30,6 +30,7 @@ MMSmsPart *mm_sms_part_3gpp_new_from_binary_pdu (guint index,
const guint8 *pdu,
gsize pdu_len,
gpointer log_object,
+ gboolean transfer_route,
GError **error);
guint8 *mm_sms_part_3gpp_get_submit_pdu (MMSmsPart *part,
guint *out_pdulen,
--
2.31.1
......@@ -2,7 +2,7 @@
# Maintainer: Stuart Cardall <developer@it-offshore.co.uk>
pkgname=modemmanager
pkgver=1.16.4
pkgrel=0
pkgrel=1
pkgdesc="ModemManager library"
url="http://www.freedesktop.org/wiki/Software/ModemManager"
arch="all !mips !mips64 !s390x" # polkit
......@@ -21,6 +21,8 @@ subpackages="
$pkgname-bash-completion
"
source="https://www.freedesktop.org/software/ModemManager/ModemManager-$pkgver.tar.xz
0001-broadband-modem-qmi-Handle-transfer-route-MT-message.patch
0002-sms-part-3gpp-add-flag-for-indicating-PDU-is-transfe.patch
$pkgname.rules
$pkgname.initd"
builddir="$srcdir"/ModemManager-$pkgver
......@@ -77,6 +79,10 @@ check() {
make check
}
sha512sums="5fb7625c9d41ce0179b4e59745b00b815038239552a5438d71ff36b019b398fc3dc6bef709e91a186f5f7427fcb59d79c0b1c3ca9c3dca867f0d5677fd979506 ModemManager-1.16.4.tar.xz
sha512sums="
5fb7625c9d41ce0179b4e59745b00b815038239552a5438d71ff36b019b398fc3dc6bef709e91a186f5f7427fcb59d79c0b1c3ca9c3dca867f0d5677fd979506 ModemManager-1.16.4.tar.xz
202cada729fb5373a343c60dbef9b3257e3a68f6817a6ba3267d286a7438b3b28d17b02b4a5928c667f64315045cfda61831837f55e16560a427fd425f7d315a 0001-broadband-modem-qmi-Handle-transfer-route-MT-message.patch
6a2a034e1c49cd9880ec1feb739da1acfcf1c7b454731a0db263496db3b053518e8bde5beade5cebba0db0ae4eec478799d86e1c4cccf5f89b929cc486fb3dad 0002-sms-part-3gpp-add-flag-for-indicating-PDU-is-transfe.patch
6fab86c27502b29be0c6610d835a3249a4a81993eb986cff2c3ea9393fadd3f693ba4bb0532ae0e50a83d359559511859dd05f7ea2f0cb52839f535a7e49f8a0 modemmanager.rules
9f74a2473b9cc7be42a467809639f5720ab251d13f29f8bbd4fd9a13edb80c10c5ee50fbe50819bfe67f231805b92f007c3e7403c46ab998dc843e1f9549659b modemmanager.initd"
9f74a2473b9cc7be42a467809639f5720ab251d13f29f8bbd4fd9a13edb80c10c5ee50fbe50819bfe67f231805b92f007c3e7403c46ab998dc843e1f9549659b modemmanager.initd
"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment