mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 09:10:30 +08:00
options to configure otg ethernet
This commit is contained in:
parent
a86ec65024
commit
771640a79c
@ -387,6 +387,12 @@ def _get_config_scheme() -> Dict:
|
|||||||
"enabled": Option(False, type=valid_bool),
|
"enabled": Option(False, type=valid_bool),
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"ethernet": {
|
||||||
|
"enabled": Option(False, type=valid_bool),
|
||||||
|
"host_mac": Option("", type=valid_mac, only_if="enabled"),
|
||||||
|
"kvm_mac": Option("", type=valid_mac, only_if="enabled"),
|
||||||
|
},
|
||||||
|
|
||||||
"drives": {
|
"drives": {
|
||||||
"enabled": Option(False, type=valid_bool),
|
"enabled": Option(False, type=valid_bool),
|
||||||
"count": Option(1, type=valid_int_f1),
|
"count": Option(1, type=valid_int_f1),
|
||||||
|
|||||||
@ -97,6 +97,7 @@ def _find_udc(udc: str) -> str:
|
|||||||
def _check_config(config: Section) -> None:
|
def _check_config(config: Section) -> None:
|
||||||
if (
|
if (
|
||||||
not config.otg.acm.enabled
|
not config.otg.acm.enabled
|
||||||
|
and not config.otg.ethernet.enabled
|
||||||
and config.kvmd.hid.type != "otg"
|
and config.kvmd.hid.type != "otg"
|
||||||
and config.kvmd.msd.type != "otg"
|
and config.kvmd.msd.type != "otg"
|
||||||
):
|
):
|
||||||
@ -110,6 +111,16 @@ def _create_acm(gadget_path: str, config_path: str) -> None:
|
|||||||
_symlink(func_path, join(config_path, "acm.usb0"))
|
_symlink(func_path, join(config_path, "acm.usb0"))
|
||||||
|
|
||||||
|
|
||||||
|
def _create_ethernet(gadget_path: str, config_path: str, host_mac: str, kvm_mac: str) -> None:
|
||||||
|
if host_mac == kvm_mac:
|
||||||
|
raise RuntimeError("Ethernet host_mac should not be equal to kvm_mac")
|
||||||
|
func_path = join(gadget_path, "functions/ecm.usb0")
|
||||||
|
_mkdir(func_path)
|
||||||
|
_write(join(func_path, "host_addr"), host_mac)
|
||||||
|
_write(join(func_path, "dev_addr"), kvm_mac)
|
||||||
|
_symlink(func_path, join(config_path, "ecm.usb0"))
|
||||||
|
|
||||||
|
|
||||||
def _create_hid(gadget_path: str, config_path: str, instance: int, hid: Hid) -> None:
|
def _create_hid(gadget_path: str, config_path: str, instance: int, hid: Hid) -> None:
|
||||||
func_path = join(gadget_path, f"functions/hid.usb{instance}")
|
func_path = join(gadget_path, f"functions/hid.usb{instance}")
|
||||||
_mkdir(func_path)
|
_mkdir(func_path)
|
||||||
@ -181,6 +192,10 @@ def _cmd_start(config: Section) -> None:
|
|||||||
logger.info("Required ACM")
|
logger.info("Required ACM")
|
||||||
_create_acm(gadget_path, config_path)
|
_create_acm(gadget_path, config_path)
|
||||||
|
|
||||||
|
if config.otg.ethernet.enabled:
|
||||||
|
logger.info("Required Ethernet")
|
||||||
|
_create_ethernet(gadget_path, config_path, config.otg.ethernet.host_mac, config.otg.ethernet.kvm_mac)
|
||||||
|
|
||||||
if config.kvmd.hid.type == "otg":
|
if config.kvmd.hid.type == "otg":
|
||||||
logger.info("Required HID")
|
logger.info("Required HID")
|
||||||
_create_hid(gadget_path, config_path, 0, KEYBOARD_HID)
|
_create_hid(gadget_path, config_path, 0, KEYBOARD_HID)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user