Debian Codegraph @

src/qmi-firmware-update/qfu-qdl-message.c

raw
1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * qmi-firmware-update -- Command line tool to update firmware in QMI devices
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * Copyright (C) 2016 Bjørn Mork <[email protected]>
19 * Copyright (C) 2016 Zodiac Inflight Innovations
20 * Copyright (C) 2016-2017 Aleksander Morgado <[email protected]>
21 */
22
23 #include <string.h>
24
25 #include <glib-object.h>
26 #include <gio/gio.h>
27
28 #include "qfu-qdl-message.h"
29 #include "qfu-utils.h"
30 #include "qfu-enum-types.h"
31
32 /******************************************************************************/
33 /* QDL generic */
34
35 /* Generic message for operations that just require the command id */
36 typedef struct _QdlMsg QdlMsg;
37 struct _QdlMsg {
38 guint8 cmd;
39 } __attribute__ ((packed));
40
41 G_STATIC_ASSERT (sizeof (QdlMsg) <= QFU_QDL_MESSAGE_MAX_HEADER_SIZE);
42
43 static gsize
44 qdl_message_generic_build (guint8 *buffer,
45 gsize buffer_len,
46 QfuQdlCmd cmd)
47 {
48 QdlMsg *req;
49
50 g_assert (buffer_len >= sizeof (QdlMsg));
51
52 /* Create request */
53 req = (QdlMsg *) buffer;
54 req->cmd = (guint8) cmd;
55
56 g_debug ("[qfu,qdl-message] sent %s:", qfu_qdl_cmd_get_string ((QfuQdlCmd) req->cmd));
57
58 return (sizeof (QdlMsg));
59 }
60
61 /******************************************************************************/
62 /* QDL Hello */
63
64 /* feature bits */
65 #define QDL_FEATURE_GENERIC_UNFRAMED 0x10
66 #define QDL_FEATURE_QDL_UNFRAMED 0x20
67 #define QDL_FEATURE_BAR_MODE 0x40
68
69 typedef struct _QdlHelloReq QdlHelloReq;
70 struct _QdlHelloReq {
71 guint8 cmd; /* 0x01 */
72 gchar magic[32];
73 guint8 maxver;
74 guint8 minver;
75 guint8 features;
76 } __attribute__ ((packed));
77
78 G_STATIC_ASSERT (sizeof (QdlHelloReq) <= QFU_QDL_MESSAGE_MAX_HEADER_SIZE);
79
80 gsize
81 qfu_qdl_request_hello_build (guint8 *buffer,
82 gsize buffer_len,
83 guint8 minver,
84 guint8 maxver)
85 {
86 static const QdlHelloReq common_hello_req = {
87 .cmd = QFU_QDL_CMD_HELLO_REQ,
88 .magic = { "QCOM high speed protocol hst" },
89 .maxver = 0,
90 .minver = 0,
91 .features = QDL_FEATURE_QDL_UNFRAMED | QDL_FEATURE_GENERIC_UNFRAMED,
92 };
93 QdlHelloReq *req;
94
95 g_assert (buffer_len >= sizeof (QdlHelloReq));
96
97 /* Create request */
98 req = (QdlHelloReq *) buffer;
99 memcpy (req, &common_hello_req, sizeof (QdlHelloReq));
100 req->minver = minver;
101 req->maxver = maxver;
102
103 g_debug ("[qfu,qdl-message] sent %s:", qfu_qdl_cmd_get_string ((QfuQdlCmd) req->cmd));
104 g_debug ("[qfu,qdl-message] magic: %.*s", req->maxver <= 5 ? 24 : 32, req->magic);
105 g_debug ("[qfu,qdl-message] maximum version: %u", req->maxver);
106 g_debug ("[qfu,qdl-message] minimum version: %u", req->minver);
107 g_debug ("[qfu,qdl-message] features: 0x%02x", req->features);
108
109 return (sizeof (QdlHelloReq));
110 }
111
112 typedef struct _QdlHelloRsp QdlHelloRsp;
113 struct _QdlHelloRsp {
114 guint8 cmd; /* 0x02 */
115 gchar magic[32];
116 guint8 maxver;
117 guint8 minver;
118 guint32 reserved1;
119 guint32 reserved2;
120 guint8 reserved3;
121 guint16 reserved4;
122 guint16 reserved5;
123 guint8 features;
124 } __attribute__ ((packed));
125
126 G_STATIC_ASSERT (sizeof (QdlHelloRsp) <= QFU_QDL_MESSAGE_MAX_HEADER_SIZE);
127
128 gboolean
129 qfu_qdl_response_hello_parse (const guint8 *buffer,
130 gsize buffer_len,
131 GError **error)
132 {
133 QdlHelloRsp *rsp;
134
135 if (buffer_len != sizeof (QdlHelloRsp)) {
136 g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
137 "message size mismatch: %" G_GSIZE_FORMAT " != %" G_GSIZE_FORMAT,
138 buffer_len, sizeof (QdlHelloRsp));
139 return FALSE;
140 }
141
142 rsp = (QdlHelloRsp *) buffer;
143 g_assert (rsp->cmd == QFU_QDL_CMD_HELLO_RSP);
144
145 g_debug ("[qfu,qdl-message] received %s:", qfu_qdl_cmd_get_string ((QfuQdlCmd) rsp->cmd));
146 g_debug ("[qfu,qdl-message] magic: %.*s", rsp->maxver <= 5 ? 24 : 32, rsp->magic);
147 g_debug ("[qfu,qdl-message] maximum version: %u", rsp->maxver);
148 g_debug ("[qfu,qdl-message] minimum version: %u", rsp->minver);
149 g_debug ("[qfu,qdl-message] features: 0x%02x", rsp->features);
150
151 /* For now, ignore fields */
152
153 return TRUE;
154 }
155
156 /******************************************************************************/
157 /* QDL Error */
158
159 typedef enum {
160 QDL_ERROR_NONE = 0x00,
161 QDL_ERROR_01_RESERVED = 0x01,
162 QDL_ERROR_BAD_ADDR = 0x02,
163 QDL_ERROR_BAD_LEN = 0x03,
164 QDL_ERROR_BAD_PACKET = 0x04,
165 QDL_ERROR_BAD_CMD = 0x05,
166 QDL_ERROR_06 = 0x06,
167 QDL_ERROR_OP_FAILED = 0x07,
168 QDL_ERROR_BAD_FLASH_ID = 0x08,
169 QDL_ERROR_BAD_VOLTAGE = 0x09,
170 QDL_ERROR_WRITE_FAILED = 0x0a,
171 QDL_ERROR_11_RESERVED = 0x0b,
172 QDL_ERROR_BAD_SPC = 0x0c,
173 QDL_ERROR_POWERDOWN = 0x0d,
174 QDL_ERROR_UNSUPPORTED = 0x0e,
175 QDL_ERROR_CMD_SEQ = 0x0f,
176 QDL_ERROR_CLOSE = 0x10,
177 QDL_ERROR_BAD_FEATURES = 0x11,
178 QDL_ERROR_SPACE = 0x12,
179 QDL_ERROR_BAD_SECURITY = 0x13,
180 QDL_ERROR_MULTI_UNSUPPORTED = 0x14,
181 QDL_ERROR_POWEROFF = 0x15,
182 QDL_ERROR_CMD_UNSUPPORTED = 0x16,
183 QDL_ERROR_BAD_CRC = 0x17,
184 QDL_ERROR_STATE = 0x18,
185 QDL_ERROR_TIMEOUT = 0x19,
186 QDL_ERROR_IMAGE_AUTH = 0x1a,
187 QDL_ERROR_LAST
188 } QdlError;
189
190 static const gchar *qdl_error_str[] = {
191 [QDL_ERROR_NONE ] = "None",
192 [QDL_ERROR_01_RESERVED ] = "Reserved",
193 [QDL_ERROR_BAD_ADDR ] = "Invalid destination address",
194 [QDL_ERROR_BAD_LEN ] = "Invalid length",
195 [QDL_ERROR_BAD_PACKET ] = "Unexpected end of packet",
196 [QDL_ERROR_BAD_CMD ] = "Invalid command",
197 [QDL_ERROR_06 ] = "Reserved",
198 [QDL_ERROR_OP_FAILED ] = "Operation failed",
199 [QDL_ERROR_BAD_FLASH_ID ] = "Invalid flash intelligent ID",
200 [QDL_ERROR_BAD_VOLTAGE ] = "Invalid programming voltage",
201 [QDL_ERROR_WRITE_FAILED ] = "Write verify failed",
202 [QDL_ERROR_11_RESERVED ] = "Reserved",
203 [QDL_ERROR_BAD_SPC ] = "Invalid security code",
204 [QDL_ERROR_POWERDOWN ] = "Power-down failed",
205 [QDL_ERROR_UNSUPPORTED ] = "NAND flash programming not supported",
206 [QDL_ERROR_CMD_SEQ ] = "Command out of sequence",
207 [QDL_ERROR_CLOSE ] = "Close failed",
208 [QDL_ERROR_BAD_FEATURES ] = "Invalid feature bits",
209 [QDL_ERROR_SPACE ] = "Out of space",
210 [QDL_ERROR_BAD_SECURITY ] = "Invalid security mode",
211 [QDL_ERROR_MULTI_UNSUPPORTED ] = "Multi-image NAND not supported",
212 [QDL_ERROR_POWEROFF ] = "Power-off command not supported",
213 [QDL_ERROR_CMD_UNSUPPORTED ] = "Command not supported",
214 [QDL_ERROR_BAD_CRC ] = "Invalid CRC",
215 [QDL_ERROR_STATE ] = "Command received in invalid state",
216 [QDL_ERROR_TIMEOUT ] = "Receive timeout",
217 [QDL_ERROR_IMAGE_AUTH ] = "Image authentication error",
218 };
219
220 G_STATIC_ASSERT (G_N_ELEMENTS (qdl_error_str) == QDL_ERROR_LAST);
221
222 static GIOErrorEnum
223 qdl_error_to_gio_error_enum (QdlError err)
224 {
225 if (err == QDL_ERROR_CMD_UNSUPPORTED)
226 return G_IO_ERROR_NOT_SUPPORTED;
227 return G_IO_ERROR_FAILED;
228 }
229
230 static const gchar *
231 qdl_error_to_string (QdlError err)
232 {
233 return (err < QDL_ERROR_LAST ? qdl_error_str[err] : "Unknown");
234 }
235
236 typedef struct _QdlErrRsp QdlErrRsp;
237 struct _QdlErrRsp {
238 guint8 cmd; /* 0x0d */
239 guint32 error;
240 guint8 errortxt;
241 } __attribute__ ((packed));
242
243 G_STATIC_ASSERT (sizeof (QdlErrRsp) <= QFU_QDL_MESSAGE_MAX_HEADER_SIZE);
244
245 gboolean
246 qfu_qdl_response_error_parse (const guint8 *buffer,
247 gsize buffer_len,
248 GError **error)
249 {
250 QdlErrRsp *rsp;
251
252 if (buffer_len != sizeof (QdlErrRsp)) {
253 g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
254 "message size mismatch: %" G_GSIZE_FORMAT " != %" G_GSIZE_FORMAT,
255 buffer_len, sizeof (QdlErrRsp));
256 return FALSE;
257 }
258
259 rsp = (QdlErrRsp *) buffer;
260 g_assert (rsp->cmd == QFU_QDL_CMD_ERROR);
261
262 g_debug ("[qfu,qdl-message] received %s", qfu_qdl_cmd_get_string ((QfuQdlCmd) rsp->cmd));
263 g_debug ("[qfu,qdl-message] error: %" G_GUINT32_FORMAT, GUINT32_FROM_LE (rsp->error));
264 g_debug ("[qfu,qdl-message] errortxt: %u", rsp->errortxt);
265
266 /* Always return an error in this case */
267 g_set_error (error, G_IO_ERROR, qdl_error_to_gio_error_enum (GUINT32_FROM_LE (rsp->error)),
268 "%s", qdl_error_to_string ((QdlError) GUINT32_FROM_LE (rsp->error)));
269 return FALSE;
270 }
271
272 /******************************************************************************/
273 /* QDL Ufopen */
274
275 typedef struct _QdlUfopenReq QdlUfopenReq;
276 struct _QdlUfopenReq {
277 guint8 cmd; /* 0x25 */
278 guint8 type;
279 guint32 length;
280 guint8 windowsize;
281 guint32 chunksize;
282 guint16 reserved;
283 } __attribute__ ((packed));
284
285 G_STATIC_ASSERT (sizeof (QdlUfopenReq) <= QFU_QDL_MESSAGE_MAX_HEADER_SIZE);
286
287 gssize
288 qfu_qdl_request_ufopen_build (guint8 *buffer,
289 gsize buffer_len,
290 QfuImage *image,
291 GCancellable *cancellable,
292 GError **error)
293 {
294 QdlUfopenReq *req;
295
296 g_assert (buffer_len >= sizeof (QdlUfopenReq));
297
298 /* Create request */
299 req = (QdlUfopenReq *) buffer;
300 memset (req, 0, sizeof (QdlUfopenReq));
301 req->cmd = QFU_QDL_CMD_OPEN_UNFRAMED_REQ;
302 req->type = (guint8) qfu_image_get_image_type (image);
303 req->windowsize = 1; /* snooped */
304 req->length = GUINT32_TO_LE (qfu_image_get_header_size (image) + qfu_image_get_data_size (image));
305 req->chunksize = GUINT32_TO_LE (qfu_image_get_data_size (image));
306
307 /* Append header */
308 if (qfu_image_read_header (image, buffer + sizeof (QdlUfopenReq), buffer_len - sizeof (QdlUfopenReq), cancellable, error) < 0) {
309 g_prefix_error (error, "couldn't read image header: ");
310 return -1;
311 }
312
313 g_debug ("[qfu,qdl-message] sent %s:", qfu_qdl_cmd_get_string ((QfuQdlCmd) req->cmd));
314 g_debug ("[qfu,qdl-message] type: %u", req->type);
315 g_debug ("[qfu,qdl-message] length: %" G_GUINT32_FORMAT, GUINT32_FROM_LE (req->length));
316 g_debug ("[qfu,qdl-message] window size: %u", req->windowsize);
317 g_debug ("[qfu,qdl-message] chunk size: %" G_GUINT32_FORMAT, GUINT32_FROM_LE (req->chunksize));
318
319 return (sizeof (QdlUfopenReq) + qfu_image_get_header_size (image));
320 }
321
322 typedef struct _QdlUfopenRsp QdlUfopenRsp;
323 struct _QdlUfopenRsp {
324 guint8 cmd; /* 0x26 */
325 guint16 status;
326 guint8 windowsize;
327 guint32 chunksize;
328 } __attribute__ ((packed));
329
330 G_STATIC_ASSERT (sizeof (QdlUfopenRsp) <= QFU_QDL_MESSAGE_MAX_HEADER_SIZE);
331
332 gboolean
333 qfu_qdl_response_ufopen_parse (const guint8 *buffer,
334 gsize buffer_len,
335 GError **error)
336 {
337 QdlUfopenRsp *rsp;
338
339 if (buffer_len != sizeof (QdlUfopenRsp)) {
340 g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
341 "message size mismatch: %" G_GSIZE_FORMAT " != %" G_GSIZE_FORMAT,
342 buffer_len, sizeof (QdlUfopenRsp));
343 return FALSE;
344 }
345
346 rsp = (QdlUfopenRsp *) buffer;
347 g_assert (rsp->cmd == QFU_QDL_CMD_OPEN_UNFRAMED_RSP);
348
349 g_debug ("[qfu,qdl-message] received %s", qfu_qdl_cmd_get_string ((QfuQdlCmd) rsp->cmd));
350 g_debug ("[qfu,qdl-message] status: %" G_GUINT16_FORMAT, GUINT16_FROM_LE (rsp->status));
351 g_debug ("[qfu,qdl-message] window size: %u", rsp->windowsize);
352 g_debug ("[qfu,qdl-message] chunk size: %" G_GUINT32_FORMAT, GUINT32_FROM_LE (rsp->chunksize));
353
354 /* For now, ignore all fields but build a GError based on status */
355
356 /* Return error if status != 0 */
357 if (rsp->status != 0) {
358 g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
359 "operation returned an error status: %" G_GUINT16_FORMAT,
360 GUINT16_FROM_LE (rsp->status));
361 return FALSE;
362 }
363
364 return TRUE;
365 }
366
367 /******************************************************************************/
368 /* QDL Ufwrite */
369
370 /* This request is not HDLC framed, so this "header" includes the crc */
371 typedef struct _QdlUfwriteReq QdlUfwriteReq;
372 struct _QdlUfwriteReq {
373 guint8 cmd; /* 0x27 */
374 guint16 sequence;
375 guint32 reserved;
376 guint32 chunksize;
377 guint16 crc;
378 } __attribute__ ((packed));
379
380 G_STATIC_ASSERT (sizeof (QdlUfwriteReq) <= QFU_QDL_MESSAGE_MAX_HEADER_SIZE);
381
382 gssize
383 qfu_qdl_request_ufwrite_build (guint8 *buffer,
384 gsize buffer_len,
385 QfuImage *image,
386 guint16 sequence,
387 GCancellable *cancellable,
388 GError **error)
389 {
390 QdlUfwriteReq *req;
391 gssize n_read;
392
393 g_assert (buffer_len >= sizeof (QdlUfwriteReq));
394
395 /* Append chunk */
396 n_read = qfu_image_read_data_chunk (image, sequence, buffer + sizeof (QdlUfwriteReq), buffer_len - sizeof (QdlUfwriteReq), cancellable, error);
397 if (n_read < 0) {
398 g_prefix_error (error, "couldn't read image chunk #%u: ", sequence);
399 return -1;
400 }
401
402 /* Create request after appending, so that we have correct chunksize */
403 req = (QdlUfwriteReq *) buffer;
404 memset (req, 0, sizeof (QdlUfwriteReq));
405 req->cmd = QFU_QDL_CMD_WRITE_UNFRAMED_REQ;
406 req->sequence = GUINT16_TO_LE (sequence);
407 req->reserved = 0;
408 req->chunksize = GUINT32_TO_LE ((guint32) n_read);
409 req->crc = GUINT16_TO_LE (qfu_utils_crc16 (buffer, sizeof (QdlUfwriteReq) - 2));
410
411 g_debug ("[qfu,qdl-message] sent %s:", qfu_qdl_cmd_get_string ((QfuQdlCmd) req->cmd));
412 g_debug ("[qfu,qdl-message] sequence: %" G_GUINT16_FORMAT, GUINT16_FROM_LE (req->sequence));
413 g_debug ("[qfu,qdl-message] chunk size: %" G_GUINT32_FORMAT, GUINT32_FROM_LE (req->chunksize));
414
415 return (sizeof (QdlUfopenReq) + n_read);
416 }
417
418 /* The response is HDLC framed, so the crc is part of the framing */
419 typedef struct _QdlUfwriteRsp QdlUfwriteRsp;
420 struct _QdlUfwriteRsp {
421 guint8 cmd; /* 0x28 */
422 guint16 sequence;
423 guint32 reserved;
424 guint16 status;
425 } __attribute__ ((packed));
426
427 G_STATIC_ASSERT (sizeof (QdlUfwriteRsp) <= QFU_QDL_MESSAGE_MAX_HEADER_SIZE);
428
429 gboolean
430 qfu_qdl_response_ufwrite_parse (const guint8 *buffer,
431 gsize buffer_len,
432 guint16 *sequence,
433 GError **error)
434 {
435 QdlUfwriteRsp *rsp;
436
437 if (buffer_len != sizeof (QdlUfwriteRsp)) {
438 g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
439 "message size mismatch: %" G_GSIZE_FORMAT " != %" G_GSIZE_FORMAT,
440 buffer_len, sizeof (QdlUfwriteRsp));
441 return FALSE;
442 }
443
444 rsp = (QdlUfwriteRsp *) buffer;
445 g_assert (rsp->cmd == QFU_QDL_CMD_WRITE_UNFRAMED_RSP);
446
447 g_debug ("[qfu,qdl-message] received %s", qfu_qdl_cmd_get_string ((QfuQdlCmd) rsp->cmd));
448 g_debug ("[qfu,qdl-message] status: %" G_GUINT16_FORMAT, GUINT16_FROM_LE (rsp->status));
449 g_debug ("[qfu,qdl-message] sequence: %" G_GUINT16_FORMAT, GUINT16_FROM_LE (rsp->sequence));
450
451 /* Only return sequence and return GError based on status */
452
453 /* Return error if status != 0 */
454 if (rsp->status != 0) {
455 g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
456 "operation returned an error status: %" G_GUINT16_FORMAT,
457 GUINT16_FROM_LE (rsp->status));
458 return FALSE;
459 }
460
461 if (sequence)
462 *sequence = GUINT16_FROM_LE (rsp->sequence);
463
464 return TRUE;
465 }
466
467 /******************************************************************************/
468 /* QDL Ufclose */
469
470 gsize
471 qfu_qdl_request_ufclose_build (guint8 *buffer,
472 gsize buffer_len)
473 {
474 return qdl_message_generic_build (buffer, buffer_len, QFU_QDL_CMD_CLOSE_UNFRAMED_REQ);
475 }
476
477 typedef struct _QdlUfcloseRsp QdlUfcloseRsp;
478 struct _QdlUfcloseRsp {
479 guint8 cmd; /* 0x2a */
480 guint16 status;
481 guint8 type;
482 guint8 errortxt;
483 } __attribute__ ((packed));
484
485 gboolean
486 qfu_qdl_response_ufclose_parse (const guint8 *buffer,
487 gsize buffer_len,
488 GError **error)
489 {
490 QdlUfcloseRsp *rsp;
491
492 if (buffer_len != sizeof (QdlUfcloseRsp)) {
493 g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
494 "message size mismatch: %" G_GSIZE_FORMAT " != %" G_GSIZE_FORMAT,
495 buffer_len, sizeof (QdlUfcloseRsp));
496 return FALSE;
497 }
498
499 rsp = (QdlUfcloseRsp *) buffer;
500 g_assert (rsp->cmd == QFU_QDL_CMD_CLOSE_UNFRAMED_RSP);
501
502 g_debug ("[qfu,qdl-message] received %s", qfu_qdl_cmd_get_string ((QfuQdlCmd) rsp->cmd));
503 g_debug ("[qfu,qdl-message] status: %" G_GUINT16_FORMAT, GUINT16_FROM_LE (rsp->status));
504 g_debug ("[qfu,qdl-message] type: %u", rsp->type);
505 g_debug ("[qfu,qdl-message] errortxt: %u", rsp->errortxt);
506
507 /* For now, ignore all fields but build a GError based on status */
508
509 /* Return error if status != 0 */
510 if (rsp->status != 0) {
511 g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
512 "operation returned an error status: %" G_GUINT16_FORMAT,
513 GUINT16_FROM_LE (rsp->status));
514 return FALSE;
515 }
516
517 return TRUE;
518 }
519
520 /******************************************************************************/
521 /* QDL session close */
522
523 gsize
524 qfu_qdl_request_reset_build (guint8 *buffer,
525 gsize buffer_len)
526 {
527 return qdl_message_generic_build (buffer, buffer_len, QFU_QDL_CMD_RESET_REQ);
528 }
529
530 /******************************************************************************/
531 /* Other unused messages */
532
533 /* 0x29 - cmd only */
534 /* 0x2d - cmd only */
535 /* 0x2e - cmd only */
536
537 typedef struct _QdlImageprefRsp QdlImageprefRsp;
538 struct _QdlImageprefRsp {
539 guint8 cmd; /* 0x2f */
540 guint8 entries;
541 struct {
542 guint8 type;
543 gchar id[16];
544 } image[];
545 } __attribute__ ((packed));