Coverage Report

Created: 2025-07-01 07:09

/work/fu-redfish-struct.c
Line
Count
Source (jump to first uncovered line)
1
/* auto-generated, do not modify */
2
#include "config.h"
3
4
#include "fu-redfish-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_redfish_interface_type_to_string(FuRedfishInterfaceType val)
16
173
{
17
173
    if (val == FU_REDFISH_INTERFACE_TYPE_USB_NETWORK)
18
16
        return "usb-network";
19
157
    if (val == FU_REDFISH_INTERFACE_TYPE_PCI_NETWORK)
20
13
        return "pci-network";
21
144
    if (val == FU_REDFISH_INTERFACE_TYPE_USB_NETWORK_V2)
22
33
        return "usb-network-v2";
23
111
    if (val == FU_REDFISH_INTERFACE_TYPE_PCI_NETWORK_V2)
24
36
        return "pci-network-v2";
25
75
    return NULL;
26
111
}
27
28
29
30
const gchar *
31
fu_redfish_smbios_interface_type_to_string(FuRedfishSmbiosInterfaceType val)
32
0
{
33
0
    if (val == FU_REDFISH_SMBIOS_INTERFACE_TYPE_UNKNOWN)
34
0
        return "unknown";
35
0
    if (val == FU_REDFISH_SMBIOS_INTERFACE_TYPE_KCS)
36
0
        return "kcs";
37
0
    if (val == FU_REDFISH_SMBIOS_INTERFACE_TYPE_8250_UART)
38
0
        return "8250-uart";
39
0
    if (val == FU_REDFISH_SMBIOS_INTERFACE_TYPE_16450_UART)
40
0
        return "16450-uart";
41
0
    if (val == FU_REDFISH_SMBIOS_INTERFACE_TYPE_16550_UART)
42
0
        return "16550-uart";
43
0
    if (val == FU_REDFISH_SMBIOS_INTERFACE_TYPE_16650_UART)
44
0
        return "16650-uart";
45
0
    if (val == FU_REDFISH_SMBIOS_INTERFACE_TYPE_16750_UART)
46
0
        return "16750-uart";
47
0
    if (val == FU_REDFISH_SMBIOS_INTERFACE_TYPE_16850_UART)
48
0
        return "16850-uart";
49
0
    if (val == FU_REDFISH_SMBIOS_INTERFACE_TYPE_MCTP)
50
0
        return "mctp";
51
0
    if (val == FU_REDFISH_SMBIOS_INTERFACE_TYPE_NETWORK)
52
0
        return "network";
53
0
    if (val == FU_REDFISH_SMBIOS_INTERFACE_TYPE_OEM)
54
0
        return "oem";
55
0
    return NULL;
56
0
}
57
58
const gchar *
59
fu_redfish_network_device_state_to_string(FuRedfishNetworkDeviceState val)
60
0
{
61
0
    if (val == FU_REDFISH_NETWORK_DEVICE_STATE_UNKNOWN)
62
0
        return "unknown";
63
0
    if (val == FU_REDFISH_NETWORK_DEVICE_STATE_UNMANAGED)
64
0
        return "unmanaged";
65
0
    if (val == FU_REDFISH_NETWORK_DEVICE_STATE_UNAVAILABLE)
66
0
        return "unavailable";
67
0
    if (val == FU_REDFISH_NETWORK_DEVICE_STATE_DISCONNECTED)
68
0
        return "disconnected";
69
0
    if (val == FU_REDFISH_NETWORK_DEVICE_STATE_PREPARE)
70
0
        return "prepare";
71
0
    if (val == FU_REDFISH_NETWORK_DEVICE_STATE_CONFIG)
72
0
        return "config";
73
0
    if (val == FU_REDFISH_NETWORK_DEVICE_STATE_NEED_AUTH)
74
0
        return "need-auth";
75
0
    if (val == FU_REDFISH_NETWORK_DEVICE_STATE_IP_CONFIG)
76
0
        return "ip-config";
77
0
    if (val == FU_REDFISH_NETWORK_DEVICE_STATE_IP_CHECK)
78
0
        return "ip-check";
79
0
    if (val == FU_REDFISH_NETWORK_DEVICE_STATE_SECONDARIES)
80
0
        return "secondaries";
81
0
    if (val == FU_REDFISH_NETWORK_DEVICE_STATE_ACTIVATED)
82
0
        return "activated";
83
0
    if (val == FU_REDFISH_NETWORK_DEVICE_STATE_DEACTIVATING)
84
0
        return "deactivating";
85
0
    if (val == FU_REDFISH_NETWORK_DEVICE_STATE_FAILED)
86
0
        return "failed";
87
0
    return NULL;
88
0
}
89
/* getters */
90
/**
91
 * fu_struct_redfish_protocol_over_ip_get_service_uuid: (skip):
92
 **/
