Git Product home page Git Product logo

vhci_hcd's Introduction

vhci_hcd

клон https://sourceforge.net/projects/usb-vhci/

vhci_hcd This project consists of a Linux kernel driver and some user-mode libraries. They allow a process to create a virtual usb host controller. Real or virtual usb devices can be "plugged" into this controller. Screenshot thumbnail usb storage device forwarded to a virtual host controller

Install as modules

Just run

mkdir -p linux/"$(uname -r | cut -d'-' -f1)"/drivers/usb/core

cp /usr/src/linux-source-"$(uname -r | cut -d'-' -f1)"/include/linux/usb/hcd.h linux/"$(uname -r | cut -d'-' -f1)"/drivers/usb/core/

make KVERSION="$(uname -r)" KSRC=/usr/src/linux-source-"$(uname -r | cut -d'-' -f1)"

or

make

and

make install # (as root)

to build and install the modules for the currently running kernel. The modules are called usb-vhci-hcd and usb-vhci-iocifc. Run

modprobe usb-vhci-hcd && modprobe usb-vhci-iocifc

to load the modules.

Patch into kernel

Run

make KVERSION= KSRC=<PATH_TO_KERNEL_SOURCE> patchkernel

(replace <PATH_TO_KERNEL_SOURCE> with the actual path) to patch the vhci-hcd sources into the kernel source. If you want to do this for a kernel with a different version than the currently running one, then you need to create the config header first by running

make config

and answering the few questions about the target kernel.

Project Members: Bruse Geng Emil Lee m_singer (admin) About this project I started working on this project in the year 2007 as an employee of the company Conemis AG in Karlsruhe.

The primary goal was to share USB devices over ethernet. At this point in time it works fine with Linux. The Windows kernel driver isn't finished yet.

The user space part is written in C# and runs on Mono and MS.NET. It consists of some libraries and a few executables (server and client).

How to use it First you need to download and build the Linux kernel driver. You can download it from the Files tab. It's in the linux kernel module folder. You can also clone the vhci_hcd GIT repository:

git clone git://git.code.sf.net/p/usb-vhci/vhci_hcd "make" should be enough to build it. When it is build successfully, you can load the modules with:

insmod usb-vhci-hcd.ko insmod usb-vhci-iocifc.ko The first module is the virtual host controller driver itself. The second module is the IOCTL interface to user mode. After loading the second module the device file /dev/usb-vhci should appear. All the communication between kernel driver and user mode happens through this file. If you don't want to be root all the time, you might want to chmod it:

chmod 666 /dev/usb-vhci There are two user mode packages you can use now:

The native C/C++ library and the .NET libraries Currently, the .NET libraries offer much more stuff. For example they include a client and a server application for "tunneling" USB devices over TCP.

Native C/C++ library The native library can be downloaded from the native libraries folder. Or you can clone the libusb_vhci repository:

git clone git://git.code.sf.net/p/usb-vhci/libusb_vhci Before you can build it, you need the usb-vhci.h header file from the kernel driver installed in /usr/include/linux (or maybe /usr/local/include/linux might work too). You can run "make install" in the top level directory of the driver sources (vhci_hcd) that you downloaded and built earlier. It will install this header and the modules.

With the header file in place, you should be able to build the library and a few example applications:

./configure make To see if it works, run one of the examples:

examples/virtual_device And use another terminal to look for the virtual USB device with "dmesg" or "cat /proc/bus/usb/devices" if you have usbfs mounted there.

.NET libraries The .NET libraries can be downloaded from the dotnet libraries folder. Or you can clone the usb-vhci repository:

git clone git://git.code.sf.net/p/usb-vhci/usb-vhci They can also be downloaded pre-built. Of course you need mono for building and using them. You can also build them in a mingw or cygwin console on Windows using the Microsoft C# compiler if you like.

