java.lang.Object
org.codelibs.jcifs.smb.netbios.NbtAddress
- All Implemented Interfaces:
Address,NetbiosAddress
This class represents a NetBIOS over TCP/IP address. Under normal
conditions, users of jCIFS need not be concerned with this class as
name resolution and session services are handled internally by the smb package.
* Applications can use the methods
getLocalHost,
getByName, and
getAllByAddress to create a new NbtAddress instance. This
class is symmetric with InetAddress.
* About NetBIOS: The NetBIOS name
service is a dynamic distributed service that allows hosts to resolve
names by broadcasting a query, directing queries to a server such as
Samba or WINS. NetBIOS is currently the primary networking layer for
providing name service, datagram service, and session service to the
Microsoft Windows platform. A NetBIOS name can be 15 characters long
and hosts usually registers several names on the network. From a
Windows command prompt you can see
what names a host registers with the nbtstat command.
*
C:\>nbtstat -a 192.168.1.15
NetBIOS Remote Machine Name Table
Name Type Status
---------------------------------------------
JMORRIS2 <00> UNIQUE Registered
BILLING-NY <00> GROUP Registered
JMORRIS2 <03> UNIQUE Registered
JMORRIS2 <20> UNIQUE Registered
BILLING-NY <1E> GROUP Registered
JMORRIS <03> UNIQUE Registered
MAC Address = 00-B0-34-21-FA-3B
* The hostname of this machine is JMORRIS2. It is
a member of the group(a.k.a workgroup and domain) BILLING-NY. To
obtain an InetAddress for a host one might do:
InetAddress addr = NbtAddress.getByName("jmorris2").getInetAddress();
* From a UNIX platform with Samba installed you can perform similar
diagnostics using the nmblookup utility.- Since:
- org.codelibs.jcifs.smb-0.1
- Author:
- Michael B. Allen
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThis is a special name that means all hosts.static final intA B node only broadcasts name queries.static final intA Hybrid node tries to resolve a name using the nameserver first.static final intTry Broadcast queries first, then try to resolve the name using the nameserver.static final StringThis is a special name for querying the master browser that serves the list of hosts found in "Network Neighborhood".static final intA Point-to-Point node, or P node, unicasts queries to a nameserver only.static final StringA special generic name specified when connecting to a host for which a name is not known.static final byte[]Unknown MAC Address -
Method Summary
Modifier and TypeMethodDescriptionbooleanDetermines if this address is equal two another.Guess next called name to try for session establishment.byte[]Returns the raw IP address of this NbtAddress.Returns this IP adress as aStringin the form "%d.The hostname of this address.To convert this address to anInetAddress.byte[]Retrieves the MAC address of the remote network interface.getName()Gets the NetBIOS name associated with this address.intReturned the hex code associated with this name(e.g. 0x20 is for the file service)intChecks the node type of this address.inthashCode()Returns a hashcode for this IP address.booleanisActive(CIFSContext tc) Determines if this address is active.booleanDetermines if this address in the process of being deleted.booleanDetermines if the address is a group address.booleanDetermines if this address in conflict with another address.booleanDetermines if this address is set to be permanent.Guess next called name to try for session establishment.Converts this address to an InetAddress.toString()Returns theStringrepresentaion of this address.<T extends Address>
TUnwrap the address to a specific type
-
Field Details
-
ANY_HOSTS_NAME
This is a special name that means all hosts. If you wish to find all hosts on a network querying a workgroup group name is the preferred method.- See Also:
-
MASTER_BROWSER_NAME
This is a special name for querying the master browser that serves the list of hosts found in "Network Neighborhood".- See Also:
-
SMBSERVER_NAME
A special generic name specified when connecting to a host for which a name is not known. Not all servers respond to this name.- See Also:
-
B_NODE
public static final int B_NODEA B node only broadcasts name queries. This is the default if a nameserver such as WINS or Samba is not specified.- See Also:
-
P_NODE
public static final int P_NODEA Point-to-Point node, or P node, unicasts queries to a nameserver only. Natrually theorg.codelibs.jcifs.smb.netbios.nameserverproperty must be set.- See Also:
-
M_NODE
public static final int M_NODETry Broadcast queries first, then try to resolve the name using the nameserver.- See Also:
-
H_NODE
public static final int H_NODEA Hybrid node tries to resolve a name using the nameserver first. If that fails use the broadcast address. This is the default if a nameserver is provided. This is the behavior of Microsoft Windows machines.- See Also:
-
UNKNOWN_MAC_ADDRESS
public static final byte[] UNKNOWN_MAC_ADDRESSUnknown MAC Address
-
-
Method Details
-
unwrap
Unwrap the address to a specific type -
firstCalledName
Guess next called name to try for session establishment. These methods are used by the smb package.- Specified by:
firstCalledNamein interfaceAddress- Returns:
- guessed name
-
nextCalledName
Description copied from interface:AddressGuess next called name to try for session establishment. These methods are used by the smb package.- Specified by:
nextCalledNamein interfaceAddress- Parameters:
tc- context to use- Returns:
- net name to try
-
isGroupAddress
Description copied from interface:NetbiosAddressDetermines if the address is a group address. This is also known as a workgroup name or group name.- Specified by:
isGroupAddressin interfaceNetbiosAddress- Parameters:
tc- context to use- Returns:
- whether the given address is a group address
- Throws:
UnknownHostException- if the host cannot be resolved to find out.
-
getNodeType
Description copied from interface:NetbiosAddressChecks the node type of this address.- Specified by:
getNodeTypein interfaceNetbiosAddress- Parameters:
tc- context to use- Returns:
B_NODE,P_NODE,M_NODE,H_NODE- Throws:
UnknownHostException- if the host cannot be resolved to find out.
-
isBeingDeleted
Description copied from interface:NetbiosAddressDetermines if this address in the process of being deleted.- Specified by:
isBeingDeletedin interfaceNetbiosAddress- Parameters:
tc- context to use- Returns:
- whether this address is in the process of being deleted
- Throws:
UnknownHostException- if the host cannot be resolved to find out.
-
isInConflict
Description copied from interface:NetbiosAddressDetermines if this address in conflict with another address.- Specified by:
isInConflictin interfaceNetbiosAddress- Parameters:
tc- context to use- Returns:
- whether this address is in conflict with another address
- Throws:
UnknownHostException- if the host cannot be resolved to find out.
-
isActive
Description copied from interface:NetbiosAddressDetermines if this address is active.- Specified by:
isActivein interfaceNetbiosAddress- Parameters:
tc- context to use- Returns:
- whether this address is active
- Throws:
UnknownHostException- if the host cannot be resolved to find out.
-
isPermanent
Description copied from interface:NetbiosAddressDetermines if this address is set to be permanent.- Specified by:
isPermanentin interfaceNetbiosAddress- Parameters:
tc- context to use- Returns:
- whether this address is permanent
- Throws:
UnknownHostException- if the host cannot be resolved to find out.
-
getMacAddress
Description copied from interface:NetbiosAddressRetrieves the MAC address of the remote network interface. Samba returns all zeros.- Specified by:
getMacAddressin interfaceNetbiosAddress- Parameters:
tc- context to use- Returns:
- the MAC address as an array of six bytes
- Throws:
UnknownHostException- if the host cannot be resolved to determine the MAC address.
-
getHostName
The hostname of this address. If the hostname is null the local machines IP address is returned.- Specified by:
getHostNamein interfaceAddress- Returns:
- the text representation of the hostname associated with this address
-
getName
Description copied from interface:NetbiosAddressGets the NetBIOS name associated with this address.- Specified by:
getNamein interfaceNetbiosAddress- Returns:
- the name for this address
-
getAddress
public byte[] getAddress()Returns the raw IP address of this NbtAddress. The result is in network byte order: the highest order byte of the address is in getAddress()[0].- Returns:
- a four byte array
-
getInetAddress
To convert this address to anInetAddress.- Returns:
- the
InetAddressrepresentation of this address. - Throws:
UnknownHostException- if the address cannot be resolved
-
toInetAddress
Description copied from interface:AddressConverts this address to an InetAddress.- Specified by:
toInetAddressin interfaceAddress- Returns:
- this address as an InetAddress
- Throws:
UnknownHostException- if the host cannot be resolved
-
getHostAddress
Returns this IP adress as aStringin the form "%d.%d.%d.%d".- Specified by:
getHostAddressin interfaceAddress- Returns:
- string representation of the IP address
-
getNameType
public int getNameType()Description copied from interface:NetbiosAddressReturned the hex code associated with this name(e.g. 0x20 is for the file service)- Specified by:
getNameTypein interfaceNetbiosAddress- Returns:
- the name type
-
hashCode
public int hashCode()Returns a hashcode for this IP address. The hashcode comes from the IP address and is not generated from the string representation. So because NetBIOS nodes can have many names, all names associated with an IP will have the same hashcode. -
equals
Determines if this address is equal two another. Only the IP Addresses are compared. Similar to thehashCode()method, the comparison is based on the integer IP address and not the string representation. -
toString
Returns theStringrepresentaion of this address.
-