93
const fwupd_guid_t *
94
fu_struct_redfish_protocol_over_ip_get_service_uuid(const FuStructRedfishProtocolOverIp *st)
95
0
{
96
0
    g_return_val_if_fail(st != NULL, NULL);
97
0
    return (const fwupd_guid_t *) (st->data + 0);
98
0
}
99
/**
100
 * fu_struct_redfish_protocol_over_ip_get_host_ip_assignment_type: (skip):
101
 **/
102
guint8
103
fu_struct_redfish_protocol_over_ip_get_host_ip_assignment_type(const FuStructRedfishProtocolOverIp *st)
104
0
{
105
0
    g_return_val_if_fail(st != NULL, 0x0);
106
0
    return st->data[16];
107
0
}
108
/**
109
 * fu_struct_redfish_protocol_over_ip_get_host_ip_address_format: (skip):
110
 **/
111
guint8
112
fu_struct_redfish_protocol_over_ip_get_host_ip_address_format(const FuStructRedfishProtocolOverIp *st)
113
0
{
114
0
    g_return_val_if_fail(st != NULL, 0x0);
115
0
    return st->data[17];
116
0
}
117
/**
118
 * fu_struct_redfish_protocol_over_ip_get_host_ip_address: (skip):
119
 **/
120
const guint8 *
121
fu_struct_redfish_protocol_over_ip_get_host_ip_address(const FuStructRedfishProtocolOverIp *st, gsize *bufsz)
122
0
{
123
0
    g_return_val_if_fail(st != NULL, NULL);
124
0
    if (bufsz != NULL)
125
0
        *bufsz = 16;
126
0
    return st->data + 18;
127
0
}
128
/**
129
 * fu_struct_redfish_protocol_over_ip_get_host_ip_mask: (skip):
130
 **/
131
const guint8 *
132
fu_struct_redfish_protocol_over_ip_get_host_ip_mask(const FuStructRedfishProtocolOverIp *st, gsize *bufsz)
133
0
{
134
0
    g_return_val_if_fail(st != NULL, NULL);
135
0
    if (bufsz != NULL)
136
0
        *bufsz = 16;
137
0
    return st->data + 34;
138
0
}
139
/**
140
 * fu_struct_redfish_protocol_over_ip_get_service_ip_assignment_type: (skip):
141
 **/
142
guint8
143
fu_struct_redfish_protocol_over_ip_get_service_ip_assignment_type(const FuStructRedfishProtocolOverIp *st)
144
0
{
145
0
    g_return_val_if_fail(st != NULL, 0x0);
146
0
    return st->data[50];
147
0
}
148
/**
149
 * fu_struct_redfish_protocol_over_ip_get_service_ip_address_format: (skip):
150
 **/
151
guint8
152
fu_struct_redfish_protocol_over_ip_get_service_ip_address_format(const FuStructRedfishProtocolOverIp *st)
153
1.47k
{
154
1.47k
    g_return_val_if_fail(st != NULL, 0x0);
155
1.47k
    return st->data[51];
156
1.47k
}
157
/**
158
 * fu_struct_redfish_protocol_over_ip_get_service_ip_address: (skip):
159
 **/
160
const guint8 *
161
fu_struct_redfish_protocol_over_ip_get_service_ip_address(const FuStructRedfishProtocolOverIp *st, gsize *bufsz)
162
1.46k
{
163
1.46k
    g_return_val_if_fail(st != NULL, NULL);
164
1.46k
    if (bufsz != NULL)
165
0
        *bufsz = 16;
166
1.46k
    return st->data + 52;
167
1.46k
}
168
/**
169
 * fu_struct_redfish_protocol_over_ip_get_service_ip_mask: (skip):
170
 **/
171
const guint8 *
172
fu_struct_redfish_protocol_over_ip_get_service_ip_mask(const FuStructRedfishProtocolOverIp *st, gsize *bufsz)
173
0
{
174
0
    g_return_val_if_fail(st != NULL, NULL);
175
0
    if (bufsz != NULL)
176
0
        *bufsz = 16;
177
0
    return st->data + 68;
178
0
}
179
/**
180
 * fu_struct_redfish_protocol_over_ip_get_service_ip_port: (skip):
181
 **/
182
guint16
183
fu_struct_redfish_protocol_over_ip_get_service_ip_port(const FuStructRedfishProtocolOverIp *st)
184
1.47k
{
185
1.47k
    g_return_val_if_fail(st != NULL, 0x0);
186
1.47k
    return fu_memread_uint16(st->data + 84, G_LITTLE_ENDIAN);
187
1.47k
}
188
/**
189
 * fu_struct_redfish_protocol_over_ip_get_service_ip_vlan_id: (skip):
190
 **/
191
guint32
192
fu_struct_redfish_protocol_over_ip_get_service_ip_vlan_id(const FuStructRedfishProtocolOverIp *st)
193
0
{
194
0
    g_return_val_if_fail(st != NULL, 0x0);
195
0
    return fu_memread_uint32(st->data + 86, G_LITTLE_ENDIAN);
196
0
}
197
/**
198
 * fu_struct_redfish_protocol_over_ip_get_service_hostname_len: (skip):
199
 **/
200
guint8
201
fu_struct_redfish_protocol_over_ip_get_service_hostname_len(const FuStructRedfishProtocolOverIp *st)
202
1.46k
{
203
1.46k
    g_return_val_if_fail(st != NULL, 0x0);
204
1.46k
    return st->data[90];
205
1.46k
}
206
207
/* setters */
208
/**
209
 * fu_struct_redfish_protocol_over_ip_set_service_uuid: (skip):
210
 **/
211
void
212
fu_struct_redfish_protocol_over_ip_set_service_uuid(FuStructRedfishProtocolOverIp *st, const fwupd_guid_t *value)
213
0
{
214
0
    g_return_if_fail(st != NULL);
215
0
    g_return_if_fail(value != NULL);
216
0
    memcpy(st->data + 0, value, sizeof(*value)); /* nocheck:blocked */
217
0
}
218
/**
219
 * fu_struct_redfish_protocol_over_ip_set_host_ip_assignment_type: (skip):
220
 **/
221
void
222
fu_struct_redfish_protocol_over_ip_set_host_ip_assignment_type(FuStructRedfishProtocolOverIp *st, guint8 value)
223
0
{
224
0
    g_return_if_fail(st != NULL);
225
0
    st->data[16] = value;
226
0
}
227
/**
228
 * fu_struct_redfish_protocol_over_ip_set_host_ip_address_format: (skip):
229
 **/
230
void
231
fu_struct_redfish_protocol_over_ip_set_host_ip_address_format(FuStructRedfishProtocolOverIp *st, guint8 value)
232
0
{
233
0
    g_return_if_fail(st != NULL);
234
0
    st->data[17] = value;
235
0
}
236
/**
237
 * fu_struct_redfish_protocol_over_ip_set_host_ip_address: (skip):
238
 **/
239
gboolean
240
fu_struct_redfish_protocol_over_ip_set_host_ip_address(FuStructRedfishProtocolOverIp *st, const guint8 *buf, gsize bufsz, GError **error)
241
0
{
242
0
    g_return_val_if_fail(st != NULL, FALSE);
243
0
    g_return_val_if_fail(buf != NULL, FALSE);
244
0
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
245
0
    return fu_memcpy_safe(st->data, st->len, 18, buf, bufsz, 0x0, bufsz, error);
246
0
}
247
/**
248
 * fu_struct_redfish_protocol_over_ip_set_host_ip_mask: (skip):
249
 **/
