• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# NetworkInformation.PhysicalAddress类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Net.NetworkInformation.PhysicalAddress的典型用法代码示例。如果您正苦于以下问题:C# PhysicalAddress类的具体用法?C# PhysicalAddress怎么用?C# PhysicalAddress使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PhysicalAddress类属于System.Net.NetworkInformation命名空间,在下文中一共展示了PhysicalAddress类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ChassisID

 public ChassisID(PhysicalAddress MACAddress)
 {
     this.EmptyTLVDataInit();
     base.Type = TLVTypes.ChassisID;
     this.SubType = ChassisSubTypes.MACAddress;
     this.SubTypeValue = MACAddress;
 }
开发者ID:BGCX261,项目名称:znqq-svn-to-git,代码行数:7,代码来源:ChassisID.cs


示例2: NetworkList

        internal NetworkList(NamedKey nk, byte[] bytes)
        {
            WriteTime = nk.WriteTime;

            foreach (ValueKey vk in nk.GetValues(bytes))
            {
                switch (vk.Name)
                {
                    case "ProfileGuid":
                        ProfileGuid = Encoding.Unicode.GetString(vk.GetData(bytes));
                        break;
                    case "Description":
                        Description = Encoding.Unicode.GetString(vk.GetData(bytes));
                        break;
                    case "Source":
                        Source = BitConverter.ToUInt32(vk.GetData(bytes), 0x00);
                        break;
                    case "DnsSuffix":
                        DnsSuffix = Encoding.Unicode.GetString(vk.GetData(bytes));
                        break;
                    case "FirstNetwork":
                        FirstNetwork = Encoding.Unicode.GetString(vk.GetData(bytes));
                        break;
                    case "DefaultGatewayMac":
                        DefaultGatewayMac = new PhysicalAddress(vk.GetData(bytes));
                        break;
                    default:
                        break;
                }
            }
        }
开发者ID:453483289,项目名称:PowerForensics_Source,代码行数:31,代码来源:NetworkList.cs


示例3: BroadcastMagicPacket

        private static void BroadcastMagicPacket(PhysicalAddress physicalAddress, IPAddress broadcastIPAddress)
        {
            if (physicalAddress == null) throw new ArgumentNullException(nameof(physicalAddress));

            var physicalAddressBytes = physicalAddress.GetAddressBytes();

            var packet = new byte[17 * 6];

            for (var i = 0; i < 6; i++)
            {
                packet[i] = 0xFF;
            }

            for (var i = 1; i <= 16; i++)
            {
                for (var j = 0; j < 6; j++)
                {
                    packet[i * 6 + j] = physicalAddressBytes[j];
                }
            }

            using (var client = new UdpClient())
            {
                client.Connect(broadcastIPAddress ?? IPAddress.Broadcast, 40000);
                client.Send(packet, packet.Length);
            }
        }
开发者ID:shaftware,项目名称:NetMagic,代码行数:27,代码来源:Program.cs


示例4: SlaacMITM

        public SlaacMITM(WinPcapDevice device, IList<Data.Attack> attacks)
        {
            this.device = device;
            this.attacks = attacks;

            invalidMac = PhysicalAddress.Parse("00-00-00-00-00-00");
        }
开发者ID:ignaciots,项目名称:EvilFOCA,代码行数:7,代码来源:SlaacMITM.cs


示例5: InvalidMacSpoofAttackIpv4Attack

 public InvalidMacSpoofAttackIpv4Attack(Target t1, Target t2, AttackType attackType)
     : base(attackType)
 {
     invalidMac = PhysicalAddress.Parse("FA-BA-DA-FA-BA-DA".ToUpper());
     this.t1 = t1;
     this.t2 = t2;
 }
开发者ID:ignaciots,项目名称:EvilFOCA,代码行数:7,代码来源:InvalidMacSpoofAttackIpv4Attack.cs


示例6: GetMacAddress

        private static void GetMacAddress(System.Net.IPAddress address, Action<PhysicalAddress> callback)
        {
            new Thread(() =>
            {
                try
                {
                    var destAddr = BitConverter.ToInt32(address.GetAddressBytes(), 0);

                    var srcAddr = BitConverter.ToInt32(System.Net.IPAddress.Any.GetAddressBytes(), 0);

                    var macAddress = new byte[6];

                    var macAddrLen = macAddress.Length;

                    var ret = SendArp(destAddr, srcAddr, macAddress, ref macAddrLen);

                    if (ret != 0)
                    {
                        throw new System.ComponentModel.Win32Exception(ret);
                    }

                    var mac = new PhysicalAddress(macAddress);

                    if (callback != null)
                        callback(mac);
                }
                catch
                {
                    //do nothing
                }
            })
            {
                IsBackground = true
            }.Start();
        }
开发者ID:noant,项目名称:Pyrite,代码行数:35,代码来源:LANHelper.cs


