Exemplo n.º 1
0
        public bool Equals(PeerSocketAddress other)
        {
            var t1 = InetAddress.Equals(other.InetAddress);
            var t2 = TcpPort.Equals(other.TcpPort);
            var t3 = UdpPort.Equals(other.UdpPort);

            return(t1 && t2 && t3);
        }
Exemplo n.º 2
0
        public virtual MacIp getMacIp(InetAddress inetAddress)
        {
            lock (this)
            {
                foreach (MacIp macIp in macIps)
                {
                    if (inetAddress.Equals(macIp.inetAddress))
                    {
                        return(macIp);
                    }

                    // When using 2 instances of pspsharp on the local machine
                    if (isLocalInetAddress(inetAddress) && isLocalInetAddress(macIp.inetAddress))
                    {
                        return(macIp);
                    }
                }

                return(null);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Compares this object against the specified object.
        /// The result is {@code true} if and only if the argument is
        /// not {@code null} and it represents the same interface address as
        /// this object.
        /// <para>
        /// Two instances of {@code InterfaceAddress} represent the same
        /// address if the InetAddress, the prefix length and the broadcast are
        /// the same for both.
        ///
        /// </para>
        /// </summary>
        /// <param name="obj">   the object to compare against. </param>
        /// <returns>  {@code true} if the objects are the same;
        ///          {@code false} otherwise. </returns>
        /// <seealso cref=     java.net.InterfaceAddress#hashCode() </seealso>
        public override bool Equals(Object obj)
        {
            if (!(obj is InterfaceAddress))
            {
                return(false);
            }
            InterfaceAddress cmp = (InterfaceAddress)obj;

            if (!(Address_Renamed == null ? cmp.Address_Renamed == null : Address_Renamed.Equals(cmp.Address_Renamed)))
            {
                return(false);
            }
            if (!(Broadcast_Renamed == null ? cmp.Broadcast_Renamed == null : Broadcast_Renamed.Equals(cmp.Broadcast_Renamed)))
            {
                return(false);
            }
            if (MaskLength != cmp.MaskLength)
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 4
0
 private bool isLocalInetAddress(InetAddress inetAddress)
 {
     return(inetAddress.Equals(loopbackInetAddress) || inetAddress.Equals(localHostInetAddress));
 }