/** * Retrieve all addresses of a host by it's address. NetBIOS hosts can * have many names for a given IP address. The name and IP address make the * NetBIOS address. This provides a way to retrieve the other names for a * host with the same IP address. * * @param host hostname to lookup all addresses for * @throws java.net.UnknownHostException if there is an error resolving the name */ public static NbtAddress[] getAllByAddress( String host ) throws UnknownHostException { return getAllByAddress( getByName( host, 0x00, null )); }
/** * To convert this address to an <code>InetAddress</code>. * * @return the {@link java.net.InetAddress} representation of this address. */ public InetAddress getInetAddress() throws UnknownHostException { return InetAddress.getByName( getHostAddress() ); }
/** * Return the hostname of this address such as "MYCOMPUTER". */ public String getHostName() { if( addr instanceof NbtAddress ) { return ((NbtAddress)addr).getHostName(); } return ((InetAddress)addr).getHostName(); }
@SneakyThrows private UniAddress getUniAddress() { if (this.loadBalance) { if (StringUtils.isNotBlank(this.includePattern)) { val dcs = NbtAddress.getAllByName(this.domainController, NBT_ADDRESS_TYPE, null, null); return Arrays.stream(dcs) .filter(dc2 -> dc2.getHostAddress().matches(this.includePattern)) .findFirst() .map(UniAddress::new) .orElse(null); } return new UniAddress(NbtAddress.getByName(this.domainController, NBT_ADDRESS_TYPE, null)); } return UniAddress.getByName(this.domainController, true); }
nbtAddr = NbtAddress.getByName(hostAddress); nbtAddr.getNodeType(); if (!nbtAddr.getHostName().equals(hostAddress)) serviceStatus = PollStatus.available();
/** * Determines the address of a host given it's host name. The name can be a NetBIOS name like * "freto" or an IP address like "192.168.1.15". It cannot be a DNS name; * the analygous {@link jcifs.UniAddress} or {@link java.net.InetAddress} * <code>getByName</code> methods can be used for that. * * @param host hostname to resolve * @throws java.net.UnknownHostException if there is an error resolving the name */ public static NbtAddress getByName( String host ) throws UnknownHostException { return getByName( host, 0x00, null ); }
request = new NodeStatusRequest( new Name( NbtAddress.ANY_HOSTS_NAME, 0x00, null)); request.addr = addr.getInetAddress(); if( log.level > 1 ) ioe.printStackTrace( log ); throw new UnknownHostException( addr.toString() );
/** * Determines if this address in the process of being deleted. * * @throws UnknownHostException if the host cannot be resolved to find out. */ public boolean isBeingDeleted() throws UnknownHostException { checkNodeStatusData(); return isBeingDeleted; }
@Override public boolean isGroupAddress ( CIFSContext tc ) throws UnknownHostException { checkData(tc); return this.groupName; }
int readRDataWireFormat( byte[] src, int srcIndex ) { if( resultCode != 0 || opCode != QUERY ) { return 0; } boolean groupName = (( src[srcIndex] & 0x80 ) == 0x80 ) ? true : false; int nodeType = ( src[srcIndex] & 0x60 ) >> 5; srcIndex += 2; int address = readInt4( src, srcIndex ); if( address != 0 ) { addrEntry[addrIndex] = new NbtAddress( recordName, address, groupName, nodeType ); } else { addrEntry[addrIndex] = null; } return 6; } public String toString() {
if ( this.getNameType() == 0x1D ) { for ( int i = 0; i < addrs.length; i++ ) { if ( addrs[ i ].getNameType() == 0x20 ) { return getHostName();
@Override public InetAddress toInetAddress () throws UnknownHostException { return getInetAddress(); }
boolean isWorkgroup0() throws UnknownHostException { if( type == TYPE_WORKGROUP || url.getHost().length() == 0 ) { type = TYPE_WORKGROUP; return true; } else { getUncPath0(); if( share == null ) { UniAddress addr = getAddress(); if( addr.getAddress() instanceof NbtAddress ) { int code = ((NbtAddress)addr.getAddress()).getNameType(); if( code == 0x1d || code == 0x1b ) { type = TYPE_WORKGROUP; return true; } } type = TYPE_SERVER; } } return false; }
/** * Guess first called name to try for session establishment. This * method is used exclusively by the <tt>jcifs.smb</tt> package. */ public String firstCalledName() { if( addr instanceof NbtAddress ) { return ((NbtAddress)addr).firstCalledName(); } else { calledName = ((InetAddress)addr).getHostName(); if( isDotQuadIP( calledName )) { calledName = NbtAddress.SMBSERVER_NAME; } else { int i = calledName.indexOf( '.' ); if( i > 1 && i < 15 ) { calledName = calledName.substring( 0, i ).toUpperCase(); } else if( calledName.length() > 15 ) { calledName = NbtAddress.SMBSERVER_NAME; } else { calledName = calledName.toUpperCase(); } } } return calledName; }
NbtAddress[] list = NbtAddress.getAllByName( DOMAIN, 0x1C, null, null ); dc_list_expiration = now + CACHE_POLICY * 1000L; if (list != null && list.length > 0) {
final NbtAddress[] dcs = NbtAddress.getAllByName(this.domainController, NBT_ADDRESS_TYPE, null, null); for (final NbtAddress dc2 : dcs) { if(dc2.getHostAddress().matches(this.includePattern)){ dc = new UniAddress(dc2); break; dc = new UniAddress(NbtAddress.getByName(this.domainController, NBT_ADDRESS_TYPE, null));
/** * Determines the address of a host given it's host name. The name can be a NetBIOS name like * "freto" or an IP address like "192.168.1.15". It cannot be a DNS name; * the analygous {@link jcifs.UniAddress} or {@link java.net.InetAddress} * <code>getByName</code> methods can be used for that. * * @param host hostname to resolve * @throws java.net.UnknownHostException if there is an error resolving the name */ public static NbtAddress getByName( String host ) throws UnknownHostException { return getByName( host, 0x00, null ); }
request = new NodeStatusRequest( new Name( NbtAddress.ANY_HOSTS_NAME, 0x00, null)); request.addr = addr.getInetAddress(); if( log.level > 1 ) ioe.printStackTrace( log ); throw new UnknownHostException( addr.toString() );
/** * Determines if this address is active. * * @throws UnknownHostException if the host cannot be resolved to find out. */ public boolean isActive() throws UnknownHostException { checkNodeStatusData(); return isActive; }
/** * Checks the node type of this address. * @return {@link jcifs.netbios.NbtAddress#B_NODE}, * {@link jcifs.netbios.NbtAddress#P_NODE}, {@link jcifs.netbios.NbtAddress#M_NODE}, * {@link jcifs.netbios.NbtAddress#H_NODE} * * @throws UnknownHostException if the host cannot be resolved to find out. */ public int getNodeType() throws UnknownHostException { checkData(); return nodeType; }