|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.gnu.jcifs.NBTNameService
NB Name Service (WINS)
Constructor Summary | |
NBTNameService()
|
Method Summary | |
static java.lang.String |
buildFirstLevelEncodedName(java.lang.String name)
Build first level representation of the name (RFC1001, Chapter 14.1: |
static byte[] |
buildSecondLevelEncodedName(java.lang.String plainname)
Build second level representation of the name. |
java.net.InetAddress |
lookup(java.net.InetAddress winsaddr,
java.lang.String netbiosname)
|
static int |
parseSecondLevelEncodedName(byte[] buf,
int off,
java.lang.StringBuffer name)
|
Methods inherited from class java.lang.Object |
|
Constructor Detail |
public NBTNameService() throws java.io.IOException
Method Detail |
public java.net.InetAddress lookup(java.net.InetAddress winsaddr, java.lang.String netbiosname)
public static java.lang.String buildFirstLevelEncodedName(java.lang.String name)
The 16 byte NetBIOS name is mapped into a 32 byte wide field using a reversible, half-ASCII, biased encoding. Each half-octet of the NetBIOS name is encoded into one byte of the 32 byte field. The first half octet is encoded into the first byte, the second half- octet into the second byte, etc.
Each 4-bit, half-octet of the NetBIOS name is treated as an 8-bit, right-adjusted, zero-filled binary number. This number is added to value of the ASCII character 'A' (hexidecimal 41). The resulting 8- bit number is stored in the appropriate byte. The following diagram demonstrates this procedure:
0 1 2 3 4 5 6 7 +-+-+-+-+-+-+-+-+ |a b c d|w x y z| ORIGINAL BYTE +-+-+-+-+-+-+-+-+ | | +--------+ +--------+ | | SPLIT THE NIBBLES v v 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+ |0 0 0 0 a b c d| |0 0 0 0 w x y z| +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+ | | + + ADD 'A' | | 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+ |0 1 0 0 0 0 0 1| |0 1 0 0 0 0 0 1| +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+This encoding results in a NetBIOS name being represented as a sequence of 32 ASCII, upper-case characters from the set {A,B,C...N,O,P}.
The NetBIOS scope identifier is a valid domain name (without a leading dot).
An ASCII dot (2E hexidecimal) and the scope identifier are appended to the encoded form of the NetBIOS name, the result forming a valid domain name.
For example, the NetBIOS name "The NetBIOS name" in the NetBIOS scope "SCOPE.ID.COM" would be represented at level one by the ASCII character string: FEGHGFCAEOGFHEECEJEPFDCAHEGBGNGF.SCOPE.ID.COM
public static byte[] buildSecondLevelEncodedName(java.lang.String plainname)
For ease of description, the first two paragraphs from page 31, the section titled "Domain name representation and compression", of RFC 883 are replicated here:
Domain names messages are expressed in terms of a sequence of labels. Each label is represented as a one octet length field followed by that number of octets. Since every domain name ends with the null label of the root, a compressed domain name is terminated by a length byte of zero. The high order two bits of the length field must be zero, and the remaining six bits of the length field limit the label to 63 octets or less.
To simplify implementations, the total length of label octets and label length octets that make up a domain name is restricted to 255 octets or less.
plainname
- name (not encoded)
|len| name |00|public static int parseSecondLevelEncodedName(byte[] buf, int off, java.lang.StringBuffer name)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |