summaryrefslogtreecommitdiff
path: root/kvmd/apps/otg
diff options
context:
space:
mode:
authorMaxim Devaev <[email protected]>2022-01-20 09:59:05 +0300
committerMaxim Devaev <[email protected]>2022-01-20 09:59:05 +0300
commitbdc2a317e536dca33048dc8e308fe9a7e20ecc15 (patch)
tree289d5c8b62fb2d8716ee5d5888658c8dea25aaec /kvmd/apps/otg
parentba1f66db9ca0073730533bff79c6df80b9321a42 (diff)
refactoring
Diffstat (limited to 'kvmd/apps/otg')
-rw-r--r--kvmd/apps/otg/__init__.py31
1 files changed, 14 insertions, 17 deletions
diff --git a/kvmd/apps/otg/__init__.py b/kvmd/apps/otg/__init__.py
index c8345d7f..fb2254ad 100644
--- a/kvmd/apps/otg/__init__.py
+++ b/kvmd/apps/otg/__init__.py
@@ -113,33 +113,30 @@ def _create_serial(gadget_path: str, config_path: str) -> None:
def _create_ethernet(gadget_path: str, config_path: str, driver: str, host_mac: str, kvm_mac: str) -> None:
if host_mac and kvm_mac and host_mac == kvm_mac:
raise RuntimeError("Ethernet host_mac should not be equal to kvm_mac")
- drv = driver
+ real_driver = driver
if driver == "rndis5":
- drv = "rndis"
- func_path = join(gadget_path, f"functions/{drv}.usb0")
+ real_driver = "rndis"
+ func_path = join(gadget_path, f"functions/{real_driver}.usb0")
_mkdir(func_path)
if host_mac:
_write(join(func_path, "host_addr"), host_mac)
if kvm_mac:
_write(join(func_path, "dev_addr"), kvm_mac)
- if driver == "rndis":
- # On Windows 7 and later, the RNDIS 5.1 driver would be used by default,
- # but it does not work very well. The RNDIS 6.0 driver works better.
- # In order to get this driver to load automatically, we have to use
- # a Microsoft-specific extension of USB.
- _write(join(func_path, "os_desc/interface.rndis/compatible_id"), "RNDIS")
- _write(join(func_path, "os_desc/interface.rndis/sub_compatible_id"), "5162001")
+ if driver in ["ncm", "rndis"]:
_write(join(gadget_path, "os_desc/use"), "1")
_write(join(gadget_path, "os_desc/b_vendor_code"), "0xCD")
_write(join(gadget_path, "os_desc/qw_sign"), "MSFT100")
+ if driver == "ncm":
+ _write(join(func_path, "os_desc/interface.ncm/compatible_id"), "WINNCM")
+ elif driver == "rndis":
+ # On Windows 7 and later, the RNDIS 5.1 driver would be used by default,
+ # but it does not work very well. The RNDIS 6.0 driver works better.
+ # In order to get this driver to load automatically, we have to use
+ # a Microsoft-specific extension of USB.
+ _write(join(func_path, "os_desc/interface.rndis/compatible_id"), "RNDIS")
+ _write(join(func_path, "os_desc/interface.rndis/sub_compatible_id"), "5162001")
_symlink(config_path, join(gadget_path, "os_desc/c.1"))
- if driver == "ncm":
- _write(join(func_path, "os_desc/interface.ncm/compatible_id"), "WINNCM")
- _write(join(gadget_path, "os_desc/use"), "1")
- _write(join(gadget_path, "os_desc/b_vendor_code"), "0xCD")
- _write(join(gadget_path, "os_desc/qw_sign"), "MSFT100")
- _symlink(config_path, join(gadget_path, "os_desc/c.1"))
- _symlink(func_path, join(config_path, f"{drv}.usb0"))
+ _symlink(func_path, join(config_path, f"{real_driver}.usb0"))
def _create_hid(gadget_path: str, config_path: str, instance: int, remote_wakeup: bool, hid: Hid) -> None: