| 1 |
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 2 |
/* SPDX-License-Identifier: GPL-2.0-or-later */ |
| 3 |
/* |
| 4 |
* Copyright (C) 2013 - 2014 Aleksander Morgado <[email protected]> |
| 5 |
*/ |
| 6 |
|
| 7 |
#include <config.h> |
| 8 |
#include <string.h> |
| 9 |
|
| 10 |
#include "mbim-basic-connect.h" |
| 11 |
#include "mbim-sms.h" |
| 12 |
#include "mbim-ussd.h" |
| 13 |
#include "mbim-auth.h" |
| 14 |
#include "mbim-stk.h" |
| 15 |
#include "mbim-ms-firmware-id.h" |
| 16 |
#include "mbim-ms-basic-connect-extensions.h" |
| 17 |
#include "mbim-ms-uicc-low-level-access.h" |
| 18 |
#include "mbim-google.h" |
| 19 |
#include "mbim-message.h" |
| 20 |
#include "mbim-tlv.h" |
| 21 |
#include "mbim-cid.h" |
| 22 |
#include "mbim-common.h" |
| 23 |
#include "mbim-error-types.h" |
| 24 |
|
| 25 |
static void |
| 26 |
test_message_trace (const guint8 *computed, |
| 27 |
guint32 computed_size, |
| 28 |
const guint8 *expected, |
| 29 |
guint32 expected_size) |
| 30 |
{ |
| 31 |
g_autofree gchar *message_str = NULL; |
| 32 |
g_autofree gchar *expected_str = NULL; |
| 33 |
|
| 34 |
message_str = mbim_common_str_hex (computed, computed_size, ':'); |
| 35 |
expected_str = mbim_common_str_hex (expected, expected_size, ':'); |
| 36 |
|
| 37 |
/* Dump all message contents */ |
| 38 |
g_print ("\n" |
| 39 |
"Message str:\n" |
| 40 |
"'%s'\n" |
| 41 |
"Expected str:\n" |
| 42 |
"'%s'\n", |
| 43 |
message_str, |
| 44 |
expected_str); |
| 45 |
|
| 46 |
/* If they are different, tell which are the different bytes */ |
| 47 |
if (computed_size != expected_size || |
| 48 |
memcmp (computed, expected, expected_size)) { |
| 49 |
guint32 i; |
| 50 |
|
| 51 |
for (i = 0; i < MIN (computed_size, expected_size); i++) { |
| 52 |
if (computed[i] != expected[i]) |
| 53 |
g_print ("Byte [%u] is different (computed: 0x%02X vs expected: 0x%02x)\n", i, computed[i], expected[i]); |
| 54 |
} |
| 55 |
} |
| 56 |
} |
| 57 |
|
| 58 |
static void |
| 59 |
test_message_printable (MbimMessage *message, |
| 60 |
guint8 mbimex_version_major, |
| 61 |
guint8 mbimex_version_minor) |
| 62 |
{ |
| 63 |
g_autofree gchar *printable = NULL; |
| 64 |
|
| 65 |
printable = mbim_message_get_printable_full (message, |
| 66 |
mbimex_version_major, |
| 67 |
mbimex_version_minor, |
| 68 |
"---- ", |
| 69 |
FALSE, |
| 70 |
NULL); |
| 71 |
g_print ("\n" |
| 72 |
"Message printable:\n" |
| 73 |
"%s\n", |
| 74 |
printable); |
| 75 |
} |
| 76 |
|
| 77 |
static void |
| 78 |
test_basic_connect_visible_providers (void) |
| 79 |
{ |
| 80 |
guint32 n_providers; |
| 81 |
g_autoptr(GError) error = NULL; |
| 82 |
g_autoptr(MbimProviderArray) providers = NULL; |
| 83 |
g_autoptr(MbimMessage) response = NULL; |
| 84 |
|
| 85 |
const guint8 buffer [] = { |
| 86 |
/* header */ |
| 87 |
0x03, 0x00, 0x00, 0x80, /* type */ |
| 88 |
0xB4, 0x00, 0x00, 0x00, /* length */ |
| 89 |
0x02, 0x00, 0x00, 0x00, /* transaction id */ |
| 90 |
/* fragment header */ |
| 91 |
0x01, 0x00, 0x00, 0x00, /* total */ |
| 92 |
0x00, 0x00, 0x00, 0x00, /* current */ |
| 93 |
/* command_done_message */ |
| 94 |
0xA2, 0x89, 0xCC, 0x33, /* service id */ |
| 95 |
0xBC, 0xBB, 0x8B, 0x4F, |
| 96 |
0xB6, 0xB0, 0x13, 0x3E, |
| 97 |
0xC2, 0xAA, 0xE6, 0xDF, |
| 98 |
0x08, 0x00, 0x00, 0x00, /* command id */ |
| 99 |
0x00, 0x00, 0x00, 0x00, /* status code */ |
| 100 |
0x84, 0x00, 0x00, 0x00, /* buffer length */ |
| 101 |
/* information buffer */ |
| 102 |
0x02, 0x00, 0x00, 0x00, /* 0x00 providers count */ |
| 103 |
0x14, 0x00, 0x00, 0x00, /* 0x04 provider 0 offset */ |
| 104 |
0x38, 0x00, 0x00, 0x00, /* 0x08 provider 0 length */ |
| 105 |
0x4C, 0x00, 0x00, 0x00, /* 0x0C provider 1 offset */ |
| 106 |
0x38, 0x00, 0x00, 0x00, /* 0x10 provider 1 length */ |
| 107 |
/* data buffer... struct provider 0 */ |
| 108 |
0x20, 0x00, 0x00, 0x00, /* 0x14 [0x00] id offset */ |
| 109 |
0x0A, 0x00, 0x00, 0x00, /* 0x18 [0x04] id length */ |
| 110 |
0x08, 0x00, 0x00, 0x00, /* 0x1C [0x08] state */ |
| 111 |
0x2C, 0x00, 0x00, 0x00, /* 0x20 [0x0C] name offset */ |
| 112 |
0x0C, 0x00, 0x00, 0x00, /* 0x24 [0x10] name length */ |
| 113 |
0x01, 0x00, 0x00, 0x00, /* 0x28 [0x14] cellular class */ |
| 114 |
0x0B, 0x00, 0x00, 0x00, /* 0x2C [0x18] rssi */ |
| 115 |
0x00, 0x00, 0x00, 0x00, /* 0x30 [0x1C] error rate */ |
| 116 |
0x32, 0x00, 0x31, 0x00, /* 0x34 [0x20] id string (10 bytes) */ |
| 117 |
0x34, 0x00, 0x30, 0x00, |
| 118 |
0x33, 0x00, 0x00, 0x00, |
| 119 |
0x4F, 0x00, 0x72, 0x00, /* 0x40 [0x2C] name string (12 bytes) */ |
| 120 |
0x61, 0x00, 0x6E, 0x00, |
| 121 |
0x67, 0x00, 0x65, 0x00, |
| 122 |
/* data buffer... struct provider 1 */ |
| 123 |
0x20, 0x00, 0x00, 0x00, /* 0x4C [0x00] id offset */ |
| 124 |
0x0A, 0x00, 0x00, 0x00, /* 0x50 [0x04] id length */ |
| 125 |
0x19, 0x00, 0x00, 0x00, /* 0x51 [0x08] state */ |
| 126 |
0x2C, 0x00, 0x00, 0x00, /* 0x54 [0x0C] name offset */ |
| 127 |
0x0C, 0x00, 0x00, 0x00, /* 0x58 [0x10] name length */ |
| 128 |
0x01, 0x00, 0x00, 0x00, /* 0x5C [0x14] cellular class */ |
| 129 |
0x0B, 0x00, 0x00, 0x00, /* 0x60 [0x18] rssi */ |
| 130 |
0x00, 0x00, 0x00, 0x00, /* 0x64 [0x1C] error rate */ |
| 131 |
0x32, 0x00, 0x31, 0x00, /* 0x68 [0x20] id string (10 bytes) */ |
| 132 |
0x34, 0x00, 0x30, 0x00, |
| 133 |
0x33, 0x00, 0x00, 0x00, |
| 134 |
0x4F, 0x00, 0x72, 0x00, /* 0x74 [0x2C] name string (12 bytes) */ |
| 135 |
0x61, 0x00, 0x6E, 0x00, |
| 136 |
0x67, 0x00, 0x65, 0x00 }; |
| 137 |
|
| 138 |
response = mbim_message_new (buffer, sizeof (buffer)); |
| 139 |
g_assert (mbim_message_validate (response, &error)); |
| 140 |
g_assert_no_error (error); |
| 141 |
|
| 142 |
test_message_printable (response, 1, 0); |
| 143 |
|
| 144 |
g_assert (mbim_message_visible_providers_response_parse ( |
| 145 |
response, |
| 146 |
&n_providers, |
| 147 |
&providers, |
| 148 |
&error)); |
| 149 |
|
| 150 |
g_assert_no_error (error); |
| 151 |
|
| 152 |
g_assert_cmpuint (n_providers, ==, 2); |
| 153 |
|
| 154 |
/* Provider [0] |
| 155 |
* Provider ID: '21403' |
| 156 |
* Provider Name: 'Orange' |
| 157 |
* State: 'visible' |
| 158 |
* Cellular class: 'gsm' |
| 159 |
* RSSI: '11' |
| 160 |
* Error rate: '0' |
| 161 |
*/ |
| 162 |
g_assert_cmpstr (providers[0]->provider_id, ==, "21403"); |
| 163 |
g_assert_cmpstr (providers[0]->provider_name, ==, "Orange"); |
| 164 |
g_assert_cmpuint (providers[0]->provider_state, ==, MBIM_PROVIDER_STATE_VISIBLE); |
| 165 |
g_assert_cmpuint (providers[0]->cellular_class, ==, MBIM_CELLULAR_CLASS_GSM); |
| 166 |
g_assert_cmpuint (providers[0]->rssi, ==, 11); |
| 167 |
g_assert_cmpuint (providers[0]->error_rate, ==, 0); |
| 168 |
|
| 169 |
/* Provider [1]: |
| 170 |
* Provider ID: '21403' |
| 171 |
* Provider Name: 'Orange' |
| 172 |
* State: 'home, visible, registered' |
| 173 |
* Cellular class: 'gsm' |
| 174 |
* RSSI: '11' |
| 175 |
* Error rate: '0' |
| 176 |
*/ |
| 177 |
g_assert_cmpstr (providers[1]->provider_id, ==, "21403"); |
| 178 |
g_assert_cmpstr (providers[1]->provider_name, ==, "Orange"); |
| 179 |
g_assert_cmpuint (providers[1]->provider_state, ==, (MBIM_PROVIDER_STATE_HOME | |
| 180 |
MBIM_PROVIDER_STATE_VISIBLE | |
| 181 |
MBIM_PROVIDER_STATE_REGISTERED)); |
| 182 |
g_assert_cmpuint (providers[1]->cellular_class, ==, MBIM_CELLULAR_CLASS_GSM); |
| 183 |
g_assert_cmpuint (providers[1]->rssi, ==, 11); |
| 184 |
g_assert_cmpuint (providers[1]->error_rate, ==, 0); |
| 185 |
} |
| 186 |
|
| 187 |
static void |
| 188 |
test_basic_connect_subscriber_ready_status (void) |
| 189 |
{ |
| 190 |
MbimSubscriberReadyState ready_state; |
| 191 |
MbimReadyInfoFlag ready_info; |
| 192 |
guint32 telephone_numbers_count; |
| 193 |
g_autofree gchar *subscriber_id = NULL; |
| 194 |
g_autofree gchar *sim_iccid = NULL; |
| 195 |
g_auto(GStrv) telephone_numbers = NULL; |
| 196 |
g_autoptr(GError) error = NULL; |
| 197 |
g_autoptr(MbimMessage) response = NULL; |
| 198 |
|
| 199 |
const guint8 buffer [] = { |
| 200 |
/* header */ |
| 201 |
0x03, 0x00, 0x00, 0x80, /* type */ |
| 202 |
0xB4, 0x00, 0x00, 0x00, /* length */ |
| 203 |
0x02, 0x00, 0x00, 0x00, /* transaction id */ |
| 204 |
/* fragment header */ |
| 205 |
0x01, 0x00, 0x00, 0x00, /* total */ |
| 206 |
0x00, 0x00, 0x00, 0x00, /* current */ |
| 207 |
/* command_message */ |
| 208 |
0xA2, 0x89, 0xCC, 0x33, /* service id */ |
| 209 |
0xBC, 0xBB, 0x8B, 0x4F, |
| 210 |
0xB6, 0xB0, 0x13, 0x3E, |
| 211 |
0xC2, 0xAA, 0xE6, 0xDF, |
| 212 |
0x02, 0x00, 0x00, 0x00, /* command id */ |
| 213 |
0x00, 0x00, 0x00, 0x00, /* status code */ |
| 214 |
0x84, 0x00, 0x00, 0x00, /* buffer_length */ |
| 215 |
/* information buffer */ |
| 216 |
0x01, 0x00, 0x00, 0x00, /* 0x00 ready state */ |
| 217 |
0x5C, 0x00, 0x00, 0x00, /* 0x04 subscriber id (offset) */ |
| 218 |
0x1E, 0x00, 0x00, 0x00, /* 0x08 subscriber id (size) */ |
| 219 |
0x7C, 0x00, 0x00, 0x00, /* 0x0C sim iccid (offset) */ |
| 220 |
0x28, 0x00, 0x00, 0x00, /* 0x10 sim iccid (size) */ |
| 221 |
0x00, 0x00, 0x00, 0x00, /* 0x14 ready info */ |
| 222 |
0x02, 0x00, 0x00, 0x00, /* 0x18 telephone numbers count */ |
| 223 |
0x2C, 0x00, 0x00, 0x00, /* 0x1C telephone number #1 (offset) */ |
| 224 |
0x16, 0x00, 0x00, 0x00, /* 0x20 telephone number #1 (size) */ |
| 225 |
0x44, 0x00, 0x00, 0x00, /* 0x24 telephone number #2 (offset) */ |
| 226 |
0x16, 0x00, 0x00, 0x00, /* 0x28 telephone number #2 (size) */ |
| 227 |
/* data buffer */ |
| 228 |
0x31, 0x00, 0x31, 0x00, /* 0x2C telephone number #1 (data) */ |
| 229 |
0x31, 0x00, 0x31, 0x00, |
| 230 |
0x31, 0x00, 0x31, 0x00, |
| 231 |
0x31, 0x00, 0x31, 0x00, |
| 232 |
0x31, 0x00, 0x31, 0x00, |
| 233 |
0x31, 0x00, 0x00, 0x00, /* last 2 bytes are padding */ |
| 234 |
0x30, 0x00, 0x30, 0x00, /* 0x44 telephone number #2 (data) */ |
| 235 |
0x30, 0x00, 0x30, 0x00, |
| 236 |
0x30, 0x00, 0x30, 0x00, |
| 237 |
0x30, 0x00, 0x30, 0x00, |
| 238 |
0x30, 0x00, 0x30, 0x00, |
| 239 |
0x30, 0x00, 0x00, 0x00, /* last 2 bytes are padding */ |
| 240 |
0x33, 0x00, 0x31, 0x00, /* 0x5C subscriber id (data) */ |
| 241 |
0x30, 0x00, 0x34, 0x00, |
| 242 |
0x31, 0x00, 0x30, 0x00, |
| 243 |
0x30, 0x00, 0x30, 0x00, |
| 244 |
0x30, 0x00, 0x31, 0x00, |
| 245 |
0x31, 0x00, 0x30, 0x00, |
| 246 |
0x37, 0x00, 0x36, 0x00, |
| 247 |
0x31, 0x00, 0x00, 0x00, /* last 2 bytes are padding */ |
| 248 |
0x38, 0x00, 0x39, 0x00, /* 0x7C sim iccid (data) */ |
| 249 |
0x30, 0x00, 0x31, 0x00, |
| 250 |
0x30, 0x00, 0x31, 0x00, |
| 251 |
0x30, 0x00, 0x34, 0x00, |
| 252 |
0x30, 0x00, 0x35, 0x00, |
| 253 |
0x34, 0x00, 0x36, 0x00, |
| 254 |
0x30, 0x00, 0x31, 0x00, |
| 255 |
0x31, 0x00, 0x30, 0x00, |
| 256 |
0x30, 0x00, 0x36, 0x00, |
| 257 |
0x31, 0x00, 0x32, 0x00 }; |
| 258 |
|
| 259 |
response = mbim_message_new (buffer, sizeof (buffer)); |
| 260 |
g_assert (mbim_message_validate (response, &error)); |
| 261 |
g_assert_no_error (error); |
| 262 |
|
| 263 |
test_message_printable (response, 1, 0); |
| 264 |
|
| 265 |
g_assert (mbim_message_subscriber_ready_status_response_parse ( |
| 266 |
response, |
| 267 |
&ready_state, |
| 268 |
&subscriber_id, |
| 269 |
&sim_iccid, |
| 270 |
&ready_info, |
| 271 |
&telephone_numbers_count, |
| 272 |
&telephone_numbers, |
| 273 |
&error)); |
| 274 |
|
| 275 |
g_assert_no_error (error); |
| 276 |
|
| 277 |
g_assert_cmpuint (ready_state, ==, MBIM_SUBSCRIBER_READY_STATE_INITIALIZED); |
| 278 |
g_assert_cmpstr (subscriber_id, ==, "310410000110761"); |
| 279 |
g_assert_cmpstr (sim_iccid, ==, "89010104054601100612"); |
| 280 |
g_assert_cmpuint (ready_info, ==, 0); |
| 281 |
g_assert_cmpuint (telephone_numbers_count, ==, 2); |
| 282 |
g_assert_cmpstr (telephone_numbers[0], ==, "11111111111"); |
| 283 |
g_assert_cmpstr (telephone_numbers[1], ==, "00000000000"); |
| 284 |
g_assert (telephone_numbers[2] == NULL); |
| 285 |
} |
| 286 |
|
| 287 |
static void |
| 288 |
test_basic_connect_device_caps (void) |
| 289 |
{ |
| 290 |
MbimDeviceType device_type; |
| 291 |
MbimCellularClass cellular_class; |
| 292 |
MbimVoiceClass voice_class; |
| 293 |
MbimSimClass sim_class; |
| 294 |
MbimDataClass data_class; |
| 295 |
MbimSmsCaps sms_caps; |
| 296 |
MbimCtrlCaps ctrl_caps; |
| 297 |
guint32 max_sessions; |
| 298 |
g_autofree gchar *custom_data_class = NULL; |
| 299 |
g_autofree gchar *device_id = NULL; |
| 300 |
g_autofree gchar *firmware_info = NULL; |
| 301 |
g_autofree gchar *hardware_info = NULL; |
| 302 |
g_autoptr(GError) error = NULL; |
| 303 |
g_autoptr(MbimMessage) response = NULL; |
| 304 |
|
| 305 |
const guint8 buffer [] = { 0x03, 0x00, 0x00, 0x80, |
| 306 |
0xD0, 0x00, 0x00, 0x00, |
| 307 |
0x02, 0x00, 0x00, 0x00, |
| 308 |
0x01, 0x00, 0x00, 0x00, |
| 309 |
0x00, 0x00, 0x00, 0x00, |
| 310 |
0xA2, 0x89, 0xCC, 0x33, |
| 311 |
0xBC, 0xBB, 0x8B, 0x4F, |
| 312 |
0xB6, 0xB0, 0x13, 0x3E, |
| 313 |
0xC2, 0xAA, 0xE6, 0xDF, |
| 314 |
0x01, 0x00, 0x00, 0x00, |
| 315 |
0x00, 0x00, 0x00, 0x00, |
| 316 |
0xA0, 0x00, 0x00, 0x00, |
| 317 |
0x02, 0x00, 0x00, 0x00, |
| 318 |
0x01, 0x00, 0x00, 0x00, |
| 319 |
0x01, 0x00, 0x00, 0x00, |
| 320 |
0x02, 0x00, 0x00, 0x00, |
| 321 |
0x1F, 0x00, 0x00, 0x80, |
| 322 |
0x03, 0x00, 0x00, 0x00, |
| 323 |
0x01, 0x00, 0x00, 0x00, |
| 324 |
0x01, 0x00, 0x00, 0x00, |
| 325 |
0x40, 0x00, 0x00, 0x00, |
| 326 |
0x0A, 0x00, 0x00, 0x00, |
| 327 |
0x4C, 0x00, 0x00, 0x00, |
| 328 |
0x1E, 0x00, 0x00, 0x00, |
| 329 |
0x6C, 0x00, 0x00, 0x00, |
| 330 |
0x1E, 0x00, 0x00, 0x00, |
| 331 |
0x8C, 0x00, 0x00, 0x00, |
| 332 |
0x12, 0x00, 0x00, 0x00, |
| 333 |
0x48, 0x00, 0x53, 0x00, |
| 334 |
0x50, 0x00, 0x41, 0x00, |
| 335 |
0x2B, 0x00, 0x00, 0x00, |
| 336 |
0x33, 0x00, 0x35, 0x00, |
| 337 |
0x33, 0x00, 0x36, 0x00, |
| 338 |
0x31, 0x00, 0x33, 0x00, |
| 339 |
0x30, 0x00, 0x34, 0x00, |
| 340 |
0x38, 0x00, 0x38, 0x00, |
| 341 |
0x30, 0x00, 0x34, 0x00, |
| 342 |
0x36, 0x00, 0x32, 0x00, |
| 343 |
0x32, 0x00, 0x00, 0x00, |
| 344 |
0x31, 0x00, 0x31, 0x00, |
| 345 |
0x2E, 0x00, 0x38, 0x00, |
| 346 |
0x31, 0x00, 0x30, 0x00, |
| 347 |
0x2E, 0x00, 0x30, 0x00, |
| 348 |
0x39, 0x00, 0x2E, 0x00, |
| 349 |
0x30, 0x00, 0x30, 0x00, |
| 350 |
0x2E, 0x00, 0x30, 0x00, |
| 351 |
0x30, 0x00, 0x00, 0x00, |
| 352 |
0x43, 0x00, 0x50, 0x00, |
| 353 |
0x31, 0x00, 0x45, 0x00, |
| 354 |
0x33, 0x00, 0x36, 0x00, |
| 355 |
0x37, 0x00, 0x55, 0x00, |
| 356 |
0x4D, 0x00, 0x00, 0x00 }; |
| 357 |
|
| 358 |
response = mbim_message_new (buffer, sizeof (buffer)); |
| 359 |
g_assert (mbim_message_validate (response, &error)); |
| 360 |
g_assert_no_error (error); |
| 361 |
|
| 362 |
test_message_printable (response, 1, 0); |
| 363 |
|
| 364 |
g_assert (mbim_message_device_caps_response_parse ( |
| 365 |
response, |
| 366 |
&device_type, |
| 367 |
&cellular_class, |
| 368 |
&voice_class, |
| 369 |
&sim_class, |
| 370 |
&data_class, |
| 371 |
&sms_caps, |
| 372 |
&ctrl_caps, |
| 373 |
&max_sessions, |
| 374 |
&custom_data_class, |
| 375 |
&device_id, |
| 376 |
&firmware_info, |
| 377 |
&hardware_info, |
| 378 |
&error)); |
| 379 |
|
| 380 |
g_assert_no_error (error); |
| 381 |
|
| 382 |
g_assert_cmpuint (device_type, ==, MBIM_DEVICE_TYPE_REMOVABLE); |
| 383 |
g_assert_cmpuint (cellular_class, ==, MBIM_CELLULAR_CLASS_GSM); |
| 384 |
g_assert_cmpuint (sim_class, ==, MBIM_SIM_CLASS_REMOVABLE); |
| 385 |
g_assert_cmpuint (data_class, ==, (MBIM_DATA_CLASS_GPRS | |
| 386 |
MBIM_DATA_CLASS_EDGE | |
| 387 |
MBIM_DATA_CLASS_UMTS | |
| 388 |
MBIM_DATA_CLASS_HSDPA | |
| 389 |
MBIM_DATA_CLASS_HSUPA | |
| 390 |
MBIM_DATA_CLASS_CUSTOM)); |
| 391 |
g_assert_cmpuint (sms_caps, ==, (MBIM_SMS_CAPS_PDU_RECEIVE | MBIM_SMS_CAPS_PDU_SEND)); |
| 392 |
g_assert_cmpuint (ctrl_caps, ==, MBIM_CTRL_CAPS_REG_MANUAL); |
| 393 |
g_assert_cmpuint (max_sessions, ==, 1); |
| 394 |
g_assert_cmpstr (custom_data_class, ==, "HSPA+"); |
| 395 |
g_assert_cmpstr (device_id, ==, "353613048804622"); |
| 396 |
g_assert_cmpstr (firmware_info, ==, "11.810.09.00.00"); |
| 397 |
g_assert_cmpstr (hardware_info, ==, "CP1E367UM"); |
| 398 |
} |
| 399 |
|
| 400 |
static void |
| 401 |
test_basic_connect_ip_configuration (void) |
| 402 |
{ |
| 403 |
guint32 session_id; |
| 404 |
MbimIPConfigurationAvailableFlag ipv4configurationavailable; |
| 405 |
MbimIPConfigurationAvailableFlag ipv6configurationavailable; |
| 406 |
guint32 ipv4addresscount; |
| 407 |
guint32 ipv6addresscount; |
| 408 |
const MbimIPv4 *ipv4gateway; |
| 409 |
const MbimIPv6 *ipv6gateway; |
| 410 |
guint32 ipv4dnsservercount; |
| 411 |
guint32 ipv6dnsservercount; |
| 412 |
guint32 ipv4mtu; |
| 413 |
guint32 ipv6mtu; |
| 414 |
g_autofree MbimIPv4 *ipv4dnsserver = NULL; |
| 415 |
g_autofree MbimIPv6 *ipv6dnsserver = NULL; |
| 416 |
g_autoptr(MbimIPv4ElementArray) ipv4address = NULL; |
| 417 |
g_autoptr(MbimIPv6ElementArray) ipv6address = NULL; |
| 418 |
g_autoptr(GError) error = NULL; |
| 419 |
g_autoptr(MbimMessage) response = NULL; |
| 420 |
|
| 421 |
const guint8 buffer [] = { |
| 422 |
/* header */ |
| 423 |
0x03, 0x00, 0x00, 0x80, /* type */ |
| 424 |
0x80, 0x00, 0x00, 0x00, /* length */ |
| 425 |
0x1A, 0x00, 0x00, 0x00, /* transaction id */ |
| 426 |
/* fragment header */ |
| 427 |
0x01, 0x00, 0x00, 0x00, /* total */ |
| 428 |
0x00, 0x00, 0x00, 0x00, /* current */ |
| 429 |
/* command_done_message */ |
| 430 |
0xA2, 0x89, 0xCC, 0x33, /* service id */ |
| 431 |
0xBC, 0xBB, 0x8B, 0x4F, |
| 432 |
0xB6, 0xB0, 0x13, 0x3E, |
| 433 |
0xC2, 0xAA, 0xE6, 0xDF, |
| 434 |
0x0F, 0x00, 0x00, 0x00, /* command id */ |
| 435 |
0x00, 0x00, 0x00, 0x00, /* status code */ |
| 436 |
0x50, 0x00, 0x00, 0x00, /* buffer length */ |
| 437 |
/* information buffer */ |
| 438 |
0x00, 0x00, 0x00, 0x00, /* session id */ |
| 439 |
0x0F, 0x00, 0x00, 0x00, /* IPv4ConfigurationAvailable */ |
| 440 |
0x00, 0x00, 0x00, 0x00, /* IPv6ConfigurationAvailable */ |
| 441 |
0x01, 0x00, 0x00, 0x00, /* IPv4 element count */ |
| 442 |
0x3C, 0x00, 0x00, 0x00, /* IPv4 element offset */ |
| 443 |
0x00, 0x00, 0x00, 0x00, /* IPv6 element count */ |
| 444 |
0x00, 0x00, 0x00, 0x00, /* IPv6 element offset */ |
| 445 |
0x44, 0x00, 0x00, 0x00, /* IPv4 gateway offset */ |
| 446 |
0x00, 0x00, 0x00, 0x00, /* IPv6 gateway offset */ |
| 447 |
0x02, 0x00, 0x00, 0x00, /* IPv4 DNS count */ |
| 448 |
0x48, 0x00, 0x00, 0x00, /* IPv4 DNS offset */ |
| 449 |
0x00, 0x00, 0x00, 0x00, /* IPv6 DNS count */ |
| 450 |
0x00, 0x00, 0x00, 0x00, /* IPv6 DNS offset */ |
| 451 |
0xDC, 0x05, 0x00, 0x00, /* IPv4 MTU */ |
| 452 |
0x00, 0x00, 0x00, 0x00, /* IPv6 MTU */ |
| 453 |
/* data buffer */ |
| 454 |
0x1C, 0x00, 0x00, 0x00, /* IPv4 element (netmask) */ |
| 455 |
0xD4, 0x49, 0x22, 0xF8, /* IPv4 element (address) */ |
| 456 |
0xD4, 0x49, 0x22, 0xF1, /* IPv4 gateway */ |
| 457 |
0xD4, 0xA6, 0xD2, 0x50, /* IPv4 DNS1 */ |
| 458 |
0xD4, 0x49, 0x20, 0x43 /* IPv4 DNS2 */ |
| 459 |
}; |
| 460 |
|
| 461 |
response = mbim_message_new (buffer, sizeof (buffer)); |
| 462 |
g_assert (mbim_message_validate (response, &error)); |
| 463 |
g_assert_no_error (error); |
| 464 |
|
| 465 |
test_message_printable (response, 1, 0); |
| 466 |
|
| 467 |
g_assert (mbim_message_ip_configuration_response_parse ( |
| 468 |
response, |
| 469 |
&session_id, |
| 470 |
&ipv4configurationavailable, |
| 471 |
&ipv6configurationavailable, |
| 472 |
&ipv4addresscount, |
| 473 |
&ipv4address, |
| 474 |
&ipv6addresscount, |
| 475 |
&ipv6address, |
| 476 |
&ipv4gateway, |
| 477 |
&ipv6gateway, |
| 478 |
&ipv4dnsservercount, |
| 479 |
&ipv4dnsserver, |
| 480 |
&ipv6dnsservercount, |
| 481 |
&ipv6dnsserver, |
| 482 |
&ipv4mtu, |
| 483 |
&ipv6mtu, |
| 484 |
&error)); |
| 485 |
|
| 486 |
/* |
| 487 |
* IPv4 configuration available: 'address, gateway, dns, mtu' |
| 488 |
* IP addresses (1) |
| 489 |
* IP [0]: '212.166.228.25/28' |
| 490 |
* Gateway: '212.166.228.26' |
| 491 |
* DNS addresses (2) |
| 492 |
* DNS [0]: '212.166.210.80' |
| 493 |
* DNS [1]: '212.73.32.67' |
| 494 |
* MTU: '1500' |
| 495 |
*/ |
| 496 |
|
| 497 |
g_assert_cmpuint (session_id, ==, 0); |
| 498 |
g_assert_cmpuint (ipv4configurationavailable, ==, (MBIM_IP_CONFIGURATION_AVAILABLE_FLAG_ADDRESS | |
| 499 |
MBIM_IP_CONFIGURATION_AVAILABLE_FLAG_GATEWAY | |
| 500 |
MBIM_IP_CONFIGURATION_AVAILABLE_FLAG_DNS | |
| 501 |
MBIM_IP_CONFIGURATION_AVAILABLE_FLAG_MTU)); |
| 502 |
g_assert_cmpuint (ipv6configurationavailable, ==, MBIM_IP_CONFIGURATION_AVAILABLE_FLAG_NONE); |
| 503 |
|
| 504 |
{ |
| 505 |
MbimIPv4 addr = { .addr = { 0xD4, 0x49, 0x22, 0xF8 } }; |
| 506 |
|
| 507 |
g_assert_cmpuint (ipv4addresscount, ==, 1); |
| 508 |
g_assert_cmpuint (ipv4address[0]->on_link_prefix_length, ==, 28); |
| 509 |
g_assert (memcmp (&addr, &(ipv4address[0]->ipv4_address), 4) == 0); |
| 510 |
} |
| 511 |
|
| 512 |
{ |
| 513 |
MbimIPv4 gateway_addr = { .addr = { 0xD4, 0x49, 0x22, 0xF1 } }; |
| 514 |
|
| 515 |
g_assert (memcmp (&gateway_addr, ipv4gateway, 4) == 0); |
| 516 |
} |
| 517 |
|
| 518 |
{ |
| 519 |
MbimIPv4 dns_addr_1 = { .addr = { 0xD4, 0xA6, 0xD2, 0x50 } }; |
| 520 |
MbimIPv4 dns_addr_2 = { .addr = { 0xD4, 0x49, 0x20, 0x43 } }; |
| 521 |
|
| 522 |
g_assert_cmpuint (ipv4dnsservercount, ==, 2); |
| 523 |
g_assert (memcmp (&dns_addr_1, &ipv4dnsserver[0], 4) == 0); |
| 524 |
g_assert (memcmp (&dns_addr_2, &ipv4dnsserver[1], 4) == 0); |
| 525 |
} |
| 526 |
|
| 527 |
g_assert_cmpuint (ipv4mtu, ==, 1500); |
| 528 |
|
| 529 |
g_assert_cmpuint (ipv6addresscount, ==, 0); |
| 530 |
g_assert (ipv6address == NULL); |
| 531 |
g_assert (ipv6gateway == NULL); |
| 532 |
g_assert_cmpuint (ipv6dnsservercount, ==, 0); |
| 533 |
g_assert (ipv6dnsserver == NULL); |
| 534 |
} |
| 535 |
|
| 536 |
|
| 537 |
static void |
| 538 |
test_basic_connect_ip_configuration_2 (void) |
| 539 |
{ |
| 540 |
guint32 session_id; |
| 541 |
MbimIPConfigurationAvailableFlag ipv4configurationavailable; |
| 542 |
MbimIPConfigurationAvailableFlag ipv6configurationavailable; |
| 543 |
guint32 ipv4addresscount; |
| 544 |
guint32 ipv6addresscount; |
| 545 |
const MbimIPv4 *ipv4gateway; |
| 546 |
const MbimIPv6 *ipv6gateway; |
| 547 |
guint32 ipv4dnsservercount; |
| 548 |
guint32 ipv6dnsservercount; |
| 549 |
guint32 ipv4mtu; |
| 550 |
guint32 ipv6mtu; |
| 551 |
g_autofree MbimIPv4 *ipv4dnsserver = NULL; |
| 552 |
g_autofree MbimIPv6 *ipv6dnsserver = NULL; |
| 553 |
g_autoptr(MbimIPv4ElementArray) ipv4address = NULL; |
| 554 |
g_autoptr(MbimIPv6ElementArray) ipv6address = NULL; |
| 555 |
g_autoptr(GError) error = NULL; |
| 556 |
g_autoptr(MbimMessage) response = NULL; |
| 557 |
|
| 558 |
const guint8 buffer [] = { |
| 559 |
/* header */ |
| 560 |
0x03, 0x00, 0x00, 0x80, /* type */ |
| 561 |
0xC4, 0x00, 0x00, 0x00, /* length */ |
| 562 |
0x24, 0x00, 0x00, 0x00, /* transaction id */ |
| 563 |
/* fragment header */ |
| 564 |
0x01, 0x00, 0x00, 0x00, /* total */ |
| 565 |
0x00, 0x00, 0x00, 0x00, /* current */ |
| 566 |
/* command_done_message */ |
| 567 |
0xA2, 0x89, 0xCC, 0x33, /* service id */ |
| 568 |
0xBC, 0xBB, 0x8B, 0x4F, |
| 569 |
0xB6, 0xB0, 0x13, 0x3E, |
| 570 |
0xC2, 0xAA, 0xE6, 0xDF, |
| 571 |
0x0F, 0x00, 0x00, 0x00, /* command id */ |
| 572 |
0x00, 0x00, 0x00, 0x00, /* status code */ |
| 573 |
0x94, 0x00, 0x00, 0x00, /* buffer length */ |
| 574 |
/* information buffer */ |
| 575 |
0x00, 0x00, 0x00, 0x00, /* session id */ |
| 576 |
0x0F, 0x00, 0x00, 0x00, /* IPv4ConfigurationAvailable */ |
| 577 |
0x0F, 0x00, 0x00, 0x00, /* IPv6ConfigurationAvailable */ |
| 578 |
0x01, 0x00, 0x00, 0x00, /* IPv4 element count */ |
| 579 |
0x3C, 0x00, 0x00, 0x00, /* IPv4 element offset */ |
| 580 |
0x01, 0x00, 0x00, 0x00, /* IPv6 element count */ |
| 581 |
0x50, 0x00, 0x00, 0x00, /* IPv6 element offset */ |
| 582 |
0x44, 0x00, 0x00, 0x00, /* IPv4 gateway offset */ |
| 583 |
0x64, 0x00, 0x00, 0x00, /* IPv6 gateway offset */ |
| 584 |
0x02, 0x00, 0x00, 0x00, /* IPv4 DNS count */ |
| 585 |
0x48, 0x00, 0x00, 0x00, /* IPv4 DNS offset */ |
| 586 |
0x02, 0x00, 0x00, 0x00, /* IPv6 DNS count */ |
| 587 |
0x74, 0x00, 0x00, 0x00, /* IPv6 DNS offset */ |
| 588 |
0xDC, 0x05, 0x00, 0x00, /* IPv4 MTU */ |
| 589 |
0xDC, 0x05, 0x00, 0x00, /* IPv6 MTU */ |
| 590 |
/* data buffer */ |
| 591 |
0x1D, 0x00, 0x00, 0x00, /* IPv4 element (netmask) */ |
| 592 |
0x1C, 0xF6, 0xC9, 0xDB, /* IPv4 element (address) */ |
| 593 |
0x1C, 0xF6, 0xC9, 0xDC, /* IPv4 gateway */ |
| 594 |
0x0A, 0xB1, 0x00, 0x22, /* IPv4 DNS1 */ |
| 595 |
0x0A, 0xB1, 0x00, 0xD2, /* IPv4 DNS2 */ |
| 596 |
0x40, 0x00, 0x00, 0x00, /* IPv6 element (netmask) */ |
| 597 |
0x26, 0x07, 0xFB, 0x90, /* IPv6 element (address) */ |
| 598 |
0x64, 0x3B, 0x28, 0x1F, |
| 599 |
0x1D, 0xFF, 0xBF, 0x3D, |
| 600 |
0xC5, 0xC8, 0x48, 0xAD, |
| 601 |
0x26, 0x07, 0xFB, 0x90, /* IPv6 gateway */ |
| 602 |
0x64, 0x3B, 0x28, 0x1F, |
| 603 |
0xFD, 0xF7, 0x80, 0xF4, |
| 604 |
0xE3, 0x99, 0x98, 0x4A, |
| 605 |
0xFD, 0x00, 0x97, 0x6A, /* IPv6 DNS1 */ |
| 606 |
0x00, 0x00, 0x00, 0x00, |
| 607 |
0x00, 0x00, 0x00, 0x00, |
| 608 |
0x00, 0x00, 0x00, 0x09, |
| 609 |
0xFD, 0x00, 0x97, 0x6A, /* IPv6 DNS2 */ |
| 610 |
0x00, 0x00, 0x00, 0x00, |
| 611 |
0x00, 0x00, 0x00, 0x00, |
| 612 |
0x00, 0x00, 0x00, 0x10 |
| 613 |
}; |
| 614 |
|
| 615 |
response = mbim_message_new (buffer, sizeof (buffer)); |
| 616 |
g_assert (mbim_message_validate (response, &error)); |
| 617 |
g_assert_no_error (error); |
| 618 |
|
| 619 |
test_message_printable (response, 1, 0); |
| 620 |
|
| 621 |
g_assert (mbim_message_ip_configuration_response_parse ( |
| 622 |
response, |
| 623 |
&session_id, |
| 624 |
&ipv4configurationavailable, |
| 625 |
&ipv6configurationavailable, |
| 626 |
&ipv4addresscount, |
| 627 |
&ipv4address, |
| 628 |
&ipv6addresscount, |
| 629 |
&ipv6address, |
| 630 |
&ipv4gateway, |
| 631 |
&ipv6gateway, |
| 632 |
&ipv4dnsservercount, |
| 633 |
&ipv4dnsserver, |
| 634 |
&ipv6dnsservercount, |
| 635 |
&ipv6dnsserver, |
| 636 |
&ipv4mtu, |
| 637 |
&ipv6mtu, |
| 638 |
&error)); |
| 639 |
|
| 640 |
/* |
| 641 |
* IPv4 configuration available: 'address, gateway, dns, mtu' |
| 642 |
* IP addresses (1) |
| 643 |
* IP [0]: '28.246.201.219/29' |
| 644 |
* gateway: '28.246.201.220' |
| 645 |
* DNS addresses (2) |
| 646 |
* DNS [0]: '10.177.0.34' |
| 647 |
* DNS [1]: '10.177.0.210' |
| 648 |
* MTU: '1500' |
| 649 |
* IPv6 configuration available: 'address, gateway, dns, mtu' |
| 650 |
* IP addresses (1) |
| 651 |
* IP [0]: '2607:fb90:643b:281f:1dff:bf3d:c5c8:48ad/64' |
| 652 |
* gateway: '2607:fb90:643b:281f:fdf7:80f4:e399:984a' |
| 653 |
* DNS addresses (2) |
| 654 |
* DNS [0]: 'fd00:976a::9' |
| 655 |
*/ |
| 656 |
|
| 657 |
g_assert_cmpuint (session_id, ==, 0); |
| 658 |
g_assert_cmpuint (ipv4configurationavailable, ==, (MBIM_IP_CONFIGURATION_AVAILABLE_FLAG_ADDRESS | |
| 659 |
MBIM_IP_CONFIGURATION_AVAILABLE_FLAG_GATEWAY | |
| 660 |
MBIM_IP_CONFIGURATION_AVAILABLE_FLAG_DNS | |
| 661 |
MBIM_IP_CONFIGURATION_AVAILABLE_FLAG_MTU)); |
| 662 |
g_assert_cmpuint (ipv6configurationavailable, ==, MBIM_IP_CONFIGURATION_AVAILABLE_FLAG_ADDRESS | |
| 663 |
MBIM_IP_CONFIGURATION_AVAILABLE_FLAG_GATEWAY | |
| 664 |
MBIM_IP_CONFIGURATION_AVAILABLE_FLAG_DNS | |
| 665 |
MBIM_IP_CONFIGURATION_AVAILABLE_FLAG_MTU); |
| 666 |
|
| 667 |
{ |
| 668 |
MbimIPv4 addr = { .addr = { 0x1C, 0xF6, 0xC9, 0xDB } }; |
| 669 |
|
| 670 |
g_assert_cmpuint (ipv4addresscount, ==, 1); |
| 671 |
g_assert_cmpuint (ipv4address[0]->on_link_prefix_length, ==, 29); |
| 672 |
g_assert (memcmp (&addr, &(ipv4address[0]->ipv4_address), 4) == 0); |
| 673 |
} |
| 674 |
|
| 675 |
{ |
| 676 |
MbimIPv4 gateway_addr = { .addr = { 0x1C, 0xF6, 0xC9, 0xDC } }; |
| 677 |
|
| 678 |
g_assert (memcmp (&gateway_addr, ipv4gateway, 4) == 0); |
| 679 |
} |
| 680 |
|
| 681 |
{ |
| 682 |
MbimIPv4 dns_addr_1 = { .addr = { 0x0A, 0xB1, 0x00, 0x22 } }; |
| 683 |
MbimIPv4 dns_addr_2 = { .addr = { 0x0A, 0xB1, 0x00, 0xD2 } }; |
| 684 |
|
| 685 |
g_assert_cmpuint (ipv4dnsservercount, ==, 2); |
| 686 |
g_assert (memcmp (&dns_addr_1, &ipv4dnsserver[0], 4) == 0); |
| 687 |
g_assert (memcmp (&dns_addr_2, &ipv4dnsserver[1], 4) == 0); |
| 688 |
} |
| 689 |
|
| 690 |
g_assert_cmpuint (ipv4mtu, ==, 1500); |
| 691 |
|
| 692 |
{ |
| 693 |
MbimIPv6 addr = { .addr = { 0x26, 0x07, 0xFB, 0x90, |
| 694 |
0x64, 0x3B, 0x28, 0x1F, |
| 695 |
0x1D, 0xFF, 0xBF, 0x3D, |
| 696 |
0xC5, 0xC8, 0x48, 0xAD } }; |
| 697 |
|
| 698 |
g_assert_cmpuint (ipv6addresscount, ==, 1); |
| 699 |
g_assert_cmpuint (ipv6address[0]->on_link_prefix_length, ==, 64); |
| 700 |
g_assert (memcmp (&addr, &(ipv6address[0]->ipv6_address), 16) == 0); |
| 701 |
} |
| 702 |
|
| 703 |
{ |
| 704 |
MbimIPv6 dns_addr_1 = { .addr = { 0xFD, 0x00, 0x97, 0x6A, |
| 705 |
0x00, 0x00, 0x00, 0x00, |
| 706 |
0x00, 0x00, 0x00, 0x00, |
| 707 |
0x00, 0x00, 0x00, 0x09 } }; |
| 708 |
MbimIPv6 dns_addr_2 = { .addr = { 0xFD, 0x00, 0x97, 0x6A, |
| 709 |
0x00, 0x00, 0x00, 0x00, |
| 710 |
0x00, 0x00, 0x00, 0x00, |
| 711 |
0x00, 0x00, 0x00, 0x10 } }; |
| 712 |
|
| 713 |
g_assert_cmpuint (ipv6dnsservercount, ==, 2); |
| 714 |
g_assert (memcmp (&dns_addr_1, &ipv6dnsserver[0], 16) == 0); |
| 715 |
g_assert (memcmp (&dns_addr_2, &ipv6dnsserver[1], 16) == 0); |
| 716 |
} |
| 717 |
} |
| 718 |
|
| 719 |
static void |
| 720 |
test_basic_connect_service_activation (void) |
| 721 |
{ |
| 722 |
guint32 nw_error; |
| 723 |
const guint8 *databuffer; |
| 724 |
guint32 databuffer_size; |
| 725 |
g_autoptr(GError) error = NULL; |
| 726 |
g_autoptr(MbimMessage) response = NULL; |
| 727 |
|
| 728 |
const guint8 expected_databuffer [] = { |
| 729 |
0x01, 0x02, 0x03, 0x04, |
| 730 |
0x05, 0x06, 0x07, 0x08 |
| 731 |
}; |
| 732 |
const guint8 buffer [] = { |
| 733 |
/* header */ |
| 734 |
0x03, 0x00, 0x00, 0x80, /* type */ |
| 735 |
0x3C, 0x00, 0x00, 0x00, /* length */ |
| 736 |
0x02, 0x00, 0x00, 0x00, /* transaction id */ |
| 737 |
/* fragment header */ |
| 738 |
0x01, 0x00, 0x00, 0x00, /* total */ |
| 739 |
0x00, 0x00, 0x00, 0x00, /* current */ |
| 740 |
/* command_done_message */ |
| 741 |
0xA2, 0x89, 0xCC, 0x33, /* service id */ |
| 742 |
0xBC, 0xBB, 0x8B, 0x4F, |
| 743 |
0xB6, 0xB0, 0x13, 0x3E, |
| 744 |
0xC2, 0xAA, 0xE6, 0xDF, |
| 745 |
0x0E, 0x00, 0x00, 0x00, /* command id */ |
| 746 |
0x00, 0x00, 0x00, 0x00, /* status code */ |
| 747 |
0x0C, 0x00, 0x00, 0x00, /* buffer length */ |
| 748 |
/* information buffer */ |
| 749 |
0x06, 0x00, 0x00, 0x00, /* nw error */ |
| 750 |
0x01, 0x02, 0x03, 0x04, /* buffer */ |
| 751 |
0x05, 0x06, 0x07, 0x08 }; |
| 752 |
|
| 753 |
response = mbim_message_new (buffer, sizeof (buffer)); |
| 754 |
g_assert (mbim_message_validate (response, &error)); |
| 755 |
g_assert_no_error (error); |
| 756 |
|
| 757 |
test_message_printable (response, 1, 0); |
| 758 |
|
| 759 |
g_assert (mbim_message_service_activation_response_parse ( |
| 760 |
response, |
| 761 |
&nw_error, |
| 762 |
&databuffer_size, |
| 763 |
&databuffer, |
| 764 |
&error)); |
| 765 |
|
| 766 |
g_assert_no_error (error); |
| 767 |
|
| 768 |
g_assert_cmpuint (nw_error, ==, MBIM_NW_ERROR_ILLEGAL_ME); |
| 769 |
g_assert_cmpuint (databuffer_size, ==, sizeof (expected_databuffer)); |
| 770 |
g_assert (memcmp (databuffer, expected_databuffer, databuffer_size) == 0); |
| 771 |
} |
| 772 |
|
| 773 |
static void |
| 774 |
test_basic_connect_register_state (void) |
| 775 |
{ |
| 776 |
MbimNwError nw_error; |
| 777 |
MbimRegisterState register_state; |
| 778 |
MbimRegisterMode register_mode; |
| 779 |
MbimDataClass available_data_classes; |
| 780 |
MbimCellularClass current_cellular_class; |
| 781 |
MbimRegistrationFlag registration_flag; |
| 782 |
g_autofree gchar *provider_id; |
| 783 |
g_autofree gchar *provider_name; |
| 784 |
g_autofree gchar *roaming_text; |
| 785 |
g_autoptr(GError) error = NULL; |
| 786 |
g_autoptr(MbimMessage) response = NULL; |
| 787 |
|
| 788 |
const guint8 buffer [] = { |
| 789 |
/* header */ |
| 790 |
0x03, 0x00, 0x00, 0x80, /* type */ |
| 791 |
0x6C, 0x00, 0x00, 0x00, /* length */ |
| 792 |
0x12, 0x00, 0x00, 0x00, /* transaction id */ |
| 793 |
/* fragment header */ |
| 794 |
0x01, 0x00, 0x00, 0x00, /* total */ |
| 795 |
0x00, 0x00, 0x00, 0x00, /* current */ |
| 796 |
/* command_done message */ |
| 797 |
0xA2, 0x89, 0xCC, 0x33, /* service id */ |
| 798 |
0xBC, 0xBB, 0x8B, 0x4F, |
| 799 |
0xB6, 0xB0, 0x13, 0x3E, |
| 800 |
0xC2, 0xAA, 0xE6, 0xDF, |
| 801 |
0x09, 0x00, 0x00, 0x00, /* command id */ |
| 802 |
0x00, 0x00, 0x00, 0x00, /* status code */ |
| 803 |
0x3C, 0x00, 0x00, 0x00, /* buffer length */ |
| 804 |
/* information buffer */ |
| 805 |
0x00, 0x00, 0x00, 0x00, /* nw error */ |
| 806 |
0x03, 0x00, 0x00, 0x00, /* register state */ |
| 807 |
0x01, 0x00, 0x00, 0x00, /* register mode */ |
| 808 |
0x1C, 0x00, 0x00, 0x00, /* available data classes */ |
| 809 |
0x01, 0x00, 0x00, 0x00, /* current cellular class */ |
| 810 |
0x30, 0x00, 0x00, 0x00, /* provider id offset */ |
| 811 |
0x0A, 0x00, 0x00, 0x00, /* provider id size */ |
| 812 |
0x00, 0x00, 0x00, 0x00, /* provider name offset */ |
| 813 |
0x00, 0x00, 0x00, 0x00, /* provider name size */ |
| 814 |
0x00, 0x00, 0x00, 0x00, /* roaming text offset */ |
| 815 |
0x00, 0x00, 0x00, 0x00, /* roaming text size */ |
| 816 |
0x02, 0x00, 0x00, 0x00, /* registration flag */ |
| 817 |
/* data buffer */ |
| 818 |
0x32, 0x00, 0x36, 0x00, |
| 819 |
0x30, 0x00, 0x30, 0x00, |
| 820 |
0x36, 0x00, 0x00, 0x00 }; |
| 821 |
|
| 822 |
response = mbim_message_new (buffer, sizeof (buffer)); |
| 823 |
g_assert (mbim_message_validate (response, &error)); |
| 824 |
g_assert_no_error (error); |
| 825 |
|
| 826 |
test_message_printable (response, 1, 0); |
| 827 |
|
| 828 |
g_assert (mbim_message_register_state_response_parse ( |
| 829 |
response, |
| 830 |
&nw_error, |
| 831 |
®ister_state, |
| 832 |
®ister_mode, |
| 833 |
&available_data_classes, |
| 834 |
¤t_cellular_class, |
| 835 |
&provider_id, |
| 836 |
&provider_name, |
| 837 |
&roaming_text, |
| 838 |
®istration_flag, |
| 839 |
&error)); |
| 840 |
|
| 841 |
g_assert_no_error (error); |
| 842 |
|
| 843 |
g_assert_cmpuint (nw_error, ==, MBIM_NW_ERROR_NONE); |
| 844 |
g_assert_cmpuint (register_state, ==, MBIM_REGISTER_STATE_HOME); |
| 845 |
g_assert_cmpuint (register_mode, ==, MBIM_REGISTER_MODE_AUTOMATIC); |
| 846 |
g_assert_cmpuint (available_data_classes, ==, (MBIM_DATA_CLASS_UMTS | |
| 847 |
MBIM_DATA_CLASS_HSDPA | |
| 848 |
MBIM_DATA_CLASS_HSUPA)); |
| 849 |
g_assert_cmpuint (current_cellular_class, ==, MBIM_CELLULAR_CLASS_GSM); |
| 850 |
g_assert_cmpstr (provider_id, ==, "26006"); |
| 851 |
g_assert (provider_name == NULL); |
| 852 |
g_assert (roaming_text == NULL); |
| 853 |
g_assert_cmpuint (registration_flag, ==, MBIM_REGISTRATION_FLAG_PACKET_SERVICE_AUTOMATIC_ATTACH); |
| 854 |
} |
| 855 |
|
| 856 |
static void |
| 857 |
test_provisioned_contexts (void) |
| 858 |
{ |
| 859 |
guint32 provisioned_contexts_count = 0; |
| 860 |
g_autoptr(MbimProvisionedContextElementArray) provisioned_contexts = NULL; |
| 861 |
g_autoptr(GError) error = NULL; |
| 862 |
g_autoptr(MbimMessage) response = NULL; |
| 863 |
|
| 864 |
const guint8 buffer [] = { |
| 865 |
/* header */ |
| 866 |
0x03, 0x00, 0x00, 0x80, /* type */ |
| 867 |
0x30, 0x00, 0x00, 0x00, /* length */ |
| 868 |
0x1C, 0x00, 0x00, 0x00, /* transaction id */ |
| 869 |
/* fragment header */ |
| 870 |
0x01, 0x00, 0x00, 0x00, /* total */ |
| 871 |
0x00, 0x00, 0x00, 0x00, /* length */ |
| 872 |
/* command_done_message */ |
| 873 |
0xA2, 0x89, 0xCC, 0x33, /* service id */ |
| 874 |
0xBC, 0xBB, 0x8B, 0x4F, |
| 875 |
0xB6, 0xB0, 0x13, 0x3E, |
| 876 |
0xC2, 0xAA, 0xE6, 0xDF, |
| 877 |
0x0D, 0x00, 0x00, 0x00, /* command id */ |
| 878 |
0x00, 0x00, 0x00, 0x00, /* status code */ |
| 879 |
0x00, 0x00, 0x00, 0x00 /* buffer length */ |
| 880 |
}; |
| 881 |
|
| 882 |
response = mbim_message_new (buffer, sizeof (buffer)); |
| 883 |
g_assert (mbim_message_validate (response, &error)); |
| 884 |
g_assert_no_error (error); |
| 885 |
|
| 886 |
test_message_printable (response, 1, 0); |
| 887 |
|
| 888 |
g_assert (!mbim_message_provisioned_contexts_response_parse ( |
| 889 |
response, |
| 890 |
&provisioned_contexts_count, |
| 891 |
&provisioned_contexts, |
| 892 |
&error)); |
| 893 |
|
| 894 |
g_assert_error (error, MBIM_CORE_ERROR, MBIM_CORE_ERROR_INVALID_MESSAGE); |
| 895 |
} |
| 896 |
|
| 897 |
static void |
| 898 |
test_sms_read_zero_pdu (void) |
| 899 |
{ |
| 900 |
MbimSmsFormat format; |
| 901 |
guint32 messages_count; |
| 902 |
g_autoptr(MbimSmsPduReadRecordArray) pdu_messages = NULL; |
| 903 |
g_autoptr(MbimSmsCdmaReadRecordArray) cdma_messages = NULL; |
| 904 |
g_autoptr(GError) error = NULL; |
| 905 |
g_autoptr(MbimMessage) response = NULL; |
| 906 |
|
| 907 |
const guint8 buffer [] = { |
| 908 |
/* header */ |
| 909 |
0x03, 0x00, 0x00, 0x80, /* type */ |
| 910 |
0x38, 0x00, 0x00, 0x00, /* length */ |
| 911 |
0x02, 0x00, 0x00, 0x00, /* transaction id */ |
| 912 |
/* fragment header */ |
| 913 |
0x01, 0x00, 0x00, 0x00, /* total */ |
| 914 |
0x00, 0x00, 0x00, 0x00, /* current */ |
| 915 |
/* command_done_message */ |
| 916 |
0x53, 0x3F, 0xBE, 0xEB, /* service id */ |
| 917 |
0x14, 0xFE, 0x44, 0x67, |
| 918 |
0x9F, 0x90, 0x33, 0xA2, |
| 919 |
0x23, 0xE5, 0x6C, 0x3F, |
| 920 |
0x02, 0x00, 0x00, 0x00, /* command id */ |
| 921 |
0x00, 0x00, 0x00, 0x00, /* status code */ |
| 922 |
0x08, 0x00, 0x00, 0x00, /* buffer length */ |
| 923 |
/* information buffer */ |
| 924 |
0x00, 0x00, 0x00, 0x00, /* 0x00 format */ |
| 925 |
0x00, 0x00, 0x00, 0x00, /* 0x04 messages count */ |
| 926 |
}; |
| 927 |
|
| 928 |
response = mbim_message_new (buffer, sizeof (buffer)); |
| 929 |
g_assert (mbim_message_validate (response, &error)); |
| 930 |
g_assert_no_error (error); |
| 931 |
|
| 932 |
test_message_printable (response, 1, 0); |
| 933 |
|
| 934 |
g_assert (mbim_message_sms_read_response_parse ( |
| 935 |
response, |
| 936 |
&format, |
| 937 |
&messages_count, |
| 938 |
&pdu_messages, |
| 939 |
&cdma_messages, |
| 940 |
&error)); |
| 941 |
g_assert_no_error (error); |
| 942 |
|
| 943 |
g_assert_cmpuint (format, ==, MBIM_SMS_FORMAT_PDU); |
| 944 |
g_assert_cmpuint (messages_count, ==, 0); |
| 945 |
g_assert (pdu_messages == NULL); |
| 946 |
g_assert (cdma_messages == NULL); |
| 947 |
} |
| 948 |
|
| 949 |
static void |
| 950 |
test_sms_read_single_pdu (void) |
| 951 |
{ |
| 952 |
MbimSmsFormat format; |
| 953 |
guint32 messages_count; |
| 954 |
g_autoptr(MbimSmsPduReadRecordArray) pdu_messages = NULL; |
| 955 |
g_autoptr(MbimSmsCdmaReadRecordArray) cdma_messages = NULL; |
| 956 |
g_autoptr(GError) error = NULL; |
| 957 |
g_autoptr(MbimMessage) response = NULL; |
| 958 |
|
| 959 |
const guint8 buffer [] = { |
| 960 |
/* header */ |
| 961 |
0x03, 0x00, 0x00, 0x80, /* type */ |
| 962 |
0x60, 0x00, 0x00, 0x00, /* length */ |
| 963 |
0x02, 0x00, 0x00, 0x00, /* transaction id */ |
| 964 |
/* fragment header */ |
| 965 |
0x01, 0x00, 0x00, 0x00, /* total */ |
| 966 |
0x00, 0x00, 0x00, 0x00, /* current */ |
| 967 |
/* command_done_message */ |
| 968 |
0x53, 0x3F, 0xBE, 0xEB, /* service id */ |
| 969 |
0x14, 0xFE, 0x44, 0x67, |
| 970 |
0x9F, 0x90, 0x33, 0xA2, |
| 971 |
0x23, 0xE5, 0x6C, 0x3F, |
| 972 |
0x02, 0x00, 0x00, 0x00, /* command id */ |
| 973 |
0x00, 0x00, 0x00, 0x00, /* status code */ |
| 974 |
0x30, 0x00, 0x00, 0x00, /* buffer length */ |
| 975 |
/* information buffer */ |
| 976 |
0x00, 0x00, 0x00, 0x00, /* 0x00 format */ |
| 977 |
0x01, 0x00, 0x00, 0x00, /* 0x04 messages count */ |
| 978 |
0x10, 0x00, 0x00, 0x00, /* 0x08 message 1 offset */ |
| 979 |
0x20, 0x00, 0x00, 0x00, /* 0x0C message 1 length */ |
| 980 |
/* data buffer... message 1 */ |
| 981 |
0x07, 0x00, 0x00, 0x00, /* 0x10 0x00 message index */ |
| 982 |
0x03, 0x00, 0x00, 0x00, /* 0x14 0x04 message status */ |
| 983 |
0x10, 0x00, 0x00, 0x00, /* 0x18 0x08 pdu data offset (w.r.t. pdu start */ |
| 984 |
0x10, 0x00, 0x00, 0x00, /* 0x1C 0x0C pdu data length */ |
| 985 |
/* pdu data... */ |
| 986 |
0x01, 0x02, 0x03, 0x04, /* 0x20 0x10 */ |
| 987 |
0x05, 0x06, 0x07, 0x08, |
| 988 |
0x09, 0x0A, 0x0B, 0x0C, |
| 989 |
0x0D, 0x0E, 0x0F, 0x00 |
| 990 |
}; |
| 991 |
|
| 992 |
const guint8 expected_pdu [] = { |
| 993 |
0x01, 0x02, 0x03, 0x04, |
| 994 |
0x05, 0x06, 0x07, 0x08, |
| 995 |
0x09, 0x0A, 0x0B, 0x0C, |
| 996 |
0x0D, 0x0E, 0x0F, 0x00 |
| 997 |
}; |
| 998 |
|
| 999 |
response = mbim_message_new (buffer, sizeof (buffer)); |
| 1000 |
g_assert (mbim_message_validate (response, &error)); |
| 1001 |
g_assert_no_error (error); |
| 1002 |
|
| 1003 |
test_message_printable (response, 1, 0); |
| 1004 |
|
| 1005 |
g_assert (mbim_message_sms_read_response_parse ( |
| 1006 |
response, |
| 1007 |
&format, |
| 1008 |
&messages_count, |
| 1009 |
&pdu_messages, |
| 1010 |
&cdma_messages, |
| 1011 |
&error)); |
| 1012 |
g_assert_no_error (error); |
| 1013 |
|
| 1014 |
g_assert_cmpuint (format, ==, MBIM_SMS_FORMAT_PDU); |
| 1015 |
g_assert_cmpuint (messages_count, ==, 1); |
| 1016 |
g_assert (pdu_messages != NULL); |
| 1017 |
g_assert (cdma_messages == NULL); |
| 1018 |
|
| 1019 |
g_assert_cmpuint (pdu_messages[0]->message_index, ==, 7); |
| 1020 |
g_assert_cmpuint (pdu_messages[0]->message_status, ==, MBIM_SMS_STATUS_SENT); |
| 1021 |
test_message_trace (pdu_messages[0]->pdu_data, |
| 1022 |
pdu_messages[0]->pdu_data_size, |
| 1023 |
expected_pdu, |
| 1024 |
sizeof (expected_pdu)); |
| 1025 |
g_assert_cmpuint (pdu_messages[0]->pdu_data_size, ==, sizeof (expected_pdu)); |
| 1026 |
g_assert (memcmp (pdu_messages[0]->pdu_data, expected_pdu, sizeof (expected_pdu)) == 0); |
| 1027 |
} |
| 1028 |
|
| 1029 |
static void |
| 1030 |
test_sms_read_multiple_pdu (void) |
| 1031 |
{ |
| 1032 |
guint32 idx; |
| 1033 |
MbimSmsFormat format; |
| 1034 |
guint32 messages_count; |
| 1035 |
g_autoptr(MbimSmsPduReadRecordArray) pdu_messages = NULL; |
| 1036 |
g_autoptr(MbimSmsCdmaReadRecordArray) cdma_messages = NULL; |
| 1037 |
g_autoptr(GError) error = NULL; |
| 1038 |
g_autoptr(MbimMessage) response = NULL; |
| 1039 |
|
| 1040 |
const guint8 buffer [] = { |
| 1041 |
/* header */ |
| 1042 |
0x03, 0x00, 0x00, 0x80, /* type */ |
| 1043 |
0x88, 0x00, 0x00, 0x00, /* length */ |
| 1044 |
0x02, 0x00, 0x00, 0x00, /* transaction id */ |
| 1045 |
/* fragment header */ |
| 1046 |
0x01, 0x00, 0x00, 0x00, /* total */ |
| 1047 |
0x00, 0x00, 0x00, 0x00, /* current */ |
| 1048 |
/* command_done_message */ |
| 1049 |
0x53, 0x3F, 0xBE, 0xEB, /* service id */ |
| 1050 |
0x14, 0xFE, 0x44, 0x67, |
| 1051 |
0x9F, 0x90, 0x33, 0xA2, |
| 1052 |
0x23, 0xE5, 0x6C, 0x3F, |
| 1053 |
0x02, 0x00, 0x00, 0x00, /* command id */ |
| 1054 |
0x00, 0x00, 0x00, 0x00, /* status code */ |
| 1055 |
0x58, 0x00, 0x00, 0x00, /* buffer length */ |
| 1056 |
/* information buffer */ |
| 1057 |
0x00, 0x00, 0x00, 0x00, /* 0x00 format */ |
| 1058 |
0x02, 0x00, 0x00, 0x00, /* 0x04 messages count */ |
| 1059 |
0x18, 0x00, 0x00, 0x00, /* 0x08 message 1 offset */ |
| 1060 |
0x20, 0x00, 0x00, 0x00, /* 0x0C message 1 length */ |
| 1061 |
0x38, 0x00, 0x00, 0x00, /* 0x10 message 2 offset */ |
| 1062 |
0x24, 0x00, 0x00, 0x00, /* 0x14 message 2 length */ |
| 1063 |
/* data buffer... message 1 */ |
| 1064 |
0x06, 0x00, 0x00, 0x00, /* 0x18 0x00 message index */ |
| 1065 |
0x03, 0x00, 0x00, 0x00, /* 0x1C 0x04 message status */ |
| 1066 |
0x10, 0x00, 0x00, 0x00, /* 0x20 0x08 pdu data offset (w.r.t. pdu start */ |
| 1067 |
0x10, 0x00, 0x00, 0x00, /* 0x24 0x0C pdu data length */ |
| 1068 |
/* pdu data... */ |
| 1069 |
0x01, 0x02, 0x03, 0x04, /* 0x28 0x10 */ |
| 1070 |
0x05, 0x06, 0x07, 0x08, |
| 1071 |
0x09, 0x0A, 0x0B, 0x0C, |
| 1072 |
0x0D, 0x0E, 0x0F, 0x00, |
| 1073 |
/* data buffer... message 2 */ |
| 1074 |
0x07, 0x00, 0x00, 0x00, /* 0x38 0x00 message index */ |
| 1075 |
0x03, 0x00, 0x00, 0x00, /* 0x3C 0x04 message status */ |
| 1076 |
0x10, 0x00, 0x00, 0x00, /* 0x40 0x08 pdu data offset (w.r.t. pdu start */ |
| 1077 |
0x10, 0x00, 0x00, 0x00, /* 0x44 0x0C pdu data length */ |
| 1078 |
/* pdu data... */ |
| 1079 |
0x00, 0x01, 0x02, 0x03, /* 0x48 0x10 */ |
| 1080 |
0x04, 0x05, 0x06, 0x07, |
| 1081 |
0x08, 0x09, 0x0A, 0x0B, |
| 1082 |
0x0C, 0x0D, 0x0E, 0x0F |
| 1083 |
}; |
| 1084 |
|
| 1085 |
const guint8 expected_pdu_idx6 [] = { |
| 1086 |
0x01, 0x02, 0x03, 0x04, |
| 1087 |
0x05, 0x06, 0x07, 0x08, |
| 1088 |
0x09, 0x0A, 0x0B, 0x0C, |
| 1089 |
0x0D, 0x0E, 0x0F, 0x00 |
| 1090 |
}; |
| 1091 |
|
| 1092 |
const guint8 expected_pdu_idx7 [] = { |
| 1093 |
0x00, 0x01, 0x02, 0x03, |
| 1094 |
0x04, 0x05, 0x06, 0x07, |
| 1095 |
0x08, 0x09, 0x0A, 0x0B, |
| 1096 |
0x0C, 0x0D, 0x0E, 0x0F |
| 1097 |
}; |
| 1098 |
|
| 1099 |
response = mbim_message_new (buffer, sizeof (buffer)); |
| 1100 |
g_assert (mbim_message_validate (response, &error)); |
| 1101 |
g_assert_no_error (error); |
| 1102 |
|
| 1103 |
test_message_printable (response, 1, 0); |
| 1104 |
|
| 1105 |
g_assert (mbim_message_sms_read_response_parse ( |
| 1106 |
response, |
| 1107 |
&format, |
| 1108 |
&messages_count, |
| 1109 |
&pdu_messages, |
| 1110 |
&cdma_messages, |
| 1111 |
&error)); |
| 1112 |
g_assert_no_error (error); |
| 1113 |
|
| 1114 |
g_assert_cmpuint (format, ==, MBIM_SMS_FORMAT_PDU); |
| 1115 |
g_assert_cmpuint (messages_count, ==, 2); |
| 1116 |
g_assert (pdu_messages != NULL); |
| 1117 |
g_assert (cdma_messages == NULL); |
| 1118 |
|
| 1119 |
/* First message with index 6 */ |
| 1120 |
if (pdu_messages[0]->message_index == 6) |
| 1121 |
idx = 0; |
| 1122 |
else if (pdu_messages[1]->message_index == 6) |
| 1123 |
idx = 1; |
| 1124 |
else |
| 1125 |
g_assert_not_reached (); |
| 1126 |
g_assert_cmpuint (pdu_messages[idx]->message_index, ==, 6); |
| 1127 |
g_assert_cmpuint (pdu_messages[idx]->message_status, ==, MBIM_SMS_STATUS_SENT); |
| 1128 |
test_message_trace (pdu_messages[idx]->pdu_data, |
| 1129 |
pdu_messages[idx]->pdu_data_size, |
| 1130 |
expected_pdu_idx6, |
| 1131 |
sizeof (expected_pdu_idx6)); |
| 1132 |
g_assert_cmpuint (pdu_messages[idx]->pdu_data_size, ==, sizeof (expected_pdu_idx6)); |
| 1133 |
g_assert (memcmp (pdu_messages[idx]->pdu_data, expected_pdu_idx6, sizeof (expected_pdu_idx6)) == 0); |
| 1134 |
|
| 1135 |
/* Second message with index 7 */ |
| 1136 |
if (pdu_messages[0]->message_index == 7) |
| 1137 |
idx = 0; |
| 1138 |
else if (pdu_messages[1]->message_index == 7) |
| 1139 |
idx = 1; |
| 1140 |
else |
| 1141 |
g_assert_not_reached (); |
| 1142 |
g_assert_cmpuint (pdu_messages[idx]->message_index, ==, 7); |
| 1143 |
g_assert_cmpuint (pdu_messages[idx]->message_status, ==, MBIM_SMS_STATUS_SENT); |
| 1144 |
test_message_trace (pdu_messages[idx]->pdu_data, |
| 1145 |
pdu_messages[idx]->pdu_data_size, |
| 1146 |
expected_pdu_idx7, |
| 1147 |
sizeof (expected_pdu_idx7)); |
| 1148 |
g_assert_cmpuint (pdu_messages[idx]->pdu_data_size, ==, sizeof (expected_pdu_idx7)); |
| 1149 |
g_assert (memcmp (pdu_messages[idx]->pdu_data, expected_pdu_idx7, sizeof (expected_pdu_idx7)) == 0); |
| 1150 |
} |
| 1151 |
|
| 1152 |
static void |
| 1153 |
test_ussd (void) |
| 1154 |
{ |
| 1155 |
MbimUssdResponse ussd_response; |
| 1156 |
MbimUssdSessionState ussd_session_state; |
| 1157 |
const guint8 *ussd_payload; |
| 1158 |
guint32 ussd_payload_size; |
| 1159 |
guint32 ussd_dcs; |
| 1160 |
g_autoptr(GError) error = NULL; |
| 1161 |
g_autoptr(MbimMessage) response = NULL; |
| 1162 |
|
| 1163 |
const guint8 buffer [] = { |
| 1164 |
/* header */ |
| 1165 |
0x03, 0x00, 0x00, 0x80, /* type */ |
| 1166 |
0x54, 0x00, 0x00, 0x00, /* length */ |
| 1167 |
0x02, 0x00, 0x00, 0x00, /* transaction id */ |
| 1168 |
/* fragment header */ |
| 1169 |
0x01, 0x00, 0x00, 0x00, /* total */ |
| 1170 |
0x00, 0x00, 0x00, 0x00, /* current */ |
| 1171 |
/* command_done_message */ |
| 1172 |
0xE5, 0x50, 0xA0, 0xC8, /* service id */ |
| 1173 |
0x5E, 0x82, 0x47, 0x9E, |
| 1174 |
0x82, 0xF7, 0x10, 0xAB, |
| 1175 |
0xF4, 0xC3, 0x35, 0x1F, |
| 1176 |
0x01, 0x00, 0x00, 0x00, /* command id */ |
| 1177 |
0x00, 0x00, 0x00, 0x00, /* status code */ |
| 1178 |
0x24, 0x00, 0x00, 0x00, /* buffer length */ |
| 1179 |
/* information buffer */ |
| 1180 |
0x05, 0x00, 0x00, 0x00, /* 0x00 response */ |
| 1181 |
0x01, 0x00, 0x00, 0x00, /* 0x04 sesstion state */ |
| 1182 |
0x01, 0x00, 0x00, 0x00, /* 0x08 coding scheme */ |
| 1183 |
0x14, 0x00, 0x00, 0x00, /* 0x0C payload offset */ |
| 1184 |
0x10, 0x00, 0x00, 0x00, /* 0x10 payload length */ |
| 1185 |
/* data buffer... payload */ |
| 1186 |
0x01, 0x02, 0x03, 0x04, /* 0x14 payload */ |
| 1187 |
0x05, 0x06, 0x07, 0x08, |
| 1188 |
0x09, 0x0A, 0x0B, 0x0C, |
| 1189 |
0x0D, 0x0E, 0x0F, 0x00 |
| 1190 |
}; |
| 1191 |
|
| 1192 |
const guint8 expected_payload [] = { |
| 1193 |
0x01, 0x02, 0x03, 0x04, |
| 1194 |
0x05, 0x06, 0x07, 0x08, |
| 1195 |
0x09, 0x0A, 0x0B, 0x0C, |
| 1196 |
0x0D, 0x0E, 0x0F, 0x00 |
| 1197 |
}; |
| 1198 |
|
| 1199 |
response = mbim_message_new (buffer, sizeof (buffer)); |
| 1200 |
g_assert (mbim_message_validate (response, &error)); |
| 1201 |
g_assert_no_error (error); |
| 1202 |
|
| 1203 |
test_message_printable (response, 1, 0); |
| 1204 |
|
| 1205 |
g_assert (mbim_message_ussd_response_parse ( |
| 1206 |
response, |
| 1207 |
&ussd_response, |
| 1208 |
&ussd_session_state, |
| 1209 |
&ussd_dcs, |
| 1210 |
&ussd_payload_size, |
| 1211 |
&ussd_payload, |
| 1212 |
&error)); |
| 1213 |
g_assert_no_error (error); |
| 1214 |
|
| 1215 |
g_assert_cmpuint (ussd_response, ==, MBIM_USSD_RESPONSE_NETWORK_TIMEOUT); |
| 1216 |
g_assert_cmpuint (ussd_session_state, ==, MBIM_USSD_SESSION_STATE_EXISTING_SESSION); |
| 1217 |
g_assert_cmpuint (ussd_dcs, ==, 0x01); |
| 1218 |
|
| 1219 |
test_message_trace (ussd_payload, |
| 1220 |
ussd_payload_size, |
| 1221 |
expected_payload, |
| 1222 |
sizeof (expected_payload)); |
| 1223 |
g_assert_cmpuint (ussd_payload_size, ==, sizeof (expected_payload)); |
| 1224 |
g_assert (memcmp (ussd_payload, expected_payload, sizeof (expected_payload)) == 0); |
| 1225 |
} |
| 1226 |
|
| 1227 |
static void |
| 1228 |
test_auth_akap (void) |
| 1229 |
{ |
| 1230 |
const guint8 *res; |
| 1231 |
guint32 res_len; |
| 1232 |
const guint8 *ik; |
| 1233 |
const guint8 *ck; |
| 1234 |
const guint8 *auts; |
| 1235 |
g_autoptr(GError) error = NULL; |
| 1236 |
g_autoptr(MbimMessage) response = NULL; |
| 1237 |
|
| 1238 |
const guint8 buffer [] = { |
| 1239 |
/* header */ |
| 1240 |
0x03, 0x00, 0x00, 0x80, /* type */ |
| 1241 |
0x74, 0x00, 0x00, 0x00, /* length */ |
| 1242 |
0x02, 0x00, 0x00, 0x00, /* transaction id */ |
| 1243 |
/* fragment header */ |
| 1244 |
0x01, 0x00, 0x00, 0x00, /* total */ |
| 1245 |
0x00, 0x00, 0x00, 0x00, /* current */ |
| 1246 |
/* command_done_message */ |
| 1247 |
0x1D, 0x2B, 0x5F, 0xF7, /* service id */ |
| 1248 |
0x0A, 0xA1, 0x48, 0xB2, |
| 1249 |
0xAA, 0x52, 0x50, 0xF1, |
| 1250 |
0x57, 0x67, 0x17, 0x4E, |
| 1251 |
0x02, 0x00, 0x00, 0x00, /* command id */ |
| 1252 |
0x00, 0x00, 0x00, 0x00, /* status code */ |
| 1253 |
0x44, 0x00, 0x00, 0x00, /* buffer length */ |
| 1254 |
/* information buffer */ |
| 1255 |
0x00, 0x01, 0x02, 0x03, /* 0x00 Res */ |
| 1256 |
0x04, 0x05, 0x06, 0x07, /* 0x04 */ |
| 1257 |
0x08, 0x09, 0x0A, 0x0B, /* 0x08 */ |
| 1258 |
0x0C, 0x0D, 0x0E, 0x0F, /* 0x0C */ |
| 1259 |
0x05, 0x00, 0x00, 0x00, /* 0x10 Reslen */ |
| 1260 |
0xFF, 0xFE, 0xFD, 0xFC, /* 0x14 IK */ |
| 1261 |
0xFB, 0xFA, 0xF9, 0xF8, /* 0x18 */ |
| 1262 |
0xF7, 0xF6, 0xF5, 0xF4, /* 0x1C */ |
| 1263 |
0xF3, 0xF2, 0xF1, 0xF0, /* 0x20 */ |
| 1264 |
0xAF, 0xAE, 0xAD, 0xAC, /* 0x24 CK */ |
| 1265 |
0xAB, 0xAA, 0xA9, 0xA8, /* 0x28 */ |
| 1266 |
0xA7, 0xA6, 0xA5, 0xA4, /* 0x2C */ |
| 1267 |
0xA3, 0xA2, 0xA1, 0xA0, /* 0x30 */ |
| 1268 |
0x7F, 0x7E, 0x7D, 0x7C, /* 0x34 Auts */ |
| 1269 |
0x7B, 0x7A, 0x79, 0x78, /* 0x38 */ |
| 1270 |
0x77, 0x76, 0x75, 0x74, /* 0x3C */ |
| 1271 |
0x73, 0x72, 0x00, 0x00, /* 0x40 */ |
| 1272 |
}; |
| 1273 |
|
| 1274 |
const guint8 expected_res [] = { |
| 1275 |
0x00, 0x01, 0x02, 0x03, |
| 1276 |
0x04, 0x05, 0x06, 0x07, |
| 1277 |
0x08, 0x09, 0x0A, 0x0B, |
| 1278 |
0x0C, 0x0D, 0x0E, 0x0F, |
| 1279 |
}; |
| 1280 |
const guint8 expected_ik [] = { |
| 1281 |
0xFF, 0xFE, 0xFD, 0xFC, |
| 1282 |
0xFB, 0xFA, 0xF9, 0xF8, |
| 1283 |
0xF7, 0xF6, 0xF5, 0xF4, |
| 1284 |
0xF3, 0xF2, 0xF1, 0xF0, |
| 1285 |
}; |
| 1286 |
const guint8 expected_ck [] = { |
| 1287 |
0xAF, 0xAE, 0xAD, 0xAC, |
| 1288 |
0xAB, 0xAA, 0xA9, 0xA8, |
| 1289 |
0xA7, 0xA6, 0xA5, 0xA4, |
| 1290 |
0xA3, 0xA2, 0xA1, 0xA0, |
| 1291 |
}; |
| 1292 |
const guint8 expected_auts [] = { |
| 1293 |
0x7F, 0x7E, 0x7D, 0x7C, |
| 1294 |
0x7B, 0x7A, 0x79, 0x78, |
| 1295 |
0x77, 0x76, 0x75, 0x74, |
| 1296 |
0x73, 0x72 |
| 1297 |
}; |
| 1298 |
|
| 1299 |
response = mbim_message_new (buffer, sizeof (buffer)); |
| 1300 |
g_assert (mbim_message_validate (response, &error)); |
| 1301 |
g_assert_no_error (error); |
| 1302 |
|
| 1303 |
test_message_printable (response, 1, 0); |
| 1304 |
|
| 1305 |
g_assert (mbim_message_auth_akap_response_parse ( |
| 1306 |
response, |
| 1307 |
&res, |
| 1308 |
&res_len, |
| 1309 |
&ik, |
| 1310 |
&ck, |
| 1311 |
&auts, |
| 1312 |
&error)); |
| 1313 |
g_assert_no_error (error); |
| 1314 |
|
| 1315 |
test_message_trace (res, |
| 1316 |
sizeof (expected_res), |
| 1317 |
expected_res, |
| 1318 |
sizeof (expected_res)); |
| 1319 |
g_assert (memcmp (res, expected_res, sizeof (expected_res)) == 0); |
| 1320 |
|
| 1321 |
g_assert_cmpuint (res_len, ==, 5); |
| 1322 |
|
| 1323 |
test_message_trace (ik, |
| 1324 |
sizeof (expected_ik), |
| 1325 |
expected_ik, |
| 1326 |
sizeof (expected_ik)); |
| 1327 |
g_assert (memcmp (ik, expected_ik, sizeof (expected_ik)) == 0); |
| 1328 |
|
| 1329 |
test_message_trace (ck, |
| 1330 |
sizeof (expected_ck), |
| 1331 |
expected_ck, |
| 1332 |
sizeof (expected_ck)); |
| 1333 |
g_assert (memcmp (ck, expected_ck, sizeof (expected_ck)) == 0); |
| 1334 |
|
| 1335 |
test_message_trace (auts, |
| 1336 |
sizeof (expected_auts), |
| 1337 |
expected_auts, |
| 1338 |
sizeof (expected_auts)); |
| 1339 |
g_assert (memcmp (auts, expected_auts, sizeof (expected_auts)) == 0); |
| 1340 |
} |
| 1341 |
|
| 1342 |
static void |
| 1343 |
test_stk_pac_notification (void) |
| 1344 |
{ |
| 1345 |
const guint8 *databuffer; |
| 1346 |
guint32 databuffer_len; |
| 1347 |
guint32 pac_type; |
| 1348 |
g_autoptr(GError) error = NULL; |
| 1349 |
g_autoptr(MbimMessage) response = NULL; |
| 1350 |
|
| 1351 |
const guint8 buffer [] = { |
| 1352 |
/* header */ |
| 1353 |
0x07, 0x00, 0x00, 0x80, /* type */ |
| 1354 |
0x54, 0x00, 0x00, 0x00, /* length */ |
| 1355 |
0x02, 0x00, 0x00, 0x00, /* transaction id */ |
| 1356 |
/* fragment header */ |
| 1357 |
0x01, 0x00, 0x00, 0x00, /* total */ |
| 1358 |
0x00, 0x00, 0x00, 0x00, /* current */ |
| 1359 |
/* indicate_status_message */ |
| 1360 |
0xD8, 0xF2, 0x01, 0x31, /* service id */ |
| 1361 |
0xFC, 0xB5, 0x4E, 0x17, |
| 1362 |
0x86, 0x02, 0xD6, 0xED, |
| 1363 |
0x38, 0x16, 0x16, 0x4C, |
| 1364 |
0x01, 0x00, 0x00, 0x00, /* command id */ |
| 1365 |
0x28, 0x00, 0x00, 0x00, /* buffer length */ |
| 1366 |
/* information buffer */ |
| 1367 |
0x01, 0x00, 0x00, 0x00, /* 0x00 Pac Type */ |
| 1368 |
0x04, 0x05, 0x06, 0x07, /* 0x04 Data buffer */ |
| 1369 |
0xAF, 0xAE, 0xAD, 0xAC, |
| 1370 |
0xAB, 0xAA, 0xA9, 0xA8, |
| 1371 |
0xA7, 0xA6, 0xA5, 0xA4, |
| 1372 |
0xA3, 0xA2, 0xA1, 0xA0, |
| 1373 |
0x7F, 0x7E, 0x7D, 0x7C, |
| 1374 |
0x7B, 0x7A, 0x79, 0x78, |
| 1375 |
0x77, 0x76, 0x75, 0x74, |
| 1376 |
0x73, 0x72, 0x00, 0x00 |
| 1377 |
}; |
| 1378 |
|
| 1379 |
const guint8 expected_databuffer [] = { |
| 1380 |
0x04, 0x05, 0x06, 0x07, |
| 1381 |
0xAF, 0xAE, 0xAD, 0xAC, |
| 1382 |
0xAB, 0xAA, 0xA9, 0xA8, |
| 1383 |
0xA7, 0xA6, 0xA5, 0xA4, |
| 1384 |
0xA3, 0xA2, 0xA1, 0xA0, |
| 1385 |
0x7F, 0x7E, 0x7D, 0x7C, |
| 1386 |
0x7B, 0x7A, 0x79, 0x78, |
| 1387 |
0x77, 0x76, 0x75, 0x74, |
| 1388 |
0x73, 0x72, 0x00, 0x00 |
| 1389 |
}; |
| 1390 |
|
| 1391 |
response = mbim_message_new (buffer, sizeof (buffer)); |
| 1392 |
g_assert (mbim_message_validate (response, &error)); |
| 1393 |
g_assert_no_error (error); |
| 1394 |
|
| 1395 |
test_message_printable (response, 1, 0); |
| 1396 |
|
| 1397 |
g_assert (mbim_message_stk_pac_notification_parse ( |
| 1398 |
response, |
| 1399 |
&pac_type, |
| 1400 |
&databuffer_len, |
| 1401 |
&databuffer, |
| 1402 |
&error)); |
| 1403 |
g_assert_no_error (error); |
| 1404 |
|
| 1405 |
g_assert_cmpuint (pac_type, ==, MBIM_STK_PAC_TYPE_NOTIFICATION); |
| 1406 |
|
| 1407 |
test_message_trace (databuffer, |
| 1408 |
sizeof (databuffer_len), |
| 1409 |
expected_databuffer, |
| 1410 |
sizeof (expected_databuffer)); |
| 1411 |
g_assert_cmpuint (databuffer_len, ==, sizeof (expected_databuffer)); |
| 1412 |
g_assert (memcmp (databuffer, expected_databuffer, sizeof (expected_databuffer)) == 0); |
| 1413 |
} |
| 1414 |
|
| 1415 |
static void |
| 1416 |
test_stk_pac_response (void) |
| 1417 |
{ |
| 1418 |
const guint8 *databuffer; |
| 1419 |
g_autoptr(GError) error = NULL; |
| 1420 |
g_autoptr(MbimMessage) response = NULL; |
| 1421 |
|
| 1422 |
const guint8 buffer [] = { |
| 1423 |
/* header */ |
| 1424 |
0x03, 0x00, 0x00, 0x80, /* type */ |
| 1425 |
0x30, 0x01, 0x00, 0x00, /* length */ |
| 1426 |
0x02, 0x00, 0x00, 0x00, /* transaction id */ |
| 1427 |
/* fragment header */ |
| 1428 |
0x01, 0x00, 0x00, 0x00, /* total */ |
| 1429 |
0x00, 0x00, 0x00, 0x00, /* current */ |
| 1430 |
/* indicate_status_message */ |
| 1431 |
0xD8, 0xF2, 0x01, 0x31, /* service id */ |
| 1432 |
0xFC, 0xB5, 0x4E, 0x17, |
| 1433 |
0x86, 0x02, 0xD6, 0xED, |
| 1434 |
0x38, 0x16, 0x16, 0x4C, |
| 1435 |
0x01, 0x00, 0x00, 0x00, /* command id */ |
| 1436 |
0x00, 0x00, 0x00, 0x00, /* status code */ |
| 1437 |
0x00, 0x01, 0x00, 0x00, /* buffer length (256) */ |
| 1438 |
/* information buffer */ |
| 1439 |
0x04, 0x05, 0x06, 0x07, |
| 1440 |
0xAF, 0xAE, 0xAD, 0xAC, |
| 1441 |
0xAB, 0xAA, 0xA9, 0xA8, |
| 1442 |
0xA7, 0xA6, 0xA5, 0xA4, |
| 1443 |
0xA3, 0xA2, 0xA1, 0xA0, |
| 1444 |
0x7F, 0x7E, 0x7D, 0x7C, |
| 1445 |
0x7B, 0x7A, 0x79, 0x78, |
| 1446 |
0x77, 0x76, 0x75, 0x74, |
| 1447 |
0x73, 0x72, 0x00, 0x00, |
| 1448 |
0x01, 0x00, 0x00, 0x00, |
| 1449 |
0x04, 0x05, 0x06, 0x07, |
| 1450 |
0xAF, 0xAE, 0xAD, 0xAC, |
| 1451 |
0xAB, 0xAA, 0xA9, 0xA8, |
| 1452 |
0xA7, 0xA6, 0xA5, 0xA4, |
| 1453 |
0xA3, 0xA2, 0xA1, 0xA0, |
| 1454 |
0x7F, 0x7E, 0x7D, 0x7C, |
| 1455 |
0x7B, 0x7A, 0x79, 0x78, |
| 1456 |
0x77, 0x76, 0x75, 0x74, |
| 1457 |
0x73, 0x72, 0x00, 0x00, |
| 1458 |
0x01, 0x00, 0x00, 0x00, |
| 1459 |
0x04, 0x05, 0x06, 0x07, |
| 1460 |
0xAF, 0xAE, 0xAD, 0xAC, |
| 1461 |
0xAB, 0xAA, 0xA9, 0xA8, |
| 1462 |
0xA7, 0xA6, 0xA5, 0xA4, |
| 1463 |
0xA3, 0xA2, 0xA1, 0xA0, |
| 1464 |
0x7F, 0x7E, 0x7D, 0x7C, |
| 1465 |
0x7B, 0x7A, 0x79, 0x78, |
| 1466 |
0x77, 0x76, 0x75, 0x74, |
| 1467 |
0x73, 0x72, 0x00, 0x00, |
| 1468 |
0x01, 0x00, 0x00, 0x00, |
| 1469 |
0x04, 0x05, 0x06, 0x07, |
| 1470 |
0xAF, 0xAE, 0xAD, 0xAC, |
| 1471 |
0xAB, 0xAA, 0xA9, 0xA8, |
| 1472 |
0xA7, 0xA6, 0xA5, 0xA4, |
| 1473 |
0xA3, 0xA2, 0xA1, 0xA0, |
| 1474 |
0x7F, 0x7E, 0x7D, 0x7C, |
| 1475 |
0x7B, 0x7A, 0x79, 0x78, |
| 1476 |
0x77, 0x76, 0x75, 0x74, |
| 1477 |
0x73, 0x72, 0x00, 0x00, |
| 1478 |
0x01, 0x00, 0x00, 0x00, |
| 1479 |
0x04, 0x05, 0x06, 0x07, |
| 1480 |
0xAF, 0xAE, 0xAD, 0xAC, |
| 1481 |
0xAB, 0xAA, 0xA9, 0xA8, |
| 1482 |
0xA7, 0xA6, 0xA5, 0xA4, |
| 1483 |
0xA3, 0xA2, 0xA1, 0xA0, |
| 1484 |
0x7F, 0x7E, 0x7D, 0x7C, |
| 1485 |
0x7B, 0x7A, 0x79, 0x78, |
| 1486 |
0x77, 0x76, 0x75, 0x74, |
| 1487 |
0x73, 0x72, 0x00, 0x00, |
| 1488 |
0x01, 0x00, 0x00, 0x00, |
| 1489 |
0x04, 0x05, 0x06, 0x07, |
| 1490 |
0xAF, 0xAE, 0xAD, 0xAC, |
| 1491 |
0xAB, 0xAA, 0xA9, 0xA8, |
| 1492 |
0xA7, 0xA6, 0xA5, 0xA4, |
| 1493 |
0xA3, 0xA2, 0xA1, 0xA0, |
| 1494 |
0x7F, 0x7E, 0x7D, 0x7C, |
| 1495 |
0x7B, 0x7A, 0x79, 0x78, |
| 1496 |
0x77, 0x76, 0x75, 0x74, |
| 1497 |
0x73, 0x72, 0x00, 0x00, |
| 1498 |
0x01, 0x00, 0x00, 0x00, |
| 1499 |
0x04, 0x05, 0x06, 0x07, |
| 1500 |
0xAF, 0xAE, 0xAD, 0xAC, |
| 1501 |
0xAB, 0xAA, 0xA9, 0xA8, |
| 1502 |
0xA7, 0xA6, 0xA5, 0xA4, |
| 1503 |
}; |
| 1504 |
|
| 1505 |
const guint8 expected_databuffer [256] = { |
| 1506 |
0x04, 0x05, 0x06, 0x07, |
| 1507 |
0xAF, 0xAE, 0xAD, 0xAC, |
| 1508 |
0xAB, 0xAA, 0xA9, 0xA8, |
| 1509 |
0xA7, 0xA6, 0xA5, 0xA4, |
| 1510 |
0xA3, 0xA2, 0xA1, 0xA0, |
| 1511 |
0x7F, 0x7E, 0x7D, 0x7C, |
| 1512 |
0x7B, 0x7A, 0x79, 0x78, |
| 1513 |
0x77, 0x76, 0x75, 0x74, |
| 1514 |
0x73, 0x72, 0x00, 0x00, |
| 1515 |
0x01, 0x00, 0x00, 0x00, |
| 1516 |
0x04, 0x05, 0x06, 0x07, |
| 1517 |
0xAF, 0xAE, 0xAD, 0xAC, |
| 1518 |
0xAB, 0xAA, 0xA9, 0xA8, |
| 1519 |
0xA7, 0xA6, 0xA5, 0xA4, |
| 1520 |
0xA3, 0xA2, 0xA1, 0xA0, |
| 1521 |
0x7F, 0x7E, 0x7D, 0x7C, |
| 1522 |
0x7B, 0x7A, 0x79, 0x78, |
| 1523 |
0x77, 0x76, 0x75, 0x74, |
| 1524 |
0x73, 0x72, 0x00, 0x00, |
| 1525 |
0x01, 0x00, 0x00, 0x00, |
| 1526 |
0x04, 0x05, 0x06, 0x07, |
| 1527 |
0xAF, 0xAE, 0xAD, 0xAC, |
| 1528 |
0xAB, 0xAA, 0xA9, 0xA8, |
| 1529 |
0xA7, 0xA6, 0xA5, 0xA4, |
| 1530 |
0xA3, 0xA2, 0xA1, 0xA0, |
| 1531 |
0x7F, 0x7E, 0x7D, 0x7C, |
| 1532 |
0x7B, 0x7A, 0x79, 0x78, |
| 1533 |
0x77, 0x76, 0x75, 0x74, |
| 1534 |
0x73, 0x72, 0x00, 0x00, |
| 1535 |
0x01, 0x00, 0x00, 0x00, |
| 1536 |
0x04, 0x05, 0x06, 0x07, |
| 1537 |
0xAF, 0xAE, 0xAD, 0xAC, |
| 1538 |
0xAB, 0xAA, 0xA9, 0xA8, |
| 1539 |
0xA7, 0xA6, 0xA5, 0xA4, |
| 1540 |
0xA3, 0xA2, 0xA1, 0xA0, |
| 1541 |
0x7F, 0x7E, 0x7D, 0x7C, |
| 1542 |
0x7B, 0x7A, 0x79, 0x78, |
| 1543 |
0x77, 0x76, 0x75, 0x74, |
| 1544 |
0x73, 0x72, 0x00, 0x00, |
| 1545 |
0x01, 0x00, 0x00, 0x00, |
| 1546 |
0x04, 0x05, 0x06, 0x07, |
| 1547 |
0xAF, 0xAE, 0xAD, 0xAC, |
| 1548 |
0xAB, 0xAA, 0xA9, 0xA8, |
| 1549 |
0xA7, 0xA6, 0xA5, 0xA4, |
| 1550 |
0xA3, 0xA2, 0xA1, 0xA0, |
| 1551 |
0x7F, 0x7E, 0x7D, 0x7C, |
| 1552 |
0x7B, 0x7A, 0x79, 0x78, |
| 1553 |
0x77, 0x76, 0x75, 0x74, |
| 1554 |
0x73, 0x72, 0x00, 0x00, |
| 1555 |
0x01, 0x00, 0x00, 0x00, |
| 1556 |
0x04, 0x05, 0x06, 0x07, |
| 1557 |
0xAF, 0xAE, 0xAD, 0xAC, |
| 1558 |
0xAB, 0xAA, 0xA9, 0xA8, |
| 1559 |
0xA7, 0xA6, 0xA5, 0xA4, |
| 1560 |
0xA3, 0xA2, 0xA1, 0xA0, |
| 1561 |
0x7F, 0x7E, 0x7D, 0x7C, |
| 1562 |
0x7B, 0x7A, 0x79, 0x78, |
| 1563 |
0x77, 0x76, 0x75, 0x74, |
| 1564 |
0x73, 0x72, 0x00, 0x00, |
| 1565 |
0x01, 0x00, 0x00, 0x00, |
| 1566 |
0x04, 0x05, 0x06, 0x07, |
| 1567 |
0xAF, 0xAE, 0xAD, 0xAC, |
| 1568 |
0xAB, 0xAA, 0xA9, 0xA8, |
| 1569 |
0xA7, 0xA6, 0xA5, 0xA4, |
| 1570 |
}; |
| 1571 |
|
| 1572 |
response = mbim_message_new (buffer, sizeof (buffer)); |
| 1573 |
mbim_message_validate (response, &error); |
| 1574 |
g_assert_no_error (error); |
| 1575 |
|
| 1576 |
test_message_printable (response, 1, 0); |
| 1577 |
|
| 1578 |
g_assert (mbim_message_stk_pac_response_parse ( |
| 1579 |
response, |
| 1580 |
&databuffer, |
| 1581 |
&error)); |
| 1582 |
g_assert_no_error (error); |
| 1583 |
|
| 1584 |
test_message_trace (databuffer, |
| 1585 |
sizeof (expected_databuffer), |
| 1586 |
expected_databuffer, |
| 1587 |
sizeof (expected_databuffer)); |
| 1588 |
g_assert (memcmp (databuffer, expected_databuffer, sizeof (expected_databuffer)) == 0); |
| 1589 |
} |
| 1590 |
|
| 1591 |
static void |
| 1592 |
test_stk_terminal_response (void) |
| 1593 |
{ |
| 1594 |
const guint8 *databuffer; |
| 1595 |
guint32 databuffer_len; |
| 1596 |
guint32 status_words; |
| 1597 |
g_autoptr(GError) error = NULL; |
| 1598 |
g_autoptr(MbimMessage) response = NULL; |
| 1599 |
|
| 1600 |
const guint8 buffer [] = { |
| 1601 |
/* header */ |
| 1602 |
0x03, 0x00, 0x00, 0x80, /* type */ |
| 1603 |
0x48, 0x00, 0x00, 0x00, /* length */ |
| 1604 |
0x02, 0x00, 0x00, 0x00, /* transaction id */ |
| 1605 |
/* fragment header */ |
| 1606 |
0x01, 0x00, 0x00, 0x00, /* total */ |
| 1607 |
0x00, 0x00, 0x00, 0x00, /* current */ |
| 1608 |
/* indicate_status_message */ |
| 1609 |
0xD8, 0xF2, 0x01, 0x31, /* service id */ |
| 1610 |
0xFC, 0xB5, 0x4E, 0x17, |
| 1611 |
0x86, 0x02, 0xD6, 0xED, |
| 1612 |
0x38, 0x16, 0x16, 0x4C, |
| 1613 |
0x02, 0x00, 0x00, 0x00, /* command id */ |
| 1614 |
0x00, 0x00, 0x00, 0x00, /* status code */ |
| 1615 |
0x18, 0x00, 0x00, 0x00, /* buffer length */ |
| 1616 |
/* information buffer */ |
| 1617 |
0x0C, 0x00, 0x00, 0x00, /* 0x00 ResultData offset */ |
| 1618 |
0x0C, 0x00, 0x00, 0x00, /* 0x04 ResultData length */ |
| 1619 |
0xCC, 0x00, 0x00, 0x00, /* 0x08 StatusWords */ |
| 1620 |
/* databuffer */ |
| 1621 |
0x00, 0x00, 0x00, 0x00, /* 0x0C ResultData */ |
| 1622 |
0x04, 0x05, 0x06, 0x07, |
| 1623 |
0xAF, 0xAE, 0xAD, 0xAC |
| 1624 |
}; |
| 1625 |
|
| 1626 |
const guint8 expected_databuffer [] = { |
| 1627 |
0x00, 0x00, 0x00, 0x00, |
| 1628 |
0x04, 0x05, 0x06, 0x07, |
| 1629 |
0xAF, 0xAE, 0xAD, 0xAC |
| 1630 |
}; |
| 1631 |
|
| 1632 |
response = mbim_message_new (buffer, sizeof (buffer)); |
| 1633 |
g_assert (mbim_message_validate (response, &error)); |
| 1634 |
g_assert_no_error (error); |
| 1635 |
|
| 1636 |
test_message_printable (response, 1, 0); |
| 1637 |
|
| 1638 |
g_assert (mbim_message_stk_terminal_response_response_parse ( |
| 1639 |
response, |
| 1640 |
&databuffer_len, |
| 1641 |
&databuffer, |
| 1642 |
&status_words, |
| 1643 |
&error)); |
| 1644 |
g_assert_no_error (error); |
| 1645 |
|
| 1646 |
g_assert_cmpuint (status_words, ==, 204); |
| 1647 |
|
| 1648 |
test_message_trace (databuffer, |
| 1649 |
databuffer_len, |
| 1650 |
expected_databuffer, |
| 1651 |
sizeof (expected_databuffer)); |
| 1652 |
g_assert_cmpuint (databuffer_len, ==, sizeof (expected_databuffer)); |
| 1653 |
g_assert (memcmp (databuffer, expected_databuffer, sizeof (expected_databuffer)) == 0); |
| 1654 |
} |
| 1655 |
|
| 1656 |
static void |
| 1657 |
test_stk_envelope_response (void) |
| 1658 |
{ |
| 1659 |
const guint8 *databuffer; |
| 1660 |
g_autoptr(GError) error = NULL; |
| 1661 |
g_autoptr(MbimMessage) response = NULL; |
| 1662 |
|
| 1663 |
const guint8 buffer [] = { |
| 1664 |
/* header */ |
| 1665 |
0x03, 0x00, 0x00, 0x80, /* type */ |
| 1666 |
0x50, 0x00, 0x00, 0x00, /* length */ |
| 1667 |
0x02, 0x00, 0x00, 0x00, /* transaction id */ |
| 1668 |
/* fragment header */ |
| 1669 |
0x01, 0x00, 0x00, 0x00, /* total */ |
| 1670 |
0x00, 0x00, 0x00, 0x00, /* current */ |
| 1671 |
/* indicate_status_message */ |
| 1672 |
0xD8, 0xF2, 0x01, 0x31, /* service id */ |
| 1673 |
0xFC, 0xB5, 0x4E, 0x17, |
| 1674 |
0x86, 0x02, 0xD6, 0xED, |
| 1675 |
0x38, 0x16, 0x16, 0x4C, |
| 1676 |
0x03, 0x00, 0x00, 0x00, /* command id */ |
| 1677 |
0x00, 0x00, 0x00, 0x00, /* status code */ |
| 1678 |
0x20, 0x00, 0x00, 0x00, /* buffer length */ |
| 1679 |
/* information buffer */ |
| 1680 |
0x0C, 0x00, 0x00, 0x00, |
| 1681 |
0x0C, 0x00, 0x00, 0x00, |
| 1682 |
0xCC, 0x00, 0x00, 0x00, |
| 1683 |
0x00, 0x00, 0x00, 0x00, |
| 1684 |
0x0C, 0x00, 0x00, 0x00, |
| 1685 |
0x0C, 0x00, 0x00, 0x00, |
| 1686 |
0xCC, 0x00, 0x00, 0x00, |
| 1687 |
0x00, 0x00, 0x00, 0x00 |
| 1688 |
}; |
| 1689 |
|
| 1690 |
const guint8 expected_databuffer [] = { |
| 1691 |
0x0C, 0x00, 0x00, 0x00, |
| 1692 |
0x0C, 0x00, 0x00, 0x00, |
| 1693 |
0xCC, 0x00, 0x00, 0x00, |
| 1694 |
0x00, 0x00, 0x00, 0x00, |
| 1695 |
0x0C, 0x00, 0x00, 0x00, |
| 1696 |
0x0C, 0x00, 0x00, 0x00, |
| 1697 |
0xCC, 0x00, 0x00, 0x00, |
| 1698 |
0x00, 0x00, 0x00, 0x00 |
| 1699 |
}; |
| 1700 |
|
| 1701 |
response = mbim_message_new (buffer, sizeof (buffer)); |
| 1702 |
g_assert (mbim_message_validate (response, &error)); |
| 1703 |
g_assert_no_error (error); |
| 1704 |
|
| 1705 |
test_message_printable (response, 1, 0); |
| 1706 |
|
| 1707 |
g_assert (mbim_message_stk_envelope_response_parse ( |
| 1708 |
response, |
| 1709 |
&databuffer, |
| 1710 |
&error)); |
| 1711 |
g_assert_no_error (error); |
| 1712 |
|
| 1713 |
test_message_trace (databuffer, |
| 1714 |
sizeof (expected_databuffer), |
| 1715 |
expected_databuffer, |
| 1716 |
sizeof (expected_databuffer)); |
| 1717 |
g_assert (memcmp (databuffer, expected_databuffer, sizeof (expected_databuffer)) == 0); |
| 1718 |
} |
| 1719 |
|
| 1720 |
static void |
| 1721 |
test_basic_connect_ip_packet_filters_none (void) |
| 1722 |
{ |
| 1723 |
guint32 n_filters; |
| 1724 |
guint32 session_id; |
| 1725 |
g_autoptr(MbimPacketFilterArray) filters = NULL; |
| 1726 |
g_autoptr(GError) error = NULL; |
| 1727 |
g_autoptr(MbimMessage) response = NULL; |
| 1728 |
|
| 1729 |
const guint8 buffer [] = { |
| 1730 |
/* header */ |
| 1731 |
0x03, 0x00, 0x00, 0x80, /* type */ |
| 1732 |
0x38, 0x00, 0x00, 0x00, /* length */ |
| 1733 |
0x02, 0x00, 0x00, 0x00, /* transaction id */ |
| 1734 |
/* fragment header */ |
| 1735 |
0x01, 0x00, 0x00, 0x00, /* total */ |
| 1736 |
0x00, 0x00, 0x00, 0x00, /* current */ |
| 1737 |
/* indicate_status_message */ |
| 1738 |
0xA2, 0x89, 0xCC, 0x33, /* service id */ |
| 1739 |
0xBC, 0xBB, 0x8B, 0x4F, |
| 1740 |
0xB6, 0xB0, 0x13, 0x3E, |
| 1741 |
0xC2, 0xAA, 0xE6, 0xDF, |
| 1742 |
0x17, 0x00, 0x00, 0x00, /* command id */ |
| 1743 |
0x00, 0x00, 0x00, 0x00, /* status code */ |
| 1744 |
0x08, 0x00, 0x00, 0x00, /* buffer length */ |
| 1745 |
/* information buffer */ |
| 1746 |
0x01, 0x00, 0x00, 0x00, /* session id */ |
| 1747 |
0x00, 0x00, 0x00, 0x00 /* packet filters count */ |
| 1748 |
}; |
| 1749 |
|
| 1750 |
response = mbim_message_new (buffer, sizeof (buffer)); |
| 1751 |
g_assert (mbim_message_validate (response, &error)); |
| 1752 |
g_assert_no_error (error); |
| 1753 |
|
| 1754 |
test_message_printable (response, 1, 0); |
| 1755 |
|
| 1756 |
g_assert (mbim_message_ip_packet_filters_response_parse ( |
| 1757 |
response, |
| 1758 |
&session_id, |
| 1759 |
&n_filters, |
| 1760 |
&filters, |
| 1761 |
&error)); |
| 1762 |
g_assert_no_error (error); |
| 1763 |
|
| 1764 |
g_assert_cmpuint (session_id, ==, 1); |
| 1765 |
g_assert_cmpuint (n_filters, ==, 0); |
| 1766 |
g_assert (filters == NULL); |
| 1767 |
} |
| 1768 |
|
| 1769 |
static void |
| 1770 |
test_basic_connect_ip_packet_filters_one (void) |
| 1771 |
{ |
| 1772 |
guint32 n_filters; |
| 1773 |
guint32 session_id; |
| 1774 |
g_autoptr(MbimPacketFilterArray) filters = NULL; |
| 1775 |
g_autoptr(GError) error = NULL; |
| 1776 |
g_autoptr(MbimMessage) response = NULL; |
| 1777 |
|
| 1778 |
const guint8 buffer [] = { |
| 1779 |
/* header */ |
| 1780 |
0x03, 0x00, 0x00, 0x80, /* type */ |
| 1781 |
0x5C, 0x00, 0x00, 0x00, /* length */ |
| 1782 |
0x02, 0x00, 0x00, 0x00, /* transaction id */ |
| 1783 |
/* fragment header */ |
| 1784 |
0x01, 0x00, 0x00, 0x00, /* total */ |
| 1785 |
0x00, 0x00, 0x00, 0x00, /* current */ |
| 1786 |
/* indicate_status_message */ |
| 1787 |
0xA2, 0x89, 0xCC, 0x33, /* service id */ |
| 1788 |
0xBC, 0xBB, 0x8B, 0x4F, |
| 1789 |
0xB6, 0xB0, 0x13, 0x3E, |
| 1790 |
0xC2, 0xAA, 0xE6, 0xDF, |
| 1791 |
0x17, 0x00, 0x00, 0x00, /* command id */ |
| 1792 |
0x00, 0x00, 0x00, 0x00, /* status code */ |
| 1793 |
0x2C, 0x00, 0x00, 0x00, /* buffer length */ |
| 1794 |
/* information buffer */ |
| 1795 |
0x01, 0x00, 0x00, 0x00, /* 0x00 session id */ |
| 1796 |
0x01, 0x00, 0x00, 0x00, /* 0x04 packet filters count */ |
| 1797 |
0x10, 0x00, 0x00, 0x00, /* 0x08 packet filter 1 offset */ |
| 1798 |
0x1C, 0x00, 0x00, 0x00, /* 0x0C packet filter 1 length */ |
| 1799 |
/* databuffer, packet filter 1 */ |
| 1800 |
0x08, 0x00, 0x00, 0x00, /* 0x10 0x00 filter size */ |
| 1801 |
0x0C, 0x00, 0x00, 0x00, /* 0x14 0x04 filter offset (from beginning of struct) */ |
| 1802 |
0x14, 0x00, 0x00, 0x00, /* 0x18 0x08 mask offset (from beginning of struct) */ |
| 1803 |
0x01, 0x02, 0x03, 0x04, /* 0x1C 0x0C filter */ |
| 1804 |
0x05, 0x06, 0x07, 0x08, |
| 1805 |
0xF1, 0xF2, 0xF3, 0xF4, /* 0x24 0x14 mask */ |
| 1806 |
0xF5, 0xF6, 0xF7, 0xF8, |
| 1807 |
}; |
| 1808 |
|
| 1809 |
const guint8 expected_filter[] = { |
| 1810 |
0x01, 0x02, 0x03, 0x04, |
| 1811 |
0x05, 0x06, 0x07, 0x08, |
| 1812 |
}; |
| 1813 |
const guint8 expected_mask[] = { |
| 1814 |
0xF1, 0xF2, 0xF3, 0xF4, |
| 1815 |
0xF5, 0xF6, 0xF7, 0xF8, |
| 1816 |
}; |
| 1817 |
|
| 1818 |
response = mbim_message_new (buffer, sizeof (buffer)); |
| 1819 |
g_assert (mbim_message_validate (response, &error)); |
| 1820 |
g_assert_no_error (error); |
| 1821 |
|
| 1822 |
test_message_printable (response, 1, 0); |
| 1823 |
|
| 1824 |
g_assert (mbim_message_ip_packet_filters_response_parse ( |
| 1825 |
response, |
| 1826 |
&session_id, |
| 1827 |
&n_filters, |
| 1828 |
&filters, |
| 1829 |
&error)); |
| 1830 |
g_assert_no_error (error); |
| 1831 |
|
| 1832 |
g_assert_cmpuint (session_id, ==, 1); |
| 1833 |
g_assert_cmpuint (n_filters, ==, 1); |
| 1834 |
g_assert (filters != NULL); |
| 1835 |
|
| 1836 |
g_assert_cmpuint (filters[0]->filter_size, ==, 8); |
| 1837 |
|
| 1838 |
test_message_trace (filters[0]->packet_filter, 8, |
| 1839 |
expected_filter, |
| 1840 |
sizeof (expected_filter)); |
| 1841 |
g_assert (memcmp (filters[0]->packet_filter, expected_filter, sizeof (expected_filter)) == 0); |
| 1842 |
|
| 1843 |
test_message_trace (filters[0]->packet_mask, 8, |
| 1844 |
expected_mask, |
| 1845 |
sizeof (expected_mask)); |
| 1846 |
g_assert (memcmp (filters[0]->packet_mask, expected_mask, sizeof (expected_mask)) == 0); |
| 1847 |
} |
| 1848 |
|
| 1849 |
static void |
| 1850 |
test_basic_connect_ip_packet_filters_two (void) |
| 1851 |
{ |
| 1852 |
guint32 n_filters; |
| 1853 |
guint32 session_id; |
| 1854 |
g_autoptr(MbimPacketFilterArray) filters = NULL; |
| 1855 |
g_autoptr(GError) error = NULL; |
| 1856 |
g_autoptr(MbimMessage) response = NULL; |
| 1857 |
|
| 1858 |
const guint8 buffer [] = { |
| 1859 |
/* header */ |
| 1860 |
0x03, 0x00, 0x00, 0x80, /* type */ |
| 1861 |
0x88, 0x00, 0x00, 0x00, /* length */ |
| 1862 |
0x02, 0x00, 0x00, 0x00, /* transaction id */ |
| 1863 |
/* fragment header */ |
| 1864 |
0x01, 0x00, 0x00, 0x00, /* total */ |
| 1865 |
0x00, 0x00, 0x00, 0x00, /* current */ |
| 1866 |
/* indicate_status_message */ |
| 1867 |
0xA2, 0x89, 0xCC, 0x33, /* service id */ |
| 1868 |
0xBC, 0xBB, 0x8B, 0x4F, |
| 1869 |
0xB6, 0xB0, 0x13, 0x3E, |
| 1870 |
0xC2, 0xAA, 0xE6, 0xDF, |
| 1871 |
0x17, 0x00, 0x00, 0x00, /* command id */ |
| 1872 |
0x00, 0x00, 0x00, 0x00, /* status code */ |
| 1873 |
0x58, 0x00, 0x00, 0x00, /* buffer length */ |
| 1874 |
/* information buffer */ |
| 1875 |
0x01, 0x00, 0x00, 0x00, /* 0x00 session id */ |
| 1876 |
0x02, 0x00, 0x00, 0x00, /* 0x04 packet filters count */ |
| 1877 |
0x18, 0x00, 0x00, 0x00, /* 0x08 packet filter 1 offset */ |
| 1878 |
0x1C, 0x00, 0x00, 0x00, /* 0x0C packet filter 1 length */ |
| 1879 |
0x34, 0x00, 0x00, 0x00, /* 0x10 packet filter 2 offset */ |
| 1880 |
0x24, 0x00, 0x00, 0x00, /* 0x14 packet filter 2 length */ |
| 1881 |
/* databuffer, packet filter 2 */ |
| 1882 |
0x08, 0x00, 0x00, 0x00, /* 0x18 0x00 filter size */ |
| 1883 |
0x0C, 0x00, 0x00, 0x00, /* 0x1C 0x04 filter offset (from beginning of struct) */ |
| 1884 |
0x14, 0x00, 0x00, 0x00, /* 0x20 0x08 mask offset (from beginning of struct) */ |
| 1885 |
0x01, 0x02, 0x03, 0x04, /* 0x24 0x0C filter */ |
| 1886 |
0x05, 0x06, 0x07, 0x08, |
| 1887 |
0xF1, 0xF2, 0xF3, 0xF4, /* 0x2C 0x14 mask */ |
| 1888 |
0xF5, 0xF6, 0xF7, 0xF8, |
| 1889 |
/* databuffer, packet filter 2 */ |
| 1890 |
0x0C, 0x00, 0x00, 0x00, /* 0x34 0x00 filter size */ |
| 1891 |
0x0C, 0x00, 0x00, 0x00, /* 0x38 0x04 filter offset (from beginning of struct) */ |
| 1892 |
0x18, 0x00, 0x00, 0x00, /* 0x3C 0x08 mask offset (from beginning of struct) */ |
| 1893 |
0x01, 0x02, 0x03, 0x04, /* 0x40 0x0C filter */ |
| 1894 |
0x05, 0x06, 0x07, 0x08, |
| 1895 |
0x05, 0x06, 0x07, 0x08, |
| 1896 |
0xF1, 0xF2, 0xF3, 0xF4, /* 0x4C 0x18 mask */ |
| 1897 |
0xF5, 0xF6, 0xF7, 0xF8, |
| 1898 |
0xF5, 0xF6, 0xF7, 0xF8, |
| 1899 |
}; |
| 1900 |
|
| 1901 |
const guint8 expected_filter1[] = { |
| 1902 |
0x01, 0x02, 0x03, 0x04, |
| 1903 |
0x05, 0x06, 0x07, 0x08, |
| 1904 |
}; |
| 1905 |
const guint8 expected_mask1[] = { |
| 1906 |
0xF1, 0xF2, 0xF3, 0xF4, |
| 1907 |
0xF5, 0xF6, 0xF7, 0xF8, |
| 1908 |
}; |
| 1909 |
const guint8 expected_filter2[] = { |
| 1910 |
0x01, 0x02, 0x03, 0x04, |
| 1911 |
0x05, 0x06, 0x07, 0x08, |
| 1912 |
0x05, 0x06, 0x07, 0x08, |
| 1913 |
}; |
| 1914 |
const guint8 expected_mask2[] = { |
| 1915 |
0xF1, 0xF2, 0xF3, 0xF4, |
| 1916 |
0xF5, 0xF6, 0xF7, 0xF8, |
| 1917 |
0xF5, 0xF6, 0xF7, 0xF8, |
| 1918 |
}; |
| 1919 |
|
| 1920 |
response = mbim_message_new (buffer, sizeof (buffer)); |
| 1921 |
g_assert (mbim_message_validate (response, &error)); |
| 1922 |
g_assert_no_error (error); |
| 1923 |
|
| 1924 |
test_message_printable (response, 1, 0); |
| 1925 |
|
| 1926 |
g_assert (mbim_message_ip_packet_filters_response_parse ( |
| 1927 |
response, |
| 1928 |
&session_id, |
| 1929 |
&n_filters, |
| 1930 |
&filters, |
| 1931 |
&error)); |
| 1932 |
g_assert_no_error (error); |
| 1933 |
|
| 1934 |
g_assert_cmpuint (session_id, ==, 1); |
| 1935 |
g_assert_cmpuint (n_filters, ==, 2); |
| 1936 |
g_assert (filters != NULL); |
| 1937 |
|
| 1938 |
g_assert_cmpuint (filters[0]->filter_size, ==, 8); |
| 1939 |
test_message_trace (filters[0]->packet_filter, 8, |
| 1940 |
expected_filter1, |
| 1941 |
sizeof (expected_filter1)); |
| 1942 |
g_assert (memcmp (filters[0]->packet_filter, expected_filter1, sizeof (expected_filter1)) == 0); |
| 1943 |
test_message_trace (filters[0]->packet_mask, 8, |
| 1944 |
expected_mask1, |
| 1945 |
sizeof (expected_mask1)); |
| 1946 |
g_assert (memcmp (filters[0]->packet_mask, expected_mask1, sizeof (expected_mask1)) == 0); |
| 1947 |
|
| 1948 |
g_assert_cmpuint (filters[1]->filter_size, ==, 12); |
| 1949 |
test_message_trace (filters[1]->packet_filter, 12, |
| 1950 |
expected_filter2, |
| 1951 |
sizeof (expected_filter2)); |
| 1952 |
g_assert (memcmp (filters[1]->packet_filter, expected_filter2, sizeof (expected_filter2)) == 0); |
| 1953 |
test_message_trace (filters[1]->packet_mask, 12, |
| 1954 |
expected_mask2, |
| 1955 |
sizeof (expected_mask2)); |
| 1956 |
g_assert (memcmp (filters[1]->packet_mask, expected_mask2, sizeof (expected_mask2)) == 0); |
| 1957 |
} |
| 1958 |
|
| 1959 |
static void |
| 1960 |
test_ms_firmware_id_get (void) |
| 1961 |
{ |
| 1962 |
const MbimUuid *firmware_id; |
| 1963 |
g_autoptr(GError) error = NULL; |
| 1964 |
g_autoptr(MbimMessage) response = NULL; |
| 1965 |
|
| 1966 |
const guint8 buffer [] = { |
| 1967 |
/* header */ |
| 1968 |
0x03, 0x00, 0x00, 0x80, /* type */ |
| 1969 |
0x40, 0x00, 0x00, 0x00, /* length */ |
| 1970 |
0x02, 0x00, 0x00, 0x00, /* transaction id */ |
| 1971 |
/* fragment header */ |
| 1972 |
0x01, 0x00, 0x00, 0x00, /* total */ |
| 1973 |
0x00, 0x00, 0x00, 0x00, /* current */ |
| 1974 |
/* command_done_message */ |
| 1975 |
0xE9, 0xF7, 0xDE, 0xA2, /* service id */ |
| 1976 |
0xFE, 0xAF, 0x40, 0x09, |
| 1977 |
0x93, 0xCE, 0x90, 0xA3, |
| 1978 |
0x69, 0x41, 0x03, 0xB6, |
| 1979 |
0x01, 0x00, 0x00, 0x00, /* command id */ |
| 1980 |
0x00, 0x00, 0x00, 0x00, /* status code */ |
| 1981 |
0x10, 0x00, 0x00, 0x00, /* buffer length */ |
| 1982 |
/* information buffer */ |
| 1983 |
0x00, 0x11, 0x22, 0x33, /* firmware id */ |
| 1984 |
0x44, 0x55, 0x66, 0x77, |
| 1985 |
0x88, 0x99, 0xAA, 0xBB, |
| 1986 |
0xCC, 0xDD, 0xEE, 0xFF }; |
| 1987 |
|
| 1988 |
const MbimUuid expected_firmware_id = { |
| 1989 |
.a = { 0x00, 0x11, 0x22, 0x33 }, |
| 1990 |
.b = { 0x44, 0x55 }, |
| 1991 |
.c = { 0x66, 0x77 }, |
| 1992 |
.d = { 0x88, 0x99 }, |
| 1993 |
.e = { 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF } |
| 1994 |
}; |
| 1995 |
|
| 1996 |
response = mbim_message_new (buffer, sizeof (buffer)); |
| 1997 |
g_assert (mbim_message_validate (response, &error)); |
| 1998 |
g_assert_no_error (error); |
| 1999 |
|
| 2000 |
test_message_printable (response, 1, 0); |
| 2001 |
|
| 2002 |
g_assert (mbim_message_ms_firmware_id_get_response_parse ( |
| 2003 |
response, |
| 2004 |
&firmware_id, |
| 2005 |
&error)); |
| 2006 |
|
| 2007 |
g_assert_no_error (error); |
| 2008 |
|
| 2009 |
g_assert (mbim_uuid_cmp (firmware_id, &expected_firmware_id)); |
| 2010 |
} |
| 2011 |
|
| 2012 |
static void |
| 2013 |
test_basic_connect_connect_short (void) |
| 2014 |
{ |
| 2015 |
guint32 session_id; |
| 2016 |
MbimActivationState activation_state; |
| 2017 |
MbimVoiceCallState voice_call_state; |
| 2018 |
MbimContextIpType ip_type; |
| 2019 |
const MbimUuid *context_type; |
| 2020 |
guint32 nw_error; |
| 2021 |
g_autoptr(GError) error = NULL; |
| 2022 |
g_autoptr(MbimMessage) response = NULL; |
| 2023 |
|
| 2024 |
const guint8 buffer [] = { |
| 2025 |
/* header */ |
| 2026 |
0x03, 0x00, 0x00, 0x80, /* type */ |
| 2027 |
0x30, 0x00, 0x00, 0x00, /* length */ |
| 2028 |
0x1A, 0x0D, 0x00, 0x00, /* transaction id */ |
| 2029 |
/* fragment header */ |
| 2030 |
0x01, 0x00, 0x00, 0x00, /* total */ |
| 2031 |
0x00, 0x00, 0x00, 0x00, /* current */ |
| 2032 |
/* command_done_message */ |
| 2033 |
0xA2, 0x89, 0xCC, 0x33, /* service id */ |
| 2034 |
0xBC, 0xBB, 0x8B, 0x4F, |
| 2035 |
0xB6, 0xB0, 0x13, 0x3E, |
| 2036 |
0xC2, 0xAA, 0xE6, 0xDF, /* command id */ |
| 2037 |
0x0C, 0x00, 0x00, 0x00, /* status code */ |
| 2038 |
0x02, 0x00, 0x00, 0x00, /* buffer length */ |
| 2039 |
/* information buffer */ |
| 2040 |
0x00, 0x00, 0x00, 0x00 |
| 2041 |
}; |
| 2042 |
|
| 2043 |
response = mbim_message_new (buffer, sizeof (buffer)); |
| 2044 |
|
| 2045 |
/* generic validation passes because the MBIM message format is fine */ |
| 2046 |
g_assert (mbim_message_validate (response, &error)); |
| 2047 |
g_assert_no_error (error); |
| 2048 |
|
| 2049 |
/* should fail! */ |
| 2050 |
g_assert (!mbim_message_connect_response_parse ( |
| 2051 |
response, |
| 2052 |
&session_id, |
| 2053 |
&activation_state, |
| 2054 |
&voice_call_state, |
| 2055 |
&ip_type, |
| 2056 |
&context_type, |
| 2057 |
&nw_error, |
| 2058 |
&error)); |
| 2059 |
|
| 2060 |
g_assert (error != NULL); |
| 2061 |
} |
| 2062 |
|
| 2063 |
static void |
| 2064 |
test_basic_connect_visible_providers_overflow (void) |
| 2065 |
{ |
| 2066 |
guint32 n_providers; |
| 2067 |
g_autoptr(GError) error = NULL; |
| 2068 |
g_autoptr(MbimProviderArray) providers = NULL; |
| 2069 |
g_autoptr(MbimMessage) response = NULL; |
| 2070 |
gboolean result; |
| 2071 |
|
| 2072 |
const guint8 buffer [] = { |
| 2073 |
/* header */ |
| 2074 |
0x03, 0x00, 0x00, 0x80, /* type */ |
| 2075 |
0xB4, 0x00, 0x00, 0x00, /* length */ |
| 2076 |
0x02, 0x00, 0x00, 0x00, /* transaction id */ |
| 2077 |
/* fragment header */ |
| 2078 |
0x01, 0x00, 0x00, 0x00, /* total */ |
| 2079 |
0x00, 0x00, 0x00, 0x00, /* current */ |
| 2080 |
/* command_done_message */ |
| 2081 |
0xA2, 0x89, 0xCC, 0x33, /* service id */ |
| 2082 |
0xBC, 0xBB, 0x8B, 0x4F, |
| 2083 |
0xB6, 0xB0, 0x13, 0x3E, |
| 2084 |
0xC2, 0xAA, 0xE6, 0xDF, |
| 2085 |
0x08, 0x00, 0x00, 0x00, /* command id */ |
| 2086 |
0x00, 0x00, 0x00, 0x00, /* status code */ |
| 2087 |
0x84, 0x00, 0x00, 0x00, /* buffer length */ |
| 2088 |
/* information buffer */ |
| 2089 |
0x02, 0x00, 0x00, 0x00, /* 0x00 providers count */ |
| 2090 |
0x14, 0x00, 0x00, 0x00, /* 0x04 provider 0 offset */ |
| 2091 |
0x38, 0x00, 0x00, 0x00, /* 0x08 provider 0 length */ |
| 2092 |
0x4C, 0x00, 0x00, 0x00, /* 0x0C provider 1 offset */ |
| 2093 |
0x38, 0x00, 0x00, 0x00, /* 0x10 provider 1 length */ |
| 2094 |
/* data buffer... struct provider 0 */ |
| 2095 |
0x20, 0x00, 0x00, 0x80, /* 0x14 [0x00] id offset */ /* OFFSET WRONG (0x80 instead of 0x00) */ |
| 2096 |
0x0A, 0x00, 0x00, 0x80, /* 0x18 [0x04] id length */ /* LENGTH WRONG (0x80 instead of 0x00) */ |
| 2097 |
0x08, 0x00, 0x00, 0x00, /* 0x1C [0x08] state */ |
| 2098 |
0x2C, 0x00, 0x00, 0x00, /* 0x20 [0x0C] name offset */ |
| 2099 |
0x0C, 0x00, 0x00, 0x00, /* 0x24 [0x10] name length */ |
| 2100 |
0x01, 0x00, 0x00, 0x00, /* 0x28 [0x14] cellular class */ |
| 2101 |
0x0B, 0x00, 0x00, 0x00, /* 0x2C [0x18] rssi */ |
| 2102 |
0x00, 0x00, 0x00, 0x00, /* 0x30 [0x1C] error rate */ |
| 2103 |
0x32, 0x00, 0x31, 0x00, /* 0x34 [0x20] id string (10 bytes) */ |
| 2104 |
0x34, 0x00, 0x30, 0x00, |
| 2105 |
0x33, 0x00, 0x00, 0x00, |
| 2106 |
0x4F, 0x00, 0x72, 0x00, /* 0x40 [0x2C] name string (12 bytes) */ |
| 2107 |
0x61, 0x00, 0x6E, 0x00, |
| 2108 |
0x67, 0x00, 0x65, 0x00, |
| 2109 |
/* data buffer... struct provider 1 */ |
| 2110 |
0x20, 0x00, 0x00, 0x00, /* 0x4C [0x00] id offset */ |
| 2111 |
0x0A, 0x00, 0x00, 0x00, /* 0x50 [0x04] id length */ |
| 2112 |
0x19, 0x00, 0x00, 0x00, /* 0x51 [0x08] state */ |
| 2113 |
0x2C, 0x00, 0x00, 0x00, /* 0x54 [0x0C] name offset */ |
| 2114 |
0x0C, 0x00, 0x00, 0x00, /* 0x58 [0x10] name length */ |
| 2115 |
0x01, 0x00, 0x00, 0x00, /* 0x5C [0x14] cellular class */ |
| 2116 |
0x0B, 0x00, 0x00, 0x00, /* 0x60 [0x18] rssi */ |
| 2117 |
0x00, 0x00, 0x00, 0x00, /* 0x64 [0x1C] error rate */ |
| 2118 |
0x32, 0x00, 0x31, 0x00, /* 0x68 [0x20] id string (10 bytes) */ |
| 2119 |
0x34, 0x00, 0x30, 0x00, |
| 2120 |
0x33, 0x00, 0x00, 0x00, |
| 2121 |
0x4F, 0x00, 0x72, 0x00, /* 0x74 [0x2C] name string (12 bytes) */ |
| 2122 |
0x61, 0x00, 0x6E, 0x00, |
| 2123 |
0x67, 0x00, 0x65, 0x00 }; |
| 2124 |
|
| 2125 |
response = mbim_message_new (buffer, sizeof (buffer)); |
| 2126 |
g_assert (mbim_message_validate (response, &error)); |
| 2127 |
g_assert_no_error (error); |
| 2128 |
|
| 2129 |
result = mbim_message_visible_providers_response_parse (response, |
| 2130 |
&n_providers, |
| 2131 |
&providers, |
| 2132 |
&error); |
| 2133 |
|
| 2134 |
g_assert (error != NULL); |
| 2135 |
g_assert (!result); |
| 2136 |
} |
| 2137 |
|
| 2138 |
static void |
| 2139 |
test_ms_basic_connect_extensions_base_stations (void) |
| 2140 |
{ |
| 2141 |
g_autoptr(GError) error = NULL; |
| 2142 |
g_autoptr(MbimMessage) response = NULL; |
| 2143 |
gboolean result; |
| 2144 |
MbimDataClass system_type; |
| 2145 |
g_autoptr(MbimCellInfoServingGsm) gsm_serving_cell = NULL; |
| 2146 |
g_autoptr(MbimCellInfoServingUmts) umts_serving_cell = NULL; |
| 2147 |
g_autoptr(MbimCellInfoServingTdscdma) tdscdma_serving_cell = NULL; |
| 2148 |
g_autoptr(MbimCellInfoServingLte) lte_serving_cell = NULL; |
| 2149 |
guint32 gsm_neighboring_cells_count; |
| 2150 |
g_autoptr(MbimCellInfoNeighboringGsmArray) gsm_neighboring_cells = NULL; |
| 2151 |
guint32 umts_neighboring_cells_count; |
| 2152 |
g_autoptr(MbimCellInfoNeighboringUmtsArray) umts_neighboring_cells = NULL; |
| 2153 |
guint32 tdscdma_neighboring_cells_count; |
| 2154 |
g_autoptr(MbimCellInfoNeighboringTdscdmaArray) tdscdma_neighboring_cells = NULL; |
| 2155 |
guint32 lte_neighboring_cells_count; |
| 2156 |
g_autoptr(MbimCellInfoNeighboringLteArray) lte_neighboring_cells = NULL; |
| 2157 |
guint32 cdma_cells_count; |
| 2158 |
g_autoptr(MbimCellInfoCdmaArray) cdma_cells = NULL; |
| 2159 |
|
| 2160 |
const guint8 buffer [] = { |
| 2161 |
/* header */ |
| 2162 |
0x03, 0x00, 0x00, 0x80, /* type */ |
| 2163 |
0xD8, 0x00, 0x00, 0x00, /* length */ |
| 2164 |
0x03, 0x00, 0x00, 0x00, /* transaction id */ |
| 2165 |
/* fragment header */ |
| 2166 |
0x01, 0x00, 0x00, 0x00, /* total */ |
| 2167 |
0x00, 0x00, 0x00, 0x00, /* current */ |
| 2168 |
/* command_done_message */ |
| 2169 |
0x3D, 0x01, 0xDC, 0xC5, /* service id */ |
| 2170 |
0xFE, 0xF5, 0x4D, 0x05, |
| 2171 |
0x0D, 0x3A, 0xBE, 0xF7, |
| 2172 |
0x05, 0x8E, 0x9A, 0xAF, |
| 2173 |
0x0B, 0x00, 0x00, 0x00, /* command id */ |
| 2174 |
0x00, 0x00, 0x00, 0x00, /* status code */ |
| 2175 |
0xA8, 0x00, 0x00, 0x00, /* buffer length */ |
| 2176 |
/* information buffer */ |
| 2177 |
0x60, 0x00, 0x00, 0x00, /* system type */ |
| 2178 |
0x00, 0x00, 0x00, 0x00, /* gsm serving cell offset */ |
| 2179 |
0x00, 0x00, 0x00, 0x00, /* gsm serving cell size */ |
| 2180 |
0x00, 0x00, 0x00, 0x00, /* umts serving cell offset */ |
| 2181 |
0x00, 0x00, 0x00, 0x00, /* umts serving cell size */ |
| 2182 |
0x00, 0x00, 0x00, 0x00, /* tdscdma serving cell offset */ |
| 2183 |
0x00, 0x00, 0x00, 0x00, /* tdscdma serving cell size */ |
| 2184 |
0x4C, 0x00, 0x00, 0x00, /* lte serving cell offset*/ |
| 2185 |
0x2E, 0x00, 0x00, 0x00, /* lte serving cell size*/ |
| 2186 |
0xA0, 0x00, 0x00, 0x00, /* gsm network measurement report offset */ |
| 2187 |
0x04, 0x00, 0x00, 0x00, /* gsm network measurement report size */ |
| 2188 |
0xA4, 0x00, 0x00, 0x00, /* umts network measurement report offset */ |
| 2189 |
0x04, 0x00, 0x00, 0x00, /* umts network measurement report size */ |
| 2190 |
0x00, 0x00, 0x00, 0x00, /* tdscdma network measurement report offset */ |
| 2191 |
0x00, 0x00, 0x00, 0x00, /* tdscdma network measurement report size */ |
| 2192 |
0x7C, 0x00, 0x00, 0x00, /* lte network measurement report offset */ |
| 2193 |
0x24, 0x00, 0x00, 0x00, /* lte network measurement report size */ |
| 2194 |
0x00, 0x00, 0x00, 0x00, /* cdma network measurement report offset */ |
| 2195 |
0x00, 0x00, 0x00, 0x00, /* cdma network measurement report size */ |
| 2196 |
/* lte serving cell */ |
| 2197 |
/*4C*/ 0x24, 0x00, 0x00, 0x00, /* provider id offset */ |
| 2198 |
0x0A, 0x00, 0x00, 0x00, /* provider id size */ |
| 2199 |
0x1F, 0xCD, 0x65, 0x04, /* cell id */ |
| 2200 |
0x00, 0x19, 0x00, 0x00, /* earfcn */ |
| 2201 |
0x36, 0x01, 0x00, 0x00, /* physical cell id */ |
| 2202 |
0xFE, 0x6F, 0x00, 0x00, /* tac */ |
| 2203 |
0x99, 0xFF, 0xFF, 0xFF, /* rsrp */ |
| 2204 |
0xF4, 0xFF, 0xFF, 0xFF, /* rsrq */ |
| 2205 |
0xFF, 0xFF, 0xFF, 0xFF, /* timing advance */ |
| 2206 |
0x32, 0x00, 0x31, 0x00, /* provider id string */ |
| 2207 |
0x34, 0x00, 0x30, 0x00, |
| 2208 |
0x37, 0x00, 0x00, 0x00, |
| 2209 |
/* lte network measurement report */ |
| 2210 |
/*7C*/ 0x01, 0x00, 0x00, 0x00, /* element count */ |
| 2211 |
0x00, 0x00, 0x00, 0x00, /* provider id offset */ |
| 2212 |
0x00, 0x00, 0x00, 0x00, /* provider id size */ |
| 2213 |
0xFF, 0xFF, 0xFF, 0xFF, /* cell id */ |
| 2214 |
0xFF, 0xFF, 0xFF, 0xFF, /* earfcn */ |
| 2215 |
0x36, 0x01, 0x00, 0x00, /* physical cell id */ |
| 2216 |
0xFF, 0xFF, 0xFF, 0xFF, /* tac */ |
| 2217 |
0x99, 0xFF, 0xFF, 0xFF, /* rsrp */ |
| 2218 |
0xF4, 0xFF, 0xFF, 0xFF, /* rsrq */ |
| 2219 |
/* gsm network measurement report */ |
| 2220 |
/*A0*/ 0x00, 0x00, 0x00, 0x00, |
| 2221 |
/* umts network measurement report */ |
| 2222 |
/*A4*/ 0x00, 0x00, 0x00, 0x00 |
| 2223 |
}; |
| 2224 |
|
| 2225 |
response = mbim_message_new (buffer, sizeof (buffer)); |
| 2226 |
g_assert (mbim_message_validate (response, &error)); |
| 2227 |
g_assert_no_error (error); |
| 2228 |
|
| 2229 |
test_message_printable (response, 1, 0); |
| 2230 |
|
| 2231 |
result = (mbim_message_ms_basic_connect_extensions_base_stations_info_response_parse ( |
| 2232 |
response, |
| 2233 |
&system_type, |
| 2234 |
&gsm_serving_cell, |
| 2235 |
&umts_serving_cell, |
| 2236 |
&tdscdma_serving_cell, |
| 2237 |
<e_serving_cell, |
| 2238 |
&gsm_neighboring_cells_count, |
| 2239 |
&gsm_neighboring_cells, |
| 2240 |
&umts_neighboring_cells_count, |
| 2241 |
&umts_neighboring_cells, |
| 2242 |
&tdscdma_neighboring_cells_count, |
| 2243 |
&tdscdma_neighboring_cells, |
| 2244 |
<e_neighboring_cells_count, |
| 2245 |
<e_neighboring_cells, |
| 2246 |
&cdma_cells_count, |
| 2247 |
&cdma_cells, |
| 2248 |
&error)); |
| 2249 |
|
| 2250 |
g_assert_no_error (error); |
| 2251 |
g_assert (result); |
| 2252 |
|
| 2253 |
g_assert_null (gsm_serving_cell); |
| 2254 |
g_assert_null (umts_serving_cell); |
| 2255 |
g_assert_null (tdscdma_serving_cell); |
| 2256 |
g_assert_nonnull (lte_serving_cell); |
| 2257 |
g_assert_cmpuint (gsm_neighboring_cells_count, ==, 0); |
| 2258 |
g_assert_null (gsm_neighboring_cells); |
| 2259 |
g_assert_cmpuint (umts_neighboring_cells_count, ==, 0); |
| 2260 |
g_assert_null (umts_neighboring_cells); |
| 2261 |
g_assert_cmpuint (tdscdma_neighboring_cells_count, ==, 0); |
| 2262 |
g_assert_null (tdscdma_neighboring_cells); |
| 2263 |
g_assert_cmpuint (lte_neighboring_cells_count, ==, 1); |
| 2264 |
g_assert_nonnull (lte_neighboring_cells); |
| 2265 |
g_assert_cmpuint (cdma_cells_count, ==, 0); |
| 2266 |
g_assert_null (cdma_cells); |
| 2267 |
} |
| 2268 |
|
| 2269 |
static void |
| 2270 |
test_ms_basic_connect_extensions_registration_parameters_0_unnamed_tlvs (void) |
| 2271 |
{ |
| 2272 |
g_autoptr(GError) error = NULL; |
| 2273 |
g_autoptr(MbimMessage) response = NULL; |
| 2274 |
gboolean result; |
| 2275 |
MbimMicoMode mico_mode; |
| 2276 |
MbimDrxCycle drx_cycle; |
| 2277 |
MbimLadnInfo ladn_info; |
| 2278 |
MbimDefaultPduActivationHint pdu_hint; |
| 2279 |
gboolean re_register_if_needed; |
| 2280 |
GList *unnamed_ies = NULL; |
| 2281 |
|
| 2282 |
const guint8 buffer [] = { |
| 2283 |
/* header */ |
| 2284 |
0x03, 0x00, 0x00, 0x80, /* type */ |
| 2285 |
0x44, 0x00, 0x00, 0x00, /* length */ |
| 2286 |
0x04, 0x00, 0x00, 0x00, /* transaction id */ |
| 2287 |
/* fragment header */ |
| 2288 |
0x01, 0x00, 0x00, 0x00, /* total */ |
| 2289 |
0x00, 0x00, 0x00, 0x00, /* current */ |
| 2290 |
/* command_done_message */ |
| 2291 |
0x3D, 0x01, 0xDC, 0xC5, /* service id */ |
| 2292 |
0xFE, 0xF5, 0x4D, 0x05, |
| 2293 |
0x0D, 0x3A, 0xBE, 0xF7, |
| 2294 |
0x05, 0x8E, 0x9A, 0xAF, |
| 2295 |
0x11, 0x00, 0x00, 0x00, /* command id */ |
| 2296 |
0x00, 0x00, 0x00, 0x00, /* status code */ |
| 2297 |
0x14, 0x00, 0x00, 0x00, /* buffer length */ |
| 2298 |
/* information buffer */ |
| 2299 |
0x00, 0x00, 0x00, 0x00, /* mico mode */ |
| 2300 |
0x00, 0x00, 0x00, 0x00, /* drx cycle */ |
| 2301 |
0x00, 0x00, 0x00, 0x00, /* ladn info */ |
| 2302 |
0x01, 0x00, 0x00, 0x00, /* pdu hint */ |
| 2303 |
0x01, 0x00, 0x00, 0x00, /* re register if needed */ |
| 2304 |
/* no unnamed TLVs */ |
| 2305 |
}; |
| 2306 |
|
| 2307 |
response = mbim_message_new (buffer, sizeof (buffer)); |
| 2308 |
g_assert (mbim_message_validate (response, &error)); |
| 2309 |
g_assert_no_error (error); |
| 2310 |
|
| 2311 |
test_message_printable (response, 3, 0); |
| 2312 |
|
| 2313 |
result = (mbim_message_ms_basic_connect_extensions_v3_registration_parameters_response_parse ( |
| 2314 |
response, |
| 2315 |
&mico_mode, |
| 2316 |
&drx_cycle, |
| 2317 |
&ladn_info, |
| 2318 |
&pdu_hint, |
| 2319 |
&re_register_if_needed, |
| 2320 |
&unnamed_ies, |
| 2321 |
&error)); |
| 2322 |
|
| 2323 |
g_assert_no_error (error); |
| 2324 |
g_assert (result); |
| 2325 |
|
| 2326 |
g_assert_cmpuint (mico_mode, ==, MBIM_MICO_MODE_DISABLED); |
| 2327 |
g_assert_cmpuint (drx_cycle, ==, MBIM_DRX_CYCLE_NOT_SPECIFIED); |
| 2328 |
g_assert_cmpuint (ladn_info, ==, MBIM_LADN_INFO_NOT_NEEDED); |
| 2329 |
g_assert_cmpuint (pdu_hint, ==, MBIM_DEFAULT_PDU_ACTIVATION_HINT_LIKELY); |
| 2330 |
g_assert_cmpuint (re_register_if_needed, ==, TRUE); |
| 2331 |
g_assert_cmpuint (g_list_length (unnamed_ies), ==, 0); |
| 2332 |
} |
| 2333 |
|
| 2334 |
static void |
| 2335 |
test_ms_basic_connect_extensions_registration_parameters_1_unnamed_tlv (void) |
| 2336 |
{ |
| 2337 |
g_autoptr(GError) error = NULL; |
| 2338 |
g_autoptr(MbimMessage) response = NULL; |
| 2339 |
gboolean result; |
| 2340 |
MbimMicoMode mico_mode; |
| 2341 |
MbimDrxCycle drx_cycle; |
| 2342 |
MbimLadnInfo ladn_info; |
| 2343 |
MbimDefaultPduActivationHint pdu_hint; |
| 2344 |
gboolean re_register_if_needed; |
| 2345 |
GList *unnamed_ies = NULL; |
| 2346 |
MbimTlv *tlv; |
| 2347 |
g_autofree gchar *tlv_str = NULL; |
| 2348 |
|
| 2349 |
const guint8 buffer [] = { |
| 2350 |
/* header */ |
| 2351 |
0x03, 0x00, 0x00, 0x80, /* type */ |
| 2352 |
0x58, 0x00, 0x00, 0x00, /* length */ |
| 2353 |
0x04, 0x00, 0x00, 0x00, /* transaction id */ |
| 2354 |
/* fragment header */ |
| 2355 |
0x01, 0x00, 0x00, 0x00, /* total */ |
| 2356 |
0x00, 0x00, 0x00, 0x00, /* current */ |
| 2357 |
/* command_done_message */ |
| 2358 |
0x3D, 0x01, 0xDC, 0xC5, /* service id */ |
| 2359 |
0xFE, 0xF5, 0x4D, 0x05, |
| 2360 |
0x0D, 0x3A, 0xBE, 0xF7, |
| 2361 |
0x05, 0x8E, 0x9A, 0xAF, |
| 2362 |
0x11, 0x00, 0x00, 0x00, /* command id */ |
| 2363 |
0x00, 0x00, 0x00, 0x00, /* status code */ |
| 2364 |
0x28, 0x00, 0x00, 0x00, /* buffer length */ |
| 2365 |
/* information buffer */ |
| 2366 |
0x00, 0x00, 0x00, 0x00, /* mico mode */ |
| 2367 |
0x00, 0x00, 0x00, 0x00, /* drx cycle */ |
| 2368 |
0x00, 0x00, 0x00, 0x00, /* ladn info */ |
| 2369 |
0x01, 0x00, 0x00, 0x00, /* pdu hint */ |
| 2370 |
0x01, 0x00, 0x00, 0x00, /* re register if needed */ |
| 2371 |
/* First unnamed TLV */ |
| 2372 |
0x0A, 0x00, 0x00, 0x00, /* TLV type MBIM_TLV_TYPE_WCHAR_STR, no padding */ |
| 2373 |
0x0C, 0x00, 0x00, 0x00, /* TLV data length */ |
| 2374 |
0x4F, 0x00, 0x72, 0x00, /* TLV data string */ |
| 2375 |
0x61, 0x00, 0x6E, 0x00, |
| 2376 |
0x67, 0x00, 0x65, 0x00, |
| 2377 |
}; |
| 2378 |
|
| 2379 |
response = mbim_message_new (buffer, sizeof (buffer)); |
| 2380 |
g_assert (mbim_message_validate (response, &error)); |
| 2381 |
g_assert_no_error (error); |
| 2382 |
|
| 2383 |
test_message_printable (response, 3, 0); |
| 2384 |
|
| 2385 |
result = (mbim_message_ms_basic_connect_extensions_v3_registration_parameters_response_parse ( |
| 2386 |
response, |
| 2387 |
&mico_mode, |
| 2388 |
&drx_cycle, |
| 2389 |
&ladn_info, |
| 2390 |
&pdu_hint, |
| 2391 |
&re_register_if_needed, |
| 2392 |
&unnamed_ies, |
| 2393 |
&error)); |
| 2394 |
|
| 2395 |
g_assert_no_error (error); |
| 2396 |
g_assert (result); |
| 2397 |
|
| 2398 |
g_assert_cmpuint (mico_mode, ==, MBIM_MICO_MODE_DISABLED); |
| 2399 |
g_assert_cmpuint (drx_cycle, ==, MBIM_DRX_CYCLE_NOT_SPECIFIED); |
| 2400 |
g_assert_cmpuint (ladn_info, ==, MBIM_LADN_INFO_NOT_NEEDED); |
| 2401 |
g_assert_cmpuint (pdu_hint, ==, MBIM_DEFAULT_PDU_ACTIVATION_HINT_LIKELY); |
| 2402 |
g_assert_cmpuint (re_register_if_needed, ==, TRUE); |
| 2403 |
g_assert_cmpuint (g_list_length (unnamed_ies), ==, 1); |
| 2404 |
|
| 2405 |
tlv = (MbimTlv *)(unnamed_ies->data); |
| 2406 |
g_assert_cmpuint (mbim_tlv_get_tlv_type (tlv), ==, MBIM_TLV_TYPE_WCHAR_STR); |
| 2407 |
|
| 2408 |
tlv_str = mbim_tlv_string_get (tlv, &error); |
| 2409 |
g_assert_no_error (error); |
| 2410 |
g_assert_cmpstr (tlv_str, ==, "Orange"); |
| 2411 |
|
| 2412 |
g_list_free_full (unnamed_ies, (GDestroyNotify)mbim_tlv_unref); |
| 2413 |
} |
| 2414 |
|
| 2415 |
static void |
| 2416 |
test_ms_basic_connect_extensions_registration_parameters_3_unnamed_tlvs (void) |
| 2417 |
{ |
| 2418 |
g_autoptr(GError) error = NULL; |
| 2419 |
g_autoptr(MbimMessage) response = NULL; |
| 2420 |
gboolean result; |
| 2421 |
MbimMicoMode mico_mode; |
| 2422 |
MbimDrxCycle drx_cycle; |
| 2423 |
MbimLadnInfo ladn_info; |
| 2424 |
MbimDefaultPduActivationHint pdu_hint; |
| 2425 |
gboolean re_register_if_needed; |
| 2426 |
GList *unnamed_ies = NULL; |
| 2427 |
GList *iter; |
| 2428 |
MbimTlv *tlv; |
| 2429 |
g_autofree gchar *tlv_str_1 = NULL; |
| 2430 |
const gchar *expected_tlv_str_1 = "abcde"; |
| 2431 |
g_autofree gchar *tlv_str_2 = NULL; |
| 2432 |
const gchar *expected_tlv_str_2 = "Orange"; |
| 2433 |
const guint8 *pco_3 = NULL; |
| 2434 |
guint32 pco_3_size = 0; |
| 2435 |
const guint8 expected_pco[] = { 0x01, 0x02, 0x03, 0x04, |
| 2436 |
0x05, 0x06, 0x07, 0x08, |
| 2437 |
0x09, 0x0A, 0x0B }; |
| 2438 |
|
| 2439 |
const guint8 buffer [] = { |
| 2440 |
/* header */ |
| 2441 |
0x03, 0x00, 0x00, 0x80, /* type */ |
| 2442 |
0x80, 0x00, 0x00, 0x00, /* length */ |
| 2443 |
0x04, 0x00, 0x00, 0x00, /* transaction id */ |
| 2444 |
/* fragment header */ |
| 2445 |
0x01, 0x00, 0x00, 0x00, /* total */ |
| 2446 |
0x00, 0x00, 0x00, 0x00, /* current */ |
| 2447 |
/* command_done_message */ |
| 2448 |
0x3D, 0x01, 0xDC, 0xC5, /* service id */ |
| 2449 |
0xFE, 0xF5, 0x4D, 0x05, |
| 2450 |
0x0D, 0x3A, 0xBE, 0xF7, |
| 2451 |
0x05, 0x8E, 0x9A, 0xAF, |
| 2452 |
0x11, 0x00, 0x00, 0x00, /* command id */ |
| 2453 |
0x00, 0x00, 0x00, 0x00, /* status code */ |
| 2454 |
0x50, 0x00, 0x00, 0x00, /* buffer length */ |
| 2455 |
/* information buffer */ |
| 2456 |
0x00, 0x00, 0x00, 0x00, /* mico mode */ |
| 2457 |
0x00, 0x00, 0x00, 0x00, /* drx cycle */ |
| 2458 |
0x00, 0x00, 0x00, 0x00, /* ladn info */ |
| 2459 |
0x01, 0x00, 0x00, 0x00, /* pdu hint */ |
| 2460 |
0x01, 0x00, 0x00, 0x00, /* re register if needed */ |
| 2461 |
/* First unnamed TLV */ |
| 2462 |
0x0A, 0x00, 0x00, 0x02, /* TLV type MBIM_TLV_TYPE_WCHAR_STR, padding 2 */ |
| 2463 |
0x0A, 0x00, 0x00, 0x00, /* TLV data length */ |
| 2464 |
0x61, 0x00, 0x62, 0x00, /* TLV data string */ |
| 2465 |
0x63, 0x00, 0x64, 0x00, |
| 2466 |
0x65, 0x00, 0x00, 0x00, |
| 2467 |
/* Second unnamed TLV */ |
| 2468 |
0x0A, 0x00, 0x00, 0x00, /* TLV type MBIM_TLV_TYPE_WCHAR_STR, no padding */ |
| 2469 |
0x0C, 0x00, 0x00, 0x00, /* TLV data length */ |
| 2470 |
0x4F, 0x00, 0x72, 0x00, /* TLV data string */ |
| 2471 |
0x61, 0x00, 0x6E, 0x00, |
| 2472 |
0x67, 0x00, 0x65, 0x00, |
| 2473 |
/* Third unnamed TLV */ |
| 2474 |
0x0D, 0x00, 0x00, 0x01, /* TLV type MBIM_TLV_TYPE_PCO, padding 1 */ |
| 2475 |
0x0B, 0x00, 0x00, 0x00, /* TLV data length */ |
| 2476 |
0x01, 0x02, 0x03, 0x04, /* TLV data bytes */ |
| 2477 |
0x05, 0x06, 0x07, 0x08, |
| 2478 |
0x09, 0x0A, 0x0B, 0x00, |
| 2479 |
}; |
| 2480 |
|
| 2481 |
response = mbim_message_new (buffer, sizeof (buffer)); |
| 2482 |
g_assert (mbim_message_validate (response, &error)); |
| 2483 |
g_assert_no_error (error); |
| 2484 |
|
| 2485 |
test_message_printable (response, 3, 0); |
| 2486 |
|
| 2487 |
result = (mbim_message_ms_basic_connect_extensions_v3_registration_parameters_response_parse ( |
| 2488 |
response, |
| 2489 |
&mico_mode, |
| 2490 |
&drx_cycle, |
| 2491 |
&ladn_info, |
| 2492 |
&pdu_hint, |
| 2493 |
&re_register_if_needed, |
| 2494 |
&unnamed_ies, |
| 2495 |
&error)); |
| 2496 |
|
| 2497 |
g_assert_no_error (error); |
| 2498 |
g_assert (result); |
| 2499 |
|
| 2500 |
g_assert_cmpuint (mico_mode, ==, MBIM_MICO_MODE_DISABLED); |
| 2501 |
g_assert_cmpuint (drx_cycle, ==, MBIM_DRX_CYCLE_NOT_SPECIFIED); |
| 2502 |
g_assert_cmpuint (ladn_info, ==, MBIM_LADN_INFO_NOT_NEEDED); |
| 2503 |
g_assert_cmpuint (pdu_hint, ==, MBIM_DEFAULT_PDU_ACTIVATION_HINT_LIKELY); |
| 2504 |
g_assert_cmpuint (re_register_if_needed, ==, TRUE); |
| 2505 |
g_assert_cmpuint (g_list_length (unnamed_ies), ==, 3); |
| 2506 |
|
| 2507 |
iter = unnamed_ies; |
| 2508 |
tlv = (MbimTlv *)(iter->data); |
| 2509 |
g_assert_cmpuint (mbim_tlv_get_tlv_type (tlv), ==, MBIM_TLV_TYPE_WCHAR_STR); |
| 2510 |
tlv_str_1 = mbim_tlv_string_get (tlv, &error); |
| 2511 |
g_assert_no_error (error); |
| 2512 |
g_assert_cmpstr (tlv_str_1, ==, expected_tlv_str_1); |
| 2513 |
|
| 2514 |
iter = g_list_next (iter); |
| 2515 |
tlv = (MbimTlv *)(iter->data); |
| 2516 |
g_assert_cmpuint (mbim_tlv_get_tlv_type (tlv), ==, MBIM_TLV_TYPE_WCHAR_STR); |
| 2517 |
tlv_str_2 = mbim_tlv_string_get (tlv, &error); |
| 2518 |
g_assert_no_error (error); |
| 2519 |
g_assert_cmpstr (tlv_str_2, ==, expected_tlv_str_2); |
| 2520 |
|
| 2521 |
iter = g_list_next (iter); |
| 2522 |
tlv = (MbimTlv *)(iter->data); |
| 2523 |
g_assert_cmpuint (mbim_tlv_get_tlv_type (tlv), ==, MBIM_TLV_TYPE_PCO); |
| 2524 |
pco_3 = mbim_tlv_get_tlv_data (tlv, &pco_3_size); |
| 2525 |
g_assert_cmpuint (pco_3_size, ==, sizeof (expected_pco)); |
| 2526 |
g_assert (memcmp (pco_3, expected_pco, sizeof (expected_pco)) == 0); |
| 2527 |
|
| 2528 |
g_list_free_full (unnamed_ies, (GDestroyNotify)mbim_tlv_unref); |
| 2529 |
} |
| 2530 |
|
| 2531 |
static void |
| 2532 |
test_ms_basic_connect_v3_connect_0_unnamed_tlvs (void) |
| 2533 |
{ |
| 2534 |
g_autoptr(GError) error = NULL; |
| 2535 |
g_autoptr(MbimMessage) response = NULL; |
| 2536 |
gboolean result; |
| 2537 |
GList *unnamed_ies = NULL; |
| 2538 |
guint32 session_id; |
| 2539 |
MbimActivationState activation_state; |
| 2540 |
MbimVoiceCallState voice_call_state; |
| 2541 |
MbimContextIpType ip_type; |
| 2542 |
MbimAccessMediaType media_type = MBIM_ACCESS_MEDIA_TYPE_UNKNOWN; |
| 2543 |
g_autofree gchar *access_string = NULL; |
| 2544 |
const MbimUuid *context_type; |
| 2545 |
guint32 nw_error; |
| 2546 |
|
| 2547 |
const guint8 buffer [] = { |
| 2548 |
/* header */ |
| 2549 |
0x03, 0x00, 0x00, 0x80, /* type */ |
| 2550 |
0x6C, 0x00, 0x00, 0x00, /* length */ |
| 2551 |
0x04, 0x00, 0x00, 0x00, /* transaction id */ |
| 2552 |
/* fragment header */ |
| 2553 |
0x01, 0x00, 0x00, 0x00, /* total */ |
| 2554 |
0x00, 0x00, 0x00, 0x00, /* current */ |
| 2555 |
/* command_done_message */ |
| 2556 |
0xA2, 0x89, 0xCC, 0x33, /* service id */ |
| 2557 |
0xBC, 0xBB, 0x8B, 0x4F, |
| 2558 |
0xB6, 0xB0, 0x13, 0x3E, |
| 2559 |
0xC2, 0xAA, 0xE6, 0xDF, |
| 2560 |
0x0C, 0x00, 0x00, 0x00, /* command id */ |
| 2561 |
0x00, 0x00, 0x00, 0x00, /* status code */ |
| 2562 |
0x3C, 0x00, 0x00, 0x00, /* buffer_length */ |
| 2563 |
/* information buffer */ |
| 2564 |
0x01, 0x00, 0x00, 0x00, /* session id */ |
| 2565 |
0x01, 0x00, 0x00, 0x00, /* activation state */ |
| 2566 |
0x00, 0x00, 0x00, 0x00, /* voice call state */ |
| 2567 |
0x01, 0x00, 0x00, 0x00, /* ip type */ |
| 2568 |
0x7E, 0x5E, 0x2A, 0x7E, /* context type */ |
| 2569 |
0x4E, 0x6F, 0x72, 0x72, |
| 2570 |
0x73, 0x6B, 0x65, 0x6E, |
| 2571 |
0x7E, 0x5E, 0x2A, 0x7E, |
| 2572 |
0x00, 0x00, 0x00, 0x00, /* nw error */ |
| 2573 |
0x01, 0x00, 0x00, 0x00, /* media type */ |
| 2574 |
0x0A, 0x00, 0x00, 0x00, /* access string */ |
| 2575 |
0x10, 0x00, 0x00, 0x00, |
| 2576 |
0x69, 0x00, 0x6E, 0x00, |
| 2577 |
0x74, 0x00, 0x65, 0x00, |
| 2578 |
0x72, 0x00, 0x6E, 0x00, |
| 2579 |
0x65, 0x00, 0x74, 0x00, |
| 2580 |
/* no unnamed TLVs */ |
| 2581 |
}; |
| 2582 |
|
| 2583 |
response = mbim_message_new (buffer, sizeof (buffer)); |
| 2584 |
g_assert (mbim_message_validate (response, &error)); |
| 2585 |
g_assert_no_error (error); |
| 2586 |
|
| 2587 |
test_message_printable (response, 3, 0); |
| 2588 |
|
| 2589 |
result = (mbim_message_ms_basic_connect_v3_connect_response_parse ( |
| 2590 |
response, |
| 2591 |
&session_id, |
| 2592 |
&activation_state, |
| 2593 |
&voice_call_state, |
| 2594 |
&ip_type, |
| 2595 |
&context_type, |
| 2596 |
&nw_error, |
| 2597 |
&media_type, |
| 2598 |
&access_string, |
| 2599 |
&unnamed_ies, |
| 2600 |
&error)); |
| 2601 |
|
| 2602 |
g_assert_no_error (error); |
| 2603 |
g_assert (result); |
| 2604 |
|
| 2605 |
g_assert_cmpuint (session_id, ==, 1); |
| 2606 |
g_assert_cmpuint (activation_state, ==, MBIM_ACTIVATION_STATE_ACTIVATED); |
| 2607 |
g_assert_cmpuint (voice_call_state, ==, MBIM_VOICE_CALL_STATE_NONE); |
| 2608 |
g_assert_cmpuint (ip_type, ==, MBIM_CONTEXT_IP_TYPE_IPV4); |
| 2609 |
g_assert_cmpuint (mbim_uuid_to_context_type (context_type), ==, MBIM_CONTEXT_TYPE_INTERNET); |
| 2610 |
g_assert_cmpuint (media_type, ==, MBIM_ACCESS_MEDIA_TYPE_3GPP); |
| 2611 |
g_assert_cmpstr (access_string, ==, "internet"); |
| 2612 |
g_assert_cmpuint (g_list_length (unnamed_ies), ==, 0); |
| 2613 |
} |
| 2614 |
|
| 2615 |
static void |
| 2616 |
test_ms_basic_connect_v3_connect_0_unnamed_tlvs_empty_access_string (void) |
| 2617 |
{ |
| 2618 |
g_autoptr(GError) error = NULL; |
| 2619 |
g_autoptr(MbimMessage) response = NULL; |
| 2620 |
gboolean result; |
| 2621 |
GList *unnamed_ies = NULL; |
| 2622 |
guint32 session_id; |
| 2623 |
MbimActivationState activation_state; |
| 2624 |
MbimVoiceCallState voice_call_state; |
| 2625 |
MbimContextIpType ip_type; |
| 2626 |
MbimAccessMediaType media_type = MBIM_ACCESS_MEDIA_TYPE_UNKNOWN; |
| 2627 |
g_autofree gchar *access_string = NULL; |
| 2628 |
const MbimUuid *context_type; |
| 2629 |
guint32 nw_error; |
| 2630 |
|
| 2631 |
const guint8 buffer [] = { |
| 2632 |
/* header */ |
| 2633 |
0x03, 0x00, 0x00, 0x80, /* type */ |
| 2634 |
0x60, 0x00, 0x00, 0x00, /* length */ |
| 2635 |
0x04, 0x00, 0x00, 0x00, /* transaction id */ |
| 2636 |
/* fragment header */ |
| 2637 |
0x01, 0x00, 0x00, 0x00, /* total */ |
| 2638 |
0x00, 0x00, 0x00, 0x00, /* current */ |
| 2639 |
/* command_done_message */ |
| 2640 |
0xA2, 0x89, 0xCC, 0x33, /* service id */ |
| 2641 |
0xBC, 0xBB, 0x8B, 0x4F, |
| 2642 |
0xB6, 0xB0, 0x13, 0x3E, |
| 2643 |
0xC2, 0xAA, 0xE6, 0xDF, |
| 2644 |
0x0C, 0x00, 0x00, 0x00, /* command id */ |
| 2645 |
0x00, 0x00, 0x00, 0x00, /* status code */ |
| 2646 |
0x30, 0x00, 0x00, 0x00, /* buffer_length */ |
| 2647 |
/* information buffer */ |
| 2648 |
0x01, 0x00, 0x00, 0x00, /* session id */ |
| 2649 |
0x01, 0x00, 0x00, 0x00, /* activation state */ |
| 2650 |
0x00, 0x00, 0x00, 0x00, /* voice call state */ |
| 2651 |
0x01, 0x00, 0x00, 0x00, /* ip type */ |
| 2652 |
0x7E, 0x5E, 0x2A, 0x7E, /* context type */ |
| 2653 |
0x4E, 0x6F, 0x72, 0x72, |
| 2654 |
0x73, 0x6B, 0x65, 0x6E, |
| 2655 |
0x7E, 0x5E, 0x2A, 0x7E, |
| 2656 |
0x00, 0x00, 0x00, 0x00, /* nw error */ |
| 2657 |
0x01, 0x00, 0x00, 0x00, /* media type */ |
| 2658 |
0x0A, 0x00, 0x00, 0x00, /* access string empty */ |
| 2659 |
0x00, 0x00, 0x00, 0x00, |
| 2660 |
/* no unnamed TLVs */ |
| 2661 |
}; |
| 2662 |
|
| 2663 |
response = mbim_message_new (buffer, sizeof (buffer)); |
| 2664 |
g_assert (mbim_message_validate (response, &error)); |
| 2665 |
g_assert_no_error (error); |
| 2666 |
|
| 2667 |
test_message_printable (response, 3, 0); |
| 2668 |
|
| 2669 |
result = (mbim_message_ms_basic_connect_v3_connect_response_parse ( |
| 2670 |
response, |
| 2671 |
&session_id, |
| 2672 |
&activation_state, |
| 2673 |
&voice_call_state, |
| 2674 |
&ip_type, |
| 2675 |
&context_type, |
| 2676 |
&nw_error, |
| 2677 |
&media_type, |
| 2678 |
&access_string, |
| 2679 |
&unnamed_ies, |
| 2680 |
&error)); |
| 2681 |
|
| 2682 |
g_assert_no_error (error); |
| 2683 |
g_assert (result); |
| 2684 |
|
| 2685 |
g_assert_cmpuint (session_id, ==, 1); |
| 2686 |
g_assert_cmpuint (activation_state, ==, MBIM_ACTIVATION_STATE_ACTIVATED); |
| 2687 |
g_assert_cmpuint (voice_call_state, ==, MBIM_VOICE_CALL_STATE_NONE); |
| 2688 |
g_assert_cmpuint (ip_type, ==, MBIM_CONTEXT_IP_TYPE_IPV4); |
| 2689 |
g_assert_cmpuint (mbim_uuid_to_context_type (context_type), ==, MBIM_CONTEXT_TYPE_INTERNET); |
| 2690 |
g_assert_cmpuint (media_type, ==, MBIM_ACCESS_MEDIA_TYPE_3GPP); |
| 2691 |
g_assert_cmpstr (access_string, ==, ""); |
| 2692 |
g_assert_cmpuint (g_list_length (unnamed_ies), ==, 0); |
| 2693 |
} |
| 2694 |
|
| 2695 |
static void |
| 2696 |
test_ms_basic_connect_v3_connect_1_unnamed_tlv (void) |
| 2697 |
{ |
| 2698 |
g_autoptr(GError) error = NULL; |
| 2699 |
g_autoptr(MbimMessage) response = NULL; |
| 2700 |
gboolean result; |
| 2701 |
GList *unnamed_ies = NULL; |
| 2702 |
guint32 session_id; |
| 2703 |
MbimActivationState activation_state; |
| 2704 |
MbimVoiceCallState voice_call_state; |
| 2705 |
MbimContextIpType ip_type; |
| 2706 |
MbimAccessMediaType media_type = MBIM_ACCESS_MEDIA_TYPE_UNKNOWN; |
| 2707 |
g_autofree gchar *access_string = NULL; |
| 2708 |
const MbimUuid *context_type; |
| 2709 |
guint32 nw_error; |
| 2710 |
MbimTlv *tlv; |
| 2711 |
g_autofree gchar *tlv_str = NULL; |
| 2712 |
|
| 2713 |
const guint8 buffer [] = { |
| 2714 |
/* header */ |
| 2715 |
0x03, 0x00, 0x00, 0x80, /* type */ |
| 2716 |
0x82, 0x00, 0x00, 0x00, /* length */ |
| 2717 |
0x04, 0x00, 0x00, 0x00, /* transaction id */ |
| 2718 |
/* fragment header */ |
| 2719 |
0x01, 0x00, 0x00, 0x00, /* total */ |
| 2720 |
0x00, 0x00, 0x00, 0x00, /* current */ |
| 2721 |
/* command_done_message */ |
| 2722 |
0xA2, 0x89, 0xCC, 0x33, /* service id */ |
| 2723 |
0xBC, 0xBB, 0x8B, 0x4F, |
| 2724 |
0xB6, 0xB0, 0x13, 0x3E, |
| 2725 |
0xC2, 0xAA, 0xE6, 0xDF, |
| 2726 |
0x0C, 0x00, 0x00, 0x00, /* command id */ |
| 2727 |
0x00, 0x00, 0x00, 0x00, /* status code */ |
| 2728 |
0x52, 0x00, 0x00, 0x00, /* buffer_length */ |
| 2729 |
/* information buffer */ |
| 2730 |
0x01, 0x00, 0x00, 0x00, /* session id */ |
| 2731 |
0x01, 0x00, 0x00, 0x00, /* activation state */ |
| 2732 |
0x00, 0x00, 0x00, 0x00, /* voice call state */ |
| 2733 |
0x01, 0x00, 0x00, 0x00, /* ip type */ |
| 2734 |
0x7E, 0x5E, 0x2A, 0x7E, /* context type */ |
| 2735 |
0x4E, 0x6F, 0x72, 0x72, |
| 2736 |
0x73, 0x6B, 0x65, 0x6E, |
| 2737 |
0x7E, 0x5E, 0x2A, 0x7E, |
| 2738 |
0x00, 0x00, 0x00, 0x00, /* nw error */ |
| 2739 |
0x01, 0x00, 0x00, 0x00, /* media type */ |
| 2740 |
0x0A, 0x00, 0x00, 0x00, /* access string */ |
| 2741 |
0x10, 0x00, 0x00, 0x00, |
| 2742 |
0x69, 0x00, 0x6E, 0x00, |
| 2743 |
0x74, 0x00, 0x65, 0x00, |
| 2744 |
0x72, 0x00, 0x6E, 0x00, |
| 2745 |
0x65, 0x00, 0x74, 0x00, |
| 2746 |
/* First unnamed TLV */ |
| 2747 |
0x0A, 0x00, 0x00, 0x00, /* TLV type MBIM_TLV_TYPE_WCHAR_STR, no padding */ |
| 2748 |
0x0C, 0x00, 0x00, 0x00, /* TLV data length */ |
| 2749 |
0x4F, 0x00, 0x72, 0x00, /* TLV data string */ |
| 2750 |
0x61, 0x00, 0x6E, 0x00, |
| 2751 |
0x67, 0x00, 0x65, 0x00, |
| 2752 |
}; |
| 2753 |
|
| 2754 |
response = mbim_message_new (buffer, sizeof (buffer)); |
| 2755 |
g_assert (mbim_message_validate (response, &error)); |
| 2756 |
g_assert_no_error (error); |
| 2757 |
|
| 2758 |
test_message_printable (response, 3, 0); |
| 2759 |
|
| 2760 |
result = (mbim_message_ms_basic_connect_v3_connect_response_parse ( |
| 2761 |
response, |
| 2762 |
&session_id, |
| 2763 |
&activation_state, |
| 2764 |
&voice_call_state, |
| 2765 |
&ip_type, |
| 2766 |
&context_type, |
| 2767 |
&nw_error, |
| 2768 |
&media_type, |
| 2769 |
&access_string, |
| 2770 |
&unnamed_ies, |
| 2771 |
&error)); |
| 2772 |
|
| 2773 |
g_assert_no_error (error); |
| 2774 |
g_assert (result); |
| 2775 |
|
| 2776 |
g_assert_cmpuint (session_id, ==, 1); |
| 2777 |
g_assert_cmpuint (activation_state, ==, MBIM_ACTIVATION_STATE_ACTIVATED); |
| 2778 |
g_assert_cmpuint (voice_call_state, ==, MBIM_VOICE_CALL_STATE_NONE); |
| 2779 |
g_assert_cmpuint (ip_type, ==, MBIM_CONTEXT_IP_TYPE_IPV4); |
| 2780 |
g_assert_cmpuint (mbim_uuid_to_context_type (context_type), ==, MBIM_CONTEXT_TYPE_INTERNET); |
| 2781 |
g_assert_cmpuint (media_type, ==, MBIM_ACCESS_MEDIA_TYPE_3GPP); |
| 2782 |
g_assert_cmpstr (access_string, ==, "internet"); |
| 2783 |
g_assert_cmpuint (g_list_length (unnamed_ies), ==, 1); |
| 2784 |
|
| 2785 |
tlv = (MbimTlv *)(unnamed_ies->data); |
| 2786 |
g_assert_cmpuint (mbim_tlv_get_tlv_type (tlv), ==, MBIM_TLV_TYPE_WCHAR_STR); |
| 2787 |
|
| 2788 |
tlv_str = mbim_tlv_string_get (tlv, &error); |
| 2789 |
g_assert_no_error (error); |
| 2790 |
g_assert_cmpstr (tlv_str, ==, "Orange"); |
| 2791 |
|
| 2792 |
g_list_free_full (unnamed_ies, (GDestroyNotify)mbim_tlv_unref); |
| 2793 |
} |
| 2794 |
|
| 2795 |
static void |
| 2796 |
test_ms_basic_connect_v3_connect_3_unnamed_tlvs (void) |
| 2797 |
{ |
| 2798 |
g_autoptr(GError) error = NULL; |
| 2799 |
g_autoptr(MbimMessage) response = NULL; |
| 2800 |
gboolean result; |
| 2801 |
GList *unnamed_ies = NULL; |
| 2802 |
guint32 session_id; |
| 2803 |
MbimActivationState activation_state; |
| 2804 |
MbimVoiceCallState voice_call_state; |
| 2805 |
MbimContextIpType ip_type; |
| 2806 |
MbimAccessMediaType media_type = MBIM_ACCESS_MEDIA_TYPE_UNKNOWN; |
| 2807 |
g_autofree gchar *access_string = NULL; |
| 2808 |
const MbimUuid *context_type; |
| 2809 |
guint32 nw_error; |
| 2810 |
GList *iter; |
| 2811 |
MbimTlv *tlv; |
| 2812 |
g_autofree gchar *tlv_str_1 = NULL; |
| 2813 |
const gchar *expected_tlv_str_1 = "abcde"; |
| 2814 |
g_autofree gchar *tlv_str_2 = NULL; |
| 2815 |
const gchar *expected_tlv_str_2 = "Orange"; |
| 2816 |
const guint8 *pco_3 = NULL; |
| 2817 |
guint32 pco_3_size = 0; |
| 2818 |
const guint8 expected_pco[] = { 0x01, 0x02, 0x03, 0x04, |
| 2819 |
0x05, 0x06, 0x07, 0x08, |
| 2820 |
0x09, 0x0A, 0x0B }; |
| 2821 |
|
| 2822 |
const guint8 buffer [] = { |
| 2823 |
/* header */ |
| 2824 |
0x03, 0x00, 0x00, 0x80, /* type */ |
| 2825 |
0xAA, 0x00, 0x00, 0x00, /* length */ |
| 2826 |
0x04, 0x00, 0x00, 0x00, /* transaction id */ |
| 2827 |
/* fragment header */ |
| 2828 |
0x01, 0x00, 0x00, 0x00, /* total */ |
| 2829 |
0x00, 0x00, 0x00, 0x00, /* current */ |
| 2830 |
/* command_done_message */ |
| 2831 |
0xA2, 0x89, 0xCC, 0x33, /* service id */ |
| 2832 |
0xBC, 0xBB, 0x8B, 0x4F, |
| 2833 |
0xB6, 0xB0, 0x13, 0x3E, |
| 2834 |
0xC2, 0xAA, 0xE6, 0xDF, |
| 2835 |
0x0C, 0x00, 0x00, 0x00, /* command id */ |
| 2836 |
0x00, 0x00, 0x00, 0x00, /* status code */ |
| 2837 |
0x7A, 0x00, 0x00, 0x00, /* buffer_length */ |
| 2838 |
/* information buffer */ |
| 2839 |
0x01, 0x00, 0x00, 0x00, /* session id */ |
| 2840 |
0x01, 0x00, 0x00, 0x00, /* activation state */ |
| 2841 |
0x00, 0x00, 0x00, 0x00, /* voice call state */ |
| 2842 |
0x01, 0x00, 0x00, 0x00, /* ip type */ |
| 2843 |
0x7E, 0x5E, 0x2A, 0x7E, /* context type */ |
| 2844 |
0x4E, 0x6F, 0x72, 0x72, |
| 2845 |
0x73, 0x6B, 0x65, 0x6E, |
| 2846 |
0x7E, 0x5E, 0x2A, 0x7E, |
| 2847 |
0x00, 0x00, 0x00, 0x00, /* nw error */ |
| 2848 |
0x01, 0x00, 0x00, 0x00, /* media type */ |
| 2849 |
0x0A, 0x00, 0x00, 0x00, /* access string */ |
| 2850 |
0x10, 0x00, 0x00, 0x00, |
| 2851 |
0x69, 0x00, 0x6E, 0x00, |
| 2852 |
0x74, 0x00, 0x65, 0x00, |
| 2853 |
0x72, 0x00, 0x6E, 0x00, |
| 2854 |
0x65, 0x00, 0x74, 0x00, |
| 2855 |
/* First unnamed TLV */ |
| 2856 |
0x0A, 0x00, 0x00, 0x02, /* TLV type MBIM_TLV_TYPE_WCHAR_STR, padding 2 */ |
| 2857 |
0x0A, 0x00, 0x00, 0x00, /* TLV data length */ |
| 2858 |
0x61, 0x00, 0x62, 0x00, /* TLV data string */ |
| 2859 |
0x63, 0x00, 0x64, 0x00, |
| 2860 |
0x65, 0x00, 0x00, 0x00, |
| 2861 |
/* Second unnamed TLV */ |
| 2862 |
0x0A, 0x00, 0x00, 0x00, /* TLV type MBIM_TLV_TYPE_WCHAR_STR, no padding */ |
| 2863 |
0x0C, 0x00, 0x00, 0x00, /* TLV data length */ |
| 2864 |
0x4F, 0x00, 0x72, 0x00, /* TLV data string */ |
| 2865 |
0x61, 0x00, 0x6E, 0x00, |
| 2866 |
0x67, 0x00, 0x65, 0x00, |
| 2867 |
/* Third unnamed TLV */ |
| 2868 |
0x0D, 0x00, 0x00, 0x01, /* TLV type MBIM_TLV_TYPE_PCO, padding 1 */ |
| 2869 |
0x0B, 0x00, 0x00, 0x00, /* TLV data length */ |
| 2870 |
0x01, 0x02, 0x03, 0x04, /* TLV data bytes */ |
| 2871 |
0x05, 0x06, 0x07, 0x08, |
| 2872 |
0x09, 0x0A, 0x0B, 0x00, |
| 2873 |
}; |
| 2874 |
|
| 2875 |
response = mbim_message_new (buffer, sizeof (buffer)); |
| 2876 |
g_assert (mbim_message_validate (response, &error)); |
| 2877 |
g_assert_no_error (error); |
| 2878 |
|
| 2879 |
test_message_printable (response, 3, 0); |
| 2880 |
|
| 2881 |
result = (mbim_message_ms_basic_connect_v3_connect_response_parse ( |
| 2882 |
response, |
| 2883 |
&session_id, |
| 2884 |
&activation_state, |
| 2885 |
&voice_call_state, |
| 2886 |
&ip_type, |
| 2887 |
&context_type, |
| 2888 |
&nw_error, |
| 2889 |
&media_type, |
| 2890 |
&access_string, |
| 2891 |
&unnamed_ies, |
| 2892 |
&error)); |
| 2893 |
|
| 2894 |
g_assert_no_error (error); |
| 2895 |
g_assert (result); |
| 2896 |
|
| 2897 |
g_assert_cmpuint (session_id, ==, 1); |
| 2898 |
g_assert_cmpuint (activation_state, ==, MBIM_ACTIVATION_STATE_ACTIVATED); |
| 2899 |
g_assert_cmpuint (voice_call_state, ==, MBIM_VOICE_CALL_STATE_NONE); |
| 2900 |
g_assert_cmpuint (ip_type, ==, MBIM_CONTEXT_IP_TYPE_IPV4); |
| 2901 |
g_assert_cmpuint (mbim_uuid_to_context_type (context_type), ==, MBIM_CONTEXT_TYPE_INTERNET); |
| 2902 |
g_assert_cmpuint (media_type, ==, MBIM_ACCESS_MEDIA_TYPE_3GPP); |
| 2903 |
g_assert_cmpstr (access_string, ==, "internet"); |
| 2904 |
g_assert_cmpuint (g_list_length (unnamed_ies), ==, 3); |
| 2905 |
|
| 2906 |
|
| 2907 |
iter = unnamed_ies; |
| 2908 |
tlv = (MbimTlv *)(iter->data); |
| 2909 |
g_assert_cmpuint (mbim_tlv_get_tlv_type (tlv), ==, MBIM_TLV_TYPE_WCHAR_STR); |
| 2910 |
tlv_str_1 = mbim_tlv_string_get (tlv, &error); |
| 2911 |
g_assert_no_error (error); |
| 2912 |
g_assert_cmpstr (tlv_str_1, ==, expected_tlv_str_1); |
| 2913 |
|
| 2914 |
iter = g_list_next (iter); |
| 2915 |
tlv = (MbimTlv *)(iter->data); |
| 2916 |
g_assert_cmpuint (mbim_tlv_get_tlv_type (tlv), ==, MBIM_TLV_TYPE_WCHAR_STR); |
| 2917 |
tlv_str_2 = mbim_tlv_string_get (tlv, &error); |
| 2918 |
g_assert_no_error (error); |
| 2919 |
g_assert_cmpstr (tlv_str_2, ==, expected_tlv_str_2); |
| 2920 |
|
| 2921 |
iter = g_list_next (iter); |
| 2922 |
tlv = (MbimTlv *)(iter->data); |
| 2923 |
g_assert_cmpuint (mbim_tlv_get_tlv_type (tlv), ==, MBIM_TLV_TYPE_PCO); |
| 2924 |
pco_3 = mbim_tlv_get_tlv_data (tlv, &pco_3_size); |
| 2925 |
g_assert_cmpuint (pco_3_size, ==, sizeof (expected_pco)); |
| 2926 |
g_assert (memcmp (pco_3, expected_pco, sizeof (expected_pco)) == 0); |
| 2927 |
|
| 2928 |
g_list_free_full (unnamed_ies, (GDestroyNotify)mbim_tlv_unref); |
| 2929 |
} |
| 2930 |
|
| 2931 |
static void |
| 2932 |
test_ms_basic_connect_extensions_device_caps_v3 (void) |
| 2933 |
{ |
| 2934 |
g_autoptr(GError) error = NULL; |
| 2935 |
g_autoptr(MbimMessage) response = NULL; |
| 2936 |
gboolean result; |
| 2937 |
MbimDeviceType device_type; |
| 2938 |
MbimVoiceClass voice_class; |
| 2939 |
MbimCellularClass cellular_class; |
| 2940 |
MbimSimClass sim_class; |
| 2941 |
MbimDataClassV3 data_class; |
| 2942 |
MbimDataSubclass data_subclass; |
| 2943 |
MbimSmsCaps sms_caps; |
| 2944 |
MbimCtrlCaps ctrl_caps; |
| 2945 |
guint32 max_sessions; |
| 2946 |
guint32 wcdma_band_class = 0; |
| 2947 |
guint32 lte_band_class_array_size = 0; |
| 2948 |
g_autofree guint16 *lte_band_class_array = NULL; |
| 2949 |
guint32 nr_band_class_array_size = 0; |
| 2950 |
g_autofree guint16 *nr_band_class_array = NULL; |
| 2951 |
g_autofree gchar *custom_data_class = NULL; |
| 2952 |
g_autofree gchar *device_id = NULL; |
| 2953 |
g_autofree gchar *firmware_info = NULL; |
| 2954 |
g_autofree gchar *hardware_info = NULL; |
| 2955 |
guint32 executor_index; |
| 2956 |
static const guint16 expected_lte_band_class_array[] = { |
| 2957 |
1, 2, 3, 4, 5, 7, 8, 12, 13, 14, 17, 18, 19, 20, 25, 26, 28, 29, 30, 32, 34, 38, 39, 40, 41, 42, 43, 46, 48 |
| 2958 |
}; |
| 2959 |
static const guint16 expected_nr_band_class_array[] = { |
| 2960 |
1, 2, 3, 5, 7, 8, 20, 25, 28, 30, 38, 40, 41, 48, 66, 71, 77, 78, 79 |
| 2961 |
}; |
| 2962 |
|
| 2963 |
const guint8 buffer [] = { |
| 2964 |
0x03, 0x00, 0x00, 0x80, 0x68, 0x01, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, |
| 2965 |
0x00, 0x00, 0x00, 0x00, 0x3D, 0x01, 0xDC, 0xC5, 0xFE, 0xF5, 0x4D, 0x05, 0x0D, 0x3A, 0xBE, 0xF7, |
| 2966 |
0x05, 0x8E, 0x9A, 0xAF, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x01, 0x00, 0x00, |
| 2967 |
0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, |
| 2968 |
0x7C, 0x00, 0x00, 0x80, 0x03, 0x00, 0x00, 0x00, 0xA3, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, |
| 2969 |
0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9B, 0x00, 0x00, 0x00, |
| 2970 |
0x0B, 0x00, 0x00, 0x02, 0x3A, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04, 0x00, |
| 2971 |
0x05, 0x00, 0x07, 0x00, 0x08, 0x00, 0x0C, 0x00, 0x0D, 0x00, 0x0E, 0x00, 0x11, 0x00, 0x12, 0x00, |
| 2972 |
0x13, 0x00, 0x14, 0x00, 0x19, 0x00, 0x1A, 0x00, 0x1C, 0x00, 0x1D, 0x00, 0x1E, 0x00, 0x20, 0x00, |
| 2973 |
0x22, 0x00, 0x26, 0x00, 0x27, 0x00, 0x28, 0x00, 0x29, 0x00, 0x2A, 0x00, 0x2B, 0x00, 0x2E, 0x00, |
| 2974 |
0x30, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x00, 0x02, 0x26, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, |
| 2975 |
0x03, 0x00, 0x05, 0x00, 0x07, 0x00, 0x08, 0x00, 0x14, 0x00, 0x19, 0x00, 0x1C, 0x00, 0x1E, 0x00, |
| 2976 |
0x26, 0x00, 0x28, 0x00, 0x29, 0x00, 0x30, 0x00, 0x42, 0x00, 0x47, 0x00, 0x4D, 0x00, 0x4E, 0x00, |
| 2977 |
0x4F, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x02, 0x0A, 0x00, 0x00, 0x00, 0x48, 0x00, 0x53, 0x00, |
| 2978 |
0x50, 0x00, 0x41, 0x00, 0x2B, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x02, 0x1E, 0x00, 0x00, 0x00, |
| 2979 |
0x38, 0x00, 0x36, 0x00, 0x32, 0x00, 0x31, 0x00, 0x34, 0x00, 0x36, 0x00, 0x30, 0x00, 0x35, 0x00, |
| 2980 |
0x30, 0x00, 0x30, 0x00, 0x38, 0x00, 0x34, 0x00, 0x35, 0x00, 0x35, 0x00, 0x35, 0x00, 0x00, 0x00, |
| 2981 |
0x0A, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x38, 0x00, 0x31, 0x00, 0x36, 0x00, 0x30, 0x00, |
| 2982 |
0x30, 0x00, 0x2E, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x2E, 0x00, 0x39, 0x00, |
| 2983 |
0x39, 0x00, 0x2E, 0x00, 0x32, 0x00, 0x39, 0x00, 0x2E, 0x00, 0x31, 0x00, 0x37, 0x00, 0x2E, 0x00, |
| 2984 |
0x31, 0x00, 0x39, 0x00, 0x5F, 0x00, 0x47, 0x00, 0x43, 0x00, 0x0D, 0x00, 0x0A, 0x00, 0x42, 0x00, |
| 2985 |
0x39, 0x00, 0x30, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x56, 0x00, 0x31, 0x00, |
| 2986 |
0x2E, 0x00, 0x30, 0x00, 0x2E, 0x00, 0x36, 0x00 |
| 2987 |
}; |
| 2988 |
|
| 2989 |
response = mbim_message_new (buffer, sizeof (buffer)); |
| 2990 |
g_assert (mbim_message_validate (response, &error)); |
| 2991 |
g_assert_no_error (error); |
| 2992 |
|
| 2993 |
test_message_printable (response, 3, 0); |
| 2994 |
|
| 2995 |
result = (mbim_message_ms_basic_connect_extensions_v3_device_caps_response_parse ( |
| 2996 |
response, |
| 2997 |
&device_type, |
| 2998 |
&cellular_class, |
| 2999 |
&voice_class, |
| 3000 |
&sim_class, |
| 3001 |
&data_class, |
| 3002 |
&sms_caps, |
| 3003 |
&ctrl_caps, |
| 3004 |
&data_subclass, |
| 3005 |
&max_sessions, |
| 3006 |
&executor_index, |
| 3007 |
&wcdma_band_class, |
| 3008 |
<e_band_class_array_size, |
| 3009 |
<e_band_class_array, |
| 3010 |
&nr_band_class_array_size, |
| 3011 |
&nr_band_class_array, |
| 3012 |
&custom_data_class, |
| 3013 |
&device_id, |
| 3014 |
&firmware_info, |
| 3015 |
&hardware_info, |
| 3016 |
&error)); |
| 3017 |
|
| 3018 |
g_assert_no_error (error); |
| 3019 |
g_assert (result); |
| 3020 |
|
| 3021 |
g_assert_cmpuint (device_type, ==, MBIM_DEVICE_TYPE_EMBEDDED); |
| 3022 |
g_assert_cmpuint (cellular_class, ==, MBIM_CELLULAR_CLASS_GSM); |
| 3023 |
g_assert_cmpuint (voice_class, ==, MBIM_VOICE_CLASS_NO_VOICE); |
| 3024 |
g_assert_cmpuint (sim_class, ==, MBIM_SIM_CLASS_REMOVABLE); |
| 3025 |
g_assert_cmpuint (data_class, ==, (MBIM_DATA_CLASS_V3_UMTS | |
| 3026 |
MBIM_DATA_CLASS_V3_HSDPA | |
| 3027 |
MBIM_DATA_CLASS_V3_HSUPA | |
| 3028 |
MBIM_DATA_CLASS_V3_LTE | |
| 3029 |
MBIM_DATA_CLASS_V3_5G | |
| 3030 |
MBIM_DATA_CLASS_V3_CUSTOM)); |
| 3031 |
g_assert_cmpuint (sms_caps, ==, (MBIM_SMS_CAPS_PDU_RECEIVE | |
| 3032 |
MBIM_SMS_CAPS_PDU_SEND)); |
| 3033 |
g_assert_cmpuint (ctrl_caps, ==, (MBIM_CTRL_CAPS_REG_MANUAL | |
| 3034 |
MBIM_CTRL_CAPS_HW_RADIO_SWITCH | |
| 3035 |
MBIM_CTRL_CAPS_ESIM | |
| 3036 |
MBIM_CTRL_CAPS_SIM_HOT_SWAP_CAPABLE)); |
| 3037 |
g_assert_cmpuint (data_subclass, ==, (MBIM_DATA_SUBCLASS_5G_ENDC | |
| 3038 |
MBIM_DATA_SUBCLASS_5G_NR)); |
| 3039 |
g_assert_cmpuint (max_sessions, ==, 2); |
| 3040 |
g_assert_cmpuint (executor_index, ==, 0); |
| 3041 |
g_assert_cmpuint (wcdma_band_class, ==, (1 << (1 - 1) | |
| 3042 |
1 << (2 - 1) | |
| 3043 |
1 << (4 - 1) | |
| 3044 |
1 << (5 - 1) | |
| 3045 |
1 << (8 - 1))); |
| 3046 |
g_assert_cmpuint (G_N_ELEMENTS (expected_lte_band_class_array), ==, lte_band_class_array_size); |
| 3047 |
g_assert (memcmp (lte_band_class_array, expected_lte_band_class_array, lte_band_class_array_size * sizeof (guint16)) == 0); |
| 3048 |
g_assert_cmpuint (G_N_ELEMENTS (expected_nr_band_class_array), ==, nr_band_class_array_size); |
| 3049 |
g_assert (memcmp (nr_band_class_array, expected_nr_band_class_array, nr_band_class_array_size * sizeof (guint16)) == 0); |
| 3050 |
g_assert_cmpstr (custom_data_class, ==, "HSPA+"); |
| 3051 |
g_assert_cmpstr (device_id, ==, "862146050084555"); |
| 3052 |
g_assert_cmpstr (firmware_info, ==, "81600.0000.99.29.17.19_GC\r\nB90"); |
| 3053 |
g_assert_cmpstr (hardware_info, ==, "V1.0.6"); |
| 3054 |
} |
| 3055 |
|
| 3056 |
static void |
| 3057 |
test_ms_basic_connect_extensions_wake_reason_command (void) |
| 3058 |
{ |
| 3059 |
g_autoptr(GError) error = NULL; |
| 3060 |
g_autoptr(MbimMessage) response = NULL; |
| 3061 |
gboolean result; |
| 3062 |
MbimWakeType wake_type; |
| 3063 |
guint32 session_id; |
| 3064 |
g_autoptr(MbimTlv) wake_tlv = NULL; |
| 3065 |
const MbimUuid *service = NULL; |
| 3066 |
guint32 cid = 0; |
| 3067 |
guint32 payload_size = 0; |
| 3068 |
g_autofree guint8 *payload = NULL; |
| 3069 |
|
| 3070 |
const guint8 buffer [] = { |
| 3071 |
/* header */ |
| 3072 |
0x03, 0x00, 0x00, 0x80, /* type */ |
| 3073 |
0x5C, 0x00, 0x00, 0x00, /* length */ |
| 3074 |
0x04, 0x00, 0x00, 0x00, /* transaction id */ |
| 3075 |
/* fragment header */ |
| 3076 |
0x01, 0x00, 0x00, 0x00, /* total */ |
| 3077 |
0x00, 0x00, 0x00, 0x00, /* current */ |
| 3078 |
/* command_done_message */ |
| 3079 |
0x3D, 0x01, 0xDC, 0xC5, /* service id */ |
| 3080 |
0xFE, 0xF5, 0x4D, 0x05, |
| 3081 |
0x0D, 0x3A, 0xBE, 0xF7, |
| 3082 |
0x05, 0x8E, 0x9A, 0xAF, |
| 3083 |
0x13, 0x00, 0x00, 0x00, /* command id */ |
| 3084 |
0x00, 0x00, 0x00, 0x00, /* status code */ |
| 3085 |
0x2C, 0x00, 0x00, 0x00, /* buffer_length */ |
| 3086 |
/* information buffer */ |
| 3087 |
0x01, 0x00, 0x00, 0x00, /* wake type: cid indication */ |
| 3088 |
0x02, 0x00, 0x00, 0x00, /* session id */ |
| 3089 |
/* TLV */ |
| 3090 |
0x10, 0x00, 0x00, 0x00, /* TLV type MBIM_TLV_TYPE_WAKE_COMMAND, padding 0 */ |
| 3091 |
0x1C, 0x00, 0x00, 0x00, /* TLV data length */ |
| 3092 |
0xA2, 0x89, 0xCC, 0x33, /* service id: basic connect */ |
| 3093 |
0xBC, 0xBB, 0x8B, 0x4F, |
| 3094 |
0xB6, 0xB0, 0x13, 0x3E, |
| 3095 |
0xC2, 0xAA, 0xE6, 0xDF, |
| 3096 |
0x0B, 0x00, 0x00, 0x00, /* command id: signal state */ |
| 3097 |
0x00, 0x00, 0x00, 0x00, /* payload offset: none */ |
| 3098 |
0x00, 0x00, 0x00, 0x00, /* payload size: none */ |
| 3099 |
}; |
| 3100 |
|
| 3101 |
response = mbim_message_new (buffer, sizeof (buffer)); |
| 3102 |
g_assert (mbim_message_validate (response, &error)); |
| 3103 |
g_assert_no_error (error); |
| 3104 |
|
| 3105 |
test_message_printable (response, 3, 0); |
| 3106 |
|
| 3107 |
result = (mbim_message_ms_basic_connect_extensions_v3_wake_reason_response_parse ( |
| 3108 |
response, |
| 3109 |
&wake_type, |
| 3110 |
&session_id, |
| 3111 |
&wake_tlv, |
| 3112 |
&error)); |
| 3113 |
g_assert_no_error (error); |
| 3114 |
g_assert (result); |
| 3115 |
|
| 3116 |
g_assert_cmpuint (wake_type, ==, MBIM_WAKE_TYPE_CID_INDICATION); |
| 3117 |
g_assert_cmpuint (session_id, ==, 2); |
| 3118 |
g_assert_nonnull (wake_tlv); |
| 3119 |
g_assert_cmpuint (mbim_tlv_get_tlv_type (wake_tlv), ==, MBIM_TLV_TYPE_WAKE_COMMAND); |
| 3120 |
|
| 3121 |
result = (mbim_tlv_wake_command_get (wake_tlv, |
| 3122 |
&service, |
| 3123 |
&cid, |
| 3124 |
&payload_size, |
| 3125 |
&payload, |
| 3126 |
&error)); |
| 3127 |
g_assert_no_error (error); |
| 3128 |
g_assert (result); |
| 3129 |
|
| 3130 |
g_assert_cmpuint (mbim_uuid_to_service (service), ==, MBIM_SERVICE_BASIC_CONNECT); |
| 3131 |
g_assert_cmpuint (cid, ==, MBIM_CID_BASIC_CONNECT_SIGNAL_STATE); |
| 3132 |
g_assert_cmpuint (payload_size, ==, 0); |
| 3133 |
g_assert_null (payload); |
| 3134 |
} |
| 3135 |
|
| 3136 |
static void |
| 3137 |
test_ms_basic_connect_extensions_wake_reason_command_payload (void) |
| 3138 |
{ |
| 3139 |
g_autoptr(GError) error = NULL; |
| 3140 |
g_autoptr(MbimMessage) response = NULL; |
| 3141 |
gboolean result; |
| 3142 |
MbimWakeType wake_type; |
| 3143 |
guint32 session_id; |
| 3144 |
g_autoptr(MbimTlv) wake_tlv = NULL; |
| 3145 |
const MbimUuid *service = NULL; |
| 3146 |
guint32 cid = 0; |
| 3147 |
guint32 payload_size = 0; |
| 3148 |
g_autofree guint8 *payload = NULL; |
| 3149 |
guint32 payload_uint; |
| 3150 |
|
| 3151 |
const guint8 buffer [] = { |
| 3152 |
/* header */ |
| 3153 |
0x03, 0x00, 0x00, 0x80, /* type */ |
| 3154 |
0x60, 0x00, 0x00, 0x00, /* length */ |
| 3155 |
0x04, 0x00, 0x00, 0x00, /* transaction id */ |
| 3156 |
/* fragment header */ |
| 3157 |
0x01, 0x00, 0x00, 0x00, /* total */ |
| 3158 |
0x00, 0x00, 0x00, 0x00, /* current */ |
| 3159 |
/* command_done_message */ |
| 3160 |
0x3D, 0x01, 0xDC, 0xC5, /* service id */ |
| 3161 |
0xFE, 0xF5, 0x4D, 0x05, |
| 3162 |
0x0D, 0x3A, 0xBE, 0xF7, |
| 3163 |
0x05, 0x8E, 0x9A, 0xAF, |
| 3164 |
0x13, 0x00, 0x00, 0x00, /* command id */ |
| 3165 |
0x00, 0x00, 0x00, 0x00, /* status code */ |
| 3166 |
0x30, 0x00, 0x00, 0x00, /* buffer_length */ |
| 3167 |
/* information buffer */ |
| 3168 |
0x00, 0x00, 0x00, 0x00, /* wake type: cid response */ |
| 3169 |
0x02, 0x00, 0x00, 0x00, /* session id */ |
| 3170 |
/* TLV */ |
| 3171 |
0x10, 0x00, 0x00, 0x00, /* TLV type MBIM_TLV_TYPE_WAKE_COMMAND, padding 0 */ |
| 3172 |
0x20, 0x00, 0x00, 0x00, /* TLV data length */ |
| 3173 |
0xA2, 0x89, 0xCC, 0x33, /* service id: basic connect */ |
| 3174 |
0xBC, 0xBB, 0x8B, 0x4F, |
| 3175 |
0xB6, 0xB0, 0x13, 0x3E, |
| 3176 |
0xC2, 0xAA, 0xE6, 0xDF, |
| 3177 |
0x0C, 0x00, 0x00, 0x00, /* command id: connect */ |
| 3178 |
0x1C, 0x00, 0x00, 0x00, /* payload offset: 28 */ |
| 3179 |
0x04, 0x00, 0x00, 0x00, /* payload size: 4 */ |
| 3180 |
0x01, 0x00, 0x00, 0x00, /* payload: a guint32 */ |
| 3181 |
}; |
| 3182 |
|
| 3183 |
response = mbim_message_new (buffer, sizeof (buffer)); |
| 3184 |
g_assert (mbim_message_validate (response, &error)); |
| 3185 |
g_assert_no_error (error); |
| 3186 |
|
| 3187 |
test_message_printable (response, 3, 0); |
| 3188 |
|
| 3189 |
result = (mbim_message_ms_basic_connect_extensions_v3_wake_reason_response_parse ( |
| 3190 |
response, |
| 3191 |
&wake_type, |
| 3192 |
&session_id, |
| 3193 |
&wake_tlv, |
| 3194 |
&error)); |
| 3195 |
g_assert_no_error (error); |
| 3196 |
g_assert (result); |
| 3197 |
|
| 3198 |
g_assert_cmpuint (wake_type, ==, MBIM_WAKE_TYPE_CID_RESPONSE); |
| 3199 |
g_assert_cmpuint (session_id, ==, 2); |
| 3200 |
g_assert_nonnull (wake_tlv); |
| 3201 |
g_assert_cmpuint (mbim_tlv_get_tlv_type (wake_tlv), ==, MBIM_TLV_TYPE_WAKE_COMMAND); |
| 3202 |
|
| 3203 |
result = (mbim_tlv_wake_command_get (wake_tlv, |
| 3204 |
&service, |
| 3205 |
&cid, |
| 3206 |
&payload_size, |
| 3207 |
&payload, |
| 3208 |
&error)); |
| 3209 |
g_assert_no_error (error); |
| 3210 |
g_assert (result); |
| 3211 |
|
| 3212 |
g_assert_cmpuint (mbim_uuid_to_service (service), ==, MBIM_SERVICE_BASIC_CONNECT); |
| 3213 |
g_assert_cmpuint (cid, ==, MBIM_CID_BASIC_CONNECT_CONNECT); |
| 3214 |
g_assert_cmpuint (payload_size, ==, 4); |
| 3215 |
g_assert_nonnull (payload); |
| 3216 |
|
| 3217 |
memcpy (&payload_uint, payload, payload_size); |
| 3218 |
payload_uint = GUINT32_FROM_LE (payload_uint); |
| 3219 |
g_assert_cmpuint (payload_uint, ==, 1); |
| 3220 |
} |
| 3221 |
|
| 3222 |
static void |
| 3223 |
test_ms_basic_connect_extensions_wake_reason_packet (void) |
| 3224 |
{ |
| 3225 |
g_autoptr(GError) error = NULL; |
| 3226 |
g_autoptr(MbimMessage) response = NULL; |
| 3227 |
gboolean result; |
| 3228 |
MbimWakeType wake_type; |
| 3229 |
guint32 session_id; |
| 3230 |
g_autoptr(MbimTlv) wake_tlv = NULL; |
| 3231 |
guint32 filter_id = 0; |
| 3232 |
guint32 original_packet_size = 0; |
| 3233 |
guint32 packet_size = 0; |
| 3234 |
g_autofree guint8 *packet = NULL; |
| 3235 |
const guint8 expected_packet[] = { 0x01, 0x02, 0x03, 0x04, |
| 3236 |
0x05, 0x06, 0x07, 0x08, |
| 3237 |
0x09, 0x0A }; |
| 3238 |
|
| 3239 |
const guint8 buffer [] = { |
| 3240 |
/* header */ |
| 3241 |
0x03, 0x00, 0x00, 0x80, /* type */ |
| 3242 |
0x5C, 0x00, 0x00, 0x00, /* length */ |
| 3243 |
0x04, 0x00, 0x00, 0x00, /* transaction id */ |
| 3244 |
/* fragment header */ |
| 3245 |
0x01, 0x00, 0x00, 0x00, /* total */ |
| 3246 |
0x00, 0x00, 0x00, 0x00, /* current */ |
| 3247 |
/* command_done_message */ |
| 3248 |
0x3D, 0x01, 0xDC, 0xC5, /* service id */ |
| 3249 |
0xFE, 0xF5, 0x4D, 0x05, |
| 3250 |
0x0D, 0x3A, 0xBE, 0xF7, |
| 3251 |
0x05, 0x8E, 0x9A, 0xAF, |
| 3252 |
0x13, 0x00, 0x00, 0x00, /* command id */ |
| 3253 |
0x00, 0x00, 0x00, 0x00, /* status code */ |
| 3254 |
0x2C, 0x00, 0x00, 0x00, /* buffer_length */ |
| 3255 |
/* information buffer */ |
| 3256 |
0x02, 0x00, 0x00, 0x00, /* wake type: packet */ |
| 3257 |
0x02, 0x00, 0x00, 0x00, /* session id */ |
| 3258 |
/* TLV */ |
| 3259 |
0x11, 0x00, 0x00, 0x02, /* TLV type MBIM_TLV_TYPE_WAKE_PACKET, padding 2 */ |
| 3260 |
0x1A, 0x00, 0x00, 0x00, /* TLV data length */ |
| 3261 |
0x0B, 0x00, 0x00, 0x00, /* filter id */ |
| 3262 |
0x0C, 0x00, 0x00, 0x00, /* original packet size: 12 */ |
| 3263 |
0x10, 0x00, 0x00, 0x00, /* packet offset: 16 */ |
| 3264 |
0x0A, 0x00, 0x00, 0x00, /* packet size: 10 */ |
| 3265 |
0x01, 0x02, 0x03, 0x04, |
| 3266 |
0x05, 0x06, 0x07, 0x08, |
| 3267 |
0x09, 0x0A, 0x00, 0x00, /* last 2 bytes padding */ |
| 3268 |
}; |
| 3269 |
|
| 3270 |
response = mbim_message_new (buffer, sizeof (buffer)); |
| 3271 |
g_assert (mbim_message_validate (response, &error)); |
| 3272 |
g_assert_no_error (error); |
| 3273 |
|
| 3274 |
test_message_printable (response, 3, 0); |
| 3275 |
|
| 3276 |
result = (mbim_message_ms_basic_connect_extensions_v3_wake_reason_response_parse ( |
| 3277 |
response, |
| 3278 |
&wake_type, |
| 3279 |
&session_id, |
| 3280 |
&wake_tlv, |
| 3281 |
&error)); |
| 3282 |
g_assert_no_error (error); |
| 3283 |
g_assert (result); |
| 3284 |
|
| 3285 |
g_assert_cmpuint (wake_type, ==, MBIM_WAKE_TYPE_PACKET); |
| 3286 |
g_assert_cmpuint (session_id, ==, 2); |
| 3287 |
g_assert_nonnull (wake_tlv); |
| 3288 |
g_assert_cmpuint (mbim_tlv_get_tlv_type (wake_tlv), ==, MBIM_TLV_TYPE_WAKE_PACKET); |
| 3289 |
|
| 3290 |
result = (mbim_tlv_wake_packet_get (wake_tlv, |
| 3291 |
&filter_id, |
| 3292 |
&original_packet_size, |
| 3293 |
&packet_size, |
| 3294 |
&packet, |
| 3295 |
&error)); |
| 3296 |
g_assert_no_error (error); |
| 3297 |
g_assert (result); |
| 3298 |
|
| 3299 |
g_assert_cmpuint (filter_id, ==, 0x0B); |
| 3300 |
g_assert_cmpuint (original_packet_size, ==, 12); |
| 3301 |
g_assert_cmpuint (packet_size, ==, sizeof (expected_packet)); |
| 3302 |
g_assert_nonnull (packet); |
| 3303 |
g_assert (memcmp (packet, expected_packet, sizeof (expected_packet)) == 0); |
| 3304 |
} |
| 3305 |
|
| 3306 |
static void |
| 3307 |
test_ms_uicc_low_level_access_application_list (void) |
| 3308 |
{ |
| 3309 |
g_autoptr(GError) error = NULL; |
| 3310 |
g_autoptr(MbimMessage) response = NULL; |
| 3311 |
gboolean result; |
| 3312 |
guint32 version; |
| 3313 |
guint32 application_count; |
| 3314 |
guint32 active_application_index; |
| 3315 |
guint32 application_list_size_bytes; |
| 3316 |
g_autoptr(MbimUiccApplicationArray) applications = NULL; |
| 3317 |
|
| 3318 |
const guint8 expected_application_id[] = { 0xA0, 0x00, 0x00, 0x00, |
| 3319 |
0x87, 0x10, 0x02, 0xFF, |
| 3320 |
0x34, 0xFF, 0x07, 0x89, |
| 3321 |
0x31, 0x2E, 0x30, 0xFF }; |
| 3322 |
const gchar *expected_application_name = "Movistar"; |
| 3323 |
const guint8 expected_pin_key_references[] = { 0x01, 0x81 }; |
| 3324 |
|
| 3325 |
const guint8 buffer [] = { |
| 3326 |
/* header */ |
| 3327 |
0x03, 0x00, 0x00, 0x80, /* type */ |
| 3328 |
0x84, 0x00, 0x00, 0x00, /* length */ |
| 3329 |
0x03, 0x00, 0x00, 0x00, /* transaction id */ |
| 3330 |
/* fragment header */ |
| 3331 |
0x01, 0x00, 0x00, 0x00, /* total */ |
| 3332 |
0x00, 0x00, 0x00, 0x00, /* current */ |
| 3333 |
/* command_done message */ |
| 3334 |
0xC2, 0xF6, 0x58, 0x8E, /* service id */ |
| 3335 |
0xF0, 0x37, 0x4B, 0xC9, |
| 3336 |
0x86, 0x65, 0xF4, 0xD4, |
| 3337 |
0x4B, 0xD0, 0x93, 0x67, |
| 3338 |
0x07, 0x00, 0x00, 0x00, /* command id */ |
| 3339 |
0x00, 0x00, 0x00, 0x00, /* status code */ |
| 3340 |
0x54, 0x00, 0x00, 0x00, /* buffer_length */ |
| 3341 |
/* information buffer */ |
| 3342 |
0x01, 0x00, 0x00, 0x00, /* version: 1 */ |
| 3343 |
0x01, 0x00, 0x00, 0x00, /* app count: 1 */ |
| 3344 |
0x00, 0x00, 0x00, 0x00, /* active app index: 0 */ |
| 3345 |
0x3C, 0x00, 0x00, 0x00, /* app list size bytes: 60 */ |
| 3346 |
0x18, 0x00, 0x00, 0x00, /* application 0 offset: 24 bytes */ |
| 3347 |
0x3C, 0x00, 0x00, 0x00, /* application 0 length: 60 bytes */ |
| 3348 |
/* application 0 */ |
| 3349 |
0x04, 0x00, 0x00, 0x00, /* application type: usim */ |
| 3350 |
0x20, 0x00, 0x00, 0x00, /* application id offset: 32 bytes */ |
| 3351 |
0x10, 0x00, 0x00, 0x00, /* application id length: 16 bytes */ |
| 3352 |
0x30, 0x00, 0x00, 0x00, /* application name offset: 48 bytes */ |
| 3353 |
0x08, 0x00, 0x00, 0x00, /* application name length: 8 bytes */ |
| 3354 |
0x02, 0x00, 0x00, 0x00, /* num pin key refs: 2 */ |
| 3355 |
0x38, 0x00, 0x00, 0x00, /* pin key refs offset: 56 bytes */ |
| 3356 |
0x02, 0x00, 0x00, 0x00, /* pin key refs length: 2 bytes */ |
| 3357 |
/* application 0 databuffer */ |
| 3358 |
0xA0, 0x00, 0x00, 0x00, /* application id */ |
| 3359 |
0x87, 0x10, 0x02, 0xFF, |
| 3360 |
0x34, 0xFF, 0x07, 0x89, |
| 3361 |
0x31, 0x2E, 0x30, 0xFF, |
| 3362 |
0x4D, 0x6F, 0x76, 0x69, /* application name */ |
| 3363 |
0x73, 0x74, 0x61, 0x72, |
| 3364 |
0x01, 0x81, 0x00, 0x00, /* pin key refs plus 2 padding bytes */ |
| 3365 |
}; |
| 3366 |
|
| 3367 |
response = mbim_message_new (buffer, sizeof (buffer)); |
| 3368 |
g_assert (mbim_message_validate (response, &error)); |
| 3369 |
g_assert_no_error (error); |
| 3370 |
|
| 3371 |
test_message_printable (response, 1, 0); |
| 3372 |
|
| 3373 |
result = (mbim_message_ms_uicc_low_level_access_application_list_response_parse ( |
| 3374 |
response, |
| 3375 |
&version, |
| 3376 |
&application_count, |
| 3377 |
&active_application_index, |
| 3378 |
&application_list_size_bytes, |
| 3379 |
&applications, |
| 3380 |
&error)); |
| 3381 |
g_assert_no_error (error); |
| 3382 |
g_assert (result); |
| 3383 |
|
| 3384 |
g_assert_cmpuint (version, ==, 1); |
| 3385 |
g_assert_cmpuint (application_count, ==, 1); |
| 3386 |
g_assert_cmpuint (active_application_index, ==, 0); |
| 3387 |
g_assert_cmpuint (application_list_size_bytes, ==, 60); |
| 3388 |
g_assert_cmpuint (applications[0]->application_id_size, ==, sizeof (expected_application_id)); |
| 3389 |
g_assert (memcmp (applications[0]->application_id, expected_application_id, sizeof (expected_application_id)) == 0); |
| 3390 |
g_assert (g_strcmp0 (applications[0]->application_name, expected_application_name) == 0); |
| 3391 |
g_assert_cmpuint (applications[0]->pin_key_reference_count, ==, 2); |
| 3392 |
g_assert_cmpuint (applications[0]->pin_key_references_size, ==, sizeof (expected_pin_key_references)); |
| 3393 |
g_assert (memcmp (applications[0]->pin_key_references, expected_pin_key_references, sizeof (expected_pin_key_references)) == 0); |
| 3394 |
} |
| 3395 |
|
| 3396 |
static void |
| 3397 |
test_google_carrier_lock (void) |
| 3398 |
{ |
| 3399 |
g_autoptr(GError) error = NULL; |
| 3400 |
g_autoptr(MbimMessage) response = NULL; |
| 3401 |
gboolean result; |
| 3402 |
MbimCarrierLockStatus carrier_lock_status; |
| 3403 |
MbimCarrierLockModemState modem_state; |
| 3404 |
MbimCarrierLockCause carrier_lock_cause; |
| 3405 |
|
| 3406 |
const guint8 buffer [] = { |
| 3407 |
/* header */ |
| 3408 |
0x03, 0x00, 0x00, 0x80, /* type */ |
| 3409 |
0x3C, 0x00, 0x00, 0x00, /* length */ |
| 3410 |
0x03, 0x00, 0x00, 0x00, /* transaction id */ |
| 3411 |
/* fragment header */ |
| 3412 |
0x01, 0x00, 0x00, 0x00, /* total */ |
| 3413 |
0x00, 0x00, 0x00, 0x00, /* current */ |
| 3414 |
/* command_done message */ |
| 3415 |
0x3E, 0x1E, 0x92, 0xCF, /* service id */ |
| 3416 |
0xC5, 0x3D, 0x4F, 0x14, |
| 3417 |
0x85, 0xD0, 0xA8, 0x6A, |
| 3418 |
0xD9, 0xE1, 0x22, 0x45, |
| 3419 |
0x01, 0x00, 0x00, 0x00, /* command id */ |
| 3420 |
0x00, 0x00, 0x00, 0x00, /* status code */ |
| 3421 |
0x0C, 0x00, 0x00, 0x00, /* buffer length */ |
| 3422 |
/* information buffer */ |
| 3423 |
0x01, 0x00, 0x00, 0x00, /* carrier lock status*/ |
| 3424 |
0x00, 0x00, 0x00, 0x00, /* modem state */ |
| 3425 |
0x00, 0x00, 0x00, 0x00, /* carrier lock cause */ |
| 3426 |
}; |
| 3427 |
|
| 3428 |
response = mbim_message_new (buffer, sizeof (buffer)); |
| 3429 |
g_assert (mbim_message_validate (response, &error)); |
| 3430 |
g_assert_no_error (error); |
| 3431 |
|
| 3432 |
test_message_printable (response, 1, 0); |
| 3433 |
|
| 3434 |
result = mbim_message_google_carrier_lock_response_parse ( |
| 3435 |
response, |
| 3436 |
&carrier_lock_status, |
| 3437 |
&modem_state, |
| 3438 |
&carrier_lock_cause, |
| 3439 |
&error); |
| 3440 |
g_assert_no_error (error); |
| 3441 |
g_assert (result); |
| 3442 |
|
| 3443 |
g_assert_cmpuint (carrier_lock_status, ==, MBIM_CARRIER_LOCK_STATUS_APPLIED); |
| 3444 |
g_assert_cmpuint (modem_state, ==, MBIM_CARRIER_LOCK_MODEM_STATE_DEREGISTERED); |
| 3445 |
g_assert_cmpuint (carrier_lock_cause, ==, MBIM_CARRIER_LOCK_CAUSE_NOT_APPLICABLE); |
| 3446 |
} |
| 3447 |
|
| 3448 |
static void |
| 3449 |
test_google_carrier_lock_notification (void) |
| 3450 |
{ |
| 3451 |
g_autoptr(GError) error = NULL; |
| 3452 |
g_autoptr(MbimMessage) response = NULL; |
| 3453 |
gboolean result; |
| 3454 |
MbimCarrierLockStatus carrier_lock_status; |
| 3455 |
MbimCarrierLockModemState modem_state; |
| 3456 |
MbimCarrierLockCause carrier_lock_cause; |
| 3457 |
|
| 3458 |
const guint8 buffer [] = { |
| 3459 |
/* header */ |
| 3460 |
0x07, 0x00, 0x00, 0x80, /* type */ |
| 3461 |
0x38, 0x00, 0x00, 0x00, /* length */ |
| 3462 |
0x03, 0x00, 0x00, 0x00, /* transaction id */ |
| 3463 |
/* fragment header */ |
| 3464 |
0x01, 0x00, 0x00, 0x00, /* total */ |
| 3465 |
0x00, 0x00, 0x00, 0x00, /* current */ |
| 3466 |
/* command_done message */ |
| 3467 |
0x3E, 0x1E, 0x92, 0xCF, /* service id */ |
| 3468 |
0xC5, 0x3D, 0x4F, 0x14, |
| 3469 |
0x85, 0xD0, 0xA8, 0x6A, |
| 3470 |
0xD9, 0xE1, 0x22, 0x45, |
| 3471 |
0x01, 0x00, 0x00, 0x00, /* command id */ |
| 3472 |
0x0C, 0x00, 0x00, 0x00, /* buffer length */ |
| 3473 |
/* information buffer */ |
| 3474 |
0x01, 0x00, 0x00, 0x00, /* carrier lock status */ |
| 3475 |
0x00, 0x00, 0x00, 0x00, /* modem state */ |
| 3476 |
0x00, 0x00, 0x00, 0x00, /* carrier lock cause */ |
| 3477 |
}; |
| 3478 |
|
| 3479 |
response = mbim_message_new (buffer, sizeof (buffer)); |
| 3480 |
g_assert (mbim_message_validate (response, &error)); |
| 3481 |
g_assert_no_error (error); |
| 3482 |
|
| 3483 |
test_message_printable (response, 1, 0); |
| 3484 |
|
| 3485 |
result = mbim_message_google_carrier_lock_notification_parse ( |
| 3486 |
response, |
| 3487 |
&carrier_lock_status, |
| 3488 |
&modem_state, |
| 3489 |
&carrier_lock_cause, |
| 3490 |
&error); |
| 3491 |
g_assert_no_error (error); |
| 3492 |
g_assert (result); |
| 3493 |
|
| 3494 |
g_assert_cmpuint (carrier_lock_status, ==, MBIM_CARRIER_LOCK_STATUS_APPLIED); |
| 3495 |
g_assert_cmpuint (modem_state, ==, MBIM_CARRIER_LOCK_MODEM_STATE_DEREGISTERED); |
| 3496 |
g_assert_cmpuint (carrier_lock_cause, ==, MBIM_CARRIER_LOCK_CAUSE_NOT_APPLICABLE); |
| 3497 |
} |
| 3498 |
|
| 3499 |
int main (int argc, char **argv) |
| 3500 |
{ |
| 3501 |
g_test_init (&argc, &argv, NULL); |
| 3502 |
|
| 3503 |
#define PREFIX "/libmbim-glib/message/parser" |
| 3504 |
|
| 3505 |
g_test_add_func (PREFIX "/basic-connect/visible-providers", test_basic_connect_visible_providers); |
| 3506 |
g_test_add_func (PREFIX "/basic-connect/subscriber-ready-status", test_basic_connect_subscriber_ready_status); |
| 3507 |
g_test_add_func (PREFIX "/basic-connect/device-caps", test_basic_connect_device_caps); |
| 3508 |
g_test_add_func (PREFIX "/basic-connect/ip-configuration/1", test_basic_connect_ip_configuration); |
| 3509 |
g_test_add_func (PREFIX "/basic-connect/ip-configuration/2", test_basic_connect_ip_configuration_2); |
| 3510 |
g_test_add_func (PREFIX "/basic-connect/service-activation", test_basic_connect_service_activation); |
| 3511 |
g_test_add_func (PREFIX "/basic-connect/register-state", test_basic_connect_register_state); |
| 3512 |
g_test_add_func (PREFIX "/basic-connect/provisioned-contexts", test_provisioned_contexts); |
| 3513 |
g_test_add_func (PREFIX "/sms/read/zero-pdu", test_sms_read_zero_pdu); |
| 3514 |
g_test_add_func (PREFIX "/sms/read/single-pdu", test_sms_read_single_pdu); |
| 3515 |
g_test_add_func (PREFIX "/sms/read/multiple-pdu", test_sms_read_multiple_pdu); |
| 3516 |
g_test_add_func (PREFIX "/ussd", test_ussd); |
| 3517 |
g_test_add_func (PREFIX "/auth/akap", test_auth_akap); |
| 3518 |
g_test_add_func (PREFIX "/stk/pac/notification", test_stk_pac_notification); |
| 3519 |
g_test_add_func (PREFIX "/stk/pac/response", test_stk_pac_response); |
| 3520 |
g_test_add_func (PREFIX "/stk/terminal/response", test_stk_terminal_response); |
| 3521 |
g_test_add_func (PREFIX "/stk/envelope/response", test_stk_envelope_response); |
| 3522 |
g_test_add_func (PREFIX "/basic-connect/ip-packet-filters/none", test_basic_connect_ip_packet_filters_none); |
| 3523 |
g_test_add_func (PREFIX "/basic-connect/ip-packet-filters/one", test_basic_connect_ip_packet_filters_one); |
| 3524 |
g_test_add_func (PREFIX "/basic-connect/ip-packet-filters/two", test_basic_connect_ip_packet_filters_two); |
| 3525 |
g_test_add_func (PREFIX "/ms-firmware-id/get", test_ms_firmware_id_get); |
| 3526 |
g_test_add_func (PREFIX "/basic-connect/connect/short", test_basic_connect_connect_short); |
| 3527 |
g_test_add_func (PREFIX "/basic-connect/visible-providers/overflow", test_basic_connect_visible_providers_overflow); |
| 3528 |
g_test_add_func (PREFIX "/basic-connect-extensions/base-stations", test_ms_basic_connect_extensions_base_stations); |
| 3529 |
g_test_add_func (PREFIX "/basic-connect-extensions/registration-parameters/0-unnamed-tlvs", test_ms_basic_connect_extensions_registration_parameters_0_unnamed_tlvs); |
| 3530 |
g_test_add_func (PREFIX "/basic-connect-extensions/registration-parameters/1-unnamed-tlv", test_ms_basic_connect_extensions_registration_parameters_1_unnamed_tlv); |
| 3531 |
g_test_add_func (PREFIX "/basic-connect-extensions/registration-parameters/3-unnamed-tlvs", test_ms_basic_connect_extensions_registration_parameters_3_unnamed_tlvs); |
| 3532 |
g_test_add_func (PREFIX "/basic-connect-v3/connect/0-unnamed-tlvs", test_ms_basic_connect_v3_connect_0_unnamed_tlvs); |
| 3533 |
g_test_add_func (PREFIX "/basic-connect-v3/connect/0-unnamed-tlvs-empty-access-string", test_ms_basic_connect_v3_connect_0_unnamed_tlvs_empty_access_string); |
| 3534 |
g_test_add_func (PREFIX "/basic-connect-v3/connect/1-unnamed-tlv", test_ms_basic_connect_v3_connect_1_unnamed_tlv); |
| 3535 |
g_test_add_func (PREFIX "/basic-connect-v3/connect/3-unnamed-tlvs", test_ms_basic_connect_v3_connect_3_unnamed_tlvs); |
| 3536 |
g_test_add_func (PREFIX "/basic-connect-extensions/device-caps-v3", test_ms_basic_connect_extensions_device_caps_v3); |
| 3537 |
g_test_add_func (PREFIX "/basic-connect-extensions/wake-reason/command", test_ms_basic_connect_extensions_wake_reason_command); |
| 3538 |
g_test_add_func (PREFIX "/basic-connect-extensions/wake-reason/command/payload", test_ms_basic_connect_extensions_wake_reason_command_payload); |
| 3539 |
g_test_add_func (PREFIX "/basic-connect-extensions/wake-reason/packet", test_ms_basic_connect_extensions_wake_reason_packet); |
| 3540 |
g_test_add_func (PREFIX "/ms-uicc-low-level-access/application-list", test_ms_uicc_low_level_access_application_list); |
| 3541 |
g_test_add_func (PREFIX "/google/carrier-lock-response", test_google_carrier_lock); |
| 3542 |
g_test_add_func (PREFIX "/google/carrier-lock-notify", test_google_carrier_lock_notification); |
| 3543 |
|
| 3544 |
#undef PREFIX |
| 3545 |
|
| 3546 |
return g_test_run (); |
| 3547 |
} |