summaryrefslogtreecommitdiff
path: root/patches/attachment-0004.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patches/attachment-0004.patch')
-rw-r--r--patches/attachment-0004.patch329
1 files changed, 329 insertions, 0 deletions
diff --git a/patches/attachment-0004.patch b/patches/attachment-0004.patch
new file mode 100644
index 00000000..b1110feb
--- /dev/null
+++ b/patches/attachment-0004.patch
@@ -0,0 +1,329 @@
1>From 4ffa5693bcaf283bc3c8ea7808226eb6e92aaaf5 Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?Bj=C3=B8rn=20Mork?= <bjorn@mork.no>
3Date: Mon, 4 Apr 2016 14:44:01 +0200
4Subject: [PATCH 1/2] libqmi: support MBIM EXT_QMUX service
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9Signed-off-by: Bjørn Mork <bjorn@mork.no>
10---
11 configure.ac | 13 ++++
12 src/libqmi-glib/Makefile.am | 4 +-
13 src/libqmi-glib/qmi-device.c | 156 ++++++++++++++++++++++++++++++++++++++++++-
14 src/libqmi-glib/qmi-device.h | 4 +-
15 4 files changed, 172 insertions(+), 5 deletions(-)
16
17diff --git a/configure.ac b/configure.ac
18index 3e05993..fe6225e 100644
19--- a/configure.ac
20+++ b/configure.ac
21@@ -95,6 +95,18 @@ fi
22
23 AM_CONDITIONAL([QMI_USERNAME_ENABLED], [test "x$QMI_USERNAME_ENABLED" = "xyes"])
24
25+# MBIM QMUX service support
26+AC_ARG_ENABLE(mbim-qmux,
27+ AS_HELP_STRING([--enable-mbim-qmux], [support QMI over MBIM QMUX service]))
28+if test -n "$enable_mbim_qmux"; then
29+ PKG_CHECK_MODULES(MBIM, mbim-glib >= 1.13)
30+ MBIM_CFLAGS="$MBIM_CFLAGS -DMBIM_QMUX"
31+ AC_SUBST(MBIM_CFLAGS)
32+ AC_SUBST(MBIM_LIBS)
33+fi
34+
35+AM_CONDITIONAL(MBIM_QMUX, [test -n "$MBIM_CFLAGS"])
36+
37 # udev base directory
38 AC_ARG_WITH(udev-base-dir, AS_HELP_STRING([--with-udev-base-dir=DIR], [where udev base directory is]))
39 if test -n "$with_udev_base_dir" ; then
40@@ -146,4 +158,5 @@ echo "
41 udev base directory: ${UDEV_BASE_DIR}
42 Documentation: ${enable_gtk_doc}
43 QMI username: ${QMI_USERNAME_ENABLED} (${QMI_USERNAME})
44+ QMUX over MBIM: ${enable_mbim_qmux}
45 "
46diff --git a/src/libqmi-glib/Makefile.am b/src/libqmi-glib/Makefile.am
47index b24e3ae..6ff4e66 100644
48--- a/src/libqmi-glib/Makefile.am
49+++ b/src/libqmi-glib/Makefile.am
50@@ -5,6 +5,7 @@ lib_LTLIBRARIES = libqmi-glib.la
51
52 libqmi_glib_la_CPPFLAGS = \
53 $(GLIB_CFLAGS) \
54+ $(MBIM_CFLAGS) \
55 -I$(top_srcdir) \
56 -I$(top_builddir) \
57 -I$(top_srcdir)/src/libqmi-glib \
58@@ -39,7 +40,8 @@ libqmi_glib_la_SOURCES = \
59
60 libqmi_glib_la_LIBADD = \
61 ${top_builddir}/src/libqmi-glib/generated/libqmi-glib-generated.la \
62- $(GLIB_LIBS)
63+ $(GLIB_LIBS) \
64+ $(MBIM_LIBS)
65
66 libqmi_glib_la_LDFLAGS = \
67 -version-info $(QMI_GLIB_LT_CURRENT):$(QMI_GLIB_LT_REVISION):$(QMI_GLIB_LT_AGE)
68diff --git a/src/libqmi-glib/qmi-device.c b/src/libqmi-glib/qmi-device.c
69index c4abbbc..6c46bca 100644
70--- a/src/libqmi-glib/qmi-device.c
71+++ b/src/libqmi-glib/qmi-device.c
72@@ -32,6 +32,10 @@
73 #include <gio/gunixoutputstream.h>
74 #include <gio/gunixsocketaddress.h>
75
76+#ifdef MBIM_QMUX
77+#include <libmbim-glib.h>
78+#endif
79+
80 #include "qmi-device.h"
81 #include "qmi-message.h"
82 #include "qmi-ctl.h"
83@@ -92,6 +96,10 @@ struct _QmiDevicePrivate {
84 gchar *path_display;
85 gboolean no_file_check;
86 gchar *proxy_path;
87+ gboolean mbim_qmux;
88+#ifdef MBIM_QMUX
89+ MbimDevice *mbimdev;
90+#endif
91
92 /* WWAN interface */
93 gboolean no_wwan_check;
94@@ -1689,7 +1697,6 @@ input_ready_cb (GInputStream *istream,
95 self->priv->buffer = g_byte_array_sized_new (r);
96 g_byte_array_append (self->priv->buffer, buffer, r);
97
98- /* Try to parse input messages */
99 parse_response (self);
100
101 return TRUE;
102@@ -2134,6 +2141,56 @@ internal_proxy_open_ready (QmiClientCtl *client_ctl,
103 device_open_context_step (ctx);
104 }
105
106+#ifdef MBIM_QMUX
107+static void
108+mbim_device_open_ready (MbimDevice *dev,
109+ GAsyncResult *res,
110+ DeviceOpenContext *ctx)
111+{
112+ GError *error = NULL;
113+
114+ if (!mbim_device_open_finish (dev, res, &error)) {
115+ g_simple_async_result_take_error (ctx->result, error);
116+ device_open_context_complete_and_free (ctx);
117+ return;
118+ }
119+ g_debug ("[%s] MBIM device Open..",
120+ ctx->self->priv->path_display);
121+
122+ /* Go on */
123+ ctx->step++;
124+ device_open_context_step (ctx);
125+ return;
126+}
127+
128+static void
129+mbim_device_new_ready (GObject *source,
130+ GAsyncResult *res,
131+ DeviceOpenContext *ctx)
132+{
133+ MbimDeviceOpenFlags open_flags = MBIM_DEVICE_OPEN_FLAGS_NONE;
134+ GError *error = NULL;
135+ MbimDevice *device;
136+
137+ if (ctx->flags & QMI_DEVICE_OPEN_FLAGS_PROXY)
138+ open_flags |= MBIM_DEVICE_OPEN_FLAGS_PROXY;
139+ device = mbim_device_new_finish (res, &error);
140+ if (!device) {
141+ g_simple_async_result_take_error (ctx->result, error);
142+ device_open_context_complete_and_free (ctx);
143+ return;
144+ }
145+ ctx->self->priv->mbimdev = device;
146+
147+ mbim_device_open_full(device,
148+ open_flags,
149+ 30,
150+ ctx->cancellable,
151+ (GAsyncReadyCallback)mbim_device_open_ready,
152+ ctx);
153+}
154+#endif
155+
156 static void
157 create_iostream_ready (QmiDevice *self,
158 GAsyncResult *res,
159@@ -2166,6 +2223,20 @@ device_open_context_step (DeviceOpenContext *ctx)
160 /* Fall down */
161
162 case DEVICE_OPEN_CONTEXT_STEP_CREATE_IOSTREAM:
163+#ifdef MBIM_QMUX
164+ if (ctx->flags & QMI_DEVICE_OPEN_FLAGS_MBIM) {
165+ GFile *file;
166+
167+ ctx->self->priv->mbim_qmux = TRUE;
168+ file = g_file_new_for_path (ctx->self->priv->path);
169+ mbim_device_new (file,
170+ ctx->cancellable,
171+ (GAsyncReadyCallback)mbim_device_new_ready,
172+ ctx);
173+ g_object_unref (file);
174+ return;
175+ }
176+#endif
177 create_iostream (ctx->self,
178 !!(ctx->flags & QMI_DEVICE_OPEN_FLAGS_PROXY),
179 (GAsyncReadyCallback)create_iostream_ready,
180@@ -2174,7 +2245,8 @@ device_open_context_step (DeviceOpenContext *ctx)
181
182 case DEVICE_OPEN_CONTEXT_STEP_FLAGS_PROXY:
183 /* Initialize communication with proxy? */
184- if (ctx->flags & QMI_DEVICE_OPEN_FLAGS_PROXY) {
185+ if (ctx->flags & QMI_DEVICE_OPEN_FLAGS_PROXY &&
186+ !(ctx->flags & QMI_DEVICE_OPEN_FLAGS_MBIM)) {
187 QmiMessageCtlInternalProxyOpenInput *input;
188
189 input = qmi_message_ctl_internal_proxy_open_input_new ();
190@@ -2369,6 +2441,21 @@ destroy_iostream (QmiDevice *self,
191 return TRUE;
192 }
193
194+#ifdef MBIM_QMUX
195+static void
196+mbim_device_close_ready (MbimDevice *dev,
197+ GAsyncResult *res)
198+{
199+ GError *error = NULL;
200+
201+ if (!mbim_device_close_finish (dev, res, &error)) {
202+ g_printerr ("error: couldn't close device: %s", error->message);
203+ g_error_free (error);
204+ } else
205+ g_debug ("Device closed");
206+}
207+#endif
208+
209 /**
210 * qmi_device_close:
211 * @self: a #QmiDevice
212@@ -2386,6 +2473,15 @@ qmi_device_close (QmiDevice *self,
213 {
214 g_return_val_if_fail (QMI_IS_DEVICE (self), FALSE);
215
216+#ifdef MBIM_QMUX
217+ if (self->priv->mbim_qmux)
218+ mbim_device_close (self->priv->mbimdev,
219+ 15,
220+ NULL,
221+ (GAsyncReadyCallback) mbim_device_close_ready,
222+ NULL);
223+ else
224+#endif
225 if (!destroy_iostream (self, error)) {
226 g_prefix_error (error, "Cannot close QMI device: ");
227 return FALSE;
228@@ -2394,6 +2490,42 @@ qmi_device_close (QmiDevice *self,
229 return TRUE;
230 }
231
232+#ifdef MBIM_QMUX
233+static void
234+mbim_device_command_ready (MbimDevice *dev,
235+ GAsyncResult *res,
236+ QmiDevice *qmidev)
237+{
238+ MbimMessage *response;
239+ GError *error = NULL;
240+ const guint8 *buf;
241+ guint32 len;
242+
243+ response = mbim_device_command_finish (dev, res, &error);
244+ if (!response || !mbim_message_response_get_result (response, MBIM_MESSAGE_TYPE_COMMAND_DONE, &error)) {
245+ g_prefix_error (&error, "MBIM error: ");
246+ // transaction_complete_and_free (tr, NULL, error);
247+ g_error_free (error);
248+ mbim_message_unref (response);
249+ return;
250+ }
251+
252+ g_debug ("[%s] Received MBIM message\n", qmidev->priv->path_display);
253+
254+
255+ /* get the information buffer */
256+ buf = mbim_message_command_done_get_raw_information_buffer (response, &len);
257+ if (!G_UNLIKELY (qmidev->priv->buffer))
258+ qmidev->priv->buffer = g_byte_array_sized_new (len);
259+ g_byte_array_append (qmidev->priv->buffer, buf, len);
260+
261+ /* and parse it as QMI */
262+ parse_response(qmidev);
263+ mbim_message_unref (response);
264+ return;
265+}
266+#endif
267+
268 /*****************************************************************************/
269 /* Command */
270
271@@ -2462,7 +2594,7 @@ qmi_device_command (QmiDevice *self,
272 tr = transaction_new (self, message, cancellable, callback, user_data);
273
274 /* Device must be open */
275- if (!self->priv->istream || !self->priv->ostream) {
276+ if ((!self->priv->istream || !self->priv->ostream) && !self->priv->mbim_qmux) {
277 error = g_error_new (QMI_CORE_ERROR,
278 QMI_CORE_ERROR_WRONG_STATE,
279 "Device must be open to send commands");
280@@ -2531,6 +2663,24 @@ qmi_device_command (QmiDevice *self,
281 g_free (printable);
282 }
283
284+#ifdef MBIM_QMUX
285+ /* wrap QMUX in MBIM? */
286+ if (self->priv->mbim_qmux) {
287+ MbimMessage *mbim;
288+
289+ mbim = (mbim_message_qmi_msg_set_new (raw_message_len, raw_message, &error));
290+ mbim_device_command (self->priv->mbimdev,
291+ mbim,
292+ 30,
293+ NULL, /* cancellable */
294+ (GAsyncReadyCallback)mbim_device_command_ready,
295+ self);
296+ g_debug ("[%s] Message sent as MBIM\n", self->priv->path_display);
297+
298+ /* FIXME: check errors, set proper MBIM TID */
299+ return;
300+ }
301+#endif
302 if (!g_output_stream_write_all (self->priv->ostream,
303 raw_message,
304 raw_message_len,
305diff --git a/src/libqmi-glib/qmi-device.h b/src/libqmi-glib/qmi-device.h
306index 58651e1..957efac 100644
307--- a/src/libqmi-glib/qmi-device.h
308+++ b/src/libqmi-glib/qmi-device.h
309@@ -97,6 +97,7 @@ gboolean qmi_device_is_open (QmiDevice *self);
310 * @QMI_DEVICE_OPEN_FLAGS_NET_QOS_HEADER: set network port to transmit/receive QoS headers; mutually exclusive with @QMI_DEVICE_OPEN_FLAGS_NET_NO_QOS_HEADER
311 * @QMI_DEVICE_OPEN_FLAGS_NET_NO_QOS_HEADER: set network port to not transmit/receive QoS headers; mutually exclusive with @QMI_DEVICE_OPEN_FLAGS_NET_QOS_HEADER
312 * @QMI_DEVICE_OPEN_FLAGS_PROXY: Try to open the port through the 'qmi-proxy'.
313+ * @QMI_DEVICE_OPEN_FLAGS_MBIM: open an MBIM port with QMUX tunneling service
314 *
315 * Flags to specify which actions to be performed when the device is open.
316 */
317@@ -108,7 +109,8 @@ typedef enum {
318 QMI_DEVICE_OPEN_FLAGS_NET_RAW_IP = 1 << 3,
319 QMI_DEVICE_OPEN_FLAGS_NET_QOS_HEADER = 1 << 4,
320 QMI_DEVICE_OPEN_FLAGS_NET_NO_QOS_HEADER = 1 << 5,
321- QMI_DEVICE_OPEN_FLAGS_PROXY = 1 << 6
322+ QMI_DEVICE_OPEN_FLAGS_PROXY = 1 << 6,
323+ QMI_DEVICE_OPEN_FLAGS_MBIM = 1 << 7
324 } QmiDeviceOpenFlags;
325
326 void qmi_device_open (QmiDevice *self,
327--
3282.1.4
329