public static void ValidateConfiguration(Wireless80211 wirelessConfiguration)
        {
            if ((wirelessConfiguration.Authentication < AuthenticationType.None  ) || 
                (wirelessConfiguration.Authentication > AuthenticationType.Shared) ||
                 (wirelessConfiguration.Encryption < EncryptionType.None         ) || 
                 (wirelessConfiguration.Encryption > EncryptionType.Certificate  ) ||
                 (wirelessConfiguration.Radio < RadioType.a                      ) || 
                 (wirelessConfiguration.Radio > (RadioType.n | RadioType.g | RadioType.b | RadioType.a)))
            {
                throw new ArgumentOutOfRangeException();
            }

            if ((wirelessConfiguration.PassPhrase    == null) || 
                (wirelessConfiguration.NetworkKey    == null) || 
                (wirelessConfiguration.ReKeyInternal == null) || 
                (wirelessConfiguration.Ssid          == null))
            {
                throw new ArgumentNullException();
            }

            if ((wirelessConfiguration.PassPhrase.Length    >= MaxPassPhraseLength) || 
                (wirelessConfiguration.NetworkKey.Length    >  NetworkKeyLength   ) || 
                (wirelessConfiguration.ReKeyInternal.Length >  ReKeyInternalLength) || 
                (wirelessConfiguration.Ssid.Length          >= SsidLength         ) ||
                (
                  wirelessConfiguration.NetworkKey.Length != 0  &&
                  wirelessConfiguration.NetworkKey.Length != 8  && wirelessConfiguration.NetworkKey.Length != 16  && wirelessConfiguration.NetworkKey.Length != 32  &&
                  wirelessConfiguration.NetworkKey.Length != 64 && wirelessConfiguration.NetworkKey.Length != 128 && wirelessConfiguration.NetworkKey.Length != 256
                )
               )
            {
                throw new ArgumentOutOfRangeException();
            }
        }
Example #2
0
        public static void ValidateConfiguration(Wireless80211 wirelessConfiguration)
        {
            if ((wirelessConfiguration.Authentication < AuthenticationType.None) ||
                (wirelessConfiguration.Authentication > AuthenticationType.Shared) ||
                (wirelessConfiguration.Encryption < EncryptionType.None) ||
                (wirelessConfiguration.Encryption > EncryptionType.Certificate) ||
                (wirelessConfiguration.Radio < RadioType.a) ||
                (wirelessConfiguration.Radio > (RadioType.n | RadioType.g | RadioType.b | RadioType.a)))
            {
                throw new ArgumentOutOfRangeException();
            }

            if ((wirelessConfiguration.PassPhrase == null) ||
                (wirelessConfiguration.NetworkKey == null) ||
                (wirelessConfiguration.ReKeyInternal == null) ||
                (wirelessConfiguration.Ssid == null))
            {
                throw new ArgumentNullException();
            }

            if ((wirelessConfiguration.PassPhrase.Length >= MaxPassPhraseLength) ||
                (wirelessConfiguration.NetworkKey.Length > NetworkKeyLength) ||
                (wirelessConfiguration.ReKeyInternal.Length > ReKeyInternalLength) ||
                (wirelessConfiguration.Ssid.Length >= SsidLength))
            {
                throw new ArgumentOutOfRangeException();
            }
        }
        public static void SaveConfiguration(Wireless80211[] wirelessConfigurations, bool useEncryption)
        {
            /// Before we update validate whether settings conform to right characteristics.
            for (int i = 0; i < wirelessConfigurations.Length; i++)
            {
                ValidateConfiguration(wirelessConfigurations[i]);
            }

            for (int i = 0; i < wirelessConfigurations.Length; i++)
            {
                UpdateConfiguration(wirelessConfigurations[i], useEncryption);
            }

            SaveAllConfigurations();
        }
        public InitializeResult Initialize()
        {            
            if (Microsoft.SPOT.Hardware.SystemInfo.SystemID.SKU == 3)
            {
                Log.Comment("Wireless tests run only on Device");
                return InitializeResult.Skip;
            }

            Log.Comment("Getting all the network interfaces.");
            m_interfaces = NetworkInterface.GetAllNetworkInterfaces();
            m_wireless = this.FindWireless80211();

            // if the device has no wireless configs, there is nothing we can do
            if(m_wireless == null)
            {
                return InitializeResult.Skip;
            }
            
            return InitializeResult.ReadyToGo;
        }
