}
public static String getSdbPath() {
- String sdbPath = null;
-
+ StringBuilder sdbPath = new StringBuilder(".." + File.separator + ".."
+ + File.separator + ".." + File.separator + ".."
+ + File.separator + ".." + File.separator + "tools"
+ + File.separator);
if (SwtUtil.isWindowsPlatform()) {
- sdbPath = "..\\..\\ansicon.exe";
+ sdbPath.append("ansicon.exe");
} else {
- sdbPath = "../../sdb";
+ sdbPath.append("sdb");
}
- return (binaryPath + sdbPath);
+ return (binaryPath + sdbPath.toString());
}
public static String getEcpPath() {
memset(&addr, 0, addrlen);
addr.sin_family = AF_INET;
- addr.sin_addr.s_addr = INADDR_ANY;
+ addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
addr.sin_port = htons(port);
s = qemu_socket(AF_INET, SOCK_STREAM, 0);
return ret;
}
-#define ECS_INDEX 3
+#define ECS_INDEX 3
+#define SDB_GUEST_PORT 26101
void set_base_port(void)
{
int tries = 10;
base_port = get_emul_vm_base_port();
- if(base_port == 0){
+ if (base_port == 0) {
for ( ; tries > 0; tries--, port += 10 ) {
- if(check_port_bind_listen(port + ECS_INDEX) < 0 )
+ if (check_port_bind_listen(port + ECS_INDEX) < 0)
continue;
success = 1;
}
base_port = port;
- INFO( "sdb port is %d\n", base_port);
+ INFO( "emulator base port is %d\n", base_port);
}
set_emul_vm_base_port(base_port);
number = get_device_serial_number();
for ( ; tries > 0; tries--, number += 10 ) {
- sprintf(buf, "tcp:%d::26101", number);
- if(net_slirp_redir((char*)buf) < 0)
+ sprintf(buf, "tcp:%d::%d", number, SDB_GUEST_PORT);
+ if (net_slirp_redir((char*)buf) < 0)
continue;
INFO( "SDBD established on port %d\n", number);
INFO( "Port(%d/tcp) listen for SDB\n", number);
}
-int sdb_loopback_client(int port, int type)
-{
- struct sockaddr_in addr;
- int s;
-
- memset(&addr, 0, sizeof(addr));
- addr.sin_family = AF_INET;
- addr.sin_port = htons(port);
- addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
-
- s = socket(AF_INET, type, 0);
- if(s < 0) return -1;
-
- if(connect(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
- close(s);
- return -1;
- }
-
- return s;
-}
-
/*
* SDB Notification server
*/
memset(&server_addr, '\0', sizeof(server_addr));
server_addr.sin_family = PF_INET;
- server_addr.sin_addr.s_addr = inet_addr("127.0.0.1");
+ server_addr.sin_addr.s_addr = INADDR_ANY;
server_addr.sin_port = htons(port);
qemu_set_nonblock(server->server_fd);