-
Notifications
You must be signed in to change notification settings - Fork 51
/
NetbiosAddress.java
192 lines (170 loc) · 6.04 KB
/
NetbiosAddress.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
/*
* © 2017 AgNO3 Gmbh & Co. KG
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package jcifs;
import java.net.UnknownHostException;
/**
* 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.
*
* <p>
* Applications can use the methods <code>getLocalHost</code>,
* <code>getByName</code>, and
* <code>getAllByAddress</code> to create a new NbtAddress instance. This
* class is symmetric with {@link java.net.InetAddress}.
*
* <p>
* <b>About NetBIOS:</b> 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.
* <p>
* <blockquote>
*
* <pre>
* 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
* </pre>
*
* </blockquote>
* <p>
* The hostname of this machine is <code>JMORRIS2</code>. It is
* a member of the group(a.k.a workgroup and domain) <code>BILLING-NY</code>. To
* obtain an {@link java.net.InetAddress} for a host one might do:
*
* <pre>
*
* InetAddress addr = NbtAddress.getByName("jmorris2").getInetAddress();
* </pre>
* <p>
* From a UNIX platform with Samba installed you can perform similar
* diagnostics using the <code>nmblookup</code> utility.
*
* @author Michael B. Allen
* @see java.net.InetAddress
* @since jcifs-0.1
*/
public interface NetbiosAddress extends Address {
/**
* Determines if the address is a group address. This is also
* known as a workgroup name or group name.
*
* @param tc
* context to use
* @return whether the given address is a group address
*
* @throws UnknownHostException
* if the host cannot be resolved to find out.
*/
boolean isGroupAddress ( CIFSContext tc ) throws UnknownHostException;
/**
* Checks the node type of this address.
*
* @param tc
* context to use
* @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.
*/
int getNodeType ( CIFSContext tc ) throws UnknownHostException;
/**
* Determines if this address in the process of being deleted.
*
* @param tc
* context to use
* @return whether this address is in the process of being deleted
*
* @throws UnknownHostException
* if the host cannot be resolved to find out.
*/
boolean isBeingDeleted ( CIFSContext tc ) throws UnknownHostException;
/**
* Determines if this address in conflict with another address.
*
* @param tc
* context to use
* @return whether this address is in conflict with another address
* @throws UnknownHostException
* if the host cannot be resolved to find out.
*/
boolean isInConflict ( CIFSContext tc ) throws UnknownHostException;
/**
* Determines if this address is active.
*
* @param tc
* context to use
* @return whether this address is active
*
* @throws UnknownHostException
* if the host cannot be resolved to find out.
*/
boolean isActive ( CIFSContext tc ) throws UnknownHostException;
/**
* Determines if this address is set to be permanent.
*
* @param tc
* context to use
* @return whether this address is permanent
*
* @throws UnknownHostException
* if the host cannot be resolved to find out.
*/
boolean isPermanent ( CIFSContext tc ) throws UnknownHostException;
/**
* Retrieves the MAC address of the remote network interface. Samba returns all zeros.
*
* @param tc
* context to use
*
* @return the MAC address as an array of six bytes
* @throws UnknownHostException
* if the host cannot be resolved to
* determine the MAC address.
*/
byte[] getMacAddress ( CIFSContext tc ) throws UnknownHostException;
/**
* Returned the hex code associated with this name(e.g. 0x20 is for the file service)
*
* @return the name type
*/
int getNameType ();
/**
* @return the name for this address
*/
NetbiosName getName ();
}