ln.skyscanner/entities/NetworkInterface.cs

66 lines
1.6 KiB
C#
Raw Normal View History

2019-03-21 14:06:36 +01:00
// /**
// * File: Router.cs
// * Author: haraldwolff
// *
// * This file and it's content is copyrighted by the Author and / or copyright holder.
// * Any use wihtout proper permission is illegal and may lead to legal actions.
// *
// *
// **/
using System;
using System.Collections.Generic;
2019-04-02 01:25:44 +02:00
using ln.types.net;
2019-03-21 14:06:36 +01:00
namespace ln.skyscanner.entities
{
2019-03-29 13:57:06 +01:00
public class NetworkInterface
2019-03-21 14:06:36 +01:00
{
2019-03-27 07:49:49 +01:00
public readonly Guid ID = Guid.NewGuid();
2019-03-26 12:53:42 +01:00
2019-03-21 14:06:36 +01:00
public string Name { get; private set; } = "";
2019-03-27 07:49:49 +01:00
public string HWAddress { get; set; } = "";
2019-03-21 14:06:36 +01:00
2019-04-03 09:19:37 +02:00
public List<ConfiguredIP> ConfiguredIPs { get; private set; } = new List<ConfiguredIP>();
2019-03-21 14:06:36 +01:00
private NetworkInterface()
{ }
2019-04-03 09:19:37 +02:00
public NetworkInterface(String name)
2019-03-21 14:06:36 +01:00
{
Name = name;
}
2019-04-02 01:25:44 +02:00
public bool HasIP(IPv4 ip)
2019-03-26 12:53:42 +01:00
{
2019-04-03 09:19:37 +02:00
foreach (ConfiguredIP ifip in ConfiguredIPs)
2019-03-26 12:53:42 +01:00
{
2019-04-02 01:25:44 +02:00
if (ifip.IP.Equals(ip))
2019-03-26 12:53:42 +01:00
return true;
}
return false;
}
2019-03-21 14:06:36 +01:00
public override int GetHashCode()
{
2019-04-03 09:19:37 +02:00
return Name.GetHashCode();
2019-03-21 14:06:36 +01:00
}
public override bool Equals(object obj)
{
if (obj is NetworkInterface)
{
NetworkInterface networkInterface = obj as NetworkInterface;
2019-04-03 09:19:37 +02:00
return object.Equals(Name,networkInterface.Name);
2019-03-21 14:06:36 +01:00
}
return false;
}
2019-04-01 15:17:41 +02:00
public override string ToString()
{
2019-04-03 09:19:37 +02:00
return string.Format("[NetworkInterface ID={0} Name={1}]",ID,Name);
2019-04-01 15:17:41 +02:00
}
2019-03-21 14:06:36 +01:00
}
}