#include <string.h>
-#define DESC_HEADER_LENGTH 2
-#define DEVICE_DESC_LENGTH 18
-#define CONFIG_DESC_LENGTH 9
-#define INTERFACE_DESC_LENGTH 9
-#define ENDPOINT_DESC_LENGTH 7
-#define ENDPOINT_AUDIO_DESC_LENGTH 9
+#define DESC_HEADER_LENGTH 2
/** @defgroup libusb_desc USB descriptors
* This page details how to examine the various standard USB descriptors
size, header->bLength);
return parsed;
}
- if (header->bLength >= ENDPOINT_AUDIO_DESC_LENGTH)
+ if (header->bLength >= LIBUSB_DT_ENDPOINT_AUDIO_SIZE)
parse_descriptor(buffer, "bbbbwbbb", endpoint, host_endian);
- else if (header->bLength >= ENDPOINT_DESC_LENGTH)
+ else if (header->bLength >= LIBUSB_DT_ENDPOINT_SIZE)
parse_descriptor(buffer, "bbbbwb", endpoint, host_endian);
else {
usbi_err(ctx, "invalid endpoint bLength (%d)", header->bLength);
usb_interface->num_altsetting = 0;
- while (size >= INTERFACE_DESC_LENGTH) {
+ while (size >= LIBUSB_DT_INTERFACE_SIZE) {
struct libusb_interface_descriptor *altsetting =
(struct libusb_interface_descriptor *) usb_interface->altsetting;
altsetting = usbi_reallocf(altsetting,
ifp->bDescriptorType, LIBUSB_DT_INTERFACE);
return parsed;
}
- if (ifp->bLength < INTERFACE_DESC_LENGTH) {
+ if (ifp->bLength < LIBUSB_DT_INTERFACE_SIZE) {
usbi_err(ctx, "invalid interface bLength (%d)",
ifp->bLength);
r = LIBUSB_ERROR_IO;
extern "C" {
#endif
-#define DEVICE_DESC_LENGTH 18
-
#define USB_MAXENDPOINTS 32
#define USB_MAXINTERFACES 32
#define USB_MAXCONFIG 8
* to retrieve it from a kernel interface (some Linux setups can do this)
* still without generating bus I/O.
*
- * This function is expected to write DEVICE_DESC_LENGTH (18) bytes into
+ * This function is expected to write LIBUSB_DT_DEVICE_SIZE (18) bytes into
* buffer, which is guaranteed to be big enough.
*
* This function is called when sanity-checking a device before adding
struct darwin_cached_device *priv = DARWIN_CACHED_DEVICE(dev);
/* return cached copy */
- memmove (buffer, &(priv->dev_descriptor), DEVICE_DESC_LENGTH);
+ memmove (buffer, &(priv->dev_descriptor), LIBUSB_DT_DEVICE_SIZE);
*host_endian = 0;
haiku_get_device_descriptor(struct libusb_device *device, unsigned char *buffer, int *host_endian)
{
USBDevice *dev = *((USBDevice **)usbi_get_device_priv(device));
- memcpy(buffer, dev->Descriptor(), DEVICE_DESC_LENGTH);
+ memcpy(buffer, dev->Descriptor(), LIBUSB_DT_DEVICE_SIZE);
*host_endian = 0;
return LIBUSB_SUCCESS;
}
struct linux_device_priv *priv = usbi_get_device_priv(dev);
*host_endian = priv->sysfs_dir != NULL;
- memcpy(buffer, priv->descriptors, DEVICE_DESC_LENGTH);
+ memcpy(buffer, priv->descriptors, LIBUSB_DT_DEVICE_SIZE);
return 0;
}
*host_endian = 0;
/* Skip device header */
- descriptors += DEVICE_DESC_LENGTH;
- size -= DEVICE_DESC_LENGTH;
+ descriptors += LIBUSB_DT_DEVICE_SIZE;
+ size -= LIBUSB_DT_DEVICE_SIZE;
/* Seek till the config is found, or till "EOF" */
while (1) {
*host_endian = 0;
/* Skip device header */
- descriptors += DEVICE_DESC_LENGTH;
- size -= DEVICE_DESC_LENGTH;
+ descriptors += LIBUSB_DT_DEVICE_SIZE;
+ size -= LIBUSB_DT_DEVICE_SIZE;
/* Seek till the config is found, or till "EOF" */
for (i = 0; ; i++) {
if (fd != wrapped_fd)
close(fd);
- if (priv->descriptors_len < DEVICE_DESC_LENGTH) {
+ if (priv->descriptors_len < LIBUSB_DT_DEVICE_SIZE) {
usbi_err(ctx, "short descriptor read (%d)", priv->descriptors_len);
return LIBUSB_ERROR_IO;
}
* config. just assume the first one is active. */
usbi_warn(ctx, "Missing rw usbfs access; cannot determine "
"active configuration descriptor");
- if (priv->descriptors_len >= (DEVICE_DESC_LENGTH + LIBUSB_DT_CONFIG_SIZE)) {
+ if (priv->descriptors_len >= (LIBUSB_DT_DEVICE_SIZE + LIBUSB_DT_CONFIG_SIZE)) {
struct usbi_configuration_descriptor *config;
- config = (struct usbi_configuration_descriptor *)(priv->descriptors + DEVICE_DESC_LENGTH);
+ config = (struct usbi_configuration_descriptor *)(priv->descriptors + LIBUSB_DT_DEVICE_SIZE);
priv->active_config = config->bConfigurationValue;
} else {
priv->active_config = -1; /* No config dt */
usbi_dbg(" ");
- memcpy(buf, &dpriv->ddesc, DEVICE_DESC_LENGTH);
+ memcpy(buf, &dpriv->ddesc, LIBUSB_DT_DEVICE_SIZE);
*host_endian = 0;
usbi_dbg(" ");
- memcpy(buf, &dpriv->ddesc, DEVICE_DESC_LENGTH);
+ memcpy(buf, &dpriv->ddesc, LIBUSB_DT_DEVICE_SIZE);
*host_endian = 0;
{
struct usbdk_device_priv *priv = usbi_get_device_priv(dev);
- memcpy(buffer, &priv->info.DeviceDescriptor, DEVICE_DESC_LENGTH);
+ memcpy(buffer, &priv->info.DeviceDescriptor, LIBUSB_DT_DEVICE_SIZE);
return LIBUSB_SUCCESS;
}
{
struct winusb_device_priv *priv = usbi_get_device_priv(dev);
- memcpy(buffer, &priv->dev_descriptor, DEVICE_DESC_LENGTH);
+ memcpy(buffer, &priv->dev_descriptor, LIBUSB_DT_DEVICE_SIZE);
return LIBUSB_SUCCESS;
}
-#define LIBUSB_NANO 11504
+#define LIBUSB_NANO 11505