diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2012-04-22 18:01:35 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2012-07-03 15:47:22 +0200 |
commit | d116505b8e0e9d7eb65fb97b15b97feb6c3007df (patch) | |
tree | 3200352c64d43aaf962ac70eafa243d9406d25c2 /src | |
parent | c049a7c91ac67d5e7e3e98a8f44604d87847a84e (diff) | |
download | external_libqmi-d116505b8e0e9d7eb65fb97b15b97feb6c3007df.zip external_libqmi-d116505b8e0e9d7eb65fb97b15b97feb6c3007df.tar.gz external_libqmi-d116505b8e0e9d7eb65fb97b15b97feb6c3007df.tar.bz2 |
message: ensure only responses are used to match transactions
Diffstat (limited to 'src')
-rw-r--r-- | src/qmi-enums.h | 19 | ||||
-rw-r--r-- | src/qmi-message.c | 20 |
2 files changed, 39 insertions, 0 deletions
diff --git a/src/qmi-enums.h b/src/qmi-enums.h index 95487f2..d6af955 100644 --- a/src/qmi-enums.h +++ b/src/qmi-enums.h @@ -62,12 +62,31 @@ typedef enum { QMI_SERVICE_OMA = 0xE2 } QmiService; +/*****************************************************************************/ +/* QMI Control */ + typedef enum { QMI_CTL_MESSAGE_GET_VERSION_INFO = 0x0021, QMI_CTL_MESSAGE_ALLOCATE_CLIENT_ID = 0x0022, QMI_CTL_MESSAGE_RELEASE_CLIENT_ID = 0x0023, } QmiCtlMessage; +typedef enum { + QMI_CTL_FLAG_NONE = 0, + QMI_CTL_FLAG_RESPONSE = 1 << 0, + QMI_CTL_FLAG_INDICATION = 1 << 1, +} QmiCtlFlag; + +/*****************************************************************************/ +/* QMI Services */ + +typedef enum { + QMI_SERVICE_FLAG_NONE = 0, + QMI_SERVICE_FLAG_COMPOUND = 1 << 0, + QMI_SERVICE_FLAG_RESPONSE = 1 << 1, + QMI_SERVICE_FLAG_INDICATION = 1 << 2, +} QmiServiceFlag; + #define QMI_CID_NONE 0x00 #define QMI_CID_BROADCAST 0xFF diff --git a/src/qmi-message.c b/src/qmi-message.c index 90873e6..473793f 100644 --- a/src/qmi-message.c +++ b/src/qmi-message.c @@ -663,6 +663,26 @@ qmi_message_get_result (QmiMessage *self, g_assert (self != NULL); + if (qmi_message_get_service (self) == QMI_SERVICE_CTL) { + if (!(qmi_message_get_qmi_flags (self) & QMI_CTL_FLAG_RESPONSE)) { + g_set_error (error, + QMI_CORE_ERROR, + QMI_CORE_ERROR_INVALID_MESSAGE, + "Cannot get result code from non-response CTL message"); + return FALSE; + } + /* CTL response, keep on */ + } else { + if (!(qmi_message_get_qmi_flags (self) & QMI_SERVICE_FLAG_RESPONSE)) { + g_set_error (error, + QMI_CORE_ERROR, + QMI_CORE_ERROR_INVALID_MESSAGE, + "Cannot get result code from non-response SVC message"); + return FALSE; + } + /* SVC response, keep on */ + } + if (!qmi_message_tlv_get (self, QMI_TLV_RESULT_CODE, sizeof (msg_result), |