/work/fu-genesys-usbhub-struct.c
Line | Count | Source |
1 | | /* auto-generated, do not modify */ |
2 | | #include "config.h" |
3 | | |
4 | | #include <glib.h> |
5 | | |
6 | | #include "fu-genesys-usbhub-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 | | const gchar * |
17 | | fu_genesys_ts_version_to_string(FuGenesysTsVersion val) |
18 | 0 | { |
19 | 0 | if (val == FU_GENESYS_TS_VERSION_DYNAMIC_9_BYTE) |
20 | 0 | return "dynamic-9-byte"; |
21 | 0 | if (val == FU_GENESYS_TS_VERSION_BONDING) |
22 | 0 | return "bonding"; |
23 | 0 | if (val == FU_GENESYS_TS_VERSION_BONDING_QC) |
24 | 0 | return "bonding-qc"; |
25 | 0 | if (val == FU_GENESYS_TS_VERSION_VENDOR_SUPPORT) |
26 | 0 | return "vendor-support"; |
27 | 0 | if (val == FU_GENESYS_TS_VERSION_MULTI_TOKEN) |
28 | 0 | return "multi-token"; |
29 | 0 | if (val == FU_GENESYS_TS_VERSION_DYNAMIC_2ND) |
30 | 0 | return "dynamic-2nd"; |
31 | 0 | if (val == FU_GENESYS_TS_VERSION_RESERVED) |
32 | 0 | return "reserved"; |
33 | 0 | if (val == FU_GENESYS_TS_VERSION_DYNAMIC_13_BYTE) |
34 | 0 | return "dynamic-13-byte"; |
35 | 0 | if (val == FU_GENESYS_TS_VERSION_BRAND_PROJECT) |
36 | 0 | return "brand-project"; |
37 | 0 | return NULL; |
38 | 0 | } |
39 | | |
40 | | const gchar * |
41 | | fu_genesys_fw_status_to_string(FuGenesysFwStatus val) |
42 | 0 | { |
43 | 0 | if (val == FU_GENESYS_FW_STATUS_MASK) |
44 | 0 | return "mask"; |
45 | 0 | if (val == FU_GENESYS_FW_STATUS_BANK1) |
46 | 0 | return "bank1"; |
47 | 0 | if (val == FU_GENESYS_FW_STATUS_BANK2) |
48 | 0 | return "bank2"; |
49 | 0 | return NULL; |
50 | 0 | } |
51 | | |
52 | | const gchar * |
53 | | fu_genesys_vs_codesign_check_to_string(FuGenesysVsCodesignCheck val) |
54 | 0 | { |
55 | 0 | if (val == FU_GENESYS_VS_CODESIGN_CHECK_UNSUPPORTED) |
56 | 0 | return "unsupported"; |
57 | 0 | if (val == FU_GENESYS_VS_CODESIGN_CHECK_SCALER) |
58 | 0 | return "scaler"; |
59 | 0 | if (val == FU_GENESYS_VS_CODESIGN_CHECK_FW) |
60 | 0 | return "fw"; |
61 | 0 | if (val == FU_GENESYS_VS_CODESIGN_CHECK_MASTER) |
62 | 0 | return "master"; |
63 | 0 | if (val == FU_GENESYS_VS_CODESIGN_CHECK_RESERVED) |
64 | 0 | return "reserved"; |
65 | 0 | if (val == FU_GENESYS_VS_CODESIGN_CHECK_HW) |
66 | 0 | return "hw"; |
67 | 0 | return NULL; |
68 | 0 | } |
69 | | |
70 | | static const gchar * |
71 | | fu_genesys_vs_hid_isp_to_string(FuGenesysVsHidIsp val) |
72 | 0 | { |
73 | 0 | if (val == FU_GENESYS_VS_HID_ISP_UNSUPPORTED) |
74 | 0 | return "unsupported"; |
75 | 0 | if (val == FU_GENESYS_VS_HID_ISP_SUPPORT) |
76 | 0 | return "support"; |
77 | 0 | if (val == FU_GENESYS_VS_HID_ISP_CODESIGN_N_RESET) |
78 | 0 | return "codesign-n-reset"; |
79 | 0 | return NULL; |
80 | 0 | } |
81 | | |
82 | | const gchar * |
83 | | fu_genesys_fw_codesign_to_string(FuGenesysFwCodesign val) |
84 | 0 | { |
85 | 0 | if (val == FU_GENESYS_FW_CODESIGN_NONE) |
86 | 0 | return "none"; |
87 | 0 | if (val == FU_GENESYS_FW_CODESIGN_RSA) |
88 | 0 | return "rsa"; |
89 | 0 | if (val == FU_GENESYS_FW_CODESIGN_ECDSA) |
90 | 0 | return "ecdsa"; |
91 | 0 | return NULL; |
92 | 0 | } |
93 | | |
94 | | const gchar * |
95 | | fu_genesys_fw_type_to_string(FuGenesysFwType val) |
96 | 29.7k | { |
97 | 29.7k | if (val == FU_GENESYS_FW_TYPE_HUB) |
98 | 1.53k | return "hub"; |
99 | 28.2k | if (val == FU_GENESYS_FW_TYPE_DEV_BRIDGE) |
100 | 17.1k | return "dev-bridge"; |
101 | 11.0k | if (val == FU_GENESYS_FW_TYPE_PD) |
102 | 11.0k | return "pd"; |
103 | 24 | if (val == FU_GENESYS_FW_TYPE_CODESIGN) |
104 | 24 | return "codesign"; |
105 | 0 | if (val == FU_GENESYS_FW_TYPE_INSIDE_HUB_COUNT) |
106 | 0 | return "inside-hub-count"; |
107 | 0 | if (val == FU_GENESYS_FW_TYPE_SCALER) |
108 | 0 | return "scaler"; |
109 | 0 | if (val == FU_GENESYS_FW_TYPE_UNKNOWN) |
110 | 0 | return "unknown"; |
111 | 0 | return NULL; |
112 | 0 | } |
113 | | /** |
114 | | * fu_struct_genesys_firmware_hdr_ref: (skip): |
115 | | **/ |
116 | | FuStructGenesysFirmwareHdr * |
117 | | fu_struct_genesys_firmware_hdr_ref(FuStructGenesysFirmwareHdr *st) |
118 | 0 | { |
119 | 0 | g_return_val_if_fail(st != NULL, NULL); |
120 | 0 | st->refcount++; |
121 | 0 | return st; |
122 | 0 | } |
123 | | /** |
124 | | * fu_struct_genesys_firmware_hdr_unref: (skip): |
125 | | **/ |
126 | | void |
127 | | fu_struct_genesys_firmware_hdr_unref(FuStructGenesysFirmwareHdr *st) |
128 | 410k | { |
129 | 410k | g_return_if_fail(st != NULL); |
130 | 410k | if (st->refcount == 0) { |
131 | 0 | g_critical("FuStructGenesysFirmwareHdr refcount already zero"); |
132 | 0 | return; |
133 | 0 | } |
134 | 410k | if (--st->refcount > 0) |
135 | 0 | return; |
136 | 410k | if (st->buf != NULL) |
137 | 410k | g_byte_array_unref(st->buf); |
138 | 410k | g_free(st); |
139 | 410k | } |
140 | | static FuStructGenesysFirmwareHdr * |
141 | | fu_struct_genesys_firmware_hdr_new_internal(void) |
142 | 410k | { |
143 | 410k | FuStructGenesysFirmwareHdr *st = g_new0(FuStructGenesysFirmwareHdr, 1); |
144 | 410k | st->refcount = 1; |
145 | 410k | return st; |
146 | 410k | } |
147 | | |
148 | | /* getters */ |
149 | | /** |
150 | | * fu_struct_genesys_firmware_hdr_get_magic: (skip): |
151 | | **/ |
152 | | static gchar * |
153 | | fu_struct_genesys_firmware_hdr_get_magic(const FuStructGenesysFirmwareHdr *st) |
154 | 376k | { |
155 | 376k | g_return_val_if_fail(st != NULL, NULL); |
156 | 376k | return fu_memstrsafe(st->buf->data, st->buf->len, 252, 4, NULL); |
157 | 376k | } |
158 | | |
159 | | /* setters */ |
160 | | static gboolean |
161 | | fu_struct_genesys_firmware_hdr_validate_internal(FuStructGenesysFirmwareHdr *st, GError **error) |
162 | 377k | { |
163 | 377k | g_return_val_if_fail(st != NULL, FALSE); |
164 | 377k | if (strncmp((const gchar *) (st->buf->data + 252), "XROM", 4) != 0) { |
165 | 376k | g_autofree gchar *str = fu_struct_genesys_firmware_hdr_get_magic(st); |
166 | 376k | g_set_error(error, |
167 | 376k | FWUPD_ERROR, |
168 | 376k | FWUPD_ERROR_INVALID_DATA, |
169 | 376k | "constant FuStructGenesysFirmwareHdr.magic was not valid, " |
170 | 376k | "expected 'XROM' and got '%s'", |
171 | 376k | str); |
172 | 376k | return FALSE; |
173 | 376k | } |
174 | 1.67k | return TRUE; |
175 | 377k | } |
176 | | /** |
177 | | * fu_struct_genesys_firmware_hdr_validate_stream: (skip): |
178 | | **/ |
179 | | gboolean |
180 | | fu_struct_genesys_firmware_hdr_validate_stream(GInputStream *stream, gsize offset, GError **error) |
181 | 410k | { |
182 | 410k | g_autoptr(FuStructGenesysFirmwareHdr) st = fu_struct_genesys_firmware_hdr_new_internal(); |
183 | 410k | g_return_val_if_fail(G_IS_INPUT_STREAM(stream), FALSE); |
184 | 410k | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
185 | 410k | st->buf = fu_input_stream_read_byte_array(stream, offset, 256, NULL, error); |
186 | 410k | if (st->buf == NULL) { |
187 | 0 | g_prefix_error(error, "FuStructGenesysFirmwareHdr failed read of 0x%x: ", (guint) 256); |
188 | 0 | return FALSE; |
189 | 0 | } |
190 | 410k | if (st->buf->len != 256) { |
191 | 33.0k | g_set_error(error, |
192 | 33.0k | FWUPD_ERROR, |
193 | 33.0k | FWUPD_ERROR_INVALID_DATA, |
194 | 33.0k | "FuStructGenesysFirmwareHdr requested 0x%x and got 0x%x", |
195 | 33.0k | (guint) 256, |
196 | 33.0k | (guint) st->buf->len); |
197 | 33.0k | return FALSE; |
198 | 33.0k | } |
199 | 377k | return fu_struct_genesys_firmware_hdr_validate_internal(st, error); |
200 | 410k | } |
201 | | /** |
202 | | * fu_struct_genesys_dev_firmware_hdr_ref: (skip): |
203 | | **/ |
204 | | FuStructGenesysDevFirmwareHdr * |
205 | | fu_struct_genesys_dev_firmware_hdr_ref(FuStructGenesysDevFirmwareHdr *st) |
206 | 0 | { |
207 | 0 | g_return_val_if_fail(st != NULL, NULL); |
208 | 0 | st->refcount++; |
209 | 0 | return st; |
210 | 0 | } |
211 | | /** |
212 | | * fu_struct_genesys_dev_firmware_hdr_unref: (skip): |
213 | | **/ |
214 | | void |
215 | | fu_struct_genesys_dev_firmware_hdr_unref(FuStructGenesysDevFirmwareHdr *st) |
216 | 28.6k | { |
217 | 28.6k | g_return_if_fail(st != NULL); |
218 | 28.6k | if (st->refcount == 0) { |
219 | 0 | g_critical("FuStructGenesysDevFirmwareHdr refcount already zero"); |
220 | 0 | return; |
221 | 0 | } |
222 | 28.6k | if (--st->refcount > 0) |
223 | 0 | return; |
224 | 28.6k | if (st->buf != NULL) |
225 | 28.6k | g_byte_array_unref(st->buf); |
226 | 28.6k | g_free(st); |
227 | 28.6k | } |
228 | | static FuStructGenesysDevFirmwareHdr * |
229 | | fu_struct_genesys_dev_firmware_hdr_new_internal(void) |
230 | 28.6k | { |
231 | 28.6k | FuStructGenesysDevFirmwareHdr *st = g_new0(FuStructGenesysDevFirmwareHdr, 1); |
232 | 28.6k | st->refcount = 1; |
233 | 28.6k | return st; |
234 | 28.6k | } |
235 | | |
236 | | /* getters */ |
237 | | /** |
238 | | * fu_struct_genesys_dev_firmware_hdr_get_magic: (skip): |
239 | | **/ |
240 | | static gchar * |
241 | | fu_struct_genesys_dev_firmware_hdr_get_magic(const FuStructGenesysDevFirmwareHdr *st) |
242 | 11.2k | { |
243 | 11.2k | g_return_val_if_fail(st != NULL, NULL); |
244 | 11.2k | return fu_memstrsafe(st->buf->data, st->buf->len, 252, 4, NULL); |
245 | 11.2k | } |
246 | | |
247 | | /* setters */ |
248 | | static gboolean |
249 | | fu_struct_genesys_dev_firmware_hdr_validate_internal(FuStructGenesysDevFirmwareHdr *st, GError **error) |
250 | 28.3k | { |
251 | 28.3k | g_return_val_if_fail(st != NULL, FALSE); |
252 | 28.3k | if (strncmp((const gchar *) (st->buf->data + 252), "HOST", 4) != 0) { |
253 | 11.2k | g_autofree gchar *str = fu_struct_genesys_dev_firmware_hdr_get_magic(st); |
254 | 11.2k | g_set_error(error, |
255 | 11.2k | FWUPD_ERROR, |
256 | 11.2k | FWUPD_ERROR_INVALID_DATA, |
257 | 11.2k | "constant FuStructGenesysDevFirmwareHdr.magic was not valid, " |
258 | 11.2k | "expected 'HOST' and got '%s'", |
259 | 11.2k | str); |
260 | 11.2k | return FALSE; |
261 | 11.2k | } |
262 | 17.1k | return TRUE; |
263 | 28.3k | } |
264 | | /** |
265 | | * fu_struct_genesys_dev_firmware_hdr_validate_stream: (skip): |
266 | | **/ |
267 | | gboolean |
268 | | fu_struct_genesys_dev_firmware_hdr_validate_stream(GInputStream *stream, gsize offset, GError **error) |
269 | 28.6k | { |
270 | 28.6k | g_autoptr(FuStructGenesysDevFirmwareHdr) st = fu_struct_genesys_dev_firmware_hdr_new_internal(); |
271 | 28.6k | g_return_val_if_fail(G_IS_INPUT_STREAM(stream), FALSE); |
272 | 28.6k | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
273 | 28.6k | st->buf = fu_input_stream_read_byte_array(stream, offset, 256, NULL, error); |
274 | 28.6k | if (st->buf == NULL) { |
275 | 0 | g_prefix_error(error, "FuStructGenesysDevFirmwareHdr failed read of 0x%x: ", (guint) 256); |
276 | 0 | return FALSE; |
277 | 0 | } |
278 | 28.6k | if (st->buf->len != 256) { |
279 | 236 | g_set_error(error, |
280 | 236 | FWUPD_ERROR, |
281 | 236 | FWUPD_ERROR_INVALID_DATA, |
282 | 236 | "FuStructGenesysDevFirmwareHdr requested 0x%x and got 0x%x", |
283 | 236 | (guint) 256, |
284 | 236 | (guint) st->buf->len); |
285 | 236 | return FALSE; |
286 | 236 | } |
287 | 28.3k | return fu_struct_genesys_dev_firmware_hdr_validate_internal(st, error); |
288 | 28.6k | } |
289 | | /** |
290 | | * fu_struct_genesys_pd_firmware_hdr_ref: (skip): |
291 | | **/ |
292 | | FuStructGenesysPdFirmwareHdr * |
293 | | fu_struct_genesys_pd_firmware_hdr_ref(FuStructGenesysPdFirmwareHdr *st) |
294 | 0 | { |
295 | 0 | g_return_val_if_fail(st != NULL, NULL); |
296 | 0 | st->refcount++; |
297 | 0 | return st; |
298 | 0 | } |
299 | | /** |
300 | | * fu_struct_genesys_pd_firmware_hdr_unref: (skip): |
301 | | **/ |
302 | | void |
303 | | fu_struct_genesys_pd_firmware_hdr_unref(FuStructGenesysPdFirmwareHdr *st) |
304 | 11.6k | { |
305 | 11.6k | g_return_if_fail(st != NULL); |
306 | 11.6k | if (st->refcount == 0) { |
307 | 0 | g_critical("FuStructGenesysPdFirmwareHdr refcount already zero"); |
308 | 0 | return; |
309 | 0 | } |
310 | 11.6k | if (--st->refcount > 0) |
311 | 0 | return; |
312 | 11.6k | if (st->buf != NULL) |
313 | 11.6k | g_byte_array_unref(st->buf); |
314 | 11.6k | g_free(st); |
315 | 11.6k | } |
316 | | static FuStructGenesysPdFirmwareHdr * |
317 | | fu_struct_genesys_pd_firmware_hdr_new_internal(void) |
318 | 11.6k | { |
319 | 11.6k | FuStructGenesysPdFirmwareHdr *st = g_new0(FuStructGenesysPdFirmwareHdr, 1); |
320 | 11.6k | st->refcount = 1; |
321 | 11.6k | return st; |
322 | 11.6k | } |
323 | | |
324 | | /* getters */ |
325 | | /** |
326 | | * fu_struct_genesys_pd_firmware_hdr_get_magic: (skip): |
327 | | **/ |
328 | | static gchar * |
329 | | fu_struct_genesys_pd_firmware_hdr_get_magic(const FuStructGenesysPdFirmwareHdr *st) |
330 | 385 | { |
331 | 385 | g_return_val_if_fail(st != NULL, NULL); |
332 | 385 | return fu_memstrsafe(st->buf->data, st->buf->len, 252, 4, NULL); |
333 | 385 | } |
334 | | |
335 | | /* setters */ |
336 | | static gboolean |
337 | | fu_struct_genesys_pd_firmware_hdr_validate_internal(FuStructGenesysPdFirmwareHdr *st, GError **error) |
338 | 11.4k | { |
339 | 11.4k | g_return_val_if_fail(st != NULL, FALSE); |
340 | 11.4k | if (strncmp((const gchar *) (st->buf->data + 252), "PRDY", 4) != 0) { |
341 | 385 | g_autofree gchar *str = fu_struct_genesys_pd_firmware_hdr_get_magic(st); |
342 | 385 | g_set_error(error, |
343 | 385 | FWUPD_ERROR, |
344 | 385 | FWUPD_ERROR_INVALID_DATA, |
345 | 385 | "constant FuStructGenesysPdFirmwareHdr.magic was not valid, " |
346 | 385 | "expected 'PRDY' and got '%s'", |
347 | 385 | str); |
348 | 385 | return FALSE; |
349 | 385 | } |
350 | 11.0k | return TRUE; |
351 | 11.4k | } |
352 | | /** |
353 | | * fu_struct_genesys_pd_firmware_hdr_validate_stream: (skip): |
354 | | **/ |
355 | | gboolean |
356 | | fu_struct_genesys_pd_firmware_hdr_validate_stream(GInputStream *stream, gsize offset, GError **error) |
357 | 11.6k | { |
358 | 11.6k | g_autoptr(FuStructGenesysPdFirmwareHdr) st = fu_struct_genesys_pd_firmware_hdr_new_internal(); |
359 | 11.6k | g_return_val_if_fail(G_IS_INPUT_STREAM(stream), FALSE); |
360 | 11.6k | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
361 | 11.6k | st->buf = fu_input_stream_read_byte_array(stream, offset, 256, NULL, error); |
362 | 11.6k | if (st->buf == NULL) { |
363 | 0 | g_prefix_error(error, "FuStructGenesysPdFirmwareHdr failed read of 0x%x: ", (guint) 256); |
364 | 0 | return FALSE; |
365 | 0 | } |
366 | 11.6k | if (st->buf->len != 256) { |
367 | 236 | g_set_error(error, |
368 | 236 | FWUPD_ERROR, |
369 | 236 | FWUPD_ERROR_INVALID_DATA, |
370 | 236 | "FuStructGenesysPdFirmwareHdr requested 0x%x and got 0x%x", |
371 | 236 | (guint) 256, |
372 | 236 | (guint) st->buf->len); |
373 | 236 | return FALSE; |
374 | 236 | } |
375 | 11.4k | return fu_struct_genesys_pd_firmware_hdr_validate_internal(st, error); |
376 | 11.6k | } |
377 | | /** |
378 | | * fu_struct_genesys_ts_static_ref: (skip): |
379 | | **/ |
380 | | FuStructGenesysTsStatic * |
381 | | fu_struct_genesys_ts_static_ref(FuStructGenesysTsStatic *st) |
382 | 0 | { |
383 | 0 | g_return_val_if_fail(st != NULL, NULL); |
384 | 0 | st->refcount++; |
385 | 0 | return st; |
386 | 0 | } |
387 | | /** |
388 | | * fu_struct_genesys_ts_static_unref: (skip): |
389 | | **/ |
390 | | void |
391 | | fu_struct_genesys_ts_static_unref(FuStructGenesysTsStatic *st) |
392 | 1.53k | { |
393 | 1.53k | g_return_if_fail(st != NULL); |
394 | 1.53k | if (st->refcount == 0) { |
395 | 0 | g_critical("FuStructGenesysTsStatic refcount already zero"); |
396 | 0 | return; |
397 | 0 | } |
398 | 1.53k | if (--st->refcount > 0) |
399 | 0 | return; |
400 | 1.53k | if (st->buf != NULL) |
401 | 1.53k | g_byte_array_unref(st->buf); |
402 | 1.53k | g_free(st); |
403 | 1.53k | } |
404 | | static FuStructGenesysTsStatic * |
405 | | fu_struct_genesys_ts_static_new_internal(void) |
406 | 1.53k | { |
407 | 1.53k | FuStructGenesysTsStatic *st = g_new0(FuStructGenesysTsStatic, 1); |
408 | 1.53k | st->refcount = 1; |
409 | 1.53k | return st; |
410 | 1.53k | } |
411 | | |
412 | | /* getters */ |
413 | | /** |
414 | | * fu_struct_genesys_ts_static_get_tool_string_version: (skip): |
415 | | **/ |
416 | | FuGenesysTsVersion |
417 | | fu_struct_genesys_ts_static_get_tool_string_version(const FuStructGenesysTsStatic *st) |
418 | 0 | { |
419 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
420 | 0 | return st->buf->data[0]; |
421 | 0 | } |
422 | | /** |
423 | | * fu_struct_genesys_ts_static_get_mask_project_code: (skip): |
424 | | **/ |
425 | | gchar * |
426 | | fu_struct_genesys_ts_static_get_mask_project_code(const FuStructGenesysTsStatic *st) |
427 | 0 | { |
428 | 0 | g_return_val_if_fail(st != NULL, NULL); |
429 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 1, 4, NULL); |
430 | 0 | } |
431 | | /** |
432 | | * fu_struct_genesys_ts_static_get_mask_project_hardware: (skip): |
433 | | **/ |
434 | | gchar * |
435 | | fu_struct_genesys_ts_static_get_mask_project_hardware(const FuStructGenesysTsStatic *st) |
436 | 0 | { |
437 | 0 | g_return_val_if_fail(st != NULL, NULL); |
438 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 5, 1, NULL); |
439 | 0 | } |
440 | | /** |
441 | | * fu_struct_genesys_ts_static_get_mask_project_firmware: (skip): |
442 | | **/ |
443 | | gchar * |
444 | | fu_struct_genesys_ts_static_get_mask_project_firmware(const FuStructGenesysTsStatic *st) |
445 | 0 | { |
446 | 0 | g_return_val_if_fail(st != NULL, NULL); |
447 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 6, 2, NULL); |
448 | 0 | } |
449 | | /** |
450 | | * fu_struct_genesys_ts_static_get_mask_project_ic_type: (skip): |
451 | | **/ |
452 | | gchar * |
453 | | fu_struct_genesys_ts_static_get_mask_project_ic_type(const FuStructGenesysTsStatic *st) |
454 | 0 | { |
455 | 0 | g_return_val_if_fail(st != NULL, NULL); |
456 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 8, 6, NULL); |
457 | 0 | } |
458 | | /** |
459 | | * fu_struct_genesys_ts_static_get_running_project_code: (skip): |
460 | | **/ |
461 | | gchar * |
462 | | fu_struct_genesys_ts_static_get_running_project_code(const FuStructGenesysTsStatic *st) |
463 | 0 | { |
464 | 0 | g_return_val_if_fail(st != NULL, NULL); |
465 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 14, 4, NULL); |
466 | 0 | } |
467 | | /** |
468 | | * fu_struct_genesys_ts_static_get_running_project_hardware: (skip): |
469 | | **/ |
470 | | gchar * |
471 | | fu_struct_genesys_ts_static_get_running_project_hardware(const FuStructGenesysTsStatic *st) |
472 | 0 | { |
473 | 0 | g_return_val_if_fail(st != NULL, NULL); |
474 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 18, 1, NULL); |
475 | 0 | } |
476 | | /** |
477 | | * fu_struct_genesys_ts_static_get_running_project_firmware: (skip): |
478 | | **/ |
479 | | gchar * |
480 | | fu_struct_genesys_ts_static_get_running_project_firmware(const FuStructGenesysTsStatic *st) |
481 | 0 | { |
482 | 0 | g_return_val_if_fail(st != NULL, NULL); |
483 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 19, 2, NULL); |
484 | 0 | } |
485 | | /** |
486 | | * fu_struct_genesys_ts_static_get_running_project_ic_type: (skip): |
487 | | **/ |
488 | | gchar * |
489 | | fu_struct_genesys_ts_static_get_running_project_ic_type(const FuStructGenesysTsStatic *st) |
490 | 0 | { |
491 | 0 | g_return_val_if_fail(st != NULL, NULL); |
492 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 21, 6, NULL); |
493 | 0 | } |
494 | | /** |
495 | | * fu_struct_genesys_ts_static_get_firmware_version: (skip): |
496 | | **/ |
497 | | gchar * |
498 | | fu_struct_genesys_ts_static_get_firmware_version(const FuStructGenesysTsStatic *st) |
499 | 0 | { |
500 | 0 | g_return_val_if_fail(st != NULL, NULL); |
501 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 27, 4, NULL); |
502 | 0 | } |
503 | | |
504 | | /* setters */ |
505 | | /** |
506 | | * fu_struct_genesys_ts_static_set_tool_string_version: (skip): |
507 | | **/ |
508 | | void |
509 | | fu_struct_genesys_ts_static_set_tool_string_version(FuStructGenesysTsStatic *st, FuGenesysTsVersion value) |
510 | 0 | { |
511 | 0 | g_return_if_fail(st != NULL); |
512 | 0 | st->buf->data[0] = value; |
513 | 0 | } |
514 | | /** |
515 | | * fu_struct_genesys_ts_static_set_mask_project_code: (skip): |
516 | | **/ |
517 | | gboolean |
518 | | fu_struct_genesys_ts_static_set_mask_project_code(FuStructGenesysTsStatic *st, const gchar *value, GError **error) |
519 | 0 | { |
520 | 0 | gsize len; |
521 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
522 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
523 | 0 | if (value == NULL) { |
524 | 0 | memset(st->buf->data + 1, 0x0, 4); |
525 | 0 | return TRUE; |
526 | 0 | } |
527 | 0 | len = strlen(value); |
528 | 0 | if (len > 4) { |
529 | 0 | g_set_error(error, |
530 | 0 | FWUPD_ERROR, |
531 | 0 | FWUPD_ERROR_INVALID_DATA, |
532 | 0 | "string '%s' (0x%x bytes) does not fit in FuStructGenesysTsStatic.mask_project_code (0x%x bytes)", |
533 | 0 | value, (guint) len, (guint) 4); |
534 | 0 | return FALSE; |
535 | 0 | } |
536 | 0 | return fu_memcpy_safe(st->buf->data, st->buf->len, 1, (const guint8 *)value, len, 0x0, len, error); |
537 | 0 | } |
538 | | /** |
539 | | * fu_struct_genesys_ts_static_set_mask_project_hardware: (skip): |
540 | | **/ |
541 | | gboolean |
542 | | fu_struct_genesys_ts_static_set_mask_project_hardware(FuStructGenesysTsStatic *st, const gchar *value, GError **error) |
543 | 0 | { |
544 | 0 | gsize len; |
545 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
546 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
547 | 0 | if (value == NULL) { |
548 | 0 | memset(st->buf->data + 5, 0x0, 1); |
549 | 0 | return TRUE; |
550 | 0 | } |
551 | 0 | len = strlen(value); |
552 | 0 | if (len > 1) { |
553 | 0 | g_set_error(error, |
554 | 0 | FWUPD_ERROR, |
555 | 0 | FWUPD_ERROR_INVALID_DATA, |
556 | 0 | "string '%s' (0x%x bytes) does not fit in FuStructGenesysTsStatic.mask_project_hardware (0x%x bytes)", |
557 | 0 | value, (guint) len, (guint) 1); |
558 | 0 | return FALSE; |
559 | 0 | } |
560 | 0 | return fu_memcpy_safe(st->buf->data, st->buf->len, 5, (const guint8 *)value, len, 0x0, len, error); |
561 | 0 | } |
562 | | /** |
563 | | * fu_struct_genesys_ts_static_set_mask_project_firmware: (skip): |
564 | | **/ |
565 | | gboolean |
566 | | fu_struct_genesys_ts_static_set_mask_project_firmware(FuStructGenesysTsStatic *st, const gchar *value, GError **error) |
567 | 0 | { |
568 | 0 | gsize len; |
569 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
570 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
571 | 0 | if (value == NULL) { |
572 | 0 | memset(st->buf->data + 6, 0x0, 2); |
573 | 0 | return TRUE; |
574 | 0 | } |
575 | 0 | len = strlen(value); |
576 | 0 | if (len > 2) { |
577 | 0 | g_set_error(error, |
578 | 0 | FWUPD_ERROR, |
579 | 0 | FWUPD_ERROR_INVALID_DATA, |
580 | 0 | "string '%s' (0x%x bytes) does not fit in FuStructGenesysTsStatic.mask_project_firmware (0x%x bytes)", |
581 | 0 | value, (guint) len, (guint) 2); |
582 | 0 | return FALSE; |
583 | 0 | } |
584 | 0 | return fu_memcpy_safe(st->buf->data, st->buf->len, 6, (const guint8 *)value, len, 0x0, len, error); |
585 | 0 | } |
586 | | /** |
587 | | * fu_struct_genesys_ts_static_set_mask_project_ic_type: (skip): |
588 | | **/ |
589 | | gboolean |
590 | | fu_struct_genesys_ts_static_set_mask_project_ic_type(FuStructGenesysTsStatic *st, const gchar *value, GError **error) |
591 | 0 | { |
592 | 0 | gsize len; |
593 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
594 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
595 | 0 | if (value == NULL) { |
596 | 0 | memset(st->buf->data + 8, 0x0, 6); |
597 | 0 | return TRUE; |
598 | 0 | } |
599 | 0 | len = strlen(value); |
600 | 0 | if (len > 6) { |
601 | 0 | g_set_error(error, |
602 | 0 | FWUPD_ERROR, |
603 | 0 | FWUPD_ERROR_INVALID_DATA, |
604 | 0 | "string '%s' (0x%x bytes) does not fit in FuStructGenesysTsStatic.mask_project_ic_type (0x%x bytes)", |
605 | 0 | value, (guint) len, (guint) 6); |
606 | 0 | return FALSE; |
607 | 0 | } |
608 | 0 | return fu_memcpy_safe(st->buf->data, st->buf->len, 8, (const guint8 *)value, len, 0x0, len, error); |
609 | 0 | } |
610 | | /** |
611 | | * fu_struct_genesys_ts_static_set_running_project_code: (skip): |
612 | | **/ |
613 | | gboolean |
614 | | fu_struct_genesys_ts_static_set_running_project_code(FuStructGenesysTsStatic *st, const gchar *value, GError **error) |
615 | 0 | { |
616 | 0 | gsize len; |
617 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
618 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
619 | 0 | if (value == NULL) { |
620 | 0 | memset(st->buf->data + 14, 0x0, 4); |
621 | 0 | return TRUE; |
622 | 0 | } |
623 | 0 | len = strlen(value); |
624 | 0 | if (len > 4) { |
625 | 0 | g_set_error(error, |
626 | 0 | FWUPD_ERROR, |
627 | 0 | FWUPD_ERROR_INVALID_DATA, |
628 | 0 | "string '%s' (0x%x bytes) does not fit in FuStructGenesysTsStatic.running_project_code (0x%x bytes)", |
629 | 0 | value, (guint) len, (guint) 4); |
630 | 0 | return FALSE; |
631 | 0 | } |
632 | 0 | return fu_memcpy_safe(st->buf->data, st->buf->len, 14, (const guint8 *)value, len, 0x0, len, error); |
633 | 0 | } |
634 | | /** |
635 | | * fu_struct_genesys_ts_static_set_running_project_hardware: (skip): |
636 | | **/ |
637 | | gboolean |
638 | | fu_struct_genesys_ts_static_set_running_project_hardware(FuStructGenesysTsStatic *st, const gchar *value, GError **error) |
639 | 0 | { |
640 | 0 | gsize len; |
641 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
642 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
643 | 0 | if (value == NULL) { |
644 | 0 | memset(st->buf->data + 18, 0x0, 1); |
645 | 0 | return TRUE; |
646 | 0 | } |
647 | 0 | len = strlen(value); |
648 | 0 | if (len > 1) { |
649 | 0 | g_set_error(error, |
650 | 0 | FWUPD_ERROR, |
651 | 0 | FWUPD_ERROR_INVALID_DATA, |
652 | 0 | "string '%s' (0x%x bytes) does not fit in FuStructGenesysTsStatic.running_project_hardware (0x%x bytes)", |
653 | 0 | value, (guint) len, (guint) 1); |
654 | 0 | return FALSE; |
655 | 0 | } |
656 | 0 | return fu_memcpy_safe(st->buf->data, st->buf->len, 18, (const guint8 *)value, len, 0x0, len, error); |
657 | 0 | } |
658 | | /** |
659 | | * fu_struct_genesys_ts_static_set_running_project_firmware: (skip): |
660 | | **/ |
661 | | gboolean |
662 | | fu_struct_genesys_ts_static_set_running_project_firmware(FuStructGenesysTsStatic *st, const gchar *value, GError **error) |
663 | 0 | { |
664 | 0 | gsize len; |
665 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
666 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
667 | 0 | if (value == NULL) { |
668 | 0 | memset(st->buf->data + 19, 0x0, 2); |
669 | 0 | return TRUE; |
670 | 0 | } |
671 | 0 | len = strlen(value); |
672 | 0 | if (len > 2) { |
673 | 0 | g_set_error(error, |
674 | 0 | FWUPD_ERROR, |
675 | 0 | FWUPD_ERROR_INVALID_DATA, |
676 | 0 | "string '%s' (0x%x bytes) does not fit in FuStructGenesysTsStatic.running_project_firmware (0x%x bytes)", |
677 | 0 | value, (guint) len, (guint) 2); |
678 | 0 | return FALSE; |
679 | 0 | } |
680 | 0 | return fu_memcpy_safe(st->buf->data, st->buf->len, 19, (const guint8 *)value, len, 0x0, len, error); |
681 | 0 | } |
682 | | /** |
683 | | * fu_struct_genesys_ts_static_set_running_project_ic_type: (skip): |
684 | | **/ |
685 | | gboolean |
686 | | fu_struct_genesys_ts_static_set_running_project_ic_type(FuStructGenesysTsStatic *st, const gchar *value, GError **error) |
687 | 0 | { |
688 | 0 | gsize len; |
689 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
690 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
691 | 0 | if (value == NULL) { |
692 | 0 | memset(st->buf->data + 21, 0x0, 6); |
693 | 0 | return TRUE; |
694 | 0 | } |
695 | 0 | len = strlen(value); |
696 | 0 | if (len > 6) { |
697 | 0 | g_set_error(error, |
698 | 0 | FWUPD_ERROR, |
699 | 0 | FWUPD_ERROR_INVALID_DATA, |
700 | 0 | "string '%s' (0x%x bytes) does not fit in FuStructGenesysTsStatic.running_project_ic_type (0x%x bytes)", |
701 | 0 | value, (guint) len, (guint) 6); |
702 | 0 | return FALSE; |
703 | 0 | } |
704 | 0 | return fu_memcpy_safe(st->buf->data, st->buf->len, 21, (const guint8 *)value, len, 0x0, len, error); |
705 | 0 | } |
706 | | /** |
707 | | * fu_struct_genesys_ts_static_set_firmware_version: (skip): |
708 | | **/ |
709 | | gboolean |
710 | | fu_struct_genesys_ts_static_set_firmware_version(FuStructGenesysTsStatic *st, const gchar *value, GError **error) |
711 | 0 | { |
712 | 0 | gsize len; |
713 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
714 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
715 | 0 | if (value == NULL) { |
716 | 0 | memset(st->buf->data + 27, 0x0, 4); |
717 | 0 | return TRUE; |
718 | 0 | } |
719 | 0 | len = strlen(value); |
720 | 0 | if (len > 4) { |
721 | 0 | g_set_error(error, |
722 | 0 | FWUPD_ERROR, |
723 | 0 | FWUPD_ERROR_INVALID_DATA, |
724 | 0 | "string '%s' (0x%x bytes) does not fit in FuStructGenesysTsStatic.firmware_version (0x%x bytes)", |
725 | 0 | value, (guint) len, (guint) 4); |
726 | 0 | return FALSE; |
727 | 0 | } |
728 | 0 | return fu_memcpy_safe(st->buf->data, st->buf->len, 27, (const guint8 *)value, len, 0x0, len, error); |
729 | 0 | } |
730 | | /** |
731 | | * fu_struct_genesys_ts_static_new: (skip): |
732 | | **/ |
733 | | FuStructGenesysTsStatic * |
734 | | fu_struct_genesys_ts_static_new(void) |
735 | 0 | { |
736 | 0 | FuStructGenesysTsStatic *st = fu_struct_genesys_ts_static_new_internal(); |
737 | 0 | st->buf = g_byte_array_sized_new(31); |
738 | 0 | fu_byte_array_set_size(st->buf, 31, 0x0); |
739 | 0 | return st; |
740 | 0 | } |
741 | | /** |
742 | | * fu_struct_genesys_ts_static_to_string: (skip): |
743 | | **/ |
744 | | static gchar * |
745 | | fu_struct_genesys_ts_static_to_string(const FuStructGenesysTsStatic *st) |
746 | 0 | { |
747 | 0 | g_autoptr(GString) str = g_string_new("FuStructGenesysTsStatic:\n"); |
748 | 0 | g_return_val_if_fail(st != NULL, NULL); |
749 | 0 | { |
750 | 0 | const gchar *tmp = fu_genesys_ts_version_to_string(fu_struct_genesys_ts_static_get_tool_string_version(st)); |
751 | 0 | if (tmp != NULL) { |
752 | 0 | g_string_append_printf(str, " tool_string_version: 0x%x [%s]\n", (guint) fu_struct_genesys_ts_static_get_tool_string_version(st), tmp); |
753 | 0 | } else { |
754 | 0 | g_string_append_printf(str, " tool_string_version: 0x%x\n", (guint) fu_struct_genesys_ts_static_get_tool_string_version(st)); |
755 | 0 | } |
756 | 0 | } |
757 | 0 | { |
758 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_static_get_mask_project_code(st); |
759 | 0 | if (tmp != NULL) |
760 | 0 | g_string_append_printf(str, " mask_project_code: %s\n", tmp); |
761 | 0 | } |
762 | 0 | { |
763 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_static_get_mask_project_hardware(st); |
764 | 0 | if (tmp != NULL) |
765 | 0 | g_string_append_printf(str, " mask_project_hardware: %s\n", tmp); |
766 | 0 | } |
767 | 0 | { |
768 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_static_get_mask_project_firmware(st); |
769 | 0 | if (tmp != NULL) |
770 | 0 | g_string_append_printf(str, " mask_project_firmware: %s\n", tmp); |
771 | 0 | } |
772 | 0 | { |
773 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_static_get_mask_project_ic_type(st); |
774 | 0 | if (tmp != NULL) |
775 | 0 | g_string_append_printf(str, " mask_project_ic_type: %s\n", tmp); |
776 | 0 | } |
777 | 0 | { |
778 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_static_get_running_project_code(st); |
779 | 0 | if (tmp != NULL) |
780 | 0 | g_string_append_printf(str, " running_project_code: %s\n", tmp); |
781 | 0 | } |
782 | 0 | { |
783 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_static_get_running_project_hardware(st); |
784 | 0 | if (tmp != NULL) |
785 | 0 | g_string_append_printf(str, " running_project_hardware: %s\n", tmp); |
786 | 0 | } |
787 | 0 | { |
788 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_static_get_running_project_firmware(st); |
789 | 0 | if (tmp != NULL) |
790 | 0 | g_string_append_printf(str, " running_project_firmware: %s\n", tmp); |
791 | 0 | } |
792 | 0 | { |
793 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_static_get_running_project_ic_type(st); |
794 | 0 | if (tmp != NULL) |
795 | 0 | g_string_append_printf(str, " running_project_ic_type: %s\n", tmp); |
796 | 0 | } |
797 | 0 | { |
798 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_static_get_firmware_version(st); |
799 | 0 | if (tmp != NULL) |
800 | 0 | g_string_append_printf(str, " firmware_version: %s\n", tmp); |
801 | 0 | } |
802 | 0 | if (str->len > 0) |
803 | 0 | g_string_set_size(str, str->len - 1); |
804 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
805 | 0 | } |
806 | | static gboolean |
807 | | fu_struct_genesys_ts_static_validate_internal(FuStructGenesysTsStatic *st, GError **error) |
808 | 1.41k | { |
809 | 1.41k | g_return_val_if_fail(st != NULL, FALSE); |
810 | 1.41k | return TRUE; |
811 | 1.41k | } |
812 | | static gboolean |
813 | | fu_struct_genesys_ts_static_parse_internal(FuStructGenesysTsStatic *st, GError **error) |
814 | 1.41k | { |
815 | 1.41k | if (g_getenv("FWUPD_VERBOSE") != NULL) { |
816 | 0 | g_autofree gchar *str = fu_struct_genesys_ts_static_to_string(st); |
817 | 0 | g_debug("%s", str); |
818 | 0 | } |
819 | 1.41k | if (!fu_struct_genesys_ts_static_validate_internal(st, error)) |
820 | 0 | return FALSE; |
821 | 1.41k | return TRUE; |
822 | 1.41k | } |
823 | | |
824 | | /** |
825 | | * fu_struct_genesys_ts_static_parse: (skip): |
826 | | **/ |
827 | | FuStructGenesysTsStatic * |
828 | | fu_struct_genesys_ts_static_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
829 | 0 | { |
830 | 0 | g_autoptr(FuStructGenesysTsStatic) st = fu_struct_genesys_ts_static_new_internal(); |
831 | 0 | g_return_val_if_fail(buf != NULL, NULL); |
832 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, NULL); |
833 | 0 | if (!fu_memchk_read(bufsz, offset, 31, error)) { |
834 | 0 | g_prefix_error_literal(error, "invalid struct FuStructGenesysTsStatic: "); |
835 | 0 | return NULL; |
836 | 0 | } |
837 | 0 | st->buf = g_byte_array_new(); |
838 | 0 | g_byte_array_append(st->buf, buf + offset, 31); |
839 | 0 | if (!fu_struct_genesys_ts_static_parse_internal(st, error)) |
840 | 0 | return NULL; |
841 | 0 | return g_steal_pointer(&st); |
842 | 0 | } |
843 | | /** |
844 | | * fu_struct_genesys_ts_static_parse_stream: (skip): |
845 | | **/ |
846 | | FuStructGenesysTsStatic * |
847 | | fu_struct_genesys_ts_static_parse_stream(GInputStream *stream, gsize offset, GError **error) |
848 | 1.53k | { |
849 | 1.53k | g_autoptr(FuStructGenesysTsStatic) st = fu_struct_genesys_ts_static_new_internal(); |
850 | 1.53k | st->buf = fu_input_stream_read_byte_array(stream, offset, 31, NULL, error); |
851 | 1.53k | if (st->buf == NULL) { |
852 | 0 | g_prefix_error(error, "FuStructGenesysTsStatic failed read of 0x%x: ", (guint) 31); |
853 | 0 | return NULL; |
854 | 0 | } |
855 | 1.53k | if (st->buf->len != 31) { |
856 | 121 | g_set_error(error, |
857 | 121 | FWUPD_ERROR, |
858 | 121 | FWUPD_ERROR_INVALID_DATA, |
859 | 121 | "FuStructGenesysTsStatic requested 0x%x and got 0x%x", |
860 | 121 | (guint) 31, |
861 | 121 | (guint) st->buf->len); |
862 | 121 | return NULL; |
863 | 121 | } |
864 | 1.41k | if (!fu_struct_genesys_ts_static_parse_internal(st, error)) |
865 | 0 | return NULL; |
866 | 1.41k | return g_steal_pointer(&st); |
867 | 1.41k | } |
868 | | /** |
869 | | * fu_struct_genesys_ts_dynamic_gl3523_ref: (skip): |
870 | | **/ |
871 | | FuStructGenesysTsDynamicGl3523 * |
872 | | fu_struct_genesys_ts_dynamic_gl3523_ref(FuStructGenesysTsDynamicGl3523 *st) |
873 | 0 | { |
874 | 0 | g_return_val_if_fail(st != NULL, NULL); |
875 | 0 | st->refcount++; |
876 | 0 | return st; |
877 | 0 | } |
878 | | /** |
879 | | * fu_struct_genesys_ts_dynamic_gl3523_unref: (skip): |
880 | | **/ |
881 | | void |
882 | | fu_struct_genesys_ts_dynamic_gl3523_unref(FuStructGenesysTsDynamicGl3523 *st) |
883 | 0 | { |
884 | 0 | g_return_if_fail(st != NULL); |
885 | 0 | if (st->refcount == 0) { |
886 | 0 | g_critical("FuStructGenesysTsDynamicGl3523 refcount already zero"); |
887 | 0 | return; |
888 | 0 | } |
889 | 0 | if (--st->refcount > 0) |
890 | 0 | return; |
891 | 0 | if (st->buf != NULL) |
892 | 0 | g_byte_array_unref(st->buf); |
893 | 0 | g_free(st); |
894 | 0 | } |
895 | | static FuStructGenesysTsDynamicGl3523 * |
896 | | fu_struct_genesys_ts_dynamic_gl3523_new_internal(void) |
897 | 0 | { |
898 | 0 | FuStructGenesysTsDynamicGl3523 *st = g_new0(FuStructGenesysTsDynamicGl3523, 1); |
899 | 0 | st->refcount = 1; |
900 | 0 | return st; |
901 | 0 | } |
902 | | |
903 | | /* getters */ |
904 | | /** |
905 | | * fu_struct_genesys_ts_dynamic_gl3523_get_running_mode: (skip): |
906 | | **/ |
907 | | gchar * |
908 | | fu_struct_genesys_ts_dynamic_gl3523_get_running_mode(const FuStructGenesysTsDynamicGl3523 *st) |
909 | 0 | { |
910 | 0 | g_return_val_if_fail(st != NULL, NULL); |
911 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 0, 1, NULL); |
912 | 0 | } |
913 | | /** |
914 | | * fu_struct_genesys_ts_dynamic_gl3523_get_ss_port_number: (skip): |
915 | | **/ |
916 | | gchar * |
917 | | fu_struct_genesys_ts_dynamic_gl3523_get_ss_port_number(const FuStructGenesysTsDynamicGl3523 *st) |
918 | 0 | { |
919 | 0 | g_return_val_if_fail(st != NULL, NULL); |
920 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 1, 1, NULL); |
921 | 0 | } |
922 | | /** |
923 | | * fu_struct_genesys_ts_dynamic_gl3523_get_hs_port_number: (skip): |
924 | | **/ |
925 | | gchar * |
926 | | fu_struct_genesys_ts_dynamic_gl3523_get_hs_port_number(const FuStructGenesysTsDynamicGl3523 *st) |
927 | 0 | { |
928 | 0 | g_return_val_if_fail(st != NULL, NULL); |
929 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 2, 1, NULL); |
930 | 0 | } |
931 | | /** |
932 | | * fu_struct_genesys_ts_dynamic_gl3523_get_ss_connection_status: (skip): |
933 | | **/ |
934 | | gchar * |
935 | | fu_struct_genesys_ts_dynamic_gl3523_get_ss_connection_status(const FuStructGenesysTsDynamicGl3523 *st) |
936 | 0 | { |
937 | 0 | g_return_val_if_fail(st != NULL, NULL); |
938 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 3, 1, NULL); |
939 | 0 | } |
940 | | /** |
941 | | * fu_struct_genesys_ts_dynamic_gl3523_get_hs_connection_status: (skip): |
942 | | **/ |
943 | | gchar * |
944 | | fu_struct_genesys_ts_dynamic_gl3523_get_hs_connection_status(const FuStructGenesysTsDynamicGl3523 *st) |
945 | 0 | { |
946 | 0 | g_return_val_if_fail(st != NULL, NULL); |
947 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 4, 1, NULL); |
948 | 0 | } |
949 | | /** |
950 | | * fu_struct_genesys_ts_dynamic_gl3523_get_fs_connection_status: (skip): |
951 | | **/ |
952 | | gchar * |
953 | | fu_struct_genesys_ts_dynamic_gl3523_get_fs_connection_status(const FuStructGenesysTsDynamicGl3523 *st) |
954 | 0 | { |
955 | 0 | g_return_val_if_fail(st != NULL, NULL); |
956 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 5, 1, NULL); |
957 | 0 | } |
958 | | /** |
959 | | * fu_struct_genesys_ts_dynamic_gl3523_get_ls_connection_status: (skip): |
960 | | **/ |
961 | | gchar * |
962 | | fu_struct_genesys_ts_dynamic_gl3523_get_ls_connection_status(const FuStructGenesysTsDynamicGl3523 *st) |
963 | 0 | { |
964 | 0 | g_return_val_if_fail(st != NULL, NULL); |
965 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 6, 1, NULL); |
966 | 0 | } |
967 | | /** |
968 | | * fu_struct_genesys_ts_dynamic_gl3523_get_charging: (skip): |
969 | | **/ |
970 | | gchar * |
971 | | fu_struct_genesys_ts_dynamic_gl3523_get_charging(const FuStructGenesysTsDynamicGl3523 *st) |
972 | 0 | { |
973 | 0 | g_return_val_if_fail(st != NULL, NULL); |
974 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 7, 1, NULL); |
975 | 0 | } |
976 | | /** |
977 | | * fu_struct_genesys_ts_dynamic_gl3523_get_non_removable_port_status: (skip): |
978 | | **/ |
979 | | gchar * |
980 | | fu_struct_genesys_ts_dynamic_gl3523_get_non_removable_port_status(const FuStructGenesysTsDynamicGl3523 *st) |
981 | 0 | { |
982 | 0 | g_return_val_if_fail(st != NULL, NULL); |
983 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 8, 1, NULL); |
984 | 0 | } |
985 | | /** |
986 | | * fu_struct_genesys_ts_dynamic_gl3523_get_bonding: (skip): |
987 | | **/ |
988 | | gchar * |
989 | | fu_struct_genesys_ts_dynamic_gl3523_get_bonding(const FuStructGenesysTsDynamicGl3523 *st) |
990 | 0 | { |
991 | 0 | g_return_val_if_fail(st != NULL, NULL); |
992 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 9, 1, NULL); |
993 | 0 | } |
994 | | |
995 | | /* setters */ |
996 | | /** |
997 | | * fu_struct_genesys_ts_dynamic_gl3523_to_string: (skip): |
998 | | **/ |
999 | | static gchar * |
1000 | | fu_struct_genesys_ts_dynamic_gl3523_to_string(const FuStructGenesysTsDynamicGl3523 *st) |
1001 | 0 | { |
1002 | 0 | g_autoptr(GString) str = g_string_new("FuStructGenesysTsDynamicGl3523:\n"); |
1003 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1004 | 0 | { |
1005 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3523_get_running_mode(st); |
1006 | 0 | if (tmp != NULL) |
1007 | 0 | g_string_append_printf(str, " running_mode: %s\n", tmp); |
1008 | 0 | } |
1009 | 0 | { |
1010 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3523_get_ss_port_number(st); |
1011 | 0 | if (tmp != NULL) |
1012 | 0 | g_string_append_printf(str, " ss_port_number: %s\n", tmp); |
1013 | 0 | } |
1014 | 0 | { |
1015 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3523_get_hs_port_number(st); |
1016 | 0 | if (tmp != NULL) |
1017 | 0 | g_string_append_printf(str, " hs_port_number: %s\n", tmp); |
1018 | 0 | } |
1019 | 0 | { |
1020 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3523_get_ss_connection_status(st); |
1021 | 0 | if (tmp != NULL) |
1022 | 0 | g_string_append_printf(str, " ss_connection_status: %s\n", tmp); |
1023 | 0 | } |
1024 | 0 | { |
1025 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3523_get_hs_connection_status(st); |
1026 | 0 | if (tmp != NULL) |
1027 | 0 | g_string_append_printf(str, " hs_connection_status: %s\n", tmp); |
1028 | 0 | } |
1029 | 0 | { |
1030 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3523_get_fs_connection_status(st); |
1031 | 0 | if (tmp != NULL) |
1032 | 0 | g_string_append_printf(str, " fs_connection_status: %s\n", tmp); |
1033 | 0 | } |
1034 | 0 | { |
1035 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3523_get_ls_connection_status(st); |
1036 | 0 | if (tmp != NULL) |
1037 | 0 | g_string_append_printf(str, " ls_connection_status: %s\n", tmp); |
1038 | 0 | } |
1039 | 0 | { |
1040 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3523_get_charging(st); |
1041 | 0 | if (tmp != NULL) |
1042 | 0 | g_string_append_printf(str, " charging: %s\n", tmp); |
1043 | 0 | } |
1044 | 0 | { |
1045 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3523_get_non_removable_port_status(st); |
1046 | 0 | if (tmp != NULL) |
1047 | 0 | g_string_append_printf(str, " non_removable_port_status: %s\n", tmp); |
1048 | 0 | } |
1049 | 0 | { |
1050 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3523_get_bonding(st); |
1051 | 0 | if (tmp != NULL) |
1052 | 0 | g_string_append_printf(str, " bonding: %s\n", tmp); |
1053 | 0 | } |
1054 | 0 | if (str->len > 0) |
1055 | 0 | g_string_set_size(str, str->len - 1); |
1056 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
1057 | 0 | } |
1058 | | static gboolean |
1059 | | fu_struct_genesys_ts_dynamic_gl3523_validate_internal(FuStructGenesysTsDynamicGl3523 *st, GError **error) |
1060 | 0 | { |
1061 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
1062 | 0 | return TRUE; |
1063 | 0 | } |
1064 | | static gboolean |
1065 | | fu_struct_genesys_ts_dynamic_gl3523_parse_internal(FuStructGenesysTsDynamicGl3523 *st, GError **error) |
1066 | 0 | { |
1067 | 0 | if (g_getenv("FWUPD_VERBOSE") != NULL) { |
1068 | 0 | g_autofree gchar *str = fu_struct_genesys_ts_dynamic_gl3523_to_string(st); |
1069 | 0 | g_debug("%s", str); |
1070 | 0 | } |
1071 | 0 | if (!fu_struct_genesys_ts_dynamic_gl3523_validate_internal(st, error)) |
1072 | 0 | return FALSE; |
1073 | 0 | return TRUE; |
1074 | 0 | } |
1075 | | |
1076 | | /** |
1077 | | * fu_struct_genesys_ts_dynamic_gl3523_parse: (skip): |
1078 | | **/ |
1079 | | FuStructGenesysTsDynamicGl3523 * |
1080 | | fu_struct_genesys_ts_dynamic_gl3523_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
1081 | 0 | { |
1082 | 0 | g_autoptr(FuStructGenesysTsDynamicGl3523) st = fu_struct_genesys_ts_dynamic_gl3523_new_internal(); |
1083 | 0 | g_return_val_if_fail(buf != NULL, NULL); |
1084 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, NULL); |
1085 | 0 | if (!fu_memchk_read(bufsz, offset, 10, error)) { |
1086 | 0 | g_prefix_error_literal(error, "invalid struct FuStructGenesysTsDynamicGl3523: "); |
1087 | 0 | return NULL; |
1088 | 0 | } |
1089 | 0 | st->buf = g_byte_array_new(); |
1090 | 0 | g_byte_array_append(st->buf, buf + offset, 10); |
1091 | 0 | if (!fu_struct_genesys_ts_dynamic_gl3523_parse_internal(st, error)) |
1092 | 0 | return NULL; |
1093 | 0 | return g_steal_pointer(&st); |
1094 | 0 | } |
1095 | | /** |
1096 | | * fu_struct_genesys_ts_dynamic_gl3590_ref: (skip): |
1097 | | **/ |
1098 | | FuStructGenesysTsDynamicGl3590 * |
1099 | | fu_struct_genesys_ts_dynamic_gl3590_ref(FuStructGenesysTsDynamicGl3590 *st) |
1100 | 0 | { |
1101 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1102 | 0 | st->refcount++; |
1103 | 0 | return st; |
1104 | 0 | } |
1105 | | /** |
1106 | | * fu_struct_genesys_ts_dynamic_gl3590_unref: (skip): |
1107 | | **/ |
1108 | | void |
1109 | | fu_struct_genesys_ts_dynamic_gl3590_unref(FuStructGenesysTsDynamicGl3590 *st) |
1110 | 0 | { |
1111 | 0 | g_return_if_fail(st != NULL); |
1112 | 0 | if (st->refcount == 0) { |
1113 | 0 | g_critical("FuStructGenesysTsDynamicGl3590 refcount already zero"); |
1114 | 0 | return; |
1115 | 0 | } |
1116 | 0 | if (--st->refcount > 0) |
1117 | 0 | return; |
1118 | 0 | if (st->buf != NULL) |
1119 | 0 | g_byte_array_unref(st->buf); |
1120 | 0 | g_free(st); |
1121 | 0 | } |
1122 | | static FuStructGenesysTsDynamicGl3590 * |
1123 | | fu_struct_genesys_ts_dynamic_gl3590_new_internal(void) |
1124 | 0 | { |
1125 | 0 | FuStructGenesysTsDynamicGl3590 *st = g_new0(FuStructGenesysTsDynamicGl3590, 1); |
1126 | 0 | st->refcount = 1; |
1127 | 0 | return st; |
1128 | 0 | } |
1129 | | |
1130 | | /* getters */ |
1131 | | /** |
1132 | | * fu_struct_genesys_ts_dynamic_gl3590_get_running_mode: (skip): |
1133 | | **/ |
1134 | | gchar * |
1135 | | fu_struct_genesys_ts_dynamic_gl3590_get_running_mode(const FuStructGenesysTsDynamicGl3590 *st) |
1136 | 0 | { |
1137 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1138 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 0, 1, NULL); |
1139 | 0 | } |
1140 | | /** |
1141 | | * fu_struct_genesys_ts_dynamic_gl3590_get_ss_port_number: (skip): |
1142 | | **/ |
1143 | | gchar * |
1144 | | fu_struct_genesys_ts_dynamic_gl3590_get_ss_port_number(const FuStructGenesysTsDynamicGl3590 *st) |
1145 | 0 | { |
1146 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1147 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 1, 1, NULL); |
1148 | 0 | } |
1149 | | /** |
1150 | | * fu_struct_genesys_ts_dynamic_gl3590_get_hs_port_number: (skip): |
1151 | | **/ |
1152 | | gchar * |
1153 | | fu_struct_genesys_ts_dynamic_gl3590_get_hs_port_number(const FuStructGenesysTsDynamicGl3590 *st) |
1154 | 0 | { |
1155 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1156 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 2, 1, NULL); |
1157 | 0 | } |
1158 | | /** |
1159 | | * fu_struct_genesys_ts_dynamic_gl3590_get_ss_connection_status: (skip): |
1160 | | **/ |
1161 | | gchar * |
1162 | | fu_struct_genesys_ts_dynamic_gl3590_get_ss_connection_status(const FuStructGenesysTsDynamicGl3590 *st) |
1163 | 0 | { |
1164 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1165 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 3, 1, NULL); |
1166 | 0 | } |
1167 | | /** |
1168 | | * fu_struct_genesys_ts_dynamic_gl3590_get_hs_connection_status: (skip): |
1169 | | **/ |
1170 | | gchar * |
1171 | | fu_struct_genesys_ts_dynamic_gl3590_get_hs_connection_status(const FuStructGenesysTsDynamicGl3590 *st) |
1172 | 0 | { |
1173 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1174 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 4, 1, NULL); |
1175 | 0 | } |
1176 | | /** |
1177 | | * fu_struct_genesys_ts_dynamic_gl3590_get_fs_connection_status: (skip): |
1178 | | **/ |
1179 | | gchar * |
1180 | | fu_struct_genesys_ts_dynamic_gl3590_get_fs_connection_status(const FuStructGenesysTsDynamicGl3590 *st) |
1181 | 0 | { |
1182 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1183 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 5, 1, NULL); |
1184 | 0 | } |
1185 | | /** |
1186 | | * fu_struct_genesys_ts_dynamic_gl3590_get_ls_connection_status: (skip): |
1187 | | **/ |
1188 | | gchar * |
1189 | | fu_struct_genesys_ts_dynamic_gl3590_get_ls_connection_status(const FuStructGenesysTsDynamicGl3590 *st) |
1190 | 0 | { |
1191 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1192 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 6, 1, NULL); |
1193 | 0 | } |
1194 | | /** |
1195 | | * fu_struct_genesys_ts_dynamic_gl3590_get_charging: (skip): |
1196 | | **/ |
1197 | | gchar * |
1198 | | fu_struct_genesys_ts_dynamic_gl3590_get_charging(const FuStructGenesysTsDynamicGl3590 *st) |
1199 | 0 | { |
1200 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1201 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 7, 1, NULL); |
1202 | 0 | } |
1203 | | /** |
1204 | | * fu_struct_genesys_ts_dynamic_gl3590_get_non_removable_port_status: (skip): |
1205 | | **/ |
1206 | | gchar * |
1207 | | fu_struct_genesys_ts_dynamic_gl3590_get_non_removable_port_status(const FuStructGenesysTsDynamicGl3590 *st) |
1208 | 0 | { |
1209 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1210 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 8, 1, NULL); |
1211 | 0 | } |
1212 | | /** |
1213 | | * fu_struct_genesys_ts_dynamic_gl3590_get_bonding: (skip): |
1214 | | **/ |
1215 | | guint8 |
1216 | | fu_struct_genesys_ts_dynamic_gl3590_get_bonding(const FuStructGenesysTsDynamicGl3590 *st) |
1217 | 0 | { |
1218 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1219 | 0 | return st->buf->data[9]; |
1220 | 0 | } |
1221 | | |
1222 | | /* setters */ |
1223 | | /** |
1224 | | * fu_struct_genesys_ts_dynamic_gl3590_to_string: (skip): |
1225 | | **/ |
1226 | | static gchar * |
1227 | | fu_struct_genesys_ts_dynamic_gl3590_to_string(const FuStructGenesysTsDynamicGl3590 *st) |
1228 | 0 | { |
1229 | 0 | g_autoptr(GString) str = g_string_new("FuStructGenesysTsDynamicGl3590:\n"); |
1230 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1231 | 0 | { |
1232 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3590_get_running_mode(st); |
1233 | 0 | if (tmp != NULL) |
1234 | 0 | g_string_append_printf(str, " running_mode: %s\n", tmp); |
1235 | 0 | } |
1236 | 0 | { |
1237 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3590_get_ss_port_number(st); |
1238 | 0 | if (tmp != NULL) |
1239 | 0 | g_string_append_printf(str, " ss_port_number: %s\n", tmp); |
1240 | 0 | } |
1241 | 0 | { |
1242 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3590_get_hs_port_number(st); |
1243 | 0 | if (tmp != NULL) |
1244 | 0 | g_string_append_printf(str, " hs_port_number: %s\n", tmp); |
1245 | 0 | } |
1246 | 0 | { |
1247 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3590_get_ss_connection_status(st); |
1248 | 0 | if (tmp != NULL) |
1249 | 0 | g_string_append_printf(str, " ss_connection_status: %s\n", tmp); |
1250 | 0 | } |
1251 | 0 | { |
1252 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3590_get_hs_connection_status(st); |
1253 | 0 | if (tmp != NULL) |
1254 | 0 | g_string_append_printf(str, " hs_connection_status: %s\n", tmp); |
1255 | 0 | } |
1256 | 0 | { |
1257 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3590_get_fs_connection_status(st); |
1258 | 0 | if (tmp != NULL) |
1259 | 0 | g_string_append_printf(str, " fs_connection_status: %s\n", tmp); |
1260 | 0 | } |
1261 | 0 | { |
1262 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3590_get_ls_connection_status(st); |
1263 | 0 | if (tmp != NULL) |
1264 | 0 | g_string_append_printf(str, " ls_connection_status: %s\n", tmp); |
1265 | 0 | } |
1266 | 0 | { |
1267 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3590_get_charging(st); |
1268 | 0 | if (tmp != NULL) |
1269 | 0 | g_string_append_printf(str, " charging: %s\n", tmp); |
1270 | 0 | } |
1271 | 0 | { |
1272 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3590_get_non_removable_port_status(st); |
1273 | 0 | if (tmp != NULL) |
1274 | 0 | g_string_append_printf(str, " non_removable_port_status: %s\n", tmp); |
1275 | 0 | } |
1276 | 0 | g_string_append_printf(str, " bonding: 0x%x\n", |
1277 | 0 | (guint) fu_struct_genesys_ts_dynamic_gl3590_get_bonding(st)); |
1278 | 0 | if (str->len > 0) |
1279 | 0 | g_string_set_size(str, str->len - 1); |
1280 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
1281 | 0 | } |
1282 | | static gboolean |
1283 | | fu_struct_genesys_ts_dynamic_gl3590_validate_internal(FuStructGenesysTsDynamicGl3590 *st, GError **error) |
1284 | 0 | { |
1285 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
1286 | 0 | return TRUE; |
1287 | 0 | } |
1288 | | static gboolean |
1289 | | fu_struct_genesys_ts_dynamic_gl3590_parse_internal(FuStructGenesysTsDynamicGl3590 *st, GError **error) |
1290 | 0 | { |
1291 | 0 | if (g_getenv("FWUPD_VERBOSE") != NULL) { |
1292 | 0 | g_autofree gchar *str = fu_struct_genesys_ts_dynamic_gl3590_to_string(st); |
1293 | 0 | g_debug("%s", str); |
1294 | 0 | } |
1295 | 0 | if (!fu_struct_genesys_ts_dynamic_gl3590_validate_internal(st, error)) |
1296 | 0 | return FALSE; |
1297 | 0 | return TRUE; |
1298 | 0 | } |
1299 | | |
1300 | | /** |
1301 | | * fu_struct_genesys_ts_dynamic_gl3590_parse: (skip): |
1302 | | **/ |
1303 | | FuStructGenesysTsDynamicGl3590 * |
1304 | | fu_struct_genesys_ts_dynamic_gl3590_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
1305 | 0 | { |
1306 | 0 | g_autoptr(FuStructGenesysTsDynamicGl3590) st = fu_struct_genesys_ts_dynamic_gl3590_new_internal(); |
1307 | 0 | g_return_val_if_fail(buf != NULL, NULL); |
1308 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, NULL); |
1309 | 0 | if (!fu_memchk_read(bufsz, offset, 10, error)) { |
1310 | 0 | g_prefix_error_literal(error, "invalid struct FuStructGenesysTsDynamicGl3590: "); |
1311 | 0 | return NULL; |
1312 | 0 | } |
1313 | 0 | st->buf = g_byte_array_new(); |
1314 | 0 | g_byte_array_append(st->buf, buf + offset, 10); |
1315 | 0 | if (!fu_struct_genesys_ts_dynamic_gl3590_parse_internal(st, error)) |
1316 | 0 | return NULL; |
1317 | 0 | return g_steal_pointer(&st); |
1318 | 0 | } |
1319 | | /** |
1320 | | * fu_struct_genesys_ts_dynamic_gl359030_ref: (skip): |
1321 | | **/ |
1322 | | FuStructGenesysTsDynamicGl359030 * |
1323 | | fu_struct_genesys_ts_dynamic_gl359030_ref(FuStructGenesysTsDynamicGl359030 *st) |
1324 | 0 | { |
1325 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1326 | 0 | st->refcount++; |
1327 | 0 | return st; |
1328 | 0 | } |
1329 | | /** |
1330 | | * fu_struct_genesys_ts_dynamic_gl359030_unref: (skip): |
1331 | | **/ |
1332 | | void |
1333 | | fu_struct_genesys_ts_dynamic_gl359030_unref(FuStructGenesysTsDynamicGl359030 *st) |
1334 | 0 | { |
1335 | 0 | g_return_if_fail(st != NULL); |
1336 | 0 | if (st->refcount == 0) { |
1337 | 0 | g_critical("FuStructGenesysTsDynamicGl359030 refcount already zero"); |
1338 | 0 | return; |
1339 | 0 | } |
1340 | 0 | if (--st->refcount > 0) |
1341 | 0 | return; |
1342 | 0 | if (st->buf != NULL) |
1343 | 0 | g_byte_array_unref(st->buf); |
1344 | 0 | g_free(st); |
1345 | 0 | } |
1346 | | static FuStructGenesysTsDynamicGl359030 * |
1347 | | fu_struct_genesys_ts_dynamic_gl359030_new_internal(void) |
1348 | 0 | { |
1349 | 0 | FuStructGenesysTsDynamicGl359030 *st = g_new0(FuStructGenesysTsDynamicGl359030, 1); |
1350 | 0 | st->refcount = 1; |
1351 | 0 | return st; |
1352 | 0 | } |
1353 | | |
1354 | | /* getters */ |
1355 | | /** |
1356 | | * fu_struct_genesys_ts_dynamic_gl359030_get_running_mode: (skip): |
1357 | | **/ |
1358 | | gchar * |
1359 | | fu_struct_genesys_ts_dynamic_gl359030_get_running_mode(const FuStructGenesysTsDynamicGl359030 *st) |
1360 | 0 | { |
1361 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1362 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 0, 1, NULL); |
1363 | 0 | } |
1364 | | /** |
1365 | | * fu_struct_genesys_ts_dynamic_gl359030_get_ss_port_number: (skip): |
1366 | | **/ |
1367 | | gchar * |
1368 | | fu_struct_genesys_ts_dynamic_gl359030_get_ss_port_number(const FuStructGenesysTsDynamicGl359030 *st) |
1369 | 0 | { |
1370 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1371 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 1, 1, NULL); |
1372 | 0 | } |
1373 | | /** |
1374 | | * fu_struct_genesys_ts_dynamic_gl359030_get_hs_port_number: (skip): |
1375 | | **/ |
1376 | | gchar * |
1377 | | fu_struct_genesys_ts_dynamic_gl359030_get_hs_port_number(const FuStructGenesysTsDynamicGl359030 *st) |
1378 | 0 | { |
1379 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1380 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 2, 1, NULL); |
1381 | 0 | } |
1382 | | /** |
1383 | | * fu_struct_genesys_ts_dynamic_gl359030_get_ss_connection_status: (skip): |
1384 | | **/ |
1385 | | gchar * |
1386 | | fu_struct_genesys_ts_dynamic_gl359030_get_ss_connection_status(const FuStructGenesysTsDynamicGl359030 *st) |
1387 | 0 | { |
1388 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1389 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 3, 1, NULL); |
1390 | 0 | } |
1391 | | /** |
1392 | | * fu_struct_genesys_ts_dynamic_gl359030_get_hs_connection_status: (skip): |
1393 | | **/ |
1394 | | gchar * |
1395 | | fu_struct_genesys_ts_dynamic_gl359030_get_hs_connection_status(const FuStructGenesysTsDynamicGl359030 *st) |
1396 | 0 | { |
1397 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1398 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 4, 1, NULL); |
1399 | 0 | } |
1400 | | /** |
1401 | | * fu_struct_genesys_ts_dynamic_gl359030_get_fs_connection_status: (skip): |
1402 | | **/ |
1403 | | gchar * |
1404 | | fu_struct_genesys_ts_dynamic_gl359030_get_fs_connection_status(const FuStructGenesysTsDynamicGl359030 *st) |
1405 | 0 | { |
1406 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1407 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 5, 1, NULL); |
1408 | 0 | } |
1409 | | /** |
1410 | | * fu_struct_genesys_ts_dynamic_gl359030_get_ls_connection_status: (skip): |
1411 | | **/ |
1412 | | gchar * |
1413 | | fu_struct_genesys_ts_dynamic_gl359030_get_ls_connection_status(const FuStructGenesysTsDynamicGl359030 *st) |
1414 | 0 | { |
1415 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1416 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 6, 1, NULL); |
1417 | 0 | } |
1418 | | /** |
1419 | | * fu_struct_genesys_ts_dynamic_gl359030_get_charging: (skip): |
1420 | | **/ |
1421 | | gchar * |
1422 | | fu_struct_genesys_ts_dynamic_gl359030_get_charging(const FuStructGenesysTsDynamicGl359030 *st) |
1423 | 0 | { |
1424 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1425 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 7, 1, NULL); |
1426 | 0 | } |
1427 | | /** |
1428 | | * fu_struct_genesys_ts_dynamic_gl359030_get_non_removable_port_status: (skip): |
1429 | | **/ |
1430 | | gchar * |
1431 | | fu_struct_genesys_ts_dynamic_gl359030_get_non_removable_port_status(const FuStructGenesysTsDynamicGl359030 *st) |
1432 | 0 | { |
1433 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1434 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 8, 1, NULL); |
1435 | 0 | } |
1436 | | /** |
1437 | | * fu_struct_genesys_ts_dynamic_gl359030_get_bonding: (skip): |
1438 | | **/ |
1439 | | guint8 |
1440 | | fu_struct_genesys_ts_dynamic_gl359030_get_bonding(const FuStructGenesysTsDynamicGl359030 *st) |
1441 | 0 | { |
1442 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1443 | 0 | return st->buf->data[9]; |
1444 | 0 | } |
1445 | | /** |
1446 | | * fu_struct_genesys_ts_dynamic_gl359030_get_hub_fw_status: (skip): |
1447 | | **/ |
1448 | | FuGenesysFwStatus |
1449 | | fu_struct_genesys_ts_dynamic_gl359030_get_hub_fw_status(const FuStructGenesysTsDynamicGl359030 *st) |
1450 | 0 | { |
1451 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1452 | 0 | return st->buf->data[10]; |
1453 | 0 | } |
1454 | | /** |
1455 | | * fu_struct_genesys_ts_dynamic_gl359030_get_dev_fw_status: (skip): |
1456 | | **/ |
1457 | | FuGenesysFwStatus |
1458 | | fu_struct_genesys_ts_dynamic_gl359030_get_dev_fw_status(const FuStructGenesysTsDynamicGl359030 *st) |
1459 | 0 | { |
1460 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1461 | 0 | return st->buf->data[11]; |
1462 | 0 | } |
1463 | | /** |
1464 | | * fu_struct_genesys_ts_dynamic_gl359030_get_dev_fw_version: (skip): |
1465 | | **/ |
1466 | | guint16 |
1467 | | fu_struct_genesys_ts_dynamic_gl359030_get_dev_fw_version(const FuStructGenesysTsDynamicGl359030 *st) |
1468 | 0 | { |
1469 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1470 | 0 | return fu_memread_uint16(st->buf->data + 12, G_LITTLE_ENDIAN); |
1471 | 0 | } |
1472 | | |
1473 | | /* setters */ |
1474 | | /** |
1475 | | * fu_struct_genesys_ts_dynamic_gl359030_to_string: (skip): |
1476 | | **/ |
1477 | | static gchar * |
1478 | | fu_struct_genesys_ts_dynamic_gl359030_to_string(const FuStructGenesysTsDynamicGl359030 *st) |
1479 | 0 | { |
1480 | 0 | g_autoptr(GString) str = g_string_new("FuStructGenesysTsDynamicGl359030:\n"); |
1481 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1482 | 0 | { |
1483 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl359030_get_running_mode(st); |
1484 | 0 | if (tmp != NULL) |
1485 | 0 | g_string_append_printf(str, " running_mode: %s\n", tmp); |
1486 | 0 | } |
1487 | 0 | { |
1488 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl359030_get_ss_port_number(st); |
1489 | 0 | if (tmp != NULL) |
1490 | 0 | g_string_append_printf(str, " ss_port_number: %s\n", tmp); |
1491 | 0 | } |
1492 | 0 | { |
1493 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl359030_get_hs_port_number(st); |
1494 | 0 | if (tmp != NULL) |
1495 | 0 | g_string_append_printf(str, " hs_port_number: %s\n", tmp); |
1496 | 0 | } |
1497 | 0 | { |
1498 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl359030_get_ss_connection_status(st); |
1499 | 0 | if (tmp != NULL) |
1500 | 0 | g_string_append_printf(str, " ss_connection_status: %s\n", tmp); |
1501 | 0 | } |
1502 | 0 | { |
1503 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl359030_get_hs_connection_status(st); |
1504 | 0 | if (tmp != NULL) |
1505 | 0 | g_string_append_printf(str, " hs_connection_status: %s\n", tmp); |
1506 | 0 | } |
1507 | 0 | { |
1508 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl359030_get_fs_connection_status(st); |
1509 | 0 | if (tmp != NULL) |
1510 | 0 | g_string_append_printf(str, " fs_connection_status: %s\n", tmp); |
1511 | 0 | } |
1512 | 0 | { |
1513 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl359030_get_ls_connection_status(st); |
1514 | 0 | if (tmp != NULL) |
1515 | 0 | g_string_append_printf(str, " ls_connection_status: %s\n", tmp); |
1516 | 0 | } |
1517 | 0 | { |
1518 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl359030_get_charging(st); |
1519 | 0 | if (tmp != NULL) |
1520 | 0 | g_string_append_printf(str, " charging: %s\n", tmp); |
1521 | 0 | } |
1522 | 0 | { |
1523 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl359030_get_non_removable_port_status(st); |
1524 | 0 | if (tmp != NULL) |
1525 | 0 | g_string_append_printf(str, " non_removable_port_status: %s\n", tmp); |
1526 | 0 | } |
1527 | 0 | g_string_append_printf(str, " bonding: 0x%x\n", |
1528 | 0 | (guint) fu_struct_genesys_ts_dynamic_gl359030_get_bonding(st)); |
1529 | 0 | { |
1530 | 0 | const gchar *tmp = fu_genesys_fw_status_to_string(fu_struct_genesys_ts_dynamic_gl359030_get_hub_fw_status(st)); |
1531 | 0 | if (tmp != NULL) { |
1532 | 0 | g_string_append_printf(str, " hub_fw_status: 0x%x [%s]\n", (guint) fu_struct_genesys_ts_dynamic_gl359030_get_hub_fw_status(st), tmp); |
1533 | 0 | } else { |
1534 | 0 | g_string_append_printf(str, " hub_fw_status: 0x%x\n", (guint) fu_struct_genesys_ts_dynamic_gl359030_get_hub_fw_status(st)); |
1535 | 0 | } |
1536 | 0 | } |
1537 | 0 | { |
1538 | 0 | const gchar *tmp = fu_genesys_fw_status_to_string(fu_struct_genesys_ts_dynamic_gl359030_get_dev_fw_status(st)); |
1539 | 0 | if (tmp != NULL) { |
1540 | 0 | g_string_append_printf(str, " dev_fw_status: 0x%x [%s]\n", (guint) fu_struct_genesys_ts_dynamic_gl359030_get_dev_fw_status(st), tmp); |
1541 | 0 | } else { |
1542 | 0 | g_string_append_printf(str, " dev_fw_status: 0x%x\n", (guint) fu_struct_genesys_ts_dynamic_gl359030_get_dev_fw_status(st)); |
1543 | 0 | } |
1544 | 0 | } |
1545 | 0 | g_string_append_printf(str, " dev_fw_version: 0x%x\n", |
1546 | 0 | (guint) fu_struct_genesys_ts_dynamic_gl359030_get_dev_fw_version(st)); |
1547 | 0 | if (str->len > 0) |
1548 | 0 | g_string_set_size(str, str->len - 1); |
1549 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
1550 | 0 | } |
1551 | | static gboolean |
1552 | | fu_struct_genesys_ts_dynamic_gl359030_validate_internal(FuStructGenesysTsDynamicGl359030 *st, GError **error) |
1553 | 0 | { |
1554 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
1555 | 0 | return TRUE; |
1556 | 0 | } |
1557 | | static gboolean |
1558 | | fu_struct_genesys_ts_dynamic_gl359030_parse_internal(FuStructGenesysTsDynamicGl359030 *st, GError **error) |
1559 | 0 | { |
1560 | 0 | if (g_getenv("FWUPD_VERBOSE") != NULL) { |
1561 | 0 | g_autofree gchar *str = fu_struct_genesys_ts_dynamic_gl359030_to_string(st); |
1562 | 0 | g_debug("%s", str); |
1563 | 0 | } |
1564 | 0 | if (!fu_struct_genesys_ts_dynamic_gl359030_validate_internal(st, error)) |
1565 | 0 | return FALSE; |
1566 | 0 | return TRUE; |
1567 | 0 | } |
1568 | | |
1569 | | /** |
1570 | | * fu_struct_genesys_ts_dynamic_gl359030_parse: (skip): |
1571 | | **/ |
1572 | | FuStructGenesysTsDynamicGl359030 * |
1573 | | fu_struct_genesys_ts_dynamic_gl359030_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
1574 | 0 | { |
1575 | 0 | g_autoptr(FuStructGenesysTsDynamicGl359030) st = fu_struct_genesys_ts_dynamic_gl359030_new_internal(); |
1576 | 0 | g_return_val_if_fail(buf != NULL, NULL); |
1577 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, NULL); |
1578 | 0 | if (!fu_memchk_read(bufsz, offset, 14, error)) { |
1579 | 0 | g_prefix_error_literal(error, "invalid struct FuStructGenesysTsDynamicGl359030: "); |
1580 | 0 | return NULL; |
1581 | 0 | } |
1582 | 0 | st->buf = g_byte_array_new(); |
1583 | 0 | g_byte_array_append(st->buf, buf + offset, 14); |
1584 | 0 | if (!fu_struct_genesys_ts_dynamic_gl359030_parse_internal(st, error)) |
1585 | 0 | return NULL; |
1586 | 0 | return g_steal_pointer(&st); |
1587 | 0 | } |
1588 | | /** |
1589 | | * fu_struct_genesys_ts_dynamic_gl3525_ref: (skip): |
1590 | | **/ |
1591 | | FuStructGenesysTsDynamicGl3525 * |
1592 | | fu_struct_genesys_ts_dynamic_gl3525_ref(FuStructGenesysTsDynamicGl3525 *st) |
1593 | 0 | { |
1594 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1595 | 0 | st->refcount++; |
1596 | 0 | return st; |
1597 | 0 | } |
1598 | | /** |
1599 | | * fu_struct_genesys_ts_dynamic_gl3525_unref: (skip): |
1600 | | **/ |
1601 | | void |
1602 | | fu_struct_genesys_ts_dynamic_gl3525_unref(FuStructGenesysTsDynamicGl3525 *st) |
1603 | 0 | { |
1604 | 0 | g_return_if_fail(st != NULL); |
1605 | 0 | if (st->refcount == 0) { |
1606 | 0 | g_critical("FuStructGenesysTsDynamicGl3525 refcount already zero"); |
1607 | 0 | return; |
1608 | 0 | } |
1609 | 0 | if (--st->refcount > 0) |
1610 | 0 | return; |
1611 | 0 | if (st->buf != NULL) |
1612 | 0 | g_byte_array_unref(st->buf); |
1613 | 0 | g_free(st); |
1614 | 0 | } |
1615 | | static FuStructGenesysTsDynamicGl3525 * |
1616 | | fu_struct_genesys_ts_dynamic_gl3525_new_internal(void) |
1617 | 0 | { |
1618 | 0 | FuStructGenesysTsDynamicGl3525 *st = g_new0(FuStructGenesysTsDynamicGl3525, 1); |
1619 | 0 | st->refcount = 1; |
1620 | 0 | return st; |
1621 | 0 | } |
1622 | | |
1623 | | /* getters */ |
1624 | | /** |
1625 | | * fu_struct_genesys_ts_dynamic_gl3525_get_running_mode: (skip): |
1626 | | **/ |
1627 | | gchar * |
1628 | | fu_struct_genesys_ts_dynamic_gl3525_get_running_mode(const FuStructGenesysTsDynamicGl3525 *st) |
1629 | 0 | { |
1630 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1631 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 0, 1, NULL); |
1632 | 0 | } |
1633 | | /** |
1634 | | * fu_struct_genesys_ts_dynamic_gl3525_get_ss_port_number: (skip): |
1635 | | **/ |
1636 | | gchar * |
1637 | | fu_struct_genesys_ts_dynamic_gl3525_get_ss_port_number(const FuStructGenesysTsDynamicGl3525 *st) |
1638 | 0 | { |
1639 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1640 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 1, 1, NULL); |
1641 | 0 | } |
1642 | | /** |
1643 | | * fu_struct_genesys_ts_dynamic_gl3525_get_hs_port_number: (skip): |
1644 | | **/ |
1645 | | gchar * |
1646 | | fu_struct_genesys_ts_dynamic_gl3525_get_hs_port_number(const FuStructGenesysTsDynamicGl3525 *st) |
1647 | 0 | { |
1648 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1649 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 2, 1, NULL); |
1650 | 0 | } |
1651 | | /** |
1652 | | * fu_struct_genesys_ts_dynamic_gl3525_get_ss_connection_status: (skip): |
1653 | | **/ |
1654 | | gchar * |
1655 | | fu_struct_genesys_ts_dynamic_gl3525_get_ss_connection_status(const FuStructGenesysTsDynamicGl3525 *st) |
1656 | 0 | { |
1657 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1658 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 3, 1, NULL); |
1659 | 0 | } |
1660 | | /** |
1661 | | * fu_struct_genesys_ts_dynamic_gl3525_get_hs_connection_status: (skip): |
1662 | | **/ |
1663 | | gchar * |
1664 | | fu_struct_genesys_ts_dynamic_gl3525_get_hs_connection_status(const FuStructGenesysTsDynamicGl3525 *st) |
1665 | 0 | { |
1666 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1667 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 4, 1, NULL); |
1668 | 0 | } |
1669 | | /** |
1670 | | * fu_struct_genesys_ts_dynamic_gl3525_get_fs_connection_status: (skip): |
1671 | | **/ |
1672 | | gchar * |
1673 | | fu_struct_genesys_ts_dynamic_gl3525_get_fs_connection_status(const FuStructGenesysTsDynamicGl3525 *st) |
1674 | 0 | { |
1675 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1676 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 5, 1, NULL); |
1677 | 0 | } |
1678 | | /** |
1679 | | * fu_struct_genesys_ts_dynamic_gl3525_get_ls_connection_status: (skip): |
1680 | | **/ |
1681 | | gchar * |
1682 | | fu_struct_genesys_ts_dynamic_gl3525_get_ls_connection_status(const FuStructGenesysTsDynamicGl3525 *st) |
1683 | 0 | { |
1684 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1685 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 6, 1, NULL); |
1686 | 0 | } |
1687 | | /** |
1688 | | * fu_struct_genesys_ts_dynamic_gl3525_get_charging: (skip): |
1689 | | **/ |
1690 | | gchar * |
1691 | | fu_struct_genesys_ts_dynamic_gl3525_get_charging(const FuStructGenesysTsDynamicGl3525 *st) |
1692 | 0 | { |
1693 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1694 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 7, 1, NULL); |
1695 | 0 | } |
1696 | | /** |
1697 | | * fu_struct_genesys_ts_dynamic_gl3525_get_non_removable_port_status: (skip): |
1698 | | **/ |
1699 | | gchar * |
1700 | | fu_struct_genesys_ts_dynamic_gl3525_get_non_removable_port_status(const FuStructGenesysTsDynamicGl3525 *st) |
1701 | 0 | { |
1702 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1703 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 8, 1, NULL); |
1704 | 0 | } |
1705 | | /** |
1706 | | * fu_struct_genesys_ts_dynamic_gl3525_get_bonding: (skip): |
1707 | | **/ |
1708 | | guint8 |
1709 | | fu_struct_genesys_ts_dynamic_gl3525_get_bonding(const FuStructGenesysTsDynamicGl3525 *st) |
1710 | 0 | { |
1711 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1712 | 0 | return st->buf->data[9]; |
1713 | 0 | } |
1714 | | /** |
1715 | | * fu_struct_genesys_ts_dynamic_gl3525_get_hub_fw_status: (skip): |
1716 | | **/ |
1717 | | FuGenesysFwStatus |
1718 | | fu_struct_genesys_ts_dynamic_gl3525_get_hub_fw_status(const FuStructGenesysTsDynamicGl3525 *st) |
1719 | 0 | { |
1720 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1721 | 0 | return st->buf->data[10]; |
1722 | 0 | } |
1723 | | /** |
1724 | | * fu_struct_genesys_ts_dynamic_gl3525_get_pd_fw_status: (skip): |
1725 | | **/ |
1726 | | FuGenesysFwStatus |
1727 | | fu_struct_genesys_ts_dynamic_gl3525_get_pd_fw_status(const FuStructGenesysTsDynamicGl3525 *st) |
1728 | 0 | { |
1729 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1730 | 0 | return st->buf->data[11]; |
1731 | 0 | } |
1732 | | /** |
1733 | | * fu_struct_genesys_ts_dynamic_gl3525_get_pd_fw_version: (skip): |
1734 | | **/ |
1735 | | guint16 |
1736 | | fu_struct_genesys_ts_dynamic_gl3525_get_pd_fw_version(const FuStructGenesysTsDynamicGl3525 *st) |
1737 | 0 | { |
1738 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1739 | 0 | return fu_memread_uint16(st->buf->data + 12, G_LITTLE_ENDIAN); |
1740 | 0 | } |
1741 | | /** |
1742 | | * fu_struct_genesys_ts_dynamic_gl3525_get_dev_fw_status: (skip): |
1743 | | **/ |
1744 | | FuGenesysFwStatus |
1745 | | fu_struct_genesys_ts_dynamic_gl3525_get_dev_fw_status(const FuStructGenesysTsDynamicGl3525 *st) |
1746 | 0 | { |
1747 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1748 | 0 | return st->buf->data[14]; |
1749 | 0 | } |
1750 | | /** |
1751 | | * fu_struct_genesys_ts_dynamic_gl3525_get_dev_fw_version: (skip): |
1752 | | **/ |
1753 | | guint16 |
1754 | | fu_struct_genesys_ts_dynamic_gl3525_get_dev_fw_version(const FuStructGenesysTsDynamicGl3525 *st) |
1755 | 0 | { |
1756 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1757 | 0 | return fu_memread_uint16(st->buf->data + 15, G_LITTLE_ENDIAN); |
1758 | 0 | } |
1759 | | |
1760 | | /* setters */ |
1761 | | /** |
1762 | | * fu_struct_genesys_ts_dynamic_gl3525_to_string: (skip): |
1763 | | **/ |
1764 | | static gchar * |
1765 | | fu_struct_genesys_ts_dynamic_gl3525_to_string(const FuStructGenesysTsDynamicGl3525 *st) |
1766 | 0 | { |
1767 | 0 | g_autoptr(GString) str = g_string_new("FuStructGenesysTsDynamicGl3525:\n"); |
1768 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1769 | 0 | { |
1770 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3525_get_running_mode(st); |
1771 | 0 | if (tmp != NULL) |
1772 | 0 | g_string_append_printf(str, " running_mode: %s\n", tmp); |
1773 | 0 | } |
1774 | 0 | { |
1775 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3525_get_ss_port_number(st); |
1776 | 0 | if (tmp != NULL) |
1777 | 0 | g_string_append_printf(str, " ss_port_number: %s\n", tmp); |
1778 | 0 | } |
1779 | 0 | { |
1780 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3525_get_hs_port_number(st); |
1781 | 0 | if (tmp != NULL) |
1782 | 0 | g_string_append_printf(str, " hs_port_number: %s\n", tmp); |
1783 | 0 | } |
1784 | 0 | { |
1785 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3525_get_ss_connection_status(st); |
1786 | 0 | if (tmp != NULL) |
1787 | 0 | g_string_append_printf(str, " ss_connection_status: %s\n", tmp); |
1788 | 0 | } |
1789 | 0 | { |
1790 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3525_get_hs_connection_status(st); |
1791 | 0 | if (tmp != NULL) |
1792 | 0 | g_string_append_printf(str, " hs_connection_status: %s\n", tmp); |
1793 | 0 | } |
1794 | 0 | { |
1795 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3525_get_fs_connection_status(st); |
1796 | 0 | if (tmp != NULL) |
1797 | 0 | g_string_append_printf(str, " fs_connection_status: %s\n", tmp); |
1798 | 0 | } |
1799 | 0 | { |
1800 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3525_get_ls_connection_status(st); |
1801 | 0 | if (tmp != NULL) |
1802 | 0 | g_string_append_printf(str, " ls_connection_status: %s\n", tmp); |
1803 | 0 | } |
1804 | 0 | { |
1805 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3525_get_charging(st); |
1806 | 0 | if (tmp != NULL) |
1807 | 0 | g_string_append_printf(str, " charging: %s\n", tmp); |
1808 | 0 | } |
1809 | 0 | { |
1810 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3525_get_non_removable_port_status(st); |
1811 | 0 | if (tmp != NULL) |
1812 | 0 | g_string_append_printf(str, " non_removable_port_status: %s\n", tmp); |
1813 | 0 | } |
1814 | 0 | g_string_append_printf(str, " bonding: 0x%x\n", |
1815 | 0 | (guint) fu_struct_genesys_ts_dynamic_gl3525_get_bonding(st)); |
1816 | 0 | { |
1817 | 0 | const gchar *tmp = fu_genesys_fw_status_to_string(fu_struct_genesys_ts_dynamic_gl3525_get_hub_fw_status(st)); |
1818 | 0 | if (tmp != NULL) { |
1819 | 0 | g_string_append_printf(str, " hub_fw_status: 0x%x [%s]\n", (guint) fu_struct_genesys_ts_dynamic_gl3525_get_hub_fw_status(st), tmp); |
1820 | 0 | } else { |
1821 | 0 | g_string_append_printf(str, " hub_fw_status: 0x%x\n", (guint) fu_struct_genesys_ts_dynamic_gl3525_get_hub_fw_status(st)); |
1822 | 0 | } |
1823 | 0 | } |
1824 | 0 | { |
1825 | 0 | const gchar *tmp = fu_genesys_fw_status_to_string(fu_struct_genesys_ts_dynamic_gl3525_get_pd_fw_status(st)); |
1826 | 0 | if (tmp != NULL) { |
1827 | 0 | g_string_append_printf(str, " pd_fw_status: 0x%x [%s]\n", (guint) fu_struct_genesys_ts_dynamic_gl3525_get_pd_fw_status(st), tmp); |
1828 | 0 | } else { |
1829 | 0 | g_string_append_printf(str, " pd_fw_status: 0x%x\n", (guint) fu_struct_genesys_ts_dynamic_gl3525_get_pd_fw_status(st)); |
1830 | 0 | } |
1831 | 0 | } |
1832 | 0 | g_string_append_printf(str, " pd_fw_version: 0x%x\n", |
1833 | 0 | (guint) fu_struct_genesys_ts_dynamic_gl3525_get_pd_fw_version(st)); |
1834 | 0 | { |
1835 | 0 | const gchar *tmp = fu_genesys_fw_status_to_string(fu_struct_genesys_ts_dynamic_gl3525_get_dev_fw_status(st)); |
1836 | 0 | if (tmp != NULL) { |
1837 | 0 | g_string_append_printf(str, " dev_fw_status: 0x%x [%s]\n", (guint) fu_struct_genesys_ts_dynamic_gl3525_get_dev_fw_status(st), tmp); |
1838 | 0 | } else { |
1839 | 0 | g_string_append_printf(str, " dev_fw_status: 0x%x\n", (guint) fu_struct_genesys_ts_dynamic_gl3525_get_dev_fw_status(st)); |
1840 | 0 | } |
1841 | 0 | } |
1842 | 0 | g_string_append_printf(str, " dev_fw_version: 0x%x\n", |
1843 | 0 | (guint) fu_struct_genesys_ts_dynamic_gl3525_get_dev_fw_version(st)); |
1844 | 0 | if (str->len > 0) |
1845 | 0 | g_string_set_size(str, str->len - 1); |
1846 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
1847 | 0 | } |
1848 | | static gboolean |
1849 | | fu_struct_genesys_ts_dynamic_gl3525_validate_internal(FuStructGenesysTsDynamicGl3525 *st, GError **error) |
1850 | 0 | { |
1851 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
1852 | 0 | return TRUE; |
1853 | 0 | } |
1854 | | static gboolean |
1855 | | fu_struct_genesys_ts_dynamic_gl3525_parse_internal(FuStructGenesysTsDynamicGl3525 *st, GError **error) |
1856 | 0 | { |
1857 | 0 | if (g_getenv("FWUPD_VERBOSE") != NULL) { |
1858 | 0 | g_autofree gchar *str = fu_struct_genesys_ts_dynamic_gl3525_to_string(st); |
1859 | 0 | g_debug("%s", str); |
1860 | 0 | } |
1861 | 0 | if (!fu_struct_genesys_ts_dynamic_gl3525_validate_internal(st, error)) |
1862 | 0 | return FALSE; |
1863 | 0 | return TRUE; |
1864 | 0 | } |
1865 | | |
1866 | | /** |
1867 | | * fu_struct_genesys_ts_dynamic_gl3525_parse: (skip): |
1868 | | **/ |
1869 | | FuStructGenesysTsDynamicGl3525 * |
1870 | | fu_struct_genesys_ts_dynamic_gl3525_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
1871 | 0 | { |
1872 | 0 | g_autoptr(FuStructGenesysTsDynamicGl3525) st = fu_struct_genesys_ts_dynamic_gl3525_new_internal(); |
1873 | 0 | g_return_val_if_fail(buf != NULL, NULL); |
1874 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, NULL); |
1875 | 0 | if (!fu_memchk_read(bufsz, offset, 17, error)) { |
1876 | 0 | g_prefix_error_literal(error, "invalid struct FuStructGenesysTsDynamicGl3525: "); |
1877 | 0 | return NULL; |
1878 | 0 | } |
1879 | 0 | st->buf = g_byte_array_new(); |
1880 | 0 | g_byte_array_append(st->buf, buf + offset, 17); |
1881 | 0 | if (!fu_struct_genesys_ts_dynamic_gl3525_parse_internal(st, error)) |
1882 | 0 | return NULL; |
1883 | 0 | return g_steal_pointer(&st); |
1884 | 0 | } |
1885 | | /** |
1886 | | * fu_struct_genesys_ts_firmware_info_ref: (skip): |
1887 | | **/ |
1888 | | FuStructGenesysTsFirmwareInfo * |
1889 | | fu_struct_genesys_ts_firmware_info_ref(FuStructGenesysTsFirmwareInfo *st) |
1890 | 0 | { |
1891 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1892 | 0 | st->refcount++; |
1893 | 0 | return st; |
1894 | 0 | } |
1895 | | /** |
1896 | | * fu_struct_genesys_ts_firmware_info_unref: (skip): |
1897 | | **/ |
1898 | | void |
1899 | | fu_struct_genesys_ts_firmware_info_unref(FuStructGenesysTsFirmwareInfo *st) |
1900 | 0 | { |
1901 | 0 | g_return_if_fail(st != NULL); |
1902 | 0 | if (st->refcount == 0) { |
1903 | 0 | g_critical("FuStructGenesysTsFirmwareInfo refcount already zero"); |
1904 | 0 | return; |
1905 | 0 | } |
1906 | 0 | if (--st->refcount > 0) |
1907 | 0 | return; |
1908 | 0 | if (st->buf != NULL) |
1909 | 0 | g_byte_array_unref(st->buf); |
1910 | 0 | g_free(st); |
1911 | 0 | } |
1912 | | static FuStructGenesysTsFirmwareInfo * |
1913 | | fu_struct_genesys_ts_firmware_info_new_internal(void) |
1914 | 0 | { |
1915 | 0 | FuStructGenesysTsFirmwareInfo *st = g_new0(FuStructGenesysTsFirmwareInfo, 1); |
1916 | 0 | st->refcount = 1; |
1917 | 0 | return st; |
1918 | 0 | } |
1919 | | |
1920 | | /* getters */ |
1921 | | /** |
1922 | | * fu_struct_genesys_ts_firmware_info_get_tool_version: (skip): |
1923 | | **/ |
1924 | | const guint8 * |
1925 | | fu_struct_genesys_ts_firmware_info_get_tool_version(const FuStructGenesysTsFirmwareInfo *st, gsize *bufsz) |
1926 | 0 | { |
1927 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1928 | 0 | if (bufsz != NULL) |
1929 | 0 | *bufsz = 6; |
1930 | 0 | return st->buf->data + 0; |
1931 | 0 | } |
1932 | | /** |
1933 | | * fu_struct_genesys_ts_firmware_info_get_address_mode: (skip): |
1934 | | **/ |
1935 | | guint8 |
1936 | | fu_struct_genesys_ts_firmware_info_get_address_mode(const FuStructGenesysTsFirmwareInfo *st) |
1937 | 0 | { |
1938 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1939 | 0 | return st->buf->data[6]; |
1940 | 0 | } |
1941 | | /** |
1942 | | * fu_struct_genesys_ts_firmware_info_get_build_fw_time: (skip): |
1943 | | **/ |
1944 | | gchar * |
1945 | | fu_struct_genesys_ts_firmware_info_get_build_fw_time(const FuStructGenesysTsFirmwareInfo *st) |
1946 | 0 | { |
1947 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1948 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 7, 12, NULL); |
1949 | 0 | } |
1950 | | /** |
1951 | | * fu_struct_genesys_ts_firmware_info_get_update_fw_time: (skip): |
1952 | | **/ |
1953 | | gchar * |
1954 | | fu_struct_genesys_ts_firmware_info_get_update_fw_time(const FuStructGenesysTsFirmwareInfo *st) |
1955 | 0 | { |
1956 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1957 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 19, 12, NULL); |
1958 | 0 | } |
1959 | | |
1960 | | /* setters */ |
1961 | | /** |
1962 | | * fu_struct_genesys_ts_firmware_info_to_string: (skip): |
1963 | | **/ |
1964 | | static gchar * |
1965 | | fu_struct_genesys_ts_firmware_info_to_string(const FuStructGenesysTsFirmwareInfo *st) |
1966 | 0 | { |
1967 | 0 | g_autoptr(GString) str = g_string_new("FuStructGenesysTsFirmwareInfo:\n"); |
1968 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1969 | 0 | { |
1970 | 0 | gsize bufsz = 0; |
1971 | 0 | const guint8 *buf = fu_struct_genesys_ts_firmware_info_get_tool_version(st, &bufsz); |
1972 | 0 | g_autoptr(GString) tmp = g_string_new(NULL); |
1973 | 0 | for (gsize i = 0; i < bufsz; i++) |
1974 | 0 | g_string_append_printf(tmp, "%02X", buf[i]); |
1975 | 0 | g_string_append_printf(str, " tool_version: 0x%s\n", tmp->str); |
1976 | 0 | } |
1977 | 0 | g_string_append_printf(str, " address_mode: 0x%x\n", |
1978 | 0 | (guint) fu_struct_genesys_ts_firmware_info_get_address_mode(st)); |
1979 | 0 | { |
1980 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_firmware_info_get_build_fw_time(st); |
1981 | 0 | if (tmp != NULL) |
1982 | 0 | g_string_append_printf(str, " build_fw_time: %s\n", tmp); |
1983 | 0 | } |
1984 | 0 | { |
1985 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_firmware_info_get_update_fw_time(st); |
1986 | 0 | if (tmp != NULL) |
1987 | 0 | g_string_append_printf(str, " update_fw_time: %s\n", tmp); |
1988 | 0 | } |
1989 | 0 | if (str->len > 0) |
1990 | 0 | g_string_set_size(str, str->len - 1); |
1991 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
1992 | 0 | } |
1993 | | static gboolean |
1994 | | fu_struct_genesys_ts_firmware_info_validate_internal(FuStructGenesysTsFirmwareInfo *st, GError **error) |
1995 | 0 | { |
1996 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
1997 | 0 | return TRUE; |
1998 | 0 | } |
1999 | | static gboolean |
2000 | | fu_struct_genesys_ts_firmware_info_parse_internal(FuStructGenesysTsFirmwareInfo *st, GError **error) |
2001 | 0 | { |
2002 | 0 | if (g_getenv("FWUPD_VERBOSE") != NULL) { |
2003 | 0 | g_autofree gchar *str = fu_struct_genesys_ts_firmware_info_to_string(st); |
2004 | 0 | g_debug("%s", str); |
2005 | 0 | } |
2006 | 0 | if (!fu_struct_genesys_ts_firmware_info_validate_internal(st, error)) |
2007 | 0 | return FALSE; |
2008 | 0 | return TRUE; |
2009 | 0 | } |
2010 | | |
2011 | | /** |
2012 | | * fu_struct_genesys_ts_firmware_info_parse: (skip): |
2013 | | **/ |
2014 | | FuStructGenesysTsFirmwareInfo * |
2015 | | fu_struct_genesys_ts_firmware_info_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
2016 | 0 | { |
2017 | 0 | g_autoptr(FuStructGenesysTsFirmwareInfo) st = fu_struct_genesys_ts_firmware_info_new_internal(); |
2018 | 0 | g_return_val_if_fail(buf != NULL, NULL); |
2019 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, NULL); |
2020 | 0 | if (!fu_memchk_read(bufsz, offset, 31, error)) { |
2021 | 0 | g_prefix_error_literal(error, "invalid struct FuStructGenesysTsFirmwareInfo: "); |
2022 | 0 | return NULL; |
2023 | 0 | } |
2024 | 0 | st->buf = g_byte_array_new(); |
2025 | 0 | g_byte_array_append(st->buf, buf + offset, 31); |
2026 | 0 | if (!fu_struct_genesys_ts_firmware_info_parse_internal(st, error)) |
2027 | 0 | return NULL; |
2028 | 0 | return g_steal_pointer(&st); |
2029 | 0 | } |
2030 | | /** |
2031 | | * fu_struct_genesys_ts_vendor_support_ref: (skip): |
2032 | | **/ |
2033 | | FuStructGenesysTsVendorSupport * |
2034 | | fu_struct_genesys_ts_vendor_support_ref(FuStructGenesysTsVendorSupport *st) |
2035 | 0 | { |
2036 | 0 | g_return_val_if_fail(st != NULL, NULL); |
2037 | 0 | st->refcount++; |
2038 | 0 | return st; |
2039 | 0 | } |
2040 | | /** |
2041 | | * fu_struct_genesys_ts_vendor_support_unref: (skip): |
2042 | | **/ |
2043 | | void |
2044 | | fu_struct_genesys_ts_vendor_support_unref(FuStructGenesysTsVendorSupport *st) |
2045 | 0 | { |
2046 | 0 | g_return_if_fail(st != NULL); |
2047 | 0 | if (st->refcount == 0) { |
2048 | 0 | g_critical("FuStructGenesysTsVendorSupport refcount already zero"); |
2049 | 0 | return; |
2050 | 0 | } |
2051 | 0 | if (--st->refcount > 0) |
2052 | 0 | return; |
2053 | 0 | if (st->buf != NULL) |
2054 | 0 | g_byte_array_unref(st->buf); |
2055 | 0 | g_free(st); |
2056 | 0 | } |
2057 | | static FuStructGenesysTsVendorSupport * |
2058 | | fu_struct_genesys_ts_vendor_support_new_internal(void) |
2059 | 0 | { |
2060 | 0 | FuStructGenesysTsVendorSupport *st = g_new0(FuStructGenesysTsVendorSupport, 1); |
2061 | 0 | st->refcount = 1; |
2062 | 0 | return st; |
2063 | 0 | } |
2064 | | |
2065 | | /* getters */ |
2066 | | /** |
2067 | | * fu_struct_genesys_ts_vendor_support_get_version: (skip): |
2068 | | **/ |
2069 | | gchar * |
2070 | | fu_struct_genesys_ts_vendor_support_get_version(const FuStructGenesysTsVendorSupport *st) |
2071 | 0 | { |
2072 | 0 | g_return_val_if_fail(st != NULL, NULL); |
2073 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 0, 2, NULL); |
2074 | 0 | } |
2075 | | /** |
2076 | | * fu_struct_genesys_ts_vendor_support_get_reserved1: (skip): |
2077 | | **/ |
2078 | | gchar * |
2079 | | fu_struct_genesys_ts_vendor_support_get_reserved1(const FuStructGenesysTsVendorSupport *st) |
2080 | 0 | { |
2081 | 0 | g_return_val_if_fail(st != NULL, NULL); |
2082 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 2, 8, NULL); |
2083 | 0 | } |
2084 | | /** |
2085 | | * fu_struct_genesys_ts_vendor_support_get_codesign_check: (skip): |
2086 | | **/ |
2087 | | FuGenesysVsCodesignCheck |
2088 | | fu_struct_genesys_ts_vendor_support_get_codesign_check(const FuStructGenesysTsVendorSupport *st) |
2089 | 0 | { |
2090 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
2091 | 0 | return st->buf->data[10]; |
2092 | 0 | } |
2093 | | /** |
2094 | | * fu_struct_genesys_ts_vendor_support_get_reserved2: (skip): |
2095 | | **/ |
2096 | | gchar * |
2097 | | fu_struct_genesys_ts_vendor_support_get_reserved2(const FuStructGenesysTsVendorSupport *st) |
2098 | 0 | { |
2099 | 0 | g_return_val_if_fail(st != NULL, NULL); |
2100 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 11, 4, NULL); |
2101 | 0 | } |
2102 | | /** |
2103 | | * fu_struct_genesys_ts_vendor_support_get_hid_isp: (skip): |
2104 | | **/ |
2105 | | FuGenesysVsHidIsp |
2106 | | fu_struct_genesys_ts_vendor_support_get_hid_isp(const FuStructGenesysTsVendorSupport *st) |
2107 | 0 | { |
2108 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
2109 | 0 | return st->buf->data[15]; |
2110 | 0 | } |
2111 | | /** |
2112 | | * fu_struct_genesys_ts_vendor_support_get_reserved3: (skip): |
2113 | | **/ |
2114 | | gchar * |
2115 | | fu_struct_genesys_ts_vendor_support_get_reserved3(const FuStructGenesysTsVendorSupport *st) |
2116 | 0 | { |
2117 | 0 | g_return_val_if_fail(st != NULL, NULL); |
2118 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 16, 15, NULL); |
2119 | 0 | } |
2120 | | |
2121 | | /* setters */ |
2122 | | /** |
2123 | | * fu_struct_genesys_ts_vendor_support_set_version: (skip): |
2124 | | **/ |
2125 | | gboolean |
2126 | | fu_struct_genesys_ts_vendor_support_set_version(FuStructGenesysTsVendorSupport *st, const gchar *value, GError **error) |
2127 | 0 | { |
2128 | 0 | gsize len; |
2129 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
2130 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
2131 | 0 | if (value == NULL) { |
2132 | 0 | memset(st->buf->data + 0, 0x0, 2); |
2133 | 0 | return TRUE; |
2134 | 0 | } |
2135 | 0 | len = strlen(value); |
2136 | 0 | if (len > 2) { |
2137 | 0 | g_set_error(error, |
2138 | 0 | FWUPD_ERROR, |
2139 | 0 | FWUPD_ERROR_INVALID_DATA, |
2140 | 0 | "string '%s' (0x%x bytes) does not fit in FuStructGenesysTsVendorSupport.version (0x%x bytes)", |
2141 | 0 | value, (guint) len, (guint) 2); |
2142 | 0 | return FALSE; |
2143 | 0 | } |
2144 | 0 | return fu_memcpy_safe(st->buf->data, st->buf->len, 0, (const guint8 *)value, len, 0x0, len, error); |
2145 | 0 | } |
2146 | | /** |
2147 | | * fu_struct_genesys_ts_vendor_support_set_reserved1: (skip): |
2148 | | **/ |
2149 | | gboolean |
2150 | | fu_struct_genesys_ts_vendor_support_set_reserved1(FuStructGenesysTsVendorSupport *st, const gchar *value, GError **error) |
2151 | 0 | { |
2152 | 0 | gsize len; |
2153 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
2154 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
2155 | 0 | if (value == NULL) { |
2156 | 0 | memset(st->buf->data + 2, 0x0, 8); |
2157 | 0 | return TRUE; |
2158 | 0 | } |
2159 | 0 | len = strlen(value); |
2160 | 0 | if (len > 8) { |
2161 | 0 | g_set_error(error, |
2162 | 0 | FWUPD_ERROR, |
2163 | 0 | FWUPD_ERROR_INVALID_DATA, |
2164 | 0 | "string '%s' (0x%x bytes) does not fit in FuStructGenesysTsVendorSupport.reserved1 (0x%x bytes)", |
2165 | 0 | value, (guint) len, (guint) 8); |
2166 | 0 | return FALSE; |
2167 | 0 | } |
2168 | 0 | return fu_memcpy_safe(st->buf->data, st->buf->len, 2, (const guint8 *)value, len, 0x0, len, error); |
2169 | 0 | } |
2170 | | /** |
2171 | | * fu_struct_genesys_ts_vendor_support_set_codesign_check: (skip): |
2172 | | **/ |
2173 | | void |
2174 | | fu_struct_genesys_ts_vendor_support_set_codesign_check(FuStructGenesysTsVendorSupport *st, FuGenesysVsCodesignCheck value) |
2175 | 0 | { |
2176 | 0 | g_return_if_fail(st != NULL); |
2177 | 0 | st->buf->data[10] = value; |
2178 | 0 | } |
2179 | | /** |
2180 | | * fu_struct_genesys_ts_vendor_support_set_reserved2: (skip): |
2181 | | **/ |
2182 | | gboolean |
2183 | | fu_struct_genesys_ts_vendor_support_set_reserved2(FuStructGenesysTsVendorSupport *st, const gchar *value, GError **error) |
2184 | 0 | { |
2185 | 0 | gsize len; |
2186 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
2187 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
2188 | 0 | if (value == NULL) { |
2189 | 0 | memset(st->buf->data + 11, 0x0, 4); |
2190 | 0 | return TRUE; |
2191 | 0 | } |
2192 | 0 | len = strlen(value); |
2193 | 0 | if (len > 4) { |
2194 | 0 | g_set_error(error, |
2195 | 0 | FWUPD_ERROR, |
2196 | 0 | FWUPD_ERROR_INVALID_DATA, |
2197 | 0 | "string '%s' (0x%x bytes) does not fit in FuStructGenesysTsVendorSupport.reserved2 (0x%x bytes)", |
2198 | 0 | value, (guint) len, (guint) 4); |
2199 | 0 | return FALSE; |
2200 | 0 | } |
2201 | 0 | return fu_memcpy_safe(st->buf->data, st->buf->len, 11, (const guint8 *)value, len, 0x0, len, error); |
2202 | 0 | } |
2203 | | /** |
2204 | | * fu_struct_genesys_ts_vendor_support_set_hid_isp: (skip): |
2205 | | **/ |
2206 | | void |
2207 | | fu_struct_genesys_ts_vendor_support_set_hid_isp(FuStructGenesysTsVendorSupport *st, FuGenesysVsHidIsp value) |
2208 | 0 | { |
2209 | 0 | g_return_if_fail(st != NULL); |
2210 | 0 | st->buf->data[15] = value; |
2211 | 0 | } |
2212 | | /** |
2213 | | * fu_struct_genesys_ts_vendor_support_set_reserved3: (skip): |
2214 | | **/ |
2215 | | gboolean |
2216 | | fu_struct_genesys_ts_vendor_support_set_reserved3(FuStructGenesysTsVendorSupport *st, const gchar *value, GError **error) |
2217 | 0 | { |
2218 | 0 | gsize len; |
2219 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
2220 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
2221 | 0 | if (value == NULL) { |
2222 | 0 | memset(st->buf->data + 16, 0x0, 15); |
2223 | 0 | return TRUE; |
2224 | 0 | } |
2225 | 0 | len = strlen(value); |
2226 | 0 | if (len > 15) { |
2227 | 0 | g_set_error(error, |
2228 | 0 | FWUPD_ERROR, |
2229 | 0 | FWUPD_ERROR_INVALID_DATA, |
2230 | 0 | "string '%s' (0x%x bytes) does not fit in FuStructGenesysTsVendorSupport.reserved3 (0x%x bytes)", |
2231 | 0 | value, (guint) len, (guint) 15); |
2232 | 0 | return FALSE; |
2233 | 0 | } |
2234 | 0 | return fu_memcpy_safe(st->buf->data, st->buf->len, 16, (const guint8 *)value, len, 0x0, len, error); |
2235 | 0 | } |
2236 | | /** |
2237 | | * fu_struct_genesys_ts_vendor_support_new: (skip): |
2238 | | **/ |
2239 | | FuStructGenesysTsVendorSupport * |
2240 | | fu_struct_genesys_ts_vendor_support_new(void) |
2241 | 0 | { |
2242 | 0 | FuStructGenesysTsVendorSupport *st = fu_struct_genesys_ts_vendor_support_new_internal(); |
2243 | 0 | st->buf = g_byte_array_sized_new(31); |
2244 | 0 | fu_byte_array_set_size(st->buf, 31, 0x0); |
2245 | 0 | return st; |
2246 | 0 | } |
2247 | | /** |
2248 | | * fu_struct_genesys_ts_vendor_support_to_string: (skip): |
2249 | | **/ |
2250 | | static gchar * |
2251 | | fu_struct_genesys_ts_vendor_support_to_string(const FuStructGenesysTsVendorSupport *st) |
2252 | 0 | { |
2253 | 0 | g_autoptr(GString) str = g_string_new("FuStructGenesysTsVendorSupport:\n"); |
2254 | 0 | g_return_val_if_fail(st != NULL, NULL); |
2255 | 0 | { |
2256 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_vendor_support_get_version(st); |
2257 | 0 | if (tmp != NULL) |
2258 | 0 | g_string_append_printf(str, " version: %s\n", tmp); |
2259 | 0 | } |
2260 | 0 | { |
2261 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_vendor_support_get_reserved1(st); |
2262 | 0 | if (tmp != NULL) |
2263 | 0 | g_string_append_printf(str, " reserved1: %s\n", tmp); |
2264 | 0 | } |
2265 | 0 | { |
2266 | 0 | const gchar *tmp = fu_genesys_vs_codesign_check_to_string(fu_struct_genesys_ts_vendor_support_get_codesign_check(st)); |
2267 | 0 | if (tmp != NULL) { |
2268 | 0 | g_string_append_printf(str, " codesign_check: 0x%x [%s]\n", (guint) fu_struct_genesys_ts_vendor_support_get_codesign_check(st), tmp); |
2269 | 0 | } else { |
2270 | 0 | g_string_append_printf(str, " codesign_check: 0x%x\n", (guint) fu_struct_genesys_ts_vendor_support_get_codesign_check(st)); |
2271 | 0 | } |
2272 | 0 | } |
2273 | 0 | { |
2274 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_vendor_support_get_reserved2(st); |
2275 | 0 | if (tmp != NULL) |
2276 | 0 | g_string_append_printf(str, " reserved2: %s\n", tmp); |
2277 | 0 | } |
2278 | 0 | { |
2279 | 0 | const gchar *tmp = fu_genesys_vs_hid_isp_to_string(fu_struct_genesys_ts_vendor_support_get_hid_isp(st)); |
2280 | 0 | if (tmp != NULL) { |
2281 | 0 | g_string_append_printf(str, " hid_isp: 0x%x [%s]\n", (guint) fu_struct_genesys_ts_vendor_support_get_hid_isp(st), tmp); |
2282 | 0 | } else { |
2283 | 0 | g_string_append_printf(str, " hid_isp: 0x%x\n", (guint) fu_struct_genesys_ts_vendor_support_get_hid_isp(st)); |
2284 | 0 | } |
2285 | 0 | } |
2286 | 0 | { |
2287 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_vendor_support_get_reserved3(st); |
2288 | 0 | if (tmp != NULL) |
2289 | 0 | g_string_append_printf(str, " reserved3: %s\n", tmp); |
2290 | 0 | } |
2291 | 0 | if (str->len > 0) |
2292 | 0 | g_string_set_size(str, str->len - 1); |
2293 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
2294 | 0 | } |
2295 | | static gboolean |
2296 | | fu_struct_genesys_ts_vendor_support_validate_internal(FuStructGenesysTsVendorSupport *st, GError **error) |
2297 | 0 | { |
2298 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
2299 | 0 | return TRUE; |
2300 | 0 | } |
2301 | | static gboolean |
2302 | | fu_struct_genesys_ts_vendor_support_parse_internal(FuStructGenesysTsVendorSupport *st, GError **error) |
2303 | 0 | { |
2304 | 0 | if (g_getenv("FWUPD_VERBOSE") != NULL) { |
2305 | 0 | g_autofree gchar *str = fu_struct_genesys_ts_vendor_support_to_string(st); |
2306 | 0 | g_debug("%s", str); |
2307 | 0 | } |
2308 | 0 | if (!fu_struct_genesys_ts_vendor_support_validate_internal(st, error)) |
2309 | 0 | return FALSE; |
2310 | 0 | return TRUE; |
2311 | 0 | } |
2312 | | |
2313 | | /** |
2314 | | * fu_struct_genesys_ts_vendor_support_parse: (skip): |
2315 | | **/ |
2316 | | FuStructGenesysTsVendorSupport * |
2317 | | fu_struct_genesys_ts_vendor_support_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
2318 | 0 | { |
2319 | 0 | g_autoptr(FuStructGenesysTsVendorSupport) st = fu_struct_genesys_ts_vendor_support_new_internal(); |
2320 | 0 | g_return_val_if_fail(buf != NULL, NULL); |
2321 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, NULL); |
2322 | 0 | if (!fu_memchk_read(bufsz, offset, 31, error)) { |
2323 | 0 | g_prefix_error_literal(error, "invalid struct FuStructGenesysTsVendorSupport: "); |
2324 | 0 | return NULL; |
2325 | 0 | } |
2326 | 0 | st->buf = g_byte_array_new(); |
2327 | 0 | g_byte_array_append(st->buf, buf + offset, 31); |
2328 | 0 | if (!fu_struct_genesys_ts_vendor_support_parse_internal(st, error)) |
2329 | 0 | return NULL; |
2330 | 0 | return g_steal_pointer(&st); |
2331 | 0 | } |
2332 | | /** |
2333 | | * fu_struct_genesys_ts_brand_project_ref: (skip): |
2334 | | **/ |
2335 | | FuStructGenesysTsBrandProject * |
2336 | | fu_struct_genesys_ts_brand_project_ref(FuStructGenesysTsBrandProject *st) |
2337 | 0 | { |
2338 | 0 | g_return_val_if_fail(st != NULL, NULL); |
2339 | 0 | st->refcount++; |
2340 | 0 | return st; |
2341 | 0 | } |
2342 | | /** |
2343 | | * fu_struct_genesys_ts_brand_project_unref: (skip): |
2344 | | **/ |
2345 | | void |
2346 | | fu_struct_genesys_ts_brand_project_unref(FuStructGenesysTsBrandProject *st) |
2347 | 0 | { |
2348 | 0 | g_return_if_fail(st != NULL); |
2349 | 0 | if (st->refcount == 0) { |
2350 | 0 | g_critical("FuStructGenesysTsBrandProject refcount already zero"); |
2351 | 0 | return; |
2352 | 0 | } |
2353 | 0 | if (--st->refcount > 0) |
2354 | 0 | return; |
2355 | 0 | if (st->buf != NULL) |
2356 | 0 | g_byte_array_unref(st->buf); |
2357 | 0 | g_free(st); |
2358 | 0 | } |
2359 | | static FuStructGenesysTsBrandProject * |
2360 | | fu_struct_genesys_ts_brand_project_new_internal(void) |
2361 | 0 | { |
2362 | 0 | FuStructGenesysTsBrandProject *st = g_new0(FuStructGenesysTsBrandProject, 1); |
2363 | 0 | st->refcount = 1; |
2364 | 0 | return st; |
2365 | 0 | } |
2366 | | |
2367 | | /* getters */ |
2368 | | /** |
2369 | | * fu_struct_genesys_ts_brand_project_get_project: (skip): |
2370 | | **/ |
2371 | | gchar * |
2372 | | fu_struct_genesys_ts_brand_project_get_project(const FuStructGenesysTsBrandProject *st) |
2373 | 0 | { |
2374 | 0 | g_return_val_if_fail(st != NULL, NULL); |
2375 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 0, 15, NULL); |
2376 | 0 | } |
2377 | | |
2378 | | /* setters */ |
2379 | | /** |
2380 | | * fu_struct_genesys_ts_brand_project_to_string: (skip): |
2381 | | **/ |
2382 | | static gchar * |
2383 | | fu_struct_genesys_ts_brand_project_to_string(const FuStructGenesysTsBrandProject *st) |
2384 | 0 | { |
2385 | 0 | g_autoptr(GString) str = g_string_new("FuStructGenesysTsBrandProject:\n"); |
2386 | 0 | g_return_val_if_fail(st != NULL, NULL); |
2387 | 0 | { |
2388 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_brand_project_get_project(st); |
2389 | 0 | if (tmp != NULL) |
2390 | 0 | g_string_append_printf(str, " project: %s\n", tmp); |
2391 | 0 | } |
2392 | 0 | if (str->len > 0) |
2393 | 0 | g_string_set_size(str, str->len - 1); |
2394 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
2395 | 0 | } |
2396 | | static gboolean |
2397 | | fu_struct_genesys_ts_brand_project_validate_internal(FuStructGenesysTsBrandProject *st, GError **error) |
2398 | 0 | { |
2399 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
2400 | 0 | return TRUE; |
2401 | 0 | } |
2402 | | static gboolean |
2403 | | fu_struct_genesys_ts_brand_project_parse_internal(FuStructGenesysTsBrandProject *st, GError **error) |
2404 | 0 | { |
2405 | 0 | if (g_getenv("FWUPD_VERBOSE") != NULL) { |
2406 | 0 | g_autofree gchar *str = fu_struct_genesys_ts_brand_project_to_string(st); |
2407 | 0 | g_debug("%s", str); |
2408 | 0 | } |
2409 | 0 | if (!fu_struct_genesys_ts_brand_project_validate_internal(st, error)) |
2410 | 0 | return FALSE; |
2411 | 0 | return TRUE; |
2412 | 0 | } |
2413 | | |
2414 | | /** |
2415 | | * fu_struct_genesys_ts_brand_project_parse: (skip): |
2416 | | **/ |
2417 | | FuStructGenesysTsBrandProject * |
2418 | | fu_struct_genesys_ts_brand_project_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
2419 | 0 | { |
2420 | 0 | g_autoptr(FuStructGenesysTsBrandProject) st = fu_struct_genesys_ts_brand_project_new_internal(); |
2421 | 0 | g_return_val_if_fail(buf != NULL, NULL); |
2422 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, NULL); |
2423 | 0 | if (!fu_memchk_read(bufsz, offset, 15, error)) { |
2424 | 0 | g_prefix_error_literal(error, "invalid struct FuStructGenesysTsBrandProject: "); |
2425 | 0 | return NULL; |
2426 | 0 | } |
2427 | 0 | st->buf = g_byte_array_new(); |
2428 | 0 | g_byte_array_append(st->buf, buf + offset, 15); |
2429 | 0 | if (!fu_struct_genesys_ts_brand_project_parse_internal(st, error)) |
2430 | 0 | return NULL; |
2431 | 0 | return g_steal_pointer(&st); |
2432 | 0 | } |
2433 | | /** |
2434 | | * fu_struct_genesys_fw_codesign_info_rsa_ref: (skip): |
2435 | | **/ |
2436 | | FuStructGenesysFwCodesignInfoRsa * |
2437 | | fu_struct_genesys_fw_codesign_info_rsa_ref(FuStructGenesysFwCodesignInfoRsa *st) |
2438 | 0 | { |
2439 | 0 | g_return_val_if_fail(st != NULL, NULL); |
2440 | 0 | st->refcount++; |
2441 | 0 | return st; |
2442 | 0 | } |
2443 | | /** |
2444 | | * fu_struct_genesys_fw_codesign_info_rsa_unref: (skip): |
2445 | | **/ |
2446 | | void |
2447 | | fu_struct_genesys_fw_codesign_info_rsa_unref(FuStructGenesysFwCodesignInfoRsa *st) |
2448 | 208 | { |
2449 | 208 | g_return_if_fail(st != NULL); |
2450 | 208 | if (st->refcount == 0) { |
2451 | 0 | g_critical("FuStructGenesysFwCodesignInfoRsa refcount already zero"); |
2452 | 0 | return; |
2453 | 0 | } |
2454 | 208 | if (--st->refcount > 0) |
2455 | 0 | return; |
2456 | 208 | if (st->buf != NULL) |
2457 | 208 | g_byte_array_unref(st->buf); |
2458 | 208 | g_free(st); |
2459 | 208 | } |
2460 | | static FuStructGenesysFwCodesignInfoRsa * |
2461 | | fu_struct_genesys_fw_codesign_info_rsa_new_internal(void) |
2462 | 208 | { |
2463 | 208 | FuStructGenesysFwCodesignInfoRsa *st = g_new0(FuStructGenesysFwCodesignInfoRsa, 1); |
2464 | 208 | st->refcount = 1; |
2465 | 208 | return st; |
2466 | 208 | } |
2467 | | |
2468 | | /* getters */ |
2469 | | /** |
2470 | | * fu_struct_genesys_fw_codesign_info_rsa_get_tag_n: (skip): |
2471 | | **/ |
2472 | | static guint32 |
2473 | | fu_struct_genesys_fw_codesign_info_rsa_get_tag_n(const FuStructGenesysFwCodesignInfoRsa *st) |
2474 | 324 | { |
2475 | 324 | g_return_val_if_fail(st != NULL, 0x0); |
2476 | 324 | return fu_memread_uint32(st->buf->data + 0, G_BIG_ENDIAN); |
2477 | 324 | } |
2478 | | /** |
2479 | | * fu_struct_genesys_fw_codesign_info_rsa_get_text_n: (skip): |
2480 | | **/ |
2481 | | gchar * |
2482 | | fu_struct_genesys_fw_codesign_info_rsa_get_text_n(const FuStructGenesysFwCodesignInfoRsa *st) |
2483 | 0 | { |
2484 | 0 | g_return_val_if_fail(st != NULL, NULL); |
2485 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 4, 512, NULL); |
2486 | 0 | } |
2487 | | /** |
2488 | | * fu_struct_genesys_fw_codesign_info_rsa_get_end_n: (skip): |
2489 | | **/ |
2490 | | static guint16 |
2491 | | fu_struct_genesys_fw_codesign_info_rsa_get_end_n(const FuStructGenesysFwCodesignInfoRsa *st) |
2492 | 115 | { |
2493 | 115 | g_return_val_if_fail(st != NULL, 0x0); |
2494 | 115 | return fu_memread_uint16(st->buf->data + 516, G_BIG_ENDIAN); |
2495 | 115 | } |
2496 | | /** |
2497 | | * fu_struct_genesys_fw_codesign_info_rsa_get_tag_e: (skip): |
2498 | | **/ |
2499 | | static guint32 |
2500 | | fu_struct_genesys_fw_codesign_info_rsa_get_tag_e(const FuStructGenesysFwCodesignInfoRsa *st) |
2501 | 115 | { |
2502 | 115 | g_return_val_if_fail(st != NULL, 0x0); |
2503 | 115 | return fu_memread_uint32(st->buf->data + 518, G_BIG_ENDIAN); |
2504 | 115 | } |
2505 | | /** |
2506 | | * fu_struct_genesys_fw_codesign_info_rsa_get_text_e: (skip): |
2507 | | **/ |
2508 | | gchar * |
2509 | | fu_struct_genesys_fw_codesign_info_rsa_get_text_e(const FuStructGenesysFwCodesignInfoRsa *st) |
2510 | 0 | { |
2511 | 0 | g_return_val_if_fail(st != NULL, NULL); |
2512 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 522, 6, NULL); |
2513 | 0 | } |
2514 | | /** |
2515 | | * fu_struct_genesys_fw_codesign_info_rsa_get_end_e: (skip): |
2516 | | **/ |
2517 | | static guint16 |
2518 | | fu_struct_genesys_fw_codesign_info_rsa_get_end_e(const FuStructGenesysFwCodesignInfoRsa *st) |
2519 | 45 | { |
2520 | 45 | g_return_val_if_fail(st != NULL, 0x0); |
2521 | 45 | return fu_memread_uint16(st->buf->data + 528, G_BIG_ENDIAN); |
2522 | 45 | } |
2523 | | /** |
2524 | | * fu_struct_genesys_fw_codesign_info_rsa_get_signature: (skip): |
2525 | | **/ |
2526 | | const guint8 * |
2527 | | fu_struct_genesys_fw_codesign_info_rsa_get_signature(const FuStructGenesysFwCodesignInfoRsa *st, gsize *bufsz) |
2528 | 0 | { |
2529 | 0 | g_return_val_if_fail(st != NULL, NULL); |
2530 | 0 | if (bufsz != NULL) |
2531 | 0 | *bufsz = 256; |
2532 | 0 | return st->buf->data + 530; |
2533 | 0 | } |
2534 | | |
2535 | | /* setters */ |
2536 | | /** |
2537 | | * fu_struct_genesys_fw_codesign_info_rsa_to_string: (skip): |
2538 | | **/ |
2539 | | static gchar * |
2540 | | fu_struct_genesys_fw_codesign_info_rsa_to_string(const FuStructGenesysFwCodesignInfoRsa *st) |
2541 | 0 | { |
2542 | 0 | g_autoptr(GString) str = g_string_new("FuStructGenesysFwCodesignInfoRsa:\n"); |
2543 | 0 | g_return_val_if_fail(st != NULL, NULL); |
2544 | 0 | { |
2545 | 0 | g_autofree gchar *tmp = fu_struct_genesys_fw_codesign_info_rsa_get_text_n(st); |
2546 | 0 | if (tmp != NULL) |
2547 | 0 | g_string_append_printf(str, " text_n: %s\n", tmp); |
2548 | 0 | } |
2549 | 0 | { |
2550 | 0 | g_autofree gchar *tmp = fu_struct_genesys_fw_codesign_info_rsa_get_text_e(st); |
2551 | 0 | if (tmp != NULL) |
2552 | 0 | g_string_append_printf(str, " text_e: %s\n", tmp); |
2553 | 0 | } |
2554 | 0 | { |
2555 | 0 | gsize bufsz = 0; |
2556 | 0 | const guint8 *buf = fu_struct_genesys_fw_codesign_info_rsa_get_signature(st, &bufsz); |
2557 | 0 | g_autoptr(GString) tmp = g_string_new(NULL); |
2558 | 0 | for (gsize i = 0; i < bufsz; i++) |
2559 | 0 | g_string_append_printf(tmp, "%02X", buf[i]); |
2560 | 0 | g_string_append_printf(str, " signature: 0x%s\n", tmp->str); |
2561 | 0 | } |
2562 | 0 | if (str->len > 0) |
2563 | 0 | g_string_set_size(str, str->len - 1); |
2564 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
2565 | 0 | } |
2566 | | static gboolean |
2567 | | fu_struct_genesys_fw_codesign_info_rsa_validate_internal(FuStructGenesysFwCodesignInfoRsa *st, GError **error) |
2568 | 208 | { |
2569 | 208 | g_return_val_if_fail(st != NULL, FALSE); |
2570 | 208 | if (fu_struct_genesys_fw_codesign_info_rsa_get_tag_n(st) != 0x4E203D20) { |
2571 | 116 | g_set_error(error, |
2572 | 116 | FWUPD_ERROR, |
2573 | 116 | FWUPD_ERROR_INVALID_DATA, |
2574 | 116 | "constant FuStructGenesysFwCodesignInfoRsa.tag_n was not valid, " |
2575 | 116 | "expected 0x%x and got 0x%x", |
2576 | 116 | (guint) 0x4E203D20, |
2577 | 116 | (guint) fu_struct_genesys_fw_codesign_info_rsa_get_tag_n(st)); |
2578 | 116 | return FALSE; |
2579 | 116 | } |
2580 | 92 | if (fu_struct_genesys_fw_codesign_info_rsa_get_end_n(st) != 0x0D0A) { |
2581 | 23 | g_set_error(error, |
2582 | 23 | FWUPD_ERROR, |
2583 | 23 | FWUPD_ERROR_INVALID_DATA, |
2584 | 23 | "constant FuStructGenesysFwCodesignInfoRsa.end_n was not valid, " |
2585 | 23 | "expected 0x%x and got 0x%x", |
2586 | 23 | (guint) 0x0D0A, |
2587 | 23 | (guint) fu_struct_genesys_fw_codesign_info_rsa_get_end_n(st)); |
2588 | 23 | return FALSE; |
2589 | 23 | } |
2590 | 69 | if (fu_struct_genesys_fw_codesign_info_rsa_get_tag_e(st) != 0x45203D20) { |
2591 | 46 | g_set_error(error, |
2592 | 46 | FWUPD_ERROR, |
2593 | 46 | FWUPD_ERROR_INVALID_DATA, |
2594 | 46 | "constant FuStructGenesysFwCodesignInfoRsa.tag_e was not valid, " |
2595 | 46 | "expected 0x%x and got 0x%x", |
2596 | 46 | (guint) 0x45203D20, |
2597 | 46 | (guint) fu_struct_genesys_fw_codesign_info_rsa_get_tag_e(st)); |
2598 | 46 | return FALSE; |
2599 | 46 | } |
2600 | 23 | if (fu_struct_genesys_fw_codesign_info_rsa_get_end_e(st) != 0x0D0A) { |
2601 | 22 | g_set_error(error, |
2602 | 22 | FWUPD_ERROR, |
2603 | 22 | FWUPD_ERROR_INVALID_DATA, |
2604 | 22 | "constant FuStructGenesysFwCodesignInfoRsa.end_e was not valid, " |
2605 | 22 | "expected 0x%x and got 0x%x", |
2606 | 22 | (guint) 0x0D0A, |
2607 | 22 | (guint) fu_struct_genesys_fw_codesign_info_rsa_get_end_e(st)); |
2608 | 22 | return FALSE; |
2609 | 22 | } |
2610 | 1 | return TRUE; |
2611 | 23 | } |
2612 | | /** |
2613 | | * fu_struct_genesys_fw_codesign_info_rsa_validate_stream: (skip): |
2614 | | **/ |
2615 | | gboolean |
2616 | | fu_struct_genesys_fw_codesign_info_rsa_validate_stream(GInputStream *stream, gsize offset, GError **error) |
2617 | 208 | { |
2618 | 208 | g_autoptr(FuStructGenesysFwCodesignInfoRsa) st = fu_struct_genesys_fw_codesign_info_rsa_new_internal(); |
2619 | 208 | g_return_val_if_fail(G_IS_INPUT_STREAM(stream), FALSE); |
2620 | 208 | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
2621 | 208 | st->buf = fu_input_stream_read_byte_array(stream, offset, 786, NULL, error); |
2622 | 208 | if (st->buf == NULL) { |
2623 | 0 | g_prefix_error(error, "FuStructGenesysFwCodesignInfoRsa failed read of 0x%x: ", (guint) 786); |
2624 | 0 | return FALSE; |
2625 | 0 | } |
2626 | 208 | if (st->buf->len != 786) { |
2627 | 0 | g_set_error(error, |
2628 | 0 | FWUPD_ERROR, |
2629 | 0 | FWUPD_ERROR_INVALID_DATA, |
2630 | 0 | "FuStructGenesysFwCodesignInfoRsa requested 0x%x and got 0x%x", |
2631 | 0 | (guint) 786, |
2632 | 0 | (guint) st->buf->len); |
2633 | 0 | return FALSE; |
2634 | 0 | } |
2635 | 208 | return fu_struct_genesys_fw_codesign_info_rsa_validate_internal(st, error); |
2636 | 208 | } |
2637 | | static gboolean |
2638 | | fu_struct_genesys_fw_codesign_info_rsa_parse_internal(FuStructGenesysFwCodesignInfoRsa *st, GError **error) |
2639 | 0 | { |
2640 | 0 | if (g_getenv("FWUPD_VERBOSE") != NULL) { |
2641 | 0 | g_autofree gchar *str = fu_struct_genesys_fw_codesign_info_rsa_to_string(st); |
2642 | 0 | g_debug("%s", str); |
2643 | 0 | } |
2644 | 0 | if (!fu_struct_genesys_fw_codesign_info_rsa_validate_internal(st, error)) |
2645 | 0 | return FALSE; |
2646 | 0 | return TRUE; |
2647 | 0 | } |
2648 | | /** |
2649 | | * fu_struct_genesys_fw_codesign_info_rsa_parse_stream: (skip): |
2650 | | **/ |
2651 | | FuStructGenesysFwCodesignInfoRsa * |
2652 | | fu_struct_genesys_fw_codesign_info_rsa_parse_stream(GInputStream *stream, gsize offset, GError **error) |
2653 | 0 | { |
2654 | 0 | g_autoptr(FuStructGenesysFwCodesignInfoRsa) st = fu_struct_genesys_fw_codesign_info_rsa_new_internal(); |
2655 | 0 | st->buf = fu_input_stream_read_byte_array(stream, offset, 786, NULL, error); |
2656 | 0 | if (st->buf == NULL) { |
2657 | 0 | g_prefix_error(error, "FuStructGenesysFwCodesignInfoRsa failed read of 0x%x: ", (guint) 786); |
2658 | 0 | return NULL; |
2659 | 0 | } |
2660 | 0 | if (st->buf->len != 786) { |
2661 | 0 | g_set_error(error, |
2662 | 0 | FWUPD_ERROR, |
2663 | 0 | FWUPD_ERROR_INVALID_DATA, |
2664 | 0 | "FuStructGenesysFwCodesignInfoRsa requested 0x%x and got 0x%x", |
2665 | 0 | (guint) 786, |
2666 | 0 | (guint) st->buf->len); |
2667 | 0 | return NULL; |
2668 | 0 | } |
2669 | 0 | if (!fu_struct_genesys_fw_codesign_info_rsa_parse_internal(st, error)) |
2670 | 0 | return NULL; |
2671 | 0 | return g_steal_pointer(&st); |
2672 | 0 | } |
2673 | | /** |
2674 | | * fu_struct_genesys_fw_rsa_public_key_text_ref: (skip): |
2675 | | **/ |
2676 | | FuStructGenesysFwRsaPublicKeyText * |
2677 | | fu_struct_genesys_fw_rsa_public_key_text_ref(FuStructGenesysFwRsaPublicKeyText *st) |
2678 | 0 | { |
2679 | 0 | g_return_val_if_fail(st != NULL, NULL); |
2680 | 0 | st->refcount++; |
2681 | 0 | return st; |
2682 | 0 | } |
2683 | | /** |
2684 | | * fu_struct_genesys_fw_rsa_public_key_text_unref: (skip): |
2685 | | **/ |
2686 | | void |
2687 | | fu_struct_genesys_fw_rsa_public_key_text_unref(FuStructGenesysFwRsaPublicKeyText *st) |
2688 | 0 | { |
2689 | 0 | g_return_if_fail(st != NULL); |
2690 | 0 | if (st->refcount == 0) { |
2691 | 0 | g_critical("FuStructGenesysFwRsaPublicKeyText refcount already zero"); |
2692 | 0 | return; |
2693 | 0 | } |
2694 | 0 | if (--st->refcount > 0) |
2695 | 0 | return; |
2696 | 0 | if (st->buf != NULL) |
2697 | 0 | g_byte_array_unref(st->buf); |
2698 | 0 | g_free(st); |
2699 | 0 | } |
2700 | | static FuStructGenesysFwRsaPublicKeyText * |
2701 | | fu_struct_genesys_fw_rsa_public_key_text_new_internal(void) |
2702 | 0 | { |
2703 | 0 | FuStructGenesysFwRsaPublicKeyText *st = g_new0(FuStructGenesysFwRsaPublicKeyText, 1); |
2704 | 0 | st->refcount = 1; |
2705 | 0 | return st; |
2706 | 0 | } |
2707 | | |
2708 | | /* getters */ |
2709 | | /** |
2710 | | * fu_struct_genesys_fw_rsa_public_key_text_get_tag_n: (skip): |
2711 | | **/ |
2712 | | static guint32 |
2713 | | fu_struct_genesys_fw_rsa_public_key_text_get_tag_n(const FuStructGenesysFwRsaPublicKeyText *st) |
2714 | 0 | { |
2715 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
2716 | 0 | return fu_memread_uint32(st->buf->data + 0, G_BIG_ENDIAN); |
2717 | 0 | } |
2718 | | /** |
2719 | | * fu_struct_genesys_fw_rsa_public_key_text_get_text_n: (skip): |
2720 | | **/ |
2721 | | gchar * |
2722 | | fu_struct_genesys_fw_rsa_public_key_text_get_text_n(const FuStructGenesysFwRsaPublicKeyText *st) |
2723 | 0 | { |
2724 | 0 | g_return_val_if_fail(st != NULL, NULL); |
2725 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 4, 512, NULL); |
2726 | 0 | } |
2727 | | /** |
2728 | | * fu_struct_genesys_fw_rsa_public_key_text_get_end_n: (skip): |
2729 | | **/ |
2730 | | static guint16 |
2731 | | fu_struct_genesys_fw_rsa_public_key_text_get_end_n(const FuStructGenesysFwRsaPublicKeyText *st) |
2732 | 0 | { |
2733 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
2734 | 0 | return fu_memread_uint16(st->buf->data + 516, G_BIG_ENDIAN); |
2735 | 0 | } |
2736 | | /** |
2737 | | * fu_struct_genesys_fw_rsa_public_key_text_get_tag_e: (skip): |
2738 | | **/ |
2739 | | static guint32 |
2740 | | fu_struct_genesys_fw_rsa_public_key_text_get_tag_e(const FuStructGenesysFwRsaPublicKeyText *st) |
2741 | 0 | { |
2742 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
2743 | 0 | return fu_memread_uint32(st->buf->data + 518, G_BIG_ENDIAN); |
2744 | 0 | } |
2745 | | /** |
2746 | | * fu_struct_genesys_fw_rsa_public_key_text_get_text_e: (skip): |
2747 | | **/ |
2748 | | gchar * |
2749 | | fu_struct_genesys_fw_rsa_public_key_text_get_text_e(const FuStructGenesysFwRsaPublicKeyText *st) |
2750 | 0 | { |
2751 | 0 | g_return_val_if_fail(st != NULL, NULL); |
2752 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 522, 6, NULL); |
2753 | 0 | } |
2754 | | /** |
2755 | | * fu_struct_genesys_fw_rsa_public_key_text_get_end_e: (skip): |
2756 | | **/ |
2757 | | static guint16 |
2758 | | fu_struct_genesys_fw_rsa_public_key_text_get_end_e(const FuStructGenesysFwRsaPublicKeyText *st) |
2759 | 0 | { |
2760 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
2761 | 0 | return fu_memread_uint16(st->buf->data + 528, G_BIG_ENDIAN); |
2762 | 0 | } |
2763 | | |
2764 | | /* setters */ |
2765 | | /** |
2766 | | * fu_struct_genesys_fw_rsa_public_key_text_to_string: (skip): |
2767 | | **/ |
2768 | | static gchar * |
2769 | | fu_struct_genesys_fw_rsa_public_key_text_to_string(const FuStructGenesysFwRsaPublicKeyText *st) |
2770 | 0 | { |
2771 | 0 | g_autoptr(GString) str = g_string_new("FuStructGenesysFwRsaPublicKeyText:\n"); |
2772 | 0 | g_return_val_if_fail(st != NULL, NULL); |
2773 | 0 | { |
2774 | 0 | g_autofree gchar *tmp = fu_struct_genesys_fw_rsa_public_key_text_get_text_n(st); |
2775 | 0 | if (tmp != NULL) |
2776 | 0 | g_string_append_printf(str, " text_n: %s\n", tmp); |
2777 | 0 | } |
2778 | 0 | { |
2779 | 0 | g_autofree gchar *tmp = fu_struct_genesys_fw_rsa_public_key_text_get_text_e(st); |
2780 | 0 | if (tmp != NULL) |
2781 | 0 | g_string_append_printf(str, " text_e: %s\n", tmp); |
2782 | 0 | } |
2783 | 0 | if (str->len > 0) |
2784 | 0 | g_string_set_size(str, str->len - 1); |
2785 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
2786 | 0 | } |
2787 | | static gboolean |
2788 | | fu_struct_genesys_fw_rsa_public_key_text_validate_internal(FuStructGenesysFwRsaPublicKeyText *st, GError **error) |
2789 | 0 | { |
2790 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
2791 | 0 | if (fu_struct_genesys_fw_rsa_public_key_text_get_tag_n(st) != 0x4E203D20) { |
2792 | 0 | g_set_error(error, |
2793 | 0 | FWUPD_ERROR, |
2794 | 0 | FWUPD_ERROR_INVALID_DATA, |
2795 | 0 | "constant FuStructGenesysFwRsaPublicKeyText.tag_n was not valid, " |
2796 | 0 | "expected 0x%x and got 0x%x", |
2797 | 0 | (guint) 0x4E203D20, |
2798 | 0 | (guint) fu_struct_genesys_fw_rsa_public_key_text_get_tag_n(st)); |
2799 | 0 | return FALSE; |
2800 | 0 | } |
2801 | 0 | if (fu_struct_genesys_fw_rsa_public_key_text_get_end_n(st) != 0x0D0A) { |
2802 | 0 | g_set_error(error, |
2803 | 0 | FWUPD_ERROR, |
2804 | 0 | FWUPD_ERROR_INVALID_DATA, |
2805 | 0 | "constant FuStructGenesysFwRsaPublicKeyText.end_n was not valid, " |
2806 | 0 | "expected 0x%x and got 0x%x", |
2807 | 0 | (guint) 0x0D0A, |
2808 | 0 | (guint) fu_struct_genesys_fw_rsa_public_key_text_get_end_n(st)); |
2809 | 0 | return FALSE; |
2810 | 0 | } |
2811 | 0 | if (fu_struct_genesys_fw_rsa_public_key_text_get_tag_e(st) != 0x45203D20) { |
2812 | 0 | g_set_error(error, |
2813 | 0 | FWUPD_ERROR, |
2814 | 0 | FWUPD_ERROR_INVALID_DATA, |
2815 | 0 | "constant FuStructGenesysFwRsaPublicKeyText.tag_e was not valid, " |
2816 | 0 | "expected 0x%x and got 0x%x", |
2817 | 0 | (guint) 0x45203D20, |
2818 | 0 | (guint) fu_struct_genesys_fw_rsa_public_key_text_get_tag_e(st)); |
2819 | 0 | return FALSE; |
2820 | 0 | } |
2821 | 0 | if (fu_struct_genesys_fw_rsa_public_key_text_get_end_e(st) != 0x0D0A) { |
2822 | 0 | g_set_error(error, |
2823 | 0 | FWUPD_ERROR, |
2824 | 0 | FWUPD_ERROR_INVALID_DATA, |
2825 | 0 | "constant FuStructGenesysFwRsaPublicKeyText.end_e was not valid, " |
2826 | 0 | "expected 0x%x and got 0x%x", |
2827 | 0 | (guint) 0x0D0A, |
2828 | 0 | (guint) fu_struct_genesys_fw_rsa_public_key_text_get_end_e(st)); |
2829 | 0 | return FALSE; |
2830 | 0 | } |
2831 | 0 | return TRUE; |
2832 | 0 | } |
2833 | | /** |
2834 | | * fu_struct_genesys_fw_rsa_public_key_text_validate: (skip): |
2835 | | **/ |
2836 | | gboolean |
2837 | | fu_struct_genesys_fw_rsa_public_key_text_validate(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
2838 | 0 | { |
2839 | 0 | GByteArray st_buf = {.data = (guint8 *) buf + offset, .len = bufsz - offset, }; |
2840 | 0 | FuStructGenesysFwRsaPublicKeyText st_tmp = {.buf = &st_buf }; |
2841 | 0 | g_return_val_if_fail(buf != NULL, FALSE); |
2842 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
2843 | 0 | if (!fu_memchk_read(bufsz, offset, 530, error)) { |
2844 | 0 | g_prefix_error_literal(error, "invalid struct FuStructGenesysFwRsaPublicKeyText: "); |
2845 | 0 | return FALSE; |
2846 | 0 | } |
2847 | 0 | if (!fu_struct_genesys_fw_rsa_public_key_text_validate_internal(&st_tmp, error)) |
2848 | 0 | return FALSE; |
2849 | 0 | return TRUE; |
2850 | 0 | } |
2851 | | static gboolean |
2852 | | fu_struct_genesys_fw_rsa_public_key_text_parse_internal(FuStructGenesysFwRsaPublicKeyText *st, GError **error) |
2853 | 0 | { |
2854 | 0 | if (g_getenv("FWUPD_VERBOSE") != NULL) { |
2855 | 0 | g_autofree gchar *str = fu_struct_genesys_fw_rsa_public_key_text_to_string(st); |
2856 | 0 | g_debug("%s", str); |
2857 | 0 | } |
2858 | 0 | if (!fu_struct_genesys_fw_rsa_public_key_text_validate_internal(st, error)) |
2859 | 0 | return FALSE; |
2860 | 0 | return TRUE; |
2861 | 0 | } |
2862 | | |
2863 | | /** |
2864 | | * fu_struct_genesys_fw_rsa_public_key_text_parse: (skip): |
2865 | | **/ |
2866 | | FuStructGenesysFwRsaPublicKeyText * |
2867 | | fu_struct_genesys_fw_rsa_public_key_text_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
2868 | 0 | { |
2869 | 0 | g_autoptr(FuStructGenesysFwRsaPublicKeyText) st = fu_struct_genesys_fw_rsa_public_key_text_new_internal(); |
2870 | 0 | g_return_val_if_fail(buf != NULL, NULL); |
2871 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, NULL); |
2872 | 0 | if (!fu_memchk_read(bufsz, offset, 530, error)) { |
2873 | 0 | g_prefix_error_literal(error, "invalid struct FuStructGenesysFwRsaPublicKeyText: "); |
2874 | 0 | return NULL; |
2875 | 0 | } |
2876 | 0 | st->buf = g_byte_array_new(); |
2877 | 0 | g_byte_array_append(st->buf, buf + offset, 530); |
2878 | 0 | if (!fu_struct_genesys_fw_rsa_public_key_text_parse_internal(st, error)) |
2879 | 0 | return NULL; |
2880 | 0 | return g_steal_pointer(&st); |
2881 | 0 | } |
2882 | | /** |
2883 | | * fu_struct_genesys_fw_codesign_info_ecdsa_ref: (skip): |
2884 | | **/ |
2885 | | FuStructGenesysFwCodesignInfoEcdsa * |
2886 | | fu_struct_genesys_fw_codesign_info_ecdsa_ref(FuStructGenesysFwCodesignInfoEcdsa *st) |
2887 | 0 | { |
2888 | 0 | g_return_val_if_fail(st != NULL, NULL); |
2889 | 0 | st->refcount++; |
2890 | 0 | return st; |
2891 | 0 | } |
2892 | | /** |
2893 | | * fu_struct_genesys_fw_codesign_info_ecdsa_unref: (skip): |
2894 | | **/ |
2895 | | void |
2896 | | fu_struct_genesys_fw_codesign_info_ecdsa_unref(FuStructGenesysFwCodesignInfoEcdsa *st) |
2897 | 23 | { |
2898 | 23 | g_return_if_fail(st != NULL); |
2899 | 23 | if (st->refcount == 0) { |
2900 | 0 | g_critical("FuStructGenesysFwCodesignInfoEcdsa refcount already zero"); |
2901 | 0 | return; |
2902 | 0 | } |
2903 | 23 | if (--st->refcount > 0) |
2904 | 0 | return; |
2905 | 23 | if (st->buf != NULL) |
2906 | 23 | g_byte_array_unref(st->buf); |
2907 | 23 | g_free(st); |
2908 | 23 | } |
2909 | | static FuStructGenesysFwCodesignInfoEcdsa * |
2910 | | fu_struct_genesys_fw_codesign_info_ecdsa_new_internal(void) |
2911 | 23 | { |
2912 | 23 | FuStructGenesysFwCodesignInfoEcdsa *st = g_new0(FuStructGenesysFwCodesignInfoEcdsa, 1); |
2913 | 23 | st->refcount = 1; |
2914 | 23 | return st; |
2915 | 23 | } |
2916 | | |
2917 | | /* getters */ |
2918 | | /** |
2919 | | * fu_struct_genesys_fw_codesign_info_ecdsa_get_hash: (skip): |
2920 | | **/ |
2921 | | const guint8 * |
2922 | | fu_struct_genesys_fw_codesign_info_ecdsa_get_hash(const FuStructGenesysFwCodesignInfoEcdsa *st, gsize *bufsz) |
2923 | 0 | { |
2924 | 0 | g_return_val_if_fail(st != NULL, NULL); |
2925 | 0 | if (bufsz != NULL) |
2926 | 0 | *bufsz = 32; |
2927 | 0 | return st->buf->data + 0; |
2928 | 0 | } |
2929 | | /** |
2930 | | * fu_struct_genesys_fw_codesign_info_ecdsa_get_key: (skip): |
2931 | | **/ |
2932 | | const guint8 * |
2933 | | fu_struct_genesys_fw_codesign_info_ecdsa_get_key(const FuStructGenesysFwCodesignInfoEcdsa *st, gsize *bufsz) |
2934 | 0 | { |
2935 | 0 | g_return_val_if_fail(st != NULL, NULL); |
2936 | 0 | if (bufsz != NULL) |
2937 | 0 | *bufsz = 64; |
2938 | 0 | return st->buf->data + 32; |
2939 | 0 | } |
2940 | | /** |
2941 | | * fu_struct_genesys_fw_codesign_info_ecdsa_get_signature: (skip): |
2942 | | **/ |
2943 | | const guint8 * |
2944 | | fu_struct_genesys_fw_codesign_info_ecdsa_get_signature(const FuStructGenesysFwCodesignInfoEcdsa *st, gsize *bufsz) |
2945 | 0 | { |
2946 | 0 | g_return_val_if_fail(st != NULL, NULL); |
2947 | 0 | if (bufsz != NULL) |
2948 | 0 | *bufsz = 64; |
2949 | 0 | return st->buf->data + 96; |
2950 | 0 | } |
2951 | | |
2952 | | /* setters */ |
2953 | | /** |
2954 | | * fu_struct_genesys_fw_codesign_info_ecdsa_to_string: (skip): |
2955 | | **/ |
2956 | | static gchar * |
2957 | | fu_struct_genesys_fw_codesign_info_ecdsa_to_string(const FuStructGenesysFwCodesignInfoEcdsa *st) |
2958 | 0 | { |
2959 | 0 | g_autoptr(GString) str = g_string_new("FuStructGenesysFwCodesignInfoEcdsa:\n"); |
2960 | 0 | g_return_val_if_fail(st != NULL, NULL); |
2961 | 0 | { |
2962 | 0 | gsize bufsz = 0; |
2963 | 0 | const guint8 *buf = fu_struct_genesys_fw_codesign_info_ecdsa_get_hash(st, &bufsz); |
2964 | 0 | g_autoptr(GString) tmp = g_string_new(NULL); |
2965 | 0 | for (gsize i = 0; i < bufsz; i++) |
2966 | 0 | g_string_append_printf(tmp, "%02X", buf[i]); |
2967 | 0 | g_string_append_printf(str, " hash: 0x%s\n", tmp->str); |
2968 | 0 | } |
2969 | 0 | { |
2970 | 0 | gsize bufsz = 0; |
2971 | 0 | const guint8 *buf = fu_struct_genesys_fw_codesign_info_ecdsa_get_key(st, &bufsz); |
2972 | 0 | g_autoptr(GString) tmp = g_string_new(NULL); |
2973 | 0 | for (gsize i = 0; i < bufsz; i++) |
2974 | 0 | g_string_append_printf(tmp, "%02X", buf[i]); |
2975 | 0 | g_string_append_printf(str, " key: 0x%s\n", tmp->str); |
2976 | 0 | } |
2977 | 0 | { |
2978 | 0 | gsize bufsz = 0; |
2979 | 0 | const guint8 *buf = fu_struct_genesys_fw_codesign_info_ecdsa_get_signature(st, &bufsz); |
2980 | 0 | g_autoptr(GString) tmp = g_string_new(NULL); |
2981 | 0 | for (gsize i = 0; i < bufsz; i++) |
2982 | 0 | g_string_append_printf(tmp, "%02X", buf[i]); |
2983 | 0 | g_string_append_printf(str, " signature: 0x%s\n", tmp->str); |
2984 | 0 | } |
2985 | 0 | if (str->len > 0) |
2986 | 0 | g_string_set_size(str, str->len - 1); |
2987 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
2988 | 0 | } |
2989 | | static gboolean |
2990 | | fu_struct_genesys_fw_codesign_info_ecdsa_validate_internal(FuStructGenesysFwCodesignInfoEcdsa *st, GError **error) |
2991 | 23 | { |
2992 | 23 | g_return_val_if_fail(st != NULL, FALSE); |
2993 | 23 | return TRUE; |
2994 | 23 | } |
2995 | | /** |
2996 | | * fu_struct_genesys_fw_codesign_info_ecdsa_validate: (skip): |
2997 | | **/ |
2998 | | gboolean |
2999 | | fu_struct_genesys_fw_codesign_info_ecdsa_validate(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
3000 | 0 | { |
3001 | 0 | GByteArray st_buf = {.data = (guint8 *) buf + offset, .len = bufsz - offset, }; |
3002 | 0 | FuStructGenesysFwCodesignInfoEcdsa st_tmp = {.buf = &st_buf }; |
3003 | 0 | g_return_val_if_fail(buf != NULL, FALSE); |
3004 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
3005 | 0 | if (!fu_memchk_read(bufsz, offset, 160, error)) { |
3006 | 0 | g_prefix_error_literal(error, "invalid struct FuStructGenesysFwCodesignInfoEcdsa: "); |
3007 | 0 | return FALSE; |
3008 | 0 | } |
3009 | 0 | if (!fu_struct_genesys_fw_codesign_info_ecdsa_validate_internal(&st_tmp, error)) |
3010 | 0 | return FALSE; |
3011 | 0 | return TRUE; |
3012 | 0 | } |
3013 | | /** |
3014 | | * fu_struct_genesys_fw_codesign_info_ecdsa_validate_stream: (skip): |
3015 | | **/ |
3016 | | gboolean |
3017 | | fu_struct_genesys_fw_codesign_info_ecdsa_validate_stream(GInputStream *stream, gsize offset, GError **error) |
3018 | 23 | { |
3019 | 23 | g_autoptr(FuStructGenesysFwCodesignInfoEcdsa) st = fu_struct_genesys_fw_codesign_info_ecdsa_new_internal(); |
3020 | 23 | g_return_val_if_fail(G_IS_INPUT_STREAM(stream), FALSE); |
3021 | 23 | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
3022 | 23 | st->buf = fu_input_stream_read_byte_array(stream, offset, 160, NULL, error); |
3023 | 23 | if (st->buf == NULL) { |
3024 | 0 | g_prefix_error(error, "FuStructGenesysFwCodesignInfoEcdsa failed read of 0x%x: ", (guint) 160); |
3025 | 0 | return FALSE; |
3026 | 0 | } |
3027 | 23 | if (st->buf->len != 160) { |
3028 | 0 | g_set_error(error, |
3029 | 0 | FWUPD_ERROR, |
3030 | 0 | FWUPD_ERROR_INVALID_DATA, |
3031 | 0 | "FuStructGenesysFwCodesignInfoEcdsa requested 0x%x and got 0x%x", |
3032 | 0 | (guint) 160, |
3033 | 0 | (guint) st->buf->len); |
3034 | 0 | return FALSE; |
3035 | 0 | } |
3036 | 23 | return fu_struct_genesys_fw_codesign_info_ecdsa_validate_internal(st, error); |
3037 | 23 | } |
3038 | | static gboolean |
3039 | | fu_struct_genesys_fw_codesign_info_ecdsa_parse_internal(FuStructGenesysFwCodesignInfoEcdsa *st, GError **error) |
3040 | 0 | { |
3041 | 0 | if (g_getenv("FWUPD_VERBOSE") != NULL) { |
3042 | 0 | g_autofree gchar *str = fu_struct_genesys_fw_codesign_info_ecdsa_to_string(st); |
3043 | 0 | g_debug("%s", str); |
3044 | 0 | } |
3045 | 0 | if (!fu_struct_genesys_fw_codesign_info_ecdsa_validate_internal(st, error)) |
3046 | 0 | return FALSE; |
3047 | 0 | return TRUE; |
3048 | 0 | } |
3049 | | |
3050 | | /** |
3051 | | * fu_struct_genesys_fw_codesign_info_ecdsa_parse: (skip): |
3052 | | **/ |
3053 | | FuStructGenesysFwCodesignInfoEcdsa * |
3054 | | fu_struct_genesys_fw_codesign_info_ecdsa_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
3055 | 0 | { |
3056 | 0 | g_autoptr(FuStructGenesysFwCodesignInfoEcdsa) st = fu_struct_genesys_fw_codesign_info_ecdsa_new_internal(); |
3057 | 0 | g_return_val_if_fail(buf != NULL, NULL); |
3058 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, NULL); |
3059 | 0 | if (!fu_memchk_read(bufsz, offset, 160, error)) { |
3060 | 0 | g_prefix_error_literal(error, "invalid struct FuStructGenesysFwCodesignInfoEcdsa: "); |
3061 | 0 | return NULL; |
3062 | 0 | } |
3063 | 0 | st->buf = g_byte_array_new(); |
3064 | 0 | g_byte_array_append(st->buf, buf + offset, 160); |
3065 | 0 | if (!fu_struct_genesys_fw_codesign_info_ecdsa_parse_internal(st, error)) |
3066 | 0 | return NULL; |
3067 | 0 | return g_steal_pointer(&st); |
3068 | 0 | } |
3069 | | /** |
3070 | | * fu_struct_genesys_fw_codesign_info_ecdsa_parse_stream: (skip): |
3071 | | **/ |
3072 | | FuStructGenesysFwCodesignInfoEcdsa * |
3073 | | fu_struct_genesys_fw_codesign_info_ecdsa_parse_stream(GInputStream *stream, gsize offset, GError **error) |
3074 | 0 | { |
3075 | 0 | g_autoptr(FuStructGenesysFwCodesignInfoEcdsa) st = fu_struct_genesys_fw_codesign_info_ecdsa_new_internal(); |
3076 | 0 | st->buf = fu_input_stream_read_byte_array(stream, offset, 160, NULL, error); |
3077 | 0 | if (st->buf == NULL) { |
3078 | 0 | g_prefix_error(error, "FuStructGenesysFwCodesignInfoEcdsa failed read of 0x%x: ", (guint) 160); |
3079 | 0 | return NULL; |
3080 | 0 | } |
3081 | 0 | if (st->buf->len != 160) { |
3082 | 0 | g_set_error(error, |
3083 | 0 | FWUPD_ERROR, |
3084 | 0 | FWUPD_ERROR_INVALID_DATA, |
3085 | 0 | "FuStructGenesysFwCodesignInfoEcdsa requested 0x%x and got 0x%x", |
3086 | 0 | (guint) 160, |
3087 | 0 | (guint) st->buf->len); |
3088 | 0 | return NULL; |
3089 | 0 | } |
3090 | 0 | if (!fu_struct_genesys_fw_codesign_info_ecdsa_parse_internal(st, error)) |
3091 | 0 | return NULL; |
3092 | 0 | return g_steal_pointer(&st); |
3093 | 0 | } |
3094 | | /** |
3095 | | * fu_struct_genesys_fw_ecdsa_public_key_ref: (skip): |
3096 | | **/ |
3097 | | FuStructGenesysFwEcdsaPublicKey * |
3098 | | fu_struct_genesys_fw_ecdsa_public_key_ref(FuStructGenesysFwEcdsaPublicKey *st) |
3099 | 0 | { |
3100 | 0 | g_return_val_if_fail(st != NULL, NULL); |
3101 | 0 | st->refcount++; |
3102 | 0 | return st; |
3103 | 0 | } |
3104 | | /** |
3105 | | * fu_struct_genesys_fw_ecdsa_public_key_unref: (skip): |
3106 | | **/ |
3107 | | void |
3108 | | fu_struct_genesys_fw_ecdsa_public_key_unref(FuStructGenesysFwEcdsaPublicKey *st) |
3109 | 0 | { |
3110 | 0 | g_return_if_fail(st != NULL); |
3111 | 0 | if (st->refcount == 0) { |
3112 | 0 | g_critical("FuStructGenesysFwEcdsaPublicKey refcount already zero"); |
3113 | 0 | return; |
3114 | 0 | } |
3115 | 0 | if (--st->refcount > 0) |
3116 | 0 | return; |
3117 | 0 | if (st->buf != NULL) |
3118 | 0 | g_byte_array_unref(st->buf); |
3119 | 0 | g_free(st); |
3120 | 0 | } |
3121 | | static FuStructGenesysFwEcdsaPublicKey * |
3122 | | fu_struct_genesys_fw_ecdsa_public_key_new_internal(void) |
3123 | 0 | { |
3124 | 0 | FuStructGenesysFwEcdsaPublicKey *st = g_new0(FuStructGenesysFwEcdsaPublicKey, 1); |
3125 | 0 | st->refcount = 1; |
3126 | 0 | return st; |
3127 | 0 | } |
3128 | | |
3129 | | /* getters */ |
3130 | | /** |
3131 | | * fu_struct_genesys_fw_ecdsa_public_key_get_key: (skip): |
3132 | | **/ |
3133 | | const guint8 * |
3134 | | fu_struct_genesys_fw_ecdsa_public_key_get_key(const FuStructGenesysFwEcdsaPublicKey *st, gsize *bufsz) |
3135 | 0 | { |
3136 | 0 | g_return_val_if_fail(st != NULL, NULL); |
3137 | 0 | if (bufsz != NULL) |
3138 | 0 | *bufsz = 64; |
3139 | 0 | return st->buf->data + 0; |
3140 | 0 | } |
3141 | | |
3142 | | /* setters */ |
3143 | | /** |
3144 | | * fu_struct_genesys_fw_ecdsa_public_key_to_string: (skip): |
3145 | | **/ |
3146 | | static gchar * |
3147 | | fu_struct_genesys_fw_ecdsa_public_key_to_string(const FuStructGenesysFwEcdsaPublicKey *st) |
3148 | 0 | { |
3149 | 0 | g_autoptr(GString) str = g_string_new("FuStructGenesysFwEcdsaPublicKey:\n"); |
3150 | 0 | g_return_val_if_fail(st != NULL, NULL); |
3151 | 0 | { |
3152 | 0 | gsize bufsz = 0; |
3153 | 0 | const guint8 *buf = fu_struct_genesys_fw_ecdsa_public_key_get_key(st, &bufsz); |
3154 | 0 | g_autoptr(GString) tmp = g_string_new(NULL); |
3155 | 0 | for (gsize i = 0; i < bufsz; i++) |
3156 | 0 | g_string_append_printf(tmp, "%02X", buf[i]); |
3157 | 0 | g_string_append_printf(str, " key: 0x%s\n", tmp->str); |
3158 | 0 | } |
3159 | 0 | if (str->len > 0) |
3160 | 0 | g_string_set_size(str, str->len - 1); |
3161 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
3162 | 0 | } |
3163 | | static gboolean |
3164 | | fu_struct_genesys_fw_ecdsa_public_key_validate_internal(FuStructGenesysFwEcdsaPublicKey *st, GError **error) |
3165 | 0 | { |
3166 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
3167 | 0 | return TRUE; |
3168 | 0 | } |
3169 | | /** |
3170 | | * fu_struct_genesys_fw_ecdsa_public_key_validate: (skip): |
3171 | | **/ |
3172 | | gboolean |
3173 | | fu_struct_genesys_fw_ecdsa_public_key_validate(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
3174 | 0 | { |
3175 | 0 | GByteArray st_buf = {.data = (guint8 *) buf + offset, .len = bufsz - offset, }; |
3176 | 0 | FuStructGenesysFwEcdsaPublicKey st_tmp = {.buf = &st_buf }; |
3177 | 0 | g_return_val_if_fail(buf != NULL, FALSE); |
3178 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
3179 | 0 | if (!fu_memchk_read(bufsz, offset, 64, error)) { |
3180 | 0 | g_prefix_error_literal(error, "invalid struct FuStructGenesysFwEcdsaPublicKey: "); |
3181 | 0 | return FALSE; |
3182 | 0 | } |
3183 | 0 | if (!fu_struct_genesys_fw_ecdsa_public_key_validate_internal(&st_tmp, error)) |
3184 | 0 | return FALSE; |
3185 | 0 | return TRUE; |
3186 | 0 | } |
3187 | | static gboolean |
3188 | | fu_struct_genesys_fw_ecdsa_public_key_parse_internal(FuStructGenesysFwEcdsaPublicKey *st, GError **error) |
3189 | 0 | { |
3190 | 0 | if (g_getenv("FWUPD_VERBOSE") != NULL) { |
3191 | 0 | g_autofree gchar *str = fu_struct_genesys_fw_ecdsa_public_key_to_string(st); |
3192 | 0 | g_debug("%s", str); |
3193 | 0 | } |
3194 | 0 | if (!fu_struct_genesys_fw_ecdsa_public_key_validate_internal(st, error)) |
3195 | 0 | return FALSE; |
3196 | 0 | return TRUE; |
3197 | 0 | } |
3198 | | |
3199 | | /** |
3200 | | * fu_struct_genesys_fw_ecdsa_public_key_parse: (skip): |
3201 | | **/ |
3202 | | FuStructGenesysFwEcdsaPublicKey * |
3203 | | fu_struct_genesys_fw_ecdsa_public_key_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
3204 | 0 | { |
3205 | 0 | g_autoptr(FuStructGenesysFwEcdsaPublicKey) st = fu_struct_genesys_fw_ecdsa_public_key_new_internal(); |
3206 | 0 | g_return_val_if_fail(buf != NULL, NULL); |
3207 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, NULL); |
3208 | 0 | if (!fu_memchk_read(bufsz, offset, 64, error)) { |
3209 | 0 | g_prefix_error_literal(error, "invalid struct FuStructGenesysFwEcdsaPublicKey: "); |
3210 | 0 | return NULL; |
3211 | 0 | } |
3212 | 0 | st->buf = g_byte_array_new(); |
3213 | 0 | g_byte_array_append(st->buf, buf + offset, 64); |
3214 | 0 | if (!fu_struct_genesys_fw_ecdsa_public_key_parse_internal(st, error)) |
3215 | 0 | return NULL; |
3216 | 0 | return g_steal_pointer(&st); |
3217 | 0 | } |