Definitions common to SFTP client and server. More...
Go to the source code of this file.
Data Structures | |
| struct | SftpFileAttrs |
| File attributes. More... | |
| struct | SftpName |
| Name structure. More... | |
Functions | |
| error_t | sftpFormatName (SftpVersion version, const SftpName *name, uint8_t *p, size_t *written) |
| Format name structure. More... | |
| error_t | sftpFormatLongFilename (const SshString *filename, const SftpFileAttrs *attributes, char_t *p, size_t *written) |
| Format long file name. More... | |
| error_t | sftpFormatAttributes (SftpVersion version, const SftpFileAttrs *attributes, uint8_t *p, size_t *written) |
| Format file attributes. More... | |
| error_t | sftpParseName (SftpVersion version, SftpName *name, const uint8_t *data, size_t length, size_t *consumed) |
| Parse name structure. More... | |
| error_t | sftpParseAttributes (SftpVersion version, SftpFileAttrs *attributes, const uint8_t *data, size_t length, size_t *consumed) |
| Parse file attributes. More... | |
| SftpFileType | sftpConvertPermToFileType (uint32_t permissions) |
| Extract file type from permission bits. More... | |
| uint32_t | sftpConvertFileTypeToPerm (SftpFileType type) |
| Convert file type to permission bits. More... | |
Variables | |
| typedef | __packed_struct |
| SFTP packet header. More... | |
| uint8_t | type |
| uint8_t | payload [] |
| SftpPacketHeader | |
| uint32_t | dataLen |
| uint8_t | data [] |
| SftpFxpDataHeader | |
Detailed Description
Definitions common to SFTP client and server.
License
SPDX-License-Identifier: GPL-2.0-or-later
Copyright (C) 2019-2025 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.
- Version
- 2.5.4
Definition in file sftp_common.h.
Macro Definition Documentation
◆ SFTP_180_DAYS
| #define SFTP_180_DAYS (180 * 86400) |
Definition at line 39 of file sftp_common.h.
◆ SFTP_MODE_IFBLK
| #define SFTP_MODE_IFBLK 0x6000 |
Definition at line 102 of file sftp_common.h.
◆ SFTP_MODE_IFCHR
| #define SFTP_MODE_IFCHR 0x2000 |
Definition at line 100 of file sftp_common.h.
◆ SFTP_MODE_IFDIR
| #define SFTP_MODE_IFDIR 0x4000 |
Definition at line 101 of file sftp_common.h.
◆ SFTP_MODE_IFIFO
| #define SFTP_MODE_IFIFO 0x1000 |
Definition at line 99 of file sftp_common.h.
◆ SFTP_MODE_IFLNK
| #define SFTP_MODE_IFLNK 0xA000 |
Definition at line 104 of file sftp_common.h.
◆ SFTP_MODE_IFMT
| #define SFTP_MODE_IFMT 0xF000 |
Definition at line 98 of file sftp_common.h.
◆ SFTP_MODE_IFREG
| #define SFTP_MODE_IFREG 0x8000 |
Definition at line 103 of file sftp_common.h.
◆ SFTP_MODE_IFSOCK
| #define SFTP_MODE_IFSOCK 0xC000 |
Definition at line 105 of file sftp_common.h.
◆ SFTP_MODE_IRGRP
| #define SFTP_MODE_IRGRP 0x0020 |
Definition at line 89 of file sftp_common.h.
◆ SFTP_MODE_IROTH
| #define SFTP_MODE_IROTH 0x0004 |
Definition at line 85 of file sftp_common.h.
◆ SFTP_MODE_IRUSR
| #define SFTP_MODE_IRUSR 0x0100 |
Definition at line 93 of file sftp_common.h.
◆ SFTP_MODE_IRWXG
| #define SFTP_MODE_IRWXG 0x0038 |
Definition at line 90 of file sftp_common.h.
◆ SFTP_MODE_IRWXO
| #define SFTP_MODE_IRWXO 0x0007 |
Definition at line 86 of file sftp_common.h.
◆ SFTP_MODE_IRWXU
| #define SFTP_MODE_IRWXU 0x01C0 |
Definition at line 94 of file sftp_common.h.
◆ SFTP_MODE_ISGID
| #define SFTP_MODE_ISGID 0x0400 |
Definition at line 96 of file sftp_common.h.
◆ SFTP_MODE_ISUID
| #define SFTP_MODE_ISUID 0x0800 |
Definition at line 97 of file sftp_common.h.
◆ SFTP_MODE_ISVTX
| #define SFTP_MODE_ISVTX 0x0200 |
Definition at line 95 of file sftp_common.h.
◆ SFTP_MODE_IWGRP
| #define SFTP_MODE_IWGRP 0x0010 |
Definition at line 88 of file sftp_common.h.
◆ SFTP_MODE_IWOTH
| #define SFTP_MODE_IWOTH 0x0002 |
Definition at line 84 of file sftp_common.h.
◆ SFTP_MODE_IWUSR
| #define SFTP_MODE_IWUSR 0x0080 |
Definition at line 92 of file sftp_common.h.
◆ SFTP_MODE_IXGRP
| #define SFTP_MODE_IXGRP 0x0008 |
Definition at line 87 of file sftp_common.h.
◆ SFTP_MODE_IXOTH
| #define SFTP_MODE_IXOTH 0x0001 |
Definition at line 83 of file sftp_common.h.
◆ SFTP_MODE_IXUSR
| #define SFTP_MODE_IXUSR 0x0040 |
Definition at line 91 of file sftp_common.h.
◆ SSH_FILEXFER_ATTR_ACCESSTIME
| #define SSH_FILEXFER_ATTR_ACCESSTIME 0x00000008 |
Definition at line 54 of file sftp_common.h.
◆ SSH_FILEXFER_ATTR_ACL
| #define SSH_FILEXFER_ATTR_ACL 0x00000040 |
Definition at line 57 of file sftp_common.h.
◆ SSH_FILEXFER_ATTR_ACMODTIME
| #define SSH_FILEXFER_ATTR_ACMODTIME 0x00000008 |
Definition at line 53 of file sftp_common.h.
◆ SSH_FILEXFER_ATTR_ALLOCATION_SIZE
| #define SSH_FILEXFER_ATTR_ALLOCATION_SIZE 0x00000400 |
Definition at line 61 of file sftp_common.h.
◆ SSH_FILEXFER_ATTR_BITS
| #define SSH_FILEXFER_ATTR_BITS 0x00000200 |
Definition at line 60 of file sftp_common.h.
◆ SSH_FILEXFER_ATTR_CREATETIME
| #define SSH_FILEXFER_ATTR_CREATETIME 0x00000010 |
Definition at line 55 of file sftp_common.h.
◆ SSH_FILEXFER_ATTR_EXTENDED
| #define SSH_FILEXFER_ATTR_EXTENDED 0x80000000 |
Definition at line 66 of file sftp_common.h.
◆ SSH_FILEXFER_ATTR_FLAGS_APPEND_ONLY
| #define SSH_FILEXFER_ATTR_FLAGS_APPEND_ONLY 0x00000100 |
Definition at line 77 of file sftp_common.h.
◆ SSH_FILEXFER_ATTR_FLAGS_ARCHIVE
| #define SSH_FILEXFER_ATTR_FLAGS_ARCHIVE 0x00000010 |
Definition at line 73 of file sftp_common.h.
◆ SSH_FILEXFER_ATTR_FLAGS_CASE_INSENSITIVE
| #define SSH_FILEXFER_ATTR_FLAGS_CASE_INSENSITIVE 0x00000008 |
Definition at line 72 of file sftp_common.h.
◆ SSH_FILEXFER_ATTR_FLAGS_COMPRESSED
| #define SSH_FILEXFER_ATTR_FLAGS_COMPRESSED 0x00000040 |
Definition at line 75 of file sftp_common.h.
◆ SSH_FILEXFER_ATTR_FLAGS_ENCRYPTED
| #define SSH_FILEXFER_ATTR_FLAGS_ENCRYPTED 0x00000020 |
Definition at line 74 of file sftp_common.h.
◆ SSH_FILEXFER_ATTR_FLAGS_HIDDEN
| #define SSH_FILEXFER_ATTR_FLAGS_HIDDEN 0x00000004 |
Definition at line 71 of file sftp_common.h.
◆ SSH_FILEXFER_ATTR_FLAGS_IMMUTABLE
| #define SSH_FILEXFER_ATTR_FLAGS_IMMUTABLE 0x00000200 |
Definition at line 78 of file sftp_common.h.
◆ SSH_FILEXFER_ATTR_FLAGS_READONLY
| #define SSH_FILEXFER_ATTR_FLAGS_READONLY 0x00000001 |
Definition at line 69 of file sftp_common.h.
◆ SSH_FILEXFER_ATTR_FLAGS_SPARSE
| #define SSH_FILEXFER_ATTR_FLAGS_SPARSE 0x00000080 |
Definition at line 76 of file sftp_common.h.
◆ SSH_FILEXFER_ATTR_FLAGS_SYNC
| #define SSH_FILEXFER_ATTR_FLAGS_SYNC 0x00000400 |
Definition at line 79 of file sftp_common.h.
◆ SSH_FILEXFER_ATTR_FLAGS_SYSTEM
| #define SSH_FILEXFER_ATTR_FLAGS_SYSTEM 0x00000002 |
Definition at line 70 of file sftp_common.h.
◆ SSH_FILEXFER_ATTR_FLAGS_TRANSLATION_ERR
| #define SSH_FILEXFER_ATTR_FLAGS_TRANSLATION_ERR 0x00000800 |
Definition at line 80 of file sftp_common.h.
◆ SSH_FILEXFER_ATTR_LINK_COUNT
| #define SSH_FILEXFER_ATTR_LINK_COUNT 0x00002000 |
Definition at line 64 of file sftp_common.h.
◆ SSH_FILEXFER_ATTR_MIME_TYPE
| #define SSH_FILEXFER_ATTR_MIME_TYPE 0x00001000 |
Definition at line 63 of file sftp_common.h.
◆ SSH_FILEXFER_ATTR_MODIFYTIME
| #define SSH_FILEXFER_ATTR_MODIFYTIME 0x00000020 |
Definition at line 56 of file sftp_common.h.
◆ SSH_FILEXFER_ATTR_OWNERGROUP
| #define SSH_FILEXFER_ATTR_OWNERGROUP 0x00000080 |
Definition at line 58 of file sftp_common.h.
◆ SSH_FILEXFER_ATTR_PERMISSIONS
| #define SSH_FILEXFER_ATTR_PERMISSIONS 0x00000004 |
Definition at line 52 of file sftp_common.h.
◆ SSH_FILEXFER_ATTR_SIZE
| #define SSH_FILEXFER_ATTR_SIZE 0x00000001 |
Definition at line 50 of file sftp_common.h.
◆ SSH_FILEXFER_ATTR_SUBSECOND_TIMES
| #define SSH_FILEXFER_ATTR_SUBSECOND_TIMES 0x00000100 |
Definition at line 59 of file sftp_common.h.
◆ SSH_FILEXFER_ATTR_TEXT_HINT
| #define SSH_FILEXFER_ATTR_TEXT_HINT 0x00000800 |
Definition at line 62 of file sftp_common.h.
◆ SSH_FILEXFER_ATTR_UIDGID
| #define SSH_FILEXFER_ATTR_UIDGID 0x00000002 |
Definition at line 51 of file sftp_common.h.
◆ SSH_FILEXFER_ATTR_UNTRANLATED_NAME
| #define SSH_FILEXFER_ATTR_UNTRANLATED_NAME 0x00004000 |
Definition at line 65 of file sftp_common.h.
◆ SSH_FXF_APPEND
| #define SSH_FXF_APPEND 0x00000004 |
Definition at line 44 of file sftp_common.h.
◆ SSH_FXF_CREAT
| #define SSH_FXF_CREAT 0x00000008 |
Definition at line 45 of file sftp_common.h.
◆ SSH_FXF_EXCL
| #define SSH_FXF_EXCL 0x00000020 |
Definition at line 47 of file sftp_common.h.
◆ SSH_FXF_READ
| #define SSH_FXF_READ 0x00000001 |
Definition at line 42 of file sftp_common.h.
◆ SSH_FXF_TRUNC
| #define SSH_FXF_TRUNC 0x00000010 |
Definition at line 46 of file sftp_common.h.
◆ SSH_FXF_WRITE
| #define SSH_FXF_WRITE 0x00000002 |
Definition at line 43 of file sftp_common.h.
Enumeration Type Documentation
◆ SftpFileType
| enum SftpFileType |
File types.
Definition at line 187 of file sftp_common.h.
◆ SftpPacketType
| enum SftpPacketType |
SFTP packet types.
Definition at line 133 of file sftp_common.h.
◆ SftpStatusCode
| enum SftpStatusCode |
Status codes.
| Enumerator | |
|---|---|
| SSH_FX_OK | |
| SSH_FX_EOF | |
| SSH_FX_NO_SUCH_FILE | |
| SSH_FX_PERMISSION_DENIED | |
| SSH_FX_FAILURE | |
| SSH_FX_BAD_MESSAGE | |
| SSH_FX_NO_CONNECTION | |
| SSH_FX_CONNECTION_LOST | |
| SSH_FX_OP_UNSUPPORTED | |
Definition at line 169 of file sftp_common.h.
◆ SftpVersion
| enum SftpVersion |
SFTP protocol version.
| Enumerator | |
|---|---|
| SFTP_VERSION_0 | |
| SFTP_VERSION_1 | |
| SFTP_VERSION_2 | |
| SFTP_VERSION_3 | |
| SFTP_VERSION_4 | |
| SFTP_VERSION_5 | |
| SFTP_VERSION_6 | |
Definition at line 117 of file sftp_common.h.
Function Documentation
◆ sftpConvertFileTypeToPerm()
| uint32_t sftpConvertFileTypeToPerm | ( | SftpFileType | type | ) |
Convert file type to permission bits.
- Parameters
-
[in] type File type
- Returns
- Permission bits
Definition at line 708 of file sftp_common.c.
◆ sftpConvertPermToFileType()
| SftpFileType sftpConvertPermToFileType | ( | uint32_t | permissions | ) |
Extract file type from permission bits.
- Parameters
-
[in] permissions Permission bits
- Returns
- File type
Definition at line 656 of file sftp_common.c.
◆ sftpFormatAttributes()
| error_t sftpFormatAttributes | ( | SftpVersion | version, |
| const SftpFileAttrs * | attributes, | ||
| uint8_t * | p, | ||
| size_t * | written | ||
| ) |
Format file attributes.
- Parameters
-
[in] version Protocol version [in] attributes File attributes [in] p Buffer where to format the attributes [out] written Total number of bytes that have been written
- Returns
- Error code
Definition at line 255 of file sftp_common.c.
◆ sftpFormatLongFilename()
| error_t sftpFormatLongFilename | ( | const SshString * | filename, |
| const SftpFileAttrs * | attributes, | ||
| char_t * | p, | ||
| size_t * | written | ||
| ) |
Format long file name.
- Parameters
-
[in] filename File name [in] attributes File attributes [in] p Buffer where to format the long file name [out] written Total number of bytes that have been written
- Returns
- Error code
Definition at line 111 of file sftp_common.c.
◆ sftpFormatName()
| error_t sftpFormatName | ( | SftpVersion | version, |
| const SftpName * | name, | ||
| uint8_t * | p, | ||
| size_t * | written | ||
| ) |
Format name structure.
- Parameters
-
[in] version Protocol version [in] name Pointer to the name structure [in] p Buffer where to format the name structure [out] written Total number of bytes that have been written
- Returns
- Error code
Definition at line 50 of file sftp_common.c.
◆ sftpParseAttributes()
| error_t sftpParseAttributes | ( | SftpVersion | version, |
| SftpFileAttrs * | attributes, | ||
| const uint8_t * | data, | ||
| size_t | length, | ||
| size_t * | consumed | ||
| ) |
Parse file attributes.
- Parameters
-
[in] version Protocol version [out] attributes File attributes [in] data Pointer to ATTRS compound data [in] length Number of bytes available in the input stream [out] consumed Total number of bytes that have been consumed
- Returns
- Error code
Definition at line 454 of file sftp_common.c.
◆ sftpParseName()
| error_t sftpParseName | ( | SftpVersion | version, |
| SftpName * | name, | ||
| const uint8_t * | data, | ||
| size_t | length, | ||
| size_t * | consumed | ||
| ) |
Parse name structure.
- Parameters
-
[in] version Protocol version [out] name Pointer to the name structure [in] data Input data stream [in] length Number of bytes available in the input stream [out] consumed Total number of bytes that have been consumed
- Returns
- Error code
Definition at line 370 of file sftp_common.c.
Variable Documentation
◆ __packed_struct
| typedef __packed_struct |
SFTP packet header.
SSH_FXP_DATA packet header.
Definition at line 214 of file sftp_common.h.
◆ data
| uint8_t data[] |
Definition at line 230 of file sftp_common.h.
◆ dataLen
| uint32_t dataLen |
Definition at line 229 of file sftp_common.h.
◆ payload
| uint8_t payload[] |
Definition at line 218 of file sftp_common.h.
◆ SftpFxpDataHeader
| SftpFxpDataHeader |
Definition at line 231 of file sftp_common.h.
◆ SftpPacketHeader
| SftpPacketHeader |
Definition at line 219 of file sftp_common.h.
◆ type
| uint8_t type |
Definition at line 217 of file sftp_common.h.
