OSDN Git Service

emulator: Allow multiple vhci adapter creation with btvirt
authorJohan Hedberg <johan.hedberg@intel.com>
Thu, 7 Mar 2013 17:00:09 +0000 (19:00 +0200)
committerJohan Hedberg <johan.hedberg@intel.com>
Thu, 7 Mar 2013 17:01:30 +0000 (19:01 +0200)
emulator/main.c

index a11fdd8..f185a97 100644 (file)
@@ -55,9 +55,9 @@ static void usage(void)
 }
 
 static const struct option main_options[] = {
-       { "local",   no_argument, NULL, 'l' },
-       { "version", no_argument, NULL, 'v' },
-       { "help",    no_argument, NULL, 'h' },
+       { "local",   optional_argument, NULL, 'l' },
+       { "version", no_argument,       NULL, 'v' },
+       { "help",    no_argument,       NULL, 'h' },
        { }
 };
 
@@ -69,22 +69,26 @@ int main(int argc, char *argv[])
        struct server *server3;
        struct server *server4;
        struct server *server5;
-       bool enable_vhci = false;
+       int vhci_count = 0;
        enum vhci_type vhci_type = VHCI_TYPE_BREDRLE;
        sigset_t mask;
+       int i;
 
        mainloop_init();
 
        for (;;) {
                int opt;
 
-               opt = getopt_long(argc, argv, "lLBvh", main_options, NULL);
+               opt = getopt_long(argc, argv, "l::LBvh", main_options, NULL);
                if (opt < 0)
                        break;
 
                switch (opt) {
                case 'l':
-                       enable_vhci = true;
+                       if (optarg)
+                               vhci_count = atoi(optarg);
+                       else
+                               vhci_count = 1;
                        break;
                case 'L':
                        vhci_type = VHCI_TYPE_LE;
@@ -111,7 +115,7 @@ int main(int argc, char *argv[])
 
        printf("Bluetooth emulator ver %s\n", VERSION);
 
-       if (enable_vhci) {
+       for (i = 0; i < vhci_count; i++) {
                vhci = vhci_open(vhci_type);
                if (!vhci)
                        fprintf(stderr, "Failed to open Virtual HCI device\n");