Coverage Report

Created: 2026-02-26 06:27

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/work/fu-cfu-struct.c
Line
Count
Source
1
/*
2
 * This file is auto-generated, do not modify!
3
 *
4
 * SPDX-License-Identifier: LGPL-2.1-or-later
5
 */
6
7
#include "config.h"
8
9
#include <glib.h>
10
11
#include "fu-cfu-struct.h"
12
#include "fu-byte-array.h"
13
#include "fu-bytes.h"
14
#include "fu-mem-private.h"
15
#include "fu-string.h"
16
17
#ifdef G_LOG_DOMAIN
18
  #undef G_LOG_DOMAIN
19
#endif
20
0
#define G_LOG_DOMAIN "FuStruct"
21
22
/**
23
 * fu_cfu_offer_info_code_to_string:
24
 * @val: value, e.g. %FU_CFU_OFFER_INFO_CODE_START_OFFER_LIST
25
 *
26
 * Converts an enumerated value to a string.
27
 *
28
 * Returns: identifier string
29
 **/
30
const gchar *
31
fu_cfu_offer_info_code_to_string(FuCfuOfferInfoCode val)
32
0
{
33
0
    if (val == FU_CFU_OFFER_INFO_CODE_START_ENTIRE_TRANSACTION)
34
0
        return "start-entire-transaction";
35
0
    if (val == FU_CFU_OFFER_INFO_CODE_START_OFFER_LIST)
36
0
        return "start-offer-list";
37
0
    if (val == FU_CFU_OFFER_INFO_CODE_END_OFFER_LIST)
38
0
        return "end-offer-list";
39
0
    return NULL;
40
0
}
41
42
/**
43
 * fu_cfu_rr_code_to_string:
44
 * @val: value, e.g. %FU_CFU_RR_CODE_OFFER_REJECT_INV_COMPONENT
45
 *
46
 * Converts an enumerated value to a string.
47
 *
48
 * Returns: identifier string
49
 **/
50
const gchar *
51
fu_cfu_rr_code_to_string(FuCfuRrCode val)
52
0
{
53
0
    if (val == FU_CFU_RR_CODE_OFFER_REJECT_OLD_FIRMWARE)
54
0
        return "offer-reject-old-firmware";
55
0
    if (val == FU_CFU_RR_CODE_OFFER_REJECT_INV_COMPONENT)
56
0
        return "offer-reject-inv-component";
57
0
    if (val == FU_CFU_RR_CODE_UPDATE_OFFER_SWAP_PENDING)
58
0
        return "update-offer-swap-pending";
59
0
    if (val == FU_CFU_RR_CODE_WRONG_BANK)
60
0
        return "wrong-bank";
61
0
    if (val == FU_CFU_RR_CODE_SIGN_RULE)
62
0
        return "sign-rule";
63
0
    if (val == FU_CFU_RR_CODE_VER_RELEASE_DEBUG)
64
0
        return "ver-release-debug";
65
0
    if (val == FU_CFU_RR_CODE_DEBUG_SAME_VERSION)
66
0
        return "debug-same-version";
67
0
    if (val == FU_CFU_RR_CODE_NONE)
68
0
        return "none";
69
0
    return NULL;
70
0
}
71
72
/**
73
 * fu_cfu_offer_status_to_string:
74
 * @val: value, e.g. %FU_CFU_OFFER_STATUS_ACCEPT
75
 *
76
 * Converts an enumerated value to a string.
77
 *
78
 * Returns: identifier string
79
 **/
80
const gchar *
81
fu_cfu_offer_status_to_string(FuCfuOfferStatus val)
82
0
{
83
0
    if (val == FU_CFU_OFFER_STATUS_SKIP)
84
0
        return "skip";
85
0
    if (val == FU_CFU_OFFER_STATUS_ACCEPT)
86
0
        return "accept";
87
0
    if (val == FU_CFU_OFFER_STATUS_REJECT)
88
0
        return "reject";
89
0
    if (val == FU_CFU_OFFER_STATUS_BUSY)
90
0
        return "busy";
91
0
    if (val == FU_CFU_OFFER_STATUS_COMMAND)
92
0
        return "command";
93
0
    if (val == FU_CFU_OFFER_STATUS_CMD_NOT_SUPPORTED)
94
0
        return "cmd-not-supported";
95
0
    return NULL;
96
0
}
97
98
99
/**
100
 * fu_cfu_content_status_to_string:
101
 * @val: value, e.g. %FU_CFU_CONTENT_STATUS_ERROR_PREPARE
102
 *
103
 * Converts an enumerated value to a string.
104
 *
105
 * Returns: identifier string
106
 **/
