Coverage Report

Created: 2026-02-26 06:27

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
158
{
34
158
    if (val == FU_REDFISH_INTERFACE_TYPE_USB_NETWORK)
35
9
        return "usb-network";
36
149
    if (val == FU_REDFISH_INTERFACE_TYPE_PCI_NETWORK)
37
12
        return "pci-network";
38
137
    if (val == FU_REDFISH_INTERFACE_TYPE_USB_NETWORK_V2)
39
35
        return "usb-network-v2";
40
102
    if (val == FU_REDFISH_INTERFACE_TYPE_PCI_NETWORK_V2)
41
42
        return "pci-network-v2";
42
60
    return NULL;
43
102
}
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.70k
{
134
1.70k
    g_return_if_fail(st != NULL);
135
1.70k
    if (st->refcount == 0) {
136
0
        g_critical("FuStructRedfishProtocolOverIp refcount already zero");
137
0
        return;
138
0
    }
139
1.70k
    if (--st->refcount > 0)
140
0
        return;
141
1.70k
    if (st->buf != NULL)
142
1.70k
        g_byte_array_unref(st->buf);
143
1.70k
    g_free(st);
144
1.70k
}
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.70k
{
151
1.70k
    FuStructRedfishProtocolOverIp *st = g_new0(FuStructRedfishProtocolOverIp, 1);
152
1.70k
    st->refcount = 1;
153
1.70k
    return st;
154
1.70k
}
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.60k
{
221
1.60k
    g_return_val_if_fail(st != NULL, 0x0);
222
1.60k
    return st->buf->data[51];
223
1.60k
}
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.59k
{
230
1.59k
    g_return_val_if_fail(st != NULL, NULL);
231
1.59k
    if (bufsz != NULL)
232
0
        *bufsz = 16;
233
1.59k
    return st->buf->data + 52;
234
1.59k
}
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.60k
{
252
1.60k
    g_return_val_if_fail(st != NULL, 0x0);
253
1.60k
    return fu_memread_uint16(st->buf->data + 84, G_LITTLE_ENDIAN);
254
1.60k
}
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.59k
{
270
1.59k
    g_return_val_if_fail(st != NULL, 0x0);
271
1.59k
    return st->buf->data[90];
272
1.59k
}
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
54
{
331
54
    g_return_if_fail(st != NULL);
332
54
    st->buf->data[50] = value;
333
54
}
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
54
{
340
54
    g_return_if_fail(st != NULL);
341
54
    st->buf->data[51] = value;
342
54
}
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
54
{
371
54
    g_return_if_fail(st != NULL);
372
54
    fu_memwrite_uint16(st->buf->data + 84, value, G_LITTLE_ENDIAN);
373
54
}
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
54
{
389
54
    g_return_if_fail(st != NULL);
390
54
    st->buf->data[90] = value;
391
54
}
392
/**
393
 * fu_struct_redfish_protocol_over_ip_new: (skip):
394
 **/
395
FuStructRedfishProtocolOverIp *
396
fu_struct_redfish_protocol_over_ip_new(void)
397
54
{
398
54
    FuStructRedfishProtocolOverIp *st = fu_struct_redfish_protocol_over_ip_new_internal();
399
54
    st->buf = g_byte_array_sized_new(91);
400
54
    fu_byte_array_set_size(st->buf, 91, 0x0);
401
54
    return st;
402
54
}
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_validate_internal(FuStructRedfishProtocolOverIp *st, GError **error)
467
1.60k
{
468
1.60k
    g_return_val_if_fail(st != NULL, FALSE);
469
1.60k
    return TRUE;
470
1.60k
}
471
static gboolean
472
fu_struct_redfish_protocol_over_ip_parse_internal(FuStructRedfishProtocolOverIp *st, GError **error)
473
1.60k
{
474
1.60k
    if (g_getenv("FWUPD_VERBOSE") != NULL) {
475
0
        g_autofree gchar *str = fu_struct_redfish_protocol_over_ip_to_string(st);
476
0
        g_debug("%s", str);
477
0
    }
478
1.60k
    if (!fu_struct_redfish_protocol_over_ip_validate_internal(st, error))
479
0
        return FALSE;
480
1.60k
    return TRUE;
481
1.60k
}
482
/**
483
 * fu_struct_redfish_protocol_over_ip_parse_stream: (skip):
484
 **/
