| [5ccb15c] | 1 | /*
|
|---|
| [d7f7a4a] | 2 | * SPDX-FileCopyrightText: 2011 Vojtech Horky
|
|---|
| [5ccb15c] | 3 | *
|
|---|
| [d7f7a4a] | 4 | * SPDX-License-Identifier: BSD-3-Clause
|
|---|
| [5ccb15c] | 5 | */
|
|---|
| 6 |
|
|---|
| [160b75e] | 7 | /** @addtogroup libusbdev
|
|---|
| [5ccb15c] | 8 | * @{
|
|---|
| 9 | */
|
|---|
| 10 | /** @file
|
|---|
| [a6add7a] | 11 | * USB descriptor parser.
|
|---|
| [5ccb15c] | 12 | */
|
|---|
| [7d521e24] | 13 | #ifndef LIBUSBDEV_DP_H_
|
|---|
| 14 | #define LIBUSBDEV_DP_H_
|
|---|
| [5ccb15c] | 15 |
|
|---|
| [8d2dd7f2] | 16 | #include <stddef.h>
|
|---|
| 17 | #include <stdint.h>
|
|---|
| [5ccb15c] | 18 |
|
|---|
| [a6add7a] | 19 | /** USB descriptors nesting.
|
|---|
| 20 | * The nesting describes the logical tree USB descriptors form
|
|---|
| 21 | * (e.g. that endpoint descriptor belongs to interface or that
|
|---|
| 22 | * interface belongs to configuration).
|
|---|
| 23 | *
|
|---|
| 24 | * See usb_descriptor_type_t for descriptor constants.
|
|---|
| 25 | */
|
|---|
| [5ccb15c] | 26 | typedef struct {
|
|---|
| [a6add7a] | 27 | /** Child descriptor id. */
|
|---|
| [5ccb15c] | 28 | int child;
|
|---|
| [a6add7a] | 29 | /** Parent descriptor id. */
|
|---|
| [5ccb15c] | 30 | int parent;
|
|---|
| 31 | } usb_dp_descriptor_nesting_t;
|
|---|
| 32 |
|
|---|
| [207acc4e] | 33 | extern const usb_dp_descriptor_nesting_t usb_dp_standard_descriptor_nesting[];
|
|---|
| [745d2ad] | 34 |
|
|---|
| [a6add7a] | 35 | /** Descriptor parser structure. */
|
|---|
| [5ccb15c] | 36 | typedef struct {
|
|---|
| [a6add7a] | 37 | /** Used descriptor nesting. */
|
|---|
| [8a121b1] | 38 | const usb_dp_descriptor_nesting_t *nesting;
|
|---|
| [5ccb15c] | 39 | } usb_dp_parser_t;
|
|---|
| 40 |
|
|---|
| [a6add7a] | 41 | /** Descriptor parser data. */
|
|---|
| [5ccb15c] | 42 | typedef struct {
|
|---|
| [a6add7a] | 43 | /** Data to be parsed. */
|
|---|
| [7c95d6f5] | 44 | const uint8_t *data;
|
|---|
| [a6add7a] | 45 | /** Size of input data in bytes. */
|
|---|
| [5ccb15c] | 46 | size_t size;
|
|---|
| [a6add7a] | 47 | /** Custom argument. */
|
|---|
| [5ccb15c] | 48 | void *arg;
|
|---|
| 49 | } usb_dp_parser_data_t;
|
|---|
| 50 |
|
|---|
| [8a121b1] | 51 | typedef void (*walk_callback_t)(const uint8_t *, size_t, void *);
|
|---|
| [5ccb15c] | 52 |
|
|---|
| [8a121b1] | 53 | const uint8_t *usb_dp_get_nested_descriptor(const usb_dp_parser_t *,
|
|---|
| 54 | const usb_dp_parser_data_t *, const uint8_t *);
|
|---|
| 55 | const uint8_t *usb_dp_get_sibling_descriptor(const usb_dp_parser_t *,
|
|---|
| 56 | const usb_dp_parser_data_t *, const uint8_t *, const uint8_t *);
|
|---|
| 57 |
|
|---|
| [25effe2] | 58 | void usb_dp_walk_simple(const uint8_t *, size_t,
|
|---|
| 59 | const usb_dp_descriptor_nesting_t *, walk_callback_t, void *);
|
|---|
| [da77278] | 60 |
|
|---|
| [5ccb15c] | 61 | #endif
|
|---|
| 62 | /**
|
|---|
| 63 | * @}
|
|---|
| 64 | */
|
|---|