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 int list_exported_devices(char *host) { int rc; int sockfd; sockfd = usbip_net_tcp_connect(host, USBIP_PORT_STRING); if (sockfd < 0) { err("could not connect to %s:%s: %s", host, USBIP_PORT_STRING, gai_strerror(sockfd)); return -1; } dbg("connected to %s:%s", host, USBIP_PORT_STRING); rc = get_exported_devices(host, sockfd); if (rc < 0) { err("failed to get device list from %s", host); return -1; } close(sockfd); return 0; }