static void attach_device(char *host, char *busid) { int sockfd; int ret; int rhport; sockfd = tcp_connect(host, USBIP_PORT_STRING); if (sockfd < 0) { err("tcp connect"); return; } rhport = query_import_device(sockfd, busid); if (rhport < 0) { err("query"); return; } close(sockfd); ret = record_connection(host, USBIP_PORT_STRING, busid, rhport); if (ret < 0) err("record connection"); return; }
static int attach_device(char *host, char *busid) { int sockfd; int rc; int rhport; sockfd = usbip_net_tcp_connect(host, USBIP_PORT_STRING); if (sockfd < 0) { err("tcp connect"); return -1; } rhport = query_import_device(sockfd, busid); if (rhport < 0) { err("query"); return -1; } close(sockfd); rc = record_connection(host, USBIP_PORT_STRING, busid, rhport); if (rc < 0) { err("record connection"); return -1; } return 0; }
static void attach_device(char * host, char * busid) { SOCKET sockfd; int rhport; HANDLE devfd=INVALID_HANDLE_VALUE; struct usb_interface uinf; sockfd = tcp_connect(host, USBIP_PORT_STRING); if (INVALID_SOCKET == sockfd) { err("tcp connect"); return; } if(query_interface0(sockfd, busid, &uinf)){ err("can't found device"); return; } closesocket(sockfd); sockfd = tcp_connect(host, USBIP_PORT_STRING); if (INVALID_SOCKET == sockfd) { err("tcp connect"); return; } rhport = query_import_device(sockfd, busid, &uinf, &devfd); if (rhport < 0) { err("query"); return; } info("new usb device attached to usbvbus port %d\n", rhport); usbip_vbus_forward(sockfd, devfd); closesocket(sockfd); CloseHandle(devfd); return; }