250
gboolean
251
fu_struct_redfish_protocol_over_ip_set_host_ip_mask(FuStructRedfishProtocolOverIp *st, const guint8 *buf, gsize bufsz, GError **error)
252
0
{
253
0
    g_return_val_if_fail(st != NULL, FALSE);
254
0
    g_return_val_if_fail(buf != NULL, FALSE);
255
0
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
256
0
    return fu_memcpy_safe(st->data, st->len, 34, buf, bufsz, 0x0, bufsz, error);
257
0
}
258
/**
259
 * fu_struct_redfish_protocol_over_ip_set_service_ip_assignment_type: (skip):
260
 **/
261
void
262
fu_struct_redfish_protocol_over_ip_set_service_ip_assignment_type(FuStructRedfishProtocolOverIp *st, guint8 value)
263
67
{
264
67
    g_return_if_fail(st != NULL);
265
67
    st->data[50] = value;
266
67
}
267
/**
268
 * fu_struct_redfish_protocol_over_ip_set_service_ip_address_format: (skip):
269
 **/
270
void
271
fu_struct_redfish_protocol_over_ip_set_service_ip_address_format(FuStructRedfishProtocolOverIp *st, guint8 value)
272
67
{
273
67
    g_return_if_fail(st != NULL);
274
67
    st->data[51] = value;
275
67
}
276
/**
277
 * fu_struct_redfish_protocol_over_ip_set_service_ip_address: (skip):
278
 **/
279
gboolean
280
fu_struct_redfish_protocol_over_ip_set_service_ip_address(FuStructRedfishProtocolOverIp *st, const guint8 *buf, gsize bufsz, GError **error)
281
0
{
282
0
    g_return_val_if_fail(st != NULL, FALSE);
283
0
    g_return_val_if_fail(buf != NULL, FALSE);
284
0
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
285
0
    return fu_memcpy_safe(st->data, st->len, 52, buf, bufsz, 0x0, bufsz, error);
286
0
}
287
/**
288
 * fu_struct_redfish_protocol_over_ip_set_service_ip_mask: (skip):
289
 **/
290
gboolean
291
fu_struct_redfish_protocol_over_ip_set_service_ip_mask(FuStructRedfishProtocolOverIp *st, const guint8 *buf, gsize bufsz, GError **error)
292
0
{
293
0
    g_return_val_if_fail(st != NULL, FALSE);
294
0
    g_return_val_if_fail(buf != NULL, FALSE);
295
0
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
296
0
    return fu_memcpy_safe(st->data, st->len, 68, buf, bufsz, 0x0, bufsz, error);
297
0
}
298
/**
299
 * fu_struct_redfish_protocol_over_ip_set_service_ip_port: (skip):
300
 **/
301
void
302
fu_struct_redfish_protocol_over_ip_set_service_ip_port(FuStructRedfishProtocolOverIp *st, guint16 value)
303
67
{
304
67
    g_return_if_fail(st != NULL);
305
67
    fu_memwrite_uint16(st->data + 84, value, G_LITTLE_ENDIAN);
306
67
}
307
/**
308
 * fu_struct_redfish_protocol_over_ip_set_service_ip_vlan_id: (skip):
309
 **/
310
void
311
fu_struct_redfish_protocol_over_ip_set_service_ip_vlan_id(FuStructRedfishProtocolOverIp *st, guint32 value)
312
0
{
313
0
    g_return_if_fail(st != NULL);
314
0
    fu_memwrite_uint32(st->data + 86, value, G_LITTLE_ENDIAN);
315
0
}
316
/**
317
 * fu_struct_redfish_protocol_over_ip_set_service_hostname_len: (skip):
318
 **/
319
void
320
fu_struct_redfish_protocol_over_ip_set_service_hostname_len(FuStructRedfishProtocolOverIp *st, guint8 value)
321
67
{
322
67
    g_return_if_fail(st != NULL);
323
67
    st->data[90] = value;
324
67
}
325
/**
326
 * fu_struct_redfish_protocol_over_ip_new: (skip):
327
 **/
328
FuStructRedfishProtocolOverIp *
329
fu_struct_redfish_protocol_over_ip_new(void)
330
67
{
331
67
    FuStructRedfishProtocolOverIp *st = g_byte_array_sized_new(91);
332
67
    fu_byte_array_set_size(st, 91, 0x0);
333
67
    return st;
334
67
}
335
/**
336
 * fu_struct_redfish_protocol_over_ip_to_string: (skip):
337
 **/
