usb_parse_data man page on SmartOS

Man page or keyword search:  
man Server   16655 pages
apropos Keyword Search (all sections)
Output format
SmartOS logo
[printable version]

USB_PARSE_DATA(9F)					    USB_PARSE_DATA(9F)

NAME
       usb_parse_data  -  Tokenize  and align the bytes of raw variable-format
       data

SYNOPSIS
       #include <sys/usb/usba.h>

       size_t usb_parse_data(char *format, uchar_t *data,
	    size_t datalen, void *structure, size_t structlen);

INTERFACE LEVEL
       Solaris DDI specific (Solaris DDI)

PARAMETERS
       format
		    Null terminated string describing the format of  the  data
		    structure  for  general-purpose byte swapping. The letters
		    "c," "s," "l," and "L" represent 1, 2, 4 and 8 byte	 quan‐
		    tities,  respectively.  A  descriptor  that	 consists of a
		    short and two bytes would be described by "scc." A	number
		    preceding  a letter serves as a multiplier of that letter.
		    A format equivalent to "scc" is "s2c."

       data
		    Raw descriptor data to parse.

       datalen
		    Length, in bytes, of the raw descriptor data buffer.

       structure
		    Destination data buffer where parsed data is returned.

       structlen
		    Length, in bytes, of the destination data  buffer.	Parsed
		    result length will not exceed this value.

DESCRIPTION
       The  usb_parse_data  function  parses  data  such  as a variable-format
       class- or vendor-specific descriptor. The function also	tokenizes  and
       aligns  the bytes of raw descriptor data into fields of a variable-for‐
       mat descriptor.

       While the USBA framework can parse the endpoint, interface,  configura‐
       tion,  and string descriptors defined by the USB 2.0 specification, the
       format of class- or vendor-specific descriptors	cannot	be  explicitly
       defined	by  the	 specification and will be unique for each. The format
       argument defines how to parse such a descriptor.

       While the USB specification defines bit ordering as little-endian, this
       routine	(like  the entire API), converts the data to the endianness of
       the host.

       The structlen parameter defines the size of the destination  data  buf‐
       fer.   Data is truncated to this size if the destination data buffer is
       too small.

RETURN VALUES
       On success: Returns the size (in bytes) of the parsed data result.

       On failure: Returns 0. (Same as USB_PARSE_ERROR).

CONTEXT
       May be called from user, kernel or interrupt context.

EXAMPLES
	   /*
	    * Parse raw descriptor data in buf, putting result into ret_descr.
	    * ret_buf_len holds the size of ret_descr buf;  routine returns
	    * number of resulting bytes.
	    *
	    * Descriptor being parsed has 2 chars, followed by one short,
	    * 3 chars and one more short.
	    */
	   size_t size_of_returned_descr;
	   xxx_descr_t ret_descr;

	    size_of_returned_descr = usb_parse_data("ccscccs",
	       buf, sizeof(buf), (void *)ret_descr, (sizeof)xxx_descr_t));
	   if (size_of_returned_descr < (sizeof (xxx_descr_t))) {
		    /* Data truncated. */
	   }

	   or:

	   size_of_returned_descr = usb_parse_data("2cs3cs",
	       buf, sizeof(buf), (void *)ret_descr, (sizeof)xxx_descr_t));
	   if (size_of_returned_descr < (sizeof (xxx_descr_t))) {
		   /* Data truncated. */
	   }

ATTRIBUTES
       See attributes(5) for descriptions of the following attributes:

       ┌────────────────────┬───────────────────┐
       │  ATTRIBUTE TYPE    │  ATTRIBUTE VALUE	│
       ├────────────────────┼───────────────────┤
       │Architecture	    │ PCI-based systems │
       ├────────────────────┼───────────────────┤
       │Interface stability │ Committed		│
       └────────────────────┴───────────────────┘

SEE ALSO
       attributes(5),	  usb_get_dev_data(9F),	     usb_get_string_descr(9F),
       usb_get_cfg(9F)

				  Jan 5, 2004		    USB_PARSE_DATA(9F)
[top]

List of man pages available for SmartOS

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net