If you want to build them on Linux (Again: You don't have to. There are pre-built ones available.), it should work just like the native libraries:

./configure make Building them on Windows (using mingw or cygwin), you might need to find out the full path to the Microsoft #C compiler and run configure like this:

./configure CSC=/path/to/compiler.exe When they got built successfully, all DLLs and executables are in the bin folder. You can start the server now:

mono bin/VhciServer.exe 4 1138 This creates a virtual USB host controller with four USB ports. The server listens on TCP port 1138 for connections. Use "dmesg" to see the new virtual host controller.

Now you can start the client on another computer (or the same one), to connect a USB device to this virtual host controller. But first you have to search for the device you want to connect:

mono bin/VhciClient.exe -l The parameter -l shows you a tree of all USB ports and which devices are connected to them. Choose a device and start the client like this:

mono bin/VhciClient.exe 4-3 127.0.0.1:1138 If you are not root, then you might run into an exception that looks like this:

Unhandled Exception: System.IO.IOException: Couldn't open /dev/bus/usb/004/002. (13) at Usb.UsbFS.DeviceFile..ctor (System.String path, Boolean ro) [0x00000] in :0 at Usb.UsbFS.DeviceFile..ctor (System.String path) [0x00000] in :0 at Usb.UsbFS.UsbDevice..ctor (System.String path) [0x00000] in :0 at Usb.UsbFS.Enumeration.Device.Acquire () [0x00000] in :0 at VhciClient.MainClass.Main (System.String[] args) [0x00000] in :0 If you don't want to start the client as root, use chmod as root to give yourself access of the device file. In this example:

chmod 666 /dev/bus/usb/004/002

vhci_hcd's People

Contributors

linuxbuh avatar zaharchuktv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

vhci_hcd's Issues

Can't build vhci_hcd

Hi,

I've downloaded the code from vhci_hcd and tried to build it, but get the following errors:

/home/dev/workspace/fido/vhci_hcd/usb-vhci-hcd.c:59:3: warning: #warning DEBUG is defined [-Wcpp]

warning DEBUG is defined

^~~~~~~
In file included from ./include/linux/stat.h:7:0,
from ./include/linux/module.h:10,
from /home/dev/workspace/fido/vhci_hcd/usb-vhci-hcd.c:24:
./include/uapi/linux/stat.h:30:17: error: expected ‘)’ before numeric constant
#define S_IRUSR 00400
^
/home/dev/workspace/fido/vhci_hcd/usb-vhci-hcd.c:1312:34: note: in expansion of macro ‘S_IRUSR’
static DRIVER_ATTR(debug_output, S_IRUSR | S_IWUSR, show_debug_output, store_debug_output);
^~~~~~~
/home/dev/workspace/fido/vhci_hcd/usb-vhci-hcd.c: In function ‘init’:
/home/dev/workspace/fido/vhci_hcd/usb-vhci-hcd.c:1334:56: error: ‘driver_attr_debug_output’ undeclared (first use in this function); did you mean ‘store_debug_output’?
retval = driver_create_file(&vhci_hcd_driver.driver, &driver_attr_debug_output);
^~~~~~~~~~~~~~~~~~~~~~~~
store_debug_output
/home/dev/workspace/fido/vhci_hcd/usb-vhci-hcd.c:1334:56: note: each undeclared identifier is reported only once for each function it appears in
/home/dev/workspace/fido/vhci_hcd/usb-vhci-hcd.c: In function ‘cleanup’:
/home/dev/workspace/fido/vhci_hcd/usb-vhci-hcd.c:1349:47: error: ‘driver_attr_debug_output’ undeclared (first use in this function); did you mean ‘store_debug_output’?
driver_remove_file(&vhci_hcd_driver.driver, &driver_attr_debug_output);
^~~~~~~~~~~~~~~~~~~~~~~~
store_debug_output
At top level:
/home/dev/workspace/fido/vhci_hcd/usb-vhci-hcd.c:1299:16: warning: ‘store_debug_output’ defined but not used [-Wunused-function]
static ssize_t store_debug_output(struct device_driver *drv, const char *buf, size_t count)
^~~~~~~~~~~~~~~~~~
/home/dev/workspace/fido/vhci_hcd/usb-vhci-hcd.c:1284:16: warning: ‘show_debug_output’ defined but not used [-Wunused-function]
static ssize_t show_debug_output(struct device_driver *drv, char *buf)
^~~~~~~~~~~~~~~~~
scripts/Makefile.build:339: recipe for target '/home/dev/workspace/fido/vhci_hcd/usb-vhci-hcd.o' failed
make[2]: *** [/home/dev/workspace/fido/vhci_hcd/usb-vhci-hcd.o] Error 1
Makefile:1551: recipe for target 'module/home/dev/workspace/fido/vhci_hcd' failed
make[1]: *** [module/home/dev/workspace/fido/vhci_hcd] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-4.15.0-42-generic'
Makefile:35: recipe for target 'default' failed
make: *** [default] Error 2
I'm building it on ubuntu 18.04.