107
const gchar *
108
fu_cfu_content_status_to_string(FuCfuContentStatus val)
109
0
{
110
0
    if (val == FU_CFU_CONTENT_STATUS_SUCCESS)
111
0
        return "success";
112
0
    if (val == FU_CFU_CONTENT_STATUS_ERROR_PREPARE)
113
0
        return "error-prepare";
114
0
    if (val == FU_CFU_CONTENT_STATUS_ERROR_WRITE)
115
0
        return "error-write";
116
0
    if (val == FU_CFU_CONTENT_STATUS_ERROR_COMPLETE)
117
0
        return "error-complete";
118
0
    if (val == FU_CFU_CONTENT_STATUS_ERROR_VERIFY)
119
0
        return "error-verify";
120
0
    if (val == FU_CFU_CONTENT_STATUS_ERROR_CRC)
121
0
        return "error-crc";
122
0
    if (val == FU_CFU_CONTENT_STATUS_ERROR_SIGNATURE)
123
0
        return "error-signature";
124
0
    if (val == FU_CFU_CONTENT_STATUS_ERROR_VERSION)
125
0
        return "error-version";
126
0
    if (val == FU_CFU_CONTENT_STATUS_SWAP_PENDING)
127
0
        return "swap-pending";
128
0
    if (val == FU_CFU_CONTENT_STATUS_ERROR_INVALID_ADDR)
129
0
        return "error-invalid-addr";
130
0
    if (val == FU_CFU_CONTENT_STATUS_ERROR_NO_OFFER)
131
0
        return "error-no-offer";
132
0
    if (val == FU_CFU_CONTENT_STATUS_ERROR_INVALID)
133
0
        return "error-invalid";
134
0
    return NULL;
135
0
}
136
/**
137
 * fu_struct_cfu_get_version_rsp_ref: (skip):
138
 **/
139
FuStructCfuGetVersionRsp *
140
fu_struct_cfu_get_version_rsp_ref(FuStructCfuGetVersionRsp *st)
141
0
{
142
0
    g_return_val_if_fail(st != NULL, NULL);
143
0
    st->refcount++;
144
0
    return st;
145
0
}
146
/**
147
 * fu_struct_cfu_get_version_rsp_unref: (skip):
148
 **/
149
void
150
fu_struct_cfu_get_version_rsp_unref(FuStructCfuGetVersionRsp *st)
151
0
{
152
0
    g_return_if_fail(st != NULL);
153
0
    if (st->refcount == 0) {
154
0
        g_critical("FuStructCfuGetVersionRsp refcount already zero");
155
0
        return;
156
0
    }
157
0
    if (--st->refcount > 0)
158
0
        return;
159
0
    if (st->buf != NULL)
160
0
        g_byte_array_unref(st->buf);
161
0
    g_free(st);
162
0
}
163
/**
164
 * fu_struct_cfu_get_version_rsp_new_internal: (skip):
165
 **/
166
static FuStructCfuGetVersionRsp *
167
fu_struct_cfu_get_version_rsp_new_internal(void)
168
0
{
169
0
    FuStructCfuGetVersionRsp *st = g_new0(FuStructCfuGetVersionRsp, 1);
170
0
    st->refcount = 1;
171
0
    return st;
172
0
}
173
174
/* getters */
175
/**
176
 * fu_struct_cfu_get_version_rsp_get_component_cnt: (skip):
177
 **/
178
guint8
179
fu_struct_cfu_get_version_rsp_get_component_cnt(const FuStructCfuGetVersionRsp *st)
180
0
{
181
0
    g_return_val_if_fail(st != NULL, 0x0);
182
0
    return st->buf->data[0];
183
0
}
184
/**
185
 * fu_struct_cfu_get_version_rsp_get_flags: (skip):
186
 **/
187
guint8
188
fu_struct_cfu_get_version_rsp_get_flags(const FuStructCfuGetVersionRsp *st)
189
0
{
190
0
    g_return_val_if_fail(st != NULL, 0x0);
191
0
    return st->buf->data[3];
192
0
}
193
194
/* setters */
195
/**
196
 * fu_struct_cfu_get_version_rsp_set_component_cnt: (skip):
197
 **/
198
void
199
fu_struct_cfu_get_version_rsp_set_component_cnt(FuStructCfuGetVersionRsp *st, guint8 value)
200
0
{
201
0
    g_return_if_fail(st != NULL);
202
0
    st->buf->data[0] = value;
203
0
}
204
/**
205
 * fu_struct_cfu_get_version_rsp_set_flags: (skip):
206
 **/
207
void
208
fu_struct_cfu_get_version_rsp_set_flags(FuStructCfuGetVersionRsp *st, guint8 value)
209
0
{
210
0
    g_return_if_fail(st != NULL);
211
0
    st->buf->data[3] = value;
212
0
}
213
/**
214
 * fu_struct_cfu_get_version_rsp_new: (skip):
215
 **/
216
FuStructCfuGetVersionRsp *
217
fu_struct_cfu_get_version_rsp_new(void)
218
0
{
219
0
    FuStructCfuGetVersionRsp *st = fu_struct_cfu_get_version_rsp_new_internal();
220
0
    st->buf = g_byte_array_sized_new(4);
221
0
    fu_byte_array_set_size(st->buf, 4, 0x0);
222
0
    return st;
223
0
}
224
/**
225
 * fu_struct_cfu_get_version_rsp_to_string: (skip):
226
 **/