485
FuStructRedfishProtocolOverIp *
486
fu_struct_redfish_protocol_over_ip_parse_stream(GInputStream *stream, gsize offset, GError **error)
487
1.65k
{
488
1.65k
    g_autoptr(FuStructRedfishProtocolOverIp) st = fu_struct_redfish_protocol_over_ip_new_internal();
489
1.65k
    st->buf = fu_input_stream_read_byte_array(stream, offset, 91, NULL, error);
490
1.65k
    if (st->buf == NULL) {
491
5
        g_prefix_error(error, "FuStructRedfishProtocolOverIp failed read of 0x%x: ", (guint) 91);
492
5
        return NULL;
493
5
    }
494
1.65k
    if (st->buf->len != 91) {
495
49
        g_set_error(error,
496
49
                    FWUPD_ERROR,
497
49
                    FWUPD_ERROR_INVALID_DATA,
498
49
                    "FuStructRedfishProtocolOverIp requested 0x%x and got 0x%x",
499
49
                    (guint) 91,
500
49
                    (guint) st->buf->len);
501
49
        return NULL;
502
49
    }
503
1.60k
    if (!fu_struct_redfish_protocol_over_ip_parse_internal(st, error))
504
0
        return NULL;
505
1.60k
    return g_steal_pointer(&st);
506
1.60k
}
507
/**
508
 * fu_struct_redfish_smbios_type42_ref: (skip):
509
 **/
510
FuStructRedfishSmbiosType42 *
511
fu_struct_redfish_smbios_type42_ref(FuStructRedfishSmbiosType42 *st)
512
0
{
513
0
    g_return_val_if_fail(st != NULL, NULL);
514
0
    st->refcount++;
515
0
    return st;
516
0
}
517
/**
518
 * fu_struct_redfish_smbios_type42_unref: (skip):
519
 **/
520
void
521
fu_struct_redfish_smbios_type42_unref(FuStructRedfishSmbiosType42 *st)
522
385
{
523
385
    g_return_if_fail(st != NULL);
524
385
    if (st->refcount == 0) {
525
0
        g_critical("FuStructRedfishSmbiosType42 refcount already zero");
526
0
        return;
527
0
    }
528
385
    if (--st->refcount > 0)
529
0
        return;
530
385
    if (st->buf != NULL)
531
385
        g_byte_array_unref(st->buf);
532
385
    g_free(st);
533
385
}
534
/**
535
 * fu_struct_redfish_smbios_type42_new_internal: (skip):
536
 **/
537
static FuStructRedfishSmbiosType42 *
538
fu_struct_redfish_smbios_type42_new_internal(void)
539
385
{
540
385
    FuStructRedfishSmbiosType42 *st = g_new0(FuStructRedfishSmbiosType42, 1);
541
385
    st->refcount = 1;
542
385
    return st;
543
385
}
544
545
/* getters */
546
/**
547
 * fu_struct_redfish_smbios_type42_get_type: (skip):
548
 **/
549
static guint8
550
fu_struct_redfish_smbios_type42_get_type(const FuStructRedfishSmbiosType42 *st)
551
385
{
552
385
    g_return_val_if_fail(st != NULL, 0x0);
553
385
    return st->buf->data[0];
554
385
}
555
/**
556
 * fu_struct_redfish_smbios_type42_get_length: (skip):
557
 **/
558
guint8
559
fu_struct_redfish_smbios_type42_get_length(const FuStructRedfishSmbiosType42 *st)
560
434
{
561
434
    g_return_val_if_fail(st != NULL, 0x0);
562
434
    return st->buf->data[1];
563
434
}
564
/**
565
 * fu_struct_redfish_smbios_type42_get_handle: (skip):
566
 **/
567
guint16
568
fu_struct_redfish_smbios_type42_get_handle(const FuStructRedfishSmbiosType42 *st)
569
0
{
570
0
    g_return_val_if_fail(st != NULL, 0x0);
571
0
    return fu_memread_uint16(st->buf->data + 2, G_LITTLE_ENDIAN);
572
0
}
573
/**
574
 * fu_struct_redfish_smbios_type42_get_interface_type: (skip):
575
 **/
576
FuRedfishSmbiosInterfaceType
577
fu_struct_redfish_smbios_type42_get_interface_type(const FuStructRedfishSmbiosType42 *st)
578
277
{
579
277
    g_return_val_if_fail(st != NULL, 0x0);
580
277
    return st->buf->data[4];
581
277
}
582
/**
583
 * fu_struct_redfish_smbios_type42_get_data_length: (skip):
584
 **/
