Coverage Report

Created: 2025-07-01 07:09

/work/fu-genesys-usbhub-struct.c
Line
Count
Source (jump to first uncovered line)
1
/* auto-generated, do not modify */
2
#include "config.h"
3
4
#include "fu-genesys-usbhub-struct.h"
5
#include "fu-byte-array.h"
6
#include "fu-mem-private.h"
7
#include "fu-string.h"
8
9
#ifdef G_LOG_DOMAIN
10
  #undef G_LOG_DOMAIN
11
#endif
12
0
#define G_LOG_DOMAIN "FuStruct"
13
14
const gchar *
15
fu_genesys_ts_version_to_string(FuGenesysTsVersion val)
16
0
{
17
0
    if (val == FU_GENESYS_TS_VERSION_DYNAMIC_9_BYTE)
18
0
        return "dynamic-9-byte";
19
0
    if (val == FU_GENESYS_TS_VERSION_BONDING)
20
0
        return "bonding";
21
0
    if (val == FU_GENESYS_TS_VERSION_BONDING_QC)
22
0
        return "bonding-qc";
23
0
    if (val == FU_GENESYS_TS_VERSION_VENDOR_SUPPORT)
24
0
        return "vendor-support";
25
0
    if (val == FU_GENESYS_TS_VERSION_MULTI_TOKEN)
26
0
        return "multi-token";
27
0
    if (val == FU_GENESYS_TS_VERSION_DYNAMIC_2ND)
28
0
        return "dynamic-2nd";
29
0
    if (val == FU_GENESYS_TS_VERSION_RESERVED)
30
0
        return "reserved";
31
0
    if (val == FU_GENESYS_TS_VERSION_DYNAMIC_13_BYTE)
32
0
        return "dynamic-13-byte";
33
0
    if (val == FU_GENESYS_TS_VERSION_BRAND_PROJECT)
34
0
        return "brand-project";
35
0
    return NULL;
36
0
}
37
38
const gchar *
39
fu_genesys_fw_status_to_string(FuGenesysFwStatus val)
40
0
{
41
0
    if (val == FU_GENESYS_FW_STATUS_MASK)
42
0
        return "mask";
43
0
    if (val == FU_GENESYS_FW_STATUS_BANK1)
44
0
        return "bank1";
45
0
    if (val == FU_GENESYS_FW_STATUS_BANK2)
46
0
        return "bank2";
47
0
    return NULL;
48
0
}
49
50
const gchar *
51
fu_genesys_vs_codesign_check_to_string(FuGenesysVsCodesignCheck val)
52
0
{
53
0
    if (val == FU_GENESYS_VS_CODESIGN_CHECK_UNSUPPORTED)
54
0
        return "unsupported";
55
0
    if (val == FU_GENESYS_VS_CODESIGN_CHECK_SCALER)
56
0
        return "scaler";
57
0
    if (val == FU_GENESYS_VS_CODESIGN_CHECK_FW)
58
0
        return "fw";
59
0
    if (val == FU_GENESYS_VS_CODESIGN_CHECK_MASTER)
60
0
        return "master";
61
0
    if (val == FU_GENESYS_VS_CODESIGN_CHECK_RESERVED)
62
0
        return "reserved";
63
0
    if (val == FU_GENESYS_VS_CODESIGN_CHECK_HW)
64
0
        return "hw";
65
0
    return NULL;
66
0
}
67
68
static const gchar *
69
fu_genesys_vs_hid_isp_to_string(FuGenesysVsHidIsp val)
70
0
{
71
0
    if (val == FU_GENESYS_VS_HID_ISP_UNSUPPORTED)
72
0
        return "unsupported";
73
0
    if (val == FU_GENESYS_VS_HID_ISP_SUPPORT)
74
0
        return "support";
75
0
    if (val == FU_GENESYS_VS_HID_ISP_CODESIGN_N_RESET)
76
0
        return "codesign-n-reset";
77
0
    return NULL;
78
0
}
79
80
const gchar *
81
fu_genesys_fw_codesign_to_string(FuGenesysFwCodesign val)
82
0
{
83
0
    if (val == FU_GENESYS_FW_CODESIGN_NONE)
84
0
        return "none";
85
0
    if (val == FU_GENESYS_FW_CODESIGN_RSA)
86
0
        return "rsa";
87
0
    if (val == FU_GENESYS_FW_CODESIGN_ECDSA)
88
0
        return "ecdsa";
89
0
    return NULL;
90
0
}
91
92
const gchar *
93
fu_genesys_fw_type_to_string(FuGenesysFwType val)
94
31.2k
{
95
31.2k
    if (val == FU_GENESYS_FW_TYPE_HUB)
96
1.53k
        return "hub";
97
29.7k
    if (val == FU_GENESYS_FW_TYPE_DEV_BRIDGE)
98
20.2k
        return "dev-bridge";
99
9.50k
    if (val == FU_GENESYS_FW_TYPE_PD)
100
9.47k
        return "pd";
101
31
    if (val == FU_GENESYS_FW_TYPE_CODESIGN)
102
31
        return "codesign";
103
0
    if (val == FU_GENESYS_FW_TYPE_INSIDE_HUB_COUNT)
104
0
        return "inside-hub-count";
105
0
    if (val == FU_GENESYS_FW_TYPE_SCALER)
106
0
        return "scaler";
107
0
    if (val == FU_GENESYS_FW_TYPE_UNKNOWN)
108
0
        return "unknown";
109
0
    return NULL;
110
0
}
111
/* getters */
112
113
/* setters */
114
static gboolean
115
fu_struct_genesys_firmware_hdr_validate_internal(FuStructGenesysFirmwareHdr *st, GError **error)
116
7.69M
{
117
7.69M
    g_return_val_if_fail(st != NULL, FALSE);
118
7.69M
    if (strncmp((const gchar *) (st->data + 252), "XROM", 4) != 0) {
119
7.69M
        g_set_error_literal(error,
120
7.69M
                            FWUPD_ERROR,
121
7.69M
                            FWUPD_ERROR_INVALID_DATA,
122
7.69M
                            "constant FuStructGenesysFirmwareHdr.magic was not valid");
123
7.69M
        return FALSE;
124
7.69M
    }
125
1.70k
    return TRUE;
126
7.69M
}
127
/**
128
 * fu_struct_genesys_firmware_hdr_validate_stream: (skip):
129
 **/
130
gboolean
131
fu_struct_genesys_firmware_hdr_validate_stream(GInputStream *stream, gsize offset, GError **error)
132
7.72M
{
133
7.72M
    g_autoptr(GByteArray) st = NULL;
134
7.72M
    g_return_val_if_fail(G_IS_INPUT_STREAM(stream), FALSE);
135
7.72M
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
136
7.72M
    st = fu_input_stream_read_byte_array(stream, offset, 256, NULL, error);
137
7.72M
    if (st == NULL) {
138
0
        g_prefix_error(error, "FuStructGenesysFirmwareHdr failed read of 0x%x: ", (guint) 256);
139
0
        return FALSE;
140
0
    }
141
7.72M
    if (st->len != 256) {
142
30.2k
        g_set_error(error,
143
30.2k
                    FWUPD_ERROR,
144
30.2k
                    FWUPD_ERROR_INVALID_DATA,
145
30.2k
                    "FuStructGenesysFirmwareHdr requested 0x%x and got 0x%x",
146
30.2k
                    (guint) 256,
147
30.2k
                    (guint) st->len);
148
30.2k
        return FALSE;
149
30.2k
    }
150
7.69M
    return fu_struct_genesys_firmware_hdr_validate_internal(st, error);
151
7.72M
}
152
/* getters */
153
154
/* setters */
155
static gboolean
156
fu_struct_genesys_dev_firmware_hdr_validate_internal(FuStructGenesysDevFirmwareHdr *st, GError **error)
157
29.8k
{
158
29.8k
    g_return_val_if_fail(st != NULL, FALSE);
159
29.8k
    if (strncmp((const gchar *) (st->data + 252), "HOST", 4) != 0) {
160
9.67k
        g_set_error_literal(error,
161
9.67k
                            FWUPD_ERROR,
162
9.67k
                            FWUPD_ERROR_INVALID_DATA,
163
9.67k
                            "constant FuStructGenesysDevFirmwareHdr.magic was not valid");
164
9.67k
        return FALSE;
165
9.67k
    }
166
20.2k
    return TRUE;
167
29.8k
}
168
/**
169
 * fu_struct_genesys_dev_firmware_hdr_validate_stream: (skip):
170
 **/
171
gboolean
172
fu_struct_genesys_dev_firmware_hdr_validate_stream(GInputStream *stream, gsize offset, GError **error)
173
30.1k
{
174
30.1k
    g_autoptr(GByteArray) st = NULL;
175
30.1k
    g_return_val_if_fail(G_IS_INPUT_STREAM(stream), FALSE);
176
30.1k
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
177
30.1k
    st = fu_input_stream_read_byte_array(stream, offset, 256, NULL, error);
178
30.1k
    if (st == NULL) {
179
0
        g_prefix_error(error, "FuStructGenesysDevFirmwareHdr failed read of 0x%x: ", (guint) 256);
180
0
        return FALSE;
181
0
    }
182
30.1k
    if (st->len != 256) {
183
240
        g_set_error(error,
184
240
                    FWUPD_ERROR,
185
240
                    FWUPD_ERROR_INVALID_DATA,
186
240
                    "FuStructGenesysDevFirmwareHdr requested 0x%x and got 0x%x",
187
240
                    (guint) 256,
188
240
                    (guint) st->len);
189
240
        return FALSE;
190
240
    }
191
29.8k
    return fu_struct_genesys_dev_firmware_hdr_validate_internal(st, error);
192
30.1k
}
193
/* getters */
194
195
/* setters */
196
static gboolean
197
fu_struct_genesys_pd_firmware_hdr_validate_internal(FuStructGenesysPdFirmwareHdr *st, GError **error)
198
9.83k
{
199
9.83k
    g_return_val_if_fail(st != NULL, FALSE);
200
9.83k
    if (strncmp((const gchar *) (st->data + 252), "PRDY", 4) != 0) {
201
359
        g_set_error_literal(error,
202
359
                            FWUPD_ERROR,
203
359
                            FWUPD_ERROR_INVALID_DATA,
204
359
                            "constant FuStructGenesysPdFirmwareHdr.magic was not valid");
205
359
        return FALSE;
206
359
    }
207
9.47k
    return TRUE;
208
9.83k
}
209
/**
210
 * fu_struct_genesys_pd_firmware_hdr_validate_stream: (skip):
211
 **/
212
gboolean
213
fu_struct_genesys_pd_firmware_hdr_validate_stream(GInputStream *stream, gsize offset, GError **error)
214
10.0k
{
215
10.0k
    g_autoptr(GByteArray) st = NULL;
216
10.0k
    g_return_val_if_fail(G_IS_INPUT_STREAM(stream), FALSE);
217
10.0k
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
218
10.0k
    st = fu_input_stream_read_byte_array(stream, offset, 256, NULL, error);
219
10.0k
    if (st == NULL) {
220
0
        g_prefix_error(error, "FuStructGenesysPdFirmwareHdr failed read of 0x%x: ", (guint) 256);
221
0
        return FALSE;
222
0
    }
223
10.0k
    if (st->len != 256) {
224
240
        g_set_error(error,
225
240
                    FWUPD_ERROR,
226
240
                    FWUPD_ERROR_INVALID_DATA,
227
240
                    "FuStructGenesysPdFirmwareHdr requested 0x%x and got 0x%x",
228
240
                    (guint) 256,
229
240
                    (guint) st->len);
230
240
        return FALSE;
231
240
    }
232
9.83k
    return fu_struct_genesys_pd_firmware_hdr_validate_internal(st, error);
233
10.0k
}
234
/* getters */
235
/**
236
 * fu_struct_genesys_ts_static_get_tool_string_version: (skip):
237
 **/
238
FuGenesysTsVersion
239
fu_struct_genesys_ts_static_get_tool_string_version(const FuStructGenesysTsStatic *st)
240
0
{
241
0
    g_return_val_if_fail(st != NULL, 0x0);
242
0
    return st->data[0];
243
0
}
244
/**
245
 * fu_struct_genesys_ts_static_get_mask_project_code: (skip):
246
 **/
247
gchar *
248
fu_struct_genesys_ts_static_get_mask_project_code(const FuStructGenesysTsStatic *st)
249
0
{
250
0
    g_return_val_if_fail(st != NULL, NULL);
251
0
    return fu_memstrsafe(st->data, st->len, 1, 4, NULL);
252
0
}
253
/**
254
 * fu_struct_genesys_ts_static_get_mask_project_hardware: (skip):
255
 **/
256
gchar *
257
fu_struct_genesys_ts_static_get_mask_project_hardware(const FuStructGenesysTsStatic *st)
258
0
{
259
0
    g_return_val_if_fail(st != NULL, NULL);
260
0
    return fu_memstrsafe(st->data, st->len, 5, 1, NULL);
261
0
}
262
/**
263
 * fu_struct_genesys_ts_static_get_mask_project_firmware: (skip):
264
 **/
265
gchar *
266
fu_struct_genesys_ts_static_get_mask_project_firmware(const FuStructGenesysTsStatic *st)
267
0
{
268
0
    g_return_val_if_fail(st != NULL, NULL);
269
0
    return fu_memstrsafe(st->data, st->len, 6, 2, NULL);
270
0
}
271
/**
272
 * fu_struct_genesys_ts_static_get_mask_project_ic_type: (skip):
273
 **/
274
gchar *
275
fu_struct_genesys_ts_static_get_mask_project_ic_type(const FuStructGenesysTsStatic *st)
276
0
{
277
0
    g_return_val_if_fail(st != NULL, NULL);
278
0
    return fu_memstrsafe(st->data, st->len, 8, 6, NULL);
279
0
}
280
/**
281
 * fu_struct_genesys_ts_static_get_running_project_code: (skip):
282
 **/
283
gchar *
284
fu_struct_genesys_ts_static_get_running_project_code(const FuStructGenesysTsStatic *st)
285
0
{
286
0
    g_return_val_if_fail(st != NULL, NULL);
287
0
    return fu_memstrsafe(st->data, st->len, 14, 4, NULL);
288
0
}
289
/**
290
 * fu_struct_genesys_ts_static_get_running_project_hardware: (skip):
291
 **/
292
gchar *
293
fu_struct_genesys_ts_static_get_running_project_hardware(const FuStructGenesysTsStatic *st)
294
0
{
295
0
    g_return_val_if_fail(st != NULL, NULL);
296
0
    return fu_memstrsafe(st->data, st->len, 18, 1, NULL);
297
0
}
298
/**
299
 * fu_struct_genesys_ts_static_get_running_project_firmware: (skip):
300
 **/
301
gchar *
302
fu_struct_genesys_ts_static_get_running_project_firmware(const FuStructGenesysTsStatic *st)
303
0
{
304
0
    g_return_val_if_fail(st != NULL, NULL);
305
0
    return fu_memstrsafe(st->data, st->len, 19, 2, NULL);
306
0
}
307
/**
308
 * fu_struct_genesys_ts_static_get_running_project_ic_type: (skip):
309
 **/
310
gchar *
311
fu_struct_genesys_ts_static_get_running_project_ic_type(const FuStructGenesysTsStatic *st)
312
0
{
313
0
    g_return_val_if_fail(st != NULL, NULL);
314
0
    return fu_memstrsafe(st->data, st->len, 21, 6, NULL);
315
0
}
316
/**
317
 * fu_struct_genesys_ts_static_get_firmware_version: (skip):
318
 **/
319
gchar *
320
fu_struct_genesys_ts_static_get_firmware_version(const FuStructGenesysTsStatic *st)
321
0
{
322
0
    g_return_val_if_fail(st != NULL, NULL);
323
0
    return fu_memstrsafe(st->data, st->len, 27, 4, NULL);
324
0
}
325
326
/* setters */
327
/**
328
 * fu_struct_genesys_ts_static_set_tool_string_version: (skip):
329
 **/
330
void
331
fu_struct_genesys_ts_static_set_tool_string_version(FuStructGenesysTsStatic *st, FuGenesysTsVersion value)
332
0
{
333
0
    g_return_if_fail(st != NULL);
334
0
    st->data[0] = value;
335
0
}
336
/**
337
 * fu_struct_genesys_ts_static_set_mask_project_code: (skip):
338
 **/
339
gboolean
340
fu_struct_genesys_ts_static_set_mask_project_code(FuStructGenesysTsStatic *st, const gchar *value, GError **error)
341
0
{
342
0
    gsize len;
343
0
    g_return_val_if_fail(st != NULL, FALSE);
344
0
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
345
0
    if (value == NULL) {
346
0
        memset(st->data + 1, 0x0, 4);
347
0
        return TRUE;
348
0
    }
349
0
    len = strlen(value);
350
0
    if (len > 4) {
351
0
        g_set_error(error,
352
0
                    FWUPD_ERROR,
353
0
                    FWUPD_ERROR_INVALID_DATA,
354
0
                    "string '%s' (0x%x bytes) does not fit in FuStructGenesysTsStatic.mask_project_code (0x%x bytes)",
355
0
                    value, (guint) len, (guint) 4);
356
0
        return FALSE;
357
0
    }
358
0
    return fu_memcpy_safe(st->data, st->len, 1, (const guint8 *)value, len, 0x0, len, error);
359
0
}
360
/**
361
 * fu_struct_genesys_ts_static_set_mask_project_hardware: (skip):
362
 **/
363
gboolean
364
fu_struct_genesys_ts_static_set_mask_project_hardware(FuStructGenesysTsStatic *st, const gchar *value, GError **error)
365
0
{
366
0
    gsize len;
367
0
    g_return_val_if_fail(st != NULL, FALSE);
368
0
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
369
0
    if (value == NULL) {
370
0
        memset(st->data + 5, 0x0, 1);
371
0
        return TRUE;
372
0
    }
373
0
    len = strlen(value);
374
0
    if (len > 1) {
375
0
        g_set_error(error,
376
0
                    FWUPD_ERROR,
377
0
                    FWUPD_ERROR_INVALID_DATA,
378
0
                    "string '%s' (0x%x bytes) does not fit in FuStructGenesysTsStatic.mask_project_hardware (0x%x bytes)",
379
0
                    value, (guint) len, (guint) 1);
380
0
        return FALSE;
381
0
    }
382
0
    return fu_memcpy_safe(st->data, st->len, 5, (const guint8 *)value, len, 0x0, len, error);
383
0
}
384
/**
385
 * fu_struct_genesys_ts_static_set_mask_project_firmware: (skip):
386
 **/
387
gboolean
388
fu_struct_genesys_ts_static_set_mask_project_firmware(FuStructGenesysTsStatic *st, const gchar *value, GError **error)
389
0
{
390
0
    gsize len;
391
0
    g_return_val_if_fail(st != NULL, FALSE);
392
0
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
393
0
    if (value == NULL) {
394
0
        memset(st->data + 6, 0x0, 2);
395
0
        return TRUE;
396
0
    }
397
0
    len = strlen(value);
398
0
    if (len > 2) {
399
0
        g_set_error(error,
400
0
                    FWUPD_ERROR,
401
0
                    FWUPD_ERROR_INVALID_DATA,
402
0
                    "string '%s' (0x%x bytes) does not fit in FuStructGenesysTsStatic.mask_project_firmware (0x%x bytes)",
403
0
                    value, (guint) len, (guint) 2);
404
0
        return FALSE;
405
0
    }
406
0
    return fu_memcpy_safe(st->data, st->len, 6, (const guint8 *)value, len, 0x0, len, error);
407
0
}
408
/**
409
 * fu_struct_genesys_ts_static_set_mask_project_ic_type: (skip):
410
 **/
411
gboolean
412
fu_struct_genesys_ts_static_set_mask_project_ic_type(FuStructGenesysTsStatic *st, const gchar *value, GError **error)
413
0
{
414
0
    gsize len;
415
0
    g_return_val_if_fail(st != NULL, FALSE);
416
0
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
417
0
    if (value == NULL) {
418
0
        memset(st->data + 8, 0x0, 6);
419
0
        return TRUE;
420
0
    }
421
0
    len = strlen(value);
422
0
    if (len > 6) {
423
0
        g_set_error(error,
424
0
                    FWUPD_ERROR,
425
0
                    FWUPD_ERROR_INVALID_DATA,
426
0
                    "string '%s' (0x%x bytes) does not fit in FuStructGenesysTsStatic.mask_project_ic_type (0x%x bytes)",
427
0
                    value, (guint) len, (guint) 6);
428
0
        return FALSE;
429
0
    }
430
0
    return fu_memcpy_safe(st->data, st->len, 8, (const guint8 *)value, len, 0x0, len, error);
431
0
}
432
/**
433
 * fu_struct_genesys_ts_static_set_running_project_code: (skip):
434
 **/
435
gboolean
436
fu_struct_genesys_ts_static_set_running_project_code(FuStructGenesysTsStatic *st, const gchar *value, GError **error)
437
0
{
438
0
    gsize len;
439
0
    g_return_val_if_fail(st != NULL, FALSE);
440
0
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
441
0
    if (value == NULL) {
442
0
        memset(st->data + 14, 0x0, 4);
443
0
        return TRUE;
444
0
    }
445
0
    len = strlen(value);
446
0
    if (len > 4) {
447
0
        g_set_error(error,
448
0
                    FWUPD_ERROR,
449
0
                    FWUPD_ERROR_INVALID_DATA,
450
0
                    "string '%s' (0x%x bytes) does not fit in FuStructGenesysTsStatic.running_project_code (0x%x bytes)",
451
0
                    value, (guint) len, (guint) 4);
452
0
        return FALSE;
453
0
    }
454
0
    return fu_memcpy_safe(st->data, st->len, 14, (const guint8 *)value, len, 0x0, len, error);
455
0
}
456
/**
457
 * fu_struct_genesys_ts_static_set_running_project_hardware: (skip):
458
 **/
459
gboolean
460
fu_struct_genesys_ts_static_set_running_project_hardware(FuStructGenesysTsStatic *st, const gchar *value, GError **error)
461
0
{
462
0
    gsize len;
463
0
    g_return_val_if_fail(st != NULL, FALSE);
464
0
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
465
0
    if (value == NULL) {
466
0
        memset(st->data + 18, 0x0, 1);
467
0
        return TRUE;
468
0
    }
469
0
    len = strlen(value);
470
0
    if (len > 1) {
471
0
        g_set_error(error,
472
0
                    FWUPD_ERROR,
473
0
                    FWUPD_ERROR_INVALID_DATA,
474
0
                    "string '%s' (0x%x bytes) does not fit in FuStructGenesysTsStatic.running_project_hardware (0x%x bytes)",
475
0
                    value, (guint) len, (guint) 1);
476
0
        return FALSE;
477
0
    }
478
0
    return fu_memcpy_safe(st->data, st->len, 18, (const guint8 *)value, len, 0x0, len, error);
479
0
}
480
/**
481
 * fu_struct_genesys_ts_static_set_running_project_firmware: (skip):
482
 **/
483
gboolean
484
fu_struct_genesys_ts_static_set_running_project_firmware(FuStructGenesysTsStatic *st, const gchar *value, GError **error)
485
0
{
486
0
    gsize len;
487
0
    g_return_val_if_fail(st != NULL, FALSE);
488
0
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
489
0
    if (value == NULL) {
490
0
        memset(st->data + 19, 0x0, 2);
491
0
        return TRUE;
492
0
    }
493
0
    len = strlen(value);
494
0
    if (len > 2) {
495
0
        g_set_error(error,
496
0
                    FWUPD_ERROR,
497
0
                    FWUPD_ERROR_INVALID_DATA,
498
0
                    "string '%s' (0x%x bytes) does not fit in FuStructGenesysTsStatic.running_project_firmware (0x%x bytes)",
499
0
                    value, (guint) len, (guint) 2);
500
0
        return FALSE;
501
0
    }
502
0
    return fu_memcpy_safe(st->data, st->len, 19, (const guint8 *)value, len, 0x0, len, error);
503
0
}
504
/**
505
 * fu_struct_genesys_ts_static_set_running_project_ic_type: (skip):
506
 **/
507
gboolean
508
fu_struct_genesys_ts_static_set_running_project_ic_type(FuStructGenesysTsStatic *st, const gchar *value, GError **error)
509
0
{
510
0
    gsize len;
511
0
    g_return_val_if_fail(st != NULL, FALSE);
512
0
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
513
0
    if (value == NULL) {
514
0
        memset(st->data + 21, 0x0, 6);
515
0
        return TRUE;
516
0
    }
517
0
    len = strlen(value);
518
0
    if (len > 6) {
519
0
        g_set_error(error,
520
0
                    FWUPD_ERROR,
521
0
                    FWUPD_ERROR_INVALID_DATA,
522
0
                    "string '%s' (0x%x bytes) does not fit in FuStructGenesysTsStatic.running_project_ic_type (0x%x bytes)",
523
0
                    value, (guint) len, (guint) 6);
524
0
        return FALSE;
525
0
    }
526
0
    return fu_memcpy_safe(st->data, st->len, 21, (const guint8 *)value, len, 0x0, len, error);
527
0
}
528
/**
529
 * fu_struct_genesys_ts_static_set_firmware_version: (skip):
530
 **/
531
gboolean
532
fu_struct_genesys_ts_static_set_firmware_version(FuStructGenesysTsStatic *st, const gchar *value, GError **error)
533
0
{
534
0
    gsize len;
535
0
    g_return_val_if_fail(st != NULL, FALSE);
536
0
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
537
0
    if (value == NULL) {
538
0
        memset(st->data + 27, 0x0, 4);
539
0
        return TRUE;
540
0
    }
541
0
    len = strlen(value);
542
0
    if (len > 4) {
543
0
        g_set_error(error,
544
0
                    FWUPD_ERROR,
545
0
                    FWUPD_ERROR_INVALID_DATA,
546
0
                    "string '%s' (0x%x bytes) does not fit in FuStructGenesysTsStatic.firmware_version (0x%x bytes)",
547
0
                    value, (guint) len, (guint) 4);
548
0
        return FALSE;
549
0
    }
550
0
    return fu_memcpy_safe(st->data, st->len, 27, (const guint8 *)value, len, 0x0, len, error);
551
0
}
552
/**
553
 * fu_struct_genesys_ts_static_new: (skip):
554
 **/
555
FuStructGenesysTsStatic *
556
fu_struct_genesys_ts_static_new(void)
557
0
{
558
0
    FuStructGenesysTsStatic *st = g_byte_array_sized_new(31);
559
0
    fu_byte_array_set_size(st, 31, 0x0);
560
0
    return st;
561
0
}
562
/**
563
 * fu_struct_genesys_ts_static_to_string: (skip):
564
 **/
565
static gchar *
566
fu_struct_genesys_ts_static_to_string(const FuStructGenesysTsStatic *st)
567
0
{
568
0
    g_autoptr(GString) str = g_string_new("FuStructGenesysTsStatic:\n");
569
0
    g_return_val_if_fail(st != NULL, NULL);
570
0
    {
571
0
        const gchar *tmp = fu_genesys_ts_version_to_string(fu_struct_genesys_ts_static_get_tool_string_version(st));
572
0
        if (tmp != NULL) {
573
0
            g_string_append_printf(str, "  tool_string_version: 0x%x [%s]\n", (guint) fu_struct_genesys_ts_static_get_tool_string_version(st), tmp);
574
0
        } else {
575
0
            g_string_append_printf(str, "  tool_string_version: 0x%x\n", (guint) fu_struct_genesys_ts_static_get_tool_string_version(st));
576
0
        }
577
0
    }
578
0
    {
579
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_static_get_mask_project_code(st);
580
0
        if (tmp != NULL)
581
0
            g_string_append_printf(str, "  mask_project_code: %s\n", tmp);
582
0
    }
583
0
    {
584
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_static_get_mask_project_hardware(st);
585
0
        if (tmp != NULL)
586
0
            g_string_append_printf(str, "  mask_project_hardware: %s\n", tmp);
587
0
    }
588
0
    {
589
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_static_get_mask_project_firmware(st);
590
0
        if (tmp != NULL)
591
0
            g_string_append_printf(str, "  mask_project_firmware: %s\n", tmp);
592
0
    }
593
0
    {
594
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_static_get_mask_project_ic_type(st);
595
0
        if (tmp != NULL)
596
0
            g_string_append_printf(str, "  mask_project_ic_type: %s\n", tmp);
597
0
    }
598
0
    {
599
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_static_get_running_project_code(st);
600
0
        if (tmp != NULL)
601
0
            g_string_append_printf(str, "  running_project_code: %s\n", tmp);
602
0
    }
603
0
    {
604
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_static_get_running_project_hardware(st);
605
0
        if (tmp != NULL)
606
0
            g_string_append_printf(str, "  running_project_hardware: %s\n", tmp);
607
0
    }
608
0
    {
609
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_static_get_running_project_firmware(st);
610
0
        if (tmp != NULL)
611
0
            g_string_append_printf(str, "  running_project_firmware: %s\n", tmp);
612
0
    }
613
0
    {
614
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_static_get_running_project_ic_type(st);
615
0
        if (tmp != NULL)
616
0
            g_string_append_printf(str, "  running_project_ic_type: %s\n", tmp);
617
0
    }
618
0
    {
619
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_static_get_firmware_version(st);
620
0
        if (tmp != NULL)
621
0
            g_string_append_printf(str, "  firmware_version: %s\n", tmp);
622
0
    }
623
0
    if (str->len > 0)
624
0
        g_string_set_size(str, str->len - 1);
625
0
    return g_string_free(g_steal_pointer(&str), FALSE);
626
0
}
627
static gboolean
628
fu_struct_genesys_ts_static_validate_internal(FuStructGenesysTsStatic *st, GError **error)
629
1.39k
{
630
1.39k
    g_return_val_if_fail(st != NULL, FALSE);
631
1.39k
    return TRUE;
632
1.39k
}
633
static gboolean
634
fu_struct_genesys_ts_static_parse_internal(FuStructGenesysTsStatic *st, GError **error)
635
1.39k
{
636
1.39k
    if (!fu_struct_genesys_ts_static_validate_internal(st, error))
637
0
        return FALSE;
638
1.39k
    if (g_getenv("FWUPD_VERBOSE") != NULL) {
639
0
        g_autofree gchar *str = fu_struct_genesys_ts_static_to_string(st);
640
0
        g_debug("%s", str);
641
0
    }
642
1.39k
    return TRUE;
643
1.39k
}
644
645
/**
646
 * fu_struct_genesys_ts_static_parse: (skip):
647
 **/
648
FuStructGenesysTsStatic *
649
fu_struct_genesys_ts_static_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
650
0
{
651
0
    g_autoptr(GByteArray) st = g_byte_array_new();
652
0
    g_return_val_if_fail(buf != NULL, NULL);
653
0
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
654
0
    if (!fu_memchk_read(bufsz, offset, 31, error)) {
655
0
        g_prefix_error(error, "invalid struct FuStructGenesysTsStatic: ");
656
0
        return NULL;
657
0
    }
658
0
    g_byte_array_append(st, buf + offset, 31);
659
0
    if (!fu_struct_genesys_ts_static_parse_internal(st, error))
660
0
        return NULL;
661
0
    return g_steal_pointer(&st);
662
0
}
663
/**
664
 * fu_struct_genesys_ts_static_parse_stream: (skip):
665
 **/
666
FuStructGenesysTsStatic *
667
fu_struct_genesys_ts_static_parse_stream(GInputStream *stream, gsize offset, GError **error)
668
1.53k
{
669
1.53k
    g_autoptr(GByteArray) st = NULL;
670
1.53k
    st = fu_input_stream_read_byte_array(stream, offset, 31, NULL, error);
671
1.53k
    if (st == NULL) {
672
0
        g_prefix_error(error, "FuStructGenesysTsStatic failed read of 0x%x: ", (guint) 31);
673
0
        return NULL;
674
0
    }
675
1.53k
    if (st->len != 31) {
676
139
        g_set_error(error,
677
139
                    FWUPD_ERROR,
678
139
                    FWUPD_ERROR_INVALID_DATA,
679
139
                    "FuStructGenesysTsStatic requested 0x%x and got 0x%x",
680
139
                    (guint) 31,
681
139
                    (guint) st->len);
682
139
        return NULL;
683
139
    }
684
1.39k
    if (!fu_struct_genesys_ts_static_parse_internal(st, error))
685
0
        return NULL;
686
1.39k
    return g_steal_pointer(&st);
687
1.39k
}
688
/* getters */
689
/**
690
 * fu_struct_genesys_ts_dynamic_gl3523_get_running_mode: (skip):
691
 **/
692
gchar *
693
fu_struct_genesys_ts_dynamic_gl3523_get_running_mode(const FuStructGenesysTsDynamicGl3523 *st)
694
0
{
695
0
    g_return_val_if_fail(st != NULL, NULL);
696
0
    return fu_memstrsafe(st->data, st->len, 0, 1, NULL);
697
0
}
698
/**
699
 * fu_struct_genesys_ts_dynamic_gl3523_get_ss_port_number: (skip):
700
 **/
