Skip to content

Commit 3ec8d75

Browse files
oleavrkuba-moo
authored andcommitted
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: Håvard Sørbø <havard@hsorbo.no> Signed-off-by: Håvard Sørbø <havard@hsorbo.no> Signed-off-by: Ole André Vadla Ravnås <oleavr@frida.re> Link: https://lore.kernel.org/r/20240607074117.31322-1-oleavr@frida.re Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 6fc1b32 commit 3ec8d75

File tree

1 file changed

+46
-1
lines changed

1 file changed

+46
-1
lines changed

drivers/net/usb/cdc_ncm.c

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,8 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_
933933

934934
cdc_ncm_find_endpoints(dev, ctx->data);
935935
cdc_ncm_find_endpoints(dev, ctx->control);
936-
if (!dev->in || !dev->out || !dev->status) {
936+
if (!dev->in || !dev->out ||
937+
(!dev->status && dev->driver_info->flags & FLAG_LINK_INTR)) {
937938
dev_dbg(&intf->dev, "failed to collect endpoints\n");
938939
goto error2;
939940
}
@@ -1925,6 +1926,34 @@ static const struct driver_info cdc_ncm_zlp_info = {
19251926
.set_rx_mode = usbnet_cdc_update_filter,
19261927
};
19271928

1929+
/* Same as cdc_ncm_info, but with FLAG_SEND_ZLP */
1930+
static const struct driver_info apple_tethering_interface_info = {
1931+
.description = "CDC NCM (Apple Tethering)",
1932+
.flags = FLAG_POINTTOPOINT | FLAG_NO_SETINT | FLAG_MULTI_PACKET
1933+
| FLAG_LINK_INTR | FLAG_ETHER | FLAG_SEND_ZLP,
1934+
.bind = cdc_ncm_bind,
1935+
.unbind = cdc_ncm_unbind,
1936+
.manage_power = usbnet_manage_power,
1937+
.status = cdc_ncm_status,
1938+
.rx_fixup = cdc_ncm_rx_fixup,
1939+
.tx_fixup = cdc_ncm_tx_fixup,
1940+
.set_rx_mode = usbnet_cdc_update_filter,
1941+
};
1942+
1943+
/* Same as apple_tethering_interface_info, but without FLAG_LINK_INTR */
1944+
static const struct driver_info apple_private_interface_info = {
1945+
.description = "CDC NCM (Apple Private)",
1946+
.flags = FLAG_POINTTOPOINT | FLAG_NO_SETINT | FLAG_MULTI_PACKET
1947+
| FLAG_ETHER | FLAG_SEND_ZLP,
1948+
.bind = cdc_ncm_bind,
1949+
.unbind = cdc_ncm_unbind,
1950+
.manage_power = usbnet_manage_power,
1951+
.status = cdc_ncm_status,
1952+
.rx_fixup = cdc_ncm_rx_fixup,
1953+
.tx_fixup = cdc_ncm_tx_fixup,
1954+
.set_rx_mode = usbnet_cdc_update_filter,
1955+
};
1956+
19281957
/* Same as cdc_ncm_info, but with FLAG_WWAN */
19291958
static const struct driver_info wwan_info = {
19301959
.description = "Mobile Broadband Network Device",
@@ -1954,6 +1983,22 @@ static const struct driver_info wwan_noarp_info = {
19541983
};
19551984

19561985
static const struct usb_device_id cdc_devs[] = {
1986+
/* iPhone */
1987+
{ USB_DEVICE_INTERFACE_NUMBER(0x05ac, 0x12a8, 2),
1988+
.driver_info = (unsigned long)&apple_tethering_interface_info,
1989+
},
1990+
{ USB_DEVICE_INTERFACE_NUMBER(0x05ac, 0x12a8, 4),
1991+
.driver_info = (unsigned long)&apple_private_interface_info,
1992+
},
1993+
1994+
/* iPad */
1995+
{ USB_DEVICE_INTERFACE_NUMBER(0x05ac, 0x12ab, 2),
1996+
.driver_info = (unsigned long)&apple_tethering_interface_info,
1997+
},
1998+
{ USB_DEVICE_INTERFACE_NUMBER(0x05ac, 0x12ab, 4),
1999+
.driver_info = (unsigned long)&apple_private_interface_info,
2000+
},
2001+
19572002
/* Ericsson MBM devices like F5521gw */
19582003
{ .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
19592004
| USB_DEVICE_ID_MATCH_VENDOR,

0 commit comments

Comments
 (0)