1 18 19 package com.knowgate.jcifs.smb; 20 21 import java.io.IOException ; 22 import java.io.InputStream ; 23 import java.io.UnsupportedEncodingException ; 24 25 import com.knowgate.debug.*; 26 27 class SmbComSessionSetupAndXResponse extends AndXServerMessageBlock { 28 29 private String nativeOs = ""; 30 private String nativeLanMan = ""; 31 private String primaryDomain = ""; 32 33 boolean isLoggedInAsGuest; 34 35 SmbComSessionSetupAndXResponse( ServerMessageBlock andx ) { 36 super( andx ); 37 } 38 39 int writeParameterWordsWireFormat( byte[] dst, int dstIndex ) { 40 return 0; 41 } 42 int writeBytesWireFormat( byte[] dst, int dstIndex ) { 43 return 0; 44 } 45 int readParameterWordsWireFormat( byte[] buffer, int bufferIndex ) { 46 isLoggedInAsGuest = ( buffer[bufferIndex] & 0x01 ) == 0x01 ? true : false; 47 return 2; 48 } 49 int readBytesWireFormat( byte[] buffer, int bufferIndex ) { 50 int start = bufferIndex; 51 52 nativeOs = readString( buffer, bufferIndex ); 53 bufferIndex += stringWireLength( nativeOs, bufferIndex ); 54 nativeLanMan = readString( buffer, bufferIndex ); 55 bufferIndex += stringWireLength( nativeLanMan, bufferIndex ); 56 57 if( useUnicode ) { 58 int len; 59 60 if((( bufferIndex - headerStart ) % 2 ) != 0 ) { 61 bufferIndex++; 62 } 63 64 len = 0; 65 while( buffer[bufferIndex + len] != (byte)0x00 ) { 66 len += 2; 67 if( len > 256 ) { 68 throw new RuntimeException ( "zero termination not found" ); 69 } 70 } 71 try { 72 primaryDomain = new String ( buffer, bufferIndex, len, "UnicodeLittle" ); 73 } catch( UnsupportedEncodingException uee ) { 74 if( DebugFile.trace ) 75 new ErrorHandler(uee); 76 } 77 bufferIndex += len; 78 } else { 79 primaryDomain = readString( buffer, bufferIndex ); 80 bufferIndex += stringWireLength( primaryDomain, bufferIndex ); 81 } 82 83 return bufferIndex - start; 84 } 85 int readBytesDirectWireFormat( InputStream in, int byteCount, 86 byte[] buffer, int bufferIndex ) throws IOException { 87 return 0; 88 } 89 public String toString() { 90 String result = new String ( "SmbComSessionSetupAndXResponse[" + 91 super.toString() + 92 ",isLoggedInAsGuest=" + isLoggedInAsGuest + 93 ",nativeOs=" + nativeOs + 94 ",nativeLanMan=" + nativeLanMan + 95 ",primaryDomain=" + primaryDomain + "]" ); 96 return result; 97 } 98 } 99 100 | Popular Tags |