1usb_parse_data(9F)       Kernel Functions for Drivers       usb_parse_data(9F)
2
3
4

NAME

6       usb_parse_data  -  Tokenize  and align the bytes of raw variable-format
7       data
8

SYNOPSIS

10       #include <sys/usb/usba.h>
11
12
13
14       size_t usb_parse_data(char *format, uchar_t *data,
15            size_t datalen, void *structure, size_t structlen);
16
17

INTERFACE LEVEL

19       Solaris DDI specific (Solaris DDI)
20

PARAMETERS

22       format       Null terminated string describing the format of  the  data
23                    structure  for  general-purpose byte swapping. The letters
24                    "c," "s," "l," and "L" represent 1, 2, 4 and 8 byte  quan‐
25                    tities,  respectively.  A  descriptor  that  consists of a
26                    short and two bytes would be described by "scc." A  number
27                    preceding  a letter serves as a multiplier of that letter.
28                    A format equivalent to "scc" is "s2c."
29
30
31       data         Raw descriptor data to parse.
32
33
34       datalen      Length, in bytes, of the raw descriptor data buffer.
35
36
37       structure    Destination data buffer where parsed data is returned.
38
39
40       structlen    Length, in bytes, of the destination data  buffer.  Parsed
41                    result length will not exceed this value.
42
43

DESCRIPTION

45       The  usb_parse_data  function  parses  data  such  as a variable-format
46       class- or vendor-specific descriptor. The function also  tokenizes  and
47       aligns  the bytes of raw descriptor data into fields of a variable-for‐
48       mat descriptor.
49
50
51       While the USBA framework can parse the endpoint, interface,  configura‐
52       tion,  and string descriptors defined by the USB 2.0 specification, the
53       format of class- or vendor-specific descriptors  cannot  be  explicitly
54       defined  by  the  specification and will be unique for each. The format
55       argument defines how to parse such a descriptor.
56
57
58       While the USB specification defines bit ordering as little-endian, this
59       routine  (like  the entire API), converts the data to the endianness of
60       the host.
61
62
63       The structlen parameter defines the size of the destination  data  buf‐
64       fer.  Data  is truncated to this size if the destination data buffer is
65       too small.
66

RETURN VALUES

68       On success: Returns the size (in bytes) of the parsed data result.
69
70
71       On failure: Returns 0. (Same as USB_PARSE_ERROR).
72

CONTEXT

74       May be called from user, kernel or interrupt context.
75

EXAMPLES

77           /*
78            * Parse raw descriptor data in buf, putting result into ret_descr.
79            * ret_buf_len holds the size of ret_descr buf;  routine returns
80            * number of resulting bytes.
81            *
82            * Descriptor being parsed has 2 chars, followed by one short,
83            * 3 chars and one more short.
84            */
85           size_t size_of_returned_descr;
86           xxx_descr_t ret_descr;
87
88            size_of_returned_descr = usb_parse_data("ccscccs",
89               buf, sizeof(buf), (void *)ret_descr, (sizeof)xxx_descr_t));
90           if (size_of_returned_descr < (sizeof (xxx_descr_t))) {
91                    /* Data truncated. */
92           }
93
94           or:
95
96           size_of_returned_descr = usb_parse_data("2cs3cs",
97               buf, sizeof(buf), (void *)ret_descr, (sizeof)xxx_descr_t));
98           if (size_of_returned_descr < (sizeof (xxx_descr_t))) {
99                   /* Data truncated. */
100           }
101
102

ATTRIBUTES

104       See attributes(5) for descriptions of the following attributes:
105
106
107
108
109       ┌─────────────────────────────┬─────────────────────────────┐
110       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
111       ├─────────────────────────────┼─────────────────────────────┤
112       │Architecture                 │PCI-based systems            │
113       ├─────────────────────────────┼─────────────────────────────┤
114       │Interface stability          │Committed                    │
115       ├─────────────────────────────┼─────────────────────────────┤
116       │Availability                 │SUNWusb                      │
117       └─────────────────────────────┴─────────────────────────────┘
118

SEE ALSO

120       attributes(5),     usb_get_dev_data(9F),      usb_get_string_descr(9F),
121       usb_get_cfg(9F)
122
123
124
125SunOS 5.11                        5 Jan 2004                usb_parse_data(9F)
Impressum