Print this page
5832 EOF wireless usb (aka UWB)
Reviewed by: TBD
Reviewed by: TBD
Approved by: TBD


   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.


  24  */
  25 
  26 
  27 /*
  28  * Descriptor parsing functions
  29  */
  30 #define USBA_FRAMEWORK
  31 #include <sys/usb/usba/usba_impl.h>
  32 #include <sys/strsun.h>
  33 
  34 #define INCREMENT_BUF(buf) \
  35                 if ((buf)[0] == 0) { \
  36                         break; \
  37                 } else { \
  38                         (buf) += (buf)[0]; \
  39                 }
  40 #define isdigit(ch) ((ch >= '0') && (ch <= '9'))
  41 
  42 extern usba_cfg_pwr_descr_t default_cfg_power;
  43 extern usba_if_pwr_descr_t default_if_power;


 603                             descr_type, descr_index,
 604                             USB_DESCR_TYPE_EP,
 605                             USB_DESCR_TYPE_IF)) == NULL) {
 606 
 607                                 break;
 608                         }
 609 
 610                         return (usb_parse_data(fmt, buf,
 611                             _PTRDIFF(bufend, buf),
 612                             ret_descr, ret_buf_len));
 613                 }
 614 
 615                 /*
 616                  * Check for a bad buffer.
 617                  * If buf[0] is 0, then this will be an infite loop
 618                  */
 619                 INCREMENT_BUF(buf);
 620         }
 621 
 622         return (USB_PARSE_ERROR);
 623 }
 624 
 625 size_t
 626 usb_parse_bos_descr(uchar_t     *buf,   /* from GET_DESCRIPTOR(BOS) */
 627         size_t                  buflen,
 628         usb_bos_descr_t         *ret_descr,
 629         size_t                  ret_buf_len)
 630 {
 631         if ((buf == NULL) || (ret_descr == NULL) ||
 632             (buflen < 2) || (buf[1] != USB_DESCR_TYPE_BOS)) {
 633 
 634                 return (USB_PARSE_ERROR);
 635         }
 636 
 637         return (usb_parse_data("ccsc",
 638             buf, buflen, ret_descr, ret_buf_len));
 639 }
 640 
 641 size_t
 642 usb_parse_uwb_bos_descr(uchar_t *buf,   /* from GET_DESCRIPTOR(BOS) */
 643         size_t                  buflen,
 644         usb_uwb_cap_descr_t     *ret_descr,
 645         size_t                  ret_buf_len)
 646 {
 647         uchar_t *bufend = buf + buflen;
 648 
 649         if ((buf == NULL) || (ret_descr == NULL)) {
 650 
 651                 return (USB_PARSE_ERROR);
 652         }
 653 
 654         while (buf + 3 <= bufend) {
 655                 if ((buf[1] == USB_DESCR_TYPE_DEV_CAPABILITY) &&
 656                     (buf[2] == USB_CAP_TYPE_WUSB)) {
 657 
 658                         return (usb_parse_data("ccccsccsc",
 659                             buf, _PTRDIFF(bufend, buf), ret_descr,
 660                             ret_buf_len));
 661                 }
 662 
 663                 INCREMENT_BUF(buf);
 664         }
 665 
 666         return (USB_PARSE_ERROR);
 667 }
 668 
 669 size_t
 670 usb_parse_comp_ep_descr(uchar_t *buf,   /* from GET_DESCRIPTOR(CONFIGURATION) */
 671         size_t                  buflen,
 672         uint_t                  if_number,
 673         uint_t                  alt_if_setting,
 674         uint_t                  ep_index,
 675         usb_ep_comp_descr_t     *ret_descr,
 676         size_t                  ret_buf_len)
 677 {
 678         return (usb_parse_CV_ep_descr(buf, buflen, "ccccsscc",
 679             if_number, alt_if_setting, ep_index,
 680             USB_DESCR_TYPE_WIRELESS_EP_COMP, 0,
 681             ret_descr, ret_buf_len));
 682 }


   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  *
  25  * Copyright 2014 Garrett D'Amore <garrett@damore.org>
  26  */
  27 
  28 
  29 /*
  30  * Descriptor parsing functions
  31  */
  32 #define USBA_FRAMEWORK
  33 #include <sys/usb/usba/usba_impl.h>
  34 #include <sys/strsun.h>
  35 
  36 #define INCREMENT_BUF(buf) \
  37                 if ((buf)[0] == 0) { \
  38                         break; \
  39                 } else { \
  40                         (buf) += (buf)[0]; \
  41                 }
  42 #define isdigit(ch) ((ch >= '0') && (ch <= '9'))
  43 
  44 extern usba_cfg_pwr_descr_t default_cfg_power;
  45 extern usba_if_pwr_descr_t default_if_power;


 605                             descr_type, descr_index,
 606                             USB_DESCR_TYPE_EP,
 607                             USB_DESCR_TYPE_IF)) == NULL) {
 608 
 609                                 break;
 610                         }
 611 
 612                         return (usb_parse_data(fmt, buf,
 613                             _PTRDIFF(bufend, buf),
 614                             ret_descr, ret_buf_len));
 615                 }
 616 
 617                 /*
 618                  * Check for a bad buffer.
 619                  * If buf[0] is 0, then this will be an infite loop
 620                  */
 621                 INCREMENT_BUF(buf);
 622         }
 623 
 624         return (USB_PARSE_ERROR);



























































 625 }