/* validate the length of each of the 3 parts */
start = buffer; for (part = 0; part < 3; part++) {
end = strchr(start, delim[part]); if (end == NULL || (end - start) > max_len[part]) {
free(buffer); return -1;
}
start = end + 1;
}
/* will be freed in usbip_driver_close() */
hc_device =
udev_device_new_from_subsystem_sysname(udev_context,
USBIP_VHCI_BUS_TYPE,
USBIP_VHCI_DEVICE_NAME); if (!hc_device) {
err("udev_device_new_from_subsystem_sysname failed"); goto err;
}
nports = get_nports(hc_device); if (nports <= 0) {
err("no available ports"); goto err;
}
dbg("available ports: %d", nports);
if (vhci_driver->ncontrollers <=0) {
err("no available usb controllers"); goto err;
}
if (refresh_imported_device_list()) goto err;
return0;
err:
udev_device_unref(hc_device);
if (vhci_driver)
free(vhci_driver);
vhci_driver = NULL;
udev_unref(udev_context);
return -1;
}
void usbip_vhci_driver_close(void)
{ if (!vhci_driver) return;
udev_device_unref(vhci_driver->hc_device);
free(vhci_driver);
vhci_driver = NULL;
udev_unref(udev_context);
}
int usbip_vhci_refresh_device_list(void)
{
if (refresh_imported_device_list()) goto err;
return0;
err:
dbg("failed to refresh device list"); return -1;
}
int usbip_vhci_get_free_port(uint32_t speed)
{ for (int i = 0; i < vhci_driver->nports; i++) {
switch (speed) { case USB_SPEED_SUPER: if (vhci_driver->idev[i].hub != HUB_SPEED_SUPER) continue; break; default: if (vhci_driver->idev[i].hub != HUB_SPEED_HIGH) continue; break;
}
if (vhci_driver->idev[i].status == VDEV_ST_NULL) return vhci_driver->idev[i].port;
}
return -1;
}
int usbip_vhci_attach_device2(uint8_t port, int sockfd, uint32_t devid,
uint32_t speed) { char buff[200]; /* what size should be ? */ char attach_attr_path[SYSFS_PATH_MAX]; char attr_attach[] = "attach"; constchar *path; int ret;
/* will be removed */ int usbip_vhci_attach_device(uint8_t port, int sockfd, uint8_t busnum,
uint8_t devnum, uint32_t speed)
{ int devid = get_devid(busnum, devnum);
int usbip_vhci_detach_device(uint8_t port)
{ char detach_attr_path[SYSFS_PATH_MAX]; char attr_detach[] = "detach"; char buff[200]; /* what size should be ? */ constchar *path; int ret;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.