Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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;
            }
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 7
0
 private void Connect(Wlan.WlanConnectionParameters connectionParams)
 {
     Wlan.ThrowIfError(Wlan.WlanConnect(_client.ItsClientHandle, _info.interfaceGuid, ref connectionParams, IntPtr.Zero));
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 9
0
 public void Scan()
 {
     Wlan.ThrowIfError(Wlan.WlanScan(_client.ItsClientHandle, _info.interfaceGuid, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero));
 }
Ejemplo n.º 10
0
 public void DeleteProfile(string profileName)
 {
     Wlan.ThrowIfError(Wlan.WlanDeleteProfile(_client.ItsClientHandle, _info.interfaceGuid, profileName, IntPtr.Zero));
 }