summaryrefslogtreecommitdiff
path: root/patches/attachment-0003.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patches/attachment-0003.patch')
-rw-r--r--patches/attachment-0003.patch446
1 files changed, 446 insertions, 0 deletions
diff --git a/patches/attachment-0003.patch b/patches/attachment-0003.patch
new file mode 100644
index 00000000..35923a90
--- /dev/null
+++ b/patches/attachment-0003.patch
@@ -0,0 +1,446 @@
1>From 35f6f9c86c3dc66f2855b513e389a99bbcbb74c4 Mon Sep 17 00:00:00 2001
2From: Collin McMillan <cmc@nd.edu>
3Date: Mon, 4 Apr 2016 11:33:46 +0200
4Subject: [PATCH] QMI via MBIM
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 build-aux/mbim-codegen/Message.py | 8 ++++----
12 build-aux/mbim-codegen/Struct.py | 8 ++++----
13 data/Makefile.am | 3 ++-
14 src/libmbim-glib/generated/Makefile.am | 18 +++++++++++++++---
15 src/libmbim-glib/libmbim-glib.h | 1 +
16 src/libmbim-glib/mbim-cid.c | 25 +++++++++++++++++++++----
17 src/libmbim-glib/mbim-cid.h | 12 ++++++++++++
18 src/libmbim-glib/mbim-message-private.h | 2 ++
19 src/libmbim-glib/mbim-message.c | 31 +++++++++++++++++++------------
20 src/libmbim-glib/mbim-uuid.c | 18 ++++++++++++++++--
21 src/libmbim-glib/mbim-uuid.h | 11 +++++++++++
22 11 files changed, 107 insertions(+), 30 deletions(-)
23
24diff --git a/build-aux/mbim-codegen/Message.py b/build-aux/mbim-codegen/Message.py
25index aa4e7b7..e66335d 100644
26--- a/build-aux/mbim-codegen/Message.py
27+++ b/build-aux/mbim-codegen/Message.py
28@@ -394,13 +394,13 @@ class Message:
29 inner_template += (' {\n')
30
31 if field['format'] == 'byte-array':
32- inner_template += (' _mbim_message_command_builder_append_byte_array (builder, FALSE, FALSE, ${field}, ${array_size});\n')
33+ inner_template += (' _mbim_message_command_builder_append_byte_array (builder, FALSE, FALSE, TRUE, ${field}, ${array_size});\n')
34 elif field['format'] == 'unsized-byte-array':
35- inner_template += (' _mbim_message_command_builder_append_byte_array (builder, FALSE, FALSE, ${field}, ${field}_size);\n')
36+ inner_template += (' _mbim_message_command_builder_append_byte_array (builder, FALSE, FALSE, FALSE, ${field}, ${field}_size);\n')
37 elif field['format'] == 'ref-byte-array':
38- inner_template += (' _mbim_message_command_builder_append_byte_array (builder, TRUE, TRUE, ${field}, ${field}_size);\n')
39+ inner_template += (' _mbim_message_command_builder_append_byte_array (builder, TRUE, TRUE, TRUE, ${field}, ${field}_size);\n')
40 elif field['format'] == 'ref-byte-array-no-offset':
41- inner_template += (' _mbim_message_command_builder_append_byte_array (builder, FALSE, TRUE, ${field}, ${field}_size);\n')
42+ inner_template += (' _mbim_message_command_builder_append_byte_array (builder, FALSE, TRUE, TRUE, ${field}, ${field}_size);\n')
43 elif field['format'] == 'uuid':
44 inner_template += (' _mbim_message_command_builder_append_uuid (builder, ${field});\n')
45 elif field['format'] == 'guint32':
46diff --git a/build-aux/mbim-codegen/Struct.py b/build-aux/mbim-codegen/Struct.py
47index 495e22f..8797f3a 100644
48--- a/build-aux/mbim-codegen/Struct.py
49+++ b/build-aux/mbim-codegen/Struct.py
50@@ -498,14 +498,14 @@ class Struct:
51 if field['format'] == 'uuid':
52 inner_template = (' _mbim_struct_builder_append_uuid (builder, &(value->${field}));\n')
53 elif field['format'] == 'byte-array':
54- inner_template = (' _mbim_struct_builder_append_byte_array (builder, FALSE, FALSE, value->${field}, ${array_size});\n')
55+ inner_template = (' _mbim_struct_builder_append_byte_array (builder, FALSE, FALSE, TRUE, value->${field}, ${array_size});\n')
56 elif field['format'] == 'unsized-byte-array':
57- inner_template = (' _mbim_struct_builder_append_byte_array (builder, FALSE, FALSE, value->${field}, value->${field}_size);\n')
58+ inner_template = (' _mbim_struct_builder_append_byte_array (builder, FALSE, FALSE, FALSE, value->${field}, value->${field}_size);\n')
59 elif field['format'] == 'ref-byte-array':
60 if 'array-size-field' in field:
61- inner_template = (' _mbim_struct_builder_append_byte_array (builder, TRUE, FALSE, value->${field}, value->${array_size_field});\n')
62+ inner_template = (' _mbim_struct_builder_append_byte_array (builder, TRUE, FALSE, TRUE, value->${field}, value->${array_size_field});\n')
63 else:
64- inner_template = (' _mbim_struct_builder_append_byte_array (builder, TRUE, TRUE, value->${field}, value->${field}_size);\n')
65+ inner_template = (' _mbim_struct_builder_append_byte_array (builder, TRUE, TRUE, TRUE, value->${field}, value->${field}_size);\n')
66 elif field['format'] == 'guint32':
67 inner_template = (' _mbim_struct_builder_append_guint32 (builder, value->${field});\n')
68 elif field['format'] == 'guint32-array':
69diff --git a/data/Makefile.am b/data/Makefile.am
70index 111e028..8c8891a 100644
71--- a/data/Makefile.am
72+++ b/data/Makefile.am
73@@ -10,4 +10,5 @@ EXTRA_DIST = \
74 mbim-service-dss.json \
75 mbim-service-ms-firmware-id.json \
76 mbim-service-ms-host-shutdown.json \
77- mbim-service-proxy-control.json
78+ mbim-service-proxy-control.json \
79+ mbim-service-qmi.json
80diff --git a/src/libmbim-glib/generated/Makefile.am b/src/libmbim-glib/generated/Makefile.am
81index ce81a71..c8b153a 100644
82--- a/src/libmbim-glib/generated/Makefile.am
83+++ b/src/libmbim-glib/generated/Makefile.am
84@@ -12,7 +12,8 @@ GENERATED_H = \
85 mbim-dss.h \
86 mbim-ms-firmware-id.h \
87 mbim-ms-host-shutdown.h \
88- mbim-proxy-control.h
89+ mbim-proxy-control.h \
90+ mbim-qmi.h
91
92 GENERATED_C = \
93 mbim-error-types.c \
94@@ -27,7 +28,8 @@ GENERATED_C = \
95 mbim-dss.c \
96 mbim-ms-firmware-id.c \
97 mbim-ms-host-shutdown.c \
98- mbim-proxy-control.c
99+ mbim-proxy-control.c \
100+ mbim-qmi.c
101
102 GENERATED_SECTIONS = \
103 mbim-basic-connect.sections \
104@@ -39,7 +41,8 @@ GENERATED_SECTIONS = \
105 mbim-dss.sections \
106 mbim-ms-firmware-id.sections \
107 mbim-ms-host-shutdown.sections \
108- mbim-proxy-control.sections
109+ mbim-proxy-control.sections \
110+ mbim-qmi.sections
111
112 # Error types
113 mbim-error-types.h: $(top_srcdir)/src/libmbim-glib/mbim-errors.h $(top_srcdir)/build-aux/templates/mbim-error-types-template.h
114@@ -170,6 +173,15 @@ mbim-proxy-control.h mbim-proxy-control.c mbim-proxy-control.sections: $(top_src
115 --input $(top_srcdir)/data/mbim-service-proxy-control.json \
116 --output mbim-proxy-control
117
118+# QMI-over-MBIM service
119+mbim-qmi.h mbim-qmi.c mbim-qmi.sections: $(top_srcdir)/data/mbim-service-qmi.json $(top_srcdir)/build-aux/mbim-codegen/*.py $(top_srcdir)/build-aux/mbim-codegen/mbim-codegen
120+ $(AM_V_GEN) \
121+ rm -f mbim-qmi.h && \
122+ rm -f mbim-qmi.c && \
123+ $(top_srcdir)/build-aux/mbim-codegen/mbim-codegen \
124+ --input $(top_srcdir)/data/mbim-service-qmi.json \
125+ --output mbim-qmi
126+
127 BUILT_SOURCES = $(GENERATED_H) $(GENERATED_C)
128
129 nodist_libmbim_glib_generated_la_SOURCES = \
130diff --git a/src/libmbim-glib/libmbim-glib.h b/src/libmbim-glib/libmbim-glib.h
131index b41122b..88d0be8 100644
132--- a/src/libmbim-glib/libmbim-glib.h
133+++ b/src/libmbim-glib/libmbim-glib.h
134@@ -48,6 +48,7 @@
135 #include "mbim-dss.h"
136 #include "mbim-ms-firmware-id.h"
137 #include "mbim-ms-host-shutdown.h"
138+#include "mbim-qmi.h"
139
140 /* backwards compatibility */
141 #include "mbim-compat.h"
142diff --git a/src/libmbim-glib/mbim-cid.c b/src/libmbim-glib/mbim-cid.c
143index 50dc4f1..cbfd81e 100644
144--- a/src/libmbim-glib/mbim-cid.c
145+++ b/src/libmbim-glib/mbim-cid.c
146@@ -38,6 +38,9 @@ typedef struct {
147 gboolean notify;
148 } CidConfig;
149
150+/* Note: MBIM_SERVICE_LAST from mbim-uuid.c should probably be visible
151+ * here somehow, since MBIM_SERVICE_QMI must be used in the error checks */
152+
153 /* Note: index of the array is CID-1 */
154 #define MBIM_CID_BASIC_CONNECT_LAST MBIM_CID_BASIC_CONNECT_MULTICARRIER_PROVIDERS
155 static const CidConfig cid_basic_connect_config [MBIM_CID_BASIC_CONNECT_LAST] = {
156@@ -132,6 +135,12 @@ static const CidConfig cid_proxy_control_config [MBIM_CID_PROXY_CONTROL_LAST] =
157 { TRUE, FALSE, FALSE }, /* MBIM_CID_PROXY_CONTROL_CONFIGURATION */
158 };
159
160+/* Note: index of the array is CID-1 */
161+#define MBIM_CID_QMI_LAST MBIM_CID_QMI_MSG
162+static const CidConfig cid_qmi_config [MBIM_CID_QMI_LAST] = {
163+ { TRUE, FALSE, FALSE }, /* MBIM_CID_QMI_MSG */
164+};
165+
166 /**
167 * mbim_cid_can_set:
168 * @service: a #MbimService.
169@@ -149,7 +158,7 @@ mbim_cid_can_set (MbimService service,
170 g_return_val_if_fail (cid > 0, FALSE);
171 /* Known service required */
172 g_return_val_if_fail (service > MBIM_SERVICE_INVALID, FALSE);
173- g_return_val_if_fail (service <= MBIM_SERVICE_PROXY_CONTROL, FALSE);
174+ g_return_val_if_fail (service <= MBIM_SERVICE_QMI, FALSE);
175
176 switch (service) {
177 case MBIM_SERVICE_BASIC_CONNECT:
178@@ -172,6 +181,8 @@ mbim_cid_can_set (MbimService service,
179 return cid_ms_host_shutdown_config[cid - 1].set;
180 case MBIM_SERVICE_PROXY_CONTROL:
181 return cid_proxy_control_config[cid - 1].set;
182+ case MBIM_SERVICE_QMI:
183+ return cid_qmi_config[cid - 1].set;
184 default:
185 g_assert_not_reached ();
186 return FALSE;
187@@ -195,7 +206,7 @@ mbim_cid_can_query (MbimService service,
188 g_return_val_if_fail (cid > 0, FALSE);
189 /* Known service required */
190 g_return_val_if_fail (service > MBIM_SERVICE_INVALID, FALSE);
191- g_return_val_if_fail (service <= MBIM_SERVICE_PROXY_CONTROL, FALSE);
192+ g_return_val_if_fail (service <= MBIM_SERVICE_QMI, FALSE);
193
194 switch (service) {
195 case MBIM_SERVICE_BASIC_CONNECT:
196@@ -218,6 +229,8 @@ mbim_cid_can_query (MbimService service,
197 return cid_ms_host_shutdown_config[cid - 1].query;
198 case MBIM_SERVICE_PROXY_CONTROL:
199 return cid_proxy_control_config[cid - 1].query;
200+ case MBIM_SERVICE_QMI:
201+ return cid_qmi_config[cid - 1].query;
202 default:
203 g_assert_not_reached ();
204 return FALSE;
205@@ -241,7 +254,7 @@ mbim_cid_can_notify (MbimService service,
206 g_return_val_if_fail (cid > 0, FALSE);
207 /* Known service required */
208 g_return_val_if_fail (service > MBIM_SERVICE_INVALID, FALSE);
209- g_return_val_if_fail (service <= MBIM_SERVICE_PROXY_CONTROL, FALSE);
210+ g_return_val_if_fail (service <= MBIM_SERVICE_QMI, FALSE);
211
212 switch (service) {
213 case MBIM_SERVICE_BASIC_CONNECT:
214@@ -264,6 +277,8 @@ mbim_cid_can_notify (MbimService service,
215 return cid_ms_host_shutdown_config[cid - 1].notify;
216 case MBIM_SERVICE_PROXY_CONTROL:
217 return cid_proxy_control_config[cid - 1].notify;
218+ case MBIM_SERVICE_QMI:
219+ return cid_qmi_config[cid - 1].notify;
220 default:
221 g_assert_not_reached ();
222 return FALSE;
223@@ -288,7 +303,7 @@ mbim_cid_get_printable (MbimService service,
224 g_return_val_if_fail (cid > 0, NULL);
225 /* Known service required */
226 g_return_val_if_fail (service > MBIM_SERVICE_INVALID, NULL);
227- g_return_val_if_fail (service <= MBIM_SERVICE_PROXY_CONTROL, NULL);
228+ g_return_val_if_fail (service <= MBIM_SERVICE_QMI, NULL);
229
230 switch (service) {
231 case MBIM_SERVICE_BASIC_CONNECT:
232@@ -311,6 +326,8 @@ mbim_cid_get_printable (MbimService service,
233 return mbim_cid_ms_host_shutdown_get_string (cid);
234 case MBIM_SERVICE_PROXY_CONTROL:
235 return mbim_cid_proxy_control_get_string (cid);
236+ case MBIM_SERVICE_QMI:
237+ return mbim_cid_qmi_get_string (cid);
238 default:
239 g_assert_not_reached ();
240 return FALSE;
241diff --git a/src/libmbim-glib/mbim-cid.h b/src/libmbim-glib/mbim-cid.h
242index 3315340..36930cd 100644
243--- a/src/libmbim-glib/mbim-cid.h
244+++ b/src/libmbim-glib/mbim-cid.h
245@@ -219,6 +219,18 @@ typedef enum {
246 MBIM_CID_PROXY_CONTROL_CONFIGURATION = 1
247 } MbimCidProxyControl;
248
249+/**
250+ * MbimCidQmi:
251+ * @MBIM_CID_QMI_UNKNOWN: Unknown command.
252+ * @MBIM_CID_QMI_MSG: Configuration.
253+ *
254+ * MBIM commands in the %MBIM_SERVICE_QMI service.
255+ */
256+typedef enum {
257+ MBIM_CID_QMI_UNKNOWN = 0,
258+ MBIM_CID_QMI_MSG = 1
259+} MbimCidQmi;
260+
261 /* Command helpers */
262
263 gboolean mbim_cid_can_set (MbimService service,
264diff --git a/src/libmbim-glib/mbim-message-private.h b/src/libmbim-glib/mbim-message-private.h
265index b5606e0..0459d00 100644
266--- a/src/libmbim-glib/mbim-message-private.h
267+++ b/src/libmbim-glib/mbim-message-private.h
268@@ -177,6 +177,7 @@ GByteArray *_mbim_struct_builder_complete (MbimStructBuilder
269 void _mbim_struct_builder_append_byte_array (MbimStructBuilder *builder,
270 gboolean with_offset,
271 gboolean with_length,
272+ gboolean permit_padding,
273 const guint8 *buffer,
274 guint32 buffer_len);
275 void _mbim_struct_builder_append_uuid (MbimStructBuilder *builder,
276@@ -225,6 +226,7 @@ MbimMessage *_mbim_message_command_builder_complete (M
277 void _mbim_message_command_builder_append_byte_array (MbimMessageCommandBuilder *builder,
278 gboolean with_offset,
279 gboolean with_length,
280+ gboolean permit_padding,
281 const guint8 *buffer,
282 guint32 buffer_len);
283 void _mbim_message_command_builder_append_uuid (MbimMessageCommandBuilder *builder,
284diff --git a/src/libmbim-glib/mbim-message.c b/src/libmbim-glib/mbim-message.c
285index b625ee5..7ab28f0 100644
286--- a/src/libmbim-glib/mbim-message.c
287+++ b/src/libmbim-glib/mbim-message.c
288@@ -492,6 +492,7 @@ void
289 _mbim_struct_builder_append_byte_array (MbimStructBuilder *builder,
290 gboolean with_offset,
291 gboolean with_length,
292+ gboolean permit_padding,
293 const guint8 *buffer,
294 guint32 buffer_len)
295 {
296@@ -501,12 +502,14 @@ _mbim_struct_builder_append_byte_array (MbimStructBuilder *builder,
297 */
298 if (!with_offset && !with_length) {
299 g_byte_array_append (builder->fixed_buffer, buffer, buffer_len);
300- while (buffer_len % 4 != 0) {
301- const guint8 padding = 0;
302-
303- g_byte_array_append (builder->fixed_buffer, &padding, 1);
304- buffer_len++;
305- }
306+ if(permit_padding) {
307+ while (buffer_len % 4 != 0) {
308+ const guint8 padding = 0;
309+
310+ g_byte_array_append (builder->fixed_buffer, &padding, 1);
311+ buffer_len++;
312+ }
313+ }
314 return;
315 }
316
317@@ -550,12 +553,15 @@ _mbim_struct_builder_append_byte_array (MbimStructBuilder *builder,
318 if (buffer_len) {
319 g_byte_array_append (builder->variable_buffer, (const guint8 *)buffer, (guint)buffer_len);
320
321- while (buffer_len % 4 != 0) {
322- const guint8 padding = 0;
323+ /* Note: adding zero padding causes trouble for QMI service */
324+ if(permit_padding) {
325+ while (buffer_len % 4 != 0) {
326+ const guint8 padding = 0;
327
328- g_byte_array_append (builder->variable_buffer, &padding, 1);
329- buffer_len++;
330- }
331+ g_byte_array_append (builder->variable_buffer, &padding, 1);
332+ buffer_len++;
333+ }
334+ }
335 }
336 }
337
338@@ -824,10 +830,11 @@ void
339 _mbim_message_command_builder_append_byte_array (MbimMessageCommandBuilder *builder,
340 gboolean with_offset,
341 gboolean with_length,
342+ gboolean permit_padding,
343 const guint8 *buffer,
344 guint32 buffer_len)
345 {
346- _mbim_struct_builder_append_byte_array (builder->contents_builder, with_offset, with_length, buffer, buffer_len);
347+ _mbim_struct_builder_append_byte_array (builder->contents_builder, with_offset, with_length, permit_padding, buffer, buffer_len);
348 }
349
350 void
351diff --git a/src/libmbim-glib/mbim-uuid.c b/src/libmbim-glib/mbim-uuid.c
352index 6497645..cdc9ba3 100644
353--- a/src/libmbim-glib/mbim-uuid.c
354+++ b/src/libmbim-glib/mbim-uuid.c
355@@ -38,7 +38,7 @@
356 * This section defines the data type for unique identifiers.
357 */
358
359-#define MBIM_SERVICE_LAST MBIM_SERVICE_PROXY_CONTROL
360+#define MBIM_SERVICE_LAST MBIM_SERVICE_QMI
361
362 /*****************************************************************************/
363
364@@ -229,6 +229,15 @@ static const MbimUuid uuid_proxy_control = {
365 .e = { 0xd7, 0x1d , 0xbe, 0xfb, 0xb3, 0x9b }
366 };
367
368+/* Note: this UUID is likely to work only for Sierra modems */
369+static const MbimUuid uuid_qmi = {
370+ .a = { 0xd1, 0xa3, 0x0b, 0xc2 },
371+ .b = { 0xf9, 0x7a },
372+ .c = { 0x6e, 0x43 },
373+ .d = { 0xbf, 0x65 },
374+ .e = { 0xc7, 0xe2 , 0x4f, 0xb0, 0xf0, 0xd3 }
375+};
376+
377 static GList *mbim_custom_service_list = NULL;
378
379 typedef struct {
380@@ -367,7 +376,7 @@ mbim_uuid_from_service (MbimService service)
381 GList *l;
382
383 g_return_val_if_fail (service >= MBIM_SERVICE_INVALID &&
384- (service <= MBIM_SERVICE_PROXY_CONTROL ||
385+ (service <= MBIM_SERVICE_LAST ||
386 mbim_service_id_is_custom (service)),
387 &uuid_invalid);
388
389@@ -394,6 +403,8 @@ mbim_uuid_from_service (MbimService service)
390 return &uuid_ms_host_shutdown;
391 case MBIM_SERVICE_PROXY_CONTROL:
392 return &uuid_proxy_control;
393+ case MBIM_SERVICE_QMI:
394+ return &uuid_qmi;
395 default:
396 for (l = mbim_custom_service_list; l != NULL; l = l->next) {
397 if (service == ((MbimCustomService *)l->data)->service_id)
398@@ -446,6 +457,9 @@ mbim_uuid_to_service (const MbimUuid *uuid)
399 if (mbim_uuid_cmp (uuid, &uuid_proxy_control))
400 return MBIM_SERVICE_PROXY_CONTROL;
401
402+ if (mbim_uuid_cmp (uuid, &uuid_qmi))
403+ return MBIM_SERVICE_QMI;
404+
405 for (l = mbim_custom_service_list; l != NULL; l = l->next) {
406 if (mbim_uuid_cmp (&((MbimCustomService *)l->data)->uuid, uuid))
407 return ((MbimCustomService *)l->data)->service_id;
408diff --git a/src/libmbim-glib/mbim-uuid.h b/src/libmbim-glib/mbim-uuid.h
409index 91def98..d42a256 100644
410--- a/src/libmbim-glib/mbim-uuid.h
411+++ b/src/libmbim-glib/mbim-uuid.h
412@@ -71,6 +71,7 @@ gboolean mbim_uuid_from_printable (const gchar *str,
413 * @MBIM_SERVICE_MS_FIRMWARE_ID: Microsoft Firmware ID service.
414 * @MBIM_SERVICE_MS_HOST_SHUTDOWN: Microsoft Host Shutdown service.
415 * @MBIM_SERVICE_PROXY_CONTROL: Proxy Control service.
416+ * @MBIM_SERVICE_QMI: QMI-over-MBIM service.
417 *
418 * Enumeration of the generic MBIM services.
419 */
420@@ -86,6 +87,7 @@ typedef enum {
421 MBIM_SERVICE_MS_FIRMWARE_ID = 8,
422 MBIM_SERVICE_MS_HOST_SHUTDOWN = 9,
423 MBIM_SERVICE_PROXY_CONTROL = 10,
424+ MBIM_SERVICE_QMI = 11
425 /* Note: update MBIM_SERVICE_LAST when a new value is added */
426 } MbimService;
427
428@@ -188,6 +190,15 @@ typedef enum {
429 */
430 #define MBIM_UUID_PROXY_CONTROL mbim_uuid_from_service (MBIM_SERVICE_PROXY_CONTROL)
431
432+/**
433+ * MBIM_UUID_QMI:
434+ *
435+ * Get the UUID of the %MBIM_SERVICE_QMI service.
436+ *
437+ * Returns: (transfer none): a #MbimUuid.
438+ */
439+#define MBIM_UUID_QMI mbim_uuid_from_service (MBIM_SERVICE_QMI)
440+
441 const gchar *mbim_service_lookup_name (guint service);
442
443 guint mbim_register_custom_service (const MbimUuid *uuid,
444--
4452.1.4
446