int API_EXPORTED libusb_get_config_descriptor_by_value(libusb_device *dev,
uint8_t bConfigurationValue, struct libusb_config_descriptor **config)
{
- int idx;
- int r = usbi_get_config_index_by_value(dev, bConfigurationValue, &idx);
+ int r, idx, host_endian;
+ unsigned char *buf = NULL;
+
+ if (usbi_backend->get_config_descriptor_by_value) {
+ r = usbi_backend->get_config_descriptor_by_value(dev,
+ bConfigurationValue, &buf, &host_endian);
+ if (r < 0)
+ return r;
+ return raw_desc_to_config(dev->ctx, buf, r, host_endian, config);
+ }
+
+ r = usbi_get_config_index_by_value(dev, bConfigurationValue, &idx);
if (r < 0)
return r;
else if (idx == -1)
uint8_t config_index, unsigned char *buffer, size_t len,
int *host_endian);
+ /* Like get_config_descriptor but then by bConfigurationValue instead
+ * of by index.
+ *
+ * Optional, if not present the core will call get_config_descriptor
+ * for all configs until it finds the desired bConfigurationValue.
+ *
+ * Returns a pointer to the raw-descriptor in *buffer, this memory
+ * is valid as long as device is valid.
+ *
+ * Returns the length of the returned raw-descriptor on success,
+ * or a LIBUSB_ERROR code on failure.
+ */
+ int (*get_config_descriptor_by_value)(struct libusb_device *device,
+ uint8_t bConfigurationValue, unsigned char **buffer,
+ int *host_endian);
+
/* Get the bConfigurationValue for the active configuration for a device.
* Optional. This should only be implemented if you can retrieve it from
* cache (don't generate I/O).
}
}
-static int get_config_descriptor_by_value(struct libusb_device *dev,
- unsigned char **buffer, uint8_t value)
+static int op_get_config_descriptor_by_value(struct libusb_device *dev,
+ uint8_t value, unsigned char **buffer, int *host_endian)
{
struct libusb_context *ctx = DEVICE_CTX(dev);
struct linux_device_priv *priv = _device_priv(dev);
struct libusb_config_descriptor *config;
*buffer = NULL;
+ /* Unlike the device desc. config descs. are always in raw format */
+ *host_endian = 0;
/* Skip device header */
descriptors += DEVICE_DESC_LENGTH;
int r, config;
unsigned char *config_desc;
- /* Unlike the device desc. config descs. are always in raw format */
- *host_endian = 0;
-
if (sysfs_can_relate_devices) {
r = sysfs_get_active_config(dev, &config);
if (r < 0)
if (config == -1)
return LIBUSB_ERROR_NOT_FOUND;
- r = get_config_descriptor_by_value(dev, &config_desc, config);
+ r = op_get_config_descriptor_by_value(dev, config, &config_desc,
+ host_endian);
if (r < 0)
return r;
.get_device_descriptor = op_get_device_descriptor,
.get_active_config_descriptor = op_get_active_config_descriptor,
.get_config_descriptor = op_get_config_descriptor,
+ .get_config_descriptor_by_value = op_get_config_descriptor_by_value,
.open = op_open,
.close = op_close,
obsd_get_device_descriptor,
obsd_get_active_config_descriptor,
obsd_get_config_descriptor,
+ NULL, /* get_config_descriptor_by_value() */
obsd_get_configuration,
obsd_set_configuration,
wince_get_device_descriptor,
wince_get_active_config_descriptor,
wince_get_config_descriptor,
+ NULL, /* get_config_descriptor_by_value() */
wince_get_configuration,
wince_set_configuration,
windows_get_device_descriptor,
windows_get_active_config_descriptor,
windows_get_config_descriptor,
+ NULL, /* get_config_descriptor_by_value() */
windows_get_configuration,
windows_set_configuration,
-#define LIBUSB_NANO 10713
+#define LIBUSB_NANO 10714