338
static gchar *
339
fu_struct_redfish_protocol_over_ip_to_string(const FuStructRedfishProtocolOverIp *st)
340
0
{
341
0
    g_autoptr(GString) str = g_string_new("FuStructRedfishProtocolOverIp:\n");
342
0
    g_return_val_if_fail(st != NULL, NULL);
343
0
    {
344
0
        g_autofree gchar *tmp = fwupd_guid_to_string(fu_struct_redfish_protocol_over_ip_get_service_uuid(st), FWUPD_GUID_FLAG_MIXED_ENDIAN);
345
0
        g_string_append_printf(str, "  service_uuid: %s\n", tmp);
346
0
    }
347
0
    g_string_append_printf(str, "  host_ip_assignment_type: 0x%x\n",
348
0
                           (guint) fu_struct_redfish_protocol_over_ip_get_host_ip_assignment_type(st));
349
0
    g_string_append_printf(str, "  host_ip_address_format: 0x%x\n",
350
0
                           (guint) fu_struct_redfish_protocol_over_ip_get_host_ip_address_format(st));
351
0
    {
352
0
        gsize bufsz = 0;
353
0
        const guint8 *buf = fu_struct_redfish_protocol_over_ip_get_host_ip_address(st, &bufsz);
354
0
        g_autoptr(GString) tmp = g_string_new(NULL);
355
0
        for (gsize i = 0; i < bufsz; i++)
356
0
            g_string_append_printf(tmp, "%02X", buf[i]);
357
0
        g_string_append_printf(str, "  host_ip_address: 0x%s\n", tmp->str);
358
0
    }
359
0
    {
360
0
        gsize bufsz = 0;
361
0
        const guint8 *buf = fu_struct_redfish_protocol_over_ip_get_host_ip_mask(st, &bufsz);
362
0
        g_autoptr(GString) tmp = g_string_new(NULL);
363
0
        for (gsize i = 0; i < bufsz; i++)
364
0
            g_string_append_printf(tmp, "%02X", buf[i]);
365
0
        g_string_append_printf(str, "  host_ip_mask: 0x%s\n", tmp->str);
366
0
    }
367
0
    g_string_append_printf(str, "  service_ip_assignment_type: 0x%x\n",
368
0
                           (guint) fu_struct_redfish_protocol_over_ip_get_service_ip_assignment_type(st));
369
0
    g_string_append_printf(str, "  service_ip_address_format: 0x%x\n",
370
0
                           (guint) fu_struct_redfish_protocol_over_ip_get_service_ip_address_format(st));
371
0
    {
372
0
        gsize bufsz = 0;
373
0
        const guint8 *buf = fu_struct_redfish_protocol_over_ip_get_service_ip_address(st, &bufsz);
374
0
        g_autoptr(GString) tmp = g_string_new(NULL);
375
0
        for (gsize i = 0; i < bufsz; i++)
376
0
            g_string_append_printf(tmp, "%02X", buf[i]);
377
0
        g_string_append_printf(str, "  service_ip_address: 0x%s\n", tmp->str);
378
0
    }
379
0
    {
380
0
        gsize bufsz = 0;
381
0
        const guint8 *buf = fu_struct_redfish_protocol_over_ip_get_service_ip_mask(st, &bufsz);
382
0
        g_autoptr(GString) tmp = g_string_new(NULL);
383
0
        for (gsize i = 0; i < bufsz; i++)
384
0
            g_string_append_printf(tmp, "%02X", buf[i]);
385
0
        g_string_append_printf(str, "  service_ip_mask: 0x%s\n", tmp->str);
386
0
    }
387
0
    g_string_append_printf(str, "  service_ip_port: 0x%x\n",
388
0
                           (guint) fu_struct_redfish_protocol_over_ip_get_service_ip_port(st));
389
0
    g_string_append_printf(str, "  service_ip_vlan_id: 0x%x\n",
390
0
                           (guint) fu_struct_redfish_protocol_over_ip_get_service_ip_vlan_id(st));
391
0
    g_string_append_printf(str, "  service_hostname_len: 0x%x\n",
392
0
                           (guint) fu_struct_redfish_protocol_over_ip_get_service_hostname_len(st));
393
0
    if (str->len > 0)
394
0
        g_string_set_size(str, str->len - 1);
395
0
    return g_string_free(g_steal_pointer(&str), FALSE);
396
0
}
397
static gboolean
398
fu_struct_redfish_protocol_over_ip_validate_internal(FuStructRedfishProtocolOverIp *st, GError **error)
399
1.47k
{
400
1.47k
    g_return_val_if_fail(st != NULL, FALSE);
401
1.47k
    return TRUE;
402
1.47k
}
403
static gboolean
404
fu_struct_redfish_protocol_over_ip_parse_internal(FuStructRedfishProtocolOverIp *st, GError **error)
405
1.47k
{
406
1.47k
    if (!fu_struct_redfish_protocol_over_ip_validate_internal(st, error))
407
0
        return FALSE;
408
1.47k
    if (g_getenv("FWUPD_VERBOSE") != NULL) {
409
0
        g_autofree gchar *str = fu_struct_redfish_protocol_over_ip_to_string(st);
410
0
        g_debug("%s", str);
411
0
    }
412
1.47k
    return TRUE;
413
1.47k
}
414
/**
415
 * fu_struct_redfish_protocol_over_ip_parse_stream: (skip):
416
 **/