Thanks,

sys-apps/hasp: не компилится с lpt USE-флагом

Собственно вся проблема описана в заголовке. Нужно патчить aksparlnx/Makefile и м.б. ещё aksparlnx/aksparpub.c

Кроме этого, в ebuild'е потеряна зависимость от app-arch/rpm2targz. Без этого пакета ни как.

DEPEND="${RDEPEND}
        app-arch/rpm2targz"

Can't build on 6.6 kernel

vhci_hcd перестал собираться на ядре 6.2 и выше

DKMS make.log for vhci_hcd-1.15.1 for kernel 6.6.8-1 (x86_64)
Wed Dec 27 19:46:03 MSK 2023
make testconfig
make[1]: Entering directory '/home/arch/abs/testing/vhci_hcd/src/build/vhci_hcd/1.15.1/build'
rm -f test/.o test/.ko test/..cmd test/..flags test/.mod.c test/Module.symvers test/Module.markers test/modules.order
rm -rf test/.tmp_versions/
make -C /lib/modules/6.6.8-1/build M=/home/arch/abs/testing/vhci_hcd/src/build/vhci_hcd/1.15.1/build/test PWD=/home/arch/abs/testing/vhci_hcd/src/build/vhci_hcd/1.15.1/build/test BUILD_PREFIX= KDIR=/lib/modules/6.6.8-1/build KVERSION=6.6.8-1 EXTRA_CFLAGS='-Wno-unused -DEXPORT_SYMTAB -DKBUILD_EXTMOD -DINCLUDE_CORE_HCD="/lib/modules/6.6.8-1/build/include/linux/usb/hcd.h" -DKERNEL_VER=6 ' modules
make[2]: Entering directory '/usr/lib/modules/6.6.8-1/build'
CC [M] /home/arch/abs/testing/vhci_hcd/src/build/vhci_hcd/1.15.1/build/test/test.o
MODPOST /home/arch/abs/testing/vhci_hcd/src/build/vhci_hcd/1.15.1/build/test/Module.symvers
CC [M] /home/arch/abs/testing/vhci_hcd/src/build/vhci_hcd/1.15.1/build/test/test.mod.o
LD [M] /home/arch/abs/testing/vhci_hcd/src/build/vhci_hcd/1.15.1/build/test/test.ko
BTF [M] /home/arch/abs/testing/vhci_hcd/src/build/vhci_hcd/1.15.1/build/test/test.ko
make[2]: Leaving directory '/usr/lib/modules/6.6.8-1/build'
mkdir -p conf/
echo "// do not edit; automatically generated by 'make testconfig' in vhci-hcd sourcedir" >conf/usb-vhci.config.h
echo "#define USB_VHCI_HCD_VERSION "1.15.1"" >>conf/usb-vhci.config.h
echo "#define USB_VHCI_HCD_DATE "2023-12-27"" >>conf/usb-vhci.config.h
echo "#define USB_VHCI_IOCIFC_VERSION "1.15.1"" >>conf/usb-vhci.config.h
echo "#define USB_VHCI_IOCIFC_DATE USB_VHCI_HCD_DATE" >>conf/usb-vhci.config.h
make clean-test
make[2]: Entering directory '/home/arch/abs/testing/vhci_hcd/src/build/vhci_hcd/1.15.1/build'
rm -f test/
.o test/.ko test/..cmd test/..flags test/.mod.c test/Module.symvers test/Module.markers test/modules.order
rm -rf test/.tmp_versions/
make[2]: Leaving directory '/home/arch/abs/testing/vhci_hcd/src/build/vhci_hcd/1.15.1/build'
if make -C /lib/modules/6.6.8-1/build M=/home/arch/abs/testing/vhci_hcd/src/build/vhci_hcd/1.15.1/build/test PWD=/home/arch/abs/testing/vhci_hcd/src/build/vhci_hcd/1.15.1/build/test BUILD_PREFIX= KDIR=/lib/modules/6.6.8-1/build KVERSION=6.6.8-1 EXTRA_CFLAGS='-Wno-unused -DEXPORT_SYMTAB -DKBUILD_EXTMOD -DINCLUDE_CORE_HCD="/lib/modules/6.6.8-1/build/include/linux/usb/hcd.h" -DKERNEL_VER=6 -DTEST_GIVEBACK_MECH' modules >/dev/null 2>&1; then
echo "//#define OLD_GIVEBACK_MECH" >>conf/usb-vhci.config.h;
else
echo "#define OLD_GIVEBACK_MECH" >>conf/usb-vhci.config.h;
fi
make clean-test
make[2]: Entering directory '/home/arch/abs/testing/vhci_hcd/src/build/vhci_hcd/1.15.1/build'
rm -f test/.o test/.ko test/..cmd test/..flags test/.mod.c test/Module.symvers test/Module.markers test/modules.order
rm -rf test/.tmp_versions/
make[2]: Leaving directory '/home/arch/abs/testing/vhci_hcd/src/build/vhci_hcd/1.15.1/build'
if make -C /lib/modules/6.6.8-1/build M=/home/arch/abs/testing/vhci_hcd/src/build/vhci_hcd/1.15.1/build/test PWD=/home/arch/abs/testing/vhci_hcd/src/build/vhci_hcd/1.15.1/build/test BUILD_PREFIX= KDIR=/lib/modules/6.6.8-1/build KVERSION=6.6.8-1 EXTRA_CFLAGS='-Wno-unused -DEXPORT_SYMTAB -DKBUILD_EXTMOD -DINCLUDE_CORE_HCD="/lib/modules/6.6.8-1/build/include/linux/usb/hcd.h" -DKERNEL_VER=6 -DTEST_DEV_BUS_ID' modules >/dev/null 2>&1; then
echo "//#define OLD_DEV_BUS_ID" >>conf/usb-vhci.config.h;
else
echo "#define OLD_DEV_BUS_ID" >>conf/usb-vhci.config.h;
fi
make clean-test
make[2]: Entering directory '/home/arch/abs/testing/vhci_hcd/src/build/vhci_hcd/1.15.1/build'
rm -f test/
.o test/.ko test/..cmd test/..flags test/.mod.c test/Module.symvers test/Module.markers test/modules.order
rm -rf test/.tmp_versions/
make[2]: Leaving directory '/home/arch/abs/testing/vhci_hcd/src/build/vhci_hcd/1.15.1/build'
if make -C /lib/modules/6.6.8-1/build M=/home/arch/abs/testing/vhci_hcd/src/build/vhci_hcd/1.15.1/build/test PWD=/home/arch/abs/testing/vhci_hcd/src/build/vhci_hcd/1.15.1/build/test BUILD_PREFIX= KDIR=/lib/modules/6.6.8-1/build KVERSION=6.6.8-1 EXTRA_CFLAGS='-Wno-unused -DEXPORT_SYMTAB -DKBUILD_EXTMOD -DINCLUDE_CORE_HCD="/lib/modules/6.6.8-1/build/include/linux/usb/hcd.h" -DKERNEL_VER=6 -DTEST_DEV_INIT_NAME' modules >/dev/null 2>&1; then
echo "//#define NO_DEV_INIT_NAME" >>conf/usb-vhci.config.h;
else
echo "#define NO_DEV_INIT_NAME" >>conf/usb-vhci.config.h;
fi
make clean-test
make[2]: Entering directory '/home/arch/abs/testing/vhci_hcd/src/build/vhci_hcd/1.15.1/build'
rm -f test/.o test/.ko test/..cmd test/..flags test/*.mod.c test/Module.symvers test/Module.markers test/modules.order
rm -rf test/.tmp_versions/
make[2]: Leaving directory '/home/arch/abs/testing/vhci_hcd/src/build/vhci_hcd/1.15.1/build'
if make -C /lib/modules/6.6.8-1/build M=/home/arch/abs/testing/vhci_hcd/src/build/vhci_hcd/1.15.1/build/test PWD=/home/arch/abs/testing/vhci_hcd/src/build/vhci_hcd/1.15.1/build/test BUILD_PREFIX= KDIR=/lib/modules/6.6.8-1/build KVERSION=6.6.8-1 EXTRA_CFLAGS='-Wno-unused -DEXPORT_SYMTAB -DKBUILD_EXTMOD -DINCLUDE_CORE_HCD="/lib/modules/6.6.8-1/build/include/linux/usb/hcd.h" -DKERNEL_VER=6 -DTEST_HAS_TT_FLAG' modules >/dev/null 2>&1; then
echo "//#define NO_HAS_TT_FLAG" >>conf/usb-vhci.config.h;
else
echo "#define NO_HAS_TT_FLAG" >>conf/usb-vhci.config.h;
fi
echo "// end of file" >>conf/usb-vhci.config.h
make[1]: Leaving directory '/home/arch/abs/testing/vhci_hcd/src/build/vhci_hcd/1.15.1/build'
make -C /lib/modules/6.6.8-1/build M=/home/arch/abs/testing/vhci_hcd/src/build/vhci_hcd/1.15.1/build PWD=/home/arch/abs/testing/vhci_hcd/src/build/vhci_hcd/1.15.1/build BUILD_PREFIX= KDIR=/lib/modules/6.6.8-1/build KVERSION=6.6.8-1 modules
make[1]: Entering directory '/usr/lib/modules/6.6.8-1/build'
CC [M] /home/arch/abs/testing/vhci_hcd/src/build/vhci_hcd/1.15.1/build/usb-vhci-hcd.o
CC [M] /home/arch/abs/testing/vhci_hcd/src/build/vhci_hcd/1.15.1/build/usb-vhci-iocifc.o
/home/arch/abs/testing/vhci_hcd/src/build/vhci_hcd/1.15.1/build/usb-vhci-iocifc.c:1073:10: error: ‘struct class’ has no member named ‘owner’
1073 | .owner = THIS_MODULE,
| ^~~~~
In file included from ./include/linux/linkage.h:7,
from ./arch/x86/include/asm/cache.h:5,
from ./include/linux/cache.h:6,
from ./arch/x86/include/asm/current.h:9,
from ./include/linux/sched.h:12,
from ./include/linux/uaccess.h:8,
from /home/arch/abs/testing/vhci_hcd/src/build/vhci_hcd/1.15.1/build/usb-vhci-iocifc.c:23:
./include/linux/export.h:29:21: error: initialization of ‘const char *’ from incompatible pointer type ‘struct module *’ [-Werror=incompatible-pointer-types]
29 | #define THIS_MODULE (&__this_module)
| ^
/home/arch/abs/testing/vhci_hcd/src/build/vhci_hcd/1.15.1/build/usb-vhci-iocifc.c:1073:18: note: in expansion of macro ‘THIS_MODULE’
1073 | .owner = THIS_MODULE,
| ^~~~~~~~~~~
./include/linux/export.h:29:21: note: (near initialization for ‘vhci_iocifc_class.name’)
29 | #define THIS_MODULE (&__this_module)
| ^
/home/arch/abs/testing/vhci_hcd/src/build/vhci_hcd/1.15.1/build/usb-vhci-iocifc.c:1073:18: note: in expansion of macro ‘THIS_MODULE’
1073 | .owner = THIS_MODULE,
| ^~~~~~~~~~~
cc1: some warnings being treated as errors
make[3]: *** [scripts/Makefile.build:243: /home/arch/abs/testing/vhci_hcd/src/build/vhci_hcd/1.15.1/build/usb-vhci-iocifc.o] Error 1
make[3]: *** Waiting for unfinished jobs....
make[2]: *** [/usr/lib/modules/6.6.8-1/build/Makefile:1911: /home/arch/abs/testing/vhci_hcd/src/build/vhci_hcd/1.15.1/build] Error 2
make[1]: *** [Makefile:234: __sub-make] Error 2
make[1]: Leaving directory '/usr/lib/modules/6.6.8-1/build'
make: *** [Makefile:82: default] Error 2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.