1 18 19 package com.knowgate.jcifs.smb; 20 21 import java.io.UnsupportedEncodingException ; 22 23 class Trans2QueryFSInformationResponse extends SmbComTransactionResponse { 24 25 static final int SMB_INFO_ALLOCATION = 1; 27 static final int SMB_QUERY_FS_SIZE_INFO = 0x103; 28 29 class SmbInfoAllocation implements AllocInfo { 30 long alloc; long free; 32 int sectPerAlloc; 33 int bytesPerSect; 34 35 public long getCapacity() { 36 return alloc * sectPerAlloc * bytesPerSect; 37 } 38 public long getFree() { 39 return free * sectPerAlloc * bytesPerSect; 40 } 41 public String toString() { 42 return new String ( "SmbInfoAllocation[" + 43 "alloc=" + alloc + ",free=" + free + 44 ",sectPerAlloc=" + sectPerAlloc + 45 ",bytesPerSect=" + bytesPerSect + "]" ); 46 } 47 } 48 49 private int informationLevel; 50 51 AllocInfo info; 52 53 Trans2QueryFSInformationResponse( int informationLevel ) { 54 this.informationLevel = informationLevel; 55 command = SMB_COM_TRANSACTION2; 56 subCommand = SmbComTransaction.TRANS2_QUERY_FS_INFORMATION; 57 } 58 59 int writeSetupWireFormat( byte[] dst, int dstIndex ) { 60 return 0; 61 } 62 int writeParametersWireFormat( byte[] dst, int dstIndex ) { 63 return 0; 64 } 65 int writeDataWireFormat( byte[] dst, int dstIndex ) { 66 return 0; 67 } 68 int readSetupWireFormat( byte[] buffer, int bufferIndex, int len ) { 69 return 0; 70 } 71 int readParametersWireFormat( byte[] buffer, int bufferIndex, int len ) { 72 return 0; 73 } 74 int readDataWireFormat( byte[] buffer, int bufferIndex, int len ) { 75 switch( informationLevel ) { 76 case SMB_INFO_ALLOCATION: 77 return readSmbInfoAllocationWireFormat( buffer, bufferIndex ); 78 case SMB_QUERY_FS_SIZE_INFO: 79 return readSmbQueryFSSizeInfoWireFormat( buffer, bufferIndex ); 80 default: 81 return 0; 82 } 83 } 84 85 int readSmbInfoAllocationWireFormat( byte[] buffer, int bufferIndex ) { 86 int start = bufferIndex; 87 88 SmbInfoAllocation info = new SmbInfoAllocation(); 89 90 bufferIndex += 4; 92 info.sectPerAlloc = readInt4( buffer, bufferIndex ); 93 bufferIndex += 4; 94 95 info.alloc = readInt4( buffer, bufferIndex ); 96 bufferIndex += 4; 97 98 info.free = readInt4( buffer, bufferIndex ); 99 bufferIndex += 4; 100 101 info.bytesPerSect = readInt2( buffer, bufferIndex ); 102 bufferIndex += 4; 103 104 this.info = info; 105 106 return bufferIndex - start; 107 } 108 int readSmbQueryFSSizeInfoWireFormat( byte[] buffer, int bufferIndex ) { 109 int start = bufferIndex; 110 111 SmbInfoAllocation info = new SmbInfoAllocation(); 112 113 info.alloc = readInt4( buffer, bufferIndex ); 114 bufferIndex += 4; 115 info.alloc |= readInt4( buffer, bufferIndex ) << 32L; 116 bufferIndex += 4; 117 118 info.free = readInt4( buffer, bufferIndex ); 119 bufferIndex += 4; 120 info.free |= readInt4( buffer, bufferIndex ) << 32L; 121 bufferIndex += 4; 122 123 info.sectPerAlloc = readInt4( buffer, bufferIndex ); 124 bufferIndex += 4; 125 126 info.bytesPerSect = readInt4( buffer, bufferIndex ); 127 bufferIndex += 4; 128 129 this.info = info; 130 131 return bufferIndex - start; 132 } 133 public String toString() { 134 return new String ( "Trans2QueryFSInformationResponse[" + 135 super.toString() + "]" ); 136 } 137 } 138 | Popular Tags |