1 18 19 package com.knowgate.jcifs.smb; 20 21 import java.io.InputStream ; 22 import java.io.IOException ; 23 import com.knowgate.misc.Gadgets; 24 import com.knowgate.debug.*; 25 26 class NetShareEnumResponse extends SmbComTransactionResponse { 27 28 class ShareInfo1 implements FileEntry { 29 String netName; 30 int type; 31 String remark; 32 33 public String getName() { 34 return netName; 35 } 36 public int getType() { 37 switch( type ) { 38 case 1: 39 return SmbFile.TYPE_PRINTER; 40 case 3: 41 return SmbFile.TYPE_NAMED_PIPE; 42 } 43 return SmbFile.TYPE_SHARE; 44 } 45 public int getAttributes() { 46 return SmbFile.ATTR_READONLY | SmbFile.ATTR_DIRECTORY; 47 } 48 public long createTime() { 49 return 0L; 50 } 51 public long lastModified() { 52 return 0L; 53 } 54 public long length() { 55 return 0L; 56 } 57 58 public String toString() { 59 return new String ( "ShareInfo1[" + 60 "netName=" + netName + 61 ",type=0x" + Gadgets.toHexString( type, 4 ) + 62 ",remark=" + remark + "]" ); 63 } 64 } 65 66 private int converter, totalAvailableEntries; 67 68 NetShareEnumResponse() { 69 } 70 71 int writeSetupWireFormat( byte[] dst, int dstIndex ) { 72 return 0; 73 } 74 int writeParametersWireFormat( byte[] dst, int dstIndex ) { 75 return 0; 76 } 77 int writeDataWireFormat( byte[] dst, int dstIndex ) { 78 return 0; 79 } 80 int readSetupWireFormat( byte[] buffer, int bufferIndex, int len ) { 81 return 0; 82 } 83 int readParametersWireFormat( byte[] buffer, int bufferIndex, int len ) { 84 int start = bufferIndex; 85 86 status = readInt2( buffer, bufferIndex ); 87 bufferIndex += 2; 88 converter = readInt2( buffer, bufferIndex ); 89 bufferIndex += 2; 90 numEntries = readInt2( buffer, bufferIndex ); 91 bufferIndex += 2; 92 totalAvailableEntries = readInt2( buffer, bufferIndex ); 93 bufferIndex += 2; 94 95 return bufferIndex - start; 96 } 97 int readDataWireFormat( byte[] buffer, int bufferIndex, int len ) { 98 int start = bufferIndex; 99 ShareInfo1 e; 100 101 useUnicode = false; 102 103 results = new ShareInfo1[numEntries]; 104 for( int i = 0; i < numEntries; i++ ) { 105 results[i] = e = new ShareInfo1(); 106 e.netName = readString( buffer, bufferIndex, 13, false ); 107 bufferIndex += 14; 108 e.type = readInt2( buffer, bufferIndex ); 109 bufferIndex += 2; 110 int off = readInt4( buffer, bufferIndex ); 111 bufferIndex += 4; 112 off = ( off & 0xFFFF ) - converter; 113 off = start + off; 114 e.remark = readString( buffer, off, 128, false ); 115 116 } 117 118 return bufferIndex - start; 119 } 120 public String toString() { 121 return new String ( "NetShareEnumResponse[" + 122 super.toString() + 123 ",status=" + status + 124 ",converter=" + converter + 125 ",entriesReturned=" + numEntries + 126 ",totalAvailableEntries=" + totalAvailableEntries + "]" ); 127 } 128 } 129 | Popular Tags |