sftp_client_packet.c File Reference

SFTP packet parsing and formatting. More...

#include "ssh/ssh.h"
#include "ssh/ssh_misc.h"
#include "sftp/sftp_client_packet.h"
#include "sftp/sftp_client_misc.h"
#include "path.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   SFTP_TRACE_LEVEL
 

Functions

error_t sftpClientFormatFxpInit (SftpClientContext *context, uint32_t version)
 Format SSH_FXP_INIT packet. More...
 
error_t sftpClientFormatFxpOpen (SftpClientContext *context, const char_t *filename, uint32_t pflags)
 Format SSH_FXP_OPEN packet. More...
 
error_t sftpClientFormatFxpClose (SftpClientContext *context, const uint8_t *handle, size_t handleLen)
 Format SSH_FXP_CLOSE packet. More...
 
error_t sftpClientFormatFxpRead (SftpClientContext *context, const uint8_t *handle, size_t handleLen, uint64_t offset, uint32_t dataLen)
 Format SSH_FXP_READ packet. More...
 
error_t sftpClientFormatFxpWrite (SftpClientContext *context, const uint8_t *handle, size_t handleLen, uint64_t offset, uint32_t dataLen)
 Format SSH_FXP_WRITE packet. More...
 
error_t sftpClientFormatFxpOpenDir (SftpClientContext *context, const char_t *path)
 Format SSH_FXP_OPENDIR packet. More...
 
error_t sftpClientFormatFxpReadDir (SftpClientContext *context, const uint8_t *handle, size_t handleLen)
 Format SSH_FXP_READDIR packet. More...
 
error_t sftpClientFormatFxpRemove (SftpClientContext *context, const char_t *filename)
 Format SSH_FXP_REMOVE packet. More...
 
error_t sftpClientFormatFxpMkDir (SftpClientContext *context, const char_t *path)
 Format SSH_FXP_MKDIR packet. More...
 
error_t sftpClientFormatFxpRmDir (SftpClientContext *context, const char_t *path)
 Format SSH_FXP_RMDIR packet. More...
 
error_t sftpClientFormatFxpRealPath (SftpClientContext *context, const char_t *path)
 Format SSH_FXP_REALPATH packet. More...
 
error_t sftpClientFormatFxpStat (SftpClientContext *context, const char_t *path)
 Format SSH_FXP_STAT packet. More...
 
error_t sftpClientFormatFxpRename (SftpClientContext *context, const char_t *oldPath, const char_t *newPath)
 Format SSH_FXP_RENAME packet. More...
 
error_t sftpClientParseFxpVersion (SftpClientContext *context, const uint8_t *packet, size_t length)
 Parse SSH_FXP_VERSION packet. More...
 
error_t sftpClientParseFxpStatus (SftpClientContext *context, const uint8_t *packet, size_t length)
 Parse SSH_FXP_STATUS packet. More...
 
error_t sftpClientParseFxpHandle (SftpClientContext *context, const uint8_t *packet, size_t length)
 Parse SSH_FXP_HANDLE packet. More...
 
error_t sftpClientParseFxpData (SftpClientContext *context, const uint8_t *packet, size_t fragLen, size_t totalLen)
 Parse SSH_FXP_DATA packet. More...
 
error_t sftpClientParseFxpName (SftpClientContext *context, const uint8_t *packet, size_t fragLen, size_t totalLen)
 Parse SSH_FXP_NAME packet. More...
 
error_t sftpClientParseFxpAttrs (SftpClientContext *context, const uint8_t *packet, size_t length)
 Parse SSH_FXP_ATTRS packet. More...
 

Detailed Description

SFTP packet parsing and formatting.

License

SPDX-License-Identifier: GPL-2.0-or-later

Copyright (C) 2019-2024 Oryx Embedded SARL. All rights reserved.

This file is part of CycloneSSH Open.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
2.4.4

Definition in file sftp_client_packet.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   SFTP_TRACE_LEVEL

Definition at line 32 of file sftp_client_packet.c.

Function Documentation

◆ sftpClientFormatFxpClose()

error_t sftpClientFormatFxpClose ( SftpClientContext context,
const uint8_t *  handle,
size_t  handleLen 
)

