本文整理汇总了C#中System.Net.NetworkInformation.PhysicalAddress类的典型用法代码示例。如果您正苦于以下问题:C# PhysicalAddress类的具体用法?C# PhysicalAddress怎么用?C# PhysicalAddress使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PhysicalAddress类属于System.Net.NetworkInformation命名空间,在下文中一共展示了PhysicalAddress类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ChassisID
public ChassisID(PhysicalAddress MACAddress)
{
this.EmptyTLVDataInit();
base.Type = TLVTypes.ChassisID;
this.SubType = ChassisSubTypes.MACAddress;
this.SubTypeValue = MACAddress;
}
示例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;
}
}
}
示例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);
}
}
示例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");
}
示例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;
}
示例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();
}
示例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 { }
}
示例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;
}
示例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();
}
示例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();
}
示例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);
}
示例12: BthDevice
public BthDevice(IBthDevice device, PhysicalAddress master, byte lsb, byte msb)
: base(new BthHandle(lsb, msb))
{
InitializeComponent();
BluetoothDevice = device;
HostAddress = master;
}
示例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;
}
示例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);
}
示例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;
}