Esempio n. 1
0
            public override bool Equals(Object o)
            {
                if (!(o is Inet6AddressHolder))
                {
                    return(false);
                }
                Inet6AddressHolder that = (Inet6AddressHolder)o;

                return(Arrays.Equals(this.Ipaddress, that.Ipaddress));
            }
Esempio n. 2
0
 internal Inet6Address(String hostName, sbyte[] addr)
 {
     Holder6 = new Inet6AddressHolder(this);
     try
     {
         Initif(hostName, addr, null);
     }             // cant happen if ifname is null
     catch (UnknownHostException)
     {
     }
 }
Esempio n. 3
0
        /// <summary>
        /// restore the state of this object from stream
        /// including the scope information, only if the
        /// scoped interface name is valid on this system
        /// </summary>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException
        private void ReadObject(ObjectInputStream s)
        {
            NetworkInterface scope_ifname = null;

            if (this.GetType().ClassLoader != null)
            {
                throw new SecurityException("invalid address type");
            }

            ObjectInputStream.GetField gf = s.ReadFields();
            sbyte[] ipaddress             = (sbyte[])gf.Get("ipaddress", null);
            int     scope_id         = (int)gf.Get("scope_id", -1);
            bool    scope_id_set     = (bool)gf.Get("scope_id_set", false);
            bool    scope_ifname_set = (bool)gf.Get("scope_ifname_set", false);
            String  ifname           = (String)gf.Get("ifname", null);

            if (ifname != null && !"".Equals(ifname))
            {
                try
                {
                    scope_ifname = NetworkInterface.GetByName(ifname);
                    if (scope_ifname == null)
                    {
                        /* the interface does not exist on this system, so we clear
                         * the scope information completely */
                        scope_id_set     = false;
                        scope_ifname_set = false;
                        scope_id         = 0;
                    }
                    else
                    {
                        scope_ifname_set = true;
                        try
                        {
                            scope_id = DeriveNumericScope(ipaddress, scope_ifname);
                        }
                        catch (UnknownHostException)
                        {
                            // typically should not happen, but it may be that
                            // the machine being used for deserialization has
                            // the same interface name but without IPv6 configured.
                        }
                    }
                }
                catch (SocketException)
                {
                }
            }

            /* if ifname was not supplied, then the numeric info is used */

            ipaddress = ipaddress.clone();

            // Check that our invariants are satisfied
            if (ipaddress.Length != INADDRSZ)
            {
                throw new InvalidObjectException("invalid address length: " + ipaddress.Length);
            }

            if (Holder_Renamed.Family != IPv6)
            {
                throw new InvalidObjectException("invalid address family type");
            }

            Inet6AddressHolder h = new Inet6AddressHolder(this, ipaddress, scope_id, scope_id_set, scope_ifname, scope_ifname_set);

            UNSAFE.putObject(this, FIELDS_OFFSET, h);
        }
Esempio n. 4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: Inet6Address(String hostName, byte addr[] , String ifname) throws UnknownHostException
        internal Inet6Address(String hostName, sbyte[] addr, String ifname)
        {
            Holder6 = new Inet6AddressHolder(this);
            Initstr(hostName, addr, ifname);
        }
Esempio n. 5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: Inet6Address(String hostName, byte addr[] , NetworkInterface nif) throws UnknownHostException
        internal Inet6Address(String hostName, sbyte[] addr, NetworkInterface nif)
        {
            Holder6 = new Inet6AddressHolder(this);
            Initif(hostName, addr, nif);
        }
Esempio n. 6
0
 /* checking of value for scope_id should be done by caller
  * scope_id must be >= 0, or -1 to indicate not being set
  */
 internal Inet6Address(String hostName, sbyte[] addr, int scope_id)
 {
     Holder_Renamed.Init(hostName, IPv6);
     Holder6 = new Inet6AddressHolder(this);
     Holder6.Init(addr, scope_id);
 }
Esempio n. 7
0
 internal Inet6Address() : base()
 {
     Holder_Renamed.Init(null, IPv6);
     Holder6 = new Inet6AddressHolder(this);
 }