|                                                                                                              1
 18
 19  package 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      static final int SMB_FS_FULL_SIZE_INFORMATION = 1007;
 29
 30      class SmbInfoAllocation implements AllocInfo {
 31          long alloc;                          long free;
 33          int sectPerAlloc;
 34          int bytesPerSect;
 35
 36          public long getCapacity() {
 37              return alloc * sectPerAlloc * bytesPerSect;
 38          }
 39          public long getFree() {
 40              return free * sectPerAlloc * bytesPerSect;
 41          }
 42          public String
  toString() { 43              return new String
  ( "SmbInfoAllocation[" + 44                  "alloc=" + alloc + ",free=" + free +
 45                  ",sectPerAlloc=" + sectPerAlloc +
 46                  ",bytesPerSect=" + bytesPerSect + "]" );
 47          }
 48      }
 49
 50      private int informationLevel;
 51
 52      AllocInfo info;
 53
 54      Trans2QueryFSInformationResponse( int informationLevel ) {
 55          this.informationLevel = informationLevel;
 56          command = SMB_COM_TRANSACTION2;
 57          subCommand = SmbComTransaction.TRANS2_QUERY_FS_INFORMATION;
 58      }
 59
 60      int writeSetupWireFormat( byte[] dst, int dstIndex ) {
 61          return 0;
 62      }
 63      int writeParametersWireFormat( byte[] dst, int dstIndex ) {
 64          return 0;
 65      }
 66      int writeDataWireFormat( byte[] dst, int dstIndex ) {
 67          return 0;
 68      }
 69      int readSetupWireFormat( byte[] buffer, int bufferIndex, int len ) {
 70          return 0;
 71      }
 72      int readParametersWireFormat( byte[] buffer, int bufferIndex, int len ) {
 73          return 0;
 74      }
 75      int readDataWireFormat( byte[] buffer, int bufferIndex, int len ) {
 76          switch( informationLevel ) {
 77              case SMB_INFO_ALLOCATION:
 78                  return readSmbInfoAllocationWireFormat( buffer, bufferIndex );
 79              case SMB_QUERY_FS_SIZE_INFO:
 80                  return readSmbQueryFSSizeInfoWireFormat( buffer, bufferIndex );
 81              case SMB_FS_FULL_SIZE_INFORMATION:
 82                  return readFsFullSizeInformationWireFormat( buffer, bufferIndex );
 83              default:
 84                  return 0;
 85          }
 86      }
 87
 88      int readSmbInfoAllocationWireFormat( byte[] buffer, int bufferIndex ) {
 89          int start = bufferIndex;
 90
 91          SmbInfoAllocation info = new SmbInfoAllocation();
 92
 93          bufferIndex += 4;
 95          info.sectPerAlloc = readInt4( buffer, bufferIndex );
 96          bufferIndex += 4;
 97
 98          info.alloc = readInt4( buffer, bufferIndex );
 99          bufferIndex += 4;
 100
 101         info.free = readInt4( buffer, bufferIndex );
 102         bufferIndex += 4;
 103
 104         info.bytesPerSect = readInt2( buffer, bufferIndex );
 105         bufferIndex += 4;
 106
 107         this.info = info;
 108
 109         return bufferIndex - start;
 110     }
 111     int readSmbQueryFSSizeInfoWireFormat( byte[] buffer, int bufferIndex ) {
 112         int start = bufferIndex;
 113
 114         SmbInfoAllocation info = new SmbInfoAllocation();
 115
 116         info.alloc = readInt8( buffer, bufferIndex );
 117         bufferIndex += 8;
 118
 119         info.free = readInt8( buffer, bufferIndex );
 120         bufferIndex += 8;
 121
 122         info.sectPerAlloc = readInt4( buffer, bufferIndex );
 123         bufferIndex += 4;
 124
 125         info.bytesPerSect = readInt4( buffer, bufferIndex );
 126         bufferIndex += 4;
 127
 128         this.info = info;
 129
 130         return bufferIndex - start;
 131     }
 132     int readFsFullSizeInformationWireFormat( byte[] buffer, int bufferIndex )
 133     {
 134         int start = bufferIndex;
 135
 136         SmbInfoAllocation info = new SmbInfoAllocation();
 137
 138                 info.alloc = readInt8( buffer, bufferIndex );
 140         bufferIndex += 8;
 141
 142                 info.free = readInt8( buffer, bufferIndex );
 144         bufferIndex += 8;
 145
 146                 bufferIndex += 8;
 148
 149         info.sectPerAlloc = readInt4( buffer, bufferIndex );
 150         bufferIndex += 4;
 151
 152         info.bytesPerSect = readInt4( buffer, bufferIndex );
 153         bufferIndex += 4;
 154
 155         this.info = info;
 156
 157         return bufferIndex - start;
 158     }
 159
 160     public String
  toString() { 161         return new String
  ( "Trans2QueryFSInformationResponse[" + 162             super.toString() + "]" );
 163     }
 164 }
 165
                                                                                                                                                                                                             |                                                                       
 
 
 
 
 
                                                                                   Popular Tags                                                                                                                                                                                              |