Format SSH_FXP_CLOSE packet.

Parameters
[in]contextPointer to the SFTP client context
[in]handleFile handle returned by SSH_FXP_OPEN or SSH_FXP_OPENDIR
[in]handleLenLength of the handle string, in bytes
Returns
Error code

Definition at line 197 of file sftp_client_packet.c.

◆ sftpClientFormatFxpInit()

error_t sftpClientFormatFxpInit ( SftpClientContext context,
uint32_t  version 
)

Format SSH_FXP_INIT packet.

Parameters
[in]contextPointer to the SFTP client context
[in]versionProtocol version number
Returns
Error code

Definition at line 53 of file sftp_client_packet.c.

◆ sftpClientFormatFxpMkDir()

error_t sftpClientFormatFxpMkDir ( SftpClientContext context,
const char_t path 
)

Format SSH_FXP_MKDIR packet.

Parameters
[in]contextPointer to the SFTP client context
[in]pathDirectory to be created
Returns
Error code

Definition at line 652 of file sftp_client_packet.c.

◆ sftpClientFormatFxpOpen()

error_t sftpClientFormatFxpOpen ( SftpClientContext context,
const char_t filename,
uint32_t  pflags 
)

Format SSH_FXP_OPEN packet.

Parameters
[in]contextPointer to the SFTP client context
[in]filenameName to the file to be be opened or created
[in]pflagsFile access mode
Returns
Error code

Definition at line 106 of file sftp_client_packet.c.

◆ sftpClientFormatFxpOpenDir()

error_t sftpClientFormatFxpOpenDir ( SftpClientContext context,
const char_t path 
)

Format SSH_FXP_OPENDIR packet.

Parameters
[in]contextPointer to the SFTP client context
[in]pathPath name of the directory to be listed
Returns
Error code

Definition at line 446 of file sftp_client_packet.c.

◆ sftpClientFormatFxpRead()

error_t sftpClientFormatFxpRead ( SftpClientContext context,
const uint8_t *  handle,
size_t  handleLen,
uint64_t  offset,
uint32_t  dataLen 
)

Format SSH_FXP_READ packet.

Parameters
[in]contextPointer to the SFTP client context
[in]handleFile handle returned by SSH_FXP_OPEN
[in]handleLenLength of the handle string, in bytes
[in]offsetOffset relative to the beginning of the file from where to start reading
[in]dataLenMaximum number of bytes to read
Returns
Error code

Definition at line 270 of file sftp_client_packet.c.

◆ sftpClientFormatFxpReadDir()

error_t sftpClientFormatFxpReadDir ( SftpClientContext context,
const uint8_t *  handle,
size_t  handleLen 
)

Format SSH_FXP_READDIR packet.

Parameters
[in]contextPointer to the SFTP client context
[in]handleFile handle returned by SSH_FXP_OPENDIR
[in]handleLenLength of the handle string, in bytes
Returns
Error code

Definition at line 515 of file sftp_client_packet.c.

◆ sftpClientFormatFxpRealPath()

error_t sftpClientFormatFxpRealPath ( SftpClientContext context,
const char_t path 
)

Format SSH_FXP_REALPATH packet.

Parameters
[in]contextPointer to the SFTP client context
[in]pathPath name to be canonicalized
Returns
Error code

Definition at line 802 of file sftp_client_packet.c.

◆ sftpClientFormatFxpRemove()

error_t sftpClientFormatFxpRemove ( SftpClientContext context,
const char_t filename 
)

Format SSH_FXP_REMOVE packet.

Parameters
[in]contextPointer to the SFTP client context
[in]filenameName of the file to be removed
Returns
Error code

Definition at line 584 of file sftp_client_packet.c.

◆ sftpClientFormatFxpRename()

error_t sftpClientFormatFxpRename ( SftpClientContext context,
const char_t oldPath,
const char_t newPath 
)

Format SSH_FXP_RENAME packet.

Parameters
[in]contextPointer to the SFTP client context
[in]oldPathName of an existing file or directory
[in]newPathNew name for the file or directory
Returns
Error code

Definition at line 940 of file sftp_client_packet.c.

◆ sftpClientFormatFxpRmDir()

error_t sftpClientFormatFxpRmDir ( SftpClientContext context,
const char_t path 
)

Format SSH_FXP_RMDIR packet.

Parameters
[in]contextPointer to the SFTP client context
[in]pathDirectory to be removed
Returns
Error code

Definition at line 734 of file sftp_client_packet.c.

◆ sftpClientFormatFxpStat()

error_t sftpClientFormatFxpStat ( SftpClientContext context,
const char_t path 
)

Format SSH_FXP_STAT packet.

Parameters
[in]contextPointer to the SFTP client context
[in]pathFile system object for which status is to be returned
Returns
Error code

Definition at line 870 of file sftp_client_packet.c.

◆ sftpClientFormatFxpWrite()

error_t sftpClientFormatFxpWrite ( SftpClientContext context,
const uint8_t *  handle,
size_t  handleLen,
uint64_t  offset,
uint32_t  dataLen 
)

Format SSH_FXP_WRITE packet.

Parameters
[in]contextPointer to the SFTP client context
[in]handleFile handle returned by SSH_FXP_OPEN
[in]handleLenLength of the handle string, in bytes
[in]offsetOffset relative to the beginning of the file from where to start writing
[in]dataLenLength of the data to be written
Returns
Error code

Definition at line 360 of file sftp_client_packet.c.

◆ sftpClientParseFxpAttrs()

error_t sftpClientParseFxpAttrs ( SftpClientContext context,
const uint8_t *  packet,
size_t  length 
)

Parse SSH_FXP_ATTRS packet.

Parameters
[in]contextPointer to the SFTP client context
[in]packetPointer to packet
[in]lengthLength of the packet, in bytes
Returns
Error code

Definition at line 1469 of file sftp_client_packet.c.

◆ sftpClientParseFxpData()

error_t sftpClientParseFxpData ( SftpClientContext context,
const uint8_t *  packet,
size_t  fragLen,
size_t  totalLen 
)

Parse SSH_FXP_DATA packet.

Parameters
[in]contextPointer to the SFTP client context
[in]packetPointer to packet
[in]fragLenNumber of bytes available on hand
[in]totalLenTotal length of the packet, in bytes
Returns
Error code

Definition at line 1293 of file sftp_client_packet.c.

◆ sftpClientParseFxpHandle()

error_t sftpClientParseFxpHandle ( SftpClientContext context,
const uint8_t *  packet,
size_t  length 
)

Parse SSH_FXP_HANDLE packet.

Parameters
[in]contextPointer to the SFTP client context
[in]packetPointer to packet
[in]lengthLength of the packet, in bytes
Returns
Error code

Definition at line 1214 of file sftp_client_packet.c.

◆ sftpClientParseFxpName()

error_t sftpClientParseFxpName ( SftpClientContext context,
const uint8_t *  packet,
size_t  fragLen,
size_t  totalLen 
)

Parse SSH_FXP_NAME packet.

Parameters
[in]contextPointer to the SFTP client context
[in]packetPointer to packet
[in]fragLenNumber of bytes available on hand
[in]totalLenTotal length of the packet, in bytes
Returns
Error code

Definition at line 1368 of file sftp_client_packet.c.

◆ sftpClientParseFxpStatus()

error_t sftpClientParseFxpStatus ( SftpClientContext context,
const uint8_t *  packet,
size_t  length 
)

Parse SSH_FXP_STATUS packet.

Parameters
[in]contextPointer to the SFTP client context
[in]packetPointer to packet
[in]lengthLength of the packet, in bytes
Returns
Error code

Definition at line 1095 of file sftp_client_packet.c.

◆ sftpClientParseFxpVersion()

error_t sftpClientParseFxpVersion ( SftpClientContext context,
const uint8_t *  packet,
size_t  length 
)

Parse SSH_FXP_VERSION packet.

Parameters
[in]contextPointer to the SFTP client context
[in]packetPointer to packet
[in]lengthLength of the packet, in bytes
Returns
Error code

Definition at line 1019 of file sftp_client_packet.c.