Coverage Report

Created: 2026-06-15 06:54

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