A socket daemon to multiplex connections from and to iOS devices

Overview

usbmuxd

A socket daemon to multiplex connections from and to iOS devices.

build

Features

usbmuxd stands for "USB multiplexing daemon". This daemon is in charge of multiplexing connections over USB to an iOS device.

To users, it means you can use various applications to interact with your device.

To developers, it means you can connect to any listening localhost socket on the device.

Some key features are:

  • Implementation: Open-Source implementation of proprietary usbmuxd daemon
  • Cross-Platform: Tested on Linux, macOS, Windows and Android platforms
  • Linux: Supports udev and systemd for automatic activation
  • Compatibility: Supports latest device firmware releases
  • Scalability: Supports multiple connections to different ports in parallel

usbmuxd is not used for tethering data transfers which uses a dedicated USB interface to act as a virtual network device.

The higher-level layers, especially if you want to write an application to interact with the device, are handled by libimobiledevice.

The low-level layer is handled by libusbmuxd.

Installation / Getting started

Debian / Ubuntu Linux

First install all required dependencies and build tools:

sudo apt-get install \
	build-essential \
	checkinstall \
	git \
	autoconf \
	automake \
	libtool-bin \
	libplist-dev \
	libusbmuxd-dev \
	libimobiledevice-dev \
	libimobiledevice-glue-dev \
	libusb-1.0-0-dev \
	udev

If systemd is not installed and should control spawning the daemon use:

sudo apt-get install \
	systemd

Then clone the actual project repository:

git clone https://github.com/libimobiledevice/usbmuxd.git
cd usbmuxd

Now you can build and install it:

./autogen.sh
make
sudo make install

If you require a custom prefix or other option being passed to ./configure you can pass them directly to ./autogen.sh like this:

./autogen.sh --prefix=/opt/local --without-preflight --without-systemd
make
sudo make install

To output a list of available configure options use:

./autogen.sh --help

Usage

The daemon is automatically started by udev or systemd depending on what you have configured upon hotplug of an iOS device and exits if the last device was unplugged.

When usbmuxd is running it provides a socket interface at /var/run/usbmuxd that is designed to be compatible with the socket interface that is provided on macOS.

You should also create an usbmux user that has access to USB devices on your system. Alternatively, just pass a different username using the -U argument.

The daemon also manages pairing records with iOS devices and the host in /var/lib/lockdown (Linux) or /var/db/lockdown (macOS).

Ensure proper permissions are setup for the daemon to access the directory.

For debugging purposes it is helpful to start usbmuxd using the foreground -f argument and enable verbose mode -v to get suitable logs.

Please consult the usage information or manual page for a full documentation of available command line options:

usbmuxd --help
man usbmuxd

Contributing

We welcome contributions from anyone and are grateful for every pull request!

If you'd like to contribute, please fork the master branch, change, commit and send a pull request for review. Once approved it can be merged into the main code base.

If you plan to contribute larger changes or a major refactoring, please create a ticket first to discuss the idea upfront to ensure less effort for everyone.

Please make sure your contribution adheres to:

  • Try to follow the code style of the project
  • Commit messages should describe the change well without being too short
  • Try to split larger changes into individual commits of a common domain
  • Use your real name and a valid email address for your commits

We are still working on the guidelines so bear with us!

Links

License

This library and utilities are licensed under the GNU General Public License v3.0, also included in the repository in the COPYING.GPLv3 file.

Credits

The initial usbmuxd daemon implementation was authored by Hector Martin.

Apple, iPhone, iPad, iPod, iPod Touch, Apple TV, Apple Watch, Mac, iOS, iPadOS, tvOS, watchOS, and macOS are trademarks of Apple Inc.

usbmuxd is an independent software application and has not been authorized, sponsored, or otherwise approved by Apple Inc.

README Updated on: 2021-08-30

