diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 09:27:07 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 09:27:07 +0000 |
commit | e2e1a00b1595b4930b86e3ba3ea2e9b771a79653 (patch) | |
tree | ba77e3ac3992e0dbf8f751513b9015d37122a2b1 /desc-dump.h | |
parent | Initial commit. (diff) | |
download | usbutils-e2e1a00b1595b4930b86e3ba3ea2e9b771a79653.tar.xz usbutils-e2e1a00b1595b4930b86e3ba3ea2e9b771a79653.zip |
Adding upstream version 1:014.upstream/1%014upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'desc-dump.h')
-rw-r--r-- | desc-dump.h | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/desc-dump.h b/desc-dump.h new file mode 100644 index 0000000..a6191a1 --- /dev/null +++ b/desc-dump.h @@ -0,0 +1,50 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * USB descriptor dumping + * + * Copyright (C) 2017 Michael Drake <michael.drake@codethink.co.uk> + */ + +#ifndef _DESC_DUMP_H +#define _DESC_DUMP_H + +/* ---------------------------------------------------------------------- */ + +/** + * Buffer length value indicating that the buffer length should be + * read from the value of the first field in the buffer, as defined + * by the first field descriptor definition. + */ +#define DESC_BUF_LEN_FROM_BUF 0xffffffff + +/** + * Dump descriptor using a descriptor definition array. + * + * This function dumps the USB descriptor data given in the byte array, + * `buf`, according to the descriptor definition array given in `desc`. + * + * The first byte(s) of `buf` must correspond to the first field definition + * in the `desc` descriptor definition array. + * + * \param[in] dev LibUSB device handle. + * \param[in] desc Array of descriptor field definitions to use to interpret + * `buf`. This array constitutes the descriptor definition. + * The final entry in the array must have a NULL field name, + * which is interpreted as the end of the array. + * \param[in] buf Byte array containing the descriptor data to dump. + * \param[in] buf_len Byte length of `buf` or `DESC_BUF_LEN_FROM_BUF` to get + * the length from the value of the first field in the + * descriptor data. + * \param[in] indent Indent level to use for descriptor dump. + */ +extern void desc_dump( + libusb_device_handle *dev, + const struct desc *desc, + const unsigned char *buf, + unsigned int buf_len, + unsigned int indent); + + +/* ---------------------------------------------------------------------- */ + +#endif /* _DESC_DUMP_H */ |