Skip to content

Commit acb258a

Browse files
committed
PoC of usbflux/usbfluxd
1 parent 0524326 commit acb258a

26 files changed

+7026
-0
lines changed

.gitignore

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# git-ls-files --others --exclude-from=.git/info/exclude
2+
# Lines that start with '#' are comments.
3+
# For a project mostly in C, the following would be a good set of
4+
# exclude patterns (uncomment them if you want to use them):
5+
*.[oa]
6+
*~
7+
*.po
8+
*.lo
9+
*.la
10+
autom4te.cache/*
11+
*.in
12+
*/.deps/*
13+
m4/*
14+
swig/*
15+
*.swp
16+
*.patch
17+
aclocal.m4
18+
config.h
19+
config.log
20+
config.sub
21+
config.guess
22+
config.status
23+
configure
24+
depcomp
25+
install-sh
26+
compile
27+
main
28+
ltmain.sh
29+
missing
30+
mkinstalldirs
31+
libtool
32+
*Makefile
33+
py-compile
34+
stamp-h1
35+
src/.libs
36+
src/usbflux

AUTHORS

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Aaron Burghardt
2+
Bastien Nocera
3+
Cerrato Renaud
4+
Christophe Fergeau
5+
David Sansome
6+
Hector Martin
7+
Jacob Myers
8+
John Maguire
9+
Martin Szulecki
10+
Mikkel Kamstrup Erlandsen
11+
Nikias Bassen
12+
Paul Sladen
13+
Peter Wu
14+
Satoshi Ohgoh

COPYING.GPLv2

+340
Large diffs are not rendered by default.

COPYING.GPLv3

+674
Large diffs are not rendered by default.

Makefile.am

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
AUTOMAKE_OPTIONS = foreign
2+
ACLOCAL_AMFLAGS = -I m4
3+
SUBDIRS = src
4+
5+
EXTRA_DIST = COPYING.GPLv2 COPYING.GPLv3
6+

NEWS

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
Version 1.1.1
2+
~~~~~~~~~~~~~
3+
4+
* Changes:
5+
- Make use of libusb hotplug events for device discovery
6+
- Use clock_gettime() instead of gettimeofday() to avoid timing issues
7+
when calculating packet timeouts
8+
- Get correct USB device speed instead of hardcoded value
9+
- Use non-blocking sockets for client communication to avoid hanging
10+
- Use correct manual section (8) for manpage
11+
12+
Version 1.1.0
13+
~~~~~~~~~~~~~
14+
15+
* Changes:
16+
- Check for pkg-config availability in autogen.sh
17+
- Fix missing "usbmuxd-proto.h" in released tarbal
18+
- Fix typo which broke udev support in rule for udev activation mode
19+
- Fix broken configure summary on OS X and change activation method
20+
to "manual"
21+
- Compile bits of udev and systemd support only if needed
22+
- Bump autoconf requirement to 2.64
23+
24+
Version 1.0.9
25+
~~~~~~~~~~~~~
26+
27+
* Changes:
28+
- Fix broken handling of "--user" argument value
29+
- Add new "--enable-exit" argument to enable handling of "--exit" requests
30+
- Add new "--disable-hotplug" argument to disable automatic device discovery
31+
- Add new "--systemd" argument to startup with right settings for systemd
32+
- Add man page for usbmuxd
33+
- Update copyright headers to match best practice
34+
- Flush input buffer on connection teardown
35+
- Add systemd based activation with fallback for udev and manual activation
36+
- Add initial NEWS file and update README with latest information
37+
- Rename header guards according to C++ standard
38+
- Implement support for usbmux protocol version 2 which improves stability
39+
- Fix crash when old libusbmuxd was used as a client
40+
- Add "--version" argument to print version number and exit
41+
- Update command line usage to match best practice and other tools
42+
- Massively improve read performance by using 3 parallel transfers
43+
- Bump requirement to libplist 1.11
44+
- Remove trailing "\n" from usbmuxd_log() messages
45+
- Improve thread safety
46+
- Fix crash on 64bit systems in process_send()
47+
- Fix possible leak of file descriptors
48+
- Implement "ReadBUID", "ReadPairRecord", "SavePairRecord" and
49+
"DeletePairRecord" commands
50+
- Make plist based protocol support mandatory
51+
- Return proper error packet on client version mismatch
52+
- Implement "ListDevices" command
53+
- Manage pair records in a directory compatible to native usbmuxd
54+
- Output USB configuration changes in log
55+
- Set "deactivated" USB configuration on iOS device by default as usbmuxd will
56+
bring device to "life" on it's own now
57+
- Add udev rule installation with autotools
58+
- Lower udev rules numbering to make sure to start as early as possible
59+
- Split out client library into "libusbmuxd" and depend on "libimobiledevice"
60+
- Implement preflight worker to support iOS 7 based trust dialog handling
61+
- Install usbmuxd binary to sbindir instead of bindir
62+
- Switch from CMake to autotools build system
63+
64+
This is the first release after the usbmuxd/libusbmuxd project split.

README

+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
About
2+
=====
3+
4+
A socket daemon to multiplex connections from and to iOS devices.
5+
6+
Background
7+
==========
8+
9+
usbmuxd stands for "USB multiplexing daemon". This daemon is in charge of
10+
multiplexing connections over USB to an iOS device. To users, it means
11+
you can sync your music, contacts, photos, etc. over USB. To developers, it
12+
means you can connect to any listening localhost socket on the device. usbmuxd
13+
is not used for tethering data transfer which uses a dedicated USB interface as
14+
a virtual network device. Multiple connections to different TCP ports can happen
15+
in parallel. The higher-level layers are handled by libimobiledevice.
16+
17+
When usbmuxd is running (normally started, or stopped as a result of "udev"
18+
auto-insertion messages or by systemd) it provides a socket interface in
19+
"/var/run/usbmuxd" that is designed to be compatible with the socket interface
20+
that is provided on Mac OS X.
21+
22+
You should also create a "usbmux" user that has access to USB devices on your
23+
system. Alternatively, you can pass a different username using the -U argument.
24+
25+
Due to iOS 7 the daemon now also manages pairing records with iOS devices and
26+
the host in "/var/lib/lockdown" (Linux) or "/var/db/lockdown" (Mac OS X).
27+
Ensure proper permissions are setup for the daemon to access the directory.
28+
29+
Requirements
30+
============
31+
32+
Development Packages of:
33+
libimobiledevice
34+
libplist
35+
libusb
36+
37+
Software:
38+
make
39+
autoheader
40+
automake
41+
autoconf
42+
libtool
43+
pkg-config
44+
gcc
45+
udev (Linux only)
46+
47+
Optional:
48+
systemd (Linux only)
49+
50+
Installation
51+
============
52+
53+
To compile run:
54+
./autogen.sh
55+
make
56+
sudo make install
57+
58+
The daemon is automatically started by udev or systemd depending on what you
59+
have configured it on hotplug of an iOS device and exits if the last device
60+
was unplugged.
61+
62+
For debugging purposes it is helpful to start usbmuxd using the foreground '-f'
63+
argument and enable verbose mode '-v' to get suitable logs.
64+
65+
Who/What/Where?
66+
===============
67+
68+
Home:
69+
http://www.libimobiledevice.org/
70+
71+
Code:
72+
git clone http://git.libimobiledevice.org/usbmuxd.git
73+
74+
Code (Mirror):
75+
git clone https://github.com/libimobiledevice/usbmuxd.git
76+
77+
Tickets:
78+
http://github.com/libimobiledevice/usbmuxd/issues
79+
80+
Mailing List:
81+
http://lists.libimobiledevice.org/mailman/listinfo/libimobiledevice-devel
82+
83+
IRC:
84+
irc://irc.freenode.net#libimobiledevice
85+
86+
Twitter:
87+
https://twitter.com/libimobiledev
88+
89+
Credits
90+
=======
91+
92+
The first usbmuxd daemon implementation was authored by Hector Martin.
93+
94+
Apple, iPhone, iPod, and iPod Touch are trademarks of Apple Inc.
95+
libimobiledevice is an independent software library and has not been
96+
authorized, sponsored, or otherwise approved by Apple Inc.
97+
98+
README Updated on:
99+
2015-01-28

autogen.sh

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/sh
2+
gprefix=`which glibtoolize 2>&1 >/dev/null`
3+
if [ $? -eq 0 ]; then
4+
glibtoolize --force
5+
else
6+
libtoolize --force
7+
fi
8+
aclocal -I m4
9+
autoheader
10+
automake --add-missing
11+
autoconf
12+
requires_pkgconfig=`which pkg-config 2>&1 >/dev/null`
13+
if [ $? -ne 0 ]; then
14+
echo "Missing required pkg-config. Please install it on your system and run again."
15+
fi
16+
17+
if [ -z "$NOCONFIGURE" ]; then
18+
./configure "$@"
19+
fi

configure.ac

+124
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# -*- Autoconf -*-
2+
# Process this file with autoconf to produce a configure script.
3+
4+
AC_PREREQ(2.64)
5+
AC_INIT([usbfluxd], [1.1.1], [https://github.com/libimobiledevice/usbmuxd/issues],, [http://libimobiledevice.org])
6+
AM_INIT_AUTOMAKE([dist-bzip2 no-dist-gzip check-news])
7+
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES])
8+
AC_CONFIG_SRCDIR([src/])
9+
AC_CONFIG_HEADERS([config.h])
10+
AC_CONFIG_MACRO_DIR([m4])
11+
12+
# Checks for programs.
13+
AC_PROG_CC
14+
AC_PROG_CXX
15+
AM_PROG_CC_C_O
16+
AC_PROG_LIBTOOL
17+
18+
# Checks for libraries.
19+
PKG_CHECK_MODULES(libusb, libusb-1.0 >= 1.0.9)
20+
PKG_CHECK_MODULES(libplist, libplist >= 1.11)
21+
PKG_CHECK_MODULES(libimobiledevice, libimobiledevice-1.0 >= 1.1.6, have_limd=yes, have_limd=no)
22+
AC_CHECK_LIB(pthread, [pthread_create, pthread_mutex_lock], [AC_SUBST(libpthread_LIBS,[-lpthread])], [AC_MSG_ERROR([libpthread is required to build usbfluxd])])
23+
24+
AC_ARG_WITH([preflight],
25+
[AS_HELP_STRING([--without-preflight],
26+
[do not build with preflight worker support @<:@default=yes@:>@])],
27+
[with_preflight=no],
28+
[with_preflight=yes])
29+
30+
if test "x$have_limd" = "xyes"; then
31+
if test "x$with_preflight" != "xyes"; then
32+
have_limd=no
33+
echo "*** Note: preflight worker support has been disabled ***"
34+
else
35+
AC_DEFINE(HAVE_LIBIMOBILEDEVICE, 1, [Define if you have libimobiledevice support])
36+
AC_SUBST(libimobiledevice_CFLAGS)
37+
AC_SUBST(libimobiledevice_LIBS)
38+
fi
39+
else
40+
if test "x$with_preflight" == "xyes"; then
41+
AC_MSG_ERROR([preflight worker support requested but libimobiledevice could not be found])
42+
fi
43+
fi
44+
45+
# Checks for header files.
46+
AC_HEADER_STDC
47+
AC_CHECK_HEADERS([stdint.h stdlib.h string.h])
48+
49+
# Checks for typedefs, structures, and compiler characteristics.
50+
AC_C_CONST
51+
AC_TYPE_SIZE_T
52+
AC_TYPE_SSIZE_T
53+
AC_TYPE_UINT16_T
54+
AC_TYPE_UINT32_T
55+
AC_TYPE_UINT8_T
56+
57+
# Checks for library functions.
58+
AC_FUNC_MALLOC
59+
AC_FUNC_REALLOC
60+
AC_CHECK_FUNCS([strcasecmp strdup strerror strndup stpcpy])
61+
AC_CHECK_FUNCS([ppoll clock_gettime])
62+
63+
# Check for operating system
64+
AC_MSG_CHECKING([whether to enable WIN32 build settings])
65+
UDEV_SUB=
66+
SYSTEMD_SUB=
67+
case ${host_os} in
68+
*mingw32*|*cygwin*)
69+
win32=true
70+
AC_MSG_RESULT([yes])
71+
AC_CHECK_TOOL([WINDRES], [windres], AC_MSG_ERROR([windres not found]))
72+
AC_SUBST(WINDRES)
73+
activation_method="manual"
74+
;;
75+
darwin*)
76+
win32=false
77+
AC_MSG_RESULT([no])
78+
# No support for launchd yet
79+
activation_method="manual"
80+
;;
81+
*)
82+
win32=false
83+
AC_MSG_RESULT([no])
84+
UDEV_SUB=udev
85+
AC_SUBST([udevrulesdir], [$with_udevrulesdir])
86+
AC_DEFINE(HAVE_UDEV, 1, [Define to enable udev support])
87+
activation_method="systemd"
88+
if test "x$with_systemd" != "xyes"; then
89+
echo "*** Note: support for systemd activation has been disabled, using udev activation instead ***"
90+
activation_method="udev"
91+
else
92+
AC_DEFINE(HAVE_SYSTEMD, 1, [Define to enable systemd support])
93+
SYSTEMD_SUB=systemd
94+
fi
95+
;;
96+
esac
97+
AM_CONDITIONAL(WIN32, test x$win32 = xtrue)
98+
99+
AC_SUBST([UDEV_SUB])
100+
AC_SUBST([SYSTEMD_SUB])
101+
102+
AS_COMPILER_FLAGS(GLOBAL_CFLAGS, "-g -Wall -Wextra -Wmissing-declarations -Wredundant-decls -Wshadow -Wpointer-arith -Wwrite-strings -Wswitch-default -Wno-unused-parameter")
103+
AC_SUBST(GLOBAL_CFLAGS)
104+
105+
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
106+
107+
AC_OUTPUT([
108+
Makefile
109+
src/Makefile
110+
])
111+
112+
echo "
113+
Configuration for $PACKAGE $VERSION:
114+
-------------------------------------------
115+
116+
install prefix ............: $prefix
117+
preflight worker support ..: $have_limd
118+
activation method .........: $activation_method"
119+
120+
echo " compiler ..................: ${CC}
121+
122+
Now type 'make' to build $PACKAGE $VERSION,
123+
and then 'make install' for installation.
124+
"

src/Makefile.am

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)
2+
3+
AM_CFLAGS = $(GLOBAL_CFLAGS) $(libplist_CFLAGS) $(libusb_CFLAGS) $(libimobildevice_CFLAGS)
4+
AM_LDFLAGS = $(libplist_LIBS) $(libusb_LIBS) $(libimobiledevice_LIBS) $(libpthread_LIBS)
5+
6+
sbin_PROGRAMS = usbfluxd
7+
8+
usbfluxd_CFLAGS = $(AM_CFLAGS)
9+
usbfluxd_LDFLAGS = $(AM_LDFLAGS) -no-undefined
10+
usbfluxd_SOURCES = client.c client.h \
11+
device.c device.h \
12+
preflight.c preflight.h \
13+
log.c log.h \
14+
usbmuxd-proto.h usb.c usb.h \
15+
utils.c utils.h \
16+
conf.c conf.h \
17+
main.c

0 commit comments

Comments
 (0)