From 69ea49f29e3e22d5de4e5fa09badff06cdabe9d9 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Mon, 16 May 2016 15:38:34 +0200 Subject: json! --- hel.nix | 5 +- patches/attachment-0001.patch | 158 ++++++++++++++++++++++++++++++++++++++++++ patches/attachment.patch | 34 +++++++++ 3 files changed, 193 insertions(+), 4 deletions(-) create mode 100644 patches/attachment-0001.patch create mode 100644 patches/attachment.patch diff --git a/hel.nix b/hel.nix index 44c3f279..c8f42f82 100644 --- a/hel.nix +++ b/hel.nix @@ -58,11 +58,8 @@ nixpkgs.config.packageOverrides = pkgs: rec { libmbim = pkgs.stdenv.lib.overrideDerivation pkgs.libmbim (attrs: { - patches = [ ./patches/attachment-0003.patch ]; + patches = [ ./patches/attachment-0003.patch ./patches/attachment.patch ./patches/attachment-0001.patch ]; buildInputs = attrs.buildInputs ++ [ pkgs.automake114x pkgs.autoconf ]; - postConfigure = '' - ${pkgs.findutils}/bin/find . -iname '*.json' - ''; }); libqmi = pkgs.stdenv.lib.overrideDerivation pkgs.libqmi (attrs: { patches = [ ./patches/attachment-0004.patch ./patches/attachment-0005.patch ]; diff --git a/patches/attachment-0001.patch b/patches/attachment-0001.patch new file mode 100644 index 00000000..54882d44 --- /dev/null +++ b/patches/attachment-0001.patch @@ -0,0 +1,158 @@ +From 9550bd568371995acca003d6250ba4535db7d59f Mon Sep 17 00:00:00 2001 +From: Emil Ljungdahl +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 + diff --git a/patches/attachment.patch b/patches/attachment.patch new file mode 100644 index 00000000..32d4b053 --- /dev/null +++ b/patches/attachment.patch @@ -0,0 +1,34 @@ +From 65d4a4bb0420794ece5082da2cac0b6771e75be7 Mon Sep 17 00:00:00 2001 +From: Emil Ljungdahl +Date: Wed, 6 Apr 2016 19:16:47 +0200 +Subject: [PATCH 2/3] Added json file lost in original qmi-over-mbim patch + +--- + data/mbim-service-qmi.json | 15 +++++++++++++++ + 1 file changed, 15 insertions(+) + create mode 100644 data/mbim-service-qmi.json + +diff --git a/data/mbim-service-qmi.json b/data/mbim-service-qmi.json +new file mode 100644 +index 0000000..b764d01 +--- /dev/null ++++ b/data/mbim-service-qmi.json +@@ -0,0 +1,15 @@ ++ ++[ ++ // ********************************************************************************* ++ { "type" : "Service", ++ "name" : "QMI" }, ++ ++ // ********************************************************************************* ++ { "name" : "msg", ++ "service" : "QMI", ++ "type" : "Command", ++ "set" : [ { "name" : "QmiMsg", ++ "format" : "unsized-byte-array" } ], ++ "response" : [ { "name" : "QMUX", ++ "format" : "unsized-byte-array" } ] } ++] +-- +1.9.1 + -- cgit v1.2.3