/
SmbComNtTransaction.java
116 lines (99 loc) · 3.9 KB
/
SmbComNtTransaction.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/* jcifs smb client library in Java
* Copyright (C) 2005 "Michael B. Allen" <jcifs at samba dot org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package jcifs.internal.smb1.trans.nt;
import jcifs.Configuration;
import jcifs.internal.CommonServerMessageBlockRequest;
import jcifs.internal.smb1.trans.SmbComTransaction;
import jcifs.internal.util.SMBUtil;
/**
*
*/
public abstract class SmbComNtTransaction extends SmbComTransaction {
// relative to headerStart
private static final int NTT_PRIMARY_SETUP_OFFSET = 71;
private static final int NTT_SECONDARY_PARAMETER_OFFSET = 51;
/**
*
*/
public static final int NT_TRANSACT_QUERY_SECURITY_DESC = 0x6;
/**
*
*/
public static final int NT_TRANSACT_NOTIFY_CHANGE = 0x4;
private final int function;
protected SmbComNtTransaction ( Configuration config, int function ) {
super(config, SMB_COM_NT_TRANSACT, (byte) 0);
this.function = function;
this.primarySetupOffset = NTT_PRIMARY_SETUP_OFFSET;
this.secondaryParameterOffset = NTT_SECONDARY_PARAMETER_OFFSET;
}
/**
*
* @return a cancel request
*/
@Override
public CommonServerMessageBlockRequest createCancel () {
return new SmbComNtCancel(getConfig(), (int) getMid());
}
@Override
protected int writeParameterWordsWireFormat ( byte[] dst, int dstIndex ) {
int start = dstIndex;
if ( this.getCommand() != SMB_COM_NT_TRANSACT_SECONDARY ) {
dst[ dstIndex++ ] = this.maxSetupCount;
}
else {
dst[ dstIndex++ ] = (byte) 0x00; // Reserved
}
dst[ dstIndex++ ] = (byte) 0x00; // Reserved
dst[ dstIndex++ ] = (byte) 0x00; // Reserved
SMBUtil.writeInt4(this.totalParameterCount, dst, dstIndex);
dstIndex += 4;
SMBUtil.writeInt4(this.totalDataCount, dst, dstIndex);
dstIndex += 4;
if ( this.getCommand() != SMB_COM_NT_TRANSACT_SECONDARY ) {
SMBUtil.writeInt4(this.maxParameterCount, dst, dstIndex);
dstIndex += 4;
SMBUtil.writeInt4(this.maxDataCount, dst, dstIndex);
dstIndex += 4;
}
SMBUtil.writeInt4(this.parameterCount, dst, dstIndex);
dstIndex += 4;
SMBUtil.writeInt4( ( this.parameterCount == 0 ? 0 : this.parameterOffset ), dst, dstIndex);
dstIndex += 4;
if ( this.getCommand() == SMB_COM_NT_TRANSACT_SECONDARY ) {
SMBUtil.writeInt4(this.parameterDisplacement, dst, dstIndex);
dstIndex += 4;
}
SMBUtil.writeInt4(this.dataCount, dst, dstIndex);
dstIndex += 4;
SMBUtil.writeInt4( ( this.dataCount == 0 ? 0 : this.dataOffset ), dst, dstIndex);
dstIndex += 4;
if ( this.getCommand() == SMB_COM_NT_TRANSACT_SECONDARY ) {
SMBUtil.writeInt4(this.dataDisplacement, dst, dstIndex);
dstIndex += 4;
dst[ dstIndex++ ] = (byte) 0x00; // Reserved1
}
else {
dst[ dstIndex++ ] = (byte) this.setupCount;
SMBUtil.writeInt2(this.function, dst, dstIndex);
dstIndex += 2;
dstIndex += writeSetupWireFormat(dst, dstIndex);
}
return dstIndex - start;
}
}