Commit 3ec8d757 authored by Ole André Vadla Ravnås's avatar Ole André Vadla Ravnås Committed by Jakub Kicinski

CDC-NCM: add support for Apple's private interface

Available on iOS/iPadOS >= 17, where this new interface is used by
developer tools using the new RemoteXPC protocol.

This private interface lacks a status endpoint, presumably because there
isn't a physical cable that can be unplugged, nor any speed changes to
be notified about.

Note that NCM interfaces are not exposed until a mode switch is
requested, which macOS does automatically.

The mode switch can be performed like this:

        uint8_t status;
        libusb_control_transfer(device_handle,
                LIBUSB_RECIPIENT_DEVICE | LIBUSB_REQUEST_TYPE_VENDOR |
                LIBUSB_ENDPOINT_IN,
                82, /* bRequest */
                0,  /* wValue   */
                3,  /* wIndex   */
                &status,
                sizeof(status),
                0);

Newer versions of usbmuxd do this automatically.
Co-developed-by: default avatarHåvard Sørbø <havard@hsorbo.no>
Signed-off-by: default avatarHåvard Sørbø <havard@hsorbo.no>
Signed-off-by: default avatarOle André Vadla Ravnås <oleavr@frida.re>
Link: https://lore.kernel.org/r/20240607074117.31322-1-oleavr@frida.reSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 6fc1b322
...@@ -933,7 +933,8 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_ ...@@ -933,7 +933,8 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_
cdc_ncm_find_endpoints(dev, ctx->data); cdc_ncm_find_endpoints(dev, ctx->data);
cdc_ncm_find_endpoints(dev, ctx->control); cdc_ncm_find_endpoints(dev, ctx->control);
if (!dev->in || !dev->out || !dev->status) { if (!dev->in || !dev->out ||
(!dev->status && dev->driver_info->flags & FLAG_LINK_INTR)) {
dev_dbg(&intf->dev, "failed to collect endpoints\n"); dev_dbg(&intf->dev, "failed to collect endpoints\n");
goto error2; goto error2;
} }
...@@ -1925,6 +1926,34 @@ static const struct driver_info cdc_ncm_zlp_info = { ...@@ -1925,6 +1926,34 @@ static const struct driver_info cdc_ncm_zlp_info = {
.set_rx_mode = usbnet_cdc_update_filter, .set_rx_mode = usbnet_cdc_update_filter,
}; };
/* Same as cdc_ncm_info, but with FLAG_SEND_ZLP */
static const struct driver_info apple_tethering_interface_info = {
.description = "CDC NCM (Apple Tethering)",
.flags = FLAG_POINTTOPOINT | FLAG_NO_SETINT | FLAG_MULTI_PACKET
| FLAG_LINK_INTR | FLAG_ETHER | FLAG_SEND_ZLP,
.bind = cdc_ncm_bind,
.unbind = cdc_ncm_unbind,
.manage_power = usbnet_manage_power,
.status = cdc_ncm_status,
.rx_fixup = cdc_ncm_rx_fixup,
.tx_fixup = cdc_ncm_tx_fixup,
.set_rx_mode = usbnet_cdc_update_filter,
};
/* Same as apple_tethering_interface_info, but without FLAG_LINK_INTR */
static const struct driver_info apple_private_interface_info = {
.description = "CDC NCM (Apple Private)",
.flags = FLAG_POINTTOPOINT | FLAG_NO_SETINT | FLAG_MULTI_PACKET
| FLAG_ETHER | FLAG_SEND_ZLP,
.bind = cdc_ncm_bind,
.unbind = cdc_ncm_unbind,
.manage_power = usbnet_manage_power,
.status = cdc_ncm_status,
.rx_fixup = cdc_ncm_rx_fixup,
.tx_fixup = cdc_ncm_tx_fixup,
.set_rx_mode = usbnet_cdc_update_filter,
};
/* Same as cdc_ncm_info, but with FLAG_WWAN */ /* Same as cdc_ncm_info, but with FLAG_WWAN */
static const struct driver_info wwan_info = { static const struct driver_info wwan_info = {
.description = "Mobile Broadband Network Device", .description = "Mobile Broadband Network Device",
...@@ -1954,6 +1983,22 @@ static const struct driver_info wwan_noarp_info = { ...@@ -1954,6 +1983,22 @@ static const struct driver_info wwan_noarp_info = {
}; };
static const struct usb_device_id cdc_devs[] = { static const struct usb_device_id cdc_devs[] = {
/* iPhone */
{ USB_DEVICE_INTERFACE_NUMBER(0x05ac, 0x12a8, 2),
.driver_info = (unsigned long)&apple_tethering_interface_info,
},
{ USB_DEVICE_INTERFACE_NUMBER(0x05ac, 0x12a8, 4),
.driver_info = (unsigned long)&apple_private_interface_info,
},
/* iPad */
{ USB_DEVICE_INTERFACE_NUMBER(0x05ac, 0x12ab, 2),
.driver_info = (unsigned long)&apple_tethering_interface_info,
},
{ USB_DEVICE_INTERFACE_NUMBER(0x05ac, 0x12ab, 4),
.driver_info = (unsigned long)&apple_private_interface_info,
},
/* Ericsson MBM devices like F5521gw */ /* Ericsson MBM devices like F5521gw */
{ .match_flags = USB_DEVICE_ID_MATCH_INT_INFO { .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
| USB_DEVICE_ID_MATCH_VENDOR, | USB_DEVICE_ID_MATCH_VENDOR,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment