public final class NbtAddress extends Object implements NetbiosAddress
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.
InetAddress
Modifier and Type | Field and Description |
---|---|
static String |
ANY_HOSTS_NAME
This is a special name that means all hosts.
|
static int |
B_NODE
A B node only broadcasts name queries.
|
static int |
H_NODE
A Hybrid node tries to resolve a name using the nameserver first.
|
static int |
M_NODE
Try Broadcast queries first, then try to resolve the name using the
nameserver.
|
static String |
MASTER_BROWSER_NAME
This is a special name for querying the master browser that serves the
list of hosts found in "Network Neighborhood".
|
static int |
P_NODE
A Point-to-Point node, or P node, unicasts queries to a nameserver
only.
|
static String |
SMBSERVER_NAME
A special generic name specified when connecting to a host for which
a name is not known.
|
static byte[] |
UNKNOWN_MAC_ADDRESS
Unknown MAC Address
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj)
Determines if this address is equal two another.
|
String |
firstCalledName()
Guess next called name to try for session establishment.
|
byte[] |
getAddress()
Returns the raw IP address of this NbtAddress.
|
String |
getHostAddress()
Returns this IP adress as a
String in the form "%d.%d.%d.%d". |
String |
getHostName()
The hostname of this address.
|
InetAddress |
getInetAddress()
To convert this address to an
InetAddress . |
byte[] |
getMacAddress(CIFSContext tc)
Retrieves the MAC address of the remote network interface.
|
NetbiosName |
getName() |
int |
getNameType()
Returned the hex code associated with this name(e.g.
|
int |
getNodeType(CIFSContext tc)
Checks the node type of this address.
|
int |
hashCode()
Returns a hashcode for this IP address.
|
boolean |
isActive(CIFSContext tc)
Determines if this address is active.
|
boolean |
isBeingDeleted(CIFSContext tc)
Determines if this address in the process of being deleted.
|
boolean |
isGroupAddress(CIFSContext tc)
Determines if the address is a group address.
|
boolean |
isInConflict(CIFSContext tc)
Determines if this address in conflict with another address.
|
boolean |
isPermanent(CIFSContext tc)
Determines if this address is set to be permanent.
|
String |
nextCalledName(CIFSContext tc)
Guess next called name to try for session establishment.
|
InetAddress |
toInetAddress() |
String |
toString()
Returns the
String representaion of this address. |
<T extends Address> |
unwrap(Class<T> type) |
public static final String ANY_HOSTS_NAME
public static final String MASTER_BROWSER_NAME
public static final String SMBSERVER_NAME
public static final int B_NODE
public static final int P_NODE
jcifs.netbios.nameserver
property must
be set.public static final int M_NODE
public static final int H_NODE
public static final byte[] UNKNOWN_MAC_ADDRESS
public <T extends Address> T unwrap(Class<T> type)
unwrap
in interface Address
Address.unwrap(java.lang.Class)
public String firstCalledName()
firstCalledName
in interface Address
public String nextCalledName(CIFSContext tc)
Address
nextCalledName
in interface Address
tc
- context to usepublic boolean isGroupAddress(CIFSContext tc) throws UnknownHostException
NetbiosAddress
isGroupAddress
in interface NetbiosAddress
tc
- context to useUnknownHostException
- if the host cannot be resolved to find out.public int getNodeType(CIFSContext tc) throws UnknownHostException
NetbiosAddress
getNodeType
in interface NetbiosAddress
tc
- context to useB_NODE
,
P_NODE
, M_NODE
,
H_NODE
UnknownHostException
- if the host cannot be resolved to find out.public boolean isBeingDeleted(CIFSContext tc) throws UnknownHostException
NetbiosAddress
isBeingDeleted
in interface NetbiosAddress
tc
- context to useUnknownHostException
- if the host cannot be resolved to find out.public boolean isInConflict(CIFSContext tc) throws UnknownHostException
NetbiosAddress
isInConflict
in interface NetbiosAddress
tc
- context to useUnknownHostException
- if the host cannot be resolved to find out.public boolean isActive(CIFSContext tc) throws UnknownHostException
NetbiosAddress
isActive
in interface NetbiosAddress
tc
- context to useUnknownHostException
- if the host cannot be resolved to find out.public boolean isPermanent(CIFSContext tc) throws UnknownHostException
NetbiosAddress
isPermanent
in interface NetbiosAddress
tc
- context to useUnknownHostException
- if the host cannot be resolved to find out.public byte[] getMacAddress(CIFSContext tc) throws UnknownHostException
NetbiosAddress
getMacAddress
in interface NetbiosAddress
tc
- context to useUnknownHostException
- if the host cannot be resolved to
determine the MAC address.public String getHostName()
getHostName
in interface Address
public NetbiosName getName()
getName
in interface NetbiosAddress
public byte[] getAddress()
public InetAddress getInetAddress() throws UnknownHostException
InetAddress
.InetAddress
representation of this address.UnknownHostException
public InetAddress toInetAddress() throws UnknownHostException
toInetAddress
in interface Address
UnknownHostException
public String getHostAddress()
String
in the form "%d.%d.%d.%d".getHostAddress
in interface Address
public int getNameType()
NetbiosAddress
getNameType
in interface NetbiosAddress
public int hashCode()
public boolean equals(Object obj)
hashCode()
method, the comparison
is based on the integer IP address and not the string representation.Copyright © 2017. All rights reserved.