585
guint8
586
fu_struct_redfish_smbios_type42_get_data_length(const FuStructRedfishSmbiosType42 *st)
587
563
{
588
563
    g_return_val_if_fail(st != NULL, 0x0);
589
563
    return st->buf->data[5];
590
563
}
591
592
/* setters */
593
/**
594
 * fu_struct_redfish_smbios_type42_to_string: (skip):
595
 **/
596
static gchar *
597
fu_struct_redfish_smbios_type42_to_string(const FuStructRedfishSmbiosType42 *st)
598
0
{
599
0
    g_autoptr(GString) str = g_string_new("FuStructRedfishSmbiosType42:\n");
600
0
    g_return_val_if_fail(st != NULL, NULL);
601
0
    g_string_append_printf(str, "  type: 0x%x\n",
602
0
                           (guint) fu_struct_redfish_smbios_type42_get_type(st));
603
0
    g_string_append_printf(str, "  length: 0x%x\n",
604
0
                           (guint) fu_struct_redfish_smbios_type42_get_length(st));
605
0
    g_string_append_printf(str, "  handle: 0x%x\n",
606
0
                           (guint) fu_struct_redfish_smbios_type42_get_handle(st));
607
0
    {
608
0
        const gchar *tmp = fu_redfish_smbios_interface_type_to_string(fu_struct_redfish_smbios_type42_get_interface_type(st));
609
0
        if (tmp != NULL) {
610
0
            g_string_append_printf(str, "  interface_type: 0x%x [%s]\n", (guint) fu_struct_redfish_smbios_type42_get_interface_type(st), tmp);
611
0
        } else {
612
0
            g_string_append_printf(str, "  interface_type: 0x%x\n", (guint) fu_struct_redfish_smbios_type42_get_interface_type(st));
613
0
        }
614
0
    }
615
0
    g_string_append_printf(str, "  data_length: 0x%x\n",
616
0
                           (guint) fu_struct_redfish_smbios_type42_get_data_length(st));
617
0
    if (str->len > 0)
618
0
        g_string_set_size(str, str->len - 1);
619
0
    return g_string_free(g_steal_pointer(&str), FALSE);
620
0
}
621
static gboolean
622
fu_struct_redfish_smbios_type42_validate_internal(FuStructRedfishSmbiosType42 *st, GError **error)
623
385
{
624
385
    g_return_val_if_fail(st != NULL, FALSE);
625
385
    if (fu_struct_redfish_smbios_type42_get_type(st) != 42) {
626
25
        g_set_error_literal(error,
627
25
                            FWUPD_ERROR,
628
25
                            FWUPD_ERROR_INVALID_DATA,
629
25
                            "constant FuStructRedfishSmbiosType42.type was not valid");
630
25
        return FALSE;
631
25
    }
632
360
    return TRUE;
633
385
}
634
static gboolean
635
fu_struct_redfish_smbios_type42_parse_internal(FuStructRedfishSmbiosType42 *st, GError **error)
636
385
{
637
385
    if (g_getenv("FWUPD_VERBOSE") != NULL) {
638
0
        g_autofree gchar *str = fu_struct_redfish_smbios_type42_to_string(st);
639
0
        g_debug("%s", str);
640
0
    }
641
385
    if (!fu_struct_redfish_smbios_type42_validate_internal(st, error))
642
25
        return FALSE;
643
360
    return TRUE;
644
385
}
645
/**
646
 * fu_struct_redfish_smbios_type42_parse_stream: (skip):
647
 **/
648
FuStructRedfishSmbiosType42 *
649
fu_struct_redfish_smbios_type42_parse_stream(GInputStream *stream, gsize offset, GError **error)
650
385
{
651
385
    g_autoptr(FuStructRedfishSmbiosType42) st = fu_struct_redfish_smbios_type42_new_internal();
652
385
    st->buf = fu_input_stream_read_byte_array(stream, offset, 6, NULL, error);
653
385
    if (st->buf == NULL) {
654
0
        g_prefix_error(error, "FuStructRedfishSmbiosType42 failed read of 0x%x: ", (guint) 6);
655
0
        return NULL;
656
0
    }
657
385
    if (st->buf->len != 6) {
658
0
        g_set_error(error,
659
0
                    FWUPD_ERROR,
660
0
                    FWUPD_ERROR_INVALID_DATA,
661
0
                    "FuStructRedfishSmbiosType42 requested 0x%x and got 0x%x",
662
0
                    (guint) 6,
663
0
                    (guint) st->buf->len);
664
0
        return NULL;
665
0
    }
666
385
    if (!fu_struct_redfish_smbios_type42_parse_internal(st, error))
667
25
        return NULL;
668
360
    return g_steal_pointer(&st);
669
385
}