summaryrefslogtreecommitdiff
path: root/patches/attachment-0001.patch
blob: 54882d442a60f7b61ecb86ac214bbe96438b4bdc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
From 9550bd568371995acca003d6250ba4535db7d59f Mon Sep 17 00:00:00 2001
From: Emil Ljungdahl <emil.ljungdahl@wisi.se>
Date: Wed, 6 Apr 2016 19:25:27 +0200
Subject: [PATCH 3/3] Avoid affecting the padding behavior for other services
 than QMI

---
 build-aux/mbim-codegen/Message.py       |  9 +++++----
 build-aux/mbim-codegen/Struct.py        |  9 +++++----
 data/mbim-service-qmi.json              |  6 ++++--
 src/libmbim-glib/mbim-message-private.h |  4 ++--
 src/libmbim-glib/mbim-message.c         | 10 +++++-----
 5 files changed, 21 insertions(+), 17 deletions(-)

diff --git a/build-aux/mbim-codegen/Message.py b/build-aux/mbim-codegen/Message.py
index e66335d..a569685 100644
--- a/build-aux/mbim-codegen/Message.py
+++ b/build-aux/mbim-codegen/Message.py
@@ -381,6 +381,7 @@ class Message:
             translations['struct'] = field['struct-type'] if 'struct-type' in field else ''
             translations['struct_underscore'] = utils.build_underscore_name_from_camelcase (translations['struct'])
             translations['array_size'] = field['array-size'] if 'array-size' in field else ''
+            translations['pad_array'] = field['pad-array'] if 'pad-array' in field else 'TRUE'
 
             inner_template = ''
             if 'available-if' in field:
@@ -394,13 +395,13 @@ class Message:
                 inner_template += ('    {\n')
 
             if field['format'] == 'byte-array':
-                inner_template += ('        _mbim_message_command_builder_append_byte_array (builder, FALSE, FALSE, TRUE, ${field}, ${array_size});\n')
+                inner_template += ('        _mbim_message_command_builder_append_byte_array (builder, FALSE, FALSE, ${pad_array}, ${field}, ${array_size});\n')
             elif field['format'] == 'unsized-byte-array':
-                inner_template += ('        _mbim_message_command_builder_append_byte_array (builder, FALSE, FALSE, FALSE, ${field}, ${field}_size);\n')
+                inner_template += ('        _mbim_message_command_builder_append_byte_array (builder, FALSE, FALSE, ${pad_array}, ${field}, ${field}_size);\n')
             elif field['format'] == 'ref-byte-array':
-                inner_template += ('        _mbim_message_command_builder_append_byte_array (builder, TRUE, TRUE, TRUE, ${field}, ${field}_size);\n')
+                inner_template += ('        _mbim_message_command_builder_append_byte_array (builder, TRUE, TRUE, ${pad_array}, ${field}, ${field}_size);\n')
             elif field['format'] == 'ref-byte-array-no-offset':
-                inner_template += ('        _mbim_message_command_builder_append_byte_array (builder, FALSE, TRUE, TRUE, ${field}, ${field}_size);\n')
+                inner_template += ('        _mbim_message_command_builder_append_byte_array (builder, FALSE, TRUE, ${pad_array}, ${field}, ${field}_size);\n')
             elif field['format'] == 'uuid':
                 inner_template += ('        _mbim_message_command_builder_append_uuid (builder, ${field});\n')
             elif field['format'] == 'guint32':
diff --git a/build-aux/mbim-codegen/Struct.py b/build-aux/mbim-codegen/Struct.py
index 8797f3a..84570de 100644
--- a/build-aux/mbim-codegen/Struct.py
+++ b/build-aux/mbim-codegen/Struct.py
@@ -494,18 +494,19 @@ class Struct:
             translations['field'] = utils.build_underscore_name_from_camelcase(field['name'])
             translations['array_size'] = field['array-size'] if 'array-size' in field else ''
             translations['array_size_field'] = utils.build_underscore_name_from_camelcase(field['array-size-field']) if 'array-size-field' in field else ''
+            translations['pad_array'] = field['pad-array'] if 'pad-array' in field else 'TRUE'
 
             if field['format'] == 'uuid':
                 inner_template = ('    _mbim_struct_builder_append_uuid (builder, &(value->${field}));\n')
             elif field['format'] == 'byte-array':
-                inner_template = ('    _mbim_struct_builder_append_byte_array (builder, FALSE, FALSE, TRUE, value->${field}, ${array_size});\n')
+                inner_template = ('    _mbim_struct_builder_append_byte_array (builder, FALSE, FALSE, ${pad_array}, value->${field}, ${array_size});\n')
             elif field['format'] == 'unsized-byte-array':
-                inner_template = ('    _mbim_struct_builder_append_byte_array (builder, FALSE, FALSE, FALSE, value->${field}, value->${field}_size);\n')
+                inner_template = ('    _mbim_struct_builder_append_byte_array (builder, FALSE, FALSE, ${pad_array}, value->${field}, value->${field}_size);\n')
             elif field['format'] == 'ref-byte-array':
                 if 'array-size-field' in field:
