1 18 19 package jcifs.smb; 20 21 import java.util.Date ; 22 23 class Trans2GetDfsReferralResponse extends SmbComTransactionResponse { 24 25 class Referral { 26 private int version; 27 private int size; 28 private int serverType; 29 private int flags; 30 private int proximity; 31 private int ttl; 32 private int pathOffset; 33 private int altPathOffset; 34 private int nodeOffset; 35 private String path = null; 36 private String altPath; 37 38 String node; 39 40 int readWireFormat( byte[] buffer, int bufferIndex, int len ) { 41 int start = bufferIndex; 42 43 version = readInt2( buffer, bufferIndex ); 44 if( version != 3 && version != 1 ) { 45 throw new RuntimeException ( "Version " + version + " referral not supported. Please report this to jcifs at samba dot org." ); 46 } 47 bufferIndex += 2; 48 size = readInt2( buffer, bufferIndex ); 49 bufferIndex += 2; 50 serverType = readInt2( buffer, bufferIndex ); 51 bufferIndex += 2; 52 flags = readInt2( buffer, bufferIndex ); 53 bufferIndex += 2; 54 if( version == 3 ) { 55 proximity = readInt2( buffer, bufferIndex ); 56 bufferIndex += 2; 57 ttl = readInt2( buffer, bufferIndex ); 58 bufferIndex += 2; 59 pathOffset = readInt2( buffer, bufferIndex ); 60 bufferIndex += 2; 61 altPathOffset = readInt2( buffer, bufferIndex ); 62 bufferIndex += 2; 63 nodeOffset = readInt2( buffer, bufferIndex ); 64 bufferIndex += 2; 65 66 path = readString( buffer, start + pathOffset, len, (flags2 & FLAGS2_UNICODE) != 0); 67 node = readString( buffer, start + nodeOffset, len, (flags2 & FLAGS2_UNICODE) != 0); 68 } else if( version == 1 ) { 69 node = readString( buffer, bufferIndex, len, (flags2 & FLAGS2_UNICODE) != 0); 70 } 71 72 return size; 73 } 74 75 public String toString() { 76 return new String ( "Referral[" + 77 "version=" + version + ",size=" + size + 78 ",serverType=" + serverType + ",flags=" + flags + 79 ",proximity=" + proximity + ",ttl=" + ttl + 80 ",pathOffset=" + pathOffset + ",altPathOffset=" + altPathOffset + 81 ",nodeOffset=" + nodeOffset + ",path=" + path + ",altPath=" + altPath + 82 ",node=" + node + "]" ); 83 } 84 } 85 86 int pathConsumed; 87 int numReferrals; 88 int flags; 89 Referral referral; 90 91 Trans2GetDfsReferralResponse() { 92 subCommand = SmbComTransaction.TRANS2_GET_DFS_REFERRAL; 93 } 94 95 int writeSetupWireFormat( byte[] dst, int dstIndex ) { 96 return 0; 97 } 98 int writeParametersWireFormat( byte[] dst, int dstIndex ) { 99 return 0; 100 } 101 int writeDataWireFormat( byte[] dst, int dstIndex ) { 102 return 0; 103 } 104 int readSetupWireFormat( byte[] buffer, int bufferIndex, int len ) { 105 return 0; 106 } 107 int readParametersWireFormat( byte[] buffer, int bufferIndex, int len ) { 108 return 0; 109 } 110 int readDataWireFormat( byte[] buffer, int bufferIndex, int len ) { 111 int start = bufferIndex; 112 113 pathConsumed = readInt2( buffer, bufferIndex ); 114 bufferIndex += 2; 115 119 if((flags2 & FLAGS2_UNICODE) != 0) { 120 pathConsumed /= 2; 121 } 122 numReferrals = readInt2( buffer, bufferIndex ); 123 bufferIndex += 2; 124 flags = readInt2( buffer, bufferIndex ); 125 bufferIndex += 4; 126 127 referral = new Referral(); 128 while( numReferrals-- > 0 ) { 129 bufferIndex += referral.readWireFormat( buffer, bufferIndex, len ); 130 } 131 if (referral.path != null && referral.path.charAt( pathConsumed - 1 ) == '\\' ) { 132 pathConsumed--; 133 } 134 135 return bufferIndex - start; 136 } 137 public String toString() { 138 return new String ( "Trans2GetDfsReferralResponse[" + 139 super.toString() + ",pathConsumed=" + pathConsumed + 140 ",numReferrals=" + numReferrals + ",flags=" + flags + 141 "," + referral + "]" ); 142 } 143 } 144 | Popular Tags |