tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Support more devices in if_urndis
Greetings.
I hope this is the correct mailing list.
I have a mobile phone that i use for internet using usb tethering.
When i connect it to NetBSD, ugen gets bind instead of urndis.
I read if_urndis.c and it has the following code
if (id->bInterfaceClass == UICLASS_WIRELESS &&
id->bInterfaceSubClass == UISUBCLASS_RF &&
id->bInterfaceProtocol == UIPROTO_RNDIS)
return UMATCH_IFACECLASS_IFACESUBCLASS_IFACEPROTO;
so it binds for wireless devices with rndis protocol and also has
code for specific usb ids for devices that do not conform with this.
I ran lsusb on linux where my phone works and i get the following:
Interface Association:
bFunctionClass 239 Miscellaneous Device
bFunctionSubClass 4 [unknown]
bFunctionProtocol 1
iFunction 7 RNDIS
Interface Descriptor:
bInterfaceClass 239 Miscellaneous Device
bInterfaceSubClass 4 [unknown]
bInterfaceProtocol 1
iInterface 5 RNDIS Communications Control
So lsusb does not know the specifics but i visited
https://www.usb.org/defined-class-codes and the class specifiers are
defined (I use usb tethering but i guess internally protocol 0x01
is defined ad RNDIS over Ethernet).
I modified the code as shown in the attached patch file to account
for this class and protocol. I do not have any other device to test
if my code messed up something but my phone now gets matched correctly
and works fine.
--- dmesg.before 2025-01-31 11:08:38.382020284 +0200
+++ dmesg.after 2025-01-31 11:08:37.074040964 +0200
@@ -168,8 +168,9 @@
cd1 at atapibus1 drive 0: <QEMU DVD-ROM, QM00005, 2.5+> cdrom
removable
cd1: drive supports PIO mode 4, DMA mode 2, Ultra-DMA mode 5
(Ultra/100), NCQ (32 tags)
cd1(ahcisata0:2:0): using PIO mode 4, DMA mode 2, Ultra-DMA mode 5
(Ultra/100) (using DMA), NCQ (31 tags)
-ugen0 at uhub3 port 2
-ugen0: motorola (0x22b8) moto g53 5G (0x2e24), rev 2.00/5.04, addr 3
+urndis0 at uhub3 port 2 configuration 1 interface 0
+urndis0: motorola (0x22b8) moto g53 5G (0x2e24), rev 2.00/5.04, addr 3
+urndis0: Ethernet address ea:1b:52:34:51:c3
swwdog0: software watchdog initialized
WARNING: 3 errors while detecting hardware; check system log.
boot device: ld0
Thank you for your time.
diff -ur /usr/src/sys/dev/usb.orig/if_urndis.c /usr/src/sys/dev/usb/if_urndis.c
--- /usr/src/sys/dev/usb.orig/if_urndis.c 2023-10-14 10:05:39.000000000 +0300
+++ /usr/src/sys/dev/usb/if_urndis.c 2025-01-31 11:03:33.631442159 +0200
@@ -884,6 +884,11 @@
id->bInterfaceProtocol == UIPROTO_RNDIS)
return UMATCH_IFACECLASS_IFACESUBCLASS_IFACEPROTO;
+ if (id->bInterfaceClass == UICLASS_MISCDEV &&
+ id->bInterfaceSubClass == UISUBCLASS_RNDIS &&
+ id->bInterfaceProtocol == UIPROTO_RNDISOETH)
+ return UMATCH_IFACECLASS_IFACESUBCLASS_IFACEPROTO;
+
return usb_lookup(urndis_devs, uiaa->uiaa_vendor, uiaa->uiaa_product) != NULL ?
UMATCH_VENDOR_PRODUCT : UMATCH_NONE;
}
diff -ur /usr/src/sys/dev/usb.orig/usb.h /usr/src/sys/dev/usb/usb.h
--- /usr/src/sys/dev/usb.orig/usb.h 2024-02-03 13:47:07.000000000 +0200
+++ /usr/src/sys/dev/usb/usb.h 2025-01-31 10:35:38.490663556 +0200
@@ -746,6 +746,10 @@
#define UIPROTO_BLUETOOTH 0x01
#define UIPROTO_RNDIS 0x03
+#define UICLASS_MISCDEV 0xef
+#define UISUBCLASS_RNDIS 0x04
+#define UIPROTO_RNDISOETH 0x01
+
#define UICLASS_APPL_SPEC 0xfe
#define UISUBCLASS_FIRMWARE_DOWNLOAD 1
#define UISUBCLASS_IRDA 2
Home |
Main Index |
Thread Index |
Old Index