示例7: LocalMacAndIPAddress

        public static void LocalMacAndIPAddress( out byte[] ip, out PhysicalAddress mac )
        {
            ip = new byte[4];
            mac = PhysicalAddress.None;
            //get the interface
            NetworkInterface TrueNic = null;
            foreach ( NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces() )
            {
                if ( nic.OperationalStatus == OperationalStatus.Up )
                {
                    TrueNic = nic;
                    break;
                }
            }

            //get the interface ipv4
            foreach ( IPAddress ips in Dns.GetHostEntry( Environment.MachineName ).AddressList )
            {
                if ( ips.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork )
                {
                    ip = ips.GetAddressBytes();
                    break;
                }
            }
            //get the interface mac
            try
            {
                mac = PhysicalAddress.Parse(TrueNic.GetPhysicalAddress().ToString());
            }
            catch { }
        }
开发者ID:LudovicT,项目名称:Grid-Mapper,代码行数:31,代码来源:GetLocalMacAndIPAddress.cs


示例8: EthernetPacket

        /// <summary>
        /// Construct a new ethernet packet from source and destination mac addresses
        /// </summary>
        public EthernetPacket(PhysicalAddress SourceHwAddress,
                              PhysicalAddress DestinationHwAddress,
                              EthernetPacketType ethernetPacketType,
                              byte[] EthernetPayload)
        {
            int ethernetPayloadLength = 0;
            if (EthernetPayload != null)
            {
                ethernetPayloadLength = EthernetPayload.Length;
            }

            _bytes = new byte[EthernetFields_Fields.ETH_HEADER_LEN + ethernetPayloadLength];
            _ethernetHeaderLength = EthernetFields_Fields.ETH_HEADER_LEN;
            _ethPayloadOffset = _ethernetHeaderLength;

            // if we have a payload, copy it into the byte array
            if (EthernetPayload != null)
            {
                Array.Copy(EthernetPayload, 0, _bytes, EthernetFields_Fields.ETH_HEADER_LEN, EthernetPayload.Length);
            }

            // set the instance values
            this.SourceHwAddress = SourceHwAddress;
            this.DestinationHwAddress = DestinationHwAddress;
            this.EthernetProtocol = ethernetPacketType;
        }
开发者ID:vic-alexiev,项目名称:TrafficDissector,代码行数:29,代码来源:EthernetPacket.cs


示例9: Main

        static void Main(string[] args)
        {
            try {
                dashMac = PhysicalAddress.Parse(Properties.Settings.Default.DashMac.Replace("-", "").Replace(":", "").ToUpper());
            } catch (Exception e) {
                if (!string.IsNullOrWhiteSpace(Properties.Settings.Default.DashMac)) {
                    Console.WriteLine("Error: Could not parse dash mac address: " + e.Message);
                    return;
                }
            }

            CaptureDeviceList devices = CaptureDeviceList.Instance;

            if (devices.Count < 1) {
                Console.WriteLine("No devices were found on this machine");
                return;
            }

            Console.WriteLine("The following devices are available on this machine:");
            for (int i = 0; i < devices.Count; i++) {
                ICaptureDevice dev = devices[i];
                Console.WriteLine($"{i}: {dev.Description}");
            }

            ICaptureDevice device = devices[Properties.Settings.Default.InterfaceIndex];
            device.OnPacketArrival += device_OnPacketArrival;
            device.Open(DeviceMode.Promiscuous, ReadTimeoutMilliseconds);
            device.StartCapture();
            Console.WriteLine($"-- Listening on {Properties.Settings.Default.InterfaceIndex}, hit 'Enter' to stop...");
            Console.ReadLine();
            device.StopCapture();
            device.Close();
        }
开发者ID:youresam,项目名称:Dash-Button,代码行数:33,代码来源:Program.cs


示例10: Connected

 public Connected(string name, string remarks, PhysicalAddress macAddress, IEnumerable<Command.Response.Device> roster)
 {
     Name = name;
     Remarks = remarks;
     MacAddress = macAddress;
     Roster = (roster ?? Enumerable.Empty<Command.Response.Device>()).ToArray();
 }
开发者ID:jamesleech,项目名称:Harmonize,代码行数:7,代码来源:Connected.cs


示例11: Router

 public Router(WinPcapDevice dev, SynchronizedCollection<Data.Attack> attacks, SynchronizedCollection<string> slaacReqs)
 {
     this.device = dev;
     this.localPhysicalAddress = device.MacAddress;
     this.attacks = attacks;
     //this.slaacReqs = slaacReqs;
     this.dnsHijacking = new DNSHijacking(dev, attacks);
 }
开发者ID:ignaciots,项目名称:EvilFOCA,代码行数:8,代码来源:Router.cs


示例12: BthDevice

        public BthDevice(IBthDevice device, PhysicalAddress master, byte lsb, byte msb)
            : base(new BthHandle(lsb, msb))
        {
            InitializeComponent();

            BluetoothDevice = device;
            HostAddress = master;
        }
开发者ID:elecyb,项目名称:ScpServer,代码行数:8,代码来源:BthDevice.cs


示例13: MacRule

 public MacRule(PacketStatus ps, PhysicalAddress mac, Direction direction, bool log, bool notify)
 {
     this.ps = ps;
     this.mac = mac.GetAddressBytes();
     this.direction = direction;
     this.log = log;
     this.notify = notify;
 }