701
gchar *
702
fu_struct_genesys_ts_dynamic_gl3523_get_ss_port_number(const FuStructGenesysTsDynamicGl3523 *st)
703
0
{
704
0
    g_return_val_if_fail(st != NULL, NULL);
705
0
    return fu_memstrsafe(st->data, st->len, 1, 1, NULL);
706
0
}
707
/**
708
 * fu_struct_genesys_ts_dynamic_gl3523_get_hs_port_number: (skip):
709
 **/
710
gchar *
711
fu_struct_genesys_ts_dynamic_gl3523_get_hs_port_number(const FuStructGenesysTsDynamicGl3523 *st)
712
0
{
713
0
    g_return_val_if_fail(st != NULL, NULL);
714
0
    return fu_memstrsafe(st->data, st->len, 2, 1, NULL);
715
0
}
716
/**
717
 * fu_struct_genesys_ts_dynamic_gl3523_get_ss_connection_status: (skip):
718
 **/
719
gchar *
720
fu_struct_genesys_ts_dynamic_gl3523_get_ss_connection_status(const FuStructGenesysTsDynamicGl3523 *st)
721
0
{
722
0
    g_return_val_if_fail(st != NULL, NULL);
723
0
    return fu_memstrsafe(st->data, st->len, 3, 1, NULL);
724
0
}
725
/**
726
 * fu_struct_genesys_ts_dynamic_gl3523_get_hs_connection_status: (skip):
727
 **/
728
gchar *
729
fu_struct_genesys_ts_dynamic_gl3523_get_hs_connection_status(const FuStructGenesysTsDynamicGl3523 *st)
730
0
{
731
0
    g_return_val_if_fail(st != NULL, NULL);
732
0
    return fu_memstrsafe(st->data, st->len, 4, 1, NULL);
733
0
}
734
/**
735
 * fu_struct_genesys_ts_dynamic_gl3523_get_fs_connection_status: (skip):
736
 **/
737
gchar *
738
fu_struct_genesys_ts_dynamic_gl3523_get_fs_connection_status(const FuStructGenesysTsDynamicGl3523 *st)
739
0
{
740
0
    g_return_val_if_fail(st != NULL, NULL);
741
0
    return fu_memstrsafe(st->data, st->len, 5, 1, NULL);
742
0
}
743
/**
744
 * fu_struct_genesys_ts_dynamic_gl3523_get_ls_connection_status: (skip):
745
 **/
746
gchar *
747
fu_struct_genesys_ts_dynamic_gl3523_get_ls_connection_status(const FuStructGenesysTsDynamicGl3523 *st)
748
0
{
749
0
    g_return_val_if_fail(st != NULL, NULL);
750
0
    return fu_memstrsafe(st->data, st->len, 6, 1, NULL);
751
0
}
752
/**
753
 * fu_struct_genesys_ts_dynamic_gl3523_get_charging: (skip):
754
 **/
755
gchar *
756
fu_struct_genesys_ts_dynamic_gl3523_get_charging(const FuStructGenesysTsDynamicGl3523 *st)
757
0
{
758
0
    g_return_val_if_fail(st != NULL, NULL);
759
0
    return fu_memstrsafe(st->data, st->len, 7, 1, NULL);
760
0
}
761
/**
762
 * fu_struct_genesys_ts_dynamic_gl3523_get_non_removable_port_status: (skip):
763
 **/
764
gchar *
765
fu_struct_genesys_ts_dynamic_gl3523_get_non_removable_port_status(const FuStructGenesysTsDynamicGl3523 *st)
766
0
{
767
0
    g_return_val_if_fail(st != NULL, NULL);
768
0
    return fu_memstrsafe(st->data, st->len, 8, 1, NULL);
769
0
}
770
/**
771
 * fu_struct_genesys_ts_dynamic_gl3523_get_bonding: (skip):
772
 **/
773
gchar *
774
fu_struct_genesys_ts_dynamic_gl3523_get_bonding(const FuStructGenesysTsDynamicGl3523 *st)
775
0
{
776
0
    g_return_val_if_fail(st != NULL, NULL);
777
0
    return fu_memstrsafe(st->data, st->len, 9, 1, NULL);
778
0
}
779
780
/* setters */
781
/**
782
 * fu_struct_genesys_ts_dynamic_gl3523_to_string: (skip):
783
 **/
784
static gchar *
785
fu_struct_genesys_ts_dynamic_gl3523_to_string(const FuStructGenesysTsDynamicGl3523 *st)
786
0
{
787
0
    g_autoptr(GString) str = g_string_new("FuStructGenesysTsDynamicGl3523:\n");
788
0
    g_return_val_if_fail(st != NULL, NULL);
789
0
    {
790
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3523_get_running_mode(st);
791
0
        if (tmp != NULL)
792
0
            g_string_append_printf(str, "  running_mode: %s\n", tmp);
793
0
    }
794
0
    {
795
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3523_get_ss_port_number(st);
796
0
        if (tmp != NULL)
797
0
            g_string_append_printf(str, "  ss_port_number: %s\n", tmp);
798
0
    }
799
0
    {
800
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3523_get_hs_port_number(st);
801
0
        if (tmp != NULL)
802
0
            g_string_append_printf(str, "  hs_port_number: %s\n", tmp);
803
0
    }
804
0
    {
805
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3523_get_ss_connection_status(st);
806
0
        if (tmp != NULL)
807
0
            g_string_append_printf(str, "  ss_connection_status: %s\n", tmp);
808
0
    }
809
0
    {
810
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3523_get_hs_connection_status(st);
811
0
        if (tmp != NULL)
812
0
            g_string_append_printf(str, "  hs_connection_status: %s\n", tmp);
813
0
    }
814
0
    {
815
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3523_get_fs_connection_status(st);
816
0
        if (tmp != NULL)
817
0
            g_string_append_printf(str, "  fs_connection_status: %s\n", tmp);
818
0
    }
819
0
    {
820
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3523_get_ls_connection_status(st);
821
0
        if (tmp != NULL)
822
0
            g_string_append_printf(str, "  ls_connection_status: %s\n", tmp);
823
0
    }
824
0
    {
825
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3523_get_charging(st);
826
0
        if (tmp != NULL)
827
0
            g_string_append_printf(str, "  charging: %s\n", tmp);
828
0
    }
829
0
    {
830
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3523_get_non_removable_port_status(st);
831
0
        if (tmp != NULL)
832
0
            g_string_append_printf(str, "  non_removable_port_status: %s\n", tmp);
833
0
    }
834
0
    {
835
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3523_get_bonding(st);
836
0
        if (tmp != NULL)
837
0
            g_string_append_printf(str, "  bonding: %s\n", tmp);
838
0
    }
839
0
    if (str->len > 0)
840
0
        g_string_set_size(str, str->len - 1);
841
0
    return g_string_free(g_steal_pointer(&str), FALSE);
842
0
}
843
static gboolean
844
fu_struct_genesys_ts_dynamic_gl3523_validate_internal(FuStructGenesysTsDynamicGl3523 *st, GError **error)
845
0
{
846
0
    g_return_val_if_fail(st != NULL, FALSE);
847
0
    return TRUE;
848
0
}
849
static gboolean
850
fu_struct_genesys_ts_dynamic_gl3523_parse_internal(FuStructGenesysTsDynamicGl3523 *st, GError **error)
851
0
{
852
0
    if (!fu_struct_genesys_ts_dynamic_gl3523_validate_internal(st, error))
853
0
        return FALSE;
854
0
    if (g_getenv("FWUPD_VERBOSE") != NULL) {
855
0
        g_autofree gchar *str = fu_struct_genesys_ts_dynamic_gl3523_to_string(st);
856
0
        g_debug("%s", str);
857
0
    }
858
0
    return TRUE;
859
0
}
860
861
/**
862
 * fu_struct_genesys_ts_dynamic_gl3523_parse: (skip):
863
 **/
864
FuStructGenesysTsDynamicGl3523 *
865
fu_struct_genesys_ts_dynamic_gl3523_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
866
0
{
867
0
    g_autoptr(GByteArray) st = g_byte_array_new();
868
0
    g_return_val_if_fail(buf != NULL, NULL);
869
0
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
870
0
    if (!fu_memchk_read(bufsz, offset, 10, error)) {
871
0
        g_prefix_error(error, "invalid struct FuStructGenesysTsDynamicGl3523: ");
872
0
        return NULL;
873
0
    }
874
0
    g_byte_array_append(st, buf + offset, 10);
875
0
    if (!fu_struct_genesys_ts_dynamic_gl3523_parse_internal(st, error))
876
0
        return NULL;
877
0
    return g_steal_pointer(&st);
878
0
}
879
/* getters */
880
/**
881
 * fu_struct_genesys_ts_dynamic_gl3590_get_running_mode: (skip):
882
 **/
883
gchar *
884
fu_struct_genesys_ts_dynamic_gl3590_get_running_mode(const FuStructGenesysTsDynamicGl3590 *st)
885
0
{
886
0
    g_return_val_if_fail(st != NULL, NULL);
887
0
    return fu_memstrsafe(st->data, st->len, 0, 1, NULL);
888
0
}
889
/**
890
 * fu_struct_genesys_ts_dynamic_gl3590_get_ss_port_number: (skip):
891
 **/
892
gchar *
893
fu_struct_genesys_ts_dynamic_gl3590_get_ss_port_number(const FuStructGenesysTsDynamicGl3590 *st)
894
0
{
895
0
    g_return_val_if_fail(st != NULL, NULL);
896
0
    return fu_memstrsafe(st->data, st->len, 1, 1, NULL);
897
0
}
898
/**
899
 * fu_struct_genesys_ts_dynamic_gl3590_get_hs_port_number: (skip):
900
 **/
901
gchar *
902
fu_struct_genesys_ts_dynamic_gl3590_get_hs_port_number(const FuStructGenesysTsDynamicGl3590 *st)
903
0
{
904
0
    g_return_val_if_fail(st != NULL, NULL);
905
0
    return fu_memstrsafe(st->data, st->len, 2, 1, NULL);
906
0
}
907
/**
908
 * fu_struct_genesys_ts_dynamic_gl3590_get_ss_connection_status: (skip):
909
 **/
910
gchar *
911
fu_struct_genesys_ts_dynamic_gl3590_get_ss_connection_status(const FuStructGenesysTsDynamicGl3590 *st)
912
0
{
913
0
    g_return_val_if_fail(st != NULL, NULL);
914
0
    return fu_memstrsafe(st->data, st->len, 3, 1, NULL);
915
0
}
916
/**
917
 * fu_struct_genesys_ts_dynamic_gl3590_get_hs_connection_status: (skip):
918
 **/
919
gchar *
920
fu_struct_genesys_ts_dynamic_gl3590_get_hs_connection_status(const FuStructGenesysTsDynamicGl3590 *st)
921
0
{
922
0
    g_return_val_if_fail(st != NULL, NULL);
923
0
    return fu_memstrsafe(st->data, st->len, 4, 1, NULL);
924
0
}
925
/**
926
 * fu_struct_genesys_ts_dynamic_gl3590_get_fs_connection_status: (skip):
927
 **/
928
gchar *
929
fu_struct_genesys_ts_dynamic_gl3590_get_fs_connection_status(const FuStructGenesysTsDynamicGl3590 *st)
930
0
{
931
0
    g_return_val_if_fail(st != NULL, NULL);
932
0
    return fu_memstrsafe(st->data, st->len, 5, 1, NULL);
933
0
}
934
/**
935
 * fu_struct_genesys_ts_dynamic_gl3590_get_ls_connection_status: (skip):
936
 **/
937
gchar *
938
fu_struct_genesys_ts_dynamic_gl3590_get_ls_connection_status(const FuStructGenesysTsDynamicGl3590 *st)
939
0
{
940
0
    g_return_val_if_fail(st != NULL, NULL);
941
0
    return fu_memstrsafe(st->data, st->len, 6, 1, NULL);
942
0
}
943
/**
944
 * fu_struct_genesys_ts_dynamic_gl3590_get_charging: (skip):
945
 **/
946
gchar *
947
fu_struct_genesys_ts_dynamic_gl3590_get_charging(const FuStructGenesysTsDynamicGl3590 *st)
948
0
{
949
0
    g_return_val_if_fail(st != NULL, NULL);
950
0
    return fu_memstrsafe(st->data, st->len, 7, 1, NULL);
951
0
}
952
/**
953
 * fu_struct_genesys_ts_dynamic_gl3590_get_non_removable_port_status: (skip):
954
 **/
955
gchar *
956
fu_struct_genesys_ts_dynamic_gl3590_get_non_removable_port_status(const FuStructGenesysTsDynamicGl3590 *st)
957
0
{
958
0
    g_return_val_if_fail(st != NULL, NULL);
959
0
    return fu_memstrsafe(st->data, st->len, 8, 1, NULL);
960
0
}
961
/**
962
 * fu_struct_genesys_ts_dynamic_gl3590_get_bonding: (skip):
963
 **/
964
guint8
965
fu_struct_genesys_ts_dynamic_gl3590_get_bonding(const FuStructGenesysTsDynamicGl3590 *st)
966
0
{
967
0
    g_return_val_if_fail(st != NULL, 0x0);
968
0
    return st->data[9];
969
0
}
970
971
/* setters */
972
/**
973
 * fu_struct_genesys_ts_dynamic_gl3590_to_string: (skip):
974
 **/
975
static gchar *
976
fu_struct_genesys_ts_dynamic_gl3590_to_string(const FuStructGenesysTsDynamicGl3590 *st)
977
0
{
978
0
    g_autoptr(GString) str = g_string_new("FuStructGenesysTsDynamicGl3590:\n");
979
0
    g_return_val_if_fail(st != NULL, NULL);
980
0
    {
981
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3590_get_running_mode(st);
982
0
        if (tmp != NULL)
983
0
            g_string_append_printf(str, "  running_mode: %s\n", tmp);
984
0
    }
985
0
    {
986
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3590_get_ss_port_number(st);
987
0
        if (tmp != NULL)
988
0
            g_string_append_printf(str, "  ss_port_number: %s\n", tmp);
989
0
    }
990
0
    {
991
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3590_get_hs_port_number(st);
992
0
        if (tmp != NULL)
993
0
            g_string_append_printf(str, "  hs_port_number: %s\n", tmp);
994
0
    }
995
0
    {
996
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3590_get_ss_connection_status(st);
997
0
        if (tmp != NULL)
998
0
            g_string_append_printf(str, "  ss_connection_status: %s\n", tmp);
999
0
    }
1000
0
    {
1001
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3590_get_hs_connection_status(st);
1002
0
        if (tmp != NULL)
1003
0
            g_string_append_printf(str, "  hs_connection_status: %s\n", tmp);
1004
0
    }
1005
0
    {
1006
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3590_get_fs_connection_status(st);
1007
0
        if (tmp != NULL)
1008
0
            g_string_append_printf(str, "  fs_connection_status: %s\n", tmp);
1009
0
    }
1010
0
    {
1011
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3590_get_ls_connection_status(st);
1012
0
        if (tmp != NULL)
1013
0
            g_string_append_printf(str, "  ls_connection_status: %s\n", tmp);
1014
0
    }
1015
0
    {
1016
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3590_get_charging(st);
1017
0
        if (tmp != NULL)
1018
0
            g_string_append_printf(str, "  charging: %s\n", tmp);
1019
0
    }
1020
0
    {
1021
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3590_get_non_removable_port_status(st);
1022
0
        if (tmp != NULL)
1023
0
            g_string_append_printf(str, "  non_removable_port_status: %s\n", tmp);
1024
0
    }
1025
0
    g_string_append_printf(str, "  bonding: 0x%x\n",
1026
0
                           (guint) fu_struct_genesys_ts_dynamic_gl3590_get_bonding(st));
1027
0
    if (str->len > 0)
1028
0
        g_string_set_size(str, str->len - 1);
1029
0
    return g_string_free(g_steal_pointer(&str), FALSE);
1030
0
}
1031
static gboolean
1032
fu_struct_genesys_ts_dynamic_gl3590_validate_internal(FuStructGenesysTsDynamicGl3590 *st, GError **error)
1033
0
{
1034
0
    g_return_val_if_fail(st != NULL, FALSE);
1035
0
    return TRUE;
1036
0
}
1037
static gboolean
1038
fu_struct_genesys_ts_dynamic_gl3590_parse_internal(FuStructGenesysTsDynamicGl3590 *st, GError **error)
1039
0
{
1040
0
    if (!fu_struct_genesys_ts_dynamic_gl3590_validate_internal(st, error))
1041
0
        return FALSE;
1042
0
    if (g_getenv("FWUPD_VERBOSE") != NULL) {
1043
0
        g_autofree gchar *str = fu_struct_genesys_ts_dynamic_gl3590_to_string(st);
1044
0
        g_debug("%s", str);
1045
0
    }
1046
0
    return TRUE;
1047
0
}
1048
1049
/**
1050
 * fu_struct_genesys_ts_dynamic_gl3590_parse: (skip):
1051
 **/
