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