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 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; why was this here?
044: maxDataCount = 16384;
045: maxSetupCount = (byte) 0x00;
046: setupCount = 0;
047: timeout = 5000;
048: }
049:
050: void reset(int key, String lastName) {
051: super .reset();
052: this .lastName = lastName;
053: }
054:
055: int writeSetupWireFormat(byte[] dst, int dstIndex) {
056: return 0;
057: }
058:
059: int writeParametersWireFormat(byte[] dst, int dstIndex) {
060: int start = dstIndex;
061: byte[] descr;
062: int which = subCommand == NET_SERVER_ENUM2 ? 0 : 1;
063:
064: try {
065: descr = DESCR[which].getBytes("ASCII");
066: } catch (UnsupportedEncodingException uee) {
067: return 0;
068: }
069:
070: writeInt2(subCommand & 0xFF, dst, dstIndex);
071: dstIndex += 2;
072: System.arraycopy(descr, 0, dst, dstIndex, descr.length);
073: dstIndex += descr.length;
074: writeInt2(0x0001, dst, dstIndex);
075: dstIndex += 2;
076: writeInt2(maxDataCount, dst, dstIndex);
077: dstIndex += 2;
078: writeInt4(serverTypes, dst, dstIndex);
079: dstIndex += 4;
080: dstIndex += writeString(domain.toUpperCase(), dst, dstIndex,
081: false);
082: if (which == 1) {
083: dstIndex += writeString(lastName.toUpperCase(), dst,
084: dstIndex, false);
085: }
086:
087: return dstIndex - start;
088: }
089:
090: int writeDataWireFormat(byte[] dst, int dstIndex) {
091: return 0;
092: }
093:
094: int readSetupWireFormat(byte[] buffer, int bufferIndex, int len) {
095: return 0;
096: }
097:
098: int readParametersWireFormat(byte[] buffer, int bufferIndex, int len) {
099: return 0;
100: }
101:
102: int readDataWireFormat(byte[] buffer, int bufferIndex, int len) {
103: return 0;
104: }
105:
106: public String toString() {
107: return new String("NetServerEnum2["
108: + super .toString()
109: + ",name="
110: + name
111: + ",serverTypes="
112: + (serverTypes == SV_TYPE_ALL ? "SV_TYPE_ALL"
113: : "SV_TYPE_DOMAIN_ENUM") + "]");
114: }
115: }
|