1 // SPDX-License-Identifier: GPL-2.0+
3 * USB descriptor dumping
5 * Copyright (C) 2017 Michael Drake <michael.drake@codethink.co.uk>
11 /* ---------------------------------------------------------------------- */
14 * Buffer length value indicating that the buffer length should be
15 * read from the value of the first field in the buffer, as defined
16 * by the first field descriptor definition.
18 #define DESC_BUF_LEN_FROM_BUF 0xffffffff
21 * Dump descriptor using a descriptor definition array.
23 * This function dumps the USB descriptor data given in the byte array,
24 * `buf`, according to the descriptor definition array given in `desc`.
26 * The first byte(s) of `buf` must correspond to the first field definition
27 * in the `desc` descriptor definition array.
29 * \param[in] dev LibUSB device handle.
30 * \param[in] desc Array of descriptor field definitions to use to interpret
31 * `buf`. This array constitutes the descriptor definition.
32 * The final entry in the array must have a NULL field name,
33 * which is interpreted as the end of the array.
34 * \param[in] buf Byte array containing the descriptor data to dump.
35 * \param[in] buf_len Byte length of `buf` or `DESC_BUF_LEN_FROM_BUF` to get
36 * the length from the value of the first field in the
38 * \param[in] indent Indent level to use for descriptor dump.
40 extern void desc_dump(
41 libusb_device_handle *dev,
42 const struct desc *desc,
43 const unsigned char *buf,
48 /* ---------------------------------------------------------------------- */
50 #endif /* _DESC_DUMP_H */