diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2014-11-09 00:40:44 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2014-11-09 00:42:37 +0100 |
commit | 924f5d0e5b45765a571e64be34d9d34d3ddf1f31 (patch) | |
tree | bfcf915fab4f3b52572342af81961d45d0389e31 | |
parent | ce723135cabb20e79f23f93a885410762c73d3ef (diff) | |
download | external_libqmi-924f5d0e5b45765a571e64be34d9d34d3ddf1f31.zip external_libqmi-924f5d0e5b45765a571e64be34d9d34d3ddf1f31.tar.gz external_libqmi-924f5d0e5b45765a571e64be34d9d34d3ddf1f31.tar.bz2 |
libqmi,message: fix qmi_message_set_transaction_id() in non-CTL messages
The transaction ID in non-CTL messages wasn't being written properly when
qmi_message_set_transaction_id() was used. Internally this never happened, but
this method is part of the API, so could be a big issue for users.
-rw-r--r-- | src/libqmi-glib/qmi-message.c | 2 | ||||
-rw-r--r-- | src/libqmi-glib/test/test-message.c | 52 |
2 files changed, 53 insertions, 1 deletions
diff --git a/src/libqmi-glib/qmi-message.c b/src/libqmi-glib/qmi-message.c index ad3ad50..2c0905e 100644 --- a/src/libqmi-glib/qmi-message.c +++ b/src/libqmi-glib/qmi-message.c @@ -268,7 +268,7 @@ qmi_message_set_transaction_id (QmiMessage *self, if (message_is_control (self)) ((struct full_message *)self->data)->qmi.control.header.transaction = (guint8)transaction_id; else - ((struct full_message *)self->data)->qmi.control.header.transaction = GUINT16_TO_LE (transaction_id); + ((struct full_message *)self->data)->qmi.service.header.transaction = GUINT16_TO_LE (transaction_id); } /** diff --git a/src/libqmi-glib/test/test-message.c b/src/libqmi-glib/test/test-message.c index f78b647..807d15f 100644 --- a/src/libqmi-glib/test/test-message.c +++ b/src/libqmi-glib/test/test-message.c @@ -160,6 +160,56 @@ test_message_parse_missing_size (void) } #endif +static void +test_message_set_transaction_id_ctl (void) +{ + GByteArray *buffer; + QmiMessage *message; + GError *error = NULL; + guint8 ctl_message[] = { + 0x01, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xFF, /* TRID to update */ + 0x22, 0x00, 0x04, 0x00, 0x01, 0x01, 0x00, 0x01 + }; + + /* CTL message */ + buffer = g_byte_array_append (g_byte_array_sized_new (G_N_ELEMENTS (ctl_message)), ctl_message, G_N_ELEMENTS (ctl_message)); + message = qmi_message_new_from_raw (buffer, &error); + g_assert_no_error (error); + g_assert (message); + + qmi_message_set_transaction_id (message, 0x55); + g_assert_cmpuint (qmi_message_get_transaction_id (message), ==, 0x55); + + qmi_message_unref (message); + g_byte_array_unref (buffer); +} + +static void +test_message_set_transaction_id_services (void) +{ + GByteArray *buffer; + QmiMessage *message; + GError *error = NULL; + guint8 dms_message[] = { + 0x01, 0x0C, 0x00, 0x00, 0x02, 0x01, 0x00, + 0xFF, 0xFF, /* TRID to update */ + 0x25, 0x00, 0x00, 0x00 + }; + + /* DMS message */ + buffer = g_byte_array_append (g_byte_array_sized_new (G_N_ELEMENTS (dms_message)), dms_message, G_N_ELEMENTS (dms_message)); + message = qmi_message_new_from_raw (buffer, &error); + g_assert_no_error (error); + g_assert (message); + + qmi_message_set_transaction_id (message, 0x5566); + g_assert_cmpuint (qmi_message_get_transaction_id (message), ==, 0x5566); + + qmi_message_unref (message); + g_byte_array_unref (buffer); +} + int main (int argc, char **argv) { g_type_init (); @@ -173,6 +223,8 @@ int main (int argc, char **argv) g_test_add_func ("/libqmi-glib/message/parse/wrong-tlv", test_message_parse_wrong_tlv); g_test_add_func ("/libqmi-glib/message/parse/missing-size", test_message_parse_missing_size); #endif + g_test_add_func ("/libqmi-glib/message/set-transaction-id/ctl", test_message_set_transaction_id_ctl); + g_test_add_func ("/libqmi-glib/message/set-transaction-id/services", test_message_set_transaction_id_services); return g_test_run (); } |