-                    inner_template = ('    _mbim_struct_builder_append_byte_array (builder, TRUE, FALSE, TRUE, value->${field}, value->${array_size_field});\n')
+                    inner_template = ('    _mbim_struct_builder_append_byte_array (builder, TRUE, FALSE, ${pad_array}, value->${field}, value->${array_size_field});\n')
                 else:
-                    inner_template = ('    _mbim_struct_builder_append_byte_array (builder, TRUE, TRUE, TRUE, value->${field}, value->${field}_size);\n')
+                    inner_template = ('    _mbim_struct_builder_append_byte_array (builder, TRUE, TRUE, ${pad_array}, value->${field}, value->${field}_size);\n')
             elif field['format'] == 'guint32':
                 inner_template = ('    _mbim_struct_builder_append_guint32 (builder, value->${field});\n')
             elif field['format'] == 'guint32-array':
diff --git a/data/mbim-service-qmi.json b/data/mbim-service-qmi.json
index b764d01..c11857f 100644
--- a/data/mbim-service-qmi.json
+++ b/data/mbim-service-qmi.json
@@ -9,7 +9,9 @@
       "service"  : "QMI",
       "type"     : "Command",
       "set"      : [ { "name"      : "QmiMsg",
-                       "format"    : "unsized-byte-array" } ],
+                       "format"    : "unsized-byte-array",
+                       "pad-array" : "FALSE" } ],
       "response" : [ { "name"      : "QMUX",
-                       "format"    : "unsized-byte-array" } ] }
+                       "format"    : "unsized-byte-array",
+                       "pad-array" : "FALSE" } ] }
 ]
diff --git a/src/libmbim-glib/mbim-message-private.h b/src/libmbim-glib/mbim-message-private.h
index 0082026..79071d8 100644
--- a/src/libmbim-glib/mbim-message-private.h
+++ b/src/libmbim-glib/mbim-message-private.h
@@ -177,7 +177,7 @@ GByteArray        *_mbim_struct_builder_complete             (MbimStructBuilder
 void               _mbim_struct_builder_append_byte_array    (MbimStructBuilder *builder,
                                                               gboolean           with_offset,
                                                               gboolean           with_length,
-                                                              gboolean           permit_padding,
+                                                              gboolean           pad_buffer,
                                                               const guint8      *buffer,
                                                               guint32            buffer_len);
 void               _mbim_struct_builder_append_uuid          (MbimStructBuilder *builder,
@@ -226,7 +226,7 @@ MbimMessage               *_mbim_message_command_builder_complete             (M
 void                       _mbim_message_command_builder_append_byte_array    (MbimMessageCommandBuilder *builder,
                                                                                gboolean                   with_offset,
                                                                                gboolean                   with_length,
-                                                                               gboolean                   permit_padding,
+                                                                               gboolean                   pad_buffer,
                                                                                const guint8              *buffer,
                                                                                guint32                    buffer_len);
 void                       _mbim_message_command_builder_append_uuid          (MbimMessageCommandBuilder *builder,
diff --git a/src/libmbim-glib/mbim-message.c b/src/libmbim-glib/mbim-message.c
index ad67059..1a0d492 100644
--- a/src/libmbim-glib/mbim-message.c
+++ b/src/libmbim-glib/mbim-message.c
@@ -492,7 +492,7 @@ void
 _mbim_struct_builder_append_byte_array (MbimStructBuilder *builder,
                                         gboolean           with_offset,
                                         gboolean           with_length,
-                                        gboolean           permit_padding,
+                                        gboolean           pad_buffer,
                                         const guint8      *buffer,
                                         guint32            buffer_len)
 {
@@ -502,7 +502,7 @@ _mbim_struct_builder_append_byte_array (MbimStructBuilder *builder,
      */
     if (!with_offset && !with_length) {
         g_byte_array_append (builder->fixed_buffer, buffer, buffer_len);
-        if(permit_padding) {
+        if(pad_buffer) {
             while (buffer_len % 4 != 0) {
                 const guint8 padding = 0;
 
@@ -554,7 +554,7 @@ _mbim_struct_builder_append_byte_array (MbimStructBuilder *builder,
         g_byte_array_append (builder->variable_buffer, (const guint8 *)buffer, (guint)buffer_len);
 
         /* Note: adding zero padding causes trouble for QMI service */
-        if(permit_padding) {
+        if(pad_buffer) {
             while (buffer_len % 4 != 0) {
                 const guint8 padding = 0;
 
@@ -830,11 +830,11 @@ void
 _mbim_message_command_builder_append_byte_array (MbimMessageCommandBuilder *builder,
                                                  gboolean                   with_offset,
                                                  gboolean                   with_length,
-                                                 gboolean                   permit_padding,
+                                                 gboolean                   pad_buffer,
                                                  const guint8              *buffer,
                                                  guint32                    buffer_len)
 {
-    _mbim_struct_builder_append_byte_array (builder->contents_builder, with_offset, with_length, permit_padding, buffer, buffer_len);
+    _mbim_struct_builder_append_byte_array (builder->contents_builder, with_offset, with_length, pad_buffer, buffer, buffer_len);
 }
 
 void
-- 
1.9.1