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