1 18 19 package jcifs.netbios; 20 21 import java.io.UnsupportedEncodingException ; 22 23 class NodeStatusResponse extends NameServicePacket { 24 25 private NbtAddress queryAddress; 26 27 private int numberOfNames; 28 private byte[] macAddress; 29 private byte[] stats; 30 31 NbtAddress[] addressArray; 32 33 40 41 NodeStatusResponse( NbtAddress queryAddress ) { 42 this.queryAddress = queryAddress; 43 recordName = new Name(); 44 macAddress = new byte[6]; 45 } 46 47 int writeBodyWireFormat( byte[] dst, int dstIndex ) { 48 return 0; 49 } 50 int readBodyWireFormat( byte[] src, int srcIndex ) { 51 return readResourceRecordWireFormat( src, srcIndex ); 52 } 53 int writeRDataWireFormat( byte[] dst, int dstIndex ) { 54 return 0; 55 } 56 int readRDataWireFormat( byte[] src, int srcIndex ) { 57 int start = srcIndex; 58 numberOfNames = src[srcIndex] & 0xFF; 59 int namesLength = numberOfNames * 18; 60 int statsLength = rDataLength - namesLength - 1; 61 numberOfNames = src[srcIndex++] & 0xFF; 62 System.arraycopy( src, srcIndex + namesLength, macAddress, 0, 6 ); 64 srcIndex += readNodeNameArray( src, srcIndex ); 65 stats = new byte[statsLength]; 66 System.arraycopy( src, srcIndex, stats, 0, statsLength ); 67 srcIndex += statsLength; 68 return srcIndex - start; 69 } 70 private int readNodeNameArray( byte[] src, int srcIndex ) { 71 int start = srcIndex; 72 73 addressArray = new NbtAddress[numberOfNames]; 74 75 String n; 76 int hexCode; 77 String scope = queryAddress.hostName.scope; 78 boolean groupName; 79 int ownerNodeType; 80 boolean isBeingDeleted; 81 boolean isInConflict; 82 boolean isActive; 83 boolean isPermanent; 84 int j; 85 boolean addrFound = false; 86 87 try { 88 for( int i = 0; i < numberOfNames; srcIndex += 18, i++ ) { 89 for( j = srcIndex + 14; src[j] == 0x20; j-- ) 90 ; 91 n = new String ( src, srcIndex, j - srcIndex + 1, Name.OEM_ENCODING ); 92 hexCode = src[srcIndex + 15] & 0xFF; 93 groupName = (( src[srcIndex + 16] & 0x80 ) == 0x80 ) ? true : false; 94 ownerNodeType = ( src[srcIndex + 16] & 0x60 ) >> 5; 95 isBeingDeleted = (( src[srcIndex + 16] & 0x10 ) == 0x10 ) ? true : false; 96 isInConflict = (( src[srcIndex + 16] & 0x08 ) == 0x08 ) ? true : false; 97 isActive = (( src[srcIndex + 16] & 0x04 ) == 0x04 ) ? true : false; 98 isPermanent = (( src[srcIndex + 16] & 0x02 ) == 0x02 ) ? true : false; 99 100 106 if( !addrFound && queryAddress.hostName.hexCode == hexCode && 107 ( queryAddress.hostName == NbtAddress.UNKNOWN_NAME || 108 queryAddress.hostName.name.equals( n ))) { 109 110 if( queryAddress.hostName == NbtAddress.UNKNOWN_NAME ) { 111 queryAddress.hostName = new Name( n, hexCode, scope ); 112 } 113 queryAddress.groupName = groupName; 114 queryAddress.nodeType = ownerNodeType; 115 queryAddress.isBeingDeleted = isBeingDeleted; 116 queryAddress.isInConflict = isInConflict; 117 queryAddress.isActive = isActive; 118 queryAddress.isPermanent = isPermanent; 119 queryAddress.macAddress = macAddress; 120 queryAddress.isDataFromNodeStatus = true; 121 addrFound = true; 122 addressArray[i] = queryAddress; 123 } else { 124 addressArray[i] = new NbtAddress( new Name( n, hexCode, scope ), 125 queryAddress.address, 126 groupName, 127 ownerNodeType, 128 isBeingDeleted, 129 isInConflict, 130 isActive, 131 isPermanent, 132 macAddress ); 133 } 134 } 135 } catch( UnsupportedEncodingException uee ) { 136 } 137 return srcIndex - start; 138 } 139 public String toString() { 140 return new String ( "NodeStatusResponse[" + 141 super.toString() + "]" ); 142 } 143 } 144 145 | Popular Tags |