VirtualBox

source: vbox/trunk/src/VBox/Main/include/USBGetDevices.h@ 101041

Last change on this file since 101041 was 98292, checked in by vboxsync, 23 months ago

Main/src-server: rc -> hrc/vrc. Enabled scm rc checks. bugref:10223

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.3 KB
Line 
1/* $Id: USBGetDevices.h 98292 2023-01-25 01:14:53Z vboxsync $ */
2/** @file
3 * VirtualBox Linux host USB device enumeration.
4 */
5
6/*
7 * Copyright (C) 2006-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28#ifndef MAIN_INCLUDED_USBGetDevices_h
29#define MAIN_INCLUDED_USBGetDevices_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34#include <VBox/usb.h>
35#include <iprt/mem.h>
36#include <iprt/string.h>
37
38/**
39 * Free all the members of a USB device created by the Linux enumeration code.
40 *
41 * @note This duplicates a USBProxyService method which we needed access too
42 * without pulling in the rest of the proxy service code.
43 *
44 * @param pDevice Pointer to the device.
45 */
46DECLINLINE(void) deviceFreeMembers(PUSBDEVICE pDevice)
47{
48 RTStrFree((char *)pDevice->pszManufacturer);
49 pDevice->pszManufacturer = NULL;
50 RTStrFree((char *)pDevice->pszProduct);
51 pDevice->pszProduct = NULL;
52 RTStrFree((char *)pDevice->pszSerialNumber);
53 pDevice->pszSerialNumber = NULL;
54
55 RTStrFree((char *)pDevice->pszAddress);
56 pDevice->pszAddress = NULL;
57}
58
59/**
60 * Free one USB device created by the Linux enumeration code.
61 *
62 * @note This duplicates a USBProxyService method which we needed access too
63 * without pulling in the rest of the proxy service code.
64 *
65 * @param pDevice Pointer to the device. NULL is OK.
66 */
67DECLINLINE(void) deviceFree(PUSBDEVICE pDevice)
68{
69 if (pDevice)
70 {
71 deviceFreeMembers(pDevice);
72 RTMemFree(pDevice);
73 }
74}
75
76/**
77 * Free a linked list of USB devices created by the Linux enumeration code.
78 * @param ppHead Pointer to the first device in the linked list
79 */
80DECLINLINE(void) deviceListFree(PUSBDEVICE *ppHead)
81{
82 PUSBDEVICE pHead = *ppHead;
83 while (pHead)
84 {
85 PUSBDEVICE pNext = pHead->pNext;
86 deviceFree(pHead);
87 pHead = pNext;
88 }
89 *ppHead = NULL;
90}
91
92RT_C_DECLS_BEGIN
93
94extern bool USBProxyLinuxCheckDeviceRoot(const char *pcszRoot, bool fIsDeviceNodes);
95
96#ifdef UNIT_TEST
97void TestUSBSetupInit(const char *pcszUsbfsRoot, bool fUsbfsAccessible,
98 const char *pcszDevicesRoot, bool fDevicesAccessible,
99 int vrcMethodInitResult);
100void TestUSBSetEnv(const char *pcszEnvUsb, const char *pcszEnvUsbRoot);
101#endif
102
103extern int USBProxyLinuxChooseMethod(bool *pfUsingUsbfsDevices, const char **ppcszDevicesRoot);
104#ifdef UNIT_TEST
105extern void TestUSBSetAvailableUsbfsDevices(const char **pacszDeviceAddresses);
106extern void TestUSBSetAccessibleFiles(const char **pacszAccessibleFiles);
107#endif
108
109extern PUSBDEVICE USBProxyLinuxGetDevices(const char *pcszDevicesRoot, bool fUseSysfs);
110
111RT_C_DECLS_END
112
113#endif /* !MAIN_INCLUDED_USBGetDevices_h */
114
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette