Diff between bc3feb5e777d8d2d0c097f7bf235eafc1967b594 and b9ab5a45fffa6131d4514d7ccda1cfe8fa9015f6

Changed Files

File Additions Deletions Status
test/hciemu.c +6 -16 modified

Full Patch

diff --git a/test/hciemu.c b/test/hciemu.c
index ca6a867..38918f5 100644
--- a/test/hciemu.c
+++ b/test/hciemu.c
@@ -40,7 +40,6 @@
 #include <sys/epoll.h>
 #include <sys/socket.h>
 #include <sys/resource.h>
-#include <netdb.h>
 
 #include <bluetooth/bluetooth.h>
 #include <bluetooth/hci.h>
@@ -968,22 +967,13 @@ static int getbdaddrbyname(char *str, bdaddr_t *ba)
 		return 0;
 	}
 
-	if (n == 1) {
-		/* IP address + port */
-		struct hostent *hent;
+	if (n == 0) {
+		/* loopback port */
+		in_addr_t addr = INADDR_LOOPBACK;
 		bdaddr_t b;
-		char *ptr;
 
-		ptr = strchr(str, ':');
-		*ptr++ = 0;
-
-		if (!(hent = gethostbyname(str))) {
-			fprintf(stderr, "Can't resolve %s\n", str);
-			return -2;
-		}
-
-		memcpy(&b, hent->h_addr, 4);
-		*(uint16_t *) (&b.b[4]) = htons(atoi(ptr));
+		memcpy(&b, &addr, 4);
+		*(uint16_t *) (&b.b[4]) = htons(atoi(str));
 		baswap(ba, &b);
 
 		return 0;
@@ -998,7 +988,7 @@ static void usage(void)
 {
 	printf("hciemu - HCI emulator ver %s\n", VERSION);
 	printf("Usage: \n");
-	printf("\thciemu [options] local_address\n"
+	printf("\thciemu [options] port_number\n"
 		"Options:\n"
 		"\t[-d device] use specified device node\n"
 		"\t[-s file] create snoop file\n"