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