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