Example #1
0
        /// <summary>
        /// Retrieves the basic service sets (BSS) list of the specified network.
        /// </summary>
        /// <param name="ssid">Specifies the SSID of the network from which the BSS list is requested.</param>
        /// <param name="bssType">Indicates the BSS type of the network.</param>
        /// <param name="securityEnabled">Indicates whether security is enabled on the network.</param>
        public WlanBssEntry[] GetNetworkBssList(Dot11Ssid ssid, Dot11BssType bssType, bool securityEnabled)
        {
            IntPtr ssidPtr = Marshal.AllocHGlobal(Marshal.SizeOf(ssid));

            Marshal.StructureToPtr(ssid, ssidPtr, false);

            try
            {
                IntPtr bssListPtr;
                WlanInterop.ThrowIfError(WlanInterop.WlanGetNetworkBssList(client.clientHandle, info.interfaceGuid, ssidPtr, bssType, securityEnabled, IntPtr.Zero, out bssListPtr));

                try
                {
                    return(ConvertBssListPtr(bssListPtr));
                }
                finally
                {
                    WlanInterop.WlanFreeMemory(bssListPtr);
                }
            }
            finally
            {
                Marshal.FreeHGlobal(ssidPtr);
            }
        }
Example #2
0
        /// <summary>
        /// Retrieves the basic service sets (BSS) list of all available networks.
        /// </summary>
        public WlanBssEntry[] GetNetworkBssList()
        {
            IntPtr bssListPtr;

            WlanInterop.ThrowIfError(WlanInterop.WlanGetNetworkBssList(client.clientHandle, info.interfaceGuid, IntPtr.Zero, Dot11BssType.Any, false, IntPtr.Zero, out bssListPtr));

            try
            {
                return(ConvertBssListPtr(bssListPtr));
            }
            finally
            {
                WlanInterop.WlanFreeMemory(bssListPtr);
            }
        }