Example #5
0
 private extern static void UpdateConfiguration(Wireless80211 wirelessConfigurations, bool useEncryption);
 private MFTestResults VerifyNetworkKey(byte[] key)
 {
     m_wireless = FindWireless80211();
     Log.Comment("Verifying the network key is " + ByteArrayPrinter(key));
     byte[] currentValue = m_wireless.NetworkKey;
     return ReturnResult(key, currentValue);
 }
        private string RadioTypeToString(Wireless80211.RadioType radioType)
        {
            string type = "";

            if (0 != (radioType & Wireless80211.RadioType.a)) type += "A";
            if (0 != (radioType & Wireless80211.RadioType.b)) type += "B";
            if (0 != (radioType & Wireless80211.RadioType.g)) type += "G";
            if (0 != (radioType & Wireless80211.RadioType.n)) type += "N";

            return type;
        }
 private void SetEncryptionType(Wireless80211.EncryptionType encryptionType)
 {
     Log.Comment("Setting encryption type to " + m_encryptionType[(int)encryptionType]);
     m_wireless.Encryption = encryptionType;
     Log.Comment("Calling SaveConfiguration to save the encryption type");
     Wireless80211.SaveConfiguration(new Wireless80211[] { m_wireless }, true);
 }
 private static void UpdateConfiguration(Wireless80211 wirelessConfigurations, bool useEncryption)
 {
     throw new NotImplementedException();
 }
 private extern static void UpdateConfiguration(Wireless80211 wirelessConfigurations, bool useEncryption);
 private MFTestResults VerifySsid(string key)
 {
     m_wireless = FindWireless80211();
     string currentValue = m_wireless.Ssid;
     Log.Comment("Verifying the ssid is " + key);
     if (string.Equals(key, currentValue))
     {
         Log.Comment("Returning a pass since " + key + " == " + currentValue);                
         return MFTestResults.Pass; 
     }
     
     Log.Comment("Returning a fail since " + key + " != " + currentValue);                
     return MFTestResults.Fail;
 }
Example #12
0
 private static void UpdateConfiguration(Wireless80211 wirelessConfigurations, bool useEncryption)
 {
     throw new NotImplementedException();
 }
 private void SetAuthenticationType(Wireless80211.AuthenticationType authType)
 {
     Log.Comment("Setting authentication type to " + m_authenticationType[(int)authType]);
     m_wireless.Authentication = authType;
     Log.Comment("Calling SaveConfiguration to save the authentication type");
     Wireless80211.SaveConfiguration(new Wireless80211[] { m_wireless }, true);
 }
 private MFTestResults VerifyReKeyInternal(byte[] key)
 {
     m_wireless = FindWireless80211();
     Log.Comment("Verifying ReKeyInternal is " + ByteArrayPrinter(key));
     byte[] currentValue = m_wireless.ReKeyInternal;
     return ReturnResult(key, currentValue);
 }
 private MFTestResults VerifyPassPhrase(string passPhrase)
 {
     m_wireless = FindWireless80211();
     Log.Comment("Verifying the pass phrase is " + passPhrase);
     string currentValue = m_wireless.PassPhrase;
     Log.Comment("The pass phrase we get is " + currentValue);
     if (string.Equals(passPhrase, currentValue))
     {
         Log.Comment("Returning a pass since " + passPhrase + " == " + currentValue);                
         return MFTestResults.Pass; 
     }
     
     Log.Comment("Returning a fail since " + passPhrase + " != " + currentValue);                
     return MFTestResults.Fail;
 }
        private MFTestResults VerifyRadioType(Wireless80211.RadioType radioType)
        {
            m_wireless = FindWireless80211();
            Log.Comment("Verifying radio type is set to " + RadioTypeToString(radioType));
            Wireless80211.RadioType currentValue = m_wireless.Radio;
            Log.Comment("Radio type we get is " + RadioTypeToString(currentValue));
            if (currentValue == radioType)
            {
                Log.Comment("Returning a pass since " + RadioTypeToString(radioType)
                    + " == " + RadioTypeToString(currentValue));
                return MFTestResults.Pass;
            }

            Log.Comment("Returning a fail since " + RadioTypeToString(radioType)
                + " != " + RadioTypeToString(currentValue));
            return MFTestResults.Fail;
        }
        private MFTestResults VerifyEncryptionType(Wireless80211.EncryptionType encryptionType)
        {
            m_wireless = FindWireless80211();
            Log.Comment("Verifying encryption type is set to " + m_encryptionType[(int)encryptionType]);
            Wireless80211.EncryptionType currentValue = m_wireless.Encryption;
            Log.Comment("Encryption type we get is " + m_encryptionType[(int)currentValue]);
            if (currentValue == encryptionType)
            {
                Log.Comment("Returning a pass since " + m_encryptionType[(int)encryptionType]
                    + " == " + m_encryptionType[(int)currentValue]);
                return MFTestResults.Pass;
            }

            Log.Comment("Returning a fail since " + m_encryptionType[(int)encryptionType]
                + " != " + m_encryptionType[(int)currentValue]);
            return MFTestResults.Fail;
        }
        private MFTestResults VerifyAuthenticationType(Wireless80211.AuthenticationType authType)
        {
            m_wireless = FindWireless80211();
            Log.Comment("Verifying authentication type is set to " + m_authenticationType[(int)authType]);
            Wireless80211.AuthenticationType currentValue = m_wireless.Authentication;
            Log.Comment("Authentication type we get is " + m_authenticationType[(int)currentValue]);
            if (currentValue == authType)
            {
                Log.Comment("Returning a pass since " + m_authenticationType[(int)authType]
                    + " == " + m_authenticationType[(int)currentValue]);
                return MFTestResults.Pass;
            }

            Log.Comment("Returning a fail since " + m_authenticationType[(int)authType]
                + " != " + m_authenticationType[(int)currentValue]);
            return MFTestResults.Fail;
        }
        private void SetRadioType(Wireless80211.RadioType radioType)
        {

            Log.Comment("Setting radio type to " + RadioTypeToString(radioType));
            m_wireless.Radio = radioType;
            Log.Comment("Calling SaveConfiguration to save the radio type");
            Wireless80211.SaveConfiguration(new Wireless80211[] { m_wireless }, true);
        }