Package jcifs.netbios
Class NameServiceClientImpl
- java.lang.Object
-
- jcifs.netbios.NameServiceClientImpl
-
- All Implemented Interfaces:
Runnable
,NameServiceClient
public class NameServiceClientImpl extends Object implements Runnable, NameServiceClient
- Author:
- mbechler
-
-
Constructor Summary
Constructors Constructor Description NameServiceClientImpl(CIFSContext tc)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description UniAddress[]
getAllByName(String hostname, boolean possibleNTDomainOrWorkgroup)
Lookup addresses for the given hostname.UniAddress
getByName(String hostname)
Determines the address of a host given it's host name.UniAddress
getByName(String hostname, boolean possibleNTDomainOrWorkgroup)
Lookup hostname and return it's UniAddress.Lmhosts
getLmhosts()
NbtAddress
getLocalHost()
Name
getLocalName()
NbtAddress[]
getNbtAllByAddress(String host)
Retrieve all addresses of a host by it's address.NbtAddress[]
getNbtAllByAddress(String host, int type, String scope)
Retrieve all addresses of a host by it's address.NbtAddress[]
getNbtAllByAddress(NetbiosAddress addr)
Retrieve all addresses of a host by it's address.NbtAddress[]
getNbtAllByName(String host, int type, String scope, InetAddress svr)
Retrieve all addresses of a host by it's name.NbtAddress
getNbtByName(String host)
Determines the address of a host given it's host name.NbtAddress
getNbtByName(String host, int type, String scope)
Determines the address of a host given it's host name.NbtAddress
getNbtByName(String host, int type, String scope, InetAddress svr)
Determines the address of a host given it's host name.NbtAddress[]
getNodeStatus(NetbiosAddress addr)
Name
getUnknownName()
protected InetAddress
getWINSAddress()
protected boolean
isWINS(InetAddress svr)
void
run()
protected InetAddress
switchWINS()
-
-
-
Constructor Detail
-
NameServiceClientImpl
public NameServiceClientImpl(CIFSContext tc)
- Parameters:
tc
-
-
-
Method Detail
-
getNodeStatus
public NbtAddress[] getNodeStatus(NetbiosAddress addr) throws UnknownHostException
- Specified by:
getNodeStatus
in interfaceNameServiceClient
- Returns:
- the node status responses
- Throws:
UnknownHostException
-
getNbtByName
public NbtAddress getNbtByName(String host) throws UnknownHostException
Description copied from interface:NameServiceClient
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 analygousUniAddress
orInetAddress
getByName
methods can be used for that.- Specified by:
getNbtByName
in interfaceNameServiceClient
- Parameters:
host
- hostname to resolve- Returns:
- the resolved address
- Throws:
UnknownHostException
- if there is an error resolving the name
-
getNbtByName
public NbtAddress getNbtByName(String host, int type, String scope) throws UnknownHostException
Description copied from interface:NameServiceClient
Determines the address of a host given it's host name. NetBIOS names also have atype
. Types(aka Hex Codes) are used to distinguish the various services on a host. Here is a fairly complete list of NetBIOS hex codes. Scope is not used but is still functional in other NetBIOS products and so for completeness it has been implemented. Ascope
ofnull
or""
signifies no scope.- Specified by:
getNbtByName
in interfaceNameServiceClient
- Parameters:
host
- the name to resolvetype
- the hex code of the namescope
- the scope of the name- Returns:
- the resolved address
- Throws:
UnknownHostException
- if there is an error resolving the name
-
getNbtByName
public NbtAddress getNbtByName(String host, int type, String scope, InetAddress svr) throws UnknownHostException
Description copied from interface:NameServiceClient
Determines the address of a host given it's host name. NetBIOS names also have atype
. Types(aka Hex Codes) are used to distinguish the various services on a host. Here is a fairly complete list of NetBIOS hex codes. Scope is not used but is still functional in other NetBIOS products and so for completeness it has been implemented. Ascope
ofnull
or""
signifies no scope. The additionalsvr
parameter specifies the address to query. This might be the address of a specific host, a name server, or a broadcast address.- Specified by:
getNbtByName
in interfaceNameServiceClient
- Parameters:
host
- the name to resolvetype
- the hex code of the namescope
- the scope of the namesvr
- server to query- Returns:
- the resolved address
- Throws:
UnknownHostException
- if there is an error resolving the name
-
getNbtAllByName
public NbtAddress[] getNbtAllByName(String host, int type, String scope, InetAddress svr) throws UnknownHostException
Description copied from interface:NameServiceClient
Retrieve all addresses of a host by it's name.- Specified by:
getNbtAllByName
in interfaceNameServiceClient
- Parameters:
host
- hostname to lookup all addresses fortype
- the hexcode of the namescope
- the scope of the namesvr
- server to query- Returns:
- the resolved addresses
- Throws:
UnknownHostException
-
getNbtAllByAddress
public NbtAddress[] getNbtAllByAddress(String host) throws UnknownHostException
Description copied from interface:NameServiceClient
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.- Specified by:
getNbtAllByAddress
in interfaceNameServiceClient
- Parameters:
host
- hostname to lookup all addresses for- Returns:
- resolved addresses
- Throws:
UnknownHostException
- if there is an error resolving the name
-
getNbtAllByAddress
public NbtAddress[] getNbtAllByAddress(String host, int type, String scope) throws UnknownHostException
Description copied from interface:NameServiceClient
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. SeeNameServiceClient.getByName(java.lang.String, boolean)
for a description oftype
andscope
.- Specified by:
getNbtAllByAddress
in interfaceNameServiceClient
- Parameters:
host
- hostname to lookup all addresses fortype
- the hexcode of the namescope
- the scope of the name- Returns:
- resolved addresses
- Throws:
UnknownHostException
- if there is an error resolving the name
-
getNbtAllByAddress
public NbtAddress[] getNbtAllByAddress(NetbiosAddress addr) throws UnknownHostException
Description copied from interface:NameServiceClient
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.- Specified by:
getNbtAllByAddress
in interfaceNameServiceClient
- Parameters:
addr
- the address to query- Returns:
- resolved addresses
- Throws:
UnknownHostException
- if address cannot be resolved
-
getWINSAddress
protected InetAddress getWINSAddress()
- Parameters:
tc
-- Returns:
- address of active WINS server
-
isWINS
protected boolean isWINS(InetAddress svr)
- Parameters:
svr
-- Returns:
- whether the given address is a WINS server
-
switchWINS
protected InetAddress switchWINS()
-
getByName
public UniAddress getByName(String hostname) throws UnknownHostException
Description copied from interface:NameServiceClient
Determines the address of a host given it's host name. The name can be a machine name like "jcifs.samba.org", or an IP address like "192.168.1.15".- Specified by:
getByName
in interfaceNameServiceClient
- Parameters:
hostname
- NetBIOS or DNS hostname to resolve- Returns:
- the found address
- Throws:
UnknownHostException
- if there is an error resolving the name
-
getByName
public UniAddress getByName(String hostname, boolean possibleNTDomainOrWorkgroup) throws UnknownHostException
Description copied from interface:NameServiceClient
Lookup hostname and return it's UniAddress. If the possibleNTDomainOrWorkgroup parameter is true an additional name query will be performed to locate a master browser.- Specified by:
getByName
in interfaceNameServiceClient
- Returns:
- the first resolved address
- Throws:
UnknownHostException
-
getAllByName
public UniAddress[] getAllByName(String hostname, boolean possibleNTDomainOrWorkgroup) throws UnknownHostException
Description copied from interface:NameServiceClient
Lookup addresses for the given hostname.- Specified by:
getAllByName
in interfaceNameServiceClient
- Returns:
- found addresses
- Throws:
UnknownHostException
-
getLocalHost
public NbtAddress getLocalHost()
- Specified by:
getLocalHost
in interfaceNameServiceClient
- Returns:
- local host address
- See Also:
NameServiceClient.getLocalHost()
-
getLocalName
public Name getLocalName()
- Specified by:
getLocalName
in interfaceNameServiceClient
- Returns:
- the local host name
- See Also:
NameServiceClient.getLocalName()
-
getLmhosts
public Lmhosts getLmhosts()
- Returns:
- lmhosts file used
-
getUnknownName
public Name getUnknownName()
- Specified by:
getUnknownName
in interfaceNameServiceClient
- Returns:
- the unknown name
- See Also:
NameServiceClient.getUnknownName()
-
-