Message/TLV builder API

Aleksander Morgado aleksander at aleksander.es
Fri Oct 10 05:13:42 PDT 2014


On Thu, Oct 9, 2014 at 5:42 PM, Aleksander Morgado
<aleksander at aleksander.es> wrote:
> The qmi_utils_write_{something}_to_buffer() methods are really a bit
> error prone, as the caller needs to make sure that there is enough
> space in the buffer to write the variable that is being written, and
> failure to do so would make some nasty assert()s.
>
> I've now developed a new TLV writer API which does bounds checking and
> error reporting, and also changed the libqmi implementation to avoid
> relying on fixed-size stack buffers. We now rely on GByteArray to grow
> the QmiMessage as we're adding more contents to the TLV. Note that
> there won't be one realloc() per qmi_message_tlv_write_{something}()
> call, as GByteArray does internally reallocs to the closest power-of-2
> IIRC.
>
> This work is in the 'aleksander/tlv-api' branch in upstream git.
>
> This is WIP, but comments on the API are greatly appreciated. Relevant
> commit is:
> http://cgit.freedesktop.org/libqmi/commit/?h=aleksander/tlv-api&id=5b223047864b0ae0f423d33ea284df5b01eacb57
>
> I'm also going to update the TLV reader API, and end up with all those
> qmi_utils_read/write methods deprecated in the API.

Also wrote now the TLV reader API, and updated qmi-codegen with
several changes. There is no longer TLV validation() methods before
reading the TLV contents. Instead, we just try to read one by one the
fields, checking for out-of-TLV reads, and flag the TLV as unavailable
if there is any error reading.

http://cgit.freedesktop.org/libqmi/log/?h=aleksander/tlv-api


-- 
Aleksander
https://aleksander.es


More information about the libqmi-devel mailing list