227
static gchar *
228
fu_struct_cfu_get_version_rsp_to_string(const FuStructCfuGetVersionRsp *st)
229
0
{
230
0
    g_autoptr(GString) str = g_string_new("FuStructCfuGetVersionRsp:\n");
231
0
    g_return_val_if_fail(st != NULL, NULL);
232
0
    g_string_append_printf(str, "  component_cnt: 0x%x\n",
233
0
                           (guint) fu_struct_cfu_get_version_rsp_get_component_cnt(st));
234
0
    g_string_append_printf(str, "  flags: 0x%x\n",
235
0
                           (guint) fu_struct_cfu_get_version_rsp_get_flags(st));
236
0
    if (str->len > 0)
237
0
        g_string_set_size(str, str->len - 1);
238
0
    return g_string_free(g_steal_pointer(&str), FALSE);
239
0
}
240
static gboolean
241
fu_struct_cfu_get_version_rsp_validate_internal(FuStructCfuGetVersionRsp *st, GError **error)
242
0
{
243
0
    g_return_val_if_fail(st != NULL, FALSE);
244
0
    return TRUE;
245
0
}
246
static gboolean
247
fu_struct_cfu_get_version_rsp_parse_internal(FuStructCfuGetVersionRsp *st, GError **error)
248
0
{
249
0
    if (g_getenv("FWUPD_VERBOSE") != NULL) {
250
0
        g_autofree gchar *str = fu_struct_cfu_get_version_rsp_to_string(st);
251
0
        g_debug("%s", str);
252
0
    }
253
0
    if (!fu_struct_cfu_get_version_rsp_validate_internal(st, error))
254
0
        return FALSE;
255
0
    return TRUE;
256
0
}
257
258
/**
259
 * fu_struct_cfu_get_version_rsp_parse: (skip):
260
 **/
261
FuStructCfuGetVersionRsp *
262
fu_struct_cfu_get_version_rsp_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
263
0
{
264
0
    g_autoptr(FuStructCfuGetVersionRsp) st = fu_struct_cfu_get_version_rsp_new_internal();
265
0
    g_return_val_if_fail(buf != NULL, NULL);
266
0
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
267
0
    if (!fu_memchk_read(bufsz, offset, 4, error)) {
268
0
        g_prefix_error_literal(error, "invalid struct FuStructCfuGetVersionRsp: ");
269
0
        return NULL;
270
0
    }
271
0
    st->buf = g_byte_array_new();
272
0
    g_byte_array_append(st->buf, buf + offset, 4);
273
0
    if (!fu_struct_cfu_get_version_rsp_parse_internal(st, error))
274
0
        return NULL;
275
0
    return g_steal_pointer(&st);
276
0
}
277
/**
278
 * fu_struct_cfu_get_version_rsp_component_ref: (skip):
279
 **/
280
FuStructCfuGetVersionRspComponent *
281
fu_struct_cfu_get_version_rsp_component_ref(FuStructCfuGetVersionRspComponent *st)
282
0
{
283
0
    g_return_val_if_fail(st != NULL, NULL);
284
0
    st->refcount++;
285
0
    return st;
286
0
}
287
/**
288
 * fu_struct_cfu_get_version_rsp_component_unref: (skip):
289
 **/
290
void
291
fu_struct_cfu_get_version_rsp_component_unref(FuStructCfuGetVersionRspComponent *st)
292
0
{
293
0
    g_return_if_fail(st != NULL);
294
0
    if (st->refcount == 0) {
295
0
        g_critical("FuStructCfuGetVersionRspComponent refcount already zero");
296
0
        return;
297
0
    }
298
0
    if (--st->refcount > 0)
299
0
        return;
300
0
    if (st->buf != NULL)
301
0
        g_byte_array_unref(st->buf);
302
0
    g_free(st);
303
0
}
304
/**
305
 * fu_struct_cfu_get_version_rsp_component_new_internal: (skip):
306
 **/
307
static FuStructCfuGetVersionRspComponent *
308
fu_struct_cfu_get_version_rsp_component_new_internal(void)
309
0
{
310
0
    FuStructCfuGetVersionRspComponent *st = g_new0(FuStructCfuGetVersionRspComponent, 1);
311
0
    st->refcount = 1;
312
0
    return st;
313
0
}
314
315
/* getters */
316
/**
317
 * fu_struct_cfu_get_version_rsp_component_get_fw_version: (skip):
318
 **/
319
guint32
320
fu_struct_cfu_get_version_rsp_component_get_fw_version(const FuStructCfuGetVersionRspComponent *st)
321
0
{
322
0
    g_return_val_if_fail(st != NULL, 0x0);
323
0
    return fu_memread_uint32(st->buf->data + 0, G_LITTLE_ENDIAN);
324
0
}
325
/**
326
 * fu_struct_cfu_get_version_rsp_component_get_flags: (skip):
327
 **/
328
guint8
329
fu_struct_cfu_get_version_rsp_component_get_flags(const FuStructCfuGetVersionRspComponent *st)
330
0
{
331
0
    g_return_val_if_fail(st != NULL, 0x0);
332
0
    return st->buf->data[4];
333
0
}
334
/**
335
 * fu_struct_cfu_get_version_rsp_component_get_component_id: (skip):
336
 **/
