001: /* jcifs smb client library in Java
002: * Copyright (C) 2000 "Michael B. Allen" <jcifs at samba dot org>
003: * Gary Rambo <grambo aventail.com>
004: *
005: * This library is free software; you can redistribute it and/or
006: * modify it under the terms of the GNU Lesser General Public
007: * License as published by the Free Software Foundation; either
008: * version 2.1 of the License, or (at your option) any later version.
009: *
010: * This library is distributed in the hope that it will be useful,
011: * but WITHOUT ANY WARRANTY; without even the implied warranty of
012: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013: * Lesser General Public License for more details.
014: *
015: * You should have received a copy of the GNU Lesser General Public
016: * License along with this library; if not, write to the Free Software
017: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
018: */
019:
020: package com.knowgate.jcifs.smb;
021:
022: import java.io.UnsupportedEncodingException;
023:
024: class NetServerEnum2 extends SmbComTransaction {
025:
026: static final int SV_TYPE_ALL = 0xFFFFFFFF;
027: static final int SV_TYPE_DOMAIN_ENUM = 0x80000000;
028:
029: static final String[] DESCR = { "WrLehDz\u0000B16BBDz\u0000",
030: "WrLehDzz\u0000B16BBDz\u0000" };
031:
032: String domain, lastName = null;
033: int serverTypes;
034:
035: NetServerEnum2(String domain, int serverTypes) {
036: this .domain = domain;
037: this .serverTypes = serverTypes;
038: command = SMB_COM_TRANSACTION;
039: subCommand = NET_SERVER_ENUM2; // not really true be used by upper logic
040: name = "\\PIPE\\LANMAN";
041:
042: maxParameterCount = 8;
043: maxDataCount = 4096;
044: maxSetupCount = (byte) 0x00;
045: setupCount = 0;
046: timeout = 5000;
047: }
048:
049: void reset(int key, String lastName) {
050: super .reset();
051: this .lastName = lastName;
052: }
053:
054: int writeSetupWireFormat(byte[] dst, int dstIndex) {
055: return 0;
056: }
057:
058: int writeParametersWireFormat(byte[] dst, int dstIndex) {
059: int start = dstIndex;
060: byte[] descr;
061: int which = subCommand == NET_SERVER_ENUM2 ? 0 : 1;
062:
063: try {
064: descr = DESCR[which].getBytes("ASCII");
065: } catch (UnsupportedEncodingException uee) {
066: return 0;
067: }
068:
069: writeInt2(subCommand & 0xFF, dst, dstIndex);
070: dstIndex += 2;
071: System.arraycopy(descr, 0, dst, dstIndex, descr.length);
072: dstIndex += descr.length;
073: writeInt2(0x0001, dst, dstIndex);
074: dstIndex += 2;
075: writeInt2(maxDataCount, dst, dstIndex);
076: dstIndex += 2;
077: writeInt4(serverTypes, dst, dstIndex);
078: dstIndex += 4;
079: dstIndex += writeString(domain.toUpperCase(), dst, dstIndex,
080: false);
081: if (which == 1) {
082: dstIndex += writeString(lastName.toUpperCase(), dst,
083: dstIndex, false);
084: }
085:
086: return dstIndex - start;
087: }
088:
089: int writeDataWireFormat(byte[] dst, int dstIndex) {
090: return 0;
091: }
092:
093: int readSetupWireFormat(byte[] buffer, int bufferIndex, int len) {
094: return 0;
095: }
096:
097: int readParametersWireFormat(byte[] buffer, int bufferIndex, int len) {
098: return 0;
099: }
100:
101: int readDataWireFormat(byte[] buffer, int bufferIndex, int len) {
102: return 0;
103: }
104:
105: public String toString() {
106: return new String("NetServerEnum2["
107: + super .toString()
108: + ",name="
109: + name
110: + ",serverTypes="
111: + (serverTypes == SV_TYPE_ALL ? "SV_TYPE_ALL"
112: : "SV_TYPE_DOMAIN_ENUM") + "]");
113: }
114: }
|