From 503cb0c0629257b05ca0da333583288b4e8a1ea4 Mon Sep 17 00:00:00 2001 From: olegkap_cp Date: Fri, 28 Dec 2012 15:35:47 +0000 Subject: [PATCH] Add some SFTP messages for future support --- .../Renci.SshNet.NET35.csproj | 9 +++ .../Renci.SshNet.Silverlight.csproj | 9 +++ .../Renci.SshNet.Silverlight5.csproj | 9 +++ .../Renci.SshNet.WindowsPhone.csproj | 9 +++ .../Renci.SshNet.WindowsPhone8.csproj | 9 +++ .../Renci.SshNet/Renci.SshNet.csproj | 3 + .../Sftp/Requests/SftpBlockRequest.cs | 51 +++++++++++++++++ .../Sftp/Requests/SftpLinkRequest.cs | 55 +++++++++++++++++++ .../Sftp/Requests/SftpUnblockRequest.cs | 47 ++++++++++++++++ .../Renci.SshNet/Sftp/SftpMessageTypes.cs | 13 +++++ 10 files changed, 214 insertions(+) create mode 100644 Renci.SshClient/Renci.SshNet/Sftp/Requests/SftpBlockRequest.cs create mode 100644 Renci.SshClient/Renci.SshNet/Sftp/Requests/SftpLinkRequest.cs create mode 100644 Renci.SshClient/Renci.SshNet/Sftp/Requests/SftpUnblockRequest.cs diff --git a/Renci.SshClient/Renci.SshNet.NET35/Renci.SshNet.NET35.csproj b/Renci.SshClient/Renci.SshNet.NET35/Renci.SshNet.NET35.csproj index 76de44c9..32ebb3dc 100644 --- a/Renci.SshClient/Renci.SshNet.NET35/Renci.SshNet.NET35.csproj +++ b/Renci.SshClient/Renci.SshNet.NET35/Renci.SshNet.NET35.csproj @@ -645,6 +645,9 @@ Sftp\Requests\ExtendedRequests\StatVfsRequest.cs + + Sftp\Requests\SftpBlockRequest.cs + Sftp\Requests\SftpCloseRequest.cs @@ -660,6 +663,9 @@ Sftp\Requests\SftpInitRequest.cs + + Sftp\Requests\SftpLinkRequest.cs + Sftp\Requests\SftpLStatRequest.cs @@ -705,6 +711,9 @@ Sftp\Requests\SftpSymLinkRequest.cs + + Sftp\Requests\SftpUnblockRequest.cs + Sftp\Requests\SftpWriteRequest.cs diff --git a/Renci.SshClient/Renci.SshNet.Silverlight/Renci.SshNet.Silverlight.csproj b/Renci.SshClient/Renci.SshNet.Silverlight/Renci.SshNet.Silverlight.csproj index 7abc5c23..aece265c 100644 --- a/Renci.SshClient/Renci.SshNet.Silverlight/Renci.SshNet.Silverlight.csproj +++ b/Renci.SshClient/Renci.SshNet.Silverlight/Renci.SshNet.Silverlight.csproj @@ -612,6 +612,9 @@ Sftp\Requests\ExtendedRequests\StatVfsRequest.cs + + Sftp\Requests\SftpBlockRequest.cs + Sftp\Requests\SftpCloseRequest.cs @@ -627,6 +630,9 @@ Sftp\Requests\SftpInitRequest.cs + + Sftp\Requests\SftpLinkRequest.cs + Sftp\Requests\SftpLStatRequest.cs @@ -672,6 +678,9 @@ Sftp\Requests\SftpSymLinkRequest.cs + + Sftp\Requests\SftpUnblockRequest.cs + Sftp\Requests\SftpWriteRequest.cs diff --git a/Renci.SshClient/Renci.SshNet.Silverlight5/Renci.SshNet.Silverlight5.csproj b/Renci.SshClient/Renci.SshNet.Silverlight5/Renci.SshNet.Silverlight5.csproj index 379f7ca4..5fdb753c 100644 --- a/Renci.SshClient/Renci.SshNet.Silverlight5/Renci.SshNet.Silverlight5.csproj +++ b/Renci.SshClient/Renci.SshNet.Silverlight5/Renci.SshNet.Silverlight5.csproj @@ -618,6 +618,9 @@ Sftp\Requests\ExtendedRequests\StatVfsRequest.cs + + Sftp\Requests\SftpBlockRequest.cs + Sftp\Requests\SftpCloseRequest.cs @@ -633,6 +636,9 @@ Sftp\Requests\SftpInitRequest.cs + + Sftp\Requests\SftpLinkRequest.cs + Sftp\Requests\SftpLStatRequest.cs @@ -678,6 +684,9 @@ Sftp\Requests\SftpSymLinkRequest.cs + + Sftp\Requests\SftpUnblockRequest.cs + Sftp\Requests\SftpWriteRequest.cs diff --git a/Renci.SshClient/Renci.SshNet.WindowsPhone/Renci.SshNet.WindowsPhone.csproj b/Renci.SshClient/Renci.SshNet.WindowsPhone/Renci.SshNet.WindowsPhone.csproj index 68f9670d..a6bb73c6 100644 --- a/Renci.SshClient/Renci.SshNet.WindowsPhone/Renci.SshNet.WindowsPhone.csproj +++ b/Renci.SshClient/Renci.SshNet.WindowsPhone/Renci.SshNet.WindowsPhone.csproj @@ -616,6 +616,9 @@ Sftp\Requests\ExtendedRequests\StatVfsRequest.cs + + Sftp\Requests\SftpBlockRequest.cs + Sftp\Requests\SftpCloseRequest.cs @@ -631,6 +634,9 @@ Sftp\Requests\SftpInitRequest.cs + + Sftp\Requests\SftpLinkRequest.cs + Sftp\Requests\SftpLStatRequest.cs @@ -676,6 +682,9 @@ Sftp\Requests\SftpSymLinkRequest.cs + + Sftp\Requests\SftpUnblockRequest.cs + Sftp\Requests\SftpWriteRequest.cs diff --git a/Renci.SshClient/Renci.SshNet.WindowsPhone8/Renci.SshNet.WindowsPhone8.csproj b/Renci.SshClient/Renci.SshNet.WindowsPhone8/Renci.SshNet.WindowsPhone8.csproj index 96bb2708..c60b308a 100644 --- a/Renci.SshClient/Renci.SshNet.WindowsPhone8/Renci.SshNet.WindowsPhone8.csproj +++ b/Renci.SshClient/Renci.SshNet.WindowsPhone8/Renci.SshNet.WindowsPhone8.csproj @@ -659,6 +659,9 @@ Sftp\Requests\ExtendedRequests\StatVfsRequest.cs + + Sftp\Requests\SftpBlockRequest.cs + Sftp\Requests\SftpCloseRequest.cs @@ -674,6 +677,9 @@ Sftp\Requests\SftpInitRequest.cs + + Sftp\Requests\SftpLinkRequest.cs + Sftp\Requests\SftpLStatRequest.cs @@ -719,6 +725,9 @@ Sftp\Requests\SftpSymLinkRequest.cs + + Sftp\Requests\SftpUnblockRequest.cs + Sftp\Requests\SftpWriteRequest.cs diff --git a/Renci.SshClient/Renci.SshNet/Renci.SshNet.csproj b/Renci.SshClient/Renci.SshNet/Renci.SshNet.csproj index 06e8f116..da8240a2 100644 --- a/Renci.SshClient/Renci.SshNet/Renci.SshNet.csproj +++ b/Renci.SshClient/Renci.SshNet/Renci.SshNet.csproj @@ -358,6 +358,8 @@ + + Code @@ -366,6 +368,7 @@ + diff --git a/Renci.SshClient/Renci.SshNet/Sftp/Requests/SftpBlockRequest.cs b/Renci.SshClient/Renci.SshNet/Sftp/Requests/SftpBlockRequest.cs new file mode 100644 index 00000000..ece83161 --- /dev/null +++ b/Renci.SshClient/Renci.SshNet/Sftp/Requests/SftpBlockRequest.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Renci.SshNet.Sftp.Responses; + +namespace Renci.SshNet.Sftp.Requests +{ + internal class SftpBlockRequest : SftpRequest + { + public override SftpMessageTypes SftpMessageType + { + get { return SftpMessageTypes.Block; } + } + + public byte[] Handle { get; private set; } + + public UInt64 Offset { get; private set; } + + public UInt64 Length { get; private set; } + + public UInt32 LockMask { get; private set; } + + public SftpBlockRequest(uint protocolVersion, uint requestId, byte[] handle, UInt64 offset, UInt64 length, UInt32 lockMask, Action statusAction) + : base(protocolVersion, requestId, statusAction) + { + this.Handle = handle; + this.Offset = offset; + this.Length = length; + this.LockMask = lockMask; + } + + protected override void LoadData() + { + base.LoadData(); + this.Handle = this.ReadBinaryString(); + this.Offset = this.ReadUInt64(); + this.Length = this.ReadUInt64(); + this.LockMask = this.ReadUInt32(); + } + + protected override void SaveData() + { + base.SaveData(); + this.WriteBinaryString(this.Handle); + this.Write(this.Offset); + this.Write(this.Length); + this.Write(this.LockMask); + } + } +} diff --git a/Renci.SshClient/Renci.SshNet/Sftp/Requests/SftpLinkRequest.cs b/Renci.SshClient/Renci.SshNet/Sftp/Requests/SftpLinkRequest.cs new file mode 100644 index 00000000..b311d940 --- /dev/null +++ b/Renci.SshClient/Renci.SshNet/Sftp/Requests/SftpLinkRequest.cs @@ -0,0 +1,55 @@ +using Renci.SshNet.Sftp.Responses; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Renci.SshNet.Sftp.Requests +{ + internal class SftpLinkRequest : SftpRequest + { + public override SftpMessageTypes SftpMessageType + { + get { return SftpMessageTypes.Link; } + } + + public string NewLinkPath { get; private set; } + + public string ExistingPath { get; private set; } + + public bool IsSymLink { get; private set; } + + /// + /// Initializes a new instance of the class. + /// + /// The protocol version. + /// The request id. + /// Specifies the path name of the new link to create. + /// Specifies the path of a target object to which the newly created link will refer. In the case of a symbolic link, this path may not exist. + /// if set to false the link should be a hard link, or a second directory entry referring to the same file or directory object. + /// The status action. + public SftpLinkRequest(uint protocolVersion, uint requestId, string newLinkPath, string existingPath, bool isSymLink, Action statusAction) + : base(protocolVersion, requestId, statusAction) + { + this.NewLinkPath = newLinkPath; + this.ExistingPath = existingPath; + this.IsSymLink = isSymLink; + } + + protected override void LoadData() + { + base.LoadData(); + this.NewLinkPath = this.ReadString(); + this.ExistingPath = this.ReadString(); + this.IsSymLink = this.ReadBoolean(); + } + + protected override void SaveData() + { + base.SaveData(); + this.Write(this.NewLinkPath); + this.Write(this.ExistingPath); + this.Write(this.IsSymLink); + } + } +} diff --git a/Renci.SshClient/Renci.SshNet/Sftp/Requests/SftpUnblockRequest.cs b/Renci.SshClient/Renci.SshNet/Sftp/Requests/SftpUnblockRequest.cs new file mode 100644 index 00000000..33a6a94a --- /dev/null +++ b/Renci.SshClient/Renci.SshNet/Sftp/Requests/SftpUnblockRequest.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Renci.SshNet.Sftp.Responses; + +namespace Renci.SshNet.Sftp.Requests +{ + internal class SftpUnblockRequest : SftpRequest + { + public override SftpMessageTypes SftpMessageType + { + get { return SftpMessageTypes.Block; } + } + + public byte[] Handle { get; private set; } + + public UInt64 Offset { get; private set; } + + public UInt64 Length { get; private set; } + + public SftpUnblockRequest(uint protocolVersion, uint requestId, byte[] handle, UInt64 offset, UInt64 length, UInt32 lockMask, Action statusAction) + : base(protocolVersion, requestId, statusAction) + { + this.Handle = handle; + this.Offset = offset; + this.Length = length; + this.SetAction(dataAction); + } + + protected override void LoadData() + { + base.LoadData(); + this.Handle = this.ReadBinaryString(); + this.Offset = this.ReadUInt64(); + this.Length = this.ReadUInt64(); + } + + protected override void SaveData() + { + base.SaveData(); + this.WriteBinaryString(this.Handle); + this.Write(this.Offset); + this.Write(this.Length); + } + } +} diff --git a/Renci.SshClient/Renci.SshNet/Sftp/SftpMessageTypes.cs b/Renci.SshClient/Renci.SshNet/Sftp/SftpMessageTypes.cs index acfb84c2..b87bb8d0 100644 --- a/Renci.SshClient/Renci.SshNet/Sftp/SftpMessageTypes.cs +++ b/Renci.SshClient/Renci.SshNet/Sftp/SftpMessageTypes.cs @@ -83,6 +83,19 @@ namespace Renci.SshNet.Sftp /// SSH_FXP_SYMLINK /// SymLink = 20, + /// + /// SSH_FXP_LINK + /// + Link = 21, + /// + /// SSH_FXP_BLOCK + /// + Block = 22, + /// + /// SSH_FXP_UNBLOCK + /// + Unblock = 23, + /// /// SSH_FXP_STATUS ///