337
guint8
338
fu_struct_cfu_get_version_rsp_component_get_component_id(const FuStructCfuGetVersionRspComponent *st)
339
0
{
340
0
    g_return_val_if_fail(st != NULL, 0x0);
341
0
    return st->buf->data[5];
342
0
}
343
344
/* setters */
345
/**
346
 * fu_struct_cfu_get_version_rsp_component_set_fw_version: (skip):
347
 **/
348
void
349
fu_struct_cfu_get_version_rsp_component_set_fw_version(FuStructCfuGetVersionRspComponent *st, guint32 value)
350
0
{
351
0
    g_return_if_fail(st != NULL);
352
0
    fu_memwrite_uint32(st->buf->data + 0, value, G_LITTLE_ENDIAN);
353
0
}
354
/**
355
 * fu_struct_cfu_get_version_rsp_component_set_flags: (skip):
356
 **/
357
void
358
fu_struct_cfu_get_version_rsp_component_set_flags(FuStructCfuGetVersionRspComponent *st, guint8 value)
359
0
{
360
0
    g_return_if_fail(st != NULL);
361
0
    st->buf->data[4] = value;
362
0
}
363
/**
364
 * fu_struct_cfu_get_version_rsp_component_set_component_id: (skip):
365
 **/
366
void
367
fu_struct_cfu_get_version_rsp_component_set_component_id(FuStructCfuGetVersionRspComponent *st, guint8 value)
368
0
{
369
0
    g_return_if_fail(st != NULL);
370
0
    st->buf->data[5] = value;
371
0
}
372
/**
373
 * fu_struct_cfu_get_version_rsp_component_new: (skip):
374
 **/
375
FuStructCfuGetVersionRspComponent *
376
fu_struct_cfu_get_version_rsp_component_new(void)
377
0
{
378
0
    FuStructCfuGetVersionRspComponent *st = fu_struct_cfu_get_version_rsp_component_new_internal();
379
0
    st->buf = g_byte_array_sized_new(8);
380
0
    fu_byte_array_set_size(st->buf, 8, 0x0);
381
0
    return st;
382
0
}
383
/**
384
 * fu_struct_cfu_get_version_rsp_component_to_string: (skip):
385
 **/
386
static gchar *
387
fu_struct_cfu_get_version_rsp_component_to_string(const FuStructCfuGetVersionRspComponent *st)
388
0
{
389
0
    g_autoptr(GString) str = g_string_new("FuStructCfuGetVersionRspComponent:\n");
390
0
    g_return_val_if_fail(st != NULL, NULL);
391
0
    g_string_append_printf(str, "  fw_version: 0x%x\n",
392
0
                           (guint) fu_struct_cfu_get_version_rsp_component_get_fw_version(st));
393
0
    g_string_append_printf(str, "  flags: 0x%x\n",
394
0
                           (guint) fu_struct_cfu_get_version_rsp_component_get_flags(st));
395
0
    g_string_append_printf(str, "  component_id: 0x%x\n",
396
0
                           (guint) fu_struct_cfu_get_version_rsp_component_get_component_id(st));
397
0
    if (str->len > 0)
398
0
        g_string_set_size(str, str->len - 1);
399
0
    return g_string_free(g_steal_pointer(&str), FALSE);
400
0
}
401
static gboolean
402
fu_struct_cfu_get_version_rsp_component_validate_internal(FuStructCfuGetVersionRspComponent *st, GError **error)
403
0
{
404
0
    g_return_val_if_fail(st != NULL, FALSE);
405
0
    return TRUE;
406
0
}
407
static gboolean
408
fu_struct_cfu_get_version_rsp_component_parse_internal(FuStructCfuGetVersionRspComponent *st, GError **error)
409
0
{
410
0
    if (g_getenv("FWUPD_VERBOSE") != NULL) {
411
0
        g_autofree gchar *str = fu_struct_cfu_get_version_rsp_component_to_string(st);
412
0
        g_debug("%s", str);
413
0
    }
414
0
    if (!fu_struct_cfu_get_version_rsp_component_validate_internal(st, error))
415
0
        return FALSE;
416
0
    return TRUE;
417
0
}
418
419
/**
420
 * fu_struct_cfu_get_version_rsp_component_parse: (skip):
421
 **/
422
FuStructCfuGetVersionRspComponent *
423
fu_struct_cfu_get_version_rsp_component_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
424
0
{
425
0
    g_autoptr(FuStructCfuGetVersionRspComponent) st = fu_struct_cfu_get_version_rsp_component_new_internal();
426
0
    g_return_val_if_fail(buf != NULL, NULL);
427
0
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
428
0
    if (!fu_memchk_read(bufsz, offset, 8, error)) {
429
0
        g_prefix_error_literal(error, "invalid struct FuStructCfuGetVersionRspComponent: ");
430
0
        return NULL;
431
0
    }
432
0
    st->buf = g_byte_array_new();
433
0
    g_byte_array_append(st->buf, buf + offset, 8);
434
0
    if (!fu_struct_cfu_get_version_rsp_component_parse_internal(st, error))
435
0
        return NULL;
436
0
    return g_steal_pointer(&st);
437
0
}
438
/**
439
 * fu_struct_cfu_offer_info_req_ref: (skip):
440
 **/
