private void OnWlanNotification(ref Wlan.WlanNotificationData notifyData, IntPtr context) { WlanInterface wlanIface = ifaces.ContainsKey(notifyData.interfaceGuid) ? ifaces[notifyData.interfaceGuid] : null; switch (notifyData.notificationSource) { case Wlan.WlanNotificationSource.ACM: switch ((Wlan.WlanNotificationCodeAcm)notifyData.notificationCode) { case Wlan.WlanNotificationCodeAcm.ConnectionStart: case Wlan.WlanNotificationCodeAcm.ConnectionComplete: case Wlan.WlanNotificationCodeAcm.ConnectionAttemptFail: case Wlan.WlanNotificationCodeAcm.Disconnecting: case Wlan.WlanNotificationCodeAcm.Disconnected: Wlan.WlanConnectionNotificationData?connNotifyData = ParseWlanConnectionNotification(ref notifyData); if (connNotifyData.HasValue) { if (wlanIface != null) { wlanIface.OnWlanConnection(notifyData, connNotifyData.Value); } } break; case Wlan.WlanNotificationCodeAcm.ScanFail: { try { int expectedSize = Marshal.SizeOf(typeof(Wlan.WlanReasonCode)); if (notifyData.dataSize >= expectedSize) { Wlan.WlanReasonCode reasonCode = (Wlan.WlanReasonCode)Marshal.ReadInt32(notifyData.dataPtr); if (wlanIface != null) { wlanIface.OnWlanReason(notifyData, reasonCode); } } } catch { } } break; } break; case Wlan.WlanNotificationSource.MSM: switch ((Wlan.WlanNotificationCodeMsm)notifyData.notificationCode) { case Wlan.WlanNotificationCodeMsm.Associating: case Wlan.WlanNotificationCodeMsm.Associated: case Wlan.WlanNotificationCodeMsm.Authenticating: case Wlan.WlanNotificationCodeMsm.Connected: case Wlan.WlanNotificationCodeMsm.RoamingStart: case Wlan.WlanNotificationCodeMsm.RoamingEnd: case Wlan.WlanNotificationCodeMsm.Disassociating: case Wlan.WlanNotificationCodeMsm.Disconnected: case Wlan.WlanNotificationCodeMsm.PeerJoin: case Wlan.WlanNotificationCodeMsm.PeerLeave: case Wlan.WlanNotificationCodeMsm.AdapterRemoval: Wlan.WlanConnectionNotificationData?connNotifyData = ParseWlanConnectionNotification(ref notifyData); if (connNotifyData.HasValue) { if (wlanIface != null) { wlanIface.OnWlanConnection(notifyData, connNotifyData.Value); } } break; } break; } if (wlanIface != null) { wlanIface.OnWlanNotification(notifyData); } }
private void OnWlanNotification(ref Wlan.WlanNotificationData notifyData, IntPtr context) { WlanInterface wlanIface = null;// = GenericInfo.WlanInterface; foreach (WlanInterface wli in this.Interfaces) { if (wli.InterfaceGuid == notifyData.interfaceGuid) { wlanIface = wli; } } switch (notifyData.notificationSource) { case Wlan.WlanNotificationSource.ACM: Console.WriteLine("ACM-EVENT: " + (Wlan.WlanNotificationCodeAcm)notifyData.NotificationCode); switch ((Wlan.WlanNotificationCodeAcm)notifyData.notificationCode) { case Wlan.WlanNotificationCodeAcm.ConnectionStart: break; case Wlan.WlanNotificationCodeAcm.ConnectionComplete: wlanIface.LatestConnection = wlanIface.CurrentConnection; //LINK UP INDICATION LINK_SAP_CS_80211.LINK_SAP_80211.Events.EventHandler.HandleLinkUp(notifyData); break; case Wlan.WlanNotificationCodeAcm.ConnectionAttemptFail: break; case Wlan.WlanNotificationCodeAcm.Disconnecting: break; case Wlan.WlanNotificationCodeAcm.Disconnected: //LINK DOWN INDICATION LINK_SAP_CS_80211.LINK_SAP_80211.Events.EventHandler.HandleLinkDown(notifyData); Wlan.WlanConnectionNotificationData?connNotifyData = ParseWlanConnectionNotification(ref notifyData); if (connNotifyData.HasValue) { if (wlanIface != null) { wlanIface.OnWlanConnection(notifyData, connNotifyData.Value); } } break; case Wlan.WlanNotificationCodeAcm.ScanComplete: //Handles LINK DETECTED INDICATION LINK_SAP_CS_80211.LINK_SAP_80211.Events.EventHandler.HandleScanComplete(notifyData); break; case Wlan.WlanNotificationCodeAcm.ScanFail: { int expectedSize = Marshal.SizeOf(typeof(int)); if (notifyData.dataSize >= expectedSize) { Wlan.WlanReasonCode reasonCode = (Wlan.WlanReasonCode)Marshal.ReadInt32(notifyData.dataPtr); if (wlanIface != null) { wlanIface.OnWlanReason(notifyData, reasonCode); } } } break; } break; case Wlan.WlanNotificationSource.MSM: Console.WriteLine("MSM-EVENT: " + (Wlan.WlanNotificationCodeMsm)notifyData.NotificationCode); switch ((Wlan.WlanNotificationCodeMsm)notifyData.notificationCode) { case Wlan.WlanNotificationCodeMsm.SignalQualityChange: LINK_SAP_CS_80211.LINK_SAP_80211.Events.EventHandler.HandleParamsReport(notifyData); break; case Wlan.WlanNotificationCodeMsm.Associating: break; case Wlan.WlanNotificationCodeMsm.Associated: break; case Wlan.WlanNotificationCodeMsm.Authenticating: break; case Wlan.WlanNotificationCodeMsm.Connected: break; case Wlan.WlanNotificationCodeMsm.RoamingStart: break; case Wlan.WlanNotificationCodeMsm.RoamingEnd: break; case Wlan.WlanNotificationCodeMsm.Disassociating: break; case Wlan.WlanNotificationCodeMsm.Disconnected: break; case Wlan.WlanNotificationCodeMsm.PeerJoin: break; case Wlan.WlanNotificationCodeMsm.PeerLeave: break; case Wlan.WlanNotificationCodeMsm.AdapterRemoval: Wlan.WlanConnectionNotificationData?connNotifyData = ParseWlanConnectionNotification(ref notifyData); if (connNotifyData.HasValue) { if (wlanIface != null) { wlanIface.OnWlanConnection(notifyData, connNotifyData.Value); } } break; } break; } if (wlanIface != null) { wlanIface.OnWlanNotification(notifyData); } }
private void OnWlanNotification(ref Wlan.WlanNotificationData notifyData, IntPtr context) { WlanInterface wlanIface = ifaces.ContainsKey(notifyData.interfaceGuid) ? ifaces[notifyData.interfaceGuid] : null; switch (notifyData.notificationSource) { case Wlan.WlanNotificationSource.ACM: switch ((Wlan.WlanNotificationCodeAcm)notifyData.notificationCode) { case Wlan.WlanNotificationCodeAcm.ConnectionStart: case Wlan.WlanNotificationCodeAcm.ConnectionComplete: case Wlan.WlanNotificationCodeAcm.ConnectionAttemptFail: case Wlan.WlanNotificationCodeAcm.Disconnecting: case Wlan.WlanNotificationCodeAcm.Disconnected: Wlan.WlanConnectionNotificationData?connNotifyData = ParseWlanConnectionNotification(ref notifyData); if (connNotifyData.HasValue) { if (wlanIface != null) { wlanIface.OnWlanConnection(notifyData, connNotifyData.Value); } } break; case Wlan.WlanNotificationCodeAcm.ScanFail: { //HACK: Prevents exception on WLAN connection: System.ArgumentException: Type 'NativeWifi.Wlan+WlanReasonCode' cannot be marshaled as an unmanaged structure; no meaningful size or offset can be computed. int expectedSize = 0; //Marshal.SizeOf(typeof (Wlan.WlanReasonCode)); if (notifyData.dataSize >= expectedSize) { Wlan.WlanReasonCode reasonCode = (Wlan.WlanReasonCode)Marshal.ReadInt32(notifyData.dataPtr); if (wlanIface != null) { wlanIface.OnWlanReason(notifyData, reasonCode); } } } break; } break; case Wlan.WlanNotificationSource.MSM: switch ((Wlan.WlanNotificationCodeMsm)notifyData.notificationCode) { case Wlan.WlanNotificationCodeMsm.Associating: case Wlan.WlanNotificationCodeMsm.Associated: case Wlan.WlanNotificationCodeMsm.Authenticating: case Wlan.WlanNotificationCodeMsm.Connected: case Wlan.WlanNotificationCodeMsm.RoamingStart: case Wlan.WlanNotificationCodeMsm.RoamingEnd: case Wlan.WlanNotificationCodeMsm.Disassociating: case Wlan.WlanNotificationCodeMsm.Disconnected: case Wlan.WlanNotificationCodeMsm.PeerJoin: case Wlan.WlanNotificationCodeMsm.PeerLeave: case Wlan.WlanNotificationCodeMsm.AdapterRemoval: Wlan.WlanConnectionNotificationData?connNotifyData = ParseWlanConnectionNotification(ref notifyData); if (connNotifyData.HasValue) { if (wlanIface != null) { wlanIface.OnWlanConnection(notifyData, connNotifyData.Value); } } break; } break; } if (wlanIface != null) { wlanIface.OnWlanNotification(notifyData); } }