1052
FuStructGenesysTsDynamicGl3590 *
1053
fu_struct_genesys_ts_dynamic_gl3590_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
1054
0
{
1055
0
    g_autoptr(GByteArray) st = g_byte_array_new();
1056
0
    g_return_val_if_fail(buf != NULL, NULL);
1057
0
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
1058
0
    if (!fu_memchk_read(bufsz, offset, 10, error)) {
1059
0
        g_prefix_error(error, "invalid struct FuStructGenesysTsDynamicGl3590: ");
1060
0
        return NULL;
1061
0
    }
1062
0
    g_byte_array_append(st, buf + offset, 10);
1063
0
    if (!fu_struct_genesys_ts_dynamic_gl3590_parse_internal(st, error))
1064
0
        return NULL;
1065
0
    return g_steal_pointer(&st);
1066
0
}
1067
/* getters */
1068
/**
1069
 * fu_struct_genesys_ts_dynamic_gl359030_get_running_mode: (skip):
1070
 **/
1071
gchar *
1072
fu_struct_genesys_ts_dynamic_gl359030_get_running_mode(const FuStructGenesysTsDynamicGl359030 *st)
1073
0
{
1074
0
    g_return_val_if_fail(st != NULL, NULL);
1075
0
    return fu_memstrsafe(st->data, st->len, 0, 1, NULL);
1076
0
}
1077
/**
1078
 * fu_struct_genesys_ts_dynamic_gl359030_get_ss_port_number: (skip):
1079
 **/
1080
gchar *
1081
fu_struct_genesys_ts_dynamic_gl359030_get_ss_port_number(const FuStructGenesysTsDynamicGl359030 *st)
1082
0
{
1083
0
    g_return_val_if_fail(st != NULL, NULL);
1084
0
    return fu_memstrsafe(st->data, st->len, 1, 1, NULL);
1085
0
}
1086
/**
1087
 * fu_struct_genesys_ts_dynamic_gl359030_get_hs_port_number: (skip):
1088
 **/
1089
gchar *
1090
fu_struct_genesys_ts_dynamic_gl359030_get_hs_port_number(const FuStructGenesysTsDynamicGl359030 *st)
1091
0
{
1092
0
    g_return_val_if_fail(st != NULL, NULL);
1093
0
    return fu_memstrsafe(st->data, st->len, 2, 1, NULL);
1094
0
}
1095
/**
1096
 * fu_struct_genesys_ts_dynamic_gl359030_get_ss_connection_status: (skip):
1097
 **/
1098
gchar *
1099
fu_struct_genesys_ts_dynamic_gl359030_get_ss_connection_status(const FuStructGenesysTsDynamicGl359030 *st)
1100
0
{
1101
0
    g_return_val_if_fail(st != NULL, NULL);
1102
0
    return fu_memstrsafe(st->data, st->len, 3, 1, NULL);
1103
0
}
1104
/**
1105
 * fu_struct_genesys_ts_dynamic_gl359030_get_hs_connection_status: (skip):
1106
 **/
1107
gchar *
1108
fu_struct_genesys_ts_dynamic_gl359030_get_hs_connection_status(const FuStructGenesysTsDynamicGl359030 *st)
1109
0
{
1110
0
    g_return_val_if_fail(st != NULL, NULL);
1111
0
    return fu_memstrsafe(st->data, st->len, 4, 1, NULL);
1112
0
}
1113
/**
1114
 * fu_struct_genesys_ts_dynamic_gl359030_get_fs_connection_status: (skip):
1115
 **/
1116
gchar *
1117
fu_struct_genesys_ts_dynamic_gl359030_get_fs_connection_status(const FuStructGenesysTsDynamicGl359030 *st)
1118
0
{
1119
0
    g_return_val_if_fail(st != NULL, NULL);
1120
0
    return fu_memstrsafe(st->data, st->len, 5, 1, NULL);
1121
0
}
1122
/**
1123
 * fu_struct_genesys_ts_dynamic_gl359030_get_ls_connection_status: (skip):
1124
 **/
1125
gchar *
1126
fu_struct_genesys_ts_dynamic_gl359030_get_ls_connection_status(const FuStructGenesysTsDynamicGl359030 *st)
1127
0
{
1128
0
    g_return_val_if_fail(st != NULL, NULL);
1129
0
    return fu_memstrsafe(st->data, st->len, 6, 1, NULL);
1130
0
}
1131
/**
1132
 * fu_struct_genesys_ts_dynamic_gl359030_get_charging: (skip):
1133
 **/
1134
gchar *
1135
fu_struct_genesys_ts_dynamic_gl359030_get_charging(const FuStructGenesysTsDynamicGl359030 *st)
1136
0
{
1137
0
    g_return_val_if_fail(st != NULL, NULL);
1138
0
    return fu_memstrsafe(st->data, st->len, 7, 1, NULL);
1139
0
}
1140
/**
1141
 * fu_struct_genesys_ts_dynamic_gl359030_get_non_removable_port_status: (skip):
1142
 **/
1143
gchar *
1144
fu_struct_genesys_ts_dynamic_gl359030_get_non_removable_port_status(const FuStructGenesysTsDynamicGl359030 *st)
1145
0
{
1146
0
    g_return_val_if_fail(st != NULL, NULL);
1147
0
    return fu_memstrsafe(st->data, st->len, 8, 1, NULL);
1148
0
}
1149
/**
1150
 * fu_struct_genesys_ts_dynamic_gl359030_get_bonding: (skip):
1151
 **/
1152
guint8
1153
fu_struct_genesys_ts_dynamic_gl359030_get_bonding(const FuStructGenesysTsDynamicGl359030 *st)
1154
0
{
1155
0
    g_return_val_if_fail(st != NULL, 0x0);
1156
0
    return st->data[9];
1157
0
}
1158
/**
1159
 * fu_struct_genesys_ts_dynamic_gl359030_get_hub_fw_status: (skip):
1160
 **/
1161
FuGenesysFwStatus
1162
fu_struct_genesys_ts_dynamic_gl359030_get_hub_fw_status(const FuStructGenesysTsDynamicGl359030 *st)
1163
0
{
1164
0
    g_return_val_if_fail(st != NULL, 0x0);
1165
0
    return st->data[10];
1166
0
}
1167
/**
1168
 * fu_struct_genesys_ts_dynamic_gl359030_get_dev_fw_status: (skip):
1169
 **/
1170
FuGenesysFwStatus
1171
fu_struct_genesys_ts_dynamic_gl359030_get_dev_fw_status(const FuStructGenesysTsDynamicGl359030 *st)
1172
0
{
1173
0
    g_return_val_if_fail(st != NULL, 0x0);
1174
0
    return st->data[11];
1175
0
}
1176
/**
1177
 * fu_struct_genesys_ts_dynamic_gl359030_get_dev_fw_version: (skip):
1178
 **/
1179
guint16
1180
fu_struct_genesys_ts_dynamic_gl359030_get_dev_fw_version(const FuStructGenesysTsDynamicGl359030 *st)
1181
0
{
1182
0
    g_return_val_if_fail(st != NULL, 0x0);
1183
0
    return fu_memread_uint16(st->data + 12, G_LITTLE_ENDIAN);
1184
0
}
1185
1186
/* setters */
1187
/**
1188
 * fu_struct_genesys_ts_dynamic_gl359030_to_string: (skip):
1189
 **/
1190
static gchar *
1191
fu_struct_genesys_ts_dynamic_gl359030_to_string(const FuStructGenesysTsDynamicGl359030 *st)
1192
0
{
1193
0
    g_autoptr(GString) str = g_string_new("FuStructGenesysTsDynamicGl359030:\n");
1194
0
    g_return_val_if_fail(st != NULL, NULL);
1195
0
    {
1196
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl359030_get_running_mode(st);
1197
0
        if (tmp != NULL)
1198
0
            g_string_append_printf(str, "  running_mode: %s\n", tmp);
1199
0
    }
1200
0
    {
1201
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl359030_get_ss_port_number(st);
1202
0
        if (tmp != NULL)
1203
0
            g_string_append_printf(str, "  ss_port_number: %s\n", tmp);
1204
0
    }
1205
0
    {
1206
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl359030_get_hs_port_number(st);
1207
0
        if (tmp != NULL)
1208
0
            g_string_append_printf(str, "  hs_port_number: %s\n", tmp);
1209
0
    }
1210
0
    {
1211
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl359030_get_ss_connection_status(st);
1212
0
        if (tmp != NULL)
1213
0
            g_string_append_printf(str, "  ss_connection_status: %s\n", tmp);
1214
0
    }
1215
0
    {
1216
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl359030_get_hs_connection_status(st);
1217
0
        if (tmp != NULL)
1218
0
            g_string_append_printf(str, "  hs_connection_status: %s\n", tmp);
1219
0
    }
1220
0
    {
1221
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl359030_get_fs_connection_status(st);
1222
0
        if (tmp != NULL)
1223
0
            g_string_append_printf(str, "  fs_connection_status: %s\n", tmp);
1224
0
    }
1225
0
    {
1226
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl359030_get_ls_connection_status(st);
1227
0
        if (tmp != NULL)
1228
0
            g_string_append_printf(str, "  ls_connection_status: %s\n", tmp);
1229
0
    }
1230
0
    {
1231
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl359030_get_charging(st);
1232
0
        if (tmp != NULL)
1233
0
            g_string_append_printf(str, "  charging: %s\n", tmp);
1234
0
    }
1235
0
    {
1236
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl359030_get_non_removable_port_status(st);
1237
0
        if (tmp != NULL)
1238
0
            g_string_append_printf(str, "  non_removable_port_status: %s\n", tmp);
1239
0
    }
1240
0
    g_string_append_printf(str, "  bonding: 0x%x\n",
1241
0
                           (guint) fu_struct_genesys_ts_dynamic_gl359030_get_bonding(st));
1242
0
    {
1243
0
        const gchar *tmp = fu_genesys_fw_status_to_string(fu_struct_genesys_ts_dynamic_gl359030_get_hub_fw_status(st));
1244
0
        if (tmp != NULL) {
1245
0
            g_string_append_printf(str, "  hub_fw_status: 0x%x [%s]\n", (guint) fu_struct_genesys_ts_dynamic_gl359030_get_hub_fw_status(st), tmp);
1246
0
        } else {
1247
0
            g_string_append_printf(str, "  hub_fw_status: 0x%x\n", (guint) fu_struct_genesys_ts_dynamic_gl359030_get_hub_fw_status(st));
1248
0
        }
1249
0
    }
1250
0
    {
1251
0
        const gchar *tmp = fu_genesys_fw_status_to_string(fu_struct_genesys_ts_dynamic_gl359030_get_dev_fw_status(st));
1252
0
        if (tmp != NULL) {
1253
0
            g_string_append_printf(str, "  dev_fw_status: 0x%x [%s]\n", (guint) fu_struct_genesys_ts_dynamic_gl359030_get_dev_fw_status(st), tmp);
1254
0
        } else {
1255
0
            g_string_append_printf(str, "  dev_fw_status: 0x%x\n", (guint) fu_struct_genesys_ts_dynamic_gl359030_get_dev_fw_status(st));
1256
0
        }
1257
0
    }
1258
0
    g_string_append_printf(str, "  dev_fw_version: 0x%x\n",
1259
0
                           (guint) fu_struct_genesys_ts_dynamic_gl359030_get_dev_fw_version(st));
1260
0
    if (str->len > 0)
1261
0
        g_string_set_size(str, str->len - 1);
1262
0
    return g_string_free(g_steal_pointer(&str), FALSE);
1263
0
}
1264
static gboolean
1265
fu_struct_genesys_ts_dynamic_gl359030_validate_internal(FuStructGenesysTsDynamicGl359030 *st, GError **error)
1266
0
{
1267
0
    g_return_val_if_fail(st != NULL, FALSE);
1268
0
    return TRUE;
1269
0
}
1270
static gboolean
1271
fu_struct_genesys_ts_dynamic_gl359030_parse_internal(FuStructGenesysTsDynamicGl359030 *st, GError **error)
1272
0
{
1273
0
    if (!fu_struct_genesys_ts_dynamic_gl359030_validate_internal(st, error))
1274
0
        return FALSE;
1275
0
    if (g_getenv("FWUPD_VERBOSE") != NULL) {
1276
0
        g_autofree gchar *str = fu_struct_genesys_ts_dynamic_gl359030_to_string(st);
1277
0
        g_debug("%s", str);
1278
0
    }
1279
0
    return TRUE;
1280
0
}
1281
1282
/**
1283
 * fu_struct_genesys_ts_dynamic_gl359030_parse: (skip):
1284
 **/
1285
FuStructGenesysTsDynamicGl359030 *
1286
fu_struct_genesys_ts_dynamic_gl359030_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
1287
0
{
1288
0
    g_autoptr(GByteArray) st = g_byte_array_new();
1289
0
    g_return_val_if_fail(buf != NULL, NULL);
1290
0
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
1291
0
    if (!fu_memchk_read(bufsz, offset, 14, error)) {
1292
0
        g_prefix_error(error, "invalid struct FuStructGenesysTsDynamicGl359030: ");
1293
0
        return NULL;
1294
0
    }
1295
0
    g_byte_array_append(st, buf + offset, 14);
1296
0
    if (!fu_struct_genesys_ts_dynamic_gl359030_parse_internal(st, error))
1297
0
        return NULL;
1298
0
    return g_steal_pointer(&st);
1299
0
}
1300
/* getters */
1301
/**
1302
 * fu_struct_genesys_ts_dynamic_gl3525_get_running_mode: (skip):
1303
 **/
1304
gchar *
1305
fu_struct_genesys_ts_dynamic_gl3525_get_running_mode(const FuStructGenesysTsDynamicGl3525 *st)
1306
0
{
1307
0
    g_return_val_if_fail(st != NULL, NULL);
1308
0
    return fu_memstrsafe(st->data, st->len, 0, 1, NULL);
1309
0
}
1310
/**
1311
 * fu_struct_genesys_ts_dynamic_gl3525_get_ss_port_number: (skip):
1312
 **/
1313
gchar *
1314
fu_struct_genesys_ts_dynamic_gl3525_get_ss_port_number(const FuStructGenesysTsDynamicGl3525 *st)
1315
0
{
1316
0
    g_return_val_if_fail(st != NULL, NULL);
1317
0
    return fu_memstrsafe(st->data, st->len, 1, 1, NULL);
1318
0
}
1319
/**
1320
 * fu_struct_genesys_ts_dynamic_gl3525_get_hs_port_number: (skip):
1321
 **/
1322
gchar *
1323
fu_struct_genesys_ts_dynamic_gl3525_get_hs_port_number(const FuStructGenesysTsDynamicGl3525 *st)
1324
0
{
1325
0
    g_return_val_if_fail(st != NULL, NULL);
1326
0
    return fu_memstrsafe(st->data, st->len, 2, 1, NULL);
1327
0
}
1328
/**
1329
 * fu_struct_genesys_ts_dynamic_gl3525_get_ss_connection_status: (skip):
1330
 **/
1331
gchar *
1332
fu_struct_genesys_ts_dynamic_gl3525_get_ss_connection_status(const FuStructGenesysTsDynamicGl3525 *st)
1333
0
{
1334
0
    g_return_val_if_fail(st != NULL, NULL);
1335
0
    return fu_memstrsafe(st->data, st->len, 3, 1, NULL);
1336
0
}
1337
/**
1338
 * fu_struct_genesys_ts_dynamic_gl3525_get_hs_connection_status: (skip):
1339
 **/
1340
gchar *
1341
fu_struct_genesys_ts_dynamic_gl3525_get_hs_connection_status(const FuStructGenesysTsDynamicGl3525 *st)
1342
0
{
1343
0
    g_return_val_if_fail(st != NULL, NULL);
1344
0
    return fu_memstrsafe(st->data, st->len, 4, 1, NULL);
1345
0
}
1346
/**
1347
 * fu_struct_genesys_ts_dynamic_gl3525_get_fs_connection_status: (skip):
1348
 **/
1349
gchar *
1350
fu_struct_genesys_ts_dynamic_gl3525_get_fs_connection_status(const FuStructGenesysTsDynamicGl3525 *st)
1351
0
{
1352
0
    g_return_val_if_fail(st != NULL, NULL);
1353
0
    return fu_memstrsafe(st->data, st->len, 5, 1, NULL);
1354
0
}
1355
/**
1356
 * fu_struct_genesys_ts_dynamic_gl3525_get_ls_connection_status: (skip):
1357
 **/