441
FuStructCfuOfferInfoReq *
442
fu_struct_cfu_offer_info_req_ref(FuStructCfuOfferInfoReq *st)
443
0
{
444
0
    g_return_val_if_fail(st != NULL, NULL);
445
0
    st->refcount++;
446
0
    return st;
447
0
}
448
/**
449
 * fu_struct_cfu_offer_info_req_unref: (skip):
450
 **/
451
void
452
fu_struct_cfu_offer_info_req_unref(FuStructCfuOfferInfoReq *st)
453
0
{
454
0
    g_return_if_fail(st != NULL);
455
0
    if (st->refcount == 0) {
456
0
        g_critical("FuStructCfuOfferInfoReq refcount already zero");
457
0
        return;
458
0
    }
459
0
    if (--st->refcount > 0)
460
0
        return;
461
0
    if (st->buf != NULL)
462
0
        g_byte_array_unref(st->buf);
463
0
    g_free(st);
464
0
}
465
/**
466
 * fu_struct_cfu_offer_info_req_new_internal: (skip):
467
 **/
468
static FuStructCfuOfferInfoReq *
469
fu_struct_cfu_offer_info_req_new_internal(void)
470
0
{
471
0
    FuStructCfuOfferInfoReq *st = g_new0(FuStructCfuOfferInfoReq, 1);
472
0
    st->refcount = 1;
473
0
    return st;
474
0
}
475
476
/* getters */
477
478
/* setters */
479
/**
480
 * fu_struct_cfu_offer_info_req_set_code: (skip):
481
 **/
482
void
483
fu_struct_cfu_offer_info_req_set_code(FuStructCfuOfferInfoReq *st, FuCfuOfferInfoCode value)
484
0
{
485
0
    g_return_if_fail(st != NULL);
486
0
    st->buf->data[0] = value;
487
0
}
488
/**
489
 * fu_struct_cfu_offer_info_req_set_component_id: (skip):
490
 **/
491
static void
492
fu_struct_cfu_offer_info_req_set_component_id(FuStructCfuOfferInfoReq *st, guint8 value)
493
0
{
494
0
    g_return_if_fail(st != NULL);
495
0
    st->buf->data[2] = value;
496
0
}
497
/**
498
 * fu_struct_cfu_offer_info_req_set_token: (skip):
499
 **/
500
static void
501
fu_struct_cfu_offer_info_req_set_token(FuStructCfuOfferInfoReq *st, guint8 value)
502
0
{
503
0
    g_return_if_fail(st != NULL);
504
0
    st->buf->data[3] = value;
505
0
}
506
/**
507
 * fu_struct_cfu_offer_info_req_new: (skip):
508
 **/
509
FuStructCfuOfferInfoReq *
510
fu_struct_cfu_offer_info_req_new(void)
511
0
{
512
0
    FuStructCfuOfferInfoReq *st = fu_struct_cfu_offer_info_req_new_internal();
513
0
    st->buf = g_byte_array_sized_new(16);
514
0
    fu_byte_array_set_size(st->buf, 16, 0x0);
515
0
    fu_struct_cfu_offer_info_req_set_component_id(st, 0xFF);
516
0
    fu_struct_cfu_offer_info_req_set_token(st, 0xDE);
517
0
    return st;
518
0
}
519
/**
520
 * fu_struct_cfu_offer_rsp_ref: (skip):
521
 **/
522
FuStructCfuOfferRsp *
523
fu_struct_cfu_offer_rsp_ref(FuStructCfuOfferRsp *st)
524
0
{
525
0
    g_return_val_if_fail(st != NULL, NULL);
526
0
    st->refcount++;
527
0
    return st;
528
0
}
529
/**
530
 * fu_struct_cfu_offer_rsp_unref: (skip):
531
 **/
532
void
533
fu_struct_cfu_offer_rsp_unref(FuStructCfuOfferRsp *st)
534
0
{
535
0
    g_return_if_fail(st != NULL);
536
0
    if (st->refcount == 0) {
537
0
        g_critical("FuStructCfuOfferRsp refcount already zero");
538
0
        return;
539
0
    }
540
0
    if (--st->refcount > 0)
541
0
        return;
542
0
    if (st->buf != NULL)
543
0
        g_byte_array_unref(st->buf);
544
0
    g_free(st);
545
0
}
546
/**
547
 * fu_struct_cfu_offer_rsp_new_internal: (skip):
548
 **/
549
static FuStructCfuOfferRsp *
550
fu_struct_cfu_offer_rsp_new_internal(void)
551
0
{
552
0
    FuStructCfuOfferRsp *st = g_new0(FuStructCfuOfferRsp, 1);
553
0
    st->refcount = 1;
554
0
    return st;
555
0
}
556
557
/* getters */
558
/**
559
 * fu_struct_cfu_offer_rsp_get_token: (skip):
560
 **/
