001: /* jcifs smb client library in Java
002: * Copyright (C) 2000 "Michael B. Allen" <jcifs at samba dot org>
003: *
004: * This library is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License as published by the Free Software Foundation; either
007: * version 2.1 of the License, or (at your option) any later version.
008: *
009: * This library is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: * Lesser General Public License for more details.
013: *
014: * You should have received a copy of the GNU Lesser General Public
015: * License along with this library; if not, write to the Free Software
016: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017: */
018:
019: package com.knowgate.jcifs.smb;
020:
021: import java.io.IOException;
022: import java.io.InputStream;
023: import java.io.UnsupportedEncodingException;
024:
025: import com.knowgate.debug.*;
026:
027: class SmbComSessionSetupAndXResponse extends AndXServerMessageBlock {
028:
029: private String nativeOs = "";
030: private String nativeLanMan = "";
031: private String primaryDomain = "";
032:
033: boolean isLoggedInAsGuest;
034:
035: SmbComSessionSetupAndXResponse(ServerMessageBlock andx) {
036: super (andx);
037: }
038:
039: int writeParameterWordsWireFormat(byte[] dst, int dstIndex) {
040: return 0;
041: }
042:
043: int writeBytesWireFormat(byte[] dst, int dstIndex) {
044: return 0;
045: }
046:
047: int readParameterWordsWireFormat(byte[] buffer, int bufferIndex) {
048: isLoggedInAsGuest = (buffer[bufferIndex] & 0x01) == 0x01 ? true
049: : false;
050: return 2;
051: }
052:
053: int readBytesWireFormat(byte[] buffer, int bufferIndex) {
054: int start = bufferIndex;
055:
056: nativeOs = readString(buffer, bufferIndex);
057: bufferIndex += stringWireLength(nativeOs, bufferIndex);
058: nativeLanMan = readString(buffer, bufferIndex);
059: bufferIndex += stringWireLength(nativeLanMan, bufferIndex);
060:
061: if (useUnicode) {
062: int len;
063:
064: if (((bufferIndex - headerStart) % 2) != 0) {
065: bufferIndex++;
066: }
067:
068: len = 0;
069: while (buffer[bufferIndex + len] != (byte) 0x00) {
070: len += 2;
071: if (len > 256) {
072: throw new RuntimeException(
073: "zero termination not found");
074: }
075: }
076: try {
077: primaryDomain = new String(buffer, bufferIndex, len,
078: "UnicodeLittle");
079: } catch (UnsupportedEncodingException uee) {
080: if (DebugFile.trace)
081: new ErrorHandler(uee);
082: }
083: bufferIndex += len;
084: } else {
085: primaryDomain = readString(buffer, bufferIndex);
086: bufferIndex += stringWireLength(primaryDomain, bufferIndex);
087: }
088:
089: return bufferIndex - start;
090: }
091:
092: int readBytesDirectWireFormat(InputStream in, int byteCount,
093: byte[] buffer, int bufferIndex) throws IOException {
094: return 0;
095: }
096:
097: public String toString() {
098: String result = new String("SmbComSessionSetupAndXResponse["
099: + super .toString() + ",isLoggedInAsGuest="
100: + isLoggedInAsGuest + ",nativeOs=" + nativeOs
101: + ",nativeLanMan=" + nativeLanMan + ",primaryDomain="
102: + primaryDomain + "]");
103: return result;
104: }
105: }
|