1358
gchar *
1359
fu_struct_genesys_ts_dynamic_gl3525_get_ls_connection_status(const FuStructGenesysTsDynamicGl3525 *st)
1360
0
{
1361
0
    g_return_val_if_fail(st != NULL, NULL);
1362
0
    return fu_memstrsafe(st->data, st->len, 6, 1, NULL);
1363
0
}
1364
/**
1365
 * fu_struct_genesys_ts_dynamic_gl3525_get_charging: (skip):
1366
 **/
1367
gchar *
1368
fu_struct_genesys_ts_dynamic_gl3525_get_charging(const FuStructGenesysTsDynamicGl3525 *st)
1369
0
{
1370
0
    g_return_val_if_fail(st != NULL, NULL);
1371
0
    return fu_memstrsafe(st->data, st->len, 7, 1, NULL);
1372
0
}
1373
/**
1374
 * fu_struct_genesys_ts_dynamic_gl3525_get_non_removable_port_status: (skip):
1375
 **/
1376
gchar *
1377
fu_struct_genesys_ts_dynamic_gl3525_get_non_removable_port_status(const FuStructGenesysTsDynamicGl3525 *st)
1378
0
{
1379
0
    g_return_val_if_fail(st != NULL, NULL);
1380
0
    return fu_memstrsafe(st->data, st->len, 8, 1, NULL);
1381
0
}
1382
/**
1383
 * fu_struct_genesys_ts_dynamic_gl3525_get_bonding: (skip):
1384
 **/
1385
guint8
1386
fu_struct_genesys_ts_dynamic_gl3525_get_bonding(const FuStructGenesysTsDynamicGl3525 *st)
1387
0
{
1388
0
    g_return_val_if_fail(st != NULL, 0x0);
1389
0
    return st->data[9];
1390
0
}
1391
/**
1392
 * fu_struct_genesys_ts_dynamic_gl3525_get_hub_fw_status: (skip):
1393
 **/
1394
FuGenesysFwStatus
1395
fu_struct_genesys_ts_dynamic_gl3525_get_hub_fw_status(const FuStructGenesysTsDynamicGl3525 *st)
1396
0
{
1397
0
    g_return_val_if_fail(st != NULL, 0x0);
1398
0
    return st->data[10];
1399
0
}
1400
/**
1401
 * fu_struct_genesys_ts_dynamic_gl3525_get_pd_fw_status: (skip):
1402
 **/
1403
FuGenesysFwStatus
1404
fu_struct_genesys_ts_dynamic_gl3525_get_pd_fw_status(const FuStructGenesysTsDynamicGl3525 *st)
1405
0
{
1406
0
    g_return_val_if_fail(st != NULL, 0x0);
1407
0
    return st->data[11];
1408
0
}
1409
/**
1410
 * fu_struct_genesys_ts_dynamic_gl3525_get_pd_fw_version: (skip):
1411
 **/
1412
guint16
1413
fu_struct_genesys_ts_dynamic_gl3525_get_pd_fw_version(const FuStructGenesysTsDynamicGl3525 *st)
1414
0
{
1415
0
    g_return_val_if_fail(st != NULL, 0x0);
1416
0
    return fu_memread_uint16(st->data + 12, G_LITTLE_ENDIAN);
1417
0
}
1418
/**
1419
 * fu_struct_genesys_ts_dynamic_gl3525_get_dev_fw_status: (skip):
1420
 **/
1421
FuGenesysFwStatus
1422
fu_struct_genesys_ts_dynamic_gl3525_get_dev_fw_status(const FuStructGenesysTsDynamicGl3525 *st)
1423
0
{
1424
0
    g_return_val_if_fail(st != NULL, 0x0);
1425
0
    return st->data[14];
1426
0
}
1427
/**
1428
 * fu_struct_genesys_ts_dynamic_gl3525_get_dev_fw_version: (skip):
1429
 **/
1430
guint16
1431
fu_struct_genesys_ts_dynamic_gl3525_get_dev_fw_version(const FuStructGenesysTsDynamicGl3525 *st)
1432
0
{
1433
0
    g_return_val_if_fail(st != NULL, 0x0);
1434
0
    return fu_memread_uint16(st->data + 15, G_LITTLE_ENDIAN);
1435
0
}
1436
1437
/* setters */
1438
/**
1439
 * fu_struct_genesys_ts_dynamic_gl3525_to_string: (skip):
1440
 **/
1441
static gchar *
1442
fu_struct_genesys_ts_dynamic_gl3525_to_string(const FuStructGenesysTsDynamicGl3525 *st)
1443
0
{
1444
0
    g_autoptr(GString) str = g_string_new("FuStructGenesysTsDynamicGl3525:\n");
1445
0
    g_return_val_if_fail(st != NULL, NULL);
1446
0
    {
1447
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3525_get_running_mode(st);
1448
0
        if (tmp != NULL)
1449
0
            g_string_append_printf(str, "  running_mode: %s\n", tmp);
1450
0
    }
1451
0
    {
1452
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3525_get_ss_port_number(st);
1453
0
        if (tmp != NULL)
1454
0
            g_string_append_printf(str, "  ss_port_number: %s\n", tmp);
1455
0
    }
1456
0
    {
1457
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3525_get_hs_port_number(st);
1458
0
        if (tmp != NULL)
1459
0
            g_string_append_printf(str, "  hs_port_number: %s\n", tmp);
1460
0
    }
1461
0
    {
1462
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3525_get_ss_connection_status(st);
1463
0
        if (tmp != NULL)
1464
0
            g_string_append_printf(str, "  ss_connection_status: %s\n", tmp);
1465
0
    }
1466
0
    {
1467
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3525_get_hs_connection_status(st);
1468
0
        if (tmp != NULL)
1469
0
            g_string_append_printf(str, "  hs_connection_status: %s\n", tmp);
1470
0
    }
1471
0
    {
1472
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3525_get_fs_connection_status(st);
1473
0
        if (tmp != NULL)
1474
0
            g_string_append_printf(str, "  fs_connection_status: %s\n", tmp);
1475
0
    }
1476
0
    {
1477
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3525_get_ls_connection_status(st);
1478
0
        if (tmp != NULL)
1479
0
            g_string_append_printf(str, "  ls_connection_status: %s\n", tmp);
1480
0
    }
1481
0
    {
1482
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3525_get_charging(st);
1483
0
        if (tmp != NULL)
1484
0
            g_string_append_printf(str, "  charging: %s\n", tmp);
1485
0
    }
1486
0
    {
1487
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3525_get_non_removable_port_status(st);
1488
0
        if (tmp != NULL)
1489
0
            g_string_append_printf(str, "  non_removable_port_status: %s\n", tmp);
1490
0
    }
1491
0
    g_string_append_printf(str, "  bonding: 0x%x\n",
1492
0
                           (guint) fu_struct_genesys_ts_dynamic_gl3525_get_bonding(st));
1493
0
    {
1494
0
        const gchar *tmp = fu_genesys_fw_status_to_string(fu_struct_genesys_ts_dynamic_gl3525_get_hub_fw_status(st));
1495
0
        if (tmp != NULL) {
1496
0
            g_string_append_printf(str, "  hub_fw_status: 0x%x [%s]\n", (guint) fu_struct_genesys_ts_dynamic_gl3525_get_hub_fw_status(st), tmp);
1497
0
        } else {
1498
0
            g_string_append_printf(str, "  hub_fw_status: 0x%x\n", (guint) fu_struct_genesys_ts_dynamic_gl3525_get_hub_fw_status(st));
1499
0
        }
1500
0
    }
1501
0
    {
1502
0
        const gchar *tmp = fu_genesys_fw_status_to_string(fu_struct_genesys_ts_dynamic_gl3525_get_pd_fw_status(st));
1503
0
        if (tmp != NULL) {
1504
0
            g_string_append_printf(str, "  pd_fw_status: 0x%x [%s]\n", (guint) fu_struct_genesys_ts_dynamic_gl3525_get_pd_fw_status(st), tmp);
1505
0
        } else {
1506
0
            g_string_append_printf(str, "  pd_fw_status: 0x%x\n", (guint) fu_struct_genesys_ts_dynamic_gl3525_get_pd_fw_status(st));
1507
0
        }
1508
0
    }
1509
0
    g_string_append_printf(str, "  pd_fw_version: 0x%x\n",
1510
0
                           (guint) fu_struct_genesys_ts_dynamic_gl3525_get_pd_fw_version(st));
1511
0
    {
1512
0
        const gchar *tmp = fu_genesys_fw_status_to_string(fu_struct_genesys_ts_dynamic_gl3525_get_dev_fw_status(st));
1513
0
        if (tmp != NULL) {
1514
0
            g_string_append_printf(str, "  dev_fw_status: 0x%x [%s]\n", (guint) fu_struct_genesys_ts_dynamic_gl3525_get_dev_fw_status(st), tmp);
1515
0
        } else {
1516
0
            g_string_append_printf(str, "  dev_fw_status: 0x%x\n", (guint) fu_struct_genesys_ts_dynamic_gl3525_get_dev_fw_status(st));
1517
0
        }
1518
0
    }
1519
0
    g_string_append_printf(str, "  dev_fw_version: 0x%x\n",
1520
0
                           (guint) fu_struct_genesys_ts_dynamic_gl3525_get_dev_fw_version(st));
1521
0
    if (str->len > 0)
1522
0
        g_string_set_size(str, str->len - 1);
1523
0
    return g_string_free(g_steal_pointer(&str), FALSE);
1524
0
}
1525
static gboolean
1526
fu_struct_genesys_ts_dynamic_gl3525_validate_internal(FuStructGenesysTsDynamicGl3525 *st, GError **error)
1527
0
{
1528
0
    g_return_val_if_fail(st != NULL, FALSE);
1529
0
    return TRUE;
1530
0
}
1531
static gboolean
1532
fu_struct_genesys_ts_dynamic_gl3525_parse_internal(FuStructGenesysTsDynamicGl3525 *st, GError **error)
1533
0
{
1534
0
    if (!fu_struct_genesys_ts_dynamic_gl3525_validate_internal(st, error))
1535
0
        return FALSE;
1536
0
    if (g_getenv("FWUPD_VERBOSE") != NULL) {
1537
0
        g_autofree gchar *str = fu_struct_genesys_ts_dynamic_gl3525_to_string(st);
1538
0
        g_debug("%s", str);
1539
0
    }
1540
0
    return TRUE;
1541
0
}
1542
1543
/**
1544
 * fu_struct_genesys_ts_dynamic_gl3525_parse: (skip):
1545
 **/
1546
FuStructGenesysTsDynamicGl3525 *
1547
fu_struct_genesys_ts_dynamic_gl3525_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
1548
0
{
1549
0
    g_autoptr(GByteArray) st = g_byte_array_new();
1550
0
    g_return_val_if_fail(buf != NULL, NULL);
1551
0
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
1552
0
    if (!fu_memchk_read(bufsz, offset, 17, error)) {
1553
0
        g_prefix_error(error, "invalid struct FuStructGenesysTsDynamicGl3525: ");
1554
0
        return NULL;
1555
0
    }
1556
0
    g_byte_array_append(st, buf + offset, 17);
1557
0
    if (!fu_struct_genesys_ts_dynamic_gl3525_parse_internal(st, error))
1558
0
        return NULL;
1559
0
    return g_steal_pointer(&st);
1560
0
}
1561
/* getters */
1562
/**
1563
 * fu_struct_genesys_ts_firmware_info_get_tool_version: (skip):
1564
 **/
1565
const guint8 *
1566
fu_struct_genesys_ts_firmware_info_get_tool_version(const FuStructGenesysTsFirmwareInfo *st, gsize *bufsz)
1567
0
{
1568
0
    g_return_val_if_fail(st != NULL, NULL);
1569
0
    if (bufsz != NULL)
1570
0
        *bufsz = 6;
1571
0
    return st->data + 0;
1572
0
}
1573
/**
1574
 * fu_struct_genesys_ts_firmware_info_get_address_mode: (skip):
1575
 **/
1576
guint8
1577
fu_struct_genesys_ts_firmware_info_get_address_mode(const FuStructGenesysTsFirmwareInfo *st)
1578
0
{
1579
0
    g_return_val_if_fail(st != NULL, 0x0);
1580
0
    return st->data[6];
1581
0
}
1582
/**
1583
 * fu_struct_genesys_ts_firmware_info_get_build_fw_time: (skip):
1584
 **/
1585
gchar *
1586
fu_struct_genesys_ts_firmware_info_get_build_fw_time(const FuStructGenesysTsFirmwareInfo *st)
1587
0
{
1588
0
    g_return_val_if_fail(st != NULL, NULL);
1589
0
    return fu_memstrsafe(st->data, st->len, 7, 12, NULL);
1590
0
}
1591
/**
1592
 * fu_struct_genesys_ts_firmware_info_get_update_fw_time: (skip):
1593
 **/
1594
gchar *
1595
fu_struct_genesys_ts_firmware_info_get_update_fw_time(const FuStructGenesysTsFirmwareInfo *st)
1596
0
{
1597
0
    g_return_val_if_fail(st != NULL, NULL);
1598
0
    return fu_memstrsafe(st->data, st->len, 19, 12, NULL);
1599
0
}
1600
1601
/* setters */
1602
/**
1603
 * fu_struct_genesys_ts_firmware_info_to_string: (skip):
1604
 **/
1605
static gchar *
1606
fu_struct_genesys_ts_firmware_info_to_string(const FuStructGenesysTsFirmwareInfo *st)
1607
0
{
1608
0
    g_autoptr(GString) str = g_string_new("FuStructGenesysTsFirmwareInfo:\n");
1609
0
    g_return_val_if_fail(st != NULL, NULL);
1610
0
    {
1611
0
        gsize bufsz = 0;
1612
0
        const guint8 *buf = fu_struct_genesys_ts_firmware_info_get_tool_version(st, &bufsz);
1613
0
        g_autoptr(GString) tmp = g_string_new(NULL);
1614
0
        for (gsize i = 0; i < bufsz; i++)
1615
0
            g_string_append_printf(tmp, "%02X", buf[i]);
1616
0
        g_string_append_printf(str, "  tool_version: 0x%s\n", tmp->str);
1617
0
    }
1618
0
    g_string_append_printf(str, "  address_mode: 0x%x\n",
1619
0
                           (guint) fu_struct_genesys_ts_firmware_info_get_address_mode(st));
1620
0
    {
1621
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_firmware_info_get_build_fw_time(st);
1622
0
        if (tmp != NULL)
1623
0
            g_string_append_printf(str, "  build_fw_time: %s\n", tmp);
1624
0
    }
1625
0
    {
1626
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_firmware_info_get_update_fw_time(st);
1627
0
        if (tmp != NULL)
1628
0
            g_string_append_printf(str, "  update_fw_time: %s\n", tmp);
1629
0
    }
1630
0
    if (str->len > 0)
1631
0
        g_string_set_size(str, str->len - 1);
1632
0
    return g_string_free(g_steal_pointer(&str), FALSE);
1633
0
}
1634
static gboolean
1635
fu_struct_genesys_ts_firmware_info_validate_internal(FuStructGenesysTsFirmwareInfo *st, GError **error)
1636
0
{
1637
0
    g_return_val_if_fail(st != NULL, FALSE);
1638
0
    return TRUE;
1639
0
}
1640
static gboolean
1641
fu_struct_genesys_ts_firmware_info_parse_internal(FuStructGenesysTsFirmwareInfo *st, GError **error)
1642
0
{
1643
0
    if (!fu_struct_genesys_ts_firmware_info_validate_internal(st, error))
1644
0
        return FALSE;
1645
0
    if (g_getenv("FWUPD_VERBOSE") != NULL) {
1646
0
        g_autofree gchar *str = fu_struct_genesys_ts_firmware_info_to_string(st);
1647
0
        g_debug("%s", str);
1648
0
    }
1649
0
    return TRUE;
1650
0
}
1651
1652
/**
1653
 * fu_struct_genesys_ts_firmware_info_parse: (skip):
1654
 **/
1655
FuStructGenesysTsFirmwareInfo *
1656
fu_struct_genesys_ts_firmware_info_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
1657
0
{
1658
0
    g_autoptr(GByteArray) st = g_byte_array_new();
1659
0
    g_return_val_if_fail(buf != NULL, NULL);
1660
0
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
1661
0
    if (!fu_memchk_read(bufsz, offset, 31, error)) {
1662
0
        g_prefix_error(error, "invalid struct FuStructGenesysTsFirmwareInfo: ");
1663
0
        return NULL;
1664
0
    }
1665
0
    g_byte_array_append(st, buf + offset, 31);
1666
0
    if (!fu_struct_genesys_ts_firmware_info_parse_internal(st, error))
1667
0
        return NULL;
1668
0
    return g_steal_pointer(&st);
1669
0
}
1670
/* getters */
1671
/**
1672
 * fu_struct_genesys_ts_vendor_support_get_version: (skip):
1673
 **/