417
FuStructRedfishProtocolOverIp *
418
fu_struct_redfish_protocol_over_ip_parse_stream(GInputStream *stream, gsize offset, GError **error)
419
1.53k
{
420
1.53k
    g_autoptr(GByteArray) st = NULL;
421
1.53k
    st = fu_input_stream_read_byte_array(stream, offset, 91, NULL, error);
422
1.53k
    if (st == NULL) {
423
10
        g_prefix_error(error, "FuStructRedfishProtocolOverIp failed read of 0x%x: ", (guint) 91);
424
10
        return NULL;
425
10
    }
426
1.52k
    if (st->len != 91) {
427
50
        g_set_error(error,
428
50
                    FWUPD_ERROR,
429
50
                    FWUPD_ERROR_INVALID_DATA,
430
50
                    "FuStructRedfishProtocolOverIp requested 0x%x and got 0x%x",
431
50
                    (guint) 91,
432
50
                    (guint) st->len);
433
50
        return NULL;
434
50
    }
435
1.47k
    if (!fu_struct_redfish_protocol_over_ip_parse_internal(st, error))
436
0
        return NULL;
437
1.47k
    return g_steal_pointer(&st);
438
1.47k
}
439
/* getters */
440
/**
441
 * fu_struct_redfish_smbios_type42_get_type: (skip):
442
 **/
443
static guint8
444
fu_struct_redfish_smbios_type42_get_type(const FuStructRedfishSmbiosType42 *st)
445
450
{
446
450
    g_return_val_if_fail(st != NULL, 0x0);
447
450
    return st->data[0];
448
450
}
449
/**
450
 * fu_struct_redfish_smbios_type42_get_length: (skip):
451
 **/
452
guint8
453
fu_struct_redfish_smbios_type42_get_length(const FuStructRedfishSmbiosType42 *st)
454
490
{
455
490
    g_return_val_if_fail(st != NULL, 0x0);
456
490
    return st->data[1];
457
490
}
458
/**
459
 * fu_struct_redfish_smbios_type42_get_handle: (skip):
460
 **/
461
guint16
462
fu_struct_redfish_smbios_type42_get_handle(const FuStructRedfishSmbiosType42 *st)
463
0
{
464
0
    g_return_val_if_fail(st != NULL, 0x0);
465
0
    return fu_memread_uint16(st->data + 2, G_LITTLE_ENDIAN);
466
0
}
467
/**
468
 * fu_struct_redfish_smbios_type42_get_interface_type: (skip):
469
 **/
470
FuRedfishSmbiosInterfaceType
471
fu_struct_redfish_smbios_type42_get_interface_type(const FuStructRedfishSmbiosType42 *st)
472
306
{
473
306
    g_return_val_if_fail(st != NULL, 0x0);
474
306
    return st->data[4];
475
306
}
476
/**
477
 * fu_struct_redfish_smbios_type42_get_data_length: (skip):
478
 **/
479
guint8
480
fu_struct_redfish_smbios_type42_get_data_length(const FuStructRedfishSmbiosType42 *st)
481
624
{
482
624
    g_return_val_if_fail(st != NULL, 0x0);
483
624
    return st->data[5];
484
624
}
485
486
/* setters */
487
/**
488
 * fu_struct_redfish_smbios_type42_to_string: (skip):
489
 **/
