\hypertarget{usb__parse_8c_source}{}\doxysection{usb\+\_\+parse.\+c}
\label{usb__parse_8c_source}\index{dev/usb/usb\_parse.c@{dev/usb/usb\_parse.c}}
\mbox{\hyperlink{usb__parse_8c}{Go to the documentation of this file.}}
\begin{DoxyCode}{0}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00001}00001 \textcolor{comment}{/* \$FreeBSD\$ */}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00002}00002 \textcolor{comment}{/*-\/}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00003}00003 \textcolor{comment}{ * SPDX-\/License-\/Identifier: BSD-\/2-\/Clause-\/FreeBSD}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00004}00004 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00005}00005 \textcolor{comment}{ * Copyright (c) 2008-\/2020 Hans Petter Selasky. All rights reserved.}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00006}00006 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00007}00007 \textcolor{comment}{ * Redistribution and use in source and binary forms, with or without}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00008}00008 \textcolor{comment}{ * modification, are permitted provided that the following conditions}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00009}00009 \textcolor{comment}{ * are met:}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00010}00010 \textcolor{comment}{ * 1. Redistributions of source code must retain the above copyright}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00011}00011 \textcolor{comment}{ *    notice, this list of conditions and the following disclaimer.}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00012}00012 \textcolor{comment}{ * 2. Redistributions in binary form must reproduce the above copyright}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00013}00013 \textcolor{comment}{ *    notice, this list of conditions and the following disclaimer in the}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00014}00014 \textcolor{comment}{ *    documentation and/or other materials provided with the distribution.}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00015}00015 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00016}00016 \textcolor{comment}{ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00017}00017 \textcolor{comment}{ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00018}00018 \textcolor{comment}{ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00019}00019 \textcolor{comment}{ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00020}00020 \textcolor{comment}{ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00021}00021 \textcolor{comment}{ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00022}00022 \textcolor{comment}{ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00023}00023 \textcolor{comment}{ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00024}00024 \textcolor{comment}{ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00025}00025 \textcolor{comment}{ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00026}00026 \textcolor{comment}{ * SUCH DAMAGE.}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00027}00027 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00028}00028 }
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00029}00029 \textcolor{preprocessor}{\#ifdef USB\_GLOBAL\_INCLUDE\_FILE}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00030}00030 \textcolor{preprocessor}{\#include USB\_GLOBAL\_INCLUDE\_FILE}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00031}00031 \textcolor{preprocessor}{\#else}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00032}00032 \textcolor{preprocessor}{\#include <sys/stdint.h>}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00033}00033 \textcolor{preprocessor}{\#include <sys/stddef.h>}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00034}00034 \textcolor{preprocessor}{\#include <sys/param.h>}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00035}00035 \textcolor{preprocessor}{\#include <sys/queue.h>}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00036}00036 \textcolor{preprocessor}{\#include <sys/types.h>}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00037}00037 \textcolor{preprocessor}{\#include <sys/systm.h>}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00038}00038 \textcolor{preprocessor}{\#include <sys/kernel.h>}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00039}00039 \textcolor{preprocessor}{\#include <sys/bus.h>}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00040}00040 \textcolor{preprocessor}{\#include <sys/module.h>}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00041}00041 \textcolor{preprocessor}{\#include <sys/lock.h>}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00042}00042 \textcolor{preprocessor}{\#include <sys/mutex.h>}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00043}00043 \textcolor{preprocessor}{\#include <sys/condvar.h>}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00044}00044 \textcolor{preprocessor}{\#include <sys/sysctl.h>}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00045}00045 \textcolor{preprocessor}{\#include <sys/sx.h>}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00046}00046 \textcolor{preprocessor}{\#include <sys/unistd.h>}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00047}00047 \textcolor{preprocessor}{\#include <sys/callout.h>}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00048}00048 \textcolor{preprocessor}{\#include <sys/malloc.h>}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00049}00049 \textcolor{preprocessor}{\#include <sys/priv.h>}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00050}00050 }
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00051}00051 \textcolor{preprocessor}{\#include <\mbox{\hyperlink{usb_8h}{dev/usb/usb.h}}>}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00052}00052 \textcolor{preprocessor}{\#include <\mbox{\hyperlink{usbdi_8h}{dev/usb/usbdi.h}}>}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00053}00053 \textcolor{preprocessor}{\#include <\mbox{\hyperlink{usbdi__util_8h}{dev/usb/usbdi\_util.h}}>}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00054}00054 }
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00055}\mbox{\hyperlink{usb__parse_8c_a927dd6f59caf10a2991dfb564bcbb1e1}{00055}} \textcolor{preprocessor}{\#define USB\_DEBUG\_VAR usb\_debug}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00056}00056 }
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00057}00057 \textcolor{preprocessor}{\#include <\mbox{\hyperlink{usb__core_8h}{dev/usb/usb\_core.h}}>}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00058}00058 \textcolor{preprocessor}{\#include <\mbox{\hyperlink{usb__debug_8h}{dev/usb/usb\_debug.h}}>}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00059}00059 \textcolor{preprocessor}{\#endif                  }\textcolor{comment}{/* USB\_GLOBAL\_INCLUDE\_FILE */}\textcolor{preprocessor}{}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00060}00060 }
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00061}00061 \textcolor{comment}{/*-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/*}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00062}00062 \textcolor{comment}{ *      usb\_desc\_foreach}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00063}00063 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00064}00064 \textcolor{comment}{ * This function is the safe way to iterate across the USB config}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00065}00065 \textcolor{comment}{ * descriptor. It contains several checks against invalid}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00066}00066 \textcolor{comment}{ * descriptors. If the "{}desc"{} argument passed to this function is}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00067}00067 \textcolor{comment}{ * "{}NULL"{} the first descriptor, if any, will be returned.}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00068}00068 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00069}00069 \textcolor{comment}{ * Return values:}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00070}00070 \textcolor{comment}{ *   NULL: End of descriptors}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00071}00071 \textcolor{comment}{ *   Else: Next descriptor after "{}desc"{}}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00072}00072 \textcolor{comment}{ *-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/*/}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00073}00073 \textcolor{keyword}{struct }\mbox{\hyperlink{structusb__descriptor}{usb\_descriptor}} *}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00074}\mbox{\hyperlink{usb__parse_8c_ad481250bba6a8950a17f0ae325ff27d5}{00074}} \mbox{\hyperlink{usb__parse_8c_ad481250bba6a8950a17f0ae325ff27d5}{usb\_desc\_foreach}}(\textcolor{keyword}{struct} \mbox{\hyperlink{structusb__config__descriptor}{usb\_config\_descriptor}} *cd, }
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00075}00075     \textcolor{keyword}{struct} \mbox{\hyperlink{structusb__descriptor}{usb\_descriptor}} *\_desc)}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00076}00076 \{}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00077}00077         uint8\_t *desc\_next;}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00078}00078         uint8\_t *start;}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00079}00079         uint8\_t *end;}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00080}00080         uint8\_t *\mbox{\hyperlink{usb__device_8h_ab3a00cd7fdc532cb4cd4d59733b440bf}{desc}};}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00081}00081 }
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00082}00082         \textcolor{comment}{/* be NULL safe */}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00083}00083         \textcolor{keywordflow}{if} (cd == NULL)}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00084}00084                 \textcolor{keywordflow}{return} (NULL);}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00085}00085 }
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00086}00086         \textcolor{comment}{/* We assume that the "{}wTotalLength"{} has been checked. */}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00087}00087         start = (uint8\_t *)cd;}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00088}00088         end = start + \mbox{\hyperlink{usb__endian_8h_aa3860f9452db3a5d865cc943e2f01829}{UGETW}}(cd-\/>\mbox{\hyperlink{structusb__config__descriptor_a2d8360ac0c5b03cd0ed13158a54cad36}{wTotalLength}});}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00089}00089         \mbox{\hyperlink{usb__device_8h_ab3a00cd7fdc532cb4cd4d59733b440bf}{desc}} = (uint8\_t *)\_desc;}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00090}00090 }
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00091}00091         \textcolor{comment}{/* Get start of next USB descriptor. */}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00092}00092         \textcolor{keywordflow}{if} (\mbox{\hyperlink{usb__device_8h_ab3a00cd7fdc532cb4cd4d59733b440bf}{desc}} == NULL)}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00093}00093                 \mbox{\hyperlink{usb__device_8h_ab3a00cd7fdc532cb4cd4d59733b440bf}{desc}} = start;}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00094}00094         \textcolor{keywordflow}{else}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00095}00095                 \mbox{\hyperlink{usb__device_8h_ab3a00cd7fdc532cb4cd4d59733b440bf}{desc}} = \mbox{\hyperlink{usb__device_8h_ab3a00cd7fdc532cb4cd4d59733b440bf}{desc}} + \mbox{\hyperlink{usb__device_8h_ab3a00cd7fdc532cb4cd4d59733b440bf}{desc}}[0];}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00096}00096 }
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00097}00097         \textcolor{comment}{/* Check that the next USB descriptor is within the range. */}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00098}00098         \textcolor{keywordflow}{if} ((\mbox{\hyperlink{usb__device_8h_ab3a00cd7fdc532cb4cd4d59733b440bf}{desc}} < start) || (\mbox{\hyperlink{usb__device_8h_ab3a00cd7fdc532cb4cd4d59733b440bf}{desc}} >= end))}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00099}00099                 \textcolor{keywordflow}{return} (NULL);          \textcolor{comment}{/* out of range, or EOD */}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00100}00100 }
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00101}00101         \textcolor{comment}{/* Check that the second next USB descriptor is within range. */}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00102}00102         desc\_next = \mbox{\hyperlink{usb__device_8h_ab3a00cd7fdc532cb4cd4d59733b440bf}{desc}} + \mbox{\hyperlink{usb__device_8h_ab3a00cd7fdc532cb4cd4d59733b440bf}{desc}}[0];}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00103}00103         \textcolor{keywordflow}{if} ((desc\_next < start) || (desc\_next > end))}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00104}00104                 \textcolor{keywordflow}{return} (NULL);          \textcolor{comment}{/* out of range */}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00105}00105 }
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00106}00106         \textcolor{comment}{/* Check minimum descriptor length. */}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00107}00107         \textcolor{keywordflow}{if} (\mbox{\hyperlink{usb__device_8h_ab3a00cd7fdc532cb4cd4d59733b440bf}{desc}}[0] < 3)}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00108}00108                 \textcolor{keywordflow}{return} (NULL);          \textcolor{comment}{/* too short descriptor */}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00109}00109 }
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00110}00110         \textcolor{comment}{/* Return start of next descriptor. */}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00111}00111         \textcolor{keywordflow}{return} ((\textcolor{keyword}{struct} \mbox{\hyperlink{structusb__descriptor}{usb\_descriptor}} *)\mbox{\hyperlink{usb__device_8h_ab3a00cd7fdc532cb4cd4d59733b440bf}{desc}});}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00112}00112 \}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00113}00113 }
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00114}00114 \textcolor{comment}{/*-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/*}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00115}00115 \textcolor{comment}{ *      usb\_idesc\_foreach}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00116}00116 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00117}00117 \textcolor{comment}{ * This function will iterate the interface descriptors in the config}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00118}00118 \textcolor{comment}{ * descriptor. The parse state structure should be zeroed before}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00119}00119 \textcolor{comment}{ * calling this function the first time.}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00120}00120 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00121}00121 \textcolor{comment}{ * Return values:}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00122}00122 \textcolor{comment}{ *   NULL: End of descriptors}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00123}00123 \textcolor{comment}{ *   Else: A valid interface descriptor}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00124}00124 \textcolor{comment}{ *-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/*/}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00125}00125 \textcolor{keyword}{struct }\mbox{\hyperlink{structusb__interface__descriptor}{usb\_interface\_descriptor}} *}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00126}\mbox{\hyperlink{usb__parse_8c_ad7ace023a2e707b760d9d902ff32455f}{00126}} \mbox{\hyperlink{usb__parse_8c_ad7ace023a2e707b760d9d902ff32455f}{usb\_idesc\_foreach}}(\textcolor{keyword}{struct} \mbox{\hyperlink{structusb__config__descriptor}{usb\_config\_descriptor}} *cd,}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00127}00127     \textcolor{keyword}{struct} \mbox{\hyperlink{structusb__idesc__parse__state}{usb\_idesc\_parse\_state}} *ps)}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00128}00128 \{}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00129}00129         \textcolor{keyword}{struct }\mbox{\hyperlink{structusb__interface__descriptor}{usb\_interface\_descriptor}} *\mbox{\hyperlink{if__usievar_8h_a1e6927fa1486224044e568f9c370519b}{id}};}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00130}00130         uint8\_t new\_iface;}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00131}00131 }
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00132}00132         \textcolor{comment}{/* retrieve current descriptor */}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00133}00133         \textcolor{keywordtype}{id} = (\textcolor{keyword}{struct }\mbox{\hyperlink{structusb__interface__descriptor}{usb\_interface\_descriptor}} *)ps-\/>\mbox{\hyperlink{structusb__idesc__parse__state_a6906388a87609ed6f3a2e5e738f2532f}{desc}};}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00134}00134         \textcolor{comment}{/* default is to start a new interface */}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00135}00135         new\_iface = 1;}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00136}00136 }
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00137}00137         while (1) \{}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00138}00138                 \textcolor{keywordtype}{id} = (\textcolor{keyword}{struct }\mbox{\hyperlink{structusb__interface__descriptor}{usb\_interface\_descriptor}} *)}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00139}00139                     \mbox{\hyperlink{usb__parse_8c_ad481250bba6a8950a17f0ae325ff27d5}{usb\_desc\_foreach}}(cd, (\textcolor{keyword}{struct} \mbox{\hyperlink{structusb__descriptor}{usb\_descriptor}} *)\mbox{\hyperlink{if__usievar_8h_a1e6927fa1486224044e568f9c370519b}{id}});}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00140}00140                 \textcolor{keywordflow}{if} (\textcolor{keywordtype}{id} == NULL)}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00141}00141                         \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00142}00142                 \textcolor{keywordflow}{if} ((\mbox{\hyperlink{if__usievar_8h_a1e6927fa1486224044e568f9c370519b}{id}}-\/>bDescriptorType == \mbox{\hyperlink{usb_8h_a93c15218c1fed26b097fb0b53a3ce4f7}{UDESC\_INTERFACE}}) \&\&}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00143}00143                     (\textcolor{keywordtype}{id}-\/>bLength >= \textcolor{keyword}{sizeof}(*id))) \{}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00144}00144                         \textcolor{keywordflow}{if} (ps-\/>\mbox{\hyperlink{structusb__idesc__parse__state_a6d185270be1f6295e0ec3df2cd2ce849}{iface\_no\_last}} == \mbox{\hyperlink{if__usievar_8h_a1e6927fa1486224044e568f9c370519b}{id}}-\/>bInterfaceNumber) \{}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00145}00145                                 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00146}00146 \textcolor{comment}{                                 * Don't allow more than 256 alternate}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00147}00147 \textcolor{comment}{                                 * settings to avoid overflowing the}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00148}00148 \textcolor{comment}{                                 * alternate index which is a 8-\/bit}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00149}00149 \textcolor{comment}{                                 * variable.}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00150}00150 \textcolor{comment}{                                 */}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00151}00151                                 \textcolor{keywordflow}{if} (ps-\/>\mbox{\hyperlink{structusb__idesc__parse__state_aabf582c3cd7078a7d675063945932089}{iface\_index\_alt}} == 255) \{}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00152}00152                                         \mbox{\hyperlink{umass_8c_aa786fc43d4857c3ab9f2c777b4e6f9c5}{DPRINTF}}(\textcolor{stringliteral}{"{}Interface(\%u) has more than 256 alternate settings\(\backslash\)n"{}},}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00153}00153                                             \mbox{\hyperlink{if__usievar_8h_a1e6927fa1486224044e568f9c370519b}{id}}-\/>bInterfaceNumber);}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00154}00154                                         \textcolor{keywordflow}{continue};}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00155}00155                                 \}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00156}00156                                 new\_iface = 0;}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00157}00157                         \}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00158}00158                         ps-\/>\mbox{\hyperlink{structusb__idesc__parse__state_a6d185270be1f6295e0ec3df2cd2ce849}{iface\_no\_last}} = \textcolor{keywordtype}{id}-\/>bInterfaceNumber;}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00159}00159                         \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00160}00160                 \}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00161}00161         \}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00162}00162 }
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00163}00163         \textcolor{keywordflow}{if} (ps-\/>\mbox{\hyperlink{structusb__idesc__parse__state_a6906388a87609ed6f3a2e5e738f2532f}{desc}} == NULL) \{}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00164}00164                 \textcolor{comment}{/* first time or zero descriptors */}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00165}00165         \} \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (new\_iface) \{}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00166}00166                 \textcolor{comment}{/* new interface */}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00167}00167                 ps-\/>\mbox{\hyperlink{structusb__idesc__parse__state_a215e06a85790e167c9fad80242c97ef9}{iface\_index}} ++;}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00168}00168                 ps-\/>\mbox{\hyperlink{structusb__idesc__parse__state_aabf582c3cd7078a7d675063945932089}{iface\_index\_alt}} = 0;}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00169}00169         \} \textcolor{keywordflow}{else} \{}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00170}00170                 \textcolor{comment}{/* new alternate interface */}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00171}00171                 ps-\/>\mbox{\hyperlink{structusb__idesc__parse__state_aabf582c3cd7078a7d675063945932089}{iface\_index\_alt}} ++;}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00172}00172         \}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00173}00173 \textcolor{preprocessor}{\#if (USB\_IFACE\_MAX <= 0)}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00174}00174 \textcolor{preprocessor}{\#error "{}USB\_IFACE\_MAX must be defined greater than zero"{}}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00175}00175 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00176}00176         \textcolor{comment}{/* check for too many interfaces */}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00177}00177         \textcolor{keywordflow}{if} (ps-\/>\mbox{\hyperlink{structusb__idesc__parse__state_a215e06a85790e167c9fad80242c97ef9}{iface\_index}} >= \mbox{\hyperlink{usb__freebsd_8h_af142c9a36c3f6c71637e422d3737515a}{USB\_IFACE\_MAX}}) \{}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00178}00178                 \mbox{\hyperlink{umass_8c_aa786fc43d4857c3ab9f2c777b4e6f9c5}{DPRINTF}}(\textcolor{stringliteral}{"{}Interface limit reached\(\backslash\)n"{}});}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00179}00179                 \textcolor{keywordtype}{id} = NULL;}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00180}00180         \}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00181}00181 }
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00182}00182         \textcolor{comment}{/* store and return current descriptor */}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00183}00183         ps-\/>\mbox{\hyperlink{structusb__idesc__parse__state_a6906388a87609ed6f3a2e5e738f2532f}{desc}} = (\textcolor{keyword}{struct }\mbox{\hyperlink{structusb__descriptor}{usb\_descriptor}} *)\textcolor{keywordtype}{id};}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00184}00184         \textcolor{keywordflow}{return} (\textcolor{keywordtype}{id});}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00185}00185 \}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00186}00186 }
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00187}00187 \textcolor{comment}{/*-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/*}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00188}00188 \textcolor{comment}{ *      usb\_edesc\_foreach}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00189}00189 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00190}00190 \textcolor{comment}{ * This function will iterate all the endpoint descriptors within an}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00191}00191 \textcolor{comment}{ * interface descriptor. Starting value for the "{}ped"{} argument should}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00192}00192 \textcolor{comment}{ * be a valid interface descriptor.}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00193}00193 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00194}00194 \textcolor{comment}{ * Return values:}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00195}00195 \textcolor{comment}{ *   NULL: End of descriptors}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00196}00196 \textcolor{comment}{ *   Else: A valid endpoint descriptor}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00197}00197 \textcolor{comment}{ *-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/*/}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00198}00198 \textcolor{keyword}{struct }\mbox{\hyperlink{structusb__endpoint__descriptor}{usb\_endpoint\_descriptor}} *}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00199}\mbox{\hyperlink{usb__parse_8c_a5bd3eb5de64976eba68bbfbe668ef6c9}{00199}} \mbox{\hyperlink{usb__parse_8c_a5bd3eb5de64976eba68bbfbe668ef6c9}{usb\_edesc\_foreach}}(\textcolor{keyword}{struct} \mbox{\hyperlink{structusb__config__descriptor}{usb\_config\_descriptor}} *cd,}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00200}00200     \textcolor{keyword}{struct} \mbox{\hyperlink{structusb__endpoint__descriptor}{usb\_endpoint\_descriptor}} *ped)}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00201}00201 \{}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00202}00202         \textcolor{keyword}{struct }\mbox{\hyperlink{structusb__descriptor}{usb\_descriptor}} *\mbox{\hyperlink{usb__device_8h_ab3a00cd7fdc532cb4cd4d59733b440bf}{desc}};}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00203}00203 }
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00204}00204         \mbox{\hyperlink{usb__device_8h_ab3a00cd7fdc532cb4cd4d59733b440bf}{desc}} = ((\textcolor{keyword}{struct }\mbox{\hyperlink{structusb__descriptor}{usb\_descriptor}} *)ped);}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00205}00205 }
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00206}00206         \textcolor{keywordflow}{while} ((\mbox{\hyperlink{usb__device_8h_ab3a00cd7fdc532cb4cd4d59733b440bf}{desc}} = \mbox{\hyperlink{usb__parse_8c_ad481250bba6a8950a17f0ae325ff27d5}{usb\_desc\_foreach}}(cd, \mbox{\hyperlink{usb__device_8h_ab3a00cd7fdc532cb4cd4d59733b440bf}{desc}}))) \{}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00207}00207                 \textcolor{keywordflow}{if} (\mbox{\hyperlink{usb__device_8h_ab3a00cd7fdc532cb4cd4d59733b440bf}{desc}}-\/>\mbox{\hyperlink{structusb__endpoint__descriptor_a82be4599246c494022ea964cfddfb121}{bDescriptorType}} == \mbox{\hyperlink{usb_8h_a93c15218c1fed26b097fb0b53a3ce4f7}{UDESC\_INTERFACE}}) \{}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00208}00208                         \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00209}00209                 \}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00210}00210                 \textcolor{keywordflow}{if} (\mbox{\hyperlink{usb__device_8h_ab3a00cd7fdc532cb4cd4d59733b440bf}{desc}}-\/>\mbox{\hyperlink{structusb__endpoint__descriptor_a82be4599246c494022ea964cfddfb121}{bDescriptorType}} == \mbox{\hyperlink{usb_8h_a4b8e0317b094aec02ff237d9b4f7a202}{UDESC\_ENDPOINT}}) \{}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00211}00211                         \textcolor{keywordflow}{if} (\mbox{\hyperlink{usb__device_8h_ab3a00cd7fdc532cb4cd4d59733b440bf}{desc}}-\/>\mbox{\hyperlink{structusb__endpoint__descriptor_a7fde19381a599eefdfeda5439770267e}{bLength}} < \textcolor{keyword}{sizeof}(*ped)) \{}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00212}00212                                 \textcolor{comment}{/* endpoint descriptor is invalid */}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00213}00213                                 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00214}00214                         \}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00215}00215                         \textcolor{keywordflow}{return} ((\textcolor{keyword}{struct} \mbox{\hyperlink{structusb__endpoint__descriptor}{usb\_endpoint\_descriptor}} *)\mbox{\hyperlink{usb__device_8h_ab3a00cd7fdc532cb4cd4d59733b440bf}{desc}});}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00216}00216                 \}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00217}00217         \}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00218}00218         \textcolor{keywordflow}{return} (NULL);}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00219}00219 \}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00220}00220 }
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00221}00221 \textcolor{comment}{/*-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/*}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00222}00222 \textcolor{comment}{ *      usb\_ed\_comp\_foreach}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00223}00223 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00224}00224 \textcolor{comment}{ * This function will iterate all the endpoint companion descriptors}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00225}00225 \textcolor{comment}{ * within an endpoint descriptor in an interface descriptor. Starting}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00226}00226 \textcolor{comment}{ * value for the "{}ped"{} argument should be a valid endpoint companion}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00227}00227 \textcolor{comment}{ * descriptor.}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00228}00228 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00229}00229 \textcolor{comment}{ * Return values:}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00230}00230 \textcolor{comment}{ *   NULL: End of descriptors}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00231}00231 \textcolor{comment}{ *   Else: A valid endpoint companion descriptor}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00232}00232 \textcolor{comment}{ *-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/*/}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00233}00233 \textcolor{keyword}{struct }\mbox{\hyperlink{structusb__endpoint__ss__comp__descriptor}{usb\_endpoint\_ss\_comp\_descriptor}} *}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00234}\mbox{\hyperlink{usb__parse_8c_a3fa9b8e9865c72ee4dfbaffd6736382c}{00234}} \mbox{\hyperlink{usb__parse_8c_a3fa9b8e9865c72ee4dfbaffd6736382c}{usb\_ed\_comp\_foreach}}(\textcolor{keyword}{struct} \mbox{\hyperlink{structusb__config__descriptor}{usb\_config\_descriptor}} *cd,}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00235}00235     \textcolor{keyword}{struct} \mbox{\hyperlink{structusb__endpoint__ss__comp__descriptor}{usb\_endpoint\_ss\_comp\_descriptor}} *ped)}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00236}00236 \{}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00237}00237         \textcolor{keyword}{struct }\mbox{\hyperlink{structusb__descriptor}{usb\_descriptor}} *\mbox{\hyperlink{usb__device_8h_ab3a00cd7fdc532cb4cd4d59733b440bf}{desc}};}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00238}00238 }
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00239}00239         \mbox{\hyperlink{usb__device_8h_ab3a00cd7fdc532cb4cd4d59733b440bf}{desc}} = ((\textcolor{keyword}{struct }\mbox{\hyperlink{structusb__descriptor}{usb\_descriptor}} *)ped);}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00240}00240 }
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00241}00241         \textcolor{keywordflow}{while} ((\mbox{\hyperlink{usb__device_8h_ab3a00cd7fdc532cb4cd4d59733b440bf}{desc}} = \mbox{\hyperlink{usb__parse_8c_ad481250bba6a8950a17f0ae325ff27d5}{usb\_desc\_foreach}}(cd, \mbox{\hyperlink{usb__device_8h_ab3a00cd7fdc532cb4cd4d59733b440bf}{desc}}))) \{}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00242}00242                 \textcolor{keywordflow}{if} (\mbox{\hyperlink{usb__device_8h_ab3a00cd7fdc532cb4cd4d59733b440bf}{desc}}-\/>\mbox{\hyperlink{structusb__endpoint__descriptor_a82be4599246c494022ea964cfddfb121}{bDescriptorType}} == \mbox{\hyperlink{usb_8h_a93c15218c1fed26b097fb0b53a3ce4f7}{UDESC\_INTERFACE}})}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00243}00243                         \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00244}00244                 \textcolor{keywordflow}{if} (\mbox{\hyperlink{usb__device_8h_ab3a00cd7fdc532cb4cd4d59733b440bf}{desc}}-\/>\mbox{\hyperlink{structusb__endpoint__descriptor_a82be4599246c494022ea964cfddfb121}{bDescriptorType}} == \mbox{\hyperlink{usb_8h_a4b8e0317b094aec02ff237d9b4f7a202}{UDESC\_ENDPOINT}})}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00245}00245                         \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00246}00246                 \textcolor{keywordflow}{if} (\mbox{\hyperlink{usb__device_8h_ab3a00cd7fdc532cb4cd4d59733b440bf}{desc}}-\/>\mbox{\hyperlink{structusb__endpoint__descriptor_a82be4599246c494022ea964cfddfb121}{bDescriptorType}} == \mbox{\hyperlink{usb_8h_a58a919bb1baa8738f6d89c4ff37fdfa8}{UDESC\_ENDPOINT\_SS\_COMP}}) \{}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00247}00247                         \textcolor{keywordflow}{if} (\mbox{\hyperlink{usb__device_8h_ab3a00cd7fdc532cb4cd4d59733b440bf}{desc}}-\/>\mbox{\hyperlink{structusb__endpoint__descriptor_a7fde19381a599eefdfeda5439770267e}{bLength}} < \textcolor{keyword}{sizeof}(*ped)) \{}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00248}00248                                 \textcolor{comment}{/* endpoint companion descriptor is invalid */}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00249}00249                                 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00250}00250                         \}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00251}00251                         \textcolor{keywordflow}{return} ((\textcolor{keyword}{struct} \mbox{\hyperlink{structusb__endpoint__ss__comp__descriptor}{usb\_endpoint\_ss\_comp\_descriptor}} *)\mbox{\hyperlink{usb__device_8h_ab3a00cd7fdc532cb4cd4d59733b440bf}{desc}});}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00252}00252                 \}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00253}00253         \}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00254}00254         \textcolor{keywordflow}{return} (NULL);}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00255}00255 \}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00256}00256 }
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00257}00257 \textcolor{comment}{/*-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/*}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00258}00258 \textcolor{comment}{ *      usbd\_get\_no\_descriptors}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00259}00259 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00260}00260 \textcolor{comment}{ * This function will count the total number of descriptors in the}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00261}00261 \textcolor{comment}{ * configuration descriptor of type "{}type"{}.}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00262}00262 \textcolor{comment}{ *-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/*/}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00263}00263 uint8\_t}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00264}\mbox{\hyperlink{usb__parse_8c_a9eda9ac00cb77a482bb8dbbe3a341edd}{00264}} \mbox{\hyperlink{usb__parse_8c_a9eda9ac00cb77a482bb8dbbe3a341edd}{usbd\_get\_no\_descriptors}}(\textcolor{keyword}{struct} \mbox{\hyperlink{structusb__config__descriptor}{usb\_config\_descriptor}} *cd, uint8\_t type)}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00265}00265 \{}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00266}00266         \textcolor{keyword}{struct }\mbox{\hyperlink{structusb__descriptor}{usb\_descriptor}} *\mbox{\hyperlink{usb__device_8h_ab3a00cd7fdc532cb4cd4d59733b440bf}{desc}} = NULL;}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00267}00267         uint8\_t count = 0;}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00268}00268 }
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00269}00269         \textcolor{keywordflow}{while} ((\mbox{\hyperlink{usb__device_8h_ab3a00cd7fdc532cb4cd4d59733b440bf}{desc}} = \mbox{\hyperlink{usb__parse_8c_ad481250bba6a8950a17f0ae325ff27d5}{usb\_desc\_foreach}}(cd, \mbox{\hyperlink{usb__device_8h_ab3a00cd7fdc532cb4cd4d59733b440bf}{desc}}))) \{}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00270}00270                 \textcolor{keywordflow}{if} (\mbox{\hyperlink{usb__device_8h_ab3a00cd7fdc532cb4cd4d59733b440bf}{desc}}-\/>\mbox{\hyperlink{structusb__endpoint__descriptor_a82be4599246c494022ea964cfddfb121}{bDescriptorType}} == type) \{}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00271}00271                         count++;}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00272}00272                         \textcolor{keywordflow}{if} (count == 0xFF)}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00273}00273                                 \textcolor{keywordflow}{break};                  \textcolor{comment}{/* crazy */}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00274}00274                 \}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00275}00275         \}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00276}00276         \textcolor{keywordflow}{return} (count);}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00277}00277 \}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00278}00278 }
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00279}00279 \textcolor{comment}{/*-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/*}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00280}00280 \textcolor{comment}{ *      usbd\_get\_no\_alts}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00281}00281 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00282}00282 \textcolor{comment}{ * Return value:}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00283}00283 \textcolor{comment}{ *   Number of alternate settings for the given interface descriptor}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00284}00284 \textcolor{comment}{ *   pointer. If the USB descriptor is corrupt, the returned value can}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00285}00285 \textcolor{comment}{ *   be greater than the actual number of alternate settings.}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00286}00286 \textcolor{comment}{ *-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/*/}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00287}00287 uint8\_t}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00288}\mbox{\hyperlink{usb__parse_8c_adc2bb0ce8388580b246c3d82c986cd84}{00288}} \mbox{\hyperlink{usb__parse_8c_adc2bb0ce8388580b246c3d82c986cd84}{usbd\_get\_no\_alts}}(\textcolor{keyword}{struct} \mbox{\hyperlink{structusb__config__descriptor}{usb\_config\_descriptor}} *cd,}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00289}00289     \textcolor{keyword}{struct} \mbox{\hyperlink{structusb__interface__descriptor}{usb\_interface\_descriptor}} *\textcolor{keywordtype}{id})}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00290}00290 \{}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00291}00291         \textcolor{keyword}{struct }\mbox{\hyperlink{structusb__descriptor}{usb\_descriptor}} *\mbox{\hyperlink{usb__device_8h_ab3a00cd7fdc532cb4cd4d59733b440bf}{desc}};}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00292}00292         uint8\_t \mbox{\hyperlink{if__run_8c_a5a648f5ec00c526b0dfa2df7a272c6c0}{n}};}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00293}00293         uint8\_t ifaceno;}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00294}00294 }
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00295}00295         \textcolor{comment}{/* Reset interface count */}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00296}00296 }
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00297}00297         \mbox{\hyperlink{if__run_8c_a5a648f5ec00c526b0dfa2df7a272c6c0}{n}} = 0;}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00298}00298 }
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00299}00299         \textcolor{comment}{/* Get the interface number */}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00300}00300 }
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00301}00301         ifaceno = \textcolor{keywordtype}{id}-\/>bInterfaceNumber;}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00302}00302 }
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00303}00303         \textcolor{comment}{/* Iterate all the USB descriptors */}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00304}00304 }
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00305}00305         \mbox{\hyperlink{usb__device_8h_ab3a00cd7fdc532cb4cd4d59733b440bf}{desc}} = NULL;}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00306}00306         \textcolor{keywordflow}{while} ((\mbox{\hyperlink{usb__device_8h_ab3a00cd7fdc532cb4cd4d59733b440bf}{desc}} = \mbox{\hyperlink{usb__parse_8c_ad481250bba6a8950a17f0ae325ff27d5}{usb\_desc\_foreach}}(cd, \mbox{\hyperlink{usb__device_8h_ab3a00cd7fdc532cb4cd4d59733b440bf}{desc}}))) \{}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00307}00307                 \textcolor{keywordflow}{if} ((\mbox{\hyperlink{usb__device_8h_ab3a00cd7fdc532cb4cd4d59733b440bf}{desc}}-\/>\mbox{\hyperlink{structusb__endpoint__descriptor_a82be4599246c494022ea964cfddfb121}{bDescriptorType}} == \mbox{\hyperlink{usb_8h_a93c15218c1fed26b097fb0b53a3ce4f7}{UDESC\_INTERFACE}}) \&\&}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00308}00308                     (\mbox{\hyperlink{usb__device_8h_ab3a00cd7fdc532cb4cd4d59733b440bf}{desc}}-\/>\mbox{\hyperlink{structusb__endpoint__descriptor_a7fde19381a599eefdfeda5439770267e}{bLength}} >= \textcolor{keyword}{sizeof}(*\textcolor{keywordtype}{id}))) \{}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00309}00309                         \textcolor{keywordtype}{id} = (\textcolor{keyword}{struct }\mbox{\hyperlink{structusb__interface__descriptor}{usb\_interface\_descriptor}} *)\mbox{\hyperlink{usb__device_8h_ab3a00cd7fdc532cb4cd4d59733b440bf}{desc}};}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00310}00310                         \textcolor{keywordflow}{if} (\mbox{\hyperlink{if__usievar_8h_a1e6927fa1486224044e568f9c370519b}{id}}-\/>bInterfaceNumber == ifaceno) \{}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00311}00311                                 \mbox{\hyperlink{if__run_8c_a5a648f5ec00c526b0dfa2df7a272c6c0}{n}}++;}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00312}00312                                 \textcolor{keywordflow}{if} (\mbox{\hyperlink{if__run_8c_a5a648f5ec00c526b0dfa2df7a272c6c0}{n}} == 0xFF)}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00313}00313                                         \textcolor{keywordflow}{break};          \textcolor{comment}{/* crazy */}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00314}00314                         \}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00315}00315                 \}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00316}00316         \}}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00317}00317         \textcolor{keywordflow}{return} (\mbox{\hyperlink{if__run_8c_a5a648f5ec00c526b0dfa2df7a272c6c0}{n}});}
\DoxyCodeLine{\Hypertarget{usb__parse_8c_source_l00318}00318 \}}

\end{DoxyCode}
