public Wlan.WlanBssEntry[] GetNetworkBssList()
            {
                IntPtr wlanBssList;

                Wlan.ThrowIfError(Wlan.WlanGetNetworkBssList(this.client.clientHandle, this.info.interfaceGuid, IntPtr.Zero, Wlan.Dot11BssType.Any, false, IntPtr.Zero, out wlanBssList));
                try
                {
                    return(WlanClient.WlanInterface.ConvertBssListPtr(wlanBssList));
                }
                finally
                {
                    Wlan.WlanFreeMemory(wlanBssList);
                }
            }
            public Wlan.WlanAvailableNetwork[] GetAvailableNetworkList(Wlan.WlanGetAvailableNetworkFlags flags = (Wlan.WlanGetAvailableNetworkFlags) 0)
            {
                IntPtr availableNetworkListPtr;

                Wlan.ThrowIfError(Wlan.WlanGetAvailableNetworkList(this.client.clientHandle, this.info.interfaceGuid, flags, IntPtr.Zero, out availableNetworkListPtr));
                try
                {
                    return(WlanClient.WlanInterface.ConvertAvailableNetworkListPtr(availableNetworkListPtr));
                }
                finally
                {
                    Wlan.WlanFreeMemory(availableNetworkListPtr);
                }
            }
Exemplo n.º 3
0
            /// <summary>
            /// Retrieves the basic service sets (BSS) list of all available networks.
            /// </summary>
            public Wlan.WlanBssEntry[] GetNetworkBssList()
            {
                IntPtr bssListPtr;

                Wlan.ThrowIfError(
                    Wlan.WlanGetNetworkBssList(client.clientHandle, info.interfaceGuid, IntPtr.Zero, Wlan.Dot11BssType.Any, false, IntPtr.Zero, out bssListPtr));
                try
                {
                    return(ConvertBssListPtr(bssListPtr));
                }
                finally
                {
                    Wlan.WlanFreeMemory(bssListPtr);
                }
            }
            public string GetProfileXml(string profileName)
            {
                IntPtr profileXml;

                Wlan.WlanProfileFlags flags;
                Wlan.WlanAccess       grantedAccess;
                Wlan.ThrowIfError(Wlan.WlanGetProfile(this.client.clientHandle, this.info.interfaceGuid, profileName, IntPtr.Zero, out profileXml, out flags, out grantedAccess));
                try
                {
                    return(Marshal.PtrToStringUni(profileXml));
                }
                finally
                {
                    Wlan.WlanFreeMemory(profileXml);
                }
            }
            private int GetInterfaceInt(Wlan.WlanIntfOpcode opCode)
            {
                int    dataSize;
                IntPtr ppData;

                Wlan.WlanOpcodeValueType wlanOpcodeValueType;
                Wlan.ThrowIfError(Wlan.WlanQueryInterface(this.client.clientHandle, this.info.interfaceGuid, opCode, IntPtr.Zero, out dataSize, out ppData, out wlanOpcodeValueType));
                try
                {
                    return(Marshal.ReadInt32(ppData));
                }
                finally
                {
                    Wlan.WlanFreeMemory(ppData);
                }
            }
