Commit Graph

16 Commits

Author SHA1 Message Date
Dan Williams e2f9d3d591 qmi-codegen: allow fields to be hidden with 'visible':'no'
We want to mark some TLV fields as reserved and not exposed through the
public API due to alignment or other issues.
2016-10-06 10:12:04 -05:00
Aleksander Morgado b9c3701e33 qmi-codegen: fix public struct type generation
This change triggers an API break.

When building structs to be included in the public header, we were just relying
on using the 'public_format' of each variable. This is an error, as the variable
may be more complex than just public/private. E.g. could be another struct, or
an array, or a fixed sized string, as in the example.

In particular, this bug currently affects one public type, where one of its
elements changes from being just a pointer to a string to a fixed sized array of
4 bytes.

The following type is changed from:

    typedef struct _QmiMessageNasGetCellLocationInfoOutputGeranInfoCellElement {
        guint32 cell_id;
        gchar * plmn;
        guint16 lac;
        guint16 geran_absolute_rf_channel_number;
        guint8 base_station_identity_code;
        guint16 rx_level;
    } QmiMessageNasGetCellLocationInfoOutputGeranInfoCellElement;

To:

    typedef struct _QmiMessageNasGetCellLocationInfoOutputGeranInfoCellElement {
        guint32 cell_id;
        gchar plmn[4];
        guint16 lac;
        guint16 geran_absolute_rf_channel_number;
        guint8 base_station_identity_code;
        guint16 rx_level;
    } QmiMessageNasGetCellLocationInfoOutputGeranInfoCellElement;

Thanks to Joseba Sanjuan <joseba.sanjuan@gmail.com> for finding the bug.
2014-12-12 09:21:15 +01:00
Aleksander Morgado b143b7f6ba qmi-codegen: use the new TLV reader API 2014-11-09 20:15:56 +01:00
Aleksander Morgado 654ad38ad9 qmi-codegen: use the new TLV builder API 2014-11-09 20:15:28 +01:00
Thomas Haller b439d6d13e qmi-codegen: avoid buffer overlow in emit_input_tlv_add()
https://bugzilla.redhat.com/show_bug.cgi?id=1031738

Reported-by: Florian Weimer <fweimer@redhat.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-08 10:50:39 +02:00
Aleksander Morgado e1193a99b7 qmi-codegen: handle 'gfloat' types 2014-05-28 12:39:00 +02:00
Dan Williams 01becf82d5 qmi-codegen: fix some python3 compatibility issues
Simple methods are no longer in the string module.
2012-12-17 11:37:31 -06:00
Aleksander Morgado d07c5e14b9 qmi-codegen: translate the values of enums/flags in traces 2012-11-02 13:13:47 +01:00
Aleksander Morgado 4c98ff41cc qmi-codegen: validate TLV before really reading it
Try to handle buggy firmware, or just make the library more robust, by
validating the read TLV before really reading it. If a TLV is not considered
valid, we just skip it for now.

E.g.: the "Detailed Service Status" TLV (0x21) in the "NAS Get Serving System"
message is supposed to be a sequence of 5 bytes, but some models (e.g. ZTE MF683)
end up sending only the first 4 bytes.
2012-10-30 20:42:59 +01:00
Aleksander Morgado fe7d46d49a libqmi-glib,utils: no need to pass endianness when reading/writing single bytes 2012-10-29 11:57:20 +01:00
Dan Williams cb5851e700 libqmi-glib,qmi-codegen: add endian-ness annotation capability
Some values are sent by the firmware in big endian byte order,
specifically IP addresses, which are sent in network byte order
(ie, big endian).  Add the ability to specify the byte order
the firmware handles the value as, and convert that to host
byte order when reading/writing QMI buffers.
2012-10-23 17:25:05 +02:00
Aleksander Morgado 148791b4ca docs: improve generated `libqmi-glib' documentation
Among the tons of fixes done here, we now generate some per-service .sections
file which we then concatenate to build the final libqmi-glib-sections.txt file.
2012-10-09 15:23:47 +02:00
Aleksander Morgado 6979e2752a qmi-codegen: handle uints of arbitrary sizes
The code generator can now handle uints of arbitrary sizes (<= guint64), which
are read into guint64 variables.
2012-07-04 16:00:39 +02:00
Aleksander Morgado 03aa6bc53c qmi-codegen: handle 64-bit signed/unsigned integers 2012-07-04 12:02:15 +02:00
Aleksander Morgado 4130a72091 qmi-codegen: let variables decide how the getter/setter methods pass them
And change the structs to be passed by reference.
2012-07-03 16:08:58 +02:00
Aleksander Morgado 2a511da7d3 qmi-codegen: refactor, don't use internal packed structs to match TLVs
This is a huge refactor to avoid using internal packed structs to match TLVs
from a raw byte buffer. There are cases where packed structs do not help, for
example when two variable-length fields (like strings) are found in the same
TLV.

Instead of packed structs, we'll read basic types one by one directly from the
raw byte buffer. With this new logic, struct and array variables are no more
than containers of other basic types. Each basic type, implemented as objects
inheriting from a base Variable type, knows how to read/write from/to the
raw buffer. Therefore, reading a struct is just about reading one by one each
of the fields in the struct; and reading an array is just about providing a
loop to read all the array elements one by one.

This greatly simplifies reading basic types like integers, as the implementation
is kept in a single place, regardless of having the integer as the only field
in the TLV or as a field of a struct TLV or as an element of an array TLV.

Strings are treated a bit differently. In string TLVs, the string is to be
considered to be as long as the TLV value itself. In struct TLVs with string
fields, the string is assumed to have a 1-byte length prefix which specifies
the length of the string field within the TLV.
2012-07-03 16:08:56 +02:00