开发者ID:prashanthbc,项目名称:firebwall,代码行数:8,代码来源:fireBwallModule.cs


示例14: Send

        /// <summary>
        /// Sendet ein Wake-On-LAN-Signal an einen Client.
        /// </summary>
        /// <param name="target">Der Ziel-IPEndPoint.</param>
        /// <param name="macAddress">Die MAC-Adresse des Clients.</param>
        /// <exception cref="System.ArgumentNullException">macAddress ist null.</exception>
        /// <exception cref="System.Net.Sockets.SocketException">Fehler beim Zugriff auf den Socket. Weitere Informationen finden Sie im Abschnitt "Hinweise".</exception>
        public static void Send(IPEndPoint target, PhysicalAddress macAddress)
        {
            if (macAddress == null)
                throw new ArgumentNullException("macAddress");

            byte[] packet = GetWolPacket(macAddress.GetAddressBytes());
            SendPacket(target, packet);
        }
开发者ID:MuhammadWaqar,项目名称:wake-on-lan,代码行数:15,代码来源:SendWol.cs


示例15: CtsFrame

			/// <summary>
			/// Initializes a new instance of the <see cref="PacketDotNet.Ieee80211.CtsFrame"/> class.
			/// </summary>
			/// <param name='ReceiverAddress'>
			/// Receiver address.
			/// </param>
			public CtsFrame (PhysicalAddress ReceiverAddress)
			{
				this.FrameControl = new FrameControlField ();
                this.Duration = new DurationField ();
				this.ReceiverAddress = ReceiverAddress;
				
                this.FrameControl.SubType = FrameControlField.FrameSubTypes.ControlCTS;
			}
开发者ID:RSchwoerer,项目名称:Terminals,代码行数:14,代码来源:CtsFrame.cs


示例16: Registration

 public Registration(Command.Endpoint.IInstance commandEndpoint, Version version, string name, string remarks, PhysicalAddress macAddress)
 {
     CommandEndpoint = commandEndpoint;
     Version = version;
     Name = name;
     Remarks = remarks;
     MacAddress = macAddress;
 }
开发者ID:jamesleech,项目名称:Harmonize,代码行数:8,代码来源:Registration.cs


示例17: Host

        public Host(PhysicalAddress mac, IPAddress ipAddress)
        {
            _mac = mac;
            _ipAddress = ipAddress;
            _hostname = _ipAddress.ToString();

            DnsRequests.Enqueue(Resolve);
        }
开发者ID:borte,项目名称:Pcap-Wrapper,代码行数:8,代码来源:Host.cs


示例18: NetworkDictionaryItem

 internal NetworkDictionaryItem( IPAddress ipAddress, PingReply pingReply, PhysicalAddress macAddress, IPHostEntry hostEntry, IOS os )
 {
     _ipAddress = ipAddress;
     _pingReply = pingReply;
     _macAddress = macAddress;
     _hostEntry = hostEntry;
     _os = os;
     _ports = new ConcurrentDictionary<ushort,ushort>();
 }
开发者ID:LudovicT,项目名称:Grid-Mapper,代码行数:9,代码来源:NetworkDictionaryItem.cs


示例19: PrintMACAddress

		/// <summary>
		/// Creates a string from a Physical address in the format "xx:xx:xx:xx:xx:xx"
		/// </summary>
		/// <param name="address">
		/// A <see cref="PhysicalAddress"/>
		/// </param>
		/// <returns>
		/// A <see cref="System.String"/>
		/// </returns>
		public static string PrintMACAddress(PhysicalAddress address) {
			byte[] bytes = address.GetAddressBytes();
			string output = "";

			for (int i = 0; i < bytes.Length; i++) {
				output += bytes[i].ToString("x").PadLeft(2, '0') + ":";
			}
			return output.TrimEnd(':');
		}
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:18,代码来源:HexPrinter.cs


示例20: Send

        /// <summary>Sends a Wake On LAN signal (magic packet) to a client.</summary>
        /// <param name="target">Destination <see cref="IPEndPoint"/>.</param>
        /// <param name="macAddress">The MAC address of the designated client.</param>
        /// <param name="password">The SecureOn password of the client.</param>
        /// <exception cref="ArgumentNullException"><paramref name="macAddress"/> is null.</exception>
        /// <exception cref="SocketException">An error occurred when accessing the socket. See Remarks section of <see cref="UdpClient.Send(byte[], int, IPEndPoint)"/> for more information.</exception>
        public static void Send(IPEndPoint target, PhysicalAddress macAddress, SecureOnPassword password)
        {
            if (macAddress == null)
                throw new ArgumentNullException(nameof(macAddress));

            byte[] passwordBuffer = password?.GetPasswordBytes();
            byte[] packet = GetWolPacket(macAddress.GetAddressBytes(), passwordBuffer);
            SendPacket(target, packet);
        }
开发者ID:nikeee,项目名称:wake-on-lan,代码行数:15,代码来源:SendWol.cs



注:本文中的System.Net.NetworkInformation.PhysicalAddress类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# NetworkInformation.Ping类代码示例发布时间:2022-05-26
下一篇:
C# NetworkInformation.NetworkInterface类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap