KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > knowgate > 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 com.knowgate.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;
46         maxSetupCount = (byte)0x00;
47         setupCount = 0;
48         timeout = 5000;
49     }
50
51     void reset( int key, String JavaDoc lastName ) {
52         super.reset();
53         this.lastName = lastName;
54     }
55
56     int writeSetupWireFormat( byte[] dst, int dstIndex ) {
57         return 0;
58     }
59     int writeParametersWireFormat( byte[] dst, int dstIndex ) {
60         int start = dstIndex;
61         byte[] descr;
62         int which = subCommand == NET_SERVER_ENUM2 ? 0 : 1;
63
64         try {
65             descr = DESCR[which].getBytes( "ASCII" );
66         } catch( UnsupportedEncodingException JavaDoc uee ) {
67             return 0;
68         }
69
70         writeInt2( subCommand & 0xFF, dst, dstIndex );
71         dstIndex += 2;
72         System.arraycopy( descr, 0, dst, dstIndex, descr.length );
73         dstIndex += descr.length;
74         writeInt2( 0x0001, dst, dstIndex );
75         dstIndex += 2;
76         writeInt2( maxDataCount, dst, dstIndex );
77         dstIndex += 2;
78         writeInt4( serverTypes, dst, dstIndex );
79         dstIndex += 4;
80         dstIndex += writeString( domain.toUpperCase(), dst, dstIndex, false );
81         if( which == 1 ) {
82             dstIndex += writeString( lastName.toUpperCase(), dst, dstIndex, false );
83         }
84
85         return dstIndex - start;
86     }
87     int writeDataWireFormat( byte[] dst, int dstIndex ) {
88         return 0;
89     }
90     int readSetupWireFormat( byte[] buffer, int bufferIndex, int len ) {
91         return 0;
92     }
93     int readParametersWireFormat( byte[] buffer, int bufferIndex, int len ) {
94         return 0;
95     }
96     int readDataWireFormat( byte[] buffer, int bufferIndex, int len ) {
97         return 0;
98     }
99     public String JavaDoc toString() {
100         return new String JavaDoc( "NetServerEnum2[" + super.toString() +
101                 ",name=" + name +
102                 ",serverTypes=" + (serverTypes == SV_TYPE_ALL ?
103                         "SV_TYPE_ALL" : "SV_TYPE_DOMAIN_ENUM" ) +
104                 "]" );
105     }
106 }
107
Popular Tags