1674
gchar *
1675
fu_struct_genesys_ts_vendor_support_get_version(const FuStructGenesysTsVendorSupport *st)
1676
0
{
1677
0
    g_return_val_if_fail(st != NULL, NULL);
1678
0
    return fu_memstrsafe(st->data, st->len, 0, 2, NULL);
1679
0
}
1680
/**
1681
 * fu_struct_genesys_ts_vendor_support_get_reserved1: (skip):
1682
 **/
1683
gchar *
1684
fu_struct_genesys_ts_vendor_support_get_reserved1(const FuStructGenesysTsVendorSupport *st)
1685
0
{
1686
0
    g_return_val_if_fail(st != NULL, NULL);
1687
0
    return fu_memstrsafe(st->data, st->len, 2, 8, NULL);
1688
0
}
1689
/**
1690
 * fu_struct_genesys_ts_vendor_support_get_codesign_check: (skip):
1691
 **/
1692
FuGenesysVsCodesignCheck
1693
fu_struct_genesys_ts_vendor_support_get_codesign_check(const FuStructGenesysTsVendorSupport *st)
1694
0
{
1695
0
    g_return_val_if_fail(st != NULL, 0x0);
1696
0
    return st->data[10];
1697
0
}
1698
/**
1699
 * fu_struct_genesys_ts_vendor_support_get_reserved2: (skip):
1700
 **/
1701
gchar *
1702
fu_struct_genesys_ts_vendor_support_get_reserved2(const FuStructGenesysTsVendorSupport *st)
1703
0
{
1704
0
    g_return_val_if_fail(st != NULL, NULL);
1705
0
    return fu_memstrsafe(st->data, st->len, 11, 4, NULL);
1706
0
}
1707
/**
1708
 * fu_struct_genesys_ts_vendor_support_get_hid_isp: (skip):
1709
 **/
1710
FuGenesysVsHidIsp
1711
fu_struct_genesys_ts_vendor_support_get_hid_isp(const FuStructGenesysTsVendorSupport *st)
1712
0
{
1713
0
    g_return_val_if_fail(st != NULL, 0x0);
1714
0
    return st->data[15];
1715
0
}
1716
/**
1717
 * fu_struct_genesys_ts_vendor_support_get_reserved3: (skip):
1718
 **/
1719
gchar *
1720
fu_struct_genesys_ts_vendor_support_get_reserved3(const FuStructGenesysTsVendorSupport *st)
1721
0
{
1722
0
    g_return_val_if_fail(st != NULL, NULL);
1723
0
    return fu_memstrsafe(st->data, st->len, 16, 15, NULL);
1724
0
}
1725
1726
/* setters */
1727
/**
1728
 * fu_struct_genesys_ts_vendor_support_set_version: (skip):
1729
 **/
1730
gboolean
1731
fu_struct_genesys_ts_vendor_support_set_version(FuStructGenesysTsVendorSupport *st, const gchar *value, GError **error)
1732
0
{
1733
0
    gsize len;
1734
0
    g_return_val_if_fail(st != NULL, FALSE);
1735
0
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
1736
0
    if (value == NULL) {
1737
0
        memset(st->data + 0, 0x0, 2);
1738
0
        return TRUE;
1739
0
    }
1740
0
    len = strlen(value);
1741
0
    if (len > 2) {
1742
0
        g_set_error(error,
1743
0
                    FWUPD_ERROR,
1744
0
                    FWUPD_ERROR_INVALID_DATA,
1745
0
                    "string '%s' (0x%x bytes) does not fit in FuStructGenesysTsVendorSupport.version (0x%x bytes)",
1746
0
                    value, (guint) len, (guint) 2);
1747
0
        return FALSE;
1748
0
    }
1749
0
    return fu_memcpy_safe(st->data, st->len, 0, (const guint8 *)value, len, 0x0, len, error);
1750
0
}
1751
/**
1752
 * fu_struct_genesys_ts_vendor_support_set_reserved1: (skip):
1753
 **/
1754
gboolean
1755
fu_struct_genesys_ts_vendor_support_set_reserved1(FuStructGenesysTsVendorSupport *st, const gchar *value, GError **error)
1756
0
{
1757
0
    gsize len;
1758
0
    g_return_val_if_fail(st != NULL, FALSE);
1759
0
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
1760
0
    if (value == NULL) {
1761
0
        memset(st->data + 2, 0x0, 8);
1762
0
        return TRUE;
1763
0
    }
1764
0
    len = strlen(value);
1765
0
    if (len > 8) {
1766
0
        g_set_error(error,
1767
0
                    FWUPD_ERROR,
1768
0
                    FWUPD_ERROR_INVALID_DATA,
1769
0
                    "string '%s' (0x%x bytes) does not fit in FuStructGenesysTsVendorSupport.reserved1 (0x%x bytes)",
1770
0
                    value, (guint) len, (guint) 8);
1771
0
        return FALSE;
1772
0
    }
1773
0
    return fu_memcpy_safe(st->data, st->len, 2, (const guint8 *)value, len, 0x0, len, error);
1774
0
}
1775
/**
1776
 * fu_struct_genesys_ts_vendor_support_set_codesign_check: (skip):
1777
 **/
1778
void
1779
fu_struct_genesys_ts_vendor_support_set_codesign_check(FuStructGenesysTsVendorSupport *st, FuGenesysVsCodesignCheck value)
1780
0
{
1781
0
    g_return_if_fail(st != NULL);
1782
0
    st->data[10] = value;
1783
0
}
1784
/**
1785
 * fu_struct_genesys_ts_vendor_support_set_reserved2: (skip):
1786
 **/
1787
gboolean
1788
fu_struct_genesys_ts_vendor_support_set_reserved2(FuStructGenesysTsVendorSupport *st, const gchar *value, GError **error)
1789
0
{
1790
0
    gsize len;
1791
0
    g_return_val_if_fail(st != NULL, FALSE);
1792
0
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
1793
0
    if (value == NULL) {
1794
0
        memset(st->data + 11, 0x0, 4);
1795
0
        return TRUE;
1796
0
    }
1797
0
    len = strlen(value);
1798
0
    if (len > 4) {
1799
0
        g_set_error(error,
1800
0
                    FWUPD_ERROR,
1801
0
                    FWUPD_ERROR_INVALID_DATA,
1802
0
                    "string '%s' (0x%x bytes) does not fit in FuStructGenesysTsVendorSupport.reserved2 (0x%x bytes)",
1803
0
                    value, (guint) len, (guint) 4);
1804
0
        return FALSE;
1805
0
    }
1806
0
    return fu_memcpy_safe(st->data, st->len, 11, (const guint8 *)value, len, 0x0, len, error);
1807
0
}
1808
/**
1809
 * fu_struct_genesys_ts_vendor_support_set_hid_isp: (skip):
1810
 **/
1811
void
1812
fu_struct_genesys_ts_vendor_support_set_hid_isp(FuStructGenesysTsVendorSupport *st, FuGenesysVsHidIsp value)
1813
0
{
1814
0
    g_return_if_fail(st != NULL);
1815
0
    st->data[15] = value;
1816
0
}
1817
/**
1818
 * fu_struct_genesys_ts_vendor_support_set_reserved3: (skip):
1819
 **/
1820
gboolean
1821
fu_struct_genesys_ts_vendor_support_set_reserved3(FuStructGenesysTsVendorSupport *st, const gchar *value, GError **error)
1822
0
{
1823
0
    gsize len;
1824
0
    g_return_val_if_fail(st != NULL, FALSE);
1825
0
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
1826
0
    if (value == NULL) {
1827
0
        memset(st->data + 16, 0x0, 15);
1828
0
        return TRUE;
1829
0
    }
1830
0
    len = strlen(value);
1831
0
    if (len > 15) {
1832
0
        g_set_error(error,
1833
0
                    FWUPD_ERROR,
1834
0
                    FWUPD_ERROR_INVALID_DATA,
1835
0
                    "string '%s' (0x%x bytes) does not fit in FuStructGenesysTsVendorSupport.reserved3 (0x%x bytes)",
1836
0
                    value, (guint) len, (guint) 15);
1837
0
        return FALSE;
1838
0
    }
1839
0
    return fu_memcpy_safe(st->data, st->len, 16, (const guint8 *)value, len, 0x0, len, error);
1840
0
}
1841
/**
1842
 * fu_struct_genesys_ts_vendor_support_new: (skip):
1843
 **/
1844
FuStructGenesysTsVendorSupport *
1845
fu_struct_genesys_ts_vendor_support_new(void)
1846
0
{
1847
0
    FuStructGenesysTsVendorSupport *st = g_byte_array_sized_new(31);
1848
0
    fu_byte_array_set_size(st, 31, 0x0);
1849
0
    return st;
1850
0
}
1851
/**
1852
 * fu_struct_genesys_ts_vendor_support_to_string: (skip):
1853
 **/
1854
static gchar *
1855
fu_struct_genesys_ts_vendor_support_to_string(const FuStructGenesysTsVendorSupport *st)
1856
0
{
1857
0
    g_autoptr(GString) str = g_string_new("FuStructGenesysTsVendorSupport:\n");
1858
0
    g_return_val_if_fail(st != NULL, NULL);
1859
0
    {
1860
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_vendor_support_get_version(st);
1861
0
        if (tmp != NULL)
1862
0
            g_string_append_printf(str, "  version: %s\n", tmp);
1863
0
    }
1864
0
    {
1865
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_vendor_support_get_reserved1(st);
1866
0
        if (tmp != NULL)
1867
0
            g_string_append_printf(str, "  reserved1: %s\n", tmp);
1868
0
    }
1869
0
    {
1870
0
        const gchar *tmp = fu_genesys_vs_codesign_check_to_string(fu_struct_genesys_ts_vendor_support_get_codesign_check(st));
1871
0
        if (tmp != NULL) {
1872
0
            g_string_append_printf(str, "  codesign_check: 0x%x [%s]\n", (guint) fu_struct_genesys_ts_vendor_support_get_codesign_check(st), tmp);
1873
0
        } else {
1874
0
            g_string_append_printf(str, "  codesign_check: 0x%x\n", (guint) fu_struct_genesys_ts_vendor_support_get_codesign_check(st));
1875
0
        }
1876
0
    }
1877
0
    {
1878
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_vendor_support_get_reserved2(st);
1879
0
        if (tmp != NULL)
1880
0
            g_string_append_printf(str, "  reserved2: %s\n", tmp);
1881
0
    }
1882
0
    {
1883
0
        const gchar *tmp = fu_genesys_vs_hid_isp_to_string(fu_struct_genesys_ts_vendor_support_get_hid_isp(st));
1884
0
        if (tmp != NULL) {
1885
0
            g_string_append_printf(str, "  hid_isp: 0x%x [%s]\n", (guint) fu_struct_genesys_ts_vendor_support_get_hid_isp(st), tmp);
1886
0
        } else {
1887
0
            g_string_append_printf(str, "  hid_isp: 0x%x\n", (guint) fu_struct_genesys_ts_vendor_support_get_hid_isp(st));
1888
0
        }
1889
0
    }
1890
0
    {
1891
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_vendor_support_get_reserved3(st);
1892
0
        if (tmp != NULL)
1893
0
            g_string_append_printf(str, "  reserved3: %s\n", tmp);
1894
0
    }
1895
0
    if (str->len > 0)
1896
0
        g_string_set_size(str, str->len - 1);
1897
0
    return g_string_free(g_steal_pointer(&str), FALSE);
1898
0
}
1899
static gboolean
1900
fu_struct_genesys_ts_vendor_support_validate_internal(FuStructGenesysTsVendorSupport *st, GError **error)
1901
0
{
1902
0
    g_return_val_if_fail(st != NULL, FALSE);
1903
0
    return TRUE;
1904
0
}
1905
static gboolean
1906
fu_struct_genesys_ts_vendor_support_parse_internal(FuStructGenesysTsVendorSupport *st, GError **error)
1907
0
{
1908
0
    if (!fu_struct_genesys_ts_vendor_support_validate_internal(st, error))
1909
0
        return FALSE;
1910
0
    if (g_getenv("FWUPD_VERBOSE") != NULL) {
1911
0
        g_autofree gchar *str = fu_struct_genesys_ts_vendor_support_to_string(st);
1912
0
        g_debug("%s", str);
1913
0
    }
1914
0
    return TRUE;
1915
0
}
1916
1917
/**
1918
 * fu_struct_genesys_ts_vendor_support_parse: (skip):
1919
 **/
1920
FuStructGenesysTsVendorSupport *
1921
fu_struct_genesys_ts_vendor_support_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
1922
0
{
1923
0
    g_autoptr(GByteArray) st = g_byte_array_new();
1924
0
    g_return_val_if_fail(buf != NULL, NULL);
1925
0
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
1926
0
    if (!fu_memchk_read(bufsz, offset, 31, error)) {
1927
0
        g_prefix_error(error, "invalid struct FuStructGenesysTsVendorSupport: ");
1928
0
        return NULL;
1929
0
    }
1930
0
    g_byte_array_append(st, buf + offset, 31);
1931
0
    if (!fu_struct_genesys_ts_vendor_support_parse_internal(st, error))
1932
0
        return NULL;
1933
0
    return g_steal_pointer(&st);
1934
0
}
1935
/* getters */
1936
/**
1937
 * fu_struct_genesys_ts_brand_project_get_project: (skip):
1938
 **/
1939
gchar *
1940
fu_struct_genesys_ts_brand_project_get_project(const FuStructGenesysTsBrandProject *st)
1941
0
{
1942
0
    g_return_val_if_fail(st != NULL, NULL);
1943
0
    return fu_memstrsafe(st->data, st->len, 0, 15, NULL);
1944
0
}
1945
1946
/* setters */
1947
/**
1948
 * fu_struct_genesys_ts_brand_project_to_string: (skip):
1949
 **/
1950
static gchar *
1951
fu_struct_genesys_ts_brand_project_to_string(const FuStructGenesysTsBrandProject *st)
1952
0
{
1953
0
    g_autoptr(GString) str = g_string_new("FuStructGenesysTsBrandProject:\n");
1954
0
    g_return_val_if_fail(st != NULL, NULL);
1955
0
    {
1956
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_brand_project_get_project(st);
1957
0
        if (tmp != NULL)
1958
0
            g_string_append_printf(str, "  project: %s\n", tmp);
1959
0
    }
1960
0
    if (str->len > 0)
1961
0
        g_string_set_size(str, str->len - 1);
1962
0
    return g_string_free(g_steal_pointer(&str), FALSE);
1963
0
}
1964
static gboolean
1965
fu_struct_genesys_ts_brand_project_validate_internal(FuStructGenesysTsBrandProject *st, GError **error)
1966
0
{
1967
0
    g_return_val_if_fail(st != NULL, FALSE);
1968
0
    return TRUE;
1969
0
}
1970
static gboolean
1971
fu_struct_genesys_ts_brand_project_parse_internal(FuStructGenesysTsBrandProject *st, GError **error)
1972
0
{
1973
0
    if (!fu_struct_genesys_ts_brand_project_validate_internal(st, error))
1974
0
        return FALSE;
1975
0
    if (g_getenv("FWUPD_VERBOSE") != NULL) {
1976
0
        g_autofree gchar *str = fu_struct_genesys_ts_brand_project_to_string(st);
1977
0
        g_debug("%s", str);
1978
0
    }
1979
0
    return TRUE;
1980
0
}
1981
1982
/**
1983
 * fu_struct_genesys_ts_brand_project_parse: (skip):
1984
 **/
1985
FuStructGenesysTsBrandProject *
1986
fu_struct_genesys_ts_brand_project_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
1987
0
{
1988
0
    g_autoptr(GByteArray) st = g_byte_array_new();
1989
0
    g_return_val_if_fail(buf != NULL, NULL);
1990
0
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
1991
0
    if (!fu_memchk_read(bufsz, offset, 15, error)) {
1992
0
        g_prefix_error(error, "invalid struct FuStructGenesysTsBrandProject: ");
1993
0
        return NULL;
1994
0
    }
1995
0
    g_byte_array_append(st, buf + offset, 15);
1996
0
    if (!fu_struct_genesys_ts_brand_project_parse_internal(st, error))
1997
0
        return NULL;
1998
0
    return g_steal_pointer(&st);
1999
0
}
2000
/* getters */
2001
/**
2002
 * fu_struct_genesys_fw_codesign_info_rsa_get_tag_n: (skip):
2003
 **/
