Diff between 58f8c75c0b094cf9106efc271f4fafd282e6705c and b823e9e96076902b811975264e57a5d218ac8fa8

Changed Files

File Additions Deletions Status
emulator/main.c +5 -0 modified
emulator/server.c +6 -0 modified
emulator/server.h +1 -0 modified

Full Patch

diff --git a/emulator/main.c b/emulator/main.c
index 6a30c8c..807c663 100644
--- a/emulator/main.c
+++ b/emulator/main.c
@@ -65,6 +65,7 @@ int main(int argc, char *argv[])
 	struct server *server1;
 	struct server *server2;
 	struct server *server3;
+	struct server *server4;
 	sigset_t mask;
 
 	mainloop_init();
@@ -112,5 +113,9 @@ int main(int argc, char *argv[])
 	if (!server3)
 		fprintf(stderr, "Failed to open LE server channel\n");
 
+	server4 = server_open_unix(SERVER_TYPE_MONITOR, "/tmp/bt-server-mon");
+	if (!server4)
+		fprintf(stderr, "Failed to open monitor server channel\n");
+
 	return mainloop_run();
 }
diff --git a/emulator/server.c b/emulator/server.c
index 841c2b3..e4c4570 100644
--- a/emulator/server.c
+++ b/emulator/server.c
@@ -117,6 +117,9 @@ again:
 		return;
 	}
 
+	if (!client->btdev)
+		return;
+
 	count = client->pkt_offset + len;
 
 	while (count > 0) {
@@ -223,6 +226,8 @@ static void server_accept_callback(int fd, uint32_t events, void *user_data)
 	case SERVER_TYPE_AMP:
 		type = BTDEV_TYPE_AMP;
 		break;
+	case SERVER_TYPE_MONITOR:
+		goto done;
 	}
 
 	client->btdev = btdev_create(type, server->id);
@@ -234,6 +239,7 @@ static void server_accept_callback(int fd, uint32_t events, void *user_data)
 
 	btdev_set_send_handler(client->btdev, client_write_callback, client);
 
+done:
 	if (mainloop_add_fd(client->fd, EPOLLIN, client_read_callback,
 						client, client_destroy) < 0) {
 		btdev_destroy(client->btdev);
diff --git a/emulator/server.h b/emulator/server.h
index e63e2b2..b99b210 100644
--- a/emulator/server.h
+++ b/emulator/server.h
@@ -28,6 +28,7 @@ enum server_type {
 	SERVER_TYPE_BREDR,
 	SERVER_TYPE_LE,
 	SERVER_TYPE_AMP,
+	SERVER_TYPE_MONITOR,
 };
 
 struct server;