/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (ServiceName != null) { hashCode = hashCode * 59 + ServiceName.GetHashCode(); } if (Ipv4 != null) { hashCode = hashCode * 59 + Ipv4.GetHashCode(); } if (Ipv6 != null) { hashCode = hashCode * 59 + Ipv6.GetHashCode(); } if (Port != null) { hashCode = hashCode * 59 + Port.GetHashCode(); } return(hashCode); } }
/// <summary> /// Returns true if Endpoint instances are equal /// </summary> /// <param name="other">Instance of Endpoint to be compared</param> /// <returns>Boolean</returns> public bool Equals(Endpoint other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( ServiceName == other.ServiceName || ServiceName != null && ServiceName.Equals(other.ServiceName) ) && ( Ipv4 == other.Ipv4 || Ipv4 != null && Ipv4.Equals(other.Ipv4) ) && ( Ipv6 == other.Ipv6 || Ipv6 != null && Ipv6.Equals(other.Ipv6) ) && ( Port == other.Port || Port != null && Port.Equals(other.Port) )); }
public IMatch Match(string myString) { var ipv4 = new Ipv4(); var regName = new RegName(); var host = new Choice(ipv4, regName); return(host.Match(myString)); }
/// <summary> /// TBD /// </summary> /// <param name="name">TBD</param> /// <param name="ipv4">TBD</param> /// <param name="ipv6">TBD</param> public Resolved(string name, IEnumerable <IPAddress> ipv4, IEnumerable <IPAddress> ipv6) { Name = name; Ipv4 = ipv4?.ToImmutableList() ?? ImmutableList <IPAddress> .Empty; Ipv6 = ipv6?.ToImmutableList() ?? ImmutableList <IPAddress> .Empty; _addr = Ipv4.FirstOrDefault() ?? Ipv6.FirstOrDefault(); }
/// <summary> /// Se encarga de crear y mostrar una direccion ipv4 representada en sistema binario /// </summary> /// <param name="ipv4">Recibe un arreglo con la direccion en decimal</param> public static void addAdressIpv4(byte [] ipv4) { Direction <Ipv4> directionsIpv4 = new Direction <Ipv4>(1); //Crea un objeto de la clase generica tipo clase ipv4 directionsIpv4.Write(new Ipv4(ipv4)); //Escribe una direccion ipv4 representada en binario Ipv4 d1 = directionsIpv4.GetItem(0); //Se crea un objeto de la clase ipv4 para poder mostrar su direccion representada en binario d1.getDirection(); //Se muestra la direccion }
internal Network(CiscoTelePresenceCodec codec, int indexer) : base(codec, indexer) { _cdp = new Cdp(this, "CDP"); _dns = new Dns(this, "DNS"); _ethernet = new Ethernet(this, "Ethernet"); _ipv4 = new Ipv4(this, "IPV4"); _ipv6 = new Ipv6(this, "IPV6"); _vlan = new Vlan(this, "VLAN"); }
public override int GetHashCode() { int hashcode = 0; unchecked { hashcode = (hashcode * 397) ^ (Ipv4 == null ? 0 : (Ipv4.GetHashCode())); hashcode = (hashcode * 397) ^ (Port == null ? 0 : (Port.GetHashCode())); hashcode = (hashcode * 397) ^ (Service_name == null ? 0 : (Service_name.GetHashCode())); hashcode = (hashcode * 397) ^ (Ipv6 == null ? 0 : (Ipv6.GetHashCode())); } return(hashcode); }
public override int GetHashCode() { int h = 1; h *= 1000003; h ^= (ServiceName == null) ? 0 : ServiceName.GetHashCode(); h *= 1000003; h ^= (Ipv4 == null) ? 0 : Ipv4.GetHashCode(); h *= 1000003; h ^= (Ipv6 == null) ? 0 : Ipv6.GetHashCode(); h *= 1000003; h ^= Port.GetHashCode(); return(h); }
public bool Check(IPAddress ipAddress) { if (ipAddress.AddressFamily == AddressFamily.InterNetwork) { var ipv4 = new Ipv4(ipAddress); lock (_lockObject) { return(!_ipv4ResultMap.GetOrAdd(ipv4, (_) => _ipv4RangeSet.Any(n => n.Verify(ipv4)))); } } return(true); }
/// <summary> /// Initializes a new instance of the Host class. /// </summary> /// <param name="hostName">The host's name.</param> /// <param name="nodalProcessingDelay"></param> /// <param name="interfaces"></param> /// <exception cref="ArgumentNullException">Thrown if the hostName /// parameter is null.</exception> public Host(string hostName, ulong nodalProcessingDelay = 20000, IEnumerable<Interface> interfaces = null) { hostName.ThrowIfNull("hostName"); Hostname = hostName; NodalProcessingDelay = nodalProcessingDelay; Interfaces = new Dictionary<string, Interface>(); Network = new Ipv4(Interfaces.Values, routingTable, nodalProcessingDelay); Routes = routingTable; if (interfaces != null) { foreach (var ifc in interfaces) RegisterInterface(ifc); } }
public override string ToString() { var sb = new StringBuilder("Endpoint("); int tmp1 = 0; if (__isset.ipv4) { if (0 < tmp1++) { sb.Append(", "); } sb.Append("Ipv4: "); Ipv4.ToString(sb); } if (__isset.port) { if (0 < tmp1++) { sb.Append(", "); } sb.Append("Port: "); Port.ToString(sb); } if ((Service_name != null) && __isset.service_name) { if (0 < tmp1++) { sb.Append(", "); } sb.Append("Service_name: "); Service_name.ToString(sb); } if ((Ipv6 != null) && __isset.ipv6) { if (0 < tmp1++) { sb.Append(", "); } sb.Append("Ipv6: "); Ipv6.ToString(sb); } sb.Append(')'); return(sb.ToString()); }
/// <summary> /// Initializes a new instance of the Host class. /// </summary> /// <param name="hostName">The host's name.</param> /// <param name="nodalProcessingDelay"></param> /// <param name="interfaces"></param> /// <exception cref="ArgumentNullException">Thrown if the hostName /// parameter is null.</exception> public Host(string hostName, ulong nodalProcessingDelay = 20000, IEnumerable <Interface> interfaces = null) { hostName.ThrowIfNull("hostName"); Hostname = hostName; NodalProcessingDelay = nodalProcessingDelay; Interfaces = new Dictionary <string, Interface>(); Network = new Ipv4(Interfaces.Values, routingTable, nodalProcessingDelay); Routes = routingTable; if (interfaces != null) { foreach (var ifc in interfaces) { RegisterInterface(ifc); } } }
public override bool Equals(object o) { if (o == this) { return(true); } if (!(o is ZipkinEndpoint)) { return(false); } ZipkinEndpoint that = (ZipkinEndpoint)o; return(((ServiceName == null) ? (that.ServiceName == null) : ServiceName.Equals(that.ServiceName)) && ((Ipv4 == null) ? (that.Ipv4 == null) : Ipv4.Equals(that.Ipv4)) && ((Ipv6 == null) ? (that.Ipv6 == null) : Ipv6.Equals(that.Ipv6)) && Port.Equals(that.Port)); }
private IEnumerable <SearchRange <Ipv4> > ParseIpv4Ranges(StreamReader reader) { var list = new List <SearchRange <Ipv4> >(); using (reader) { string line; while ((line = reader.ReadLine()) != null) { int index = line.LastIndexOf(':'); if (index == -1) { continue; } var items = line.Substring(index + 1).Split('-'); if (items.Length != 2) { return(null); } var ipv4s = new Ipv4[2]; ipv4s[0] = new Ipv4(IPAddress.Parse(items[0])); ipv4s[1] = new Ipv4(IPAddress.Parse(items[1])); int c = ipv4s[0].CompareTo(ipv4s[1]); if (c < 0) { list.Add(new SearchRange <Ipv4>(ipv4s[0], ipv4s[1])); } else { list.Add(new SearchRange <Ipv4>(ipv4s[1], ipv4s[0])); } } } return(list); }
public override int GetHashCode() { int hashcode = 157; unchecked { if (__isset.ipv4) { hashcode = (hashcode * 397) + Ipv4.GetHashCode(); } if (__isset.port) { hashcode = (hashcode * 397) + Port.GetHashCode(); } if ((Service_name != null) && __isset.service_name) { hashcode = (hashcode * 397) + Service_name.GetHashCode(); } if ((Ipv6 != null) && __isset.ipv6) { hashcode = (hashcode * 397) + Ipv6.GetHashCode(); } } return(hashcode); }
public void GetObjectData(SerializationInfo info, StreamingContext context) { string ipv4 = Ipv4 == null?Dns.GetHostEntry(string.Empty).AddressList.First((x) => x.AddressFamily == AddressFamily.InterNetwork).ToString() : Ipv4.ToString(); info.AddValue("Ipv4", ipv4); info.AddValue("HostName", HostName); }