/// <summary> /// Send a Dfs request to server /// </summary> /// <param name="payload">REQ_GET_DFS_REFERRAL structure in byte array</param> /// <param name="isEX"> /// Boolean which indicates whether payload contains DFS_GET_REFERRAL_EX message /// MUST be false for SMB transport. /// </param>> /// <exception cref="System.ArgumentNullException">the payload to be sent is null.</exception> /// <exception cref="ArgumentException">extended request packet cannot be in payload</exception> /// <exception cref="System.InvalidOperationException">The transport is not connected</exception> public override void SendDfscPayload(byte[] payload, bool isEX) { if (isEX) { throw new ArgumentException("REQ_DFS_GET_REFERRAL_EX message not supported over SMB transport"); } if (this.smbClient == null) { throw new InvalidOperationException("The transport is not connected."); } if (payload == null) { throw new ArgumentNullException("payload"); } REQ_GET_DFS_REFERRAL referral = new REQ_GET_DFS_REFERRAL(); // Put payload[0] into the lower byte of MaxReferralLevel // Put payload[1] into the upper byte of MaxReferralLevel // Sample: payload[0] = 0x0B; payload[1] = 0x0A // MaxReferralLevel = 0x0A0B; referral.MaxReferralLevel = (ushort)(payload[1] << 8 | payload[0]); referral.RequestFileName = new byte[payload.Length - sizeofMaxReferralLevel]; Array.Copy(payload, sizeofMaxReferralLevel, referral.RequestFileName, 0, referral.RequestFileName.Length); SmbTrans2GetDfsReferralRequestPacket request = this.smbClient.CreateTrans2GetDFSReferralRequest( this.treeId, Trans2SmbParametersFlags.NONE, "", referral); if (this.isSignRequired) { request.Sign(this.NextSequenceNumber, this.sessionKey); } this.smbClient.SendPacket(request); }
/// <summary> /// Send a Dfs request to server /// 1. Decode payload from byte array to Dfsc REQ_GET_DFS_REFERRAL payload defined in Cifs /// 2. Create cifs packet with payload and send out. /// </summary> /// <param name="payload">REQ_GET_DFS_REFERRAL structure in byte array</param> /// <param name="isEX"> /// Boolean indicating whether payload contains REQ_GET_DFS_REFFERAL_EX message. /// MUST be false for CIFS transport /// </param> /// <exception cref="System.ArgumentNullException">the payload to be sent is null.</exception> /// <exception cref="ArgumentException">extended request packet cannot be in payload</exception> /// <exception cref="System.InvalidOperationException">The transport is not connected</exception> public override void SendDfscPayload(byte[] payload, bool isEX) { if (isEX) { throw new ArgumentException("REQ_DFS_GET_REFERRAL_EX message not supported over CIFS transport"); } if (this.cifsClient == null) { throw new InvalidOperationException("The transport is not connected."); } if (payload == null) { throw new ArgumentNullException("payload"); } REQ_GET_DFS_REFERRAL referral = new REQ_GET_DFS_REFERRAL(); // Put payload[0] into the lower byte of MaxReferralLevel // Put payload[1] into the upper byte of MaxReferralLevel // Sample: payload[0] = 0x0B; payload[1] = 0x0A // MaxReferralLevel = 0x0A0B; referral.MaxReferralLevel = (ushort)(payload[1] << 8 | payload[0]); referral.RequestFileName = new byte[payload.Length - sizeofMaxReferralLevel]; Array.Copy(payload, sizeofMaxReferralLevel, referral.RequestFileName, 0, referral.RequestFileName.Length - sizeofMaxReferralLevel); SmbPacket request = this.cifsClient.CreateTrans2GetDfsReferalRequest( this.uid, this.treeId, "", referral); this.cifsClient.SendPacket(request); }