예제 #1
0
        private void SetInterfaceInt(Wlan.WlanIntfOpcode opCode, int value)
        {
            IntPtr ptr = Marshal.AllocHGlobal(4);

            Marshal.WriteInt32(ptr, value);
            try
            {
                Wlan.ThrowIfError(Wlan.WlanSetInterface(_client.ItsClientHandle, _info.interfaceGuid, opCode, 4, ptr, IntPtr.Zero));
            }
            finally
            {
                Marshal.FreeHGlobal(ptr);
            }
        }
예제 #2
0
        public IEnumerable <Wlan.WlanBssEntryN> GetNetworkBssList()
        {
            IntPtr ptr;

            Wlan.WlanBssEntryN[] entryArray;
            Wlan.ThrowIfError(Wlan.WlanGetNetworkBssList(_client.ItsClientHandle, _info.interfaceGuid, IntPtr.Zero, Wlan.Dot11BssType.Any, false, IntPtr.Zero, out ptr));
            try
            {
                entryArray = ConvertBssListPtr(ptr);
            }
            finally
            {
                Wlan.WlanFreeMemory(ptr);
            }
            return(entryArray);
        }
예제 #3
0
        public IEnumerable <Wlan.WlanAvailableNetwork> GetAvailableNetworkList(Wlan.WlanGetAvailableNetworkFlags flags)
        {
            IntPtr ptr;

            Wlan.WlanAvailableNetwork[] networkArray;
            Wlan.ThrowIfError(Wlan.WlanGetAvailableNetworkList(_client.ItsClientHandle, _info.interfaceGuid, flags, IntPtr.Zero, out ptr));
            try
            {
                networkArray = ConvertAvailableNetworkListPtr(ptr);
            }
            finally
            {
                Wlan.WlanFreeMemory(ptr);
            }
            return(networkArray);
        }
예제 #4
0
        public WlanClient()
        {
            ItsLogger = new Logger(this);

            try
            {
                Wlan.ThrowIfError(Wlan.WlanOpenHandle(1, IntPtr.Zero, out _negotiatedVersion, out _clientHandle));
                WlanNotificationCallback = new Wlan.WlanNotificationCallbackDelegate(OnWlanNotification);

                Wlan.WlanNotificationSource source;
                Wlan.ThrowIfError(Wlan.WlanRegisterNotification(_clientHandle, Wlan.WlanNotificationSource.All, false, WlanNotificationCallback, IntPtr.Zero, IntPtr.Zero, out source));
            }
            catch (Win32Exception ex)
            {
                Wlan.WlanCloseHandle(_clientHandle, IntPtr.Zero);
                ItsLogger.Warn(ex.Message);
                throw;
            }
        }
예제 #5
0
        private int GetInterfaceInt(Wlan.WlanIntfOpcode opCode)
        {
            IntPtr ptr;
            int    num;

            Wlan.WlanOpcodeValueType type;
            int num2;

            Wlan.ThrowIfError(Wlan.WlanQueryInterface(_client.ItsClientHandle, _info.interfaceGuid, opCode, IntPtr.Zero, out num, out ptr, out type));
            try
            {
                num2 = Marshal.ReadInt32(ptr);
            }
            finally
            {
                Wlan.WlanFreeMemory(ptr);
            }
            return(num2);
        }
예제 #6
0
        public string GetProfileXml(string profileName)
        {
            IntPtr ptr;

            Wlan.WlanProfileFlags flags;
            Wlan.WlanAccess       access;
            string str;

            Wlan.ThrowIfError(Wlan.WlanGetProfile(_client.ItsClientHandle, _info.interfaceGuid, profileName, IntPtr.Zero, out ptr, out flags, out access));
            try
            {
                str = Marshal.PtrToStringUni(ptr);
            }
            finally
            {
                Wlan.WlanFreeMemory(ptr);
            }
            return(str);
        }
예제 #7
0
 private void Connect(Wlan.WlanConnectionParameters connectionParams)
 {
     Wlan.ThrowIfError(Wlan.WlanConnect(_client.ItsClientHandle, _info.interfaceGuid, ref connectionParams, IntPtr.Zero));
 }
예제 #8
0
 public Wlan.WlanReasonCode SetProfile(Wlan.WlanProfileFlags flags, string profileXml, bool overwrite)
 {
     Wlan.WlanReasonCode code;
     Wlan.ThrowIfError(Wlan.WlanSetProfile(_client.ItsClientHandle, _info.interfaceGuid, flags, profileXml, null, overwrite, IntPtr.Zero, out code));
     return(code);
 }
예제 #9
0
 public void Scan()
 {
     Wlan.ThrowIfError(Wlan.WlanScan(_client.ItsClientHandle, _info.interfaceGuid, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero));
 }
예제 #10
0
 public void DeleteProfile(string profileName)
 {
     Wlan.ThrowIfError(Wlan.WlanDeleteProfile(_client.ItsClientHandle, _info.interfaceGuid, profileName, IntPtr.Zero));
 }