Example #1
0
 public DotNetInterface(NetworkInterface n, UdpIPv4Address[] gw, UdpIPv4Address[] uni, UdpIPv4Address[] multi)
 {
     this.name               = DotNetInterface.ParseName(n);
     this.linkType           = DotNetInterface.ParseLinkType(n);
     this.physicalAddress    = DotNetInterface.ParsePhysicalAddress(n);
     this.gatewayAddresses   = gw;
     this.unicastAddresses   = uni;
     this.multicastAddresses = multi;
 }
Example #2
0
    private List <UdpPlatformInterface> FindInterfaces()
    {
        List <UdpPlatformInterface> list = new List <UdpPlatformInterface>();

        try
        {
            if (NetworkInterface.GetIsNetworkAvailable())
            {
                NetworkInterface[] allNetworkInterfaces = NetworkInterface.GetAllNetworkInterfaces();
                for (int i = 0; i < allNetworkInterfaces.Length; i++)
                {
                    NetworkInterface networkInterface = allNetworkInterfaces[i];
                    try
                    {
                        if (networkInterface.OperationalStatus == OperationalStatus.Up || networkInterface.OperationalStatus == OperationalStatus.Unknown)
                        {
                            if (networkInterface.NetworkInterfaceType != NetworkInterfaceType.Loopback)
                            {
                                DotNetInterface dotNetInterface = this.ParseInterface(networkInterface);
                                if (dotNetInterface != null)
                                {
                                    list.Add(dotNetInterface);
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        UdpLog.Error(ex.Message, new object[0]);
                    }
                }
            }
        }
        catch (Exception ex2)
        {
            UdpLog.Error(ex2.Message, new object[0]);
        }
        return(list);
    }