-
Notifications
You must be signed in to change notification settings - Fork 354
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
usb: Set default mode to 3 to include CDC NCM, and fix a log message
- Loading branch information
Showing
1 changed file
with
2 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -691,15 +691,15 @@ static void get_mode_cb(struct libusb_transfer* transfer) | |
unsigned char *data = libusb_control_transfer_get_data(transfer); | ||
|
||
char* desired_mode_char = getenv(ENV_DEVICE_MODE); | ||
int desired_mode = desired_mode_char ? atoi(desired_mode_char) : 1; | ||
int desired_mode = desired_mode_char ? atoi(desired_mode_char) : 3; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
mbilker
|
||
int guessed_mode = guess_mode(context->dev, dev); | ||
|
||
// Response is 3:3:3:0 for initial mode, 5:3:3:0 otherwise. | ||
usbmuxd_log(LL_INFO, "Received response %i:%i:%i:%i for get_mode request for device %i-%i", data[0], data[1], data[2], data[3], context->bus, context->address); | ||
if(desired_mode >= 1 && desired_mode <= 3 && | ||
guessed_mode > 0 && // do not switch mode if guess failed | ||
guessed_mode != desired_mode) { | ||
usbmuxd_log(LL_WARNING, "Switching device %i-%i mode to %i", context->bus, context->address, context->wIndex); | ||
usbmuxd_log(LL_WARNING, "Switching device %i-%i mode to %i", context->bus, context->address, desired_mode); | ||
|
||
context->bRequest = APPLE_VEND_SPECIFIC_SET_MODE; | ||
context->wValue = 0; | ||
|
1 comment
on commit c7a0dd9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Originally mode 1 was used, where a tethered iPhone appears as an Ethernet interface, handled by the
ipheth
driver. This has been the default for many years and is known to work on iPhone 3G, 4S, 7 Plus, 11 and newer. Since [1-2]ipheth
supports CDC NCM in mode 1, and configures the iPhone to use it.In mode 3, the Ethernet interface is handled by
kmod-usb-net-cdc-ncm
. This driver has better performance, but now the iPhone does not provide DHCP or Internet connectivity, so we should revert to mode 1. Am I missing some configuration? Has mode 3 been tested? Analysing the network traffic, shows that both the iPhone and OpenWRT are DHCP clients trying to obtain an address. But the iPhone does not act as a DHCP server. I can set a static IP address on OpenWRT and make it lease 172.20.10.1 to the iPhone. Then I can ping the iPhone and I have IPv4 connectivity. I used this to benchmark the network speed. However the iPhone does not provide Internet connectivity to OpenWRT. Maybe in mode 3, the iPhone is a client meant to receive Internet over USB and therefore it is not a gateway?Attempts to switch old iPhones, such as 3G and 4S to mode 3 fail. They remain in mode 1 and work correctly using the
ipheth
driver. No issues here.Comparison, tested on iPhone 7 Plus and 11
eth0
kmod-usb-net-ipheth
264 Mbit/s DHCP server, Internetusb0
kmod-usb-net-cdc-ncm
304 Mbit/s DHCP client, no InternetThe libimobiledevice packages are compiled from [3], which includes the latest releases or commits (where no recent release is available).
[1] torvalds/linux@a2d274c
[2] openwrt/openwrt@680f873
[3] https://github.com/httpstorm/openwrt.packages/commits/libimobiledevice-2024-04-16/
@nikias @FunkyM @BalkanMadman @rickmark @Blefish @marcan