1 18 19 package jcifs.smb; 20 21 import jcifs.Config; 22 23 class SmbComWriteAndX extends AndXServerMessageBlock { 24 25 private static final int READ_ANDX_BATCH_LIMIT = 26 Config.getInt( "jcifs.smb.client.WriteAndX.ReadAndX", 1 ); 27 private static final int CLOSE_BATCH_LIMIT = 28 Config.getInt( "jcifs.smb.client.WriteAndX.Close", 1 ); 29 30 private int fid, 31 writeMode, 32 remaining, 33 dataLength, 34 dataOffset, 35 off; 36 private byte[] b; 37 private long offset; 38 39 SmbComWriteAndX() { 40 super( null ); 41 command = SMB_COM_WRITE_ANDX; 42 } 43 SmbComWriteAndX( int fid, long offset, int remaining, 44 byte[] b, int off, int len, ServerMessageBlock andx ) { 45 super( andx ); 46 this.fid = fid; 47 this.offset = offset; 48 this.remaining = remaining; 49 this.b = b; 50 this.off = off; 51 dataLength = len; 52 command = SMB_COM_WRITE_ANDX; 53 } 54 55 void setParam( int fid, long offset, int remaining, 56 byte[] b, int off, int len ) { 57 this.fid = fid; 58 this.offset = offset; 59 this.remaining = remaining; 60 this.b = b; 61 this.off = off; 62 dataLength = len; 63 digest = null; 66 } 67 int getBatchLimit( byte command ) { 68 if( command == SMB_COM_READ_ANDX ) { 69 return READ_ANDX_BATCH_LIMIT; 70 } 71 if( command == SMB_COM_CLOSE ) { 72 return CLOSE_BATCH_LIMIT; 73 } 74 return 0; 75 } 76 int writeParameterWordsWireFormat( byte[] dst, int dstIndex ) { 77 int start = dstIndex; 78 79 dataOffset = (dstIndex - headerStart) + 26; 85 86 writeInt2( fid, dst, dstIndex ); 87 dstIndex += 2; 88 writeInt4( offset, dst, dstIndex ); 89 dstIndex += 4; 90 for( int i = 0; i < 4; i++ ) { 91 dst[dstIndex++] = (byte)0x00; 92 } 93 writeInt2( writeMode, dst, dstIndex ); 94 dstIndex += 2; 95 writeInt2( remaining, dst, dstIndex ); 96 dstIndex += 2; 97 dst[dstIndex++] = (byte)0x00; 98 dst[dstIndex++] = (byte)0x00; 99 writeInt2( dataLength, dst, dstIndex ); 100 dstIndex += 2; 101 writeInt2( dataOffset, dst, dstIndex ); 102 dstIndex += 2; 103 writeInt4( offset >> 32, dst, dstIndex ); 104 dstIndex += 4; 105 106 return dstIndex - start; 107 } 108 int writeBytesWireFormat( byte[] dst, int dstIndex ) { 109 int start = dstIndex; 110 111 116 System.arraycopy( b, off, dst, dstIndex, dataLength ); 117 dstIndex += dataLength; 118 119 return dstIndex - start; 120 } 121 int readParameterWordsWireFormat( byte[] buffer, int bufferIndex ) { 122 return 0; 123 } 124 int readBytesWireFormat( byte[] buffer, int bufferIndex ) { 125 return 0; 126 } 127 public String toString() { 128 return new String ( "SmbComWriteAndX[" + 129 super.toString() + 130 ",fid=" + fid + 131 ",offset=" + offset + 132 ",writeMode=" + writeMode + 133 ",remaining=" + remaining + 134 ",dataLength=" + dataLength + 135 ",dataOffset=" + dataOffset + "]" ); 136 } 137 } 138 | Popular Tags |