2004
static guint32
2005
fu_struct_genesys_fw_codesign_info_rsa_get_tag_n(const FuStructGenesysFwCodesignInfoRsa *st)
2006
175
{
2007
175
    g_return_val_if_fail(st != NULL, 0x0);
2008
175
    return fu_memread_uint32(st->data + 0, G_BIG_ENDIAN);
2009
175
}
2010
/**
2011
 * fu_struct_genesys_fw_codesign_info_rsa_get_text_n: (skip):
2012
 **/
2013
gchar *
2014
fu_struct_genesys_fw_codesign_info_rsa_get_text_n(const FuStructGenesysFwCodesignInfoRsa *st)
2015
0
{
2016
0
    g_return_val_if_fail(st != NULL, NULL);
2017
0
    return fu_memstrsafe(st->data, st->len, 4, 512, NULL);
2018
0
}
2019
/**
2020
 * fu_struct_genesys_fw_codesign_info_rsa_get_end_n: (skip):
2021
 **/
2022
static guint16
2023
fu_struct_genesys_fw_codesign_info_rsa_get_end_n(const FuStructGenesysFwCodesignInfoRsa *st)
2024
80
{
2025
80
    g_return_val_if_fail(st != NULL, 0x0);
2026
80
    return fu_memread_uint16(st->data + 516, G_BIG_ENDIAN);
2027
80
}
2028
/**
2029
 * fu_struct_genesys_fw_codesign_info_rsa_get_tag_e: (skip):
2030
 **/
2031
static guint32
2032
fu_struct_genesys_fw_codesign_info_rsa_get_tag_e(const FuStructGenesysFwCodesignInfoRsa *st)
2033
53
{
2034
53
    g_return_val_if_fail(st != NULL, 0x0);
2035
53
    return fu_memread_uint32(st->data + 518, G_BIG_ENDIAN);
2036
53
}
2037
/**
2038
 * fu_struct_genesys_fw_codesign_info_rsa_get_text_e: (skip):
2039
 **/
2040
gchar *
2041
fu_struct_genesys_fw_codesign_info_rsa_get_text_e(const FuStructGenesysFwCodesignInfoRsa *st)
2042
0
{
2043
0
    g_return_val_if_fail(st != NULL, NULL);
2044
0
    return fu_memstrsafe(st->data, st->len, 522, 6, NULL);
2045
0
}
2046
/**
2047
 * fu_struct_genesys_fw_codesign_info_rsa_get_end_e: (skip):
2048
 **/
2049
static guint16
2050
fu_struct_genesys_fw_codesign_info_rsa_get_end_e(const FuStructGenesysFwCodesignInfoRsa *st)
2051
25
{
2052
25
    g_return_val_if_fail(st != NULL, 0x0);
2053
25
    return fu_memread_uint16(st->data + 528, G_BIG_ENDIAN);
2054
25
}
2055
/**
2056
 * fu_struct_genesys_fw_codesign_info_rsa_get_signature: (skip):
2057
 **/
2058
const guint8 *
2059
fu_struct_genesys_fw_codesign_info_rsa_get_signature(const FuStructGenesysFwCodesignInfoRsa *st, gsize *bufsz)
2060
0
{
2061
0
    g_return_val_if_fail(st != NULL, NULL);
2062
0
    if (bufsz != NULL)
2063
0
        *bufsz = 256;
2064
0
    return st->data + 530;
2065
0
}
2066
2067
/* setters */
2068
/**
2069
 * fu_struct_genesys_fw_codesign_info_rsa_to_string: (skip):
2070
 **/
2071
static gchar *
2072
fu_struct_genesys_fw_codesign_info_rsa_to_string(const FuStructGenesysFwCodesignInfoRsa *st)
2073
0
{
2074
0
    g_autoptr(GString) str = g_string_new("FuStructGenesysFwCodesignInfoRsa:\n");
2075
0
    g_return_val_if_fail(st != NULL, NULL);
2076
0
    {
2077
0
        g_autofree gchar *tmp = fu_struct_genesys_fw_codesign_info_rsa_get_text_n(st);
2078
0
        if (tmp != NULL)
2079
0
            g_string_append_printf(str, "  text_n: %s\n", tmp);
2080
0
    }
2081
0
    {
2082
0
        g_autofree gchar *tmp = fu_struct_genesys_fw_codesign_info_rsa_get_text_e(st);
2083
0
        if (tmp != NULL)
2084
0
            g_string_append_printf(str, "  text_e: %s\n", tmp);
2085
0
    }
2086
0
    {
2087
0
        gsize bufsz = 0;
2088
0
        const guint8 *buf = fu_struct_genesys_fw_codesign_info_rsa_get_signature(st, &bufsz);
2089
0
        g_autoptr(GString) tmp = g_string_new(NULL);
2090
0
        for (gsize i = 0; i < bufsz; i++)
2091
0
            g_string_append_printf(tmp, "%02X", buf[i]);
2092
0
        g_string_append_printf(str, "  signature: 0x%s\n", tmp->str);
2093
0
    }
2094
0
    if (str->len > 0)
2095
0
        g_string_set_size(str, str->len - 1);
2096
0
    return g_string_free(g_steal_pointer(&str), FALSE);
2097
0
}
2098
static gboolean
2099
fu_struct_genesys_fw_codesign_info_rsa_validate_internal(FuStructGenesysFwCodesignInfoRsa *st, GError **error)
2100
175
{
2101
175
    g_return_val_if_fail(st != NULL, FALSE);
2102
175
    if (fu_struct_genesys_fw_codesign_info_rsa_get_tag_n(st) != 0x4E203D20) {
2103
95
        g_set_error_literal(error,
2104
95
                            FWUPD_ERROR,
2105
95
                            FWUPD_ERROR_INVALID_DATA,
2106
95
                            "constant FuStructGenesysFwCodesignInfoRsa.tag_n was not valid");
2107
95
        return FALSE;
2108
95
    }
2109
80
    if (fu_struct_genesys_fw_codesign_info_rsa_get_end_n(st) != 0x0D0A) {
2110
27
        g_set_error_literal(error,
2111
27
                            FWUPD_ERROR,
2112
27
                            FWUPD_ERROR_INVALID_DATA,
2113
27
                            "constant FuStructGenesysFwCodesignInfoRsa.end_n was not valid");
2114
27
        return FALSE;
2115
27
    }
2116
53
    if (fu_struct_genesys_fw_codesign_info_rsa_get_tag_e(st) != 0x45203D20) {
2117
28
        g_set_error_literal(error,
2118
28
                            FWUPD_ERROR,
2119
28
                            FWUPD_ERROR_INVALID_DATA,
2120
28
                            "constant FuStructGenesysFwCodesignInfoRsa.tag_e was not valid");
2121
28
        return FALSE;
2122
28
    }
2123
25
    if (fu_struct_genesys_fw_codesign_info_rsa_get_end_e(st) != 0x0D0A) {
2124
24
        g_set_error_literal(error,
2125
24
                            FWUPD_ERROR,
2126
24
                            FWUPD_ERROR_INVALID_DATA,
2127
24
                            "constant FuStructGenesysFwCodesignInfoRsa.end_e was not valid");
2128
24
        return FALSE;
2129
24
    }
2130
1
    return TRUE;
2131
25
}
2132
/**
2133
 * fu_struct_genesys_fw_codesign_info_rsa_validate_stream: (skip):
2134
 **/
2135
gboolean
2136
fu_struct_genesys_fw_codesign_info_rsa_validate_stream(GInputStream *stream, gsize offset, GError **error)
2137
175
{
2138
175
    g_autoptr(GByteArray) st = NULL;
2139
175
    g_return_val_if_fail(G_IS_INPUT_STREAM(stream), FALSE);
2140
175
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
2141
175
    st = fu_input_stream_read_byte_array(stream, offset, 786, NULL, error);
2142
175
    if (st == NULL) {
2143
0
        g_prefix_error(error, "FuStructGenesysFwCodesignInfoRsa failed read of 0x%x: ", (guint) 786);
2144
0
        return FALSE;
2145
0
    }
2146
175
    if (st->len != 786) {
2147
0
        g_set_error(error,
2148
0
                    FWUPD_ERROR,
2149
0
                    FWUPD_ERROR_INVALID_DATA,
2150
0
                    "FuStructGenesysFwCodesignInfoRsa requested 0x%x and got 0x%x",
2151
0
                    (guint) 786,
2152
0
                    (guint) st->len);
2153
0
        return FALSE;
2154
0
    }
2155
175
    return fu_struct_genesys_fw_codesign_info_rsa_validate_internal(st, error);
2156
175
}
2157
static gboolean
2158
fu_struct_genesys_fw_codesign_info_rsa_parse_internal(FuStructGenesysFwCodesignInfoRsa *st, GError **error)
2159
0
{
2160
0
    if (!fu_struct_genesys_fw_codesign_info_rsa_validate_internal(st, error))
2161
0
        return FALSE;
2162
0
    if (g_getenv("FWUPD_VERBOSE") != NULL) {
2163
0
        g_autofree gchar *str = fu_struct_genesys_fw_codesign_info_rsa_to_string(st);
2164
0
        g_debug("%s", str);
2165
0
    }
2166
0
    return TRUE;
2167
0
}
2168
/**
2169
 * fu_struct_genesys_fw_codesign_info_rsa_parse_stream: (skip):
2170
 **/
2171
FuStructGenesysFwCodesignInfoRsa *
2172
fu_struct_genesys_fw_codesign_info_rsa_parse_stream(GInputStream *stream, gsize offset, GError **error)
2173
0
{
2174
0
    g_autoptr(GByteArray) st = NULL;
2175
0
    st = fu_input_stream_read_byte_array(stream, offset, 786, NULL, error);
2176
0
    if (st == NULL) {
2177
0
        g_prefix_error(error, "FuStructGenesysFwCodesignInfoRsa failed read of 0x%x: ", (guint) 786);
2178
0
        return NULL;
2179
0
    }
2180
0
    if (st->len != 786) {
2181
0
        g_set_error(error,
2182
0
                    FWUPD_ERROR,
2183
0
                    FWUPD_ERROR_INVALID_DATA,
2184
0
                    "FuStructGenesysFwCodesignInfoRsa requested 0x%x and got 0x%x",
2185
0
                    (guint) 786,
2186
0
                    (guint) st->len);
2187
0
        return NULL;
2188
0
    }
2189
0
    if (!fu_struct_genesys_fw_codesign_info_rsa_parse_internal(st, error))
2190
0
        return NULL;
2191
0
    return g_steal_pointer(&st);
2192
0
}
2193
/* getters */
2194
/**
2195
 * fu_struct_genesys_fw_rsa_public_key_text_get_tag_n: (skip):
2196
 **/
2197
static guint32
2198
fu_struct_genesys_fw_rsa_public_key_text_get_tag_n(const FuStructGenesysFwRsaPublicKeyText *st)
2199
0
{
2200
0
    g_return_val_if_fail(st != NULL, 0x0);
2201
0
    return fu_memread_uint32(st->data + 0, G_BIG_ENDIAN);
2202
0
}
2203
/**
2204
 * fu_struct_genesys_fw_rsa_public_key_text_get_text_n: (skip):
2205
 **/
2206
gchar *
2207
fu_struct_genesys_fw_rsa_public_key_text_get_text_n(const FuStructGenesysFwRsaPublicKeyText *st)
2208
0
{
2209
0
    g_return_val_if_fail(st != NULL, NULL);
2210
0
    return fu_memstrsafe(st->data, st->len, 4, 512, NULL);
2211
0
}
2212
/**
2213
 * fu_struct_genesys_fw_rsa_public_key_text_get_end_n: (skip):
2214
 **/
2215
static guint16
2216
fu_struct_genesys_fw_rsa_public_key_text_get_end_n(const FuStructGenesysFwRsaPublicKeyText *st)
2217
0
{
2218
0
    g_return_val_if_fail(st != NULL, 0x0);
2219
0
    return fu_memread_uint16(st->data + 516, G_BIG_ENDIAN);
2220
0
}
2221
/**
2222
 * fu_struct_genesys_fw_rsa_public_key_text_get_tag_e: (skip):
2223
 **/
2224
static guint32
2225
fu_struct_genesys_fw_rsa_public_key_text_get_tag_e(const FuStructGenesysFwRsaPublicKeyText *st)
2226
0
{
2227
0
    g_return_val_if_fail(st != NULL, 0x0);
2228
0
    return fu_memread_uint32(st->data + 518, G_BIG_ENDIAN);
2229
0
}
2230
/**
2231
 * fu_struct_genesys_fw_rsa_public_key_text_get_text_e: (skip):
2232
 **/
2233
gchar *
2234
fu_struct_genesys_fw_rsa_public_key_text_get_text_e(const FuStructGenesysFwRsaPublicKeyText *st)
2235
0
{
2236
0
    g_return_val_if_fail(st != NULL, NULL);
2237
0
    return fu_memstrsafe(st->data, st->len, 522, 6, NULL);
2238
0
}
2239
/**
2240
 * fu_struct_genesys_fw_rsa_public_key_text_get_end_e: (skip):
2241
 **/
2242
static guint16
2243
fu_struct_genesys_fw_rsa_public_key_text_get_end_e(const FuStructGenesysFwRsaPublicKeyText *st)
2244
0
{
2245
0
    g_return_val_if_fail(st != NULL, 0x0);
2246
0
    return fu_memread_uint16(st->data + 528, G_BIG_ENDIAN);
2247
0
}
2248
2249
/* setters */
2250
/**
2251
 * fu_struct_genesys_fw_rsa_public_key_text_to_string: (skip):
2252
 **/
2253
static gchar *
2254
fu_struct_genesys_fw_rsa_public_key_text_to_string(const FuStructGenesysFwRsaPublicKeyText *st)
2255
0
{
2256
0
    g_autoptr(GString) str = g_string_new("FuStructGenesysFwRsaPublicKeyText:\n");
2257
0
    g_return_val_if_fail(st != NULL, NULL);
2258
0
    {
2259
0
        g_autofree gchar *tmp = fu_struct_genesys_fw_rsa_public_key_text_get_text_n(st);
2260
0
        if (tmp != NULL)
2261
0
            g_string_append_printf(str, "  text_n: %s\n", tmp);
2262
0
    }
2263
0
    {
2264
0
        g_autofree gchar *tmp = fu_struct_genesys_fw_rsa_public_key_text_get_text_e(st);
2265
0
        if (tmp != NULL)
2266
0
            g_string_append_printf(str, "  text_e: %s\n", tmp);
2267
0
    }
2268
0
    if (str->len > 0)
2269
0
        g_string_set_size(str, str->len - 1);
2270
0
    return g_string_free(g_steal_pointer(&str), FALSE);
2271
0
}
2272
static gboolean
2273
fu_struct_genesys_fw_rsa_public_key_text_validate_internal(FuStructGenesysFwRsaPublicKeyText *st, GError **error)
2274
0
{
2275
0
    g_return_val_if_fail(st != NULL, FALSE);
2276
0
    if (fu_struct_genesys_fw_rsa_public_key_text_get_tag_n(st) != 0x4E203D20) {
2277
0
        g_set_error_literal(error,
2278
0
                            FWUPD_ERROR,
2279
0
                            FWUPD_ERROR_INVALID_DATA,
2280
0
                            "constant FuStructGenesysFwRsaPublicKeyText.tag_n was not valid");
2281
0
        return FALSE;
2282
0
    }
2283
0
    if (fu_struct_genesys_fw_rsa_public_key_text_get_end_n(st) != 0x0D0A) {
2284
0
        g_set_error_literal(error,
2285
0
                            FWUPD_ERROR,
2286
0
                            FWUPD_ERROR_INVALID_DATA,
2287
0
                            "constant FuStructGenesysFwRsaPublicKeyText.end_n was not valid");
2288
0
        return FALSE;
2289
0
    }
2290
0
    if (fu_struct_genesys_fw_rsa_public_key_text_get_tag_e(st) != 0x45203D20) {
2291
0
        g_set_error_literal(error,
2292
0
                            FWUPD_ERROR,
2293
0
                            FWUPD_ERROR_INVALID_DATA,
2294
0
                            "constant FuStructGenesysFwRsaPublicKeyText.tag_e was not valid");
2295
0
        return FALSE;
2296
0
    }
2297
0
    if (fu_struct_genesys_fw_rsa_public_key_text_get_end_e(st) != 0x0D0A) {
2298
0
        g_set_error_literal(error,
2299
0
                            FWUPD_ERROR,
2300
0
                            FWUPD_ERROR_INVALID_DATA,
2301
0
                            "constant FuStructGenesysFwRsaPublicKeyText.end_e was not valid");
2302
0
        return FALSE;
2303
0
    }
2304
0
    return TRUE;
2305
0
}
2306
/**
2307
 * fu_struct_genesys_fw_rsa_public_key_text_validate: (skip):
2308
 **/
