Legacy configuration for NCM/RNDIS does not work for Win >= 10

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The old RNDIS/NCM configs does not work against modern Windows. I wonder if there
should/could be updated to working state ?

I tried to mimic configs like so:
-------------------- drivers/usb/gadget/function/f_ncm.c ---------------------
index dc8f078f918c..f75f4bfdc971 100644
@@ -17,6 +17,7 @@
 #include <linux/device.h>
 #include <linux/etherdevice.h>
 #include <linux/crc32.h>
+#include <linux/nls.h>
 
 #include <linux/usb/cdc.h>
 
@@ -148,9 +149,9 @@ static struct usb_interface_assoc_descriptor ncm_iad_desc = {
 
 	/* .bFirstInterface =	DYNAMIC, */
 	.bInterfaceCount =	2,	/* control + data */
-	.bFunctionClass =	USB_CLASS_COMM,
-	.bFunctionSubClass =	USB_CDC_SUBCLASS_NCM,
-	.bFunctionProtocol =	USB_CDC_PROTO_NONE,
+	.bFunctionClass =	0xef, //USB_CLASS_COMM,
+	.bFunctionSubClass =	0x02, //USB_CDC_SUBCLASS_NCM,
+	.bFunctionProtocol =	0x01, //USB_CDC_PROTO_NONE,
 	/* .iFunction =		DYNAMIC */
 };
 
@@ -162,9 +163,9 @@ static struct usb_interface_descriptor ncm_control_intf = {
 
 	/* .bInterfaceNumber = DYNAMIC */
 	.bNumEndpoints =	1,
-	.bInterfaceClass =	USB_CLASS_COMM,
-	.bInterfaceSubClass =	USB_CDC_SUBCLASS_NCM,
-	.bInterfaceProtocol =	USB_CDC_PROTO_NONE,
+	.bInterfaceClass =	0xef, //USB_CLASS_COMM,
+	.bInterfaceSubClass =	0x02, //USB_CDC_SUBCLASS_NCM,
+	.bInterfaceProtocol =	0x01, //USB_CDC_PROTO_NONE,
 	/* .iInterface = DYNAMIC */
 };
 
@@ -1423,7 +1424,10 @@ static int ncm_bind(struct usb_configuration *c, struct usb_function *f)
 		return -EINVAL;
 
 	ncm_opts = container_of(f->fi, struct f_ncm_opts, func_inst);
-
+	cdev->use_os_string = true;
+	cdev->b_vendor_code = 0xbc; /* Microsoft */
+	utf8s_to_utf16s("MSFT100", 7, UTF16_LITTLE_ENDIAN,
+			(wchar_t *)cdev->qw_sign, OS_STRING_QW_SIGN_LEN); /* Microsft */
 	if (cdev->use_os_string) {
 		f->os_desc_table = kzalloc(sizeof(*f->os_desc_table),
 					   GFP_KERNEL);
@@ -1625,6 +1629,8 @@ static struct usb_function_instance *ncm_alloc_inst(void)
 	opts = kzalloc(sizeof(*opts), GFP_KERNEL);
 	if (!opts)
 		return ERR_PTR(-ENOMEM);
+	strcpy(opts->ncm_ext_compat_id, "WINNCM"); /* compatible_id */
+
 	opts->ncm_os_desc.ext_compat_id = opts->ncm_ext_compat_id;
 
 	mutex_init(&opts->lock);


and:
------------------- drivers/usb/gadget/function/f_rndis.c --------------------
index ee95e8f5f9d4..e7c0a60c1107 100644
@@ -17,6 +17,7 @@
 #include <linux/device.h>
 #include <linux/etherdevice.h>
 
+#include <linux/nls.h>
 #include <linux/atomic.h>
 
 #include "u_ether.h"
@@ -176,9 +177,9 @@ rndis_iad_descriptor = {
 
 	.bFirstInterface =	0, /* XXX, hardcoded */
 	.bInterfaceCount = 	2,	// control + data
-	.bFunctionClass =	USB_CLASS_COMM,
-	.bFunctionSubClass =	USB_CDC_SUBCLASS_ETHERNET,
-	.bFunctionProtocol =	USB_CDC_PROTO_NONE,
+	.bFunctionClass =	0xef, //USB_CLASS_COMM,
+	.bFunctionSubClass =	0x02, //USB_CDC_SUBCLASS_ETHERNET,
+	.bFunctionProtocol =	0x01, //USB_CDC_PROTO_NONE,
 	/* .iFunction = DYNAMIC */
 };
 
@@ -681,6 +682,7 @@ rndis_bind(struct usb_configuration *c, struct usb_function *f)
 
 	rndis_opts = container_of(f->fi, struct f_rndis_opts, func_inst);
 
+	cdev->use_os_string = true;
 	if (cdev->use_os_string) {
 		f->os_desc_table = kzalloc(sizeof(*f->os_desc_table),
 					   GFP_KERNEL);
@@ -688,6 +690,10 @@ rndis_bind(struct usb_configuration *c, struct usb_function *f)
 			return -ENOMEM;
 		f->os_desc_n = 1;
 		f->os_desc_table[0].os_desc = &rndis_opts->rndis_os_desc;
+		//cdev->b_vendor_code = 0xcd; /* Microsoft */
+		cdev->b_vendor_code = 0xbc; /* Microsoft */
+		utf8s_to_utf16s("MSFT100", 7, UTF16_LITTLE_ENDIAN,
+				(wchar_t *)cdev->qw_sign, OS_STRING_QW_SIGN_LEN); /* Microsoft */
 	}
 
 	rndis_iad_descriptor.bFunctionClass = rndis_opts->class;
@@ -921,6 +927,8 @@ static struct usb_function_instance *rndis_alloc_inst(void)
 	opts = kzalloc(sizeof(*opts), GFP_KERNEL);
 	if (!opts)
 		return ERR_PTR(-ENOMEM);
+	strcpy(opts->rndis_ext_compat_id, "RNDIS"); /* RNDIS 6.0, compatible_id */
+	strcpy(opts->rndis_ext_compat_id + 8, "5162001"); /* RNDIS 6.0, sub_compatible_id */
 	opts->rndis_os_desc.ext_compat_id = opts->rndis_ext_compat_id;
 
 	mutex_init(&opts->lock);


But this didn't work

 Jocke





[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux