KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jcifs > smb > SmbComNtTransaction


1 /* jcifs smb client library in Java
2  * Copyright (C) 2005 "Michael B. Allen" <jcifs at samba dot org>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */

18
19 package jcifs.smb;
20
21 abstract class SmbComNtTransaction extends SmbComTransaction {
22
23     // relative to headerStart
24
private static final int NTT_PRIMARY_SETUP_OFFSET = 69;
25     private static final int NTT_SECONDARY_PARAMETER_OFFSET = 51;
26
27     static final int NT_TRANSACT_QUERY_SECURITY_DESC = 6;
28
29     int function;
30
31     SmbComNtTransaction() {
32         super();
33         primarySetupOffset = NTT_PRIMARY_SETUP_OFFSET;
34         secondaryParameterOffset = NTT_SECONDARY_PARAMETER_OFFSET;
35     }
36
37     int writeParameterWordsWireFormat( byte[] dst, int dstIndex ) {
38         int start = dstIndex;
39
40         if (command != SMB_COM_NT_TRANSACT_SECONDARY) {
41             dst[dstIndex++] = maxSetupCount;
42         } else {
43             dst[dstIndex++] = (byte)0x00; // Reserved
44
}
45         dst[dstIndex++] = (byte)0x00; // Reserved
46
dst[dstIndex++] = (byte)0x00; // Reserved
47
writeInt4( totalParameterCount, dst, dstIndex );
48         dstIndex += 4;
49         writeInt4( totalDataCount, dst, dstIndex );
50         dstIndex += 4;
51         if (command != SMB_COM_NT_TRANSACT_SECONDARY) {
52             writeInt4( maxParameterCount, dst, dstIndex );
53             dstIndex += 4;
54             writeInt4( maxDataCount, dst, dstIndex );
55             dstIndex += 4;
56         }
57         writeInt4( parameterCount, dst, dstIndex );
58         dstIndex += 4;
59         writeInt4(( parameterCount == 0 ? 0 : parameterOffset ), dst, dstIndex );
60         dstIndex += 4;
61         if (command == SMB_COM_NT_TRANSACT_SECONDARY) {
62             writeInt4( parameterDisplacement, dst, dstIndex );
63             dstIndex += 4;
64         }
65         writeInt4( dataCount, dst, dstIndex );
66         dstIndex += 4;
67         writeInt4(( dataCount == 0 ? 0 : dataOffset ), dst, dstIndex );
68         dstIndex += 4;
69         if (command == SMB_COM_NT_TRANSACT_SECONDARY) {
70             writeInt4( dataDisplacement, dst, dstIndex );
71             dstIndex += 4;
72             dst[dstIndex++] = (byte)0x00; // Reserved1
73
} else {
74             dst[dstIndex++] = (byte)setupCount;
75             writeInt2( function, dst, dstIndex );
76             dstIndex += 2;
77             dstIndex += writeSetupWireFormat( dst, dstIndex );
78         }
79
80         return dstIndex - start;
81     }
82 }
83
Popular Tags