561
guint8
562
fu_struct_cfu_offer_rsp_get_token(const FuStructCfuOfferRsp *st)
563
0
{
564
0
    g_return_val_if_fail(st != NULL, 0x0);
565
0
    return st->buf->data[3];
566
0
}
567
/**
568
 * fu_struct_cfu_offer_rsp_get_rr_code: (skip):
569
 **/
570
FuCfuRrCode
571
fu_struct_cfu_offer_rsp_get_rr_code(const FuStructCfuOfferRsp *st)
572
0
{
573
0
    g_return_val_if_fail(st != NULL, 0x0);
574
0
    return st->buf->data[8];
575
0
}
576
/**
577
 * fu_struct_cfu_offer_rsp_get_status: (skip):
578
 **/
579
FuCfuOfferStatus
580
fu_struct_cfu_offer_rsp_get_status(const FuStructCfuOfferRsp *st)
581
0
{
582
0
    g_return_val_if_fail(st != NULL, 0x0);
583
0
    return st->buf->data[12];
584
0
}
585
586
/* setters */
587
/**
588
 * fu_struct_cfu_offer_rsp_to_string: (skip):
589
 **/
590
static gchar *
591
fu_struct_cfu_offer_rsp_to_string(const FuStructCfuOfferRsp *st)
592
0
{
593
0
    g_autoptr(GString) str = g_string_new("FuStructCfuOfferRsp:\n");
594
0
    g_return_val_if_fail(st != NULL, NULL);
595
0
    g_string_append_printf(str, "  token: 0x%x\n",
596
0
                           (guint) fu_struct_cfu_offer_rsp_get_token(st));
597
0
    {
598
0
        const gchar *tmp = fu_cfu_rr_code_to_string(fu_struct_cfu_offer_rsp_get_rr_code(st));
599
0
        if (tmp != NULL) {
600
0
            g_string_append_printf(str, "  rr_code: 0x%x [%s]\n", (guint) fu_struct_cfu_offer_rsp_get_rr_code(st), tmp);
601
0
        } else {
602
0
            g_string_append_printf(str, "  rr_code: 0x%x\n", (guint) fu_struct_cfu_offer_rsp_get_rr_code(st));
603
0
        }
604
0
    }
605
0
    {
606
0
        const gchar *tmp = fu_cfu_offer_status_to_string(fu_struct_cfu_offer_rsp_get_status(st));
607
0
        if (tmp != NULL) {
608
0
            g_string_append_printf(str, "  status: 0x%x [%s]\n", (guint) fu_struct_cfu_offer_rsp_get_status(st), tmp);
609
0
        } else {
610
0
            g_string_append_printf(str, "  status: 0x%x\n", (guint) fu_struct_cfu_offer_rsp_get_status(st));
611
0
        }
612
0
    }
613
0
    if (str->len > 0)
614
0
        g_string_set_size(str, str->len - 1);
615
0
    return g_string_free(g_steal_pointer(&str), FALSE);
616
0
}
617
static gboolean
618
fu_struct_cfu_offer_rsp_validate_internal(FuStructCfuOfferRsp *st, GError **error)
619
0
{
620
0
    g_return_val_if_fail(st != NULL, FALSE);
621
0
    return TRUE;
622
0
}
623
static gboolean
624
fu_struct_cfu_offer_rsp_parse_internal(FuStructCfuOfferRsp *st, GError **error)
625
0
{
626
0
    if (g_getenv("FWUPD_VERBOSE") != NULL) {
627
0
        g_autofree gchar *str = fu_struct_cfu_offer_rsp_to_string(st);
628
0
        g_debug("%s", str);
629
0
    }
630
0
    if (!fu_struct_cfu_offer_rsp_validate_internal(st, error))
631
0
        return FALSE;
632
0
    return TRUE;
633
0
}
634
635
/**
636
 * fu_struct_cfu_offer_rsp_parse: (skip):
637
 **/
638
FuStructCfuOfferRsp *
639
fu_struct_cfu_offer_rsp_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
640
0
{
641
0
    g_autoptr(FuStructCfuOfferRsp) st = fu_struct_cfu_offer_rsp_new_internal();
642
0
    g_return_val_if_fail(buf != NULL, NULL);
643
0
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
644
0
    if (!fu_memchk_read(bufsz, offset, 16, error)) {
645
0
        g_prefix_error_literal(error, "invalid struct FuStructCfuOfferRsp: ");
646
0
        return NULL;
647
0
    }
648
0
    st->buf = g_byte_array_new();
649
0
    g_byte_array_append(st->buf, buf + offset, 16);
650
0
    if (!fu_struct_cfu_offer_rsp_parse_internal(st, error))
651
0
        return NULL;
652
0
    return g_steal_pointer(&st);
653
0
}
654
/**
655
 * fu_struct_cfu_content_req_ref: (skip):
656
 **/
