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