Ejemplo n.º 1
0
        internal static IEnumerable <AvailableNetworkPack> EnumerateAvailableNetworks(Base.WlanClient client)
        {
            using var container = new DisposableContainer <Base.WlanClient>(client);

            foreach (var interfaceInfo in EnumerateInterfaces(container.Content))
            {
                foreach (var availableNetwork in Base.GetAvailableNetworkList(container.Content.Handle, interfaceInfo.Id))
                {
                    if (!BssTypeConverter.TryConvert(availableNetwork.dot11BssType, out BssType bssType))
                    {
                        continue;
                    }

                    if (!AuthenticationAlgorithmConverter.TryConvert(availableNetwork.dot11DefaultAuthAlgorithm, out AuthenticationAlgorithm authenticationAlgorithm))
                    {
                        continue;
                    }

                    if (!CipherAlgorithmConverter.TryConvert(availableNetwork.dot11DefaultCipherAlgorithm, out CipherAlgorithm cipherAlgorithm))
                    {
                        continue;
                    }

                    yield return(new AvailableNetworkPack(
                                     interfaceInfo: interfaceInfo,
                                     ssid: new NetworkIdentifier(availableNetwork.dot11Ssid),
                                     bssType: bssType,
                                     signalQuality: (int)availableNetwork.wlanSignalQuality,
                                     isSecurityEnabled: availableNetwork.bSecurityEnabled,
                                     profileName: availableNetwork.strProfileName,
                                     authenticationAlgorithm: authenticationAlgorithm,
                                     cipherAlgorithm: cipherAlgorithm));
                }
            }
        }
Ejemplo n.º 2
0
        private static IEnumerable <AvailableNetworkGroupPack> EnumerateAvailableNetworkGroups(Base.WlanClient client, InterfaceInfo interfaceInfo)
        {
            foreach (var availableNetwork in Base.GetAvailableNetworkList(client.Handle, interfaceInfo.Id))
            {
                if (!BssTypeConverter.TryConvert(availableNetwork.dot11BssType, out BssType bssType))
                {
                    continue;
                }

                if (!AuthenticationAlgorithmConverter.TryConvert(availableNetwork.dot11DefaultAuthAlgorithm, out AuthenticationAlgorithm authenticationAlgorithm))
                {
                    continue;
                }

                if (!CipherAlgorithmConverter.TryConvert(availableNetwork.dot11DefaultCipherAlgorithm, out CipherAlgorithm cipherAlgorithm))
                {
                    continue;
                }

                var bssNetworks = Base.GetNetworkBssEntryList(client.Handle, interfaceInfo.Id,
                                                              availableNetwork.dot11Ssid, availableNetwork.dot11BssType, availableNetwork.bSecurityEnabled)
                                  .Select(x => TryConvertBssNetwork(interfaceInfo, x, out BssNetworkPack bssNetwork) ? bssNetwork : null)
                                  .Where(x => x is not null);

                yield return(new AvailableNetworkGroupPack(
                                 interfaceInfo: interfaceInfo,
                                 ssid: new NetworkIdentifier(availableNetwork.dot11Ssid),
                                 bssType: bssType,
                                 signalQuality: (int)availableNetwork.wlanSignalQuality,
                                 isSecurityEnabled: availableNetwork.bSecurityEnabled,
                                 profileName: availableNetwork.strProfileName,
                                 authenticationAlgorithm: authenticationAlgorithm,
                                 cipherAlgorithm: cipherAlgorithm,
                                 bssNetworks: bssNetworks));
            }
        }