Debian Codegraph @

src/libmbim-glib/mbim-uuid.c

raw
1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* SPDX-License-Identifier: LGPL-2.1-or-later */
3 /*
4 * libmbim-glib -- GLib/GIO based library to control MBIM devices
5 *
6 * Copyright (C) 2013 - 2014 Aleksander Morgado <[email protected]>
7 * Copyright (C) 2014 NVDIA Corporation
8 * Copyright (C) 2014 Smith Micro Software, Inc.
9 * Copyright (C) 2022 Intel Corporation
10 */
11
12 #include <config.h>
13 #include <stdio.h>
14 #include <string.h>
15
16 #include "mbim-uuid.h"
17 #include "generated/mbim-enum-types.h"
18
19 /*****************************************************************************/
20
21 gboolean
22 mbim_uuid_cmp (const MbimUuid *a,
23 const MbimUuid *b)
24 {
25 return (memcmp (a, b, sizeof (*a)) == 0);
26 }
27
28 gchar *
29 mbim_uuid_get_printable (const MbimUuid *uuid)
30
31 {
32 return (g_strdup_printf (
33 "%02x%02x%02x%02x-"
34 "%02x%02x-"
35 "%02x%02x-"
36 "%02x%02x-"
37 "%02x%02x%02x%02x%02x%02x",
38 uuid->a[0], uuid->a[1], uuid->a[2], uuid->a[3],
39 uuid->b[0], uuid->b[1],
40 uuid->c[0], uuid->c[1],
41 uuid->d[0], uuid->d[1],
42 uuid->e[0], uuid->e[1], uuid->e[2], uuid->e[3], uuid->e[4], uuid->e[5]));
43 }
44
45 gboolean
46 mbim_uuid_from_printable (const gchar *str,
47 MbimUuid *uuid)
48 {
49 guint8 tmp[16];
50 guint i;
51 guint k;
52 gint d0;
53 gint d1;
54
55 g_return_val_if_fail (str != NULL, FALSE);
56 g_return_val_if_fail (uuid != NULL, FALSE);
57
58 if (strlen (str) != 36)
59 return FALSE;
60
61 for (i = 0, k = 0, d0 = -1, d1 = -1; str[i]; i++) {
62 /* Accept dashes in expected positions */
63 if (str[i] == '-') {
64 if (i == 8 || i == 13 || i == 18 || i == 23)
65 continue;
66 return FALSE;
67 }
68 /* Read first digit in the hex pair */
69 else if (d0 == -1) {
70 d0 = g_ascii_xdigit_value (str[i]);
71 if (d0 == -1)
72 return FALSE;
73 }
74 /* Read second digit in the hex pair */
75 else {
76 d1 = g_ascii_xdigit_value (str[i]);
77 if (d1 == -1)
78 return FALSE;
79 tmp[k++] = (d0 << 4) | d1;
80 d0 = d1 = -1;
81 }
82 }
83
84 memcpy (uuid, tmp, sizeof (tmp));
85
86 return TRUE;
87 }
88
89 /*****************************************************************************/
90
91 static const MbimUuid uuid_invalid = {
92 .a = { 0x00, 0x00, 0x00, 0x00 },
93 .b = { 0x00, 0x00 },
94 .c = { 0x00, 0x00 },
95 .d = { 0x00, 0x00 },
96 .e = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
97 };
98
99 static const MbimUuid uuid_basic_connect = {
100 .a = { 0xa2, 0x89, 0xcc, 0x33 },
101 .b = { 0xbc, 0xbb },
102 .c = { 0x8b, 0x4f },
103 .d = { 0xb6, 0xb0 },
104 .e = { 0x13, 0x3e, 0xc2, 0xaa, 0xe6, 0xdf }
105 };
106
107 static const MbimUuid uuid_sms = {
108 .a = { 0x53, 0x3f, 0xbe, 0xeb },
109 .b = { 0x14, 0xfe },
110 .c = { 0x44, 0x67 },
111 .d = { 0x9f, 0x90 },
112 .e = { 0x33, 0xa2, 0x23, 0xe5, 0x6c, 0x3f }
113 };
114
115 static const MbimUuid uuid_ussd = {
116 .a = { 0xe5, 0x50, 0xa0, 0xc8 },
117 .b = { 0x5e, 0x82 },
118 .c = { 0x47, 0x9e },
119 .d = { 0x82, 0xf7 },
120 .e = { 0x10, 0xab, 0xf4, 0xc3, 0x35, 0x1f }
121 };
122
123 static const MbimUuid uuid_phonebook = {
124 .a = { 0x4b, 0xf3, 0x84, 0x76 },
125 .b = { 0x1e, 0x6a },
126 .c = { 0x41, 0xdb },
127 .d = { 0xb1, 0xd8 },
128 .e = { 0xbe, 0xd2, 0x89, 0xc2, 0x5b, 0xdb }
129 };
130
131 static const MbimUuid uuid_stk = {
132 .a = { 0xd8, 0xf2, 0x01, 0x31 },
133 .b = { 0xfc, 0xb5 },
134 .c = { 0x4e, 0x17 },
135 .d = { 0x86, 0x02 },
136 .e = { 0xd6, 0xed, 0x38, 0x16, 0x16, 0x4c }
137 };
138
139 static const MbimUuid uuid_auth = {
140 .a = { 0x1d, 0x2b, 0x5f, 0xf7 },
141 .b = { 0x0a, 0xa1 },
142 .c = { 0x48, 0xb2 },
143 .d = { 0xaa, 0x52 },
144 .e = { 0x50, 0xf1, 0x57, 0x67, 0x17, 0x4e }
145 };
146
147 static const MbimUuid uuid_dss = {
148 .a = { 0xc0, 0x8a, 0x26, 0xdd },
149 .b = { 0x77, 0x18 },
150 .c = { 0x43, 0x82 },
151 .d = { 0x84, 0x82 },
152 .e = { 0x6e, 0x0d, 0x58, 0x3c, 0x4d, 0x0e }
153 };
154
155 static const MbimUuid uuid_ms_firmware_id = {
156 .a = { 0xe9, 0xf7, 0xde, 0xa2 },
157 .b = { 0xfe, 0xaf },
158 .c = { 0x40, 0x09 },
159 .d = { 0x93, 0xce },
160 .e = { 0x90, 0xa3, 0x69, 0x41, 0x03, 0xb6 }
161 };
162
163 static const MbimUuid uuid_ms_host_shutdown = {
164 .a = { 0x88, 0x3b, 0x7c, 0x26 },
165 .b = { 0x98, 0x5f },
166 .c = { 0x43, 0xfa },
167 .d = { 0x98, 0x04 },
168 .e = { 0x27, 0xd7, 0xfb, 0x80, 0x95, 0x9c }
169 };
170
171 static const MbimUuid uuid_ms_sar = {
172 .a = { 0x68, 0x22, 0x3d, 0x04 },
173 .b = { 0x9f, 0x6c },
174 .c = { 0x4e, 0x0f },
175 .d = { 0x82, 0x2d },
176 .e = { 0x28, 0x44, 0x1f, 0xb7, 0x23, 0x40 }
177 };
178
179 static const MbimUuid uuid_proxy_control = {
180 .a = { 0x83, 0x8c, 0xf7, 0xfb },
181 .b = { 0x8d, 0x0d },
182 .c = { 0x4d, 0x7f },
183 .d = { 0x87, 0x1e },
184 .e = { 0xd7, 0x1d , 0xbe, 0xfb, 0xb3, 0x9b }
185 };
186
187 /* Note: this UUID is likely to work only for Sierra modems */
188 static const MbimUuid uuid_qmi = {
189 .a = { 0xd1, 0xa3, 0x0b, 0xc2 },
190 .b = { 0xf9, 0x7a },
191 .c = { 0x6e, 0x43 },
192 .d = { 0xbf, 0x65 },
193 .e = { 0xc7, 0xe2 , 0x4f, 0xb0, 0xf0, 0xd3 }
194 };
195
196 static const MbimUuid uuid_atds = {
197 .a = { 0x59, 0x67, 0xbd, 0xcc },
198 .b = { 0x7f, 0xd2 },
199 .c = { 0x49, 0xa2 },
200 .d = { 0x9f, 0x5c },
201 .e = { 0xb2, 0xe7, 0x0e, 0x52, 0x7d, 0xb3 }
202 };
203
204 static const MbimUuid uuid_intel_firmware_update = {
205 .a = { 0x0e, 0xd3, 0x74, 0xcb },
206 .b = { 0xf8, 0x35 },
207 .c = { 0x44, 0x74 },
208 .d = { 0xbc, 0x11 },
209 .e = { 0x3b, 0x3f, 0xd7, 0x6f, 0x56, 0x41 }
210 };
211
212 static const MbimUuid uuid_qdu = {
213 .a = { 0x64, 0x27, 0x01, 0x5f },
214 .b = { 0x57, 0x9d },
215 .c = { 0x48, 0xf5 },
216 .d = { 0x8c, 0x54 },
217 .e = { 0xf4, 0x3e, 0xd1, 0xe7, 0x6f, 0x83 }
218 };
219
220 static const MbimUuid uuid_ms_basic_connect_extensions = {
221 .a = { 0x3d, 0x01, 0xdc, 0xc5 },
222 .b = { 0xfe, 0xf5 },
223 .c = { 0x4d, 0x05 },
224 .d = { 0x0d, 0x3a },
225 .e = { 0xbe, 0xf7, 0x05, 0x8e, 0x9a, 0xaf }
226 };
227
228 static const MbimUuid uuid_ms_uicc_low_level_access = {
229 .a = { 0xc2, 0xf6, 0x58, 0x8e },
230 .b = { 0xf0, 0x37 },
231 .c = { 0x4b, 0xc9 },
232 .d = { 0x86, 0x65 },
233 .e = { 0xf4, 0xd4, 0x4b, 0xd0, 0x93, 0x67 }
234 };
235
236 static const MbimUuid uuid_quectel = {
237 .a = { 0x11, 0x22, 0x33, 0x44 },
238 .b = { 0x55, 0x66 },
239 .c = { 0x77, 0x88 },
240 .d = { 0x99, 0xaa },
241 .e = { 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x11 }
242 };
243
244 static const MbimUuid uuid_intel_thermal_rf = {
245 .a = { 0xfd, 0xc2, 0x2a, 0xf2 },
246 .b = { 0xf4, 0x41 },
247 .c = { 0x4d, 0x46 },
248 .d = { 0xaf, 0x8d },
249 .e = { 0x25, 0x9f, 0xcd, 0xde, 0x46, 0x35 }
250 };
251
252 static const MbimUuid uuid_ms_voice_extensions = {
253 .a = { 0x8d, 0x8b, 0x9e, 0xba },
254 .b = { 0x37, 0xbe },
255 .c = { 0x44, 0x9b },
256 .d = { 0x8f, 0x1e },
257 .e = { 0x61, 0xcb, 0x03, 0x4a, 0x70, 0x2e }
258 };
259
260 static const MbimUuid uuid_intel_mutual_authentication = {
261 .a = { 0xf8, 0x5d, 0x46, 0xef },
262 .b = { 0xab, 0x26 },
263 .c = { 0x40, 0x81 },
264 .d = { 0x98, 0x68 },
265 .e = { 0x4d, 0x18, 0x3c, 0x0a, 0x3a, 0xec }
266 };
267
268 static const MbimUuid uuid_intel_tools = {
269 .a = { 0x4a, 0xda, 0x49, 0x62 },
270 .b = { 0xb9, 0x88 },
271 .c = { 0x46, 0xc3 },
272 .d = { 0x87, 0xa7 },
273 .e = { 0x97, 0xf2, 0x0f, 0x99, 0x4a, 0xbb }
274 };
275
276 static const MbimUuid uuid_google = {
277 .a = { 0x3e, 0x1e, 0x92, 0xcf },
278 .b = { 0xc5, 0x3d },
279 .c = { 0x4f, 0x14 },
280 .d = { 0x85, 0xd0 },
281 .e = { 0xa8, 0x6a, 0xd9, 0xe1, 0x22, 0x45 }
282 };
283
284 static const MbimUuid uuid_fibocom = {
285 .a = { 0xff, 0xff, 0xff, 0xff },
286 .b = { 0xab, 0xca },
287 .c = { 0x4b, 0x11 },
288 .d = { 0xa4, 0xe2 },
289 .e = { 0xf2, 0xfc, 0x87, 0xf9, 0x44, 0x88 }
290 };
291
292 static const MbimUuid uuid_compal = {
293 .a = { 0xa2, 0xa3, 0x2a, 0x97 },
294 .b = { 0xca, 0xb1 },
295 .c = { 0x4f, 0x57 },
296 .d = { 0x9a, 0xe1 },
297 .e = { 0x45, 0x1c, 0x74, 0xdd, 0xa9, 0x57 }
298 };
299
300 static const MbimUuid uuid_intel_at_tunnel = {
301 .a = { 0xda, 0x13, 0x8c, 0x64 },
302 .b = { 0x65, 0x15 },
303 .c = { 0x48, 0x93 },
304 .d = { 0x92, 0xb2 },
305 .e = { 0xa1, 0xe1, 0xca, 0x7c, 0x81, 0xca }
306 };
307
308 static GList *mbim_custom_service_list = NULL;
309
310 typedef struct {
311 guint service_id;
312 MbimUuid uuid;
313 gchar *nickname;
314 } MbimCustomService;
315
316 guint
317 mbim_register_custom_service (const MbimUuid *uuid,
318 const gchar *nickname)
319 {
320 MbimCustomService *s;
321 GList *l;
322 guint service_id = 100;
323
324 for (l = mbim_custom_service_list; l != NULL; l = l->next) {
325 s = (MbimCustomService *)l->data;
326 if (mbim_uuid_cmp (&s->uuid, uuid))
327 return s->service_id;
328 else
329 service_id = MAX (service_id, s->service_id);
330 }
331
332 /* create a new custom service */
333 s = g_slice_new (MbimCustomService);
334 s->service_id = service_id + 1;
335 memcpy (&s->uuid, uuid, sizeof (MbimUuid));
336 s->nickname = g_strdup (nickname);
337
338 mbim_custom_service_list = g_list_append (mbim_custom_service_list, s);
339 return s->service_id;
340 }
341
342 gboolean
343 mbim_unregister_custom_service (const guint id)
344 {
345 MbimCustomService *s;
346 GList *l;
347
348 for (l = mbim_custom_service_list; l != NULL; l = l->next) {
349 s = (MbimCustomService *)l->data;
350 if (s->service_id == id) {
351 g_free (s->nickname);
352 g_slice_free (MbimCustomService, s);
353 mbim_custom_service_list = \
354 g_list_delete_link (mbim_custom_service_list, l);
355 return TRUE;
356 }
357 }
358
359 return FALSE;
360 }
361
362 gboolean
363 mbim_service_id_is_custom (const guint id)
364 {
365 GList *l;
366
367 if (id < MBIM_SERVICE_LAST)
368 return FALSE;
369
370 for (l = mbim_custom_service_list; l != NULL; l = l->next) {
371 if (((MbimCustomService *)l->data)->service_id == id)
372 return TRUE;
373 }
374
375 return FALSE;
376 }
377
378 const gchar *
379 mbim_service_lookup_name (guint service)
380 {
381 GList *l;
382
383 if (service < MBIM_SERVICE_LAST)
384 return mbim_service_get_string (service);
385
386 for (l = mbim_custom_service_list; l != NULL; l = l->next) {
387 if (service == ((MbimCustomService *)l->data)->service_id)
388 return ((MbimCustomService *)l->data)->nickname;
389 }
390 return NULL;
391 }
392
393 const MbimUuid *
394 mbim_uuid_from_service (MbimService service)
395 {
396 GList *l;
397
398 g_return_val_if_fail (service < MBIM_SERVICE_LAST || mbim_service_id_is_custom (service), &uuid_invalid);
399
400 switch (service) {
401 case MBIM_SERVICE_INVALID:
402 return &uuid_invalid;
403 case MBIM_SERVICE_BASIC_CONNECT:
404 return &uuid_basic_connect;
405 case MBIM_SERVICE_SMS:
406 return &uuid_sms;
407 case MBIM_SERVICE_USSD:
408 return &uuid_ussd;
409 case MBIM_SERVICE_PHONEBOOK:
410 return &uuid_phonebook;
411 case MBIM_SERVICE_STK:
412 return &uuid_stk;
413 case MBIM_SERVICE_AUTH:
414 return &uuid_auth;
415 case MBIM_SERVICE_DSS:
416 return &uuid_dss;
417 case MBIM_SERVICE_MS_FIRMWARE_ID:
418 return &uuid_ms_firmware_id;
419 case MBIM_SERVICE_MS_HOST_SHUTDOWN:
420 return &uuid_ms_host_shutdown;
421 case MBIM_SERVICE_MS_SAR:
422 return &uuid_ms_sar;
423 case MBIM_SERVICE_PROXY_CONTROL:
424 return &uuid_proxy_control;
425 case MBIM_SERVICE_QMI:
426 return &uuid_qmi;
427 case MBIM_SERVICE_ATDS:
428 return &uuid_atds;
429 case MBIM_SERVICE_QDU:
430 return &uuid_qdu;
431 case MBIM_SERVICE_INTEL_FIRMWARE_UPDATE:
432 return &uuid_intel_firmware_update;
433 case MBIM_SERVICE_MS_BASIC_CONNECT_EXTENSIONS:
434 return &uuid_ms_basic_connect_extensions;
435 case MBIM_SERVICE_MS_UICC_LOW_LEVEL_ACCESS:
436 return &uuid_ms_uicc_low_level_access;
437 case MBIM_SERVICE_QUECTEL:
438 return &uuid_quectel;
439 case MBIM_SERVICE_INTEL_THERMAL_RF:
440 return &uuid_intel_thermal_rf;
441 case MBIM_SERVICE_MS_VOICE_EXTENSIONS:
442 return &uuid_ms_voice_extensions;
443 case MBIM_SERVICE_INTEL_MUTUAL_AUTHENTICATION:
444 return &uuid_intel_mutual_authentication;
445 case MBIM_SERVICE_INTEL_TOOLS:
446 return &uuid_intel_tools;
447 case MBIM_SERVICE_GOOGLE:
448 return &uuid_google;
449 case MBIM_SERVICE_FIBOCOM:
450 return &uuid_fibocom;
451 case MBIM_SERVICE_COMPAL:
452 return &uuid_compal;
453 case MBIM_SERVICE_INTEL_AT_TUNNEL:
454 return &uuid_intel_at_tunnel;
455 case MBIM_SERVICE_LAST:
456 g_assert_not_reached ();
457 default:
458 for (l = mbim_custom_service_list; l != NULL; l = l->next) {
459 if (service == ((MbimCustomService *)l->data)->service_id)
460 return &((MbimCustomService *)l->data)->uuid;
461 }
462 g_return_val_if_reached (NULL);
463 }
464 }
465
466 MbimService
467 mbim_uuid_to_service (const MbimUuid *uuid)
468 {
469 GList *l;
470
471 if (mbim_uuid_cmp (uuid, &uuid_basic_connect))
472 return MBIM_SERVICE_BASIC_CONNECT;
473
474 if (mbim_uuid_cmp (uuid, &uuid_sms))
475 return MBIM_SERVICE_SMS;
476
477 if (mbim_uuid_cmp (uuid, &uuid_ussd))
478 return MBIM_SERVICE_USSD;
479
480 if (mbim_uuid_cmp (uuid, &uuid_phonebook))
481 return MBIM_SERVICE_PHONEBOOK;
482
483 if (mbim_uuid_cmp (uuid, &uuid_stk))
484 return MBIM_SERVICE_STK;
485
486 if (mbim_uuid_cmp (uuid, &uuid_auth))
487 return MBIM_SERVICE_AUTH;
488
489 if (mbim_uuid_cmp (uuid, &uuid_dss))
490 return MBIM_SERVICE_DSS;
491
492 if (mbim_uuid_cmp (uuid, &uuid_ms_firmware_id))
493 return MBIM_SERVICE_MS_FIRMWARE_ID;
494
495 if (mbim_uuid_cmp (uuid, &uuid_ms_host_shutdown))
496 return MBIM_SERVICE_MS_HOST_SHUTDOWN;
497
498 if (mbim_uuid_cmp (uuid, &uuid_ms_sar))
499 return MBIM_SERVICE_MS_SAR;
500
501 if (mbim_uuid_cmp (uuid, &uuid_proxy_control))
502 return MBIM_SERVICE_PROXY_CONTROL;
503
504 if (mbim_uuid_cmp (uuid, &uuid_qmi))
505 return MBIM_SERVICE_QMI;
506
507 if (mbim_uuid_cmp (uuid, &uuid_atds))
508 return MBIM_SERVICE_ATDS;
509
510 if (mbim_uuid_cmp (uuid, &uuid_intel_firmware_update))
511 return MBIM_SERVICE_INTEL_FIRMWARE_UPDATE;
512
513 if (mbim_uuid_cmp (uuid, &uuid_qdu))
514 return MBIM_SERVICE_QDU;
515
516 if (mbim_uuid_cmp (uuid, &uuid_ms_basic_connect_extensions))
517 return MBIM_SERVICE_MS_BASIC_CONNECT_EXTENSIONS;
518
519 if (mbim_uuid_cmp (uuid, &uuid_ms_uicc_low_level_access))
520 return MBIM_SERVICE_MS_UICC_LOW_LEVEL_ACCESS;
521
522 if (mbim_uuid_cmp (uuid, &uuid_quectel))
523 return MBIM_SERVICE_QUECTEL;
524
525 if (mbim_uuid_cmp (uuid, &uuid_intel_thermal_rf))
526 return MBIM_SERVICE_INTEL_THERMAL_RF;
527
528 if (mbim_uuid_cmp (uuid, &uuid_ms_voice_extensions))
529 return MBIM_SERVICE_MS_VOICE_EXTENSIONS;
530
531 if (mbim_uuid_cmp (uuid, &uuid_intel_mutual_authentication))
532 return MBIM_SERVICE_INTEL_MUTUAL_AUTHENTICATION;
533
534 if (mbim_uuid_cmp (uuid, &uuid_intel_tools))
535 return MBIM_SERVICE_INTEL_TOOLS;
536
537 if (mbim_uuid_cmp (uuid, &uuid_google))
538 return MBIM_SERVICE_GOOGLE;
539
540 if (mbim_uuid_cmp (uuid, &uuid_fibocom))
541 return MBIM_SERVICE_FIBOCOM;
542
543 if (mbim_uuid_cmp (uuid, &uuid_compal))
544 return MBIM_SERVICE_COMPAL;
545
546 if (mbim_uuid_cmp (uuid, &uuid_intel_at_tunnel))
547 return MBIM_SERVICE_INTEL_AT_TUNNEL;
548
549 for (l = mbim_custom_service_list; l != NULL; l = l->next) {
550 if (mbim_uuid_cmp (&((MbimCustomService *)l->data)->uuid, uuid))
551 return ((MbimCustomService *)l->data)->service_id;
552 }
553
554 return MBIM_SERVICE_INVALID;
555 }
556
557 /*****************************************************************************/
558
559 static const MbimUuid uuid_context_type_none = {
560 .a = { 0xB4, 0x3F, 0x75, 0x8C },
561 .b = { 0xA5, 0x60 },
562 .c = { 0x4B, 0x46 },
563 .d = { 0xB3, 0x5E },
564 .e = { 0xC5, 0x86, 0x96, 0x41, 0xFB, 0x54 }
565 };
566
567 static const MbimUuid uuid_context_type_internet = {
568 .a = { 0x7E, 0x5E, 0x2A, 0x7E },
569 .b = { 0x4E, 0x6F },
570 .c = { 0x72, 0x72 },
571 .d = { 0x73, 0x6B },
572 .e = { 0x65, 0x6E, 0x7E, 0x5E, 0x2A, 0x7E }
573 };
574
575 static const MbimUuid uuid_context_type_vpn = {
576 .a = { 0x9B, 0x9F, 0x7B, 0xBE },
577 .b = { 0x89, 0x52 },
578 .c = { 0x44, 0xB7 },
579 .d = { 0x83, 0xAC },
580 .e = { 0xCA, 0x41, 0x31, 0x8D, 0xF7, 0xA0 }
581 };
582
583 static const MbimUuid uuid_context_type_voice = {
584 .a = { 0x88, 0x91, 0x82, 0x94 },
585 .b = { 0x0E, 0xF4 },
586 .c = { 0x43, 0x96 },
587 .d = { 0x8C, 0xCA },
588 .e = { 0xA8, 0x58, 0x8F, 0xBC, 0x02, 0xB2 }
589 };
590
591 static const MbimUuid uuid_context_type_video_share = {
592 .a = { 0x05, 0xA2, 0xA7, 0x16 },
593 .b = { 0x7C, 0x34 },
594 .c = { 0x4B, 0x4D },
595 .d = { 0x9A, 0x91 },
596 .e = { 0xC5, 0xEF, 0x0C, 0x7A, 0xAA, 0xCC }
597 };
598
599 static const MbimUuid uuid_context_type_purchase = {
600 .a = { 0xB3, 0x27, 0x24, 0x96 },
601 .b = { 0xAC, 0x6C },
602 .c = { 0x42, 0x2B },
603 .d = { 0xA8, 0xC0 },
604 .e = { 0xAC, 0xF6, 0x87, 0xA2, 0x72, 0x17 }
605 };
606
607 static const MbimUuid uuid_context_type_ims = {
608 .a = { 0x21, 0x61, 0x0D, 0x01 },
609 .b = { 0x30, 0x74 },
610 .c = { 0x4B, 0xCE },
611 .d = { 0x94, 0x25 },
612 .e = { 0xB5, 0x3A, 0x07, 0xD6, 0x97, 0xD6 }
613 };
614
615 static const MbimUuid uuid_context_type_mms = {
616 .a = { 0x46, 0x72, 0x66, 0x64 },
617 .b = { 0x72, 0x69 },
618 .c = { 0x6B, 0xC6 },
619 .d = { 0x96, 0x24 },
620 .e = { 0xD1, 0xD3, 0x53, 0x89, 0xAC, 0xA9 }
621 };
622
623 static const MbimUuid uuid_context_type_local = {
624 .a = { 0xA5, 0x7A, 0x9A, 0xFC },
625 .b = { 0xB0, 0x9F },
626 .c = { 0x45, 0xD7 },
627 .d = { 0xBB, 0x40 },
628 .e = { 0x03, 0x3C, 0x39, 0xF6, 0x0D, 0xB9 }
629 };
630
631 static const MbimUuid uuid_context_type_admin = {
632 .a = { 0x5F, 0x7E, 0x4C, 0x2E },
633 .b = { 0xE8, 0x0B },
634 .c = { 0x40, 0xA9 },
635 .d = { 0xA2, 0x39 },
636 .e = { 0xF0, 0xAB, 0xCF, 0xD1, 0x1F, 0x4B }
637 };
638
639 static const MbimUuid uuid_context_type_app = {
640 .a = { 0x74, 0xD8, 0x8A, 0x3D },
641 .b = { 0xDF, 0xBD },
642 .c = { 0x47, 0x99 },
643 .d = { 0x9A, 0x8C },
644 .e = { 0x73, 0x10, 0xA3, 0x7B, 0xB2, 0xEE }
645 };
646
647 static const MbimUuid uuid_context_type_xcap = {
648 .a = { 0x50, 0xD3, 0x78, 0xA7 },
649 .b = { 0xBA, 0xA5 },
650 .c = { 0x4A, 0x50 },
651 .d = { 0xB8, 0x72 },
652 .e = { 0x3F, 0xE5, 0xBB, 0x46, 0x34, 0x11 }
653 };
654
655 static const MbimUuid uuid_context_type_tethering = {
656 .a = { 0x5E, 0x4E, 0x06, 0x01 },
657 .b = { 0x48, 0xDC },
658 .c = { 0x4E, 0x2B },
659 .d = { 0xAC, 0xB8 },
660 .e = { 0x08, 0xB4, 0x01, 0x6B, 0xBA, 0xAC }
661 };
662
663 static const MbimUuid uuid_context_type_emergency_calling = {
664 .a = { 0x5F, 0x41, 0xAD, 0xB8 },
665 .b = { 0x20, 0x4E },
666 .c = { 0x4D, 0x31 },
667 .d = { 0x9D, 0xA8 },
668 .e = { 0xB3, 0xC9, 0x70, 0xE3, 0x60, 0xF2 }
669 };
670
671 const MbimUuid *
672 mbim_uuid_from_context_type (MbimContextType context_type)
673 {
674 g_return_val_if_fail (context_type <= MBIM_CONTEXT_TYPE_EMERGENCY_CALLING, &uuid_invalid);
675
676 switch (context_type) {
677 case MBIM_CONTEXT_TYPE_INVALID:
678 return &uuid_invalid;
679 case MBIM_CONTEXT_TYPE_NONE:
680 return &uuid_context_type_none;
681 case MBIM_CONTEXT_TYPE_INTERNET:
682 return &uuid_context_type_internet;
683 case MBIM_CONTEXT_TYPE_VPN:
684 return &uuid_context_type_vpn;
685 case MBIM_CONTEXT_TYPE_VOICE:
686 return &uuid_context_type_none;
687 case MBIM_CONTEXT_TYPE_VIDEO_SHARE:
688 return &uuid_context_type_video_share;
689 case MBIM_CONTEXT_TYPE_PURCHASE:
690 return &uuid_context_type_purchase;
691 case MBIM_CONTEXT_TYPE_IMS:
692 return &uuid_context_type_ims;
693 case MBIM_CONTEXT_TYPE_MMS:
694 return &uuid_context_type_mms;
695 case MBIM_CONTEXT_TYPE_LOCAL:
696 return &uuid_context_type_local;
697 case MBIM_CONTEXT_TYPE_ADMIN:
698 return &uuid_context_type_admin;
699 case MBIM_CONTEXT_TYPE_APP:
700 return &uuid_context_type_app;
701 case MBIM_CONTEXT_TYPE_XCAP:
702 return &uuid_context_type_xcap;
703 case MBIM_CONTEXT_TYPE_TETHERING:
704 return &uuid_context_type_tethering;
705 case MBIM_CONTEXT_TYPE_EMERGENCY_CALLING:
706 return &uuid_context_type_emergency_calling;
707 default:
708 g_assert_not_reached ();
709 }
710 }
711
712 MbimContextType
713 mbim_uuid_to_context_type (const MbimUuid *uuid)
714 {
715 if (mbim_uuid_cmp (uuid, &uuid_context_type_none))
716 return MBIM_CONTEXT_TYPE_NONE;
717
718 if (mbim_uuid_cmp (uuid, &uuid_context_type_internet))
719 return MBIM_CONTEXT_TYPE_INTERNET;
720
721 if (mbim_uuid_cmp (uuid, &uuid_context_type_vpn))
722 return MBIM_CONTEXT_TYPE_VPN;
723
724 if (mbim_uuid_cmp (uuid, &uuid_context_type_voice))
725 return MBIM_CONTEXT_TYPE_VOICE;
726
727 if (mbim_uuid_cmp (uuid, &uuid_context_type_video_share))
728 return MBIM_CONTEXT_TYPE_VIDEO_SHARE;
729
730 if (mbim_uuid_cmp (uuid, &uuid_context_type_purchase))
731 return MBIM_CONTEXT_TYPE_PURCHASE;
732
733 if (mbim_uuid_cmp (uuid, &uuid_context_type_ims))
734 return MBIM_CONTEXT_TYPE_IMS;
735
736 if (mbim_uuid_cmp (uuid, &uuid_context_type_mms))
737 return MBIM_CONTEXT_TYPE_MMS;
738
739 if (mbim_uuid_cmp (uuid, &uuid_context_type_local))
740 return MBIM_CONTEXT_TYPE_LOCAL;
741
742 if (mbim_uuid_cmp (uuid, &uuid_context_type_admin))
743 return MBIM_CONTEXT_TYPE_ADMIN;
744
745 if (mbim_uuid_cmp (uuid, &uuid_context_type_app))
746 return MBIM_CONTEXT_TYPE_APP;
747
748 if (mbim_uuid_cmp (uuid, &uuid_context_type_xcap))
749 return MBIM_CONTEXT_TYPE_XCAP;
750
751 if (mbim_uuid_cmp (uuid, &uuid_context_type_tethering))
752 return MBIM_CONTEXT_TYPE_TETHERING;
753
754 if (mbim_uuid_cmp (uuid, &uuid_context_type_emergency_calling))
755 return MBIM_CONTEXT_TYPE_EMERGENCY_CALLING;
756
757 return MBIM_CONTEXT_TYPE_INVALID;
758 }