private static MulticastIPAddressInformationCollection GetMulticastAddresses(UnixNetworkInterface uni) { var collection = new MulticastIPAddressInformationCollection(); foreach (IPAddress address in uni.Addresses.Where(IsMulticast)) { collection.InternalAdd(new UnixMulticastIPAddressInformation(address)); } return collection; }
private static UnicastIPAddressInformationCollection GetUnicastAddresses(UnixNetworkInterface uni) { var collection = new UnicastIPAddressInformationCollection(); foreach (IPAddress address in uni.Addresses.Where((addr) => !IsMulticast(addr))) { IPAddress netMask = (address.AddressFamily == AddressFamily.InterNetwork) ? uni.GetNetMaskForIPv4Address(address) : IPAddress.Any; // Windows compatibility collection.InternalAdd(new UnixUnicastIPAddressInformation(address, netMask)); } return collection; }
private static UnicastIPAddressInformationCollection GetUnicastAddresses(UnixNetworkInterface uni) { var collection = new UnicastIPAddressInformationCollection(); foreach (IPAddress address in uni.Addresses) { if (!IPAddressUtil.IsMulticast(address)) { IPAddress netMask = (address.AddressFamily == AddressFamily.InterNetwork) ? uni.GetNetMaskForIPv4Address(address) : IPAddress.Any; // Windows compatibility collection.InternalAdd(new UnixUnicastIPAddressInformation(address, netMask)); } } return(collection); }
protected static unsafe void ProcessIpv4Address(UnixNetworkInterface uni, Interop.Sys.IpAddressInfo* addressInfo, Interop.Sys.IpAddressInfo* netMask) { byte[] ipBytes = new byte[addressInfo->NumAddressBytes]; fixed (byte* ipArrayPtr = ipBytes) { Buffer.MemoryCopy(addressInfo->AddressBytes, ipArrayPtr, ipBytes.Length, ipBytes.Length); } IPAddress ipAddress = new IPAddress(ipBytes); byte[] ipBytes2 = new byte[netMask->NumAddressBytes]; fixed (byte* ipArrayPtr = ipBytes2) { Buffer.MemoryCopy(netMask->AddressBytes, ipArrayPtr, ipBytes2.Length, ipBytes2.Length); } IPAddress netMaskAddress = new IPAddress(ipBytes2); uni.AddAddress(ipAddress); uni._netMasks[ipAddress] = netMaskAddress; }
protected static unsafe void ProcessIpv4Address(UnixNetworkInterface uni, Interop.Sys.IpAddressInfo *addressInfo, Interop.Sys.IpAddressInfo *netMask) { byte[] ipBytes = new byte[addressInfo->NumAddressBytes]; fixed(byte *ipArrayPtr = ipBytes) { Buffer.MemoryCopy(addressInfo->AddressBytes, ipArrayPtr, ipBytes.Length, ipBytes.Length); } IPAddress ipAddress = new IPAddress(ipBytes); byte[] ipBytes2 = new byte[netMask->NumAddressBytes]; fixed(byte *ipArrayPtr = ipBytes2) { Buffer.MemoryCopy(netMask->AddressBytes, ipArrayPtr, ipBytes2.Length, ipBytes2.Length); } IPAddress netMaskAddress = new IPAddress(ipBytes2); uni.AddAddress(ipAddress); uni._netMasks[ipAddress] = netMaskAddress; }
public UnixIPv4InterfaceProperties (UnixNetworkInterface iface) { this.iface = iface; }
public UnixIPInterfaceProperties (UnixNetworkInterface iface, List <IPAddress> addresses) { this.iface = iface; this.addresses = addresses; }
public UnixIPInterfaceProperties(UnixNetworkInterface uni) { _uni = uni; _dnsSuffix = GetDnsSuffix(); _dnsAddresses = GetDnsAddresses(); }
public UnixIPv4InterfaceProperties(UnixNetworkInterface iface) { this.iface = iface; }
public UnixIPInterfaceProperties(UnixNetworkInterface iface, List <IPAddress> addresses) { this.iface = iface; this.addresses = addresses; }
public static int IfNameToIndex(string ifname) { return(UnixNetworkInterface.if_nametoindex(ifname)); }
protected static unsafe void ProcessIpv6Address(UnixNetworkInterface uni, Interop.Sys.IpAddressInfo* addressInfo, uint scopeId) { byte[] ipBytes = new byte[addressInfo->NumAddressBytes]; fixed (byte* ipArrayPtr = ipBytes) { Buffer.MemoryCopy(addressInfo->AddressBytes, ipArrayPtr, ipBytes.Length, ipBytes.Length); } IPAddress address = new IPAddress(ipBytes); uni.AddAddress(address); uni._ipv6ScopeId = scopeId; }
protected static unsafe void ProcessLinkLayerAddress(UnixNetworkInterface uni, Interop.Sys.LinkLayerAddressInfo* llAddr) { byte[] macAddress = new byte[llAddr->NumAddressBytes]; fixed (byte* macAddressPtr = macAddress) { Buffer.MemoryCopy(llAddr->AddressBytes, macAddressPtr, llAddr->NumAddressBytes, llAddr->NumAddressBytes); } PhysicalAddress physicalAddress = new PhysicalAddress(macAddress); uni._index = llAddr->InterfaceIndex; uni._id = uni._index.ToString(); uni._physicalAddress = physicalAddress; uni._networkInterfaceType = (NetworkInterfaceType)llAddr->HardwareType; }