Exemplo n.º 6
0
            /// <summary>
            /// Gets a parameter of the interface whose data type is <see cref="int"/>.
            /// </summary>
            /// <param name="opCode">The opcode of the parameter.</param>
            /// <returns>The integer value.</returns>
            private int GetInterfaceInt(Wlan.WlanIntfOpcode opCode)
            {
                IntPtr valuePtr;
                int    valueSize;

                Wlan.WlanOpcodeValueType opcodeValueType;
                Wlan.ThrowIfError(
                    Wlan.WlanQueryInterface(client.clientHandle, info.interfaceGuid, opCode, IntPtr.Zero, out valueSize, out valuePtr, out opcodeValueType));
                try
                {
                    return(Marshal.ReadInt32(valuePtr));
                }
                finally
                {
                    Wlan.WlanFreeMemory(valuePtr);
                }
            }
            public Wlan.WlanProfileInfo[] GetProfiles()
            {
                IntPtr profileList;

                Wlan.ThrowIfError(Wlan.WlanGetProfileList(this.client.clientHandle, this.info.interfaceGuid, IntPtr.Zero, out profileList));
                try
                {
                    Wlan.WlanProfileInfoListHeader structure1           = (Wlan.WlanProfileInfoListHeader)Marshal.PtrToStructure(profileList, typeof(Wlan.WlanProfileInfoListHeader));
                    Wlan.WlanProfileInfo[]         wlanProfileInfoArray = new Wlan.WlanProfileInfo[(int)structure1.numberOfItems];
                    long num = profileList.ToInt64() + (long)Marshal.SizeOf((object)structure1);
                    for (int index = 0; (long)index < (long)structure1.numberOfItems; ++index)
                    {
                        Wlan.WlanProfileInfo structure2 = (Wlan.WlanProfileInfo)Marshal.PtrToStructure(new IntPtr(num), typeof(Wlan.WlanProfileInfo));
                        wlanProfileInfoArray[index] = structure2;
                        num += (long)Marshal.SizeOf((object)structure2);
                    }
                    return(wlanProfileInfoArray);
                }
                finally
                {
                    Wlan.WlanFreeMemory(profileList);
                }
            }
            public Wlan.WlanBssEntry[] GetNetworkBssList(Wlan.Dot11Ssid ssid, Wlan.Dot11BssType bssType, bool securityEnabled)
            {
                IntPtr num = Marshal.AllocHGlobal(Marshal.SizeOf((object)ssid));

                Marshal.StructureToPtr((object)ssid, num, false);
                try
                {
                    IntPtr wlanBssList;
                    Wlan.ThrowIfError(Wlan.WlanGetNetworkBssList(this.client.clientHandle, this.info.interfaceGuid, num, bssType, securityEnabled, IntPtr.Zero, out wlanBssList));
                    try
                    {
                        return(WlanClient.WlanInterface.ConvertBssListPtr(wlanBssList));
                    }
                    finally
                    {
                        Wlan.WlanFreeMemory(wlanBssList);
                    }
                }
                finally
                {
                    Marshal.FreeHGlobal(num);
                }
            }
Exemplo n.º 9
0
            /// <summary>
            /// Gets the information of all profiles on this interface.
            /// </summary>
            /// <returns>The profiles information.</returns>
            public Wlan.WlanProfileInfo[] GetProfiles()
            {
                IntPtr profileListPtr;

                Wlan.ThrowIfError(
                    Wlan.WlanGetProfileList(client.clientHandle, info.interfaceGuid, IntPtr.Zero, out profileListPtr));
                try
                {
                    Wlan.WlanProfileInfoListHeader header       = (Wlan.WlanProfileInfoListHeader)Marshal.PtrToStructure(profileListPtr, typeof(Wlan.WlanProfileInfoListHeader));
                    Wlan.WlanProfileInfo[]         profileInfos = new Wlan.WlanProfileInfo[header.numberOfItems];
                    long profileListIterator = profileListPtr.ToInt64() + Marshal.SizeOf(header);
                    for (int i = 0; i < header.numberOfItems; ++i)
                    {
                        Wlan.WlanProfileInfo profileInfo = (Wlan.WlanProfileInfo)Marshal.PtrToStructure(new IntPtr(profileListIterator), typeof(Wlan.WlanProfileInfo));
                        profileInfos[i]      = profileInfo;
                        profileListIterator += Marshal.SizeOf(profileInfo);
                    }
                    return(profileInfos);
                }
                finally
                {
                    Wlan.WlanFreeMemory(profileListPtr);
                }
            }
Exemplo n.º 10
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 Wlan.WlanBssEntry[] GetNetworkBssList(Wlan.Dot11Ssid ssid, Wlan.Dot11BssType bssType, bool securityEnabled)
            {
                IntPtr ssidPtr = Marshal.AllocHGlobal(Marshal.SizeOf(ssid));

                Marshal.StructureToPtr(ssid, ssidPtr, false);
                try
                {
                    IntPtr bssListPtr;
                    Wlan.ThrowIfError(
                        Wlan.WlanGetNetworkBssList(client.clientHandle, info.interfaceGuid, ssidPtr, bssType, securityEnabled, IntPtr.Zero, out bssListPtr));
                    try
                    {
                        return(ConvertBssListPtr(bssListPtr));
                    }
                    finally
                    {
                        Wlan.WlanFreeMemory(bssListPtr);
                    }
                }
                finally
                {
                    Marshal.FreeHGlobal(ssidPtr);
                }
            }