Comments
  • Reciving lockdown error -8 (LOCKDOWN_E_MUX_ERROR) on latest push to master

    Reciving lockdown error -8 (LOCKDOWN_E_MUX_ERROR) on latest push to master

    Unable to connect to device after the latest push to master. Using an iOS 11 device.

    Command: usbmuxd -f -v Verbose output: [17:10:02.658][3] usbmuxd v1.1.1 starting up [17:10:02.658][4] Creating socket [17:10:02.658][4] Initializing USB [17:10:02.667][4] Registering for libusb hotplug events [17:10:02.667][4] Found new device with v/p 05ac:12a8 at 3-13 [17:10:02.667][4] Found interface 1 with endpoints 04/85 for device 3-13 [17:10:02.668][4] Using wMaxPacketSize=512 for device 3-13 [17:10:02.668][4] USB Speed is 480 MBit/s for device 3-13 [17:10:02.668][4] 1 device detected [17:10:02.668][3] Initialization complete [17:10:02.668][4] Got lang ID 1033 for device 3-13 [17:10:02.668][4] Got serial '<MY_SERIAL>' for device 3-13 [17:10:02.668][3] Connecting to new device on location 0x3000d as ID 1 [17:10:02.668][3] Connected to v2.0 device 1 on location 0x3000d with serial number <MY_SERIAL> [17:10:02.668][4] preflight_worker_handle_device_add: Starting preflight on device <MY_SERIAL>... [17:10:02.668][4] New client on fd 13 (self) [17:10:02.668][2] Attempted to connect to nonexistent device 0 [17:10:02.668][1] preflight_worker_handle_device_add: ERROR: Could not connect to lockdownd on device faf6944a7ef4f4cf2571b36079131d7001cc972f, lockdown error -8 [17:10:02.668][4] Client 13 connection closed [17:10:02.668][4] Disconnecting client fd 13

    Works again once reverting to the previous commit to master (tree commit d33402036d563667a76910dbfec50a37b622d3a5).

    opened by guywithface 19
  • About building and running on Android

    About building and running on Android

    I see the description of your home page.

    Cross-Platform: Tested on Linux, macOS, Windows and Android platforms

    I'm curious that when I use java code to simulate, I can't open the multiplexing interface of iPhone.

    According to https://github.com/libimobiledevice/usbmuxd/blob/e3a3180b9b380ce9092ee0d7b8e9d82d66b1c261/src/usb.c#L477 I found the interfaces numbered 6 and 8.

    When I tried to open it with android.hardware.usb.UsbDeviceConnection.claimInterface, I got an error.

    So, I would like to ask you, have you successfully run it on Android and connected to the device?

    If you have successfully connected to the device, can you say what changes you have made? Whether internal or external, what should I pay attention to?

    I can only run it on arm at present, because the permissions on Java do not allow me to open the specified interface.

    opened by xanadu-lee 18
  • segfault on startup when approximately10 or more iOS devices connected

    segfault on startup when approximately10 or more iOS devices connected

    We're using libuxbmuxd on a hub with 27 iOS devices connected. All devices are running iOS 8.4

    I am testing master/HEAD from the git repos of libplist, libuxbmuxd, usbmuxd, libimobiledevice. Target is Debian Wheezy on ARM. I checked out the source with git clone and then configured, built, and installed as per the instructions.

    When more than approximately 10 devices are plugged in, starting usbmuxd crashes immediately. This happens whether using foreground or background mode. Here is the command line session. (I will attach the logs to the ticket.)

    With fewer than ~10 devices it starts OK, and usually allows the devices to be plugged in one at a time without crashing.

    [email protected]:~# usbmuxd -U root -vv -f 2> crash2.txt
    Segmentation fault
    [email protected]:~# usbmuxd -U root -vv -f 2> crash3.txt
    Segmentation fault
    [email protected]:~# usbmuxd -U root -vv -f 2> crash4.txt
    Segmentation fault
    [email protected]:~# usbmuxd -U root -vv -f 2> crash5.txt
    Segmentation fault
    [email protected]:~# usbmuxd -U root -vv -f 2> crash6.txt
    Segmentation fault
    [email protected]:~# usbmuxd -U root -vv -f 2> crash7.txt
    Segmentation fault
    [email protected]:~# usbmuxd -U root -vv -f 2> crash8.txt
    glibc detected *** usbmuxd: free(): invalid pointer: 0x0028bdc0 ***
    Aborted
    [email protected]:~# usbmuxd -U root -vv -f 2> crash9.txt
    Segmentation fault
    [email protected]:~# usbmuxd -U root -vv -f 2> crash10.txt
    Segmentation fault
    [email protected]:~# usbmuxd -U root -vv -f 2> crash11.txt
    Segmentation fault
    

    The log files generated by the session reported above (with --vv flag) can be downloaded here: http://rossbencina.com/static/junk/usbmuxd_crashlogs_20150730.tar.gz

    This worked without crashes with libusbmuxd 1.0.7. It works with occasional crashes with the latest "official" tarballs on the website (libplist-1.12.tar.bz2 libusbmuxd-1.0.10.tar.bz2 usbmuxd-1.0.9.tar.bz2 libimobiledevice-1.1.7.tar.bz2).

    Please let me know:

    • Should we be using something other than master/HEAD for the latest code.
    • Where to start looking to debug this

    We would like to use the version that is most compatible with iOS 8.4.

    bug feedback Linux 
    opened by RossBencina 15
  • [arm linux]Device is not paired with this host

    [arm linux]Device is not paired with this host

    i cross compile usbmuxd 1.1.1 on a arm linux chip with arm-himix100-linux-gcc, when run this application, connect failed,the log display this:

    [04:51:44.452][4] preflight_worker_handle_device_add: Device 61b75e9f2e0c9f0c60e7221b6cec287820e7539b is not paired with this host.

    but the phone have any trust tips,and the same version code i comlile on ubuntu16.04 with gcc and the other arm linux with aarch64-himix100-linux-gcc was work successful and no errors.

    thanks for help! this is the detail log when new connect the phone:

    [04:51:44.329][7] poll() returned 1 main_loop:232 FD_USB [04:51:44.329][4] Found new device with v/p 05ac:12a8 at 1-19 [04:51:44.335][4] Setting configuration for device 1-19, from 1 to 4 [04:51:44.402][4] Found interface 1 with endpoints 04/85 for device 1-19 [04:51:44.406][4] Using wMaxPacketSize=512 for device 1-19 [04:51:44.407][4] USB Speed is 480 MBit/s for device 1-19 [04:51:44.407][7] fd count is 4 [04:51:44.408][7] poll() returned 2 main_loop:232 FD_USB [04:51:44.408][4] Got lang ID 1033 for device 1-19 [04:51:44.409][7] fd count is 4 [04:51:44.409][7] poll() returned 1 main_loop:232 FD_USB [04:51:44.417][4] Got serial '61b75e9f2e0c9f0c60e7221b6cec287820e7539b' for device 1-19 [04:51:44.419][3] Connecting to new device on location 0x10013 as ID 1 [04:51:44.419][6] send_packet(1, 0x0, 0xbedac97c, (nil), 0) [04:51:44.420][5] All 3 RX loops started successfully [04:51:44.421][6] TX callback dev 1-19 len 20 -> 20 status 0 [04:51:44.421][6] RX callback dev 1-19 len 20 status 0 [04:51:44.422][6] Mux data input for device 0x30088: 0x424c8 len 20 [04:51:44.422][6] send_packet(1, 0x2, (nil), 0x1c09c, 1) [04:51:44.423][3] Connected to v2.0 device 1 on location 0x10013 with serial number 61b75e9f2e0c9f0c60e7221b6cec287820e7539b [04:51:44.424][6] TX callback dev 1-19 len 17 -> 17 status 0 [04:51:44.425][7] fd count is 4 [04:51:44.425][4] preflight_worker_handle_device_add: Starting preflight on device 61b75e9f2e0c9f0c60e7221b6cec287820e7539b... [04:51:44.426][7] poll() returned 1 main_loop:241 FD_LISTEN [04:51:44.426][4] New client on fd 13 (self) [04:51:44.426][7] fd count is 5 [04:51:44.427][7] poll() returned 1 main_loop:249 FD_CLIENT client_process:949 process_recv [04:51:44.427][7] fd count is 5 [04:51:44.428][7] poll() returned 1 main_loop:249 FD_CLIENT client_process:949 process_recv [04:51:44.428][5] Client command in fd 13 len 512 ver 1 msg 8 tag 1 client_command:633 MESSAGE_PLIST client_command:656 message:Connect [04:51:44.429][5] Client 13 connection request to device 1 port 62078 [04:51:44.429][5] [OUT] dev=1 sport=1 dport=62078 seq=0 ack=0 flags=0x2 window=131072[512] len=0 [04:51:44.429][6] send_packet(1, 0x6, 0xbedaca7c, (nil), 0) [04:51:44.430][7] fd count is 5 [04:51:44.430][7] poll() returned 1 main_loop:232 FD_USB [04:51:44.431][6] TX callback dev 1-19 len 36 -> 36 status 0 [04:51:44.431][6] RX callback dev 1-19 len 36 status 0 [04:51:44.432][6] Mux data input for device 0x30088: 0x464d0 len 36 [04:51:44.432][5] [IN] dev=1 sport=62078 dport=1 seq=0 ack=1 flags=0x12 window=131072[512] len=0 [04:51:44.434][5] [OUT] dev=1 sport=1 dport=62078 seq=1 ack=1 flags=0x10 window=131072[512] len=0 [04:51:44.435][6] send_packet(1, 0x6, 0xbedac92c, (nil), 0) [04:51:44.435][6] client_notify_connect fd 13 result 0 [04:51:44.436][5] send_pkt fd 13 tag 1 msg 8 payload_length 278 [04:51:44.437][6] update_connection: sendable 49116, events 1, flags 0 [04:51:44.437][6] TX callback dev 1-19 len 36 -> 36 status 0 [04:51:44.438][7] fd count is 5 [04:51:44.438][7] poll() returned 1 main_loop:249 FD_CLIENT client_process:952 process_send [04:51:44.439][5] Client 13 switching to CONNECTED state [04:51:44.440][7] fd count is 5 [04:51:44.440][7] poll() returned 1 main_loop:249 FD_CLIENT client_process:944 CLIENT_CONNECTED [04:51:44.440][6] client_process in CONNECTED state [04:51:44.440][6] device_client_process (1) [04:51:44.441][6] client_read fd 13 buf 0x6fba0 len 49116 [04:51:44.441][5] [OUT] dev=1 sport=1 dport=62078 seq=1 ack=1 flags=0x10 window=131072[512] len=284 [04:51:44.442][6] send_packet(1, 0x6, 0xbedaca8c, 0x6fba0, 284) [04:51:44.443][6] update_connection: sendable 49116, events 1, flags 0 [04:51:44.443][7] fd count is 5 [04:51:44.444][7] poll() returned 1 main_loop:232 FD_USB [04:51:44.444][6] TX callback dev 1-19 len 320 -> 320 status 0 [04:51:44.445][6] RX callback dev 1-19 len 337 status 0 [04:51:44.445][6] Mux data input for device 0x30088: 0x4a4d8 len 337 [04:51:44.446][5] [IN] dev=1 sport=62078 dport=1 seq=1 ack=285 flags=0x10 window=131072[512] len=301 [04:51:44.447][6] update_connection: sendable 49116, events 5, flags 0 [04:51:44.447][5] [OUT] dev=1 sport=1 dport=62078 seq=285 ack=1 flags=0x10 window=131072[512] len=0 [04:51:44.448][6] send_packet(1, 0x6, 0xbedac924, (nil), 0) [04:51:44.449][6] update_connection: sendable 49116, events 5, flags 0 [04:51:44.450][6] TX callback dev 1-19 len 36 -> 36 status 0 [04:51:44.450][7] fd count is 5 [04:51:44.451][7] poll() returned 1 main_loop:249 FD_CLIENT client_process:944 CLIENT_CONNECTED [04:51:44.451][6] client_process in CONNECTED state [04:51:44.451][6] device_client_process (4) [04:51:44.451][6] client_write fd 13 buf 0xb5b5c008 len 301 [04:51:44.452][4] preflight_worker_handle_device_add: Device 61b75e9f2e0c9f0c60e7221b6cec287820e7539b is not paired with this host. [04:51:44.453][6] update_connection: sendable 49116, events 1, flags 1 [04:51:44.453][7] fd count is 5 [04:51:44.453][7] poll() returned 1 main_loop:249 FD_CLIENT client_process:944 CLIENT_CONNECTED [04:51:44.454][6] client_process in CONNECTED state [04:51:44.454][6] device_client_process (1) [04:51:44.454][6] client_read fd 13 buf 0x6fba0 len 49116 [04:51:44.455][5] [OUT] dev=1 sport=1 dport=62078 seq=285 ack=302 flags=0x10 window=131072[512] len=332 [04:51:44.456][6] send_packet(1, 0x6, 0xbedaca8c, 0x6fba0, 332) [04:51:44.456][6] update_connection: sendable 49116, events 1, flags 0 [04:51:44.457][7] fd count is 5 [04:51:44.457][7] poll() returned 1 main_loop:232 FD_USB [04:51:44.458][6] TX callback dev 1-19 len 368 -> 368 status 0 [04:51:44.458][6] RX callback dev 1-19 len 367 status 0 [04:51:44.459][6] Mux data input for device 0x30088: 0x424c8 len 367 [04:51:44.459][5] [IN] dev=1 sport=62078 dport=1 seq=302 ack=617 flags=0x10 window=131072[512] len=331 [04:51:44.460][6] update_connection: sendable 49116, events 5, flags 0 [04:51:44.461][5] [OUT] dev=1 sport=1 dport=62078 seq=617 ack=302 flags=0x10 window=131072[512] len=0 [04:51:44.462][6] send_packet(1, 0x6, 0xbedac924, (nil), 0) [04:51:44.462][6] update_connection: sendable 49116, events 5, flags 0 [04:51:44.463][6] TX callback dev 1-19 len 36 -> 36 status 0 [04:51:44.464][7] fd count is 5 [04:51:44.464][7] poll() returned 1 main_loop:249 FD_CLIENT client_process:944 CLIENT_CONNECTED [04:51:44.465][6] client_process in CONNECTED state [04:51:44.465][6] device_client_process (4) [04:51:44.465][6] client_write fd 13 buf 0xb5b5c008 len 331 [04:51:44.466][4] preflight_worker_handle_device_add: Found ProductVersion 13.3.1 device 61b75e9f2e0c9f0c60e7221b6cec287820e7539b [04:51:44.466][5] reading key SystemBUID from config_file /var/lib/lockdown/SystemConfiguration.plist [04:51:44.466][5] got SystemBUID 32B5AAD2-16AE-7B85-DEBE-11DC865B9E32 [04:51:44.466][5] using 32B5AAD2-16AE-7B85-DEBE-11DC865B9E32 as SystemBUID [04:51:44.466][5] lockdownd_set_untrusted_host_buid: Setting UntrustedHostBUID to 32B5AAD2-16AE-7B85-DEBE-11DC865B9E32 [04:51:44.467][6] update_connection: sendable 49116, events 1, flags 1 [04:51:44.467][7] fd count is 5 [04:51:44.468][7] poll() returned 1 main_loop:249 FD_CLIENT client_process:944 CLIENT_CONNECTED [04:51:44.468][6] client_process in CONNECTED state [04:51:44.468][6] device_client_process (1) [04:51:44.468][6] client_read fd 13 buf 0x6fba0 len 49116 [04:51:44.469][5] [OUT] dev=1 sport=1 dport=62078 seq=617 ack=633 flags=0x10 window=131072[512] len=408 [04:51:44.470][6] send_packet(1, 0x6, 0xbedaca8c, 0x6fba0, 408) [04:51:44.471][6] update_connection: sendable 49116, events 1, flags 0 [04:51:44.471][7] fd count is 5 [04:51:44.472][7] poll() returned 1 main_loop:232 FD_USB [04:51:44.472][6] TX callback dev 1-19 len 444 -> 444 status 0 [04:51:44.473][6] RX callback dev 1-19 len 400 status 0 [04:51:44.473][6] Mux data input for device 0x30088: 0x464d0 len 400 [04:51:44.474][5] [IN] dev=1 sport=62078 dport=1 seq=633 ack=1025 flags=0x10 window=131072[512] len=364 [04:51:44.475][6] update_connection: sendable 49116, events 5, flags 0 [04:51:44.475][5] [OUT] dev=1 sport=1 dport=62078 seq=1025 ack=633 flags=0x10 window=131072[512] len=0 [04:51:44.476][6] send_packet(1, 0x6, 0xbedac924, (nil), 0) [04:51:44.477][6] update_connection: sendable 49116, events 5, flags 0 [04:51:44.477][6] TX callback dev 1-19 len 36 -> 36 status 0 [04:51:44.478][7] fd count is 5 [04:51:44.478][7] poll() returned 1 main_loop:249 FD_CLIENT client_process:944 CLIENT_CONNECTED [04:51:44.479][6] client_process in CONNECTED state [04:51:44.479][6] device_client_process (4) [04:51:44.479][6] client_write fd 13 buf 0xb5b5c008 len 364 [04:51:44.480][6] update_connection: sendable 49116, events 1, flags 1 [04:51:44.481][7] fd count is 5 [04:51:44.481][7] poll() returned 1 main_loop:249 FD_CLIENT client_process:944 CLIENT_CONNECTED [04:51:44.481][6] client_process in CONNECTED state [04:51:44.481][6] device_client_process (1) [04:51:44.482][6] client_read fd 13 buf 0x6fba0 len 49116 [04:51:44.482][5] [OUT] dev=1 sport=1 dport=62078 seq=1025 ack=997 flags=0x10 window=131072[512] len=333 [04:51:44.483][6] send_packet(1, 0x6, 0xbedaca8c, 0x6fba0, 333) [04:51:44.484][6] update_connection: sendable 49116, events 1, flags 0 [04:51:44.484][7] fd count is 5 [04:51:44.485][7] poll() returned 1 main_loop:232 FD_USB [04:51:44.485][6] TX callback dev 1-19 len 369 -> 369 status 0 [04:51:44.486][7] fd count is 5 [04:51:44.487][7] poll() returned 1 main_loop:232 FD_USB [04:51:44.487][6] RX callback dev 1-19 len 954 status 0 [04:51:44.488][6] Mux data input for device 0x30088: 0x4a4d8 len 954 [04:51:44.488][5] [IN] dev=1 sport=62078 dport=1 seq=997 ack=1358 flags=0x10 window=131072[512] len=918 [04:51:44.490][6] update_connection: sendable 49116, events 5, flags 0 [04:51:44.490][5] [OUT] dev=1 sport=1 dport=62078 seq=1358 ack=997 flags=0x10 window=131072[512] len=0 [04:51:44.491][6] send_packet(1, 0x6, 0xbedac924, (nil), 0) [04:51:44.492][6] update_connection: sendable 49116, events 5, flags 0 [04:51:44.492][6] TX callback dev 1-19 len 36 -> 36 status 0 [04:51:44.493][7] fd count is 5 [04:51:44.493][7] poll() returned 1 main_loop:249 FD_CLIENT client_process:944 CLIENT_CONNECTED [04:51:44.494][6] client_process in CONNECTED state [04:51:44.494][6] device_client_process (4) [04:51:44.494][6] client_write fd 13 buf 0xb5b5c008 len 918 [04:51:44.500][6] update_connection: sendable 49116, events 1, flags 1 [04:51:44.500][7] fd count is 5 [04:51:44.530][7] poll() returned 0 [04:51:44.530][5] Sending ACK due to expired timeout (20623262 -> 20623300) [04:51:44.530][5] [OUT] dev=1 sport=1 dport=62078 seq=1358 ack=1915 flags=0x10 window=131072[512] len=0 [04:51:44.530][6] send_packet(1, 0x6, 0xbedacacc, (nil), 0) [04:51:44.530][6] update_connection: sendable 49116, events 1, flags 0 [04:51:44.530][7] fd count is 5 [04:51:44.530][7] poll() returned 1 main_loop:232 FD_USB [04:51:44.531][6] TX callback dev 1-19 len 36 -> 36 status 0 [04:51:44.531][7] fd count is 5

    opened by yeahtoo 14
  • iphone times out during restore. usbmuxd shows timeout err.

    iphone times out during restore. usbmuxd shows timeout err.

    This is related to issue #338 reported on idevicerestore but the source of the problem seems to be on usbmuxd or libusbmuxd.

    After reviewing all compiles, links, libs, dependencies, etc., idevicerestore gets a timeout after successfully sending NORData:

    idevice.c:642 internal_connection_receive_timeout(): ERROR: usbmuxd_recv_timeout returned -104 (Connection reset by peer).

    After tracking down the issue in libimobiledevice programs and running usbmuxd -f -vv, I see that usbmuxd 1.1.2 (libusb.1.0.23) shows error -71 as a result of a timeout and disconnects. This happens after a long conversation and transfers between host and device:

    [88.808281] [0000cff5] libusb: debug [usbi_handle_transfer_completion] transfer 0x55c0401e9a10 has callback 0x55c03f5a4760 [88.808286] [0000cff5] libusb: debug [libusb_free_transfer] transfer 0x55c0401e9a10 [88.990091] [0000cff5] libusb: debug [libusb_handle_events_timeout_completed] doing our own event handling [88.990110] [0000cff5] libusb: debug [handle_events] poll() 3 fds with timeout in 0ms [88.990119] [0000cff5] libusb: debug [handle_events] poll() returned 1 [88.990129] [0000cff5] libusb: debug [reap_for_handle] urb type=3 status=-71 transferred=0 [88.990135] [0000cff5] libusb: debug [handle_bulk_completion] handling completion status -71 of bulk urb 1/1 [88.990143] [0000cff5] libusb: debug [handle_bulk_completion] low level error -71 [88.990149] [0000cff5] libusb: debug [usbi_handle_transfer_completion] transfer 0x55c0401fc670 has callback 0x55c03f5a48b0 [13:38:08.103][4] Device 1-37 RX aborted due to error or disconnect

    I have tried using different systems (Ubuntu 20.04 and 18.04) and cables and I still cannot find the reason why the host drops the device. After reading libusbmuxd and libimobiledevice programs it is unclear whether the host reconnects to the device before sending data at some point.

    I am also attaching a couple of txt files with the console output of "idevicerestore -l -d" (libimobiledevice compiled with --enable-debug) and "usbmuxd -f -vv" which runs on a separate console terminal.

    BTW, all ilibmobiledevice's supporting libraries are git-cloned, compiled, and properly linked.

    Any hint is highly appreciated. Best rgds.

    usbmuxd.txt idevicerestore.txt

    opened by TheNegativeZero 13
  • usbmuxd does not work with iOs 11.1

    usbmuxd does not work with iOs 11.1

    Hello,

    I've just cloned the newest Version on Git and build everything and it works fine with ios 10. Then i tried with ios 11 and it says "ERROR: Could not connect to lockdownd, error code -3" although the Pairing process always succesful.

    Btw ideviceinfo gives the same error, but ideviceinfo -s works fine.

    I'm using Raspbian

    opened by MinhDucLe2412 11
  • Build fails if libimobiledevice is installed with custom prefix

    Build fails if libimobiledevice is installed with custom prefix

    The build fails if libimobiledevice is installed with custom prefix for the following reasons:

    1. Typo in src/Makefile.am that results in missing CFLAGS for libimobiledevice.
    $ make
    make  all-recursive
    make[1]: Entering directory '/opt/libimobiledevice/usbmuxd'
    Making all in src
    make[2]: Entering directory '/opt/libimobiledevice/usbmuxd/src'
      CC       usbmuxd-client.o
      CC       usbmuxd-device.o
      CC       usbmuxd-preflight.o
    preflight.c:34:10: fatal error: libimobiledevice/libimobiledevice.h: No such file or directory
     #include <libimobiledevice/libimobiledevice.h>
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    compilation terminated.
    
    1. Check for enum idevice_connection_type in configure.ac yields a false negative. As a result, HAVE_ENUM_IDEVICE_CONNECTION_TYPE is undefined and idevice_connection_type and will be redeclared in src/preflight.c:47.
    $ make
    make  all-recursive
    make[1]: Entering directory '/opt/libimobiledevice/usbmuxd'
    Making all in src
    make[2]: Entering directory '/opt/libimobiledevice/usbmuxd/src'
      CC       usbmuxd-preflight.o
    preflight.c:47:6: error: nested redefinition of ‘enum idevice_connection_type’
     enum idevice_connection_type {
          ^~~~~~~~~~~~~~~~~~~~~~~
    preflight.c:47:6: error: redeclaration of ‘enum idevice_connection_type’
    In file included from preflight.c:34:
    /opt/libimobiledevice-1.2.1/include/libimobiledevice/libimobiledevice.h:63:6: note: originally defined here
     enum idevice_connection_type {
          ^~~~~~~~~~~~~~~~~~~~~~~
    preflight.c:48:2: error: redeclaration of enumerator ‘CONNECTION_USBMUXD’
      CONNECTION_USBMUXD = 1,
      ^~~~~~~~~~~~~~~~~~
    In file included from preflight.c:34:
    /opt/libimobiledevice-1.2.1/include/libimobiledevice/libimobiledevice.h:64:2: note: previous definition of ‘CONNECTION_USBMUXD’ was here
      CONNECTION_USBMUXD = 1,
      ^~~~~~~~~~~~~~~~~~
    preflight.c:49:2: error: redeclaration of enumerator ‘CONNECTION_NETWORK’
      CONNECTION_NETWORK
      ^~~~~~~~~~~~~~~~~~
    In file included from preflight.c:34:
    /opt/libimobiledevice-1.2.1/include/libimobiledevice/libimobiledevice.h:65:2: note: previous definition of ‘CONNECTION_NETWORK’ was here
      CONNECTION_NETWORK
      ^~~~~~~~~~~~~~~~~~
    make[2]: *** [Makefile:497: usbmuxd-preflight.o] Error 1
    make[2]: Leaving directory '/opt/libimobiledevice/usbmuxd/src'
    make[1]: *** [Makefile:423: all-recursive] Error 1
    make[1]: Leaving directory '/opt/libimobiledevice/usbmuxd'
    make: *** [Makefile:355: all] Error 2
    
    opened by exioReed 9
  • Preflight check fails with `lockdown error -8`

    Preflight check fails with `lockdown error -8`

    I am trying to build usbmuxd myself in docker:

    FROM docker.io/ubuntu:22.04 AS BUILD
    
    RUN apt-get update && apt-get install -y git build-essential pkg-config checkinstall libtool-bin autoconf automake libssl-dev libusb-1.0-0-dev
    
    RUN git clone https://github.com/libimobiledevice/libplist.git
    RUN cd libplist && \
        ./autogen.sh --prefix=/usr/ --without-cython && \
        make && \
        make install
    
    RUN git clone https://github.com/libimobiledevice/libimobiledevice-glue.git
    RUN cd libimobiledevice-glue && \
        ./autogen.sh --prefix=/usr/ && \
        make && \
        make install
    
    RUN git clone https://github.com/libimobiledevice/libusbmuxd.git
    RUN cd libusbmuxd && \
        ./autogen.sh --prefix=/usr/ && \
        make && \
        make install
    
    RUN git clone https://github.com/libimobiledevice/libimobiledevice.git
    RUN cd libimobiledevice && \
        ./autogen.sh --prefix=/usr --without-cython && \
        make && \
        make install
    
    RUN git clone https://github.com/libimobiledevice/usbmuxd.git
    RUN cd usbmuxd && \
        ./autogen.sh --prefix=/usr/ --without-systemd && \
        make  && \
        make install
    
    RUN apt-get update && apt-get install -y libssl3 libusb-1.0-0
    
    EXPOSE 5037
    
    CMD ["usbmuxd", "-v", "-f", "--socket", "0.0.0.0:5037", "--disable-hotplug", "-U", "root"]
    

    when I run the container the preflight check always fails:

    [09:08:20.783][3] usbmuxd v1.1.2 starting up
    [09:08:20.784][4] Creating socket
    [09:08:20.784][4] Listening on 0.0.0.0:5037
    [09:08:20.785][4] Not dropping privileges to root
    [09:08:20.785][4] Initializing USB
    [09:08:20.785][3] Using libusb 1.0.25
    [09:08:21.084][4] Registering for libusb hotplug events
    [09:08:21.084][4] Found new device with v/p 05ac:12a8 at 1-17
    [09:08:21.085][4] Setting configuration for device 1-17, from 1 to 4
    [09:08:21.382][4] Found interface 1 with endpoints 04/85 for device 1-17
    [09:08:21.382][4] Using wMaxPacketSize=512 for device 1-17
    [09:08:21.382][4] USB Speed is 480 MBit/s for device 1-17
    [09:08:21.383][4] 1 device detected
    [09:08:21.383][3] Initialization complete
    [09:08:21.383][3] Automatic device discovery on hotplug disabled.
    [09:08:21.383][4] Got lang ID 1033 for device 1-17
    [09:08:21.383][4] Got serial '***' for device 1-17
    [09:08:21.384][3] Connecting to new device on location 0x10011 as ID 1
    [09:08:21.384][3] Connected to v2.0 device 1 on location 0x10011 with serial number ***
    [09:08:21.384][4] preflight_worker_handle_device_add: Starting preflight on device ***...
    [09:08:21.385][1] preflight_worker_handle_device_add: ERROR: Could not connect to lockdownd on device ***, lockdown error -8
    

    Does anyone has a hint what i am doing wrong?

    opened by aluedeke 8
  • Better error handling when saving pair records

    Better error handling when saving pair records

    plist_write_to_filename and buffer_write_to_filename now return 0 if the actual write operation failed (e.g. because access is denied to the file), and set errno if required.

    As a result, an error message is now output to the console when saving the pair record fails.

    opened by qmfrederik 8
  • Allow configuration number 5

    Allow configuration number 5

    Newer iOS devices can expose a video feed which contains a mirror of their main display over USB.

    You need to send a specially-crafted setup packet to the device, after which it will expose a 5th configuration with a new interface - see https://github.com/danielpaulus/quicktime_video_hack for some open source details. By default, usbmuxd will reject this configuration and connect to the 4th configuration.

    I think it makes sense to usbmuxd to enable the 5th configuration if it is available. You can only end up with this configuration if you've sent that setup packet to the device, so it's very likely intentional.

    This reverts 1f8ddeff95884da404a7fbd74d27e04ca8c99a50 / #91 which cites VMware, however, I've validated this scenario on VMware (Ubuntu guest on a Windows host).

    opened by qmfrederik 7
  • idevicebackup2 failure with usbmuxd 1.1.1

    idevicebackup2 failure with usbmuxd 1.1.1

    Hi, updating usbmuxd to 1.1.1 (after upgrading libplist, libusbmuxd, libimobiledevice) leads to failure during idevicebackup2 operations.

    Here is the log from idevicebackup2:

    [====================================              ]  71% Finished
    Receiving files
    [==================================================] 100% (38.5 MB/38.5 MB)       
    [======================================            ]  74% Finished
    Receiving files
    [=======================================           ]  77% Finished/32.7 MB)      
    ERROR: Could not receive from mobilebackup2 (-4)
    Received 1846 files from device.
    Backup Aborted.
    

    Here's the journalctl output with logs from usbmuxd:

    juin 17 23:25:31 scapa usbmuxd[50440]: [23:25:31.467][1] ERROR: client_write: sending to fd 13 failed: Broken pipe
    juin 17 23:25:31 scapa usbmuxd[50440]: [23:25:31.467][1] ERROR: client_write: sending to fd 13 failed: Broken pipe
    juin 17 23:25:31 scapa usbmuxd[50440]: [23:25:31.467][1] connection_teardown: aborting buffer flush to client after error.
    

    And here's the log from idevicesyslog:

    Jun 17 23:35:32 BackupAgent2(MobileDeviceLink)[1138] <Notice>: 1138:1876258816|SocketStreamHandler.c:_SocketLogCallback| ERROR: SocketSend (data): error 32: Broken pipe
    Jun 17 23:35:32 BackupAgent2(MobileDeviceLink)[1138] <Notice>: 1138:1876258816|StreamHandler.c:_WriteFunc| ERROR: Error sending data: Can't send data
    Jun 17 23:35:32 BackupAgent2(MobileDeviceLink)[1138] <Notice>: 1138:1876258816|DeviceLinkConnection.c:_DLSendBytesAndDisconnectOnError| ERROR: Could not send data: 'Error writing data'
    Jun 17 23:35:32 BackupAgent2(liblockdown.dylib)[1138] <Notice>: lockconn_disable_ssl: <private>
    Jun 17 23:35:32 BackupAgent2[1138] <Error>: Computer disconnected: Lost connection
    
    Downgrading to usbmuxd from 20191130 (9af2b12) fixed the issue.
    opened by corsac-s 7
  • lockdown error -5 when attempting to connect iPod Touch

    lockdown error -5 when attempting to connect iPod Touch

    I'm trying to backup all the data from my Partner's old iPod Touch. All of the libimobiledevice commands return a message saying No Device Found.

    The device shows up on lsusb

    Bus 001 Device 006: ID 05ac:129e Apple, Inc. iPod Touch 4.Gen
    

    Running usbmuxd -f gives the following output.

    [15:49:50.234][3] usbmuxd v1.1.1 starting up
    [15:49:50.235][3] Using libusb 1.0.25
    [15:49:50.241][3] Initialization complete
    [15:49:50.249][3] Connecting to new device on location 0x10006 as ID 1
    [15:49:50.250][3] Connected to v2.0 device 1 on location 0x10006 with serial number 608da3e8a75e39c5cd99953626f8c6bf2e36eca6
    [15:49:50.367][1] preflight_worker_handle_device_add: The stored pair record for device 608da3e8a75e39c5cd99953626f8c6bf2e36eca6 is invalid. Removing.
    [15:49:51.061][1] preflight_worker_handle_device_add: ERROR StartSession failed on device 608da3e8a75e39c5cd99953626f8c6bf2e36eca6, lockdown error -5
    

    I'm running Fedora 36 and using the latest builds of everything from the repositories. I seem to remember seeing another bug report that suggested it could be an issue with openssl, but was wondering whether there war any other steps I could try and take?

    Running openssl ciphers -s SSLv3 returns the following output:

    TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256:TLS_AES_128_CCM_SHA256:DHE-RSA-AES256-SHA:DHE-RSA-CAMELLIA256-SHA:DHE-RSA-AES128-SHA:DHE-RSA-CAMELLIA128-SHA:AES256-SHA:CAMELLIA256-SHA:AES128-SHA:CAMELLIA128-SHA
    

    I don't need to regularly mount this to interact with it, just getting it to work once and take a complete backup of all the data is more than sufficient.

    opened by BezPowell 0
  • Support different USB

    Support different USB "modes" (via configuration #5)

    idevices "hide" a couple of useful USB interfaces when the device is first plugged in. These interface can be revealed by:

    • starting "New Movie Recording" in macOS QuickTime reveals an interface called "Valeria" with Apple's proprietary protocol wrapping an H.265 video/audio stream of the device.
    • activating "Internet Sharing" to the connected device from macOS Settings app reveals CDC NCM interfaces used to establish Ethernet over USB between the host and device.

    Under the hood, macOS sends vendor specific control URBs to the device, instructing it to reconnect with a different set of configurations. Both modes add a new configuration (# 5) with both the desired interface (Valeria/CDC NCM) and "Apple USB Multiplexor".

    A previous commit (https://github.com/libimobiledevice/usbmuxd/commit/bf2e2ec054102286ad6ab272be42c21034c136ed) was made to support the former ("Valeria") mode. This commit assumes that the extra configuration has 3 interfaces, USBMUX being 3rd, which is not the case for CDC NCM (2nd out of 4).

    The latter mode can be considered more valuable on Linux, as it has an out-of-the-box support with the cdc_ncm USB driver module. Once the device is switched to the correct mode and configuration 5 is set, a new Network Interface is added to the system, which can then be easily controlled via UI ("Share this connection ...") or nft/iptables.

    To prevent usbmuxd from conflicting with Ethernet/USB, and also to allow users to switch to those modes, I suggest the following changes (which I plan to soon submit a PR for):

    • Add an environment variable to the service (USBMUXD_DEFAULT_DEVICE_MODE) that the user can set to control the desired mode: 0 ignore mode and connect to USBMUX interface on highest available configuration (usually 4) 1 if needed, switch to initial mode before connecting to USBMUX interface on highest available configuration (usually 4) 2 if needed, switch to "Valeria" mode before connecting to USBMUX interface on highest available configuration (usually 5) 3 if needed, switch to "Ethernet/USB" mode before connecting to USBMUX interface on highest available configuration (usually 5)
    • Factor out most of usb_device_add functionality (that is, the part that finds the suitable configuration/interface/endpoint and adds the device to the "live" list) into usb_device_complete_initialization
    • Instead, usb_device_add will use libusb async APIs to send a vendor-specific control message to the newly connected device, requesting for its current mode.
    • Once the message completes (or fails), the callback function will either call usb_device_complete_initialization, or send another vendor-specific control message to switch to the desired mode.
    • If switching the mode, the device will reconnect, and usb_device_complete_initialization will be called after validating the desired mode.
    opened by EliyahuStern 1
  • Compatibility matrix

    Compatibility matrix

    Iphone SE IOS 16.1 tethering mode with v1.1.1

    We manage to have a connection between computer and Iphone (connection does not seem always being reliable) We can ping google. But for unknown reasons we can not open a webpage . pb may be related to kernel driver which is 3.18.20

    opened by sancelot 0
  • where to find detail tutorial of cross-compiling for ARM

    where to find detail tutorial of cross-compiling for ARM

    i want build usbmuxd cross-compiling for ARM. there is not step how to cross-compiling in homepage. i found Makefile.am in doc folder. how to use it. is any detail tutorial?

    opened by railsfans 0
  • libusb init error on android

    libusb init error on android

    I want to run usbmuxd on android. But usbmuxd cannot run libusb. When I run libusby via jni in c file it works and sees the device. But when I init via usbmuxd it doesn't work. I added the following code to init.

    ` int usb_init_android(int fileDescriptor) { int res; const struct libusb_version* libusb_version_info = libusb_get_version();

    devlist_failures = 0;
    device_polling = 1;
    
    libusb_context *ctx = NULL;
        libusb_device_handle *devh = NULL;
        int r = 0;
        //r = libusb_set_option(NULL, LIBUSB_OPTION_NO_DEVICE_DISCOVERY, NULL);
     r = libusb_set_option(&ctx, LIBUSB_OPTION_NO_DEVICE_DISCOVERY, NULL);
        if (r != LIBUSB_SUCCESS) {
    	usbmuxd_log(LL_NOTICE, "libusb_set_option failed: %d\n", r);
    	return -1;
        }
        r = libusb_init(&ctx);
        if (r < 0) {
    	usbmuxd_log(LL_NOTICE, "libusb_init failed: %d\n", r);
    	return r;
        }
        r = libusb_wrap_sys_device(ctx, (intptr_t)fileDescriptor, &devh);
        if (r < 0) {
    	    usbmuxd_log(LL_NOTICE, "libusb_wrap_sys_device failed 111: %d\n", r);
    	  r = libusb_wrap_sys_device(NULL, (intptr_t)fileDescriptor, &devh);
    	    if (r < 0) {		    
    		usbmuxd_log(LL_NOTICE, "libusb_wrap_sys_device failed 222: %d\n", r);
    		return r;
        		}`
    
    opened by hcropps 0
Releases(1.1.1)
  • 1.1.1(Jun 15, 2020)

    Homepage

    1.1.1 (2020-06-15)

    Maintenance release.

    Features

    • Make use of libusb hotplug events for device discovery
    • Get correct USB device speed instead of hardcoded value
    • Bump libusb dependency to 1.0.9
    • Use non-blocking sockets for client communication to avoid hanging
    • Use correct manual section (8) for manpage
    • Log pid of connecting clients if supported
    • Implement device discovery using libusb hotplug events
    • Log error message if writing a config file fails
    • Tag all udev events with systemd tag
    • Set socket options for client connections to improve performance
    • Implement ListListeners usbmux command handling
    • Bump libimobiledevice dependency to 1.3.0
    • Bump libplist dependency to 2.2.0
    • Add support for iPhone XS/XR UDID format
    • Add option to allow logging to dedicated logfile
    • Convert README file to markdown format
    • Add support for connecting with T2 chip
    • Show actual libusb version in debug message on startup
    • Enable libusb debugging output
    • Log client process name alongside pid if possible on Linux
    • Unify and improve log message output
    • Improve README.md with project description, installation, contributing and usage sections

    Bug Fixes

    • Use clock_gettime() instead of gettimeofday() to avoid timing issues when calculating packet timeouts
    • Fix wrong timeout value in debug messages
    • Fix blocking by using libusb asynchronous I/O for getting initial device information
    • Fix occasional USB reconfiguration due to udev rules being run again
    • Fix wrong timestamps when running in foreground
    • Fix USB reconnection issues on virtual machines with iOS 11+ devices
    • Various memory leak, deadlock and invalid free fixes
    Source code(tar.gz)
    Source code(zip)
    usbmuxd-1.1.1.tar.bz2(337.19 KB)
Owner
libimobiledevice
A cross-platform protocol library to access iOS devices
libimobiledevice
Wrapper for linux TCP/UDP/unix/USB socket connections

Socket Connection wrapper shared library Shared library that realize sockets connections and could transfer data-packages. Navigation Navigation Insta

Dmitry Golgovsky 7 Dec 21, 2021
The program shows how bluetooth devices are connected, without using socket programming

The program shows how bluetooth devices are connected, without using socket programming, it shows how files are shared using principles of OOP

SAKSHI JAIN 2 Oct 5, 2022
Phorklift is an HTTP server and proxy daemon, with clear, powerful and dynamic configuration.

Phorklift is an HTTP server and proxy daemon, with clear, powerful and dynamic configuration.

null 43 Mar 1, 2022
null 4 Feb 25, 2022
Windows named pipe server that forwards connections to given TCP server

PipeTcp An asynchronous Windows named pipe server that forwards connections to given TCP server. Pre-built binaries can be found in Releases. Invocati

Jinoh Kang 5 Nov 3, 2022
A protocol for secure client/server connections over UDP

netcode netcode is a simple connection based client/server protocol built on top of UDP. It has the following features: Encrypted and signed packets S

The Network Protocol Company 2.3k Dec 26, 2022
A protocol for secure client/server connections over UDP

netcode netcode is a simple connection based client/server protocol built on top of UDP. It has the following features: Encrypted and signed packets S

The Network Protocol Company 2.3k Jan 3, 2023
Dhcpd is a dhcp daemon uses dhcp-{project} libs on this repository

dhcpd Dhcpd is a dhcp server daemon. Uses dhcp-lease dhcp-network Dependencies cunit sqlite3 (for lease module) python3 (for lease module) features sq

Ali 2 Nov 17, 2021
a CLAT configuration daemon for OpenBSD

GELATOD(8) - System Manager's Manual NAME gelatod - a CLAT configuration daemon SYNOPSIS gelatod [-dv] DESCRIPTION gelatod is a CLAT (Customer-side tr

Florian Obser 7 Dec 14, 2022
An optimized Webcash mining daemon.

Webminer An experimental vector-accelerated CPU miner for the Webcash electronic payment network. Webminer is tested and known to work on recent versi

Mark Friedenbach 20 Nov 30, 2022
Dohd is a minimalist DNS-over-HTTPS daemon that redirects all DoH queries to a local DNS server running on localhost:53 (UDP)

dohd Dohd (pron. doh-dee) is a minimalist DNS-over-HTTPS daemon that redirects all DoH queries to a local DNS server running on localhost:53 (UDP). Fe

Dyne.org 16 Dec 1, 2022
Simple server and client using python socket and declarative programming

Socket-programming Simple server and client using python socket and declarative programming How to use? open cmd and navigate to the location of the s

MAINAK CHAUDHURI 24 Dec 17, 2022
As a Teaching Assistant, this is a sample project about socket programming for my teaching in a capstone course in NTUST(National Taiwan University of Science and Technology)

socket-programming As a Teaching Assistant, this is a sample project about socket programming for my teaching in a capstone course in NTUST(National T

Chang Wei 2 Oct 26, 2021
Provide translation, currency conversion, and voting services. First using telnet you create a connection to a TCP socket, then the server connects to 3 UDP sockets hosted on other servers to do tasks.

to run micro servers g++ translator.cpp -o translator ./translator <port 1> g++ voting.cpp -o voting ./voting <port 2> g++ currency_converter.cpp -o c

Jacob Artuso 1 Oct 29, 2021
A single-header socket library for both Linux and Windows

COMS What is COMS? COMS is a single-header library designed to be simple to use. It supports TCP and UDP, Server and Client. Available for Windows and

null 5 Dec 23, 2021
Socket and Networking Library using msgpack.org[C++11]

netLink C++ 11 KISS principle networking library. Features: C++ 11 IPv4, IPv6 Protocols: TCP, UDP Enable/Disable blocking mode Join/Leave UDP-Multicas

Alexander Meißner 210 Oct 18, 2022
Portable, single-file, protocol-agnostic TCP and UDP socket wrapper, primarily for game networking

Documentation This is a header-only library, as such most of its functional documentation is contained within the "header section" of the source code

null 64 Dec 3, 2022
C++11 implementation of Socket.IO client

By virtue of being written in C++, this client works in several different platforms. The examples folder contains an iPhone, QT and Console example chat client! It depends on websocket++ and is inspired by socket.io-clientpp.

Socket.IO 2k Jan 3, 2023
HP-Socket bindings for aardio

HP-Socket-bindings-for-aardio HP-Socket is a high performance network framework. aardio is an extremely easy-to-use dynamic language, but it is also a

null 9 Jan 3, 2022