Exemple #1
0
        static NbtAddress()
        {
            IPAddress localInetAddress;
            string    localHostname;
            Name      localName;

            AddressCache.Put(UnknownName, new CacheEntry(UnknownName, UnknownAddress
                                                         , Forever));
            localInetAddress = Client.laddr;
            if (localInetAddress == null)
            {
                try
                {
                    localInetAddress = Extensions.GetAddressByName("127.0.0.1");
                }
                catch (UnknownHostException)
                {
                }
            }
            localHostname = Config.GetProperty("jcifs.netbios.hostname", null);
            if (string.IsNullOrEmpty(localHostname))
            {
                byte[] addr = localInetAddress.GetAddressBytes();

                /*localHostname = "JCIFS" + (addr[2] & unchecked((int)(0xFF))) + "_" + (addr[3] & unchecked(
                 *  (int)(0xFF))) + "_" + Hexdump.ToHexString((int)(new Random().NextDouble() * (double)unchecked(
                 *                      (int)(0xFF))), 2);*/
                localHostname = "JCIFS_127_0_0_1";
            }
            localName = new Name(localHostname, unchecked (0x00), Config.GetProperty("jcifs.netbios.scope"
                                                                                     , null));
            Localhost = new NbtAddress(localName, localInetAddress.GetHashCode(), false, BNode
                                       , false, false, true, false, UnknownMacAddress);
            CacheAddress(localName, Localhost, Forever);
        }
Exemple #2
0
        static UniAddress()
        {
            string    ro   = Config.GetProperty("jcifs.resolveOrder");
            IPAddress nbns = NbtAddress.GetWinsAddress();

            try
            {
                _baddr = Config.GetInetAddress("jcifs.netbios.baddr",
                                               Extensions.GetAddressByName("255.255.255.255"));
            }
            catch (UnknownHostException)
            {
            }
            if (string.IsNullOrEmpty(ro))
            {
                if (nbns == null)
                {
                    _resolveOrder    = new int[3];
                    _resolveOrder[0] = ResolverLmhosts;
                    _resolveOrder[1] = ResolverDns;
                    _resolveOrder[2] = ResolverBcast;
                }
                else
                {
                    _resolveOrder    = new int[4];
                    _resolveOrder[0] = ResolverLmhosts;
                    _resolveOrder[1] = ResolverWins;
                    _resolveOrder[2] = ResolverDns;
                    _resolveOrder[3] = ResolverBcast;
                }
            }
            else
            {
                int[]           tmp = new int[4];
                StringTokenizer st  = new StringTokenizer(ro, ",");
                int             i   = 0;
                while (st.HasMoreTokens())
                {
                    string s = st.NextToken().Trim();
                    if (Runtime.EqualsIgnoreCase(s, "LMHOSTS"))
                    {
                        tmp[i++] = ResolverLmhosts;
                    }
                    else
                    {
                        if (Runtime.EqualsIgnoreCase(s, "WINS"))
                        {
                            if (nbns == null)
                            {
                                if (_log.Level > 1)
                                {
                                    _log.WriteLine(
                                        "UniAddress resolveOrder specifies WINS however the "
                                        + "jcifs.netbios.wins property has not been set");
                                }
                                continue;
                            }
                            tmp[i++] = ResolverWins;
                        }
                        else
                        {
                            if (Runtime.EqualsIgnoreCase(s, "BCAST"))
                            {
                                tmp[i++] = ResolverBcast;
                            }
                            else
                            {
                                if (Runtime.EqualsIgnoreCase(s, "DNS"))
                                {
                                    tmp[i++] = ResolverDns;
                                }
                                else
                                {
                                    if (_log.Level > 1)
                                    {
                                        _log.WriteLine("unknown resolver method: " + s);
                                    }
                                }
                            }
                        }
                    }
                }
                _resolveOrder = new int[i];
                Array.Copy(tmp, 0, _resolveOrder, 0, i);
            }
        }
Exemple #3
0
 /// <summary>To convert this address to an <code>InetAddress</code>.</summary>
 /// <remarks>To convert this address to an <code>InetAddress</code>.</remarks>
 /// <returns>
 /// the
 /// <see cref="System.Net.IPAddress">System.Net.IPAddress</see>
 /// representation of this address.
 /// </returns>
 /// <exception cref="UnknownHostException"></exception>
 public IPAddress GetInetAddress()
 {
     return(Extensions.GetAddressByName(GetHostAddress()));
 }