int decode_cmd(int argc, char **argv) { int i, i1; memset(&cmdParam, 0, sizeof(cmdParam)); for (i = i1 = 1; i < argc; i++) { if (strcmp(argv[i], "-h") == 0) { // show help message return -1; } if (strcmp(argv[i], "-x") == 0) { /* X resolution */ if (i + 1 >= argc) { return -1; } cmdParam.x = atoi(argv[++i]); } else if (strcmp(argv[i], "-y") == 0) { /* X resolution */ if (i + 1 >= argc) { return -1; } cmdParam.y = atoi(argv[++i]); } else if (strcmp(argv[i], "-bpp") == 0) { /* bit per pixel */ if (i + 1 >= argc) { return -1; } cmdParam.bpp = atoi(argv[++i]); } else if (strcmp(argv[i], "-p6") == 0) { /* ipv6 port */ if (i + 1 >= argc) { return -1; } cmdParam.net.ipv6Port = atoi(argv[++i]); } else if (strcmp(argv[i], "-p4") == 0) { /* ipv4 port */ if (i + 1 >= argc) { return -1; } cmdParam.net.ipv4Port = atoi(argv[++i]); } else if (strcmp(argv[i], "-a6") == 0) { /* ipv6 Address*/ if (i + 1 >= argc || !RTNetIsIPv6AddrStr(argv[i+1])) { return -1; } strncpy(cmdParam.net.ipv6Addr, argv[++i], sizeof(cmdParam.net.ipv6Addr)); } else if (strcmp(argv[i], "-a4") == 0) { /* ipv4 Address*/ if (i + 1 >= argc || !RTNetIsIPv4AddrStr(argv[i+1])) { return -1; } strncpy(cmdParam.net.ipv4Addr, argv[++i], sizeof(cmdParam.net.ipv4Addr)); } else if (strcmp(argv[i], "-tf") == 0) { /* Testing file input. */ if (i + 1 >= argc) { return -1; } cmdParam.inputFile = argv[++i]; // testing file only works with dummy driver, so enable it automatically. cmdParam.enableDummyDriver = true; } else if (strcmp(argv[i], "-dummy") == 0) { /* use dummy Driver */ cmdParam.enableDummyDriver = true; } else if (strcmp(argv[i], "-v") == 0) { RTPrintf("%s Version: %d.%d.%d\n", VBOX_PRODUCT, VBOX_VERSION_MAJOR, VBOX_VERSION_MINOR, VBOX_VERSION_BUILD); exit(0); } } if (cmdParam.x == 0) { cmdParam.x = 800; } if (cmdParam.y == 0) { cmdParam.y = 600; } if (cmdParam.bpp != 8 && cmdParam.bpp != 16 && cmdParam.bpp != 24 && cmdParam.bpp != 32) { cmdParam.bpp = 32; } // Only 32 bpp works on current XPDM driver cmdParam.bpp = 32; // dump_cmd(&cmdParam); return 0; }
bool UIItemNetworkHost::validate(UIValidationMessage &message) { /* Pass by default: */ bool fPass = true; /* Host interface validation: */ if (!m_data.m_interface.m_fDhcpClientEnabled) { if (!m_data.m_interface.m_strInterfaceAddress.trimmed().isEmpty() && ( !RTNetIsIPv4AddrStr(m_data.m_interface.m_strInterfaceAddress.toAscii().constData()) || RTNetStrIsIPv4AddrAny(m_data.m_interface.m_strInterfaceAddress.toAscii().constData()))) { message.second << UIGlobalSettingsNetwork::tr("Host interface <b>%1</b> does not currently have a valid IPv4 address.").arg(text(0)); fPass = false; } if (!m_data.m_interface.m_strInterfaceMask.trimmed().isEmpty() && ( !RTNetIsIPv4AddrStr(m_data.m_interface.m_strInterfaceMask.toAscii().constData()) || RTNetStrIsIPv4AddrAny(m_data.m_interface.m_strInterfaceMask.toAscii().constData()))) { message.second << UIGlobalSettingsNetwork::tr("Host interface <b>%1</b> does not currently have a valid IPv4 network mask.").arg(text(0)); fPass = false; } if (m_data.m_interface.m_fIpv6Supported) { if (!m_data.m_interface.m_strInterfaceAddress6.trimmed().isEmpty() && ( !RTNetIsIPv6AddrStr(m_data.m_interface.m_strInterfaceAddress6.toAscii().constData()) || RTNetStrIsIPv6AddrAny(m_data.m_interface.m_strInterfaceAddress6.toAscii().constData()))) { message.second << UIGlobalSettingsNetwork::tr("Host interface <b>%1</b> does not currently have a valid IPv6 address.").arg(text(0)); fPass = false; } bool fIsMaskPrefixLengthNumber = false; const int iMaskPrefixLength = m_data.m_interface.m_strInterfaceMaskLength6.trimmed().toInt(&fIsMaskPrefixLengthNumber); if ( !fIsMaskPrefixLengthNumber || iMaskPrefixLength < 0 || iMaskPrefixLength > 128) { message.second << UIGlobalSettingsNetwork::tr("Host interface <b>%1</b> does not currently have a valid IPv6 network mask prefix length.").arg(text(0)); fPass = false; } } } /* DHCP server validation: */ if (m_data.m_dhcpserver.m_fDhcpServerEnabled) { if ( !RTNetIsIPv4AddrStr(m_data.m_dhcpserver.m_strDhcpServerAddress.toAscii().constData()) || RTNetStrIsIPv4AddrAny(m_data.m_dhcpserver.m_strDhcpServerAddress.toAscii().constData())) { message.second << UIGlobalSettingsNetwork::tr("Host interface <b>%1</b> does not currently have a valid DHCP server address.").arg(text(0)); fPass = false; } if ( !RTNetIsIPv4AddrStr(m_data.m_dhcpserver.m_strDhcpServerMask.toAscii().constData()) || RTNetStrIsIPv4AddrAny(m_data.m_dhcpserver.m_strDhcpServerMask.toAscii().constData())) { message.second << UIGlobalSettingsNetwork::tr("Host interface <b>%1</b> does not currently have a valid DHCP server mask.").arg(text(0)); fPass = false; } if ( !RTNetIsIPv4AddrStr(m_data.m_dhcpserver.m_strDhcpLowerAddress.toAscii().constData()) || RTNetStrIsIPv4AddrAny(m_data.m_dhcpserver.m_strDhcpLowerAddress.toAscii().constData())) { message.second << UIGlobalSettingsNetwork::tr("Host interface <b>%1</b> does not currently have a valid DHCP server lower address bound.").arg(text(0)); fPass = false; } if ( !RTNetIsIPv4AddrStr(m_data.m_dhcpserver.m_strDhcpUpperAddress.toAscii().constData()) || RTNetStrIsIPv4AddrAny(m_data.m_dhcpserver.m_strDhcpUpperAddress.toAscii().constData())) { message.second << UIGlobalSettingsNetwork::tr("Host interface <b>%1</b> does not currently have a valid DHCP server upper address bound.").arg(text(0)); fPass = false; } } /* Return result: */ return fPass; }