-
Notifications
You must be signed in to change notification settings - Fork 203
/
desc-dump.h
50 lines (43 loc) · 1.74 KB
/
desc-dump.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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 */