657
FuStructCfuContentReq *
658
fu_struct_cfu_content_req_ref(FuStructCfuContentReq *st)
659
0
{
660
0
    g_return_val_if_fail(st != NULL, NULL);
661
0
    st->refcount++;
662
0
    return st;
663
0
}
664
/**
665
 * fu_struct_cfu_content_req_unref: (skip):
666
 **/
667
void
668
fu_struct_cfu_content_req_unref(FuStructCfuContentReq *st)
669
0
{
670
0
    g_return_if_fail(st != NULL);
671
0
    if (st->refcount == 0) {
672
0
        g_critical("FuStructCfuContentReq refcount already zero");
673
0
        return;
674
0
    }
675
0
    if (--st->refcount > 0)
676
0
        return;
677
0
    if (st->buf != NULL)
678
0
        g_byte_array_unref(st->buf);
679
0
    g_free(st);
680
0
}
681
/**
682
 * fu_struct_cfu_content_req_new_internal: (skip):
683
 **/
684
static FuStructCfuContentReq *
685
fu_struct_cfu_content_req_new_internal(void)
686
0
{
687
0
    FuStructCfuContentReq *st = g_new0(FuStructCfuContentReq, 1);
688
0
    st->refcount = 1;
689
0
    return st;
690
0
}
691
692
/* getters */
693
/**
694
 * fu_struct_cfu_content_req_get_flags: (skip):
695
 **/
696
FuCfuContentFlags
697
fu_struct_cfu_content_req_get_flags(const FuStructCfuContentReq *st)
698
0
{
699
0
    g_return_val_if_fail(st != NULL, 0x0);
700
0
    return st->buf->data[0];
701
0
}
702
/**
703
 * fu_struct_cfu_content_req_get_data_length: (skip):
704
 **/
705
guint8
706
fu_struct_cfu_content_req_get_data_length(const FuStructCfuContentReq *st)
707
0
{
708
0
    g_return_val_if_fail(st != NULL, 0x0);
709
0
    return st->buf->data[1];
710
0
}
711
/**
712
 * fu_struct_cfu_content_req_get_seq_number: (skip):
713
 **/
714
guint16
715
fu_struct_cfu_content_req_get_seq_number(const FuStructCfuContentReq *st)
716
0
{
717
0
    g_return_val_if_fail(st != NULL, 0x0);
718
0
    return fu_memread_uint16(st->buf->data + 2, G_LITTLE_ENDIAN);
719
0
}
720
/**
721
 * fu_struct_cfu_content_req_get_address: (skip):
722
 **/
723
guint32
724
fu_struct_cfu_content_req_get_address(const FuStructCfuContentReq *st)
725
0
{
726
0
    g_return_val_if_fail(st != NULL, 0x0);
727
0
    return fu_memread_uint32(st->buf->data + 4, G_LITTLE_ENDIAN);
728
0
}
729
730
/* setters */
731
/**
732
 * fu_struct_cfu_content_req_set_flags: (skip):
733
 **/
734
void
735
fu_struct_cfu_content_req_set_flags(FuStructCfuContentReq *st, FuCfuContentFlags value)
736
0
{
737
0
    g_return_if_fail(st != NULL);
738
0
    st->buf->data[0] = value;
739
0
}
740
/**
741
 * fu_struct_cfu_content_req_set_data_length: (skip):
742
 **/
743
void
744
fu_struct_cfu_content_req_set_data_length(FuStructCfuContentReq *st, guint8 value)
745
0
{
746
0
    g_return_if_fail(st != NULL);
747
0
    st->buf->data[1] = value;
748
0
}
749
/**
750
 * fu_struct_cfu_content_req_set_seq_number: (skip):
751
 **/
752
void
753
fu_struct_cfu_content_req_set_seq_number(FuStructCfuContentReq *st, guint16 value)
754
0
{
755
0
    g_return_if_fail(st != NULL);
756
0
    fu_memwrite_uint16(st->buf->data + 2, value, G_LITTLE_ENDIAN);
757
0
}
758
/**
759
 * fu_struct_cfu_content_req_set_address: (skip):
760
 **/
761
void
762
fu_struct_cfu_content_req_set_address(FuStructCfuContentReq *st, guint32 value)
763
0
{
764
0
    g_return_if_fail(st != NULL);
765
0
    fu_memwrite_uint32(st->buf->data + 4, value, G_LITTLE_ENDIAN);
766
0
}
767
/**
768
 * fu_struct_cfu_content_req_new: (skip):
769
 **/
770
FuStructCfuContentReq *
771
fu_struct_cfu_content_req_new(void)
772
0
{
773
0
    FuStructCfuContentReq *st = fu_struct_cfu_content_req_new_internal();
774
0
    st->buf = g_byte_array_sized_new(8);
775
0
    fu_byte_array_set_size(st->buf, 8, 0x0);
776
0
    return st;
777
0
}
778
/**
779
 * fu_struct_cfu_content_rsp_ref: (skip):
780
 **/
