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.InputStream;
023: import java.io.IOException;
024: import com.knowgate.misc.Gadgets;
025: import com.knowgate.debug.DebugFile;
026:
027: class NetServerEnum2Response extends SmbComTransactionResponse {
028:
029: class ServerInfo1 implements FileEntry {
030: String name;
031: int versionMajor;
032: int versionMinor;
033: int type;
034: String commentOrMasterBrowser;
035:
036: public String getName() {
037: return name;
038: }
039:
040: public int getType() {
041: return (type & 0x80000000) != 0 ? SmbFile.TYPE_WORKGROUP
042: : SmbFile.TYPE_SERVER;
043: }
044:
045: public int getAttributes() {
046: return SmbFile.ATTR_READONLY | SmbFile.ATTR_DIRECTORY;
047: }
048:
049: public long createTime() {
050: return 0L;
051: }
052:
053: public long lastModified() {
054: return 0L;
055: }
056:
057: public long length() {
058: return 0L;
059: }
060:
061: public String toString() {
062: return new String("ServerInfo1[" + "name=" + name
063: + ",versionMajor=" + versionMajor
064: + ",versionMinor=" + versionMinor + ",type=0x"
065: + Gadgets.toHexString(type, 8)
066: + ",commentOrMasterBrowser="
067: + commentOrMasterBrowser + "]");
068: }
069: }
070:
071: private int converter, totalAvailableEntries;
072:
073: String lastName;
074:
075: NetServerEnum2Response() {
076: }
077:
078: int writeSetupWireFormat(byte[] dst, int dstIndex) {
079: return 0;
080: }
081:
082: int writeParametersWireFormat(byte[] dst, int dstIndex) {
083: return 0;
084: }
085:
086: int writeDataWireFormat(byte[] dst, int dstIndex) {
087: return 0;
088: }
089:
090: int readSetupWireFormat(byte[] buffer, int bufferIndex, int len) {
091: return 0;
092: }
093:
094: int readParametersWireFormat(byte[] buffer, int bufferIndex, int len) {
095: int start = bufferIndex;
096:
097: status = readInt2(buffer, bufferIndex);
098: bufferIndex += 2;
099: converter = readInt2(buffer, bufferIndex);
100: bufferIndex += 2;
101: numEntries = readInt2(buffer, bufferIndex);
102: bufferIndex += 2;
103: totalAvailableEntries = readInt2(buffer, bufferIndex);
104: bufferIndex += 2;
105:
106: return bufferIndex - start;
107: }
108:
109: int readDataWireFormat(byte[] buffer, int bufferIndex, int len) {
110: int start = bufferIndex;
111: ServerInfo1 e = null;
112:
113: results = new ServerInfo1[numEntries];
114: for (int i = 0; i < numEntries; i++) {
115: results[i] = e = new ServerInfo1();
116: e.name = readString(buffer, bufferIndex, 16, false);
117: bufferIndex += 16;
118: e.versionMajor = (int) (buffer[bufferIndex++] & 0xFF);
119: e.versionMinor = (int) (buffer[bufferIndex++] & 0xFF);
120: e.type = readInt4(buffer, bufferIndex);
121: bufferIndex += 4;
122: int off = readInt4(buffer, bufferIndex);
123: bufferIndex += 4;
124: off = (off & 0xFFFF) - converter;
125: off = start + off;
126: e.commentOrMasterBrowser = readString(buffer, off, 48,
127: false);
128:
129: }
130: lastName = numEntries == 0 ? null : e.name;
131:
132: return bufferIndex - start;
133: }
134:
135: public String toString() {
136: return new String("NetServerEnum2Response[" + super .toString()
137: + ",status=" + status + ",converter=" + converter
138: + ",entriesReturned=" + numEntries
139: + ",totalAvailableEntries=" + totalAvailableEntries
140: + ",lastName=" + lastName + "]");
141: }
142: }
|