490
static gchar *
491
fu_struct_redfish_smbios_type42_to_string(const FuStructRedfishSmbiosType42 *st)
492
0
{
493
0
    g_autoptr(GString) str = g_string_new("FuStructRedfishSmbiosType42:\n");
494
0
    g_return_val_if_fail(st != NULL, NULL);
495
0
    g_string_append_printf(str, "  length: 0x%x\n",
496
0
                           (guint) fu_struct_redfish_smbios_type42_get_length(st));
497
0
    g_string_append_printf(str, "  handle: 0x%x\n",
498
0
                           (guint) fu_struct_redfish_smbios_type42_get_handle(st));
499
0
    {
500
0
        const gchar *tmp = fu_redfish_smbios_interface_type_to_string(fu_struct_redfish_smbios_type42_get_interface_type(st));
501
0
        if (tmp != NULL) {
502
0
            g_string_append_printf(str, "  interface_type: 0x%x [%s]\n", (guint) fu_struct_redfish_smbios_type42_get_interface_type(st), tmp);
503
0
        } else {
504
0
            g_string_append_printf(str, "  interface_type: 0x%x\n", (guint) fu_struct_redfish_smbios_type42_get_interface_type(st));
505
0
        }
506
0
    }
507
0
    g_string_append_printf(str, "  data_length: 0x%x\n",
508
0
                           (guint) fu_struct_redfish_smbios_type42_get_data_length(st));
509
0
    if (str->len > 0)
510
0
        g_string_set_size(str, str->len - 1);
511
0
    return g_string_free(g_steal_pointer(&str), FALSE);
512
0
}
513
static gboolean
514
fu_struct_redfish_smbios_type42_validate_internal(FuStructRedfishSmbiosType42 *st, GError **error)
515
450
{
516
450
    g_return_val_if_fail(st != NULL, FALSE);
517
450
    if (fu_struct_redfish_smbios_type42_get_type(st) != 42) {
518
46
        g_set_error_literal(error,
519
46
                            FWUPD_ERROR,
520
46
                            FWUPD_ERROR_INVALID_DATA,
521
46
                            "constant FuStructRedfishSmbiosType42.type was not valid");
522
46
        return FALSE;
523
46
    }
524
404
    return TRUE;
525
450
}
526
static gboolean
527
fu_struct_redfish_smbios_type42_parse_internal(FuStructRedfishSmbiosType42 *st, GError **error)
528
450
{
529
450
    if (!fu_struct_redfish_smbios_type42_validate_internal(st, error))
530
46
        return FALSE;
531
404
    if (g_getenv("FWUPD_VERBOSE") != NULL) {
532
0
        g_autofree gchar *str = fu_struct_redfish_smbios_type42_to_string(st);
533
0
        g_debug("%s", str);
534
0
    }
535
404
    return TRUE;
536
450
}
537
/**
538
 * fu_struct_redfish_smbios_type42_parse_stream: (skip):
539
 **/
540
FuStructRedfishSmbiosType42 *
541
fu_struct_redfish_smbios_type42_parse_stream(GInputStream *stream, gsize offset, GError **error)
542
450
{
543
450
    g_autoptr(GByteArray) st = NULL;
544
450
    st = fu_input_stream_read_byte_array(stream, offset, 6, NULL, error);
545
450
    if (st == NULL) {
546
0
        g_prefix_error(error, "FuStructRedfishSmbiosType42 failed read of 0x%x: ", (guint) 6);
547
0
        return NULL;
548
0
    }
549
450
    if (st->len != 6) {
550
0
        g_set_error(error,
551
0
                    FWUPD_ERROR,
552
0
                    FWUPD_ERROR_INVALID_DATA,
553
0
                    "FuStructRedfishSmbiosType42 requested 0x%x and got 0x%x",
554
0
                    (guint) 6,
555
0
                    (guint) st->len);
556
0
        return NULL;
557
0
    }
558
450
    if (!fu_struct_redfish_smbios_type42_parse_internal(st, error))
559
46
        return NULL;
560
404
    return g_steal_pointer(&st);
561
450
}