Coverage Report

Created: 2025-11-24 06:59

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