Logo Search packages:      
Sourcecode: virtualbox-ose version File versions

for (  ) 

Todo:
filename

Definition at line 446 of file VBoxBFE.cpp.

References _1M, RTMAC::au8, BFENetworkDevice::enmType, BFENetworkDevice::fHaveFd, BFENetworkDevice::fSniff, GenerateMACAddress(), LogFlow, BFENetworkDevice::Mac, networkArg2Index(), BFENetworkDevice::pszName, RT_ELEMENTS, RT_FAILURE, show_usage(), strcmp(), strlen(), SyntaxError(), and VINF_SUCCESS.

Referenced by kldrModMachOObjDoImports(), Console::powerUp(), RTDECL(), and supdrvIOCtl().

    {
        const char * const pszArg = argv[curArg];
        if (strcmp(pszArg, "-boot") == 0)
        {
            if (++curArg >= argc)
                return SyntaxError("missing argument for boot drive!\n");
            if (strlen(argv[curArg]) != 1)
                return SyntaxError("invalid argument for boot drive! (%s)\n", argv[curArg]);
            rc = VINF_SUCCESS;
            switch (argv[curArg][0])
            {
                case 'a':
                {
                    g_pszBootDevice = "FLOPPY";
                    break;
                }

                case 'c':
                {
                    g_pszBootDevice = "IDE";
                    break;
                }

                case 'd':
                {
                    g_pszBootDevice = "DVD";
                    break;
                }

                default:
                    return SyntaxError("wrong argument for boot drive! (%s)\n", argv[curArg]);
            }
        }
        else if (strcmp(pszArg, "-bootmenu") == 0)
        {
            if (++curArg >= argc)
                return SyntaxError("missing argument for boot menu!\n");
            if (strlen(argv[curArg]) != 1 || *argv[curArg] < '0' || *argv[curArg] > '2')
                return SyntaxError("invalid argument for boot menu! (%s)\n", argv[curArg]);
            rc = VINF_SUCCESS;
            g_iBootMenu = *argv[curArg] - 0;
        }
        else if (strcmp(pszArg, "-m") == 0)
        {
            if (++curArg >= argc)
                return SyntaxError("missing argument for memory size!\n");
            rc = RTStrToUInt32Ex(argv[curArg], NULL, 0, &g_u32MemorySizeMB);
            if (RT_FAILURE(rc))
                return SyntaxError("bad memory size: %s (error %Rrc)\n",
                                   argv[curArg], rc);
        }
        else if (strcmp(pszArg, "-vram") == 0)
        {
            if (++curArg >= argc)
                return SyntaxError("missing argument for vram size!\n");
            uint32_t uVRAMMB;
            rc = RTStrToUInt32Ex(argv[curArg], NULL, 0, &uVRAMMB);
            g_u32VRamSize = uVRAMMB * _1M;
            if (RT_FAILURE(rc))
                return SyntaxError("bad video ram size: %s (error %Rrc)\n",
                                   argv[curArg], rc);
        }
        else if (strcmp(pszArg, "-statefile") == 0)
        {
            if (++curArg >= argc)
                return SyntaxError("missing argument for restore!\n");
            g_pszStateFile = argv[curArg];
        }
        else if (strcmp(pszArg, "-restore") == 0)
            g_fRestoreState = true;
        else if (strcmp(pszArg, "-share") == 0)
        {
            if (g_uNumShares >= MaxSharedFolders)
                return SyntaxError("too many shared folders specified!\n");
            if (++curArg >= argc)
                return SyntaxError("missing 1s argument for share!\n");
            g_pszShareDir[g_uNumShares] = argv[curArg];
            if (++curArg >= argc)
                return SyntaxError("missing 2nd argument for share!\n");
            g_pszShareName[g_uNumShares] = argv[curArg];
            if (curArg < argc-1 && strcmp(argv[curArg+1], "readonly") == 0)
            {
                g_fShareReadOnly[g_uNumShares] = true;
                curArg++;
            }
            g_uNumShares++;
        }
        else if (strcmp(pszArg, "-fullscreen") == 0)
            fFullscreen = true;
        else if (strcmp(pszArg, "-nofstoggle") == 0)
            gfAllowFullscreenToggle = false;
        else if (strcmp(pszArg, "-nohostkey") == 0)
        {
            gHostKey = 0;
            gHostKeySym = 0;
        }
        else if (strcmp(pszArg, "-acpi") == 0)
            g_fACPI = true;
        else if (strcmp(pszArg, "-noacpi") == 0)
            g_fACPI = false;
        else if (strcmp(pszArg, "-ioapic") == 0)
            g_fIOAPIC = true;
        else if (strcmp(pszArg, "-noioapic") == 0)
            g_fIOAPIC = false;
        else if (strcmp(pszArg, "-audio") == 0)
            g_fAudio = true;
#ifdef VBOXBFE_WITH_USB
        else if (strcmp(pszArg, "-usb") == 0)
            g_fUSB = true;
#endif
        else if (strcmp(pszArg, "-hda") == 0)
        {
            if (++curArg >= argc)
                return SyntaxError("missing file name for first hard disk!\n");

            /* resolve it. */
            if (RTPathExists(argv[curArg]))
                g_pszHdaFile = RTPathRealDup(argv[curArg]);
            if (!g_pszHdaFile)
                return SyntaxError("The path to the specified harddisk, '%s', could not be resolved.\n", argv[curArg]);
        }
        else if (strcmp(pszArg, "-hdaspf") == 0)
        {
            g_fHdaSpf = true;
        }
        else if (strcmp(pszArg, "-hdb") == 0)
        {
            if (++curArg >= argc)
                return SyntaxError("missing file name for second hard disk!\n");

            /* resolve it. */
            if (RTPathExists(argv[curArg]))
                g_pszHdbFile = RTPathRealDup(argv[curArg]);
            if (!g_pszHdbFile)
                return SyntaxError("The path to the specified harddisk, '%s', could not be resolved.\n", argv[curArg]);
        }
        else if (strcmp(pszArg, "-hdbspf") == 0)
        {
            g_fHdbSpf = true;
        }
        else if (strcmp(pszArg, "-fda") == 0)
        {
            if (++curArg >= argc)
                return SyntaxError("missing file/device name for first floppy disk!\n");

            /* resolve it. */
            if (RTPathExists(argv[curArg]))
                g_pszFdaFile = RTPathRealDup(argv[curArg]);
            if (!g_pszFdaFile)
                return SyntaxError("The path to the specified floppy disk, '%s', could not be resolved.\n", argv[curArg]);
        }
        else if (strcmp(pszArg, "-cdrom") == 0)
        {
            if (++curArg >= argc)
                return SyntaxError("missing file/device name for first hard disk!\n");

            /* resolve it. */
            if (RTPathExists(argv[curArg]))
                g_pszCdromFile = RTPathRealDup(argv[curArg]);
            if (!g_pszCdromFile)
                return SyntaxError("The path to the specified cdrom, '%s', could not be resolved.\n", argv[curArg]);
        }
#ifdef RT_OS_L4
        /* This is leaving a lot of dead code in the L4 version of course,
           but I don't think that that is a major problem.  We may even
           activate it sometime... */
        else if (   strncmp(pszArg, "-hifdev", 7) == 0
                 || strncmp(pszArg, "-nonetd", 7) == 0)
#else
        else if (   strncmp(pszArg, "-natdev", 7) == 0
                 || strncmp(pszArg, "-hifdev", 7) == 0
                 || strncmp(pszArg, "-nonetd", 7) == 0
                 || strncmp(pszArg, "-intnet", 7) == 0)
#endif
        {
            int i = networkArg2Index(pszArg, 7);
            if (i < 0)
                return 1;
            g_aNetDevs[i].enmType = !strncmp(pszArg, "-natdev", 7)
                                  ? BFENETDEV::NAT
                                  : !strncmp(pszArg, "-hifdev", 7)
                                  ? BFENETDEV::HIF
                                  : !strncmp(pszArg, "-intnet", 7)
                                  ? BFENETDEV::INTNET
                                  : BFENETDEV::NONE;

            /* The HIF device name / The Internal Network name. */
            g_aNetDevs[i].pszName = NULL;
            if (    g_aNetDevs[i].enmType == BFENETDEV::HIF
                ||  g_aNetDevs[i].enmType == BFENETDEV::INTNET)
            {
                if (curArg + 1 >= argc)
                    return SyntaxError(g_aNetDevs[i].enmType == BFENETDEV::HIF
                                       ? "The TAP network device name is missing! (%s)\n"
                                       : "The internal network name is missing! (%s)\n"
                                       , pszArg);
                g_aNetDevs[i].pszName = argv[++curArg];
            }

            /* The MAC address. */
            const char *pszMac;
            char szMacGen[MAC_STRING_LEN + 1];
            if ((curArg + 1 < argc) && (argv[curArg + 1][0] != '-'))
                pszMac = argv[++curArg];
            else
            {
                rc = GenerateMACAddress(szMacGen);
                if (RT_FAILURE(rc))
                    return SyntaxError("failed to generate a hardware address for network device %d (error %Rrc)\n",
                                       i, rc);
                pszMac = szMacGen;
            }
            if (strlen(pszMac) != MAC_STRING_LEN)
                return SyntaxError("The network MAC address has an invalid length: %s (%s)\n", pszMac, pszArg);
            for (unsigned j = 0; j < RT_ELEMENTS(g_aNetDevs[i].Mac.au8); j++)
            {
                char c1 = toupper(*pszMac++) - '0';
                if (c1 > 9)
                    c1 -= 7;
                char c2 = toupper(*pszMac++) - '0';
                if (c2 > 9)
                    c2 -= 7;
                if (c2 > 16 || c1 > 16)
                    return SyntaxError("Invalid MAC address: %s\n", argv[curArg]);
                g_aNetDevs[i].Mac.au8[j] = ((c1 & 0x0f) << 4) | (c2 & 0x0f);
            }
        }
        else if (strncmp(pszArg, "-netsniff", 9) == 0)
        {
            int i = networkArg2Index(pszArg, 9);
            if (i < 0)
                return 1;
            g_aNetDevs[i].fSniff = true;
            /** @todo filename */
        }
#ifdef RT_OS_OS2
        else if (strncmp(pszArg, "-brdev", 6) == 0)
        {
            int i = networkArg2Index(pszArg, 6);
            if (i < 0)
                return 1;
            if (g_aNetDevs[i].enmType != BFENETDEV::HIF)
                return SyntaxError("%d is not a hif device! Make sure you put the -hifdev argument first.\n", i);
            if (++curArg >= argc)
                return SyntaxError("missing argument for %s!\n", pszArg);
            if (    strncmp(argv[curArg], "lan", 3)
                ||  argv[curArg][3] < '0'
                ||  argv[curArg][3] >= '8'
                ||  argv[curArg][4])
                return SyntaxError("bad interface name '%s' specified with '%s'. Expected 'lan0', 'lan1' and similar.\n",
                                   argv[curArg], pszArg);
            g_aNetDevs[i].iConnectTo = argv[curArg][3] - '0';
            g_aNetDevs[i].fHaveConnectTo = true;
        }
#endif
#ifdef RT_OS_LINUX
        else if (strncmp(pszArg, "-tapfd", 6) == 0)
        {
            int i = networkArg2Index(pszArg, 6);
            if (i < 0)
                return 1;
            if (++curArg >= argc)
                return SyntaxError("missing argument for %s!\n", pszArg);
            rc = RTStrToInt32Ex(argv[curArg], NULL, 0, &g_aNetDevs[i].fd);
            if (RT_FAILURE(rc))
                return SyntaxError("bad tap file descriptor: %s (error %Rrc)\n", argv[curArg], rc);
            g_aNetDevs[i].fHaveFd = true;
        }
#endif /* RT_OS_LINUX */
#ifdef VBOX_WITH_VRDP
        else if (strcmp(pszArg, "-vrdp") == 0)
        {
            // -vrdp might take a port number (positive).
            portVRDP = 0;       // indicate that it was encountered.
            if (curArg + 1 < argc && argv[curArg + 1][0] != '-')
            {
                rc = RTStrToInt32Ex(argv[curArg], NULL, 0, &portVRDP);
                if (RT_FAILURE(rc))
                    return SyntaxError("cannot vrpd port: %s (%Rrc)\n", argv[curArg], rc);
                if (portVRDP < 0 || portVRDP >= 0x10000)
                    return SyntaxError("vrdp port number is out of range: %RI32\n", portVRDP);
            }
        }
#endif /* VBOX_WITH_VRDP */
#ifdef VBOX_SECURELABEL
        else if (strcmp(pszArg, "-securelabel") == 0)
        {
            fSecureLabel = true;
            LogFlow(("Secure labelling turned on\n"));
        }
        else if (strcmp(pszArg, "-seclabelfnt") == 0)
        {
            if (++curArg >= argc)
                return SyntaxError("missing font file name for secure label!\n");
            secureLabelFontFile = argv[curArg];
        }
        else if (strcmp(pszArg, "-seclabelsiz") == 0)
        {
            if (++curArg >= argc)
                return SyntaxError("missing font point size for secure label!\n");
            secureLabelPointSize = atoi(argv[curArg]);
        }
#endif
        else if (strcmp(pszArg, "-rellog") == 0)
            g_fReleaseLog = true;
        else if (strcmp(pszArg, "-norellog") == 0)
            g_fReleaseLog = false;
        else if (strcmp(pszArg, "-prealloc") == 0)
            g_fPreAllocRam = true;
#ifdef VBOXSDL_ADVANCED_OPTIONS
        else if (strcmp(pszArg, "-rawr0") == 0)
            g_fRawR0 = true;
        else if (strcmp(pszArg, "-norawr0") == 0)
            g_fRawR0 = false;
        else if (strcmp(pszArg, "-rawr3") == 0)
            g_fRawR3 = true;
        else if (strcmp(pszArg, "-norawr3") == 0)
            g_fRawR3 = false;
        else if (strcmp(pszArg, "-patm") == 0)
            g_fPATM = true;
        else if (strcmp(pszArg, "-nopatm") == 0)
            g_fPATM = false;
        else if (strcmp(pszArg, "-csam") == 0)
            g_fCSAM = true;
        else if (strcmp(pszArg, "-nocsam") == 0)
            g_fCSAM = false;
#endif /* VBOXSDL_ADVANCED_OPTIONS */
#ifdef RT_OS_L4
        else if (strcmp(pszArg, "-env") == 0)
            ++curArg;
#endif /* RT_OS_L4 */
        /* just show the help screen */
        else
        {
            SyntaxError("unrecognized argument '%s'\n", pszArg);
            show_usage();
            return 1;
        }
    }


Generated by  Doxygen 1.6.0   Back to index