libusb 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +8 -2
- data/Gemfile +2 -0
- data/History.md +12 -0
- data/README.md +25 -14
- data/Rakefile +64 -109
- data/appveyor.yml +23 -0
- data/ext/extconf.rb +10 -12
- data/ext/libusb_recipe.rb +29 -0
- data/lib/libusb/call.rb +14 -11
- data/lib/libusb/compat.rb +9 -9
- data/lib/libusb/context.rb +16 -1
- data/lib/libusb/dependencies.rb +7 -0
- data/lib/libusb/dev_handle.rb +13 -3
- data/lib/libusb/eventmachine.rb +4 -4
- data/lib/libusb/transfer.rb +71 -10
- data/lib/libusb/version_gem.rb +1 -1
- data/libusb.gemspec +7 -5
- data/ports/archives/libusb-1.0.21.tar.bz2 +0 -0
- data/test/test_libusb_bulk_stream_transfer.rb +1 -1
- data/test/test_libusb_descriptors.rb +4 -4
- data/test/test_libusb_event_machine.rb +7 -7
- data/test/test_libusb_hotplug.rb +15 -3
- data/test/test_libusb_iso_transfer.rb +1 -1
- data/test/test_libusb_mass_storage.rb +19 -19
- data/test/test_libusb_mass_storage2.rb +1 -1
- data/test/test_libusb_structs.rb +13 -0
- data/test/test_libusb_threads.rb +2 -2
- data/wireshark-usb-sniffer.png +0 -0
- metadata +32 -156
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/ext/libusb-1.0.20/AUTHORS +0 -89
- data/ext/libusb-1.0.20/COPYING +0 -504
- data/ext/libusb-1.0.20/ChangeLog +0 -227
- data/ext/libusb-1.0.20/INSTALL +0 -234
- data/ext/libusb-1.0.20/Makefile.am +0 -28
- data/ext/libusb-1.0.20/Makefile.in +0 -897
- data/ext/libusb-1.0.20/NEWS +0 -2
- data/ext/libusb-1.0.20/PORTING +0 -94
- data/ext/libusb-1.0.20/README +0 -29
- data/ext/libusb-1.0.20/TODO +0 -2
- data/ext/libusb-1.0.20/Xcode/common.xcconfig +0 -49
- data/ext/libusb-1.0.20/Xcode/config.h +0 -28
- data/ext/libusb-1.0.20/Xcode/debug.xcconfig +0 -29
- data/ext/libusb-1.0.20/Xcode/libusb.xcconfig +0 -21
- data/ext/libusb-1.0.20/Xcode/libusb.xcodeproj/project.pbxproj +0 -865
- data/ext/libusb-1.0.20/Xcode/libusb_debug.xcconfig +0 -21
- data/ext/libusb-1.0.20/Xcode/libusb_release.xcconfig +0 -21
- data/ext/libusb-1.0.20/Xcode/release.xcconfig +0 -30
- data/ext/libusb-1.0.20/aclocal.m4 +0 -1193
- data/ext/libusb-1.0.20/android/README +0 -114
- data/ext/libusb-1.0.20/android/config.h +0 -81
- data/ext/libusb-1.0.20/android/jni/Android.mk +0 -23
- data/ext/libusb-1.0.20/android/jni/Application.mk +0 -24
- data/ext/libusb-1.0.20/android/jni/examples.mk +0 -134
- data/ext/libusb-1.0.20/android/jni/libusb.mk +0 -54
- data/ext/libusb-1.0.20/android/jni/tests.mk +0 -56
- data/ext/libusb-1.0.20/compile +0 -347
- data/ext/libusb-1.0.20/config.guess +0 -1421
- data/ext/libusb-1.0.20/config.h.in +0 -155
- data/ext/libusb-1.0.20/config.sub +0 -1807
- data/ext/libusb-1.0.20/configure +0 -15466
- data/ext/libusb-1.0.20/configure.ac +0 -326
- data/ext/libusb-1.0.20/depcomp +0 -791
- data/ext/libusb-1.0.20/doc/Makefile.am +0 -9
- data/ext/libusb-1.0.20/doc/Makefile.in +0 -456
- data/ext/libusb-1.0.20/doc/doxygen.cfg.in +0 -2334
- data/ext/libusb-1.0.20/examples/Makefile.am +0 -19
- data/ext/libusb-1.0.20/examples/Makefile.in +0 -713
- data/ext/libusb-1.0.20/examples/dpfp.c +0 -506
- data/ext/libusb-1.0.20/examples/dpfp_threaded.c +0 -549
- data/ext/libusb-1.0.20/examples/ezusb.c +0 -831
- data/ext/libusb-1.0.20/examples/ezusb.h +0 -120
- data/ext/libusb-1.0.20/examples/fxload.c +0 -308
- data/ext/libusb-1.0.20/examples/getopt/getopt.c +0 -1060
- data/ext/libusb-1.0.20/examples/getopt/getopt.h +0 -180
- data/ext/libusb-1.0.20/examples/getopt/getopt1.c +0 -188
- data/ext/libusb-1.0.20/examples/hotplugtest.c +0 -122
- data/ext/libusb-1.0.20/examples/listdevs.c +0 -71
- data/ext/libusb-1.0.20/examples/sam3u_benchmark.c +0 -193
- data/ext/libusb-1.0.20/examples/xusb.c +0 -1130
- data/ext/libusb-1.0.20/install-sh +0 -501
- data/ext/libusb-1.0.20/libusb-1.0.pc.in +0 -11
- data/ext/libusb-1.0.20/libusb/Makefile.am +0 -90
- data/ext/libusb-1.0.20/libusb/Makefile.in +0 -1053
- data/ext/libusb-1.0.20/libusb/core.c +0 -2452
- data/ext/libusb-1.0.20/libusb/descriptor.c +0 -1201
- data/ext/libusb-1.0.20/libusb/hotplug.c +0 -344
- data/ext/libusb-1.0.20/libusb/hotplug.h +0 -90
- data/ext/libusb-1.0.20/libusb/io.c +0 -2760
- data/ext/libusb-1.0.20/libusb/libusb-1.0.def +0 -168
- data/ext/libusb-1.0.20/libusb/libusb-1.0.rc +0 -61
- data/ext/libusb-1.0.20/libusb/libusb.h +0 -1999
- data/ext/libusb-1.0.20/libusb/libusbi.h +0 -1102
- data/ext/libusb-1.0.20/libusb/os/darwin_usb.c +0 -1969
- data/ext/libusb-1.0.20/libusb/os/darwin_usb.h +0 -158
- data/ext/libusb-1.0.20/libusb/os/haiku/Makefile.am +0 -5
- data/ext/libusb-1.0.20/libusb/os/haiku/Makefile.in +0 -810
- data/ext/libusb-1.0.20/libusb/os/haiku/aclocal.m4 +0 -1193
- data/ext/libusb-1.0.20/libusb/os/haiku/compile +0 -347
- data/ext/libusb-1.0.20/libusb/os/haiku/config.guess +0 -1421
- data/ext/libusb-1.0.20/libusb/os/haiku/config.sub +0 -1807
- data/ext/libusb-1.0.20/libusb/os/haiku/configure +0 -17579
- data/ext/libusb-1.0.20/libusb/os/haiku/configure.ac +0 -8
- data/ext/libusb-1.0.20/libusb/os/haiku/depcomp +0 -791
- data/ext/libusb-1.0.20/libusb/os/haiku/haiku_pollfs.cpp +0 -378
- data/ext/libusb-1.0.20/libusb/os/haiku/haiku_usb.h +0 -112
- data/ext/libusb-1.0.20/libusb/os/haiku/haiku_usb_backend.cpp +0 -550
- data/ext/libusb-1.0.20/libusb/os/haiku/haiku_usb_raw.cpp +0 -255
- data/ext/libusb-1.0.20/libusb/os/haiku/haiku_usb_raw.h +0 -180
- data/ext/libusb-1.0.20/libusb/os/haiku/install-sh +0 -501
- data/ext/libusb-1.0.20/libusb/os/haiku/ltmain.sh +0 -9655
- data/ext/libusb-1.0.20/libusb/os/haiku/m4/libtool.m4 +0 -7992
- data/ext/libusb-1.0.20/libusb/os/haiku/m4/ltoptions.m4 +0 -384
- data/ext/libusb-1.0.20/libusb/os/haiku/m4/ltsugar.m4 +0 -123
- data/ext/libusb-1.0.20/libusb/os/haiku/m4/ltversion.m4 +0 -23
- data/ext/libusb-1.0.20/libusb/os/haiku/m4/lt~obsolete.m4 +0 -98
- data/ext/libusb-1.0.20/libusb/os/haiku/missing +0 -215
- data/ext/libusb-1.0.20/libusb/os/linux_netlink.c +0 -369
- data/ext/libusb-1.0.20/libusb/os/linux_udev.c +0 -306
- data/ext/libusb-1.0.20/libusb/os/linux_usbfs.c +0 -2692
- data/ext/libusb-1.0.20/libusb/os/linux_usbfs.h +0 -192
- data/ext/libusb-1.0.20/libusb/os/netbsd_usb.c +0 -674
- data/ext/libusb-1.0.20/libusb/os/openbsd_usb.c +0 -768
- data/ext/libusb-1.0.20/libusb/os/poll_posix.c +0 -53
- data/ext/libusb-1.0.20/libusb/os/poll_posix.h +0 -11
- data/ext/libusb-1.0.20/libusb/os/poll_windows.c +0 -728
- data/ext/libusb-1.0.20/libusb/os/poll_windows.h +0 -131
- data/ext/libusb-1.0.20/libusb/os/threads_posix.c +0 -82
- data/ext/libusb-1.0.20/libusb/os/threads_posix.h +0 -50
- data/ext/libusb-1.0.20/libusb/os/threads_windows.c +0 -214
- data/ext/libusb-1.0.20/libusb/os/threads_windows.h +0 -87
- data/ext/libusb-1.0.20/libusb/os/wince_usb.c +0 -869
- data/ext/libusb-1.0.20/libusb/os/wince_usb.h +0 -131
- data/ext/libusb-1.0.20/libusb/os/windows_common.h +0 -108
- data/ext/libusb-1.0.20/libusb/os/windows_usb.c +0 -4643
- data/ext/libusb-1.0.20/libusb/os/windows_usb.h +0 -973
- data/ext/libusb-1.0.20/libusb/strerror.c +0 -202
- data/ext/libusb-1.0.20/libusb/sync.c +0 -308
- data/ext/libusb-1.0.20/libusb/version.h +0 -18
- data/ext/libusb-1.0.20/libusb/version_nano.h +0 -1
- data/ext/libusb-1.0.20/ltmain.sh +0 -9655
- data/ext/libusb-1.0.20/m4/libtool.m4 +0 -7992
- data/ext/libusb-1.0.20/m4/ltoptions.m4 +0 -384
- data/ext/libusb-1.0.20/m4/ltsugar.m4 +0 -123
- data/ext/libusb-1.0.20/m4/ltversion.m4 +0 -23
- data/ext/libusb-1.0.20/m4/lt~obsolete.m4 +0 -98
- data/ext/libusb-1.0.20/missing +0 -215
- data/ext/libusb-1.0.20/tests/Makefile.am +0 -6
- data/ext/libusb-1.0.20/tests/Makefile.in +0 -596
- data/ext/libusb-1.0.20/tests/libusb_testlib.h +0 -107
- data/ext/libusb-1.0.20/tests/stress.c +0 -160
- data/ext/libusb-1.0.20/tests/testlib.c +0 -277
- metadata.gz.sig +0 -0
@@ -1,23 +0,0 @@
|
|
1
|
-
# ltversion.m4 -- version numbers -*- Autoconf -*-
|
2
|
-
#
|
3
|
-
# Copyright (C) 2004 Free Software Foundation, Inc.
|
4
|
-
# Written by Scott James Remnant, 2004
|
5
|
-
#
|
6
|
-
# This file is free software; the Free Software Foundation gives
|
7
|
-
# unlimited permission to copy and/or distribute it, with or without
|
8
|
-
# modifications, as long as this notice is preserved.
|
9
|
-
|
10
|
-
# @configure_input@
|
11
|
-
|
12
|
-
# serial 3337 ltversion.m4
|
13
|
-
# This file is part of GNU Libtool
|
14
|
-
|
15
|
-
m4_define([LT_PACKAGE_VERSION], [2.4.2])
|
16
|
-
m4_define([LT_PACKAGE_REVISION], [1.3337])
|
17
|
-
|
18
|
-
AC_DEFUN([LTVERSION_VERSION],
|
19
|
-
[macro_version='2.4.2'
|
20
|
-
macro_revision='1.3337'
|
21
|
-
_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
|
22
|
-
_LT_DECL(, macro_revision, 0)
|
23
|
-
])
|
@@ -1,98 +0,0 @@
|
|
1
|
-
# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*-
|
2
|
-
#
|
3
|
-
# Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc.
|
4
|
-
# Written by Scott James Remnant, 2004.
|
5
|
-
#
|
6
|
-
# This file is free software; the Free Software Foundation gives
|
7
|
-
# unlimited permission to copy and/or distribute it, with or without
|
8
|
-
# modifications, as long as this notice is preserved.
|
9
|
-
|
10
|
-
# serial 5 lt~obsolete.m4
|
11
|
-
|
12
|
-
# These exist entirely to fool aclocal when bootstrapping libtool.
|
13
|
-
#
|
14
|
-
# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN)
|
15
|
-
# which have later been changed to m4_define as they aren't part of the
|
16
|
-
# exported API, or moved to Autoconf or Automake where they belong.
|
17
|
-
#
|
18
|
-
# The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN
|
19
|
-
# in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us
|
20
|
-
# using a macro with the same name in our local m4/libtool.m4 it'll
|
21
|
-
# pull the old libtool.m4 in (it doesn't see our shiny new m4_define
|
22
|
-
# and doesn't know about Autoconf macros at all.)
|
23
|
-
#
|
24
|
-
# So we provide this file, which has a silly filename so it's always
|
25
|
-
# included after everything else. This provides aclocal with the
|
26
|
-
# AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything
|
27
|
-
# because those macros already exist, or will be overwritten later.
|
28
|
-
# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6.
|
29
|
-
#
|
30
|
-
# Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here.
|
31
|
-
# Yes, that means every name once taken will need to remain here until
|
32
|
-
# we give up compatibility with versions before 1.7, at which point
|
33
|
-
# we need to keep only those names which we still refer to.
|
34
|
-
|
35
|
-
# This is to help aclocal find these macros, as it can't see m4_define.
|
36
|
-
AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])])
|
37
|
-
|
38
|
-
m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])])
|
39
|
-
m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])])
|
40
|
-
m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])])
|
41
|
-
m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])])
|
42
|
-
m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])])
|
43
|
-
m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])])
|
44
|
-
m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])])
|
45
|
-
m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])])
|
46
|
-
m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])])
|
47
|
-
m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])])
|
48
|
-
m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])])
|
49
|
-
m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])])
|
50
|
-
m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])])
|
51
|
-
m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])])
|
52
|
-
m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])])
|
53
|
-
m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])])
|
54
|
-
m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])])
|
55
|
-
m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])])
|
56
|
-
m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])])
|
57
|
-
m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])])
|
58
|
-
m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])])
|
59
|
-
m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])])
|
60
|
-
m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])])
|
61
|
-
m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])])
|
62
|
-
m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])])
|
63
|
-
m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])])
|
64
|
-
m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])])
|
65
|
-
m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])])
|
66
|
-
m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])])
|
67
|
-
m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])])
|
68
|
-
m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])])
|
69
|
-
m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])])
|
70
|
-
m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])])
|
71
|
-
m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])])
|
72
|
-
m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])])
|
73
|
-
m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])])
|
74
|
-
m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])])
|
75
|
-
m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])])
|
76
|
-
m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])])
|
77
|
-
m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])])
|
78
|
-
m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])])
|
79
|
-
m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])])
|
80
|
-
m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])])
|
81
|
-
m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])])
|
82
|
-
m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])])
|
83
|
-
m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])])
|
84
|
-
m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])])
|
85
|
-
m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])])
|
86
|
-
m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])])
|
87
|
-
m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])])
|
88
|
-
m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])])
|
89
|
-
m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])])
|
90
|
-
m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])])
|
91
|
-
m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])])
|
92
|
-
m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS], [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])])
|
93
|
-
m4_ifndef([_LT_AC_PROG_CXXCPP], [AC_DEFUN([_LT_AC_PROG_CXXCPP])])
|
94
|
-
m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS], [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])])
|
95
|
-
m4_ifndef([_LT_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])])
|
96
|
-
m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])])
|
97
|
-
m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])])
|
98
|
-
m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])])
|
@@ -1,215 +0,0 @@
|
|
1
|
-
#! /bin/sh
|
2
|
-
# Common wrapper for a few potentially missing GNU programs.
|
3
|
-
|
4
|
-
scriptversion=2013-10-28.13; # UTC
|
5
|
-
|
6
|
-
# Copyright (C) 1996-2014 Free Software Foundation, Inc.
|
7
|
-
# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
|
8
|
-
|
9
|
-
# This program is free software; you can redistribute it and/or modify
|
10
|
-
# it under the terms of the GNU General Public License as published by
|
11
|
-
# the Free Software Foundation; either version 2, or (at your option)
|
12
|
-
# any later version.
|
13
|
-
|
14
|
-
# This program is distributed in the hope that it will be useful,
|
15
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17
|
-
# GNU General Public License for more details.
|
18
|
-
|
19
|
-
# You should have received a copy of the GNU General Public License
|
20
|
-
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
21
|
-
|
22
|
-
# As a special exception to the GNU General Public License, if you
|
23
|
-
# distribute this file as part of a program that contains a
|
24
|
-
# configuration script generated by Autoconf, you may include it under
|
25
|
-
# the same distribution terms that you use for the rest of that program.
|
26
|
-
|
27
|
-
if test $# -eq 0; then
|
28
|
-
echo 1>&2 "Try '$0 --help' for more information"
|
29
|
-
exit 1
|
30
|
-
fi
|
31
|
-
|
32
|
-
case $1 in
|
33
|
-
|
34
|
-
--is-lightweight)
|
35
|
-
# Used by our autoconf macros to check whether the available missing
|
36
|
-
# script is modern enough.
|
37
|
-
exit 0
|
38
|
-
;;
|
39
|
-
|
40
|
-
--run)
|
41
|
-
# Back-compat with the calling convention used by older automake.
|
42
|
-
shift
|
43
|
-
;;
|
44
|
-
|
45
|
-
-h|--h|--he|--hel|--help)
|
46
|
-
echo "\
|
47
|
-
$0 [OPTION]... PROGRAM [ARGUMENT]...
|
48
|
-
|
49
|
-
Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
|
50
|
-
to PROGRAM being missing or too old.
|
51
|
-
|
52
|
-
Options:
|
53
|
-
-h, --help display this help and exit
|
54
|
-
-v, --version output version information and exit
|
55
|
-
|
56
|
-
Supported PROGRAM values:
|
57
|
-
aclocal autoconf autoheader autom4te automake makeinfo
|
58
|
-
bison yacc flex lex help2man
|
59
|
-
|
60
|
-
Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
|
61
|
-
'g' are ignored when checking the name.
|
62
|
-
|
63
|
-
Send bug reports to <bug-automake@gnu.org>."
|
64
|
-
exit $?
|
65
|
-
;;
|
66
|
-
|
67
|
-
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
|
68
|
-
echo "missing $scriptversion (GNU Automake)"
|
69
|
-
exit $?
|
70
|
-
;;
|
71
|
-
|
72
|
-
-*)
|
73
|
-
echo 1>&2 "$0: unknown '$1' option"
|
74
|
-
echo 1>&2 "Try '$0 --help' for more information"
|
75
|
-
exit 1
|
76
|
-
;;
|
77
|
-
|
78
|
-
esac
|
79
|
-
|
80
|
-
# Run the given program, remember its exit status.
|
81
|
-
"$@"; st=$?
|
82
|
-
|
83
|
-
# If it succeeded, we are done.
|
84
|
-
test $st -eq 0 && exit 0
|
85
|
-
|
86
|
-
# Also exit now if we it failed (or wasn't found), and '--version' was
|
87
|
-
# passed; such an option is passed most likely to detect whether the
|
88
|
-
# program is present and works.
|
89
|
-
case $2 in --version|--help) exit $st;; esac
|
90
|
-
|
91
|
-
# Exit code 63 means version mismatch. This often happens when the user
|
92
|
-
# tries to use an ancient version of a tool on a file that requires a
|
93
|
-
# minimum version.
|
94
|
-
if test $st -eq 63; then
|
95
|
-
msg="probably too old"
|
96
|
-
elif test $st -eq 127; then
|
97
|
-
# Program was missing.
|
98
|
-
msg="missing on your system"
|
99
|
-
else
|
100
|
-
# Program was found and executed, but failed. Give up.
|
101
|
-
exit $st
|
102
|
-
fi
|
103
|
-
|
104
|
-
perl_URL=http://www.perl.org/
|
105
|
-
flex_URL=http://flex.sourceforge.net/
|
106
|
-
gnu_software_URL=http://www.gnu.org/software
|
107
|
-
|
108
|
-
program_details ()
|
109
|
-
{
|
110
|
-
case $1 in
|
111
|
-
aclocal|automake)
|
112
|
-
echo "The '$1' program is part of the GNU Automake package:"
|
113
|
-
echo "<$gnu_software_URL/automake>"
|
114
|
-
echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
|
115
|
-
echo "<$gnu_software_URL/autoconf>"
|
116
|
-
echo "<$gnu_software_URL/m4/>"
|
117
|
-
echo "<$perl_URL>"
|
118
|
-
;;
|
119
|
-
autoconf|autom4te|autoheader)
|
120
|
-
echo "The '$1' program is part of the GNU Autoconf package:"
|
121
|
-
echo "<$gnu_software_URL/autoconf/>"
|
122
|
-
echo "It also requires GNU m4 and Perl in order to run:"
|
123
|
-
echo "<$gnu_software_URL/m4/>"
|
124
|
-
echo "<$perl_URL>"
|
125
|
-
;;
|
126
|
-
esac
|
127
|
-
}
|
128
|
-
|
129
|
-
give_advice ()
|
130
|
-
{
|
131
|
-
# Normalize program name to check for.
|
132
|
-
normalized_program=`echo "$1" | sed '
|
133
|
-
s/^gnu-//; t
|
134
|
-
s/^gnu//; t
|
135
|
-
s/^g//; t'`
|
136
|
-
|
137
|
-
printf '%s\n' "'$1' is $msg."
|
138
|
-
|
139
|
-
configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
|
140
|
-
case $normalized_program in
|
141
|
-
autoconf*)
|
142
|
-
echo "You should only need it if you modified 'configure.ac',"
|
143
|
-
echo "or m4 files included by it."
|
144
|
-
program_details 'autoconf'
|
145
|
-
;;
|
146
|
-
autoheader*)
|
147
|
-
echo "You should only need it if you modified 'acconfig.h' or"
|
148
|
-
echo "$configure_deps."
|
149
|
-
program_details 'autoheader'
|
150
|
-
;;
|
151
|
-
automake*)
|
152
|
-
echo "You should only need it if you modified 'Makefile.am' or"
|
153
|
-
echo "$configure_deps."
|
154
|
-
program_details 'automake'
|
155
|
-
;;
|
156
|
-
aclocal*)
|
157
|
-
echo "You should only need it if you modified 'acinclude.m4' or"
|
158
|
-
echo "$configure_deps."
|
159
|
-
program_details 'aclocal'
|
160
|
-
;;
|
161
|
-
autom4te*)
|
162
|
-
echo "You might have modified some maintainer files that require"
|
163
|
-
echo "the 'autom4te' program to be rebuilt."
|
164
|
-
program_details 'autom4te'
|
165
|
-
;;
|
166
|
-
bison*|yacc*)
|
167
|
-
echo "You should only need it if you modified a '.y' file."
|
168
|
-
echo "You may want to install the GNU Bison package:"
|
169
|
-
echo "<$gnu_software_URL/bison/>"
|
170
|
-
;;
|
171
|
-
lex*|flex*)
|
172
|
-
echo "You should only need it if you modified a '.l' file."
|
173
|
-
echo "You may want to install the Fast Lexical Analyzer package:"
|
174
|
-
echo "<$flex_URL>"
|
175
|
-
;;
|
176
|
-
help2man*)
|
177
|
-
echo "You should only need it if you modified a dependency" \
|
178
|
-
"of a man page."
|
179
|
-
echo "You may want to install the GNU Help2man package:"
|
180
|
-
echo "<$gnu_software_URL/help2man/>"
|
181
|
-
;;
|
182
|
-
makeinfo*)
|
183
|
-
echo "You should only need it if you modified a '.texi' file, or"
|
184
|
-
echo "any other file indirectly affecting the aspect of the manual."
|
185
|
-
echo "You might want to install the Texinfo package:"
|
186
|
-
echo "<$gnu_software_URL/texinfo/>"
|
187
|
-
echo "The spurious makeinfo call might also be the consequence of"
|
188
|
-
echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
|
189
|
-
echo "want to install GNU make:"
|
190
|
-
echo "<$gnu_software_URL/make/>"
|
191
|
-
;;
|
192
|
-
*)
|
193
|
-
echo "You might have modified some files without having the proper"
|
194
|
-
echo "tools for further handling them. Check the 'README' file, it"
|
195
|
-
echo "often tells you about the needed prerequisites for installing"
|
196
|
-
echo "this package. You may also peek at any GNU archive site, in"
|
197
|
-
echo "case some other package contains this missing '$1' program."
|
198
|
-
;;
|
199
|
-
esac
|
200
|
-
}
|
201
|
-
|
202
|
-
give_advice "$1" | sed -e '1s/^/WARNING: /' \
|
203
|
-
-e '2,$s/^/ /' >&2
|
204
|
-
|
205
|
-
# Propagate the correct exit status (expected to be 127 for a program
|
206
|
-
# not found, 63 for a program that failed due to version mismatch).
|
207
|
-
exit $st
|
208
|
-
|
209
|
-
# Local variables:
|
210
|
-
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
211
|
-
# time-stamp-start: "scriptversion="
|
212
|
-
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
213
|
-
# time-stamp-time-zone: "UTC"
|
214
|
-
# time-stamp-end: "; # UTC"
|
215
|
-
# End:
|
@@ -1,369 +0,0 @@
|
|
1
|
-
/* -*- Mode: C; c-basic-offset:8 ; indent-tabs-mode:t -*- */
|
2
|
-
/*
|
3
|
-
* Linux usbfs backend for libusb
|
4
|
-
* Copyright (C) 2007-2009 Daniel Drake <dsd@gentoo.org>
|
5
|
-
* Copyright (c) 2001 Johannes Erdfelt <johannes@erdfelt.com>
|
6
|
-
* Copyright (c) 2013 Nathan Hjelm <hjelmn@mac.com>
|
7
|
-
*
|
8
|
-
* This library is free software; you can redistribute it and/or
|
9
|
-
* modify it under the terms of the GNU Lesser General Public
|
10
|
-
* License as published by the Free Software Foundation; either
|
11
|
-
* version 2.1 of the License, or (at your option) any later version.
|
12
|
-
*
|
13
|
-
* This library is distributed in the hope that it will be useful,
|
14
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
16
|
-
* Lesser General Public License for more details.
|
17
|
-
*
|
18
|
-
* You should have received a copy of the GNU Lesser General Public
|
19
|
-
* License along with this library; if not, write to the Free Software
|
20
|
-
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
21
|
-
*/
|
22
|
-
|
23
|
-
#include <config.h>
|
24
|
-
|
25
|
-
#include <ctype.h>
|
26
|
-
#include <dirent.h>
|
27
|
-
#include <errno.h>
|
28
|
-
#include <fcntl.h>
|
29
|
-
#include <poll.h>
|
30
|
-
#include <stdio.h>
|
31
|
-
#include <stdlib.h>
|
32
|
-
#include <string.h>
|
33
|
-
#include <sys/types.h>
|
34
|
-
|
35
|
-
#ifdef HAVE_ASM_TYPES_H
|
36
|
-
#include <asm/types.h>
|
37
|
-
#endif
|
38
|
-
|
39
|
-
#ifdef HAVE_SYS_SOCKET_H
|
40
|
-
#include <sys/socket.h>
|
41
|
-
#endif
|
42
|
-
|
43
|
-
#include <arpa/inet.h>
|
44
|
-
|
45
|
-
#ifdef HAVE_LINUX_NETLINK_H
|
46
|
-
#include <linux/netlink.h>
|
47
|
-
#endif
|
48
|
-
|
49
|
-
#ifdef HAVE_LINUX_FILTER_H
|
50
|
-
#include <linux/filter.h>
|
51
|
-
#endif
|
52
|
-
|
53
|
-
#include "libusbi.h"
|
54
|
-
#include "linux_usbfs.h"
|
55
|
-
|
56
|
-
#define KERNEL 1
|
57
|
-
|
58
|
-
static int linux_netlink_socket = -1;
|
59
|
-
static int netlink_control_pipe[2] = { -1, -1 };
|
60
|
-
static pthread_t libusb_linux_event_thread;
|
61
|
-
|
62
|
-
static void *linux_netlink_event_thread_main(void *arg);
|
63
|
-
|
64
|
-
struct sockaddr_nl snl = { .nl_family=AF_NETLINK, .nl_groups=KERNEL };
|
65
|
-
|
66
|
-
static int set_fd_cloexec_nb (int fd)
|
67
|
-
{
|
68
|
-
int flags;
|
69
|
-
|
70
|
-
#if defined(FD_CLOEXEC)
|
71
|
-
flags = fcntl (linux_netlink_socket, F_GETFD);
|
72
|
-
if (0 > flags) {
|
73
|
-
return -1;
|
74
|
-
}
|
75
|
-
|
76
|
-
if (!(flags & FD_CLOEXEC)) {
|
77
|
-
fcntl (linux_netlink_socket, F_SETFD, flags | FD_CLOEXEC);
|
78
|
-
}
|
79
|
-
#endif
|
80
|
-
|
81
|
-
flags = fcntl (linux_netlink_socket, F_GETFL);
|
82
|
-
if (0 > flags) {
|
83
|
-
return -1;
|
84
|
-
}
|
85
|
-
|
86
|
-
if (!(flags & O_NONBLOCK)) {
|
87
|
-
fcntl (linux_netlink_socket, F_SETFL, flags | O_NONBLOCK);
|
88
|
-
}
|
89
|
-
|
90
|
-
return 0;
|
91
|
-
}
|
92
|
-
|
93
|
-
int linux_netlink_start_event_monitor(void)
|
94
|
-
{
|
95
|
-
int socktype = SOCK_RAW;
|
96
|
-
int ret;
|
97
|
-
|
98
|
-
snl.nl_groups = KERNEL;
|
99
|
-
|
100
|
-
#if defined(SOCK_CLOEXEC)
|
101
|
-
socktype |= SOCK_CLOEXEC;
|
102
|
-
#endif
|
103
|
-
#if defined(SOCK_NONBLOCK)
|
104
|
-
socktype |= SOCK_NONBLOCK;
|
105
|
-
#endif
|
106
|
-
|
107
|
-
linux_netlink_socket = socket(PF_NETLINK, socktype, NETLINK_KOBJECT_UEVENT);
|
108
|
-
if (-1 == linux_netlink_socket && EINVAL == errno) {
|
109
|
-
linux_netlink_socket = socket(PF_NETLINK, SOCK_RAW, NETLINK_KOBJECT_UEVENT);
|
110
|
-
}
|
111
|
-
|
112
|
-
if (-1 == linux_netlink_socket) {
|
113
|
-
return LIBUSB_ERROR_OTHER;
|
114
|
-
}
|
115
|
-
|
116
|
-
ret = set_fd_cloexec_nb (linux_netlink_socket);
|
117
|
-
if (0 != ret) {
|
118
|
-
close (linux_netlink_socket);
|
119
|
-
linux_netlink_socket = -1;
|
120
|
-
return LIBUSB_ERROR_OTHER;
|
121
|
-
}
|
122
|
-
|
123
|
-
ret = bind(linux_netlink_socket, (struct sockaddr *) &snl, sizeof(snl));
|
124
|
-
if (0 != ret) {
|
125
|
-
close(linux_netlink_socket);
|
126
|
-
return LIBUSB_ERROR_OTHER;
|
127
|
-
}
|
128
|
-
|
129
|
-
/* TODO -- add authentication */
|
130
|
-
/* setsockopt(linux_netlink_socket, SOL_SOCKET, SO_PASSCRED, &one, sizeof(one)); */
|
131
|
-
|
132
|
-
ret = usbi_pipe(netlink_control_pipe);
|
133
|
-
if (ret) {
|
134
|
-
usbi_err(NULL, "could not create netlink control pipe");
|
135
|
-
close(linux_netlink_socket);
|
136
|
-
return LIBUSB_ERROR_OTHER;
|
137
|
-
}
|
138
|
-
|
139
|
-
ret = pthread_create(&libusb_linux_event_thread, NULL, linux_netlink_event_thread_main, NULL);
|
140
|
-
if (0 != ret) {
|
141
|
-
close(netlink_control_pipe[0]);
|
142
|
-
close(netlink_control_pipe[1]);
|
143
|
-
close(linux_netlink_socket);
|
144
|
-
return LIBUSB_ERROR_OTHER;
|
145
|
-
}
|
146
|
-
|
147
|
-
return LIBUSB_SUCCESS;
|
148
|
-
}
|
149
|
-
|
150
|
-
int linux_netlink_stop_event_monitor(void)
|
151
|
-
{
|
152
|
-
int r;
|
153
|
-
char dummy = 1;
|
154
|
-
|
155
|
-
if (-1 == linux_netlink_socket) {
|
156
|
-
/* already closed. nothing to do */
|
157
|
-
return LIBUSB_SUCCESS;
|
158
|
-
}
|
159
|
-
|
160
|
-
/* Write some dummy data to the control pipe and
|
161
|
-
* wait for the thread to exit */
|
162
|
-
r = usbi_write(netlink_control_pipe[1], &dummy, sizeof(dummy));
|
163
|
-
if (r <= 0) {
|
164
|
-
usbi_warn(NULL, "netlink control pipe signal failed");
|
165
|
-
}
|
166
|
-
pthread_join(libusb_linux_event_thread, NULL);
|
167
|
-
|
168
|
-
close(linux_netlink_socket);
|
169
|
-
linux_netlink_socket = -1;
|
170
|
-
|
171
|
-
/* close and reset control pipe */
|
172
|
-
close(netlink_control_pipe[0]);
|
173
|
-
close(netlink_control_pipe[1]);
|
174
|
-
netlink_control_pipe[0] = -1;
|
175
|
-
netlink_control_pipe[1] = -1;
|
176
|
-
|
177
|
-
return LIBUSB_SUCCESS;
|
178
|
-
}
|
179
|
-
|
180
|
-
static const char *netlink_message_parse (const char *buffer, size_t len, const char *key)
|
181
|
-
{
|
182
|
-
size_t keylen = strlen(key);
|
183
|
-
size_t offset;
|
184
|
-
|
185
|
-
for (offset = 0 ; offset < len && '\0' != buffer[offset] ; offset += strlen(buffer + offset) + 1) {
|
186
|
-
if (0 == strncmp(buffer + offset, key, keylen) &&
|
187
|
-
'=' == buffer[offset + keylen]) {
|
188
|
-
return buffer + offset + keylen + 1;
|
189
|
-
}
|
190
|
-
}
|
191
|
-
|
192
|
-
return NULL;
|
193
|
-
}
|
194
|
-
|
195
|
-
/* parse parts of netlink message common to both libudev and the kernel */
|
196
|
-
static int linux_netlink_parse(char *buffer, size_t len, int *detached, const char **sys_name,
|
197
|
-
uint8_t *busnum, uint8_t *devaddr) {
|
198
|
-
const char *tmp;
|
199
|
-
int i;
|
200
|
-
|
201
|
-
errno = 0;
|
202
|
-
|
203
|
-
*sys_name = NULL;
|
204
|
-
*detached = 0;
|
205
|
-
*busnum = 0;
|
206
|
-
*devaddr = 0;
|
207
|
-
|
208
|
-
tmp = netlink_message_parse((const char *) buffer, len, "ACTION");
|
209
|
-
if (tmp == NULL)
|
210
|
-
return -1;
|
211
|
-
if (0 == strcmp(tmp, "remove")) {
|
212
|
-
*detached = 1;
|
213
|
-
} else if (0 != strcmp(tmp, "add")) {
|
214
|
-
usbi_dbg("unknown device action %s", tmp);
|
215
|
-
return -1;
|
216
|
-
}
|
217
|
-
|
218
|
-
/* check that this is a usb message */
|
219
|
-
tmp = netlink_message_parse(buffer, len, "SUBSYSTEM");
|
220
|
-
if (NULL == tmp || 0 != strcmp(tmp, "usb")) {
|
221
|
-
/* not usb. ignore */
|
222
|
-
return -1;
|
223
|
-
}
|
224
|
-
|
225
|
-
tmp = netlink_message_parse(buffer, len, "BUSNUM");
|
226
|
-
if (NULL == tmp) {
|
227
|
-
/* no bus number. try "DEVICE" */
|
228
|
-
tmp = netlink_message_parse(buffer, len, "DEVICE");
|
229
|
-
if (NULL == tmp) {
|
230
|
-
/* not usb. ignore */
|
231
|
-
return -1;
|
232
|
-
}
|
233
|
-
|
234
|
-
/* Parse a device path such as /dev/bus/usb/003/004 */
|
235
|
-
char *pLastSlash = (char*)strrchr(tmp,'/');
|
236
|
-
if(NULL == pLastSlash) {
|
237
|
-
return -1;
|
238
|
-
}
|
239
|
-
|
240
|
-
*devaddr = strtoul(pLastSlash + 1, NULL, 10);
|
241
|
-
if (errno) {
|
242
|
-
errno = 0;
|
243
|
-
return -1;
|
244
|
-
}
|
245
|
-
|
246
|
-
*busnum = strtoul(pLastSlash - 3, NULL, 10);
|
247
|
-
if (errno) {
|
248
|
-
errno = 0;
|
249
|
-
return -1;
|
250
|
-
}
|
251
|
-
|
252
|
-
return 0;
|
253
|
-
}
|
254
|
-
|
255
|
-
*busnum = (uint8_t)(strtoul(tmp, NULL, 10) & 0xff);
|
256
|
-
if (errno) {
|
257
|
-
errno = 0;
|
258
|
-
return -1;
|
259
|
-
}
|
260
|
-
|
261
|
-
tmp = netlink_message_parse(buffer, len, "DEVNUM");
|
262
|
-
if (NULL == tmp) {
|
263
|
-
return -1;
|
264
|
-
}
|
265
|
-
|
266
|
-
*devaddr = (uint8_t)(strtoul(tmp, NULL, 10) & 0xff);
|
267
|
-
if (errno) {
|
268
|
-
errno = 0;
|
269
|
-
return -1;
|
270
|
-
}
|
271
|
-
|
272
|
-
tmp = netlink_message_parse(buffer, len, "DEVPATH");
|
273
|
-
if (NULL == tmp) {
|
274
|
-
return -1;
|
275
|
-
}
|
276
|
-
|
277
|
-
for (i = strlen(tmp) - 1 ; i ; --i) {
|
278
|
-
if ('/' ==tmp[i]) {
|
279
|
-
*sys_name = tmp + i + 1;
|
280
|
-
break;
|
281
|
-
}
|
282
|
-
}
|
283
|
-
|
284
|
-
/* found a usb device */
|
285
|
-
return 0;
|
286
|
-
}
|
287
|
-
|
288
|
-
static int linux_netlink_read_message(void)
|
289
|
-
{
|
290
|
-
unsigned char buffer[1024];
|
291
|
-
struct iovec iov = {.iov_base = buffer, .iov_len = sizeof(buffer)};
|
292
|
-
struct msghdr meh = { .msg_iov=&iov, .msg_iovlen=1,
|
293
|
-
.msg_name=&snl, .msg_namelen=sizeof(snl) };
|
294
|
-
const char *sys_name = NULL;
|
295
|
-
uint8_t busnum, devaddr;
|
296
|
-
int detached, r;
|
297
|
-
size_t len;
|
298
|
-
|
299
|
-
/* read netlink message */
|
300
|
-
memset(buffer, 0, sizeof(buffer));
|
301
|
-
len = recvmsg(linux_netlink_socket, &meh, 0);
|
302
|
-
if (len < 32) {
|
303
|
-
if (errno != EAGAIN)
|
304
|
-
usbi_dbg("error recieving message from netlink");
|
305
|
-
return -1;
|
306
|
-
}
|
307
|
-
|
308
|
-
/* TODO -- authenticate this message is from the kernel or udevd */
|
309
|
-
|
310
|
-
r = linux_netlink_parse(buffer, len, &detached, &sys_name,
|
311
|
-
&busnum, &devaddr);
|
312
|
-
if (r)
|
313
|
-
return r;
|
314
|
-
|
315
|
-
usbi_dbg("netlink hotplug found device busnum: %hhu, devaddr: %hhu, sys_name: %s, removed: %s",
|
316
|
-
busnum, devaddr, sys_name, detached ? "yes" : "no");
|
317
|
-
|
318
|
-
/* signal device is available (or not) to all contexts */
|
319
|
-
if (detached)
|
320
|
-
linux_device_disconnected(busnum, devaddr, sys_name);
|
321
|
-
else
|
322
|
-
linux_hotplug_enumerate(busnum, devaddr, sys_name);
|
323
|
-
|
324
|
-
return 0;
|
325
|
-
}
|
326
|
-
|
327
|
-
static void *linux_netlink_event_thread_main(void *arg)
|
328
|
-
{
|
329
|
-
char dummy;
|
330
|
-
int r;
|
331
|
-
struct pollfd fds[] = {
|
332
|
-
{ .fd = netlink_control_pipe[0],
|
333
|
-
.events = POLLIN },
|
334
|
-
{ .fd = linux_netlink_socket,
|
335
|
-
.events = POLLIN },
|
336
|
-
};
|
337
|
-
|
338
|
-
/* silence compiler warning */
|
339
|
-
(void) arg;
|
340
|
-
|
341
|
-
while (poll(fds, 2, -1) >= 0) {
|
342
|
-
if (fds[0].revents & POLLIN) {
|
343
|
-
/* activity on control pipe, read the byte and exit */
|
344
|
-
r = usbi_read(netlink_control_pipe[0], &dummy, sizeof(dummy));
|
345
|
-
if (r <= 0) {
|
346
|
-
usbi_warn(NULL, "netlink control pipe read failed");
|
347
|
-
}
|
348
|
-
break;
|
349
|
-
}
|
350
|
-
if (fds[1].revents & POLLIN) {
|
351
|
-
usbi_mutex_static_lock(&linux_hotplug_lock);
|
352
|
-
linux_netlink_read_message();
|
353
|
-
usbi_mutex_static_unlock(&linux_hotplug_lock);
|
354
|
-
}
|
355
|
-
}
|
356
|
-
|
357
|
-
return NULL;
|
358
|
-
}
|
359
|
-
|
360
|
-
void linux_netlink_hotplug_poll(void)
|
361
|
-
{
|
362
|
-
int r;
|
363
|
-
|
364
|
-
usbi_mutex_static_lock(&linux_hotplug_lock);
|
365
|
-
do {
|
366
|
-
r = linux_netlink_read_message();
|
367
|
-
} while (r == 0);
|
368
|
-
usbi_mutex_static_unlock(&linux_hotplug_lock);
|
369
|
-
}
|