KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jcifs > smb > NetServerEnum2


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

19
20 package jcifs.smb;
21
22 import java.io.UnsupportedEncodingException JavaDoc;
23
24 class NetServerEnum2 extends SmbComTransaction {
25
26     static final int SV_TYPE_ALL = 0xFFFFFFFF;
27     static final int SV_TYPE_DOMAIN_ENUM = 0x80000000;
28
29     static final String JavaDoc[] DESCR = {
30         "WrLehDz\u0000B16BBDz\u0000",
31         "WrLehDzz\u0000B16BBDz\u0000"
32     };
33
34     String JavaDoc domain, lastName = null;
35     int serverTypes;
36
37     NetServerEnum2( String JavaDoc domain, int serverTypes ) {
38         this.domain = domain;
39         this.serverTypes = serverTypes;
40         command = SMB_COM_TRANSACTION;
41         subCommand = NET_SERVER_ENUM2; // not really true be used by upper logic
42
name = "\\PIPE\\LANMAN";
43
44         maxParameterCount = 8;
45 // maxDataCount = 4096; why was this here?
46
maxDataCount = 16384;
47         maxSetupCount = (byte)0x00;
48         setupCount = 0;
49         timeout = 5000;
50     }
51
52     void reset( int key, String JavaDoc lastName ) {
53         super.reset();
54         this.lastName = lastName;
55     }
56
57     int writeSetupWireFormat( byte[] dst, int dstIndex ) {
58         return 0;
59     }
60     int writeParametersWireFormat( byte[] dst, int dstIndex ) {
61         int start = dstIndex;
62         byte[] descr;
63         int which = subCommand == NET_SERVER_ENUM2 ? 0 : 1;
64
65         try {
66             descr = DESCR[which].getBytes( "ASCII" );
67         } catch( UnsupportedEncodingException JavaDoc uee ) {
68             return 0;
69         }
70
71         writeInt2( subCommand & 0xFF, dst, dstIndex );
72         dstIndex += 2;
73         System.arraycopy( descr, 0, dst, dstIndex, descr.length );
74         dstIndex += descr.length;
75         writeInt2( 0x0001, dst, dstIndex );
76         dstIndex += 2;
77         writeInt2( maxDataCount, dst, dstIndex );
78         dstIndex += 2;
79         writeInt4( serverTypes, dst, dstIndex );
80         dstIndex += 4;
81         dstIndex += writeString( domain.toUpperCase(), dst, dstIndex, false );
82         if( which == 1 ) {
83             dstIndex += writeString( lastName.toUpperCase(), dst, dstIndex, false );
84         }
85
86         return dstIndex - start;
87     }
88     int writeDataWireFormat( byte[] dst, int dstIndex ) {
89         return 0;
90     }
91     int readSetupWireFormat( byte[] buffer, int bufferIndex, int len ) {
92         return 0;
93     }
94     int readParametersWireFormat( byte[] buffer, int bufferIndex, int len ) {
95         return 0;
96     }
97     int readDataWireFormat( byte[] buffer, int bufferIndex, int len ) {
98         return 0;
99     }
100     public String JavaDoc toString() {
101         return new String JavaDoc( "NetServerEnum2[" + super.toString() +
102                 ",name=" + name +
103                 ",serverTypes=" + (serverTypes == SV_TYPE_ALL ?
104                         "SV_TYPE_ALL" : "SV_TYPE_DOMAIN_ENUM" ) +
105                 "]" );
106     }
107 }
108
Popular Tags