Example #1
0
        protected override void OnStart(string[] args)
        {
            base.OnStart(args);
            client = new WlanClient();
            //Miofile = "C:\\" + DateTime.Now.ToLongDateString() + "-" +DateTime.Now.ToShortTimeString() + "_catture.txt";
            //System.IO.File.AppendAllText("c:\\catture.txt", "PARTOOOOOOOOOOOOOOOOOOOOO\r\n");

            // Initialize data structure
            aTimer = new System.Timers.Timer();
            aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
            aTimer.Interval = default_interval;
            //System.IO.File.AppendAllText("c:\\catture.txt", "PARTOOOOOOOOOOOOOOOOOOOOO\r\n");

            //initialize the mutex
            mut = new Mutex(false,"Global\\ServiceMutex");
            MutexSecurity mSec = mut.GetAccessControl();
            var rule = new MutexAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null),
                               MutexRights.Modify
                                | MutexRights.Synchronize
                                | MutexRights.TakeOwnership
                                | MutexRights.ReadPermissions,
                               AccessControlType.Allow);
            mSec.AddAccessRule(rule);
            mut.SetAccessControl(mSec);
            // Set the time interval

            //System.IO.File.AppendAllText("c:\\catture.txt", "PARTOOOOOOOOOOOOOOOOOOOOO\r\n");
            // File Mapping creation
            try
            {
                mmf = MemoryMappedFile.CreateNew("Global\\Broadcast", MappedFileDimension, MemoryMappedFileAccess.ReadWrite);
            }
            catch (Exception e)
            {
                System.IO.File.AppendAllText("c:\\catture.txt", e.ToString());
            }
            var mmfSec = mmf.GetAccessControl();
            mmfSec.SetAccessRule(new AccessRule<MemoryMappedFileRights>(new SecurityIdentifier(WellKnownSidType.WorldSid, null),MemoryMappedFileRights.FullControl | MemoryMappedFileRights.Read, AccessControlType.Allow));
            mmf.SetAccessControl(mmfSec);
            //System.IO.File.AppendAllText("c:\\catture.txt", "PARTOOOOOOOOOOOOOOOOOOOOO\r\n");
            stream = mmf.CreateViewStream(0, MappedFileDimension, MemoryMappedFileAccess.ReadWrite);
            //System.IO.File.AppendAllText("c:\\catture.txt", "FINISCO PARTENZA\r\n");

            aTimer.Enabled = true;
        }
Example #2
0
        private string BSSscan()
        {
            client = new WlanClient();
            List<Network> currentNetworks = new List<Network>();
            foreach (WlanClient.WlanInterface wlanIface in client.Interfaces)
            {

                Wlan.WlanBssEntry[] wlanBssEntries = wlanIface.GetNetworkBssList();
                foreach (Wlan.WlanBssEntry wlanBssEntry in wlanBssEntries)
                {
                    string mac = ErmesLib.Network.BytesToStringMacConversion(wlanBssEntry.dot11Bssid,(uint) wlanBssEntry.dot11Bssid.Length);
                    //mac = " wlanBssEntry: " + wlanBssEntry.dot11Ssid.ToString() + " dot11BssPhyType: " + wlanBssEntry.dot11BssType.ToString() + " dot11BssPhyType: " + wlanBssEntry.dot11BssPhyType.ToString() + " frequenza khz " + wlanBssEntry.chCenterFrequency.ToString() + " capabilityInformation " + wlanBssEntry.capabilityInformation.ToString() + " beaconPeriod: " + wlanBssEntry.beaconPeriod.ToString() + " MAC: " + mac + "\r\n";
                    currentNetworks.Add(new Network(wlanBssEntry.dot11Ssid.ToString(), wlanBssEntry.linkQuality, mac));
                }
            }

            return Network.SerializeList(currentNetworks);
        }
Example #3
0
 internal WlanInterface(WlanClient client, Wlan.WlanInterfaceInfo info)
 {
     this.client = client;
     this.info = info;
 }