781
FuStructCfuContentRsp *
782
fu_struct_cfu_content_rsp_ref(FuStructCfuContentRsp *st)
783
0
{
784
0
    g_return_val_if_fail(st != NULL, NULL);
785
0
    st->refcount++;
786
0
    return st;
787
0
}
788
/**
789
 * fu_struct_cfu_content_rsp_unref: (skip):
790
 **/
791
void
792
fu_struct_cfu_content_rsp_unref(FuStructCfuContentRsp *st)
793
0
{
794
0
    g_return_if_fail(st != NULL);
795
0
    if (st->refcount == 0) {
796
0
        g_critical("FuStructCfuContentRsp refcount already zero");
797
0
        return;
798
0
    }
799
0
    if (--st->refcount > 0)
800
0
        return;
801
0
    if (st->buf != NULL)
802
0
        g_byte_array_unref(st->buf);
803
0
    g_free(st);
804
0
}
805
/**
806
 * fu_struct_cfu_content_rsp_new_internal: (skip):
807
 **/
808
static FuStructCfuContentRsp *
809
fu_struct_cfu_content_rsp_new_internal(void)
810
0
{
811
0
    FuStructCfuContentRsp *st = g_new0(FuStructCfuContentRsp, 1);
812
0
    st->refcount = 1;
813
0
    return st;
814
0
}
815
816
/* getters */
817
/**
818
 * fu_struct_cfu_content_rsp_get_seq_number: (skip):
819
 **/
820
guint16
821
fu_struct_cfu_content_rsp_get_seq_number(const FuStructCfuContentRsp *st)
822
0
{
823
0
    g_return_val_if_fail(st != NULL, 0x0);
824
0
    return fu_memread_uint16(st->buf->data + 0, G_LITTLE_ENDIAN);
825
0
}
826
/**
827
 * fu_struct_cfu_content_rsp_get_status: (skip):
828
 **/
829
FuCfuContentStatus
830
fu_struct_cfu_content_rsp_get_status(const FuStructCfuContentRsp *st)
831
0
{
832
0
    g_return_val_if_fail(st != NULL, 0x0);
833
0
    return st->buf->data[4];
834
0
}
835
836
/* setters */
837
/**
838
 * fu_struct_cfu_content_rsp_to_string: (skip):
839
 **/
840
static gchar *
841
fu_struct_cfu_content_rsp_to_string(const FuStructCfuContentRsp *st)
842
0
{
843
0
    g_autoptr(GString) str = g_string_new("FuStructCfuContentRsp:\n");
844
0
    g_return_val_if_fail(st != NULL, NULL);
845
0
    g_string_append_printf(str, "  seq_number: 0x%x\n",
846
0
                           (guint) fu_struct_cfu_content_rsp_get_seq_number(st));
847
0
    {
848
0
        const gchar *tmp = fu_cfu_content_status_to_string(fu_struct_cfu_content_rsp_get_status(st));
849
0
        if (tmp != NULL) {
850
0
            g_string_append_printf(str, "  status: 0x%x [%s]\n", (guint) fu_struct_cfu_content_rsp_get_status(st), tmp);
851
0
        } else {
852
0
            g_string_append_printf(str, "  status: 0x%x\n", (guint) fu_struct_cfu_content_rsp_get_status(st));
853
0
        }
854
0
    }
855
0
    if (str->len > 0)
856
0
        g_string_set_size(str, str->len - 1);
857
0
    return g_string_free(g_steal_pointer(&str), FALSE);
858
0
}
859
static gboolean
860
fu_struct_cfu_content_rsp_validate_internal(FuStructCfuContentRsp *st, GError **error)
861
0
{
862
0
    g_return_val_if_fail(st != NULL, FALSE);
863
0
    return TRUE;
864
0
}
865
static gboolean
866
fu_struct_cfu_content_rsp_parse_internal(FuStructCfuContentRsp *st, GError **error)
867
0
{
868
0
    if (g_getenv("FWUPD_VERBOSE") != NULL) {
869
0
        g_autofree gchar *str = fu_struct_cfu_content_rsp_to_string(st);
870
0
        g_debug("%s", str);
871
0
    }
872
0
    if (!fu_struct_cfu_content_rsp_validate_internal(st, error))
873
0
        return FALSE;
874
0
    return TRUE;
875
0
}
876
877
/**
878
 * fu_struct_cfu_content_rsp_parse: (skip):
879
 **/
880
FuStructCfuContentRsp *
881
fu_struct_cfu_content_rsp_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
882
0
{
883
0
    g_autoptr(FuStructCfuContentRsp) st = fu_struct_cfu_content_rsp_new_internal();
884
0
    g_return_val_if_fail(buf != NULL, NULL);
885
0
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
886
0
    if (!fu_memchk_read(bufsz, offset, 16, error)) {
887
0
        g_prefix_error_literal(error, "invalid struct FuStructCfuContentRsp: ");
888
0
        return NULL;
889
0
    }
890
0
    st->buf = g_byte_array_new();
891
0
    g_byte_array_append(st->buf, buf + offset, 16);
892
0
    if (!fu_struct_cfu_content_rsp_parse_internal(st, error))
893
0
        return NULL;
894
0
    return g_steal_pointer(&st);
895
0
}