Loading adb/adb.c +28 −5 Original line number Diff line number Diff line Loading @@ -1020,19 +1020,24 @@ int handle_host_request(char *service, transport_type ttype, char* serial, int r char* portstr = strchr(host, ':'); if (!portstr) { snprintf(buffer, sizeof(buffer), "unable to parse %s as <host>:<port>\n", host); snprintf(buffer, sizeof(buffer), "unable to parse %s as <host>:<port>", host); goto done; } if (find_transport(host)) { snprintf(buffer, sizeof(buffer), "Already connected to %s", host); goto done; } // zero terminate host by overwriting the ':' *portstr++ = 0; if (sscanf(portstr, "%d", &port) == 0) { snprintf(buffer, sizeof(buffer), "bad port number %s\n", portstr); snprintf(buffer, sizeof(buffer), "bad port number %s", portstr); goto done; } fd = socket_network_client(host, port, SOCK_STREAM); if (fd < 0) { snprintf(buffer, sizeof(buffer), "unable to connect to %s:%d\n", host, port); snprintf(buffer, sizeof(buffer), "unable to connect to %s:%d", host, port); goto done; } Loading @@ -1041,7 +1046,7 @@ int handle_host_request(char *service, transport_type ttype, char* serial, int r disable_tcp_nagle(fd); snprintf(buf, sizeof buf, "%s:%d", host, port); register_socket_transport(fd, buf, port, 0); snprintf(buffer, sizeof(buffer), "connected to %s:%d\n", host, port); snprintf(buffer, sizeof(buffer), "connected to %s:%d", host, port); done: snprintf(buf, sizeof(buf), "OKAY%04x%s",(unsigned)strlen(buffer), buffer); Loading @@ -1049,6 +1054,24 @@ done: return 0; } // remove TCP transport if (!strncmp(service, "disconnect:", 11)) { char buffer[4096]; memset(buffer, 0, sizeof(buffer)); char* serial = service + 11; atransport *t = find_transport(serial); if (t) { unregister_transport(t); } else { snprintf(buffer, sizeof(buffer), "No such device %s", serial); } snprintf(buf, sizeof(buf), "OKAY%04x%s",(unsigned)strlen(buffer), buffer); writex(reply_fd, buf, strlen(buf)); return 0; } // returns our value for ADB_SERVER_VERSION if (!strcmp(service, "version")) { char version[12]; Loading adb/adb.h +6 −0 Original line number Diff line number Diff line Loading @@ -270,11 +270,17 @@ void close_usb_devices(); /* cause new transports to be init'd and added to the list */ void register_socket_transport(int s, const char *serial, int port, int local); /* this should only be used for the "adb disconnect" command */ void unregister_transport(atransport *t); void register_usb_transport(usb_handle *h, const char *serial, unsigned writeable); /* this should only be used for transports with connection_state == CS_NOPERM */ void unregister_usb_transport(usb_handle *usb); atransport *find_transport(const char *serial); int service_to_fd(const char *name); #if ADB_HOST asocket *host_service_to_socket(const char* name, const char *serial); Loading adb/commandline.c +3 −2 Original line number Diff line number Diff line Loading @@ -106,6 +106,7 @@ void help() " be an absolute path.\n" " devices - list all connected devices\n" " connect <host>:<port> - connect to a device via TCP/IP" " disconnect <host>:<port> - disconnect from a TCP/IP device" "\n" "device commands:\n" " adb push <local> <remote> - copy file/dir to device\n" Loading Loading @@ -853,10 +854,10 @@ top: } } if(!strcmp(argv[0], "connect")) { if(!strcmp(argv[0], "connect") || !strcmp(argv[0], "disconnect")) { char *tmp; if (argc != 2) { fprintf(stderr, "Usage: adb connect <host>:<port>\n"); fprintf(stderr, "Usage: adb %s <host>:<port>\n", argv[0]); return 1; } snprintf(buf, sizeof buf, "host:%s:%s", argv[0], argv[1]); Loading adb/jdwp_service.c +1 −1 Original line number Diff line number Diff line Loading @@ -164,7 +164,7 @@ jdwp_process_free( JdwpProcess* proc ) proc->next->prev = proc->prev; if (proc->socket >= 0) { shutdown(proc->socket, SHUT_RDWR); adb_shutdown(proc->socket); adb_close(proc->socket); proc->socket = -1; } Loading adb/sysdeps.h +8 −0 Original line number Diff line number Diff line Loading @@ -113,6 +113,7 @@ extern int adb_creat(const char* path, int mode); extern int adb_read(int fd, void* buf, int len); extern int adb_write(int fd, const void* buf, int len); extern int adb_lseek(int fd, int pos, int where); extern int adb_shutdown(int fd); extern int adb_close(int fd); static __inline__ int unix_close(int fd) Loading Loading @@ -327,6 +328,13 @@ static __inline__ int adb_open( const char* pathname, int options ) #undef open #define open ___xxx_open static __inline__ int adb_shutdown(int fd) { return shutdown(fd, SHUT_RDWR); } #undef shutdown #define shutdown ____xxx_shutdown static __inline__ int adb_close(int fd) { return close(fd); Loading Loading
adb/adb.c +28 −5 Original line number Diff line number Diff line Loading @@ -1020,19 +1020,24 @@ int handle_host_request(char *service, transport_type ttype, char* serial, int r char* portstr = strchr(host, ':'); if (!portstr) { snprintf(buffer, sizeof(buffer), "unable to parse %s as <host>:<port>\n", host); snprintf(buffer, sizeof(buffer), "unable to parse %s as <host>:<port>", host); goto done; } if (find_transport(host)) { snprintf(buffer, sizeof(buffer), "Already connected to %s", host); goto done; } // zero terminate host by overwriting the ':' *portstr++ = 0; if (sscanf(portstr, "%d", &port) == 0) { snprintf(buffer, sizeof(buffer), "bad port number %s\n", portstr); snprintf(buffer, sizeof(buffer), "bad port number %s", portstr); goto done; } fd = socket_network_client(host, port, SOCK_STREAM); if (fd < 0) { snprintf(buffer, sizeof(buffer), "unable to connect to %s:%d\n", host, port); snprintf(buffer, sizeof(buffer), "unable to connect to %s:%d", host, port); goto done; } Loading @@ -1041,7 +1046,7 @@ int handle_host_request(char *service, transport_type ttype, char* serial, int r disable_tcp_nagle(fd); snprintf(buf, sizeof buf, "%s:%d", host, port); register_socket_transport(fd, buf, port, 0); snprintf(buffer, sizeof(buffer), "connected to %s:%d\n", host, port); snprintf(buffer, sizeof(buffer), "connected to %s:%d", host, port); done: snprintf(buf, sizeof(buf), "OKAY%04x%s",(unsigned)strlen(buffer), buffer); Loading @@ -1049,6 +1054,24 @@ done: return 0; } // remove TCP transport if (!strncmp(service, "disconnect:", 11)) { char buffer[4096]; memset(buffer, 0, sizeof(buffer)); char* serial = service + 11; atransport *t = find_transport(serial); if (t) { unregister_transport(t); } else { snprintf(buffer, sizeof(buffer), "No such device %s", serial); } snprintf(buf, sizeof(buf), "OKAY%04x%s",(unsigned)strlen(buffer), buffer); writex(reply_fd, buf, strlen(buf)); return 0; } // returns our value for ADB_SERVER_VERSION if (!strcmp(service, "version")) { char version[12]; Loading
adb/adb.h +6 −0 Original line number Diff line number Diff line Loading @@ -270,11 +270,17 @@ void close_usb_devices(); /* cause new transports to be init'd and added to the list */ void register_socket_transport(int s, const char *serial, int port, int local); /* this should only be used for the "adb disconnect" command */ void unregister_transport(atransport *t); void register_usb_transport(usb_handle *h, const char *serial, unsigned writeable); /* this should only be used for transports with connection_state == CS_NOPERM */ void unregister_usb_transport(usb_handle *usb); atransport *find_transport(const char *serial); int service_to_fd(const char *name); #if ADB_HOST asocket *host_service_to_socket(const char* name, const char *serial); Loading
adb/commandline.c +3 −2 Original line number Diff line number Diff line Loading @@ -106,6 +106,7 @@ void help() " be an absolute path.\n" " devices - list all connected devices\n" " connect <host>:<port> - connect to a device via TCP/IP" " disconnect <host>:<port> - disconnect from a TCP/IP device" "\n" "device commands:\n" " adb push <local> <remote> - copy file/dir to device\n" Loading Loading @@ -853,10 +854,10 @@ top: } } if(!strcmp(argv[0], "connect")) { if(!strcmp(argv[0], "connect") || !strcmp(argv[0], "disconnect")) { char *tmp; if (argc != 2) { fprintf(stderr, "Usage: adb connect <host>:<port>\n"); fprintf(stderr, "Usage: adb %s <host>:<port>\n", argv[0]); return 1; } snprintf(buf, sizeof buf, "host:%s:%s", argv[0], argv[1]); Loading
adb/jdwp_service.c +1 −1 Original line number Diff line number Diff line Loading @@ -164,7 +164,7 @@ jdwp_process_free( JdwpProcess* proc ) proc->next->prev = proc->prev; if (proc->socket >= 0) { shutdown(proc->socket, SHUT_RDWR); adb_shutdown(proc->socket); adb_close(proc->socket); proc->socket = -1; } Loading
adb/sysdeps.h +8 −0 Original line number Diff line number Diff line Loading @@ -113,6 +113,7 @@ extern int adb_creat(const char* path, int mode); extern int adb_read(int fd, void* buf, int len); extern int adb_write(int fd, const void* buf, int len); extern int adb_lseek(int fd, int pos, int where); extern int adb_shutdown(int fd); extern int adb_close(int fd); static __inline__ int unix_close(int fd) Loading Loading @@ -327,6 +328,13 @@ static __inline__ int adb_open( const char* pathname, int options ) #undef open #define open ___xxx_open static __inline__ int adb_shutdown(int fd) { return shutdown(fd, SHUT_RDWR); } #undef shutdown #define shutdown ____xxx_shutdown static __inline__ int adb_close(int fd) { return close(fd); Loading