예제 #1
0
        private void ReadNetworkSettingsFromDevice()
        {
            MFNetworkConfiguration mfNetConfig = new MFNetworkConfiguration();

            mfNetConfig.Load(_networkManager);

            _networkConfig = new NetworkConfig();

            _networkConfig.EnableDHCP        = mfNetConfig.EnableDhcp;
            _networkConfig.StaticIPAddress   = mfNetConfig.IpAddress;
            _networkConfig.SubnetMask        = mfNetConfig.SubNetMask;
            _networkConfig.DefaultGateway    = mfNetConfig.Gateway;
            _networkConfig.NetworkMacAddress = mfNetConfig.MacAddress;
            _networkConfig.PrimaryDNS        = mfNetConfig.PrimaryDns;
            _networkConfig.SecondaryDNS      = mfNetConfig.SecondaryDns;

            if (mfNetConfig.ConfigurationType == MFNetworkConfiguration.NetworkConfigType.Wireless)
            {
                MFWirelessConfiguration mfWifiConfig = new MFWirelessConfiguration();
                mfWifiConfig.Load(_networkManager);

                _networkConfig.IsWireless       = true;
                _networkConfig.Authentication   = mfWifiConfig.Authentication;
                _networkConfig.Encryption       = mfWifiConfig.Encryption;
                _networkConfig.Radio            = mfWifiConfig.Radio;
                _networkConfig.Passphrase       = mfWifiConfig.PassPhrase;
                _networkConfig.EncryptConfig    = mfWifiConfig.UseEncryption;
                _networkConfig.NetworkKey       = mfWifiConfig.NetworkKey;
                _networkConfig.NetworkKeyLength = mfWifiConfig.NetworkKeyLength;
                _networkConfig.ReKeyInternal    = mfWifiConfig.ReKeyInternal;
                _networkConfig.SSID             = mfWifiConfig.SSID;
            }
        }
        public MFNetworkConfigDialog(MFDevice device)
        {
            m_cfg         = new MFNetworkConfiguration(device);
            m_cfgHelper   = new MFConfigHelper(device);
            m_wirelessCfg = new MFWirelessConfiguration(device);

            InitializeComponent();
        }
예제 #3
0
        private void SaveNetworkSettings(bool logToConsole = true)
        {
            MFNetworkConfiguration mfNetConfig = new MFNetworkConfiguration();

            mfNetConfig.Load(_networkManager);

            mfNetConfig.IpAddress         = _networkConfig.StaticIPAddress;
            mfNetConfig.SubNetMask        = _networkConfig.SubnetMask;
            mfNetConfig.PrimaryDns        = _networkConfig.PrimaryDNS;
            mfNetConfig.SecondaryDns      = _networkConfig.SecondaryDNS;
            mfNetConfig.Gateway           = _networkConfig.DefaultGateway;
            mfNetConfig.MacAddress        = _networkConfig.NetworkMacAddress;
            mfNetConfig.EnableDhcp        = _networkConfig.EnableDHCP;
            mfNetConfig.ConfigurationType = _networkConfig.IsWireless ? MFNetworkConfiguration.NetworkConfigType.Wireless : MFNetworkConfiguration.NetworkConfigType.Generic;

            if (_networkConfig.IsWireless)
            {
                MFWirelessConfiguration mfWifiConfig = new MFWirelessConfiguration();
                mfWifiConfig.Load(_networkManager);

                mfWifiConfig.Authentication   = _networkConfig.Authentication;
                mfWifiConfig.Encryption       = _networkConfig.Encryption;
                mfWifiConfig.Radio            = _networkConfig.Radio;
                mfWifiConfig.PassPhrase       = _networkConfig.Passphrase;
                mfWifiConfig.UseEncryption    = _networkConfig.EncryptConfig;
                mfWifiConfig.NetworkKeyLength = _networkConfig.NetworkKeyLength;
                mfWifiConfig.NetworkKey       = _networkConfig.NetworkKey;
                mfWifiConfig.ReKeyLength      = _networkConfig.ReKeyInternal.Length / 2;
                mfWifiConfig.ReKeyInternal    = _networkConfig.ReKeyInternal;
                mfWifiConfig.SSID             = _networkConfig.SSID;

                mfWifiConfig.Save(_networkManager);
            }
            mfNetConfig.Save(_networkManager);

            if (logToConsole)
            {
                OutputToConsole("Network settings saved.");
            }
        }