core: Fix definition and use of enum libusb_transfer_type

Since the beginning of the libusb-1.0, the libusb_transfer_type enum had
a 1:1 mapping to the endpoint transfer type (bits 1:0 of the endpoint
descriptor's bmAttributes). This was broken with the addition of bulk
stream support because the value of LIBUSB_TRANSFER_TYPE_BULK_STREAM
does not map to a valid value for an endpoint's transfer type.

Fix this by splitting the endpoint's transfer type for its descriptor
and the library's transfer type for its logical transfers into different
enumerations. None of the values are altered, so applications testing
an endpoint descriptor's bmAttributes field against the
libusb_transfer_type enum values will still work.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
diff --git a/libusb/core.c b/libusb/core.c
index 2097fea..446ed83 100644
--- a/libusb/core.c
+++ b/libusb/core.c
@@ -460,6 +460,7 @@
   * - \ref libusb_class_code
   * - \ref libusb_descriptor_type
   * - \ref libusb_endpoint_direction
+  * - \ref libusb_endpoint_transfer_type
   * - \ref libusb_error
   * - \ref libusb_iso_sync_type
   * - \ref libusb_iso_usage_type
@@ -1094,7 +1095,7 @@
 	struct libusb_config_descriptor *config;
 	const struct libusb_endpoint_descriptor *ep;
 	struct libusb_ss_endpoint_companion_descriptor *ss_ep_cmp;
-	enum libusb_transfer_type ep_type;
+	enum libusb_endpoint_transfer_type ep_type;
 	uint16_t val;
 	int r;
 	int speed;
@@ -1124,11 +1125,11 @@
 	/* If the device isn't a SuperSpeed device or retrieving the SS endpoint didn't worked. */
 	if (speed < LIBUSB_SPEED_SUPER || r < 0) {
 		val = ep->wMaxPacketSize;
-		ep_type = (enum libusb_transfer_type) (ep->bmAttributes & 0x3);
+		ep_type = (enum libusb_endpoint_transfer_type) (ep->bmAttributes & 0x3);
 
 		r = val & 0x07ff;
-		if (ep_type == LIBUSB_TRANSFER_TYPE_ISOCHRONOUS
-		    || ep_type == LIBUSB_TRANSFER_TYPE_INTERRUPT)
+		if (ep_type == LIBUSB_ENDPOINT_TRANSFER_TYPE_ISOCHRONOUS
+		    || ep_type == LIBUSB_ENDPOINT_TRANSFER_TYPE_INTERRUPT)
 			r *= (1 + ((val >> 11) & 3));
 	}
 
diff --git a/libusb/libusb.h b/libusb/libusb.h
index 4cd9149..072b62e 100644
--- a/libusb/libusb.h
+++ b/libusb/libusb.h
@@ -319,21 +319,18 @@
  * Endpoint transfer type. Values for bits 0:1 of the
  * \ref libusb_endpoint_descriptor::bmAttributes "endpoint attributes" field.
  */
-enum libusb_transfer_type {
+enum libusb_endpoint_transfer_type {
 	/** Control endpoint */
-	LIBUSB_TRANSFER_TYPE_CONTROL = 0,
+	LIBUSB_ENDPOINT_TRANSFER_TYPE_CONTROL = 0,
 
 	/** Isochronous endpoint */
-	LIBUSB_TRANSFER_TYPE_ISOCHRONOUS = 1,
+	LIBUSB_ENDPOINT_TRANSFER_TYPE_ISOCHRONOUS = 1,
 
 	/** Bulk endpoint */
-	LIBUSB_TRANSFER_TYPE_BULK = 2,
+	LIBUSB_ENDPOINT_TRANSFER_TYPE_BULK = 2,
 
 	/** Interrupt endpoint */
-	LIBUSB_TRANSFER_TYPE_INTERRUPT = 3,
-
-	/** Stream endpoint */
-	LIBUSB_TRANSFER_TYPE_BULK_STREAM = 4,
+	LIBUSB_ENDPOINT_TRANSFER_TYPE_INTERRUPT = 3,
 };
 
 /** \ingroup libusb_misc
@@ -529,17 +526,15 @@
 
 	/** The address of the endpoint described by this descriptor. Bits 0:3 are
 	 * the endpoint number. Bits 4:6 are reserved. Bit 7 indicates direction,
-	 * see \ref libusb_endpoint_direction.
-	 */
+	 * see \ref libusb_endpoint_direction. */
 	uint8_t  bEndpointAddress;
 
 	/** Attributes which apply to the endpoint when it is configured using
 	 * the bConfigurationValue. Bits 0:1 determine the transfer type and
-	 * correspond to \ref libusb_transfer_type. Bits 2:3 are only used for
-	 * isochronous endpoints and correspond to \ref libusb_iso_sync_type.
+	 * correspond to \ref libusb_endpoint_transfer_type. Bits 2:3 are only used
+	 * for isochronous endpoints and correspond to \ref libusb_iso_sync_type.
 	 * Bits 4:5 are also only used for isochronous endpoints and correspond to
-	 * \ref libusb_iso_usage_type. Bits 6:7 are reserved.
-	 */
+	 * \ref libusb_iso_usage_type. Bits 6:7 are reserved. */
 	uint8_t  bmAttributes;
 
 	/** Maximum packet size this endpoint is capable of sending/receiving. */
@@ -1084,6 +1079,25 @@
 #define LIBUSB_ERROR_COUNT 14
 
 /** \ingroup libusb_asyncio
+ * Transfer type */
+enum libusb_transfer_type {
+	/** Control transfer */
+	LIBUSB_TRANSFER_TYPE_CONTROL = 0U,
+
+	/** Isochronous transfer */
+	LIBUSB_TRANSFER_TYPE_ISOCHRONOUS = 1U,
+
+	/** Bulk transfer */
+	LIBUSB_TRANSFER_TYPE_BULK = 2U,
+
+	/** Interrupt transfer */
+	LIBUSB_TRANSFER_TYPE_INTERRUPT = 3U,
+
+	/** Bulk stream transfer */
+	LIBUSB_TRANSFER_TYPE_BULK_STREAM = 4U
+};
+
+/** \ingroup libusb_asyncio
  * Transfer status codes */
 enum libusb_transfer_status {
 	/** Transfer completed without error. Note that this does not indicate
@@ -1199,7 +1213,7 @@
 	/** Address of the endpoint where this transfer will be sent. */
 	unsigned char endpoint;
 
-	/** Type of the endpoint from \ref libusb_transfer_type */
+	/** Type of the transfer from \ref libusb_transfer_type */
 	unsigned char type;
 
 	/** Timeout for this transfer in milliseconds. A value of 0 indicates no
diff --git a/libusb/version_nano.h b/libusb/version_nano.h
index d7d9bc1..f63b1ed 100644
--- a/libusb/version_nano.h
+++ b/libusb/version_nano.h
@@ -1 +1 @@
-#define LIBUSB_NANO 11491
+#define LIBUSB_NANO 11492