2309
gboolean
2310
fu_struct_genesys_fw_rsa_public_key_text_validate(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
2311
0
{
2312
0
    GByteArray st = {.data = (guint8 *) buf + offset, .len = bufsz - offset, };
2313
0
    g_return_val_if_fail(buf != NULL, FALSE);
2314
0
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
2315
0
    if (!fu_memchk_read(bufsz, offset, 530, error)) {
2316
0
        g_prefix_error(error, "invalid struct FuStructGenesysFwRsaPublicKeyText: ");
2317
0
        return FALSE;
2318
0
    }
2319
0
    if (!fu_struct_genesys_fw_rsa_public_key_text_validate_internal(&st, error))
2320
0
        return FALSE;
2321
0
    return TRUE;
2322
0
}
2323
static gboolean
2324
fu_struct_genesys_fw_rsa_public_key_text_parse_internal(FuStructGenesysFwRsaPublicKeyText *st, GError **error)
2325
0
{
2326
0
    if (!fu_struct_genesys_fw_rsa_public_key_text_validate_internal(st, error))
2327
0
        return FALSE;
2328
0
    if (g_getenv("FWUPD_VERBOSE") != NULL) {
2329
0
        g_autofree gchar *str = fu_struct_genesys_fw_rsa_public_key_text_to_string(st);
2330
0
        g_debug("%s", str);
2331
0
    }
2332
0
    return TRUE;
2333
0
}
2334
2335
/**
2336
 * fu_struct_genesys_fw_rsa_public_key_text_parse: (skip):
2337
 **/
2338
FuStructGenesysFwRsaPublicKeyText *
2339
fu_struct_genesys_fw_rsa_public_key_text_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
2340
0
{
2341
0
    g_autoptr(GByteArray) st = g_byte_array_new();
2342
0
    g_return_val_if_fail(buf != NULL, NULL);
2343
0
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
2344
0
    if (!fu_memchk_read(bufsz, offset, 530, error)) {
2345
0
        g_prefix_error(error, "invalid struct FuStructGenesysFwRsaPublicKeyText: ");
2346
0
        return NULL;
2347
0
    }
2348
0
    g_byte_array_append(st, buf + offset, 530);
2349
0
    if (!fu_struct_genesys_fw_rsa_public_key_text_parse_internal(st, error))
2350
0
        return NULL;
2351
0
    return g_steal_pointer(&st);
2352
0
}
2353
/* getters */
2354
/**
2355
 * fu_struct_genesys_fw_codesign_info_ecdsa_get_hash: (skip):
2356
 **/
2357
const guint8 *
2358
fu_struct_genesys_fw_codesign_info_ecdsa_get_hash(const FuStructGenesysFwCodesignInfoEcdsa *st, gsize *bufsz)
2359
0
{
2360
0
    g_return_val_if_fail(st != NULL, NULL);
2361
0
    if (bufsz != NULL)
2362
0
        *bufsz = 32;
2363
0
    return st->data + 0;
2364
0
}
2365
/**
2366
 * fu_struct_genesys_fw_codesign_info_ecdsa_get_key: (skip):
2367
 **/
2368
const guint8 *
2369
fu_struct_genesys_fw_codesign_info_ecdsa_get_key(const FuStructGenesysFwCodesignInfoEcdsa *st, gsize *bufsz)
2370
0
{
2371
0
    g_return_val_if_fail(st != NULL, NULL);
2372
0
    if (bufsz != NULL)
2373
0
        *bufsz = 64;
2374
0
    return st->data + 32;
2375
0
}
2376
/**
2377
 * fu_struct_genesys_fw_codesign_info_ecdsa_get_signature: (skip):
2378
 **/
2379
const guint8 *
2380
fu_struct_genesys_fw_codesign_info_ecdsa_get_signature(const FuStructGenesysFwCodesignInfoEcdsa *st, gsize *bufsz)
2381
0
{
2382
0
    g_return_val_if_fail(st != NULL, NULL);
2383
0
    if (bufsz != NULL)
2384
0
        *bufsz = 64;
2385
0
    return st->data + 96;
2386
0
}
2387
2388
/* setters */
2389
/**
2390
 * fu_struct_genesys_fw_codesign_info_ecdsa_to_string: (skip):
2391
 **/
2392
static gchar *
2393
fu_struct_genesys_fw_codesign_info_ecdsa_to_string(const FuStructGenesysFwCodesignInfoEcdsa *st)
2394
0
{
2395
0
    g_autoptr(GString) str = g_string_new("FuStructGenesysFwCodesignInfoEcdsa:\n");
2396
0
    g_return_val_if_fail(st != NULL, NULL);
2397
0
    {
2398
0
        gsize bufsz = 0;
2399
0
        const guint8 *buf = fu_struct_genesys_fw_codesign_info_ecdsa_get_hash(st, &bufsz);
2400
0
        g_autoptr(GString) tmp = g_string_new(NULL);
2401
0
        for (gsize i = 0; i < bufsz; i++)
2402
0
            g_string_append_printf(tmp, "%02X", buf[i]);
2403
0
        g_string_append_printf(str, "  hash: 0x%s\n", tmp->str);
2404
0
    }
2405
0
    {
2406
0
        gsize bufsz = 0;
2407
0
        const guint8 *buf = fu_struct_genesys_fw_codesign_info_ecdsa_get_key(st, &bufsz);
2408
0
        g_autoptr(GString) tmp = g_string_new(NULL);
2409
0
        for (gsize i = 0; i < bufsz; i++)
2410
0
            g_string_append_printf(tmp, "%02X", buf[i]);
2411
0
        g_string_append_printf(str, "  key: 0x%s\n", tmp->str);
2412
0
    }
2413
0
    {
2414
0
        gsize bufsz = 0;
2415
0
        const guint8 *buf = fu_struct_genesys_fw_codesign_info_ecdsa_get_signature(st, &bufsz);
2416
0
        g_autoptr(GString) tmp = g_string_new(NULL);
2417
0
        for (gsize i = 0; i < bufsz; i++)
2418
0
            g_string_append_printf(tmp, "%02X", buf[i]);
2419
0
        g_string_append_printf(str, "  signature: 0x%s\n", tmp->str);
2420
0
    }
2421
0
    if (str->len > 0)
2422
0
        g_string_set_size(str, str->len - 1);
2423
0
    return g_string_free(g_steal_pointer(&str), FALSE);
2424
0
}
2425
static gboolean
2426
fu_struct_genesys_fw_codesign_info_ecdsa_validate_internal(FuStructGenesysFwCodesignInfoEcdsa *st, GError **error)
2427
30
{
2428
30
    g_return_val_if_fail(st != NULL, FALSE);
2429
30
    return TRUE;
2430
30
}
2431
/**
2432
 * fu_struct_genesys_fw_codesign_info_ecdsa_validate: (skip):
2433
 **/
2434
gboolean
2435
fu_struct_genesys_fw_codesign_info_ecdsa_validate(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
2436
0
{
2437
0
    GByteArray st = {.data = (guint8 *) buf + offset, .len = bufsz - offset, };
2438
0
    g_return_val_if_fail(buf != NULL, FALSE);
2439
0
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
2440
0
    if (!fu_memchk_read(bufsz, offset, 160, error)) {
2441
0
        g_prefix_error(error, "invalid struct FuStructGenesysFwCodesignInfoEcdsa: ");
2442
0
        return FALSE;
2443
0
    }
2444
0
    if (!fu_struct_genesys_fw_codesign_info_ecdsa_validate_internal(&st, error))
2445
0
        return FALSE;
2446
0
    return TRUE;
2447
0
}
2448
/**
2449
 * fu_struct_genesys_fw_codesign_info_ecdsa_validate_stream: (skip):
2450
 **/
2451
gboolean
2452
fu_struct_genesys_fw_codesign_info_ecdsa_validate_stream(GInputStream *stream, gsize offset, GError **error)
2453
30
{
2454
30
    g_autoptr(GByteArray) st = NULL;
2455
30
    g_return_val_if_fail(G_IS_INPUT_STREAM(stream), FALSE);
2456
30
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
2457
30
    st = fu_input_stream_read_byte_array(stream, offset, 160, NULL, error);
2458
30
    if (st == NULL) {
2459
0
        g_prefix_error(error, "FuStructGenesysFwCodesignInfoEcdsa failed read of 0x%x: ", (guint) 160);
2460
0
        return FALSE;
2461
0
    }
2462
30
    if (st->len != 160) {
2463
0
        g_set_error(error,
2464
0
                    FWUPD_ERROR,
2465
0
                    FWUPD_ERROR_INVALID_DATA,
2466
0
                    "FuStructGenesysFwCodesignInfoEcdsa requested 0x%x and got 0x%x",
2467
0
                    (guint) 160,
2468
0
                    (guint) st->len);
2469
0
        return FALSE;
2470
0
    }
2471
30
    return fu_struct_genesys_fw_codesign_info_ecdsa_validate_internal(st, error);
2472
30
}
2473
static gboolean
2474
fu_struct_genesys_fw_codesign_info_ecdsa_parse_internal(FuStructGenesysFwCodesignInfoEcdsa *st, GError **error)
2475
0
{
2476
0
    if (!fu_struct_genesys_fw_codesign_info_ecdsa_validate_internal(st, error))
2477
0
        return FALSE;
2478
0
    if (g_getenv("FWUPD_VERBOSE") != NULL) {
2479
0
        g_autofree gchar *str = fu_struct_genesys_fw_codesign_info_ecdsa_to_string(st);
2480
0
        g_debug("%s", str);
2481
0
    }
2482
0
    return TRUE;
2483
0
}
2484
2485
/**
2486
 * fu_struct_genesys_fw_codesign_info_ecdsa_parse: (skip):
2487
 **/
2488
FuStructGenesysFwCodesignInfoEcdsa *
2489
fu_struct_genesys_fw_codesign_info_ecdsa_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
2490
0
{
2491
0
    g_autoptr(GByteArray) st = g_byte_array_new();
2492
0
    g_return_val_if_fail(buf != NULL, NULL);
2493
0
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
2494
0
    if (!fu_memchk_read(bufsz, offset, 160, error)) {
2495
0
        g_prefix_error(error, "invalid struct FuStructGenesysFwCodesignInfoEcdsa: ");
2496
0
        return NULL;
2497
0
    }
2498
0
    g_byte_array_append(st, buf + offset, 160);
2499
0
    if (!fu_struct_genesys_fw_codesign_info_ecdsa_parse_internal(st, error))
2500
0
        return NULL;
2501
0
    return g_steal_pointer(&st);
2502
0
}
2503
/**
2504
 * fu_struct_genesys_fw_codesign_info_ecdsa_parse_stream: (skip):
2505
 **/
2506
FuStructGenesysFwCodesignInfoEcdsa *
2507
fu_struct_genesys_fw_codesign_info_ecdsa_parse_stream(GInputStream *stream, gsize offset, GError **error)
2508
0
{
2509
0
    g_autoptr(GByteArray) st = NULL;
2510
0
    st = fu_input_stream_read_byte_array(stream, offset, 160, NULL, error);
2511
0
    if (st == NULL) {
2512
0
        g_prefix_error(error, "FuStructGenesysFwCodesignInfoEcdsa failed read of 0x%x: ", (guint) 160);
2513
0
        return NULL;
2514
0
    }
2515
0
    if (st->len != 160) {
2516
0
        g_set_error(error,
2517
0
                    FWUPD_ERROR,
2518
0
                    FWUPD_ERROR_INVALID_DATA,
2519
0
                    "FuStructGenesysFwCodesignInfoEcdsa requested 0x%x and got 0x%x",
2520
0
                    (guint) 160,
2521
0
                    (guint) st->len);
2522
0
        return NULL;
2523
0
    }
2524
0
    if (!fu_struct_genesys_fw_codesign_info_ecdsa_parse_internal(st, error))
2525
0
        return NULL;
2526
0
    return g_steal_pointer(&st);
2527
0
}
2528
/* getters */
2529
/**
2530
 * fu_struct_genesys_fw_ecdsa_public_key_get_key: (skip):
2531
 **/
2532
const guint8 *
2533
fu_struct_genesys_fw_ecdsa_public_key_get_key(const FuStructGenesysFwEcdsaPublicKey *st, gsize *bufsz)
2534
0
{
2535
0
    g_return_val_if_fail(st != NULL, NULL);
2536
0
    if (bufsz != NULL)
2537
0
        *bufsz = 64;
2538
0
    return st->data + 0;
2539
0
}
2540
2541
/* setters */
2542
/**
2543
 * fu_struct_genesys_fw_ecdsa_public_key_to_string: (skip):
2544
 **/
2545
static gchar *
2546
fu_struct_genesys_fw_ecdsa_public_key_to_string(const FuStructGenesysFwEcdsaPublicKey *st)
2547
0
{
2548
0
    g_autoptr(GString) str = g_string_new("FuStructGenesysFwEcdsaPublicKey:\n");
2549
0
    g_return_val_if_fail(st != NULL, NULL);
2550
0
    {
2551
0
        gsize bufsz = 0;
2552
0
        const guint8 *buf = fu_struct_genesys_fw_ecdsa_public_key_get_key(st, &bufsz);
2553
0
        g_autoptr(GString) tmp = g_string_new(NULL);
2554
0
        for (gsize i = 0; i < bufsz; i++)
2555
0
            g_string_append_printf(tmp, "%02X", buf[i]);
2556
0
        g_string_append_printf(str, "  key: 0x%s\n", tmp->str);
2557
0
    }
2558
0
    if (str->len > 0)
2559
0
        g_string_set_size(str, str->len - 1);
2560
0
    return g_string_free(g_steal_pointer(&str), FALSE);
2561
0
}
2562
static gboolean
2563
fu_struct_genesys_fw_ecdsa_public_key_validate_internal(FuStructGenesysFwEcdsaPublicKey *st, GError **error)
2564
0
{
2565
0
    g_return_val_if_fail(st != NULL, FALSE);
2566
0
    return TRUE;
2567
0
}
2568
/**
2569
 * fu_struct_genesys_fw_ecdsa_public_key_validate: (skip):
2570
 **/
2571
gboolean
2572
fu_struct_genesys_fw_ecdsa_public_key_validate(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
2573
0
{
2574
0
    GByteArray st = {.data = (guint8 *) buf + offset, .len = bufsz - offset, };
2575
0
    g_return_val_if_fail(buf != NULL, FALSE);
2576
0
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
2577
0
    if (!fu_memchk_read(bufsz, offset, 64, error)) {
2578
0
        g_prefix_error(error, "invalid struct FuStructGenesysFwEcdsaPublicKey: ");
2579
0
        return FALSE;
2580
0
    }
2581
0
    if (!fu_struct_genesys_fw_ecdsa_public_key_validate_internal(&st, error))
2582
0
        return FALSE;
2583
0
    return TRUE;
2584
0
}
2585
static gboolean
2586
fu_struct_genesys_fw_ecdsa_public_key_parse_internal(FuStructGenesysFwEcdsaPublicKey *st, GError **error)
2587
0
{
2588
0
    if (!fu_struct_genesys_fw_ecdsa_public_key_validate_internal(st, error))
2589
0
        return FALSE;
2590
0
    if (g_getenv("FWUPD_VERBOSE") != NULL) {
2591
0
        g_autofree gchar *str = fu_struct_genesys_fw_ecdsa_public_key_to_string(st);
2592
0
        g_debug("%s", str);
2593
0
    }
2594
0
    return TRUE;
2595
0
}
2596
2597
/**
2598
 * fu_struct_genesys_fw_ecdsa_public_key_parse: (skip):
2599
 **/
2600
FuStructGenesysFwEcdsaPublicKey *
2601
fu_struct_genesys_fw_ecdsa_public_key_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
2602
0
{
2603
0
    g_autoptr(GByteArray) st = g_byte_array_new();
2604
0
    g_return_val_if_fail(buf != NULL, NULL);
2605
0
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
2606
0
    if (!fu_memchk_read(bufsz, offset, 64, error)) {
2607
0
        g_prefix_error(error, "invalid struct FuStructGenesysFwEcdsaPublicKey: ");
2608
0
        return NULL;
2609
0
    }
2610
0
    g_byte_array_append(st, buf + offset, 64);
2611
0
    if (!fu_struct_genesys_fw_ecdsa_public_key_parse_internal(st, error))
2612
0
        return NULL;
2613
0
    return g_steal_pointer(&st);
2614
0
}