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