| java.lang.Object com.knowgate.jcifs.netbios.NbtAddress
NbtAddress | final public class NbtAddress (Code) | | 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
java.net.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
java.net.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.
author: Michael B. Allen See Also: java.net.InetAddress since: jcifs-0.1 |
Inner Class :final static class CacheEntry | |
Constructor Summary | |
| NbtAddress(Name hostName, int address, boolean groupName, int nodeType) | | NbtAddress(Name hostName, int address, boolean groupName, int nodeType, boolean isBeingDeleted, boolean isInConflict, boolean isActive, boolean isPermanent, byte[] macAddress) |
Method Summary | |
static void | cacheAddress(Name hostName, NbtAddress addr) | static void | cacheAddress(Name hostName, NbtAddress addr, long expiration) | static void | cacheAddressArray(NbtAddress[] addrs) | void | checkData() | void | checkNodeStatusData() | static NbtAddress | doNameQuery(Name name, InetAddress svr) | public boolean | equals(Object obj) Determines if this address is equal two another. | public String | firstCalledName() | public byte[] | getAddress() Returns the raw IP address of this NbtAddress. | public static NbtAddress[] | getAllByAddress(String host) Retrieve all addresses of a host by it's address. | public static NbtAddress[] | getAllByAddress(String host, int type, String scope) Retrieve all addresses of a host by it's address. | public static NbtAddress[] | getAllByAddress(NbtAddress addr) Retrieve all addresses of a host by it's address. | public static NbtAddress | getByName(String host) Determines the address of a host given it's host name. | public static NbtAddress | getByName(String host, int type, String scope) Determines the address of a host given it's host name. | public static NbtAddress | getByName(String host, int type, String scope, InetAddress svr) | static NbtAddress | getCachedAddress(Name hostName) | public String | getHostAddress() Returns this IP adress as a
java.lang.String in the form "%d.%d.%d.%d". | public String | getHostName() The hostname of this address. | public InetAddress | getInetAddress() To convert this address to an InetAddress . | public static NbtAddress | getLocalHost() Retrieves the local host address. | public byte[] | getMacAddress() Retrieves the MAC address of the remote network interface. | public int | getNameType() Returned the hex code associated with this name(e.g. | public int | getNodeType() Checks the node type of this address. | public static InetAddress | getWINSAddress() | public int | hashCode() Returns a hashcode for this IP address. | public boolean | isActive() Determines if this address is active. | public boolean | isBeingDeleted() Determines if this address in the process of being deleted. | public boolean | isGroupAddress() Determines if the address is a group address. | public boolean | isInConflict() Determines if this address in conflict with another address. | public boolean | isPermanent() Determines if this address is set to be permanent. | public static boolean | isWINS(InetAddress svr) | public String | nextCalledName() | static InetAddress | switchWINS() | public String | toString() Returns the
java.lang.String representaion of this address. |
B_NODE | final public static int B_NODE(Code) | | A B node only broadcasts name queries. This is the default if a
nameserver such as WINS or Samba is not specified.
|
H_NODE | final public static int H_NODE(Code) | | A 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.
|
MASTER_BROWSER_NAME | final public static String MASTER_BROWSER_NAME(Code) | | This is a special name for querying the master browser that serves the
list of hosts found in "Network Neighborhood".
|
M_NODE | final public static int M_NODE(Code) | | Try Broadcast queries first, then try to resolve the name using the
nameserver.
|
P_NODE | final public static int P_NODE(Code) | | A Point-to-Point node, or P node, unicasts queries to a nameserver
only. Natrually the jcifs.netbios.nameserver property must
be set.
|
SMBSERVER_NAME | final public static String SMBSERVER_NAME(Code) | | A special generic name specified when connecting to a host for which
a name is not known. Not all servers respond to this name.
|
UNKNOWN_MAC_ADDRESS | final static byte[] UNKNOWN_MAC_ADDRESS(Code) | | |
addressnodeType | int addressnodeType(Code) | | |
groupNameisBeingDeletedisInConflictisActiveisPermanentisDataFromNodeStatus | boolean groupNameisBeingDeletedisInConflictisActiveisPermanentisDataFromNodeStatus(Code) | | |
macAddress | byte[] macAddress(Code) | | |
NbtAddress | NbtAddress(Name hostName, int address, boolean groupName, int nodeType)(Code) | | |
NbtAddress | NbtAddress(Name hostName, int address, boolean groupName, int nodeType, boolean isBeingDeleted, boolean isInConflict, boolean isActive, boolean isPermanent, byte[] macAddress)(Code) | | |
equals | public boolean equals(Object obj)(Code) | | Determines if this address is equal two another. Only the IP Addresses
are compared. Similar to the
NbtAddress.hashCode method, the comparison
is based on the integer IP address and not the string representation.
|
getAddress | public byte[] getAddress()(Code) | | 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].
a four byte array |
getAllByAddress | public static NbtAddress[] getAllByAddress(String host) throws UnknownHostException(Code) | | 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.
Parameters: host - hostname to lookup all addresses for throws: java.net.UnknownHostException - if there is an error resolving the name |
getAllByAddress | public static NbtAddress[] getAllByAddress(String host, int type, String scope) throws UnknownHostException(Code) | | 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. See
NbtAddress.getByName for a description of type
and scope .
Parameters: host - hostname to lookup all addresses for Parameters: type - the hexcode of the name Parameters: scope - the scope of the name throws: java.net.UnknownHostException - if there is an error resolving the name |
getAllByAddress | public static NbtAddress[] getAllByAddress(NbtAddress addr) throws UnknownHostException(Code) | | 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.
Parameters: addr - the address to query throws: UnknownHostException - if address cannot be resolved |
getByName | public static NbtAddress getByName(String host) throws UnknownHostException(Code) | | 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
jcifs.UniAddress or
java.net.InetAddress getByName methods can be used for that.
Parameters: host - hostname to resolve throws: java.net.UnknownHostException - if there is an error resolving the name |
getByName | public static NbtAddress getByName(String host, int type, String scope) throws UnknownHostException(Code) | | Determines the address of a host given it's host name. NetBIOS
names also have a type . Types(aka Hex Codes)
are used to distiquish 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. A scope of null or ""
signifies no scope.
Parameters: host - the name to resolve Parameters: type - the hex code of the name Parameters: scope - the scope of the name throws: java.net.UnknownHostException - if there is an error resolving the name |
getHostName | public String getHostName()(Code) | | The hostname of this address. If the hostname is null the local machines
IP address is returned.
the text representation of the hostname associated with this address |
getMacAddress | public byte[] getMacAddress() throws UnknownHostException(Code) | | Retrieves the MAC address of the remote network interface. Samba returns all zeros.
the MAC address as an array of six bytes throws: UnknownHostException - if the host cannot be resolved todetermine the MAC address. |
getNameType | public int getNameType()(Code) | | Returned the hex code associated with this name(e.g. 0x20 is for the file service)
|
getNodeType | public int getNodeType() throws UnknownHostException(Code) | | Checks the node type of this address.
jcifs.netbios.NbtAddress.B_NODE,jcifs.netbios.NbtAddress.P_NODE, jcifs.netbios.NbtAddress.M_NODE,jcifs.netbios.NbtAddress.H_NODE throws: UnknownHostException - if the host cannot be resolved to find out. |
hashCode | public int hashCode()(Code) | | 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.
|
isGroupAddress | public boolean isGroupAddress() throws UnknownHostException(Code) | | Determines if the address is a group address. This is also
known as a workgroup name or group name.
throws: UnknownHostException - if the host cannot be resolved to find out. |
|
|