sftp_common.h File Reference

Definitions common to SFTP client and server. More...

#include "ssh/ssh.h"
#include "date_time.h"

Go to the source code of this file.

Data Structures

struct  SftpFileAttrs
 File attributes. More...
 
struct  SftpName
 Name structure. More...
 

Macros

#define SFTP_180_DAYS   (180 * 86400)
 
#define SSH_FXF_READ   0x00000001
 
#define SSH_FXF_WRITE   0x00000002
 
#define SSH_FXF_APPEND   0x00000004
 
#define SSH_FXF_CREAT   0x00000008
 
#define SSH_FXF_TRUNC   0x00000010
 
#define SSH_FXF_EXCL   0x00000020
 
#define SSH_FILEXFER_ATTR_SIZE   0x00000001
 
#define SSH_FILEXFER_ATTR_UIDGID   0x00000002
 
#define SSH_FILEXFER_ATTR_PERMISSIONS   0x00000004
 
#define SSH_FILEXFER_ATTR_ACMODTIME   0x00000008
 
#define SSH_FILEXFER_ATTR_ACCESSTIME   0x00000008
 
#define SSH_FILEXFER_ATTR_CREATETIME   0x00000010
 
#define SSH_FILEXFER_ATTR_MODIFYTIME   0x00000020
 
#define SSH_FILEXFER_ATTR_ACL   0x00000040
 
#define SSH_FILEXFER_ATTR_OWNERGROUP   0x00000080
 
#define SSH_FILEXFER_ATTR_SUBSECOND_TIMES   0x00000100
 
#define SSH_FILEXFER_ATTR_BITS   0x00000200
 
#define SSH_FILEXFER_ATTR_ALLOCATION_SIZE   0x00000400
 
#define SSH_FILEXFER_ATTR_TEXT_HINT   0x00000800
 
#define SSH_FILEXFER_ATTR_MIME_TYPE   0x00001000
 
#define SSH_FILEXFER_ATTR_LINK_COUNT   0x00002000
 
#define SSH_FILEXFER_ATTR_UNTRANLATED_NAME   0x00004000
 
#define SSH_FILEXFER_ATTR_EXTENDED   0x80000000
 
#define SSH_FILEXFER_ATTR_FLAGS_READONLY   0x00000001
 
#define SSH_FILEXFER_ATTR_FLAGS_SYSTEM   0x00000002
 
#define SSH_FILEXFER_ATTR_FLAGS_HIDDEN   0x00000004
 
#define SSH_FILEXFER_ATTR_FLAGS_CASE_INSENSITIVE   0x00000008
 
#define SSH_FILEXFER_ATTR_FLAGS_ARCHIVE   0x00000010
 
#define SSH_FILEXFER_ATTR_FLAGS_ENCRYPTED   0x00000020
 
#define SSH_FILEXFER_ATTR_FLAGS_COMPRESSED   0x00000040
 
#define SSH_FILEXFER_ATTR_FLAGS_SPARSE   0x00000080
 
#define SSH_FILEXFER_ATTR_FLAGS_APPEND_ONLY   0x00000100
 
#define SSH_FILEXFER_ATTR_FLAGS_IMMUTABLE   0x00000200
 
#define SSH_FILEXFER_ATTR_FLAGS_SYNC   0x00000400
 
#define SSH_FILEXFER_ATTR_FLAGS_TRANSLATION_ERR   0x00000800
 
#define SFTP_MODE_IXOTH   0x0001
 
#define SFTP_MODE_IWOTH   0x0002
 
#define SFTP_MODE_IROTH   0x0004
 
#define SFTP_MODE_IRWXO   0x0007
 
#define SFTP_MODE_IXGRP   0x0008
 
#define SFTP_MODE_IWGRP   0x0010
 
#define SFTP_MODE_IRGRP   0x0020
 
#define SFTP_MODE_IRWXG   0x0038
 
#define SFTP_MODE_IXUSR   0x0040
 
#define SFTP_MODE_IWUSR   0x0080
 
#define SFTP_MODE_IRUSR   0x0100
 
#define SFTP_MODE_IRWXU   0x01C0
 
#define SFTP_MODE_ISVTX   0x0200
 
#define SFTP_MODE_ISGID   0x0400
 
#define SFTP_MODE_ISUID   0x0800
 
#define SFTP_MODE_IFMT   0xF000
 
#define SFTP_MODE_IFIFO   0x1000
 
#define SFTP_MODE_IFCHR   0x2000
 
#define SFTP_MODE_IFDIR   0x4000
 
#define SFTP_MODE_IFBLK   0x6000
 
#define SFTP_MODE_IFREG   0x8000
 
#define SFTP_MODE_IFLNK   0xA000
 
#define SFTP_MODE_IFSOCK   0xC000
 

Typedefs

struct {
   char_t   type
 
   uint32_t   dataStart
 
   uint32_t   dataLength
 
   uint8_t   nameLength
 
   char_t   name []
 
   uint8_t   tokenLen: 4
 
   uint8_t   type: 2
 
   uint8_t   version: 2
 
   uint8_t   code
 
   uint16_t   mid
 
   uint8_t   token []
 
   union {
      uint8_t   b [6]
 
      uint16_t   w [3]
 
   } 
 
   uint16_t   srcPort
 
   uint16_t   destPort
 
   uint32_t   seqNum
 
   uint32_t   ackNum
 
   uint8_t   reserved1: 4
 
   uint8_t   dataOffset: 4
 
   uint8_t   flags: 6
 
   uint8_t   reserved2: 2
 
   uint16_t   window
 
   uint16_t   checksum
 
   uint16_t   urgentPointer
 
   uint8_t   options []
 
   uint16_t   length
 
   uint8_t   data []
 
   uint8_t   op
 
   uint8_t   htype
 
   uint8_t   hlen
 
   uint8_t   hops
 
   uint32_t   xid
 
   uint16_t   secs
 
   uint16_t   flags
 
   Ipv4Addr   ciaddr
 
   Ipv4Addr   yiaddr
 
   Ipv4Addr   siaddr
 
   Ipv4Addr   giaddr
 
   MacAddr   chaddr
 
   uint8_t   unused [10]
 
   uint8_t   sname [64]
 
   uint8_t   file [128]
 
   uint32_t   magicCookie
 
   uint16_t   type
 
   uint16_t   hardwareType
 
   uint32_t   time
 
   MacAddr   linkLayerAddr
 
   uint16_t   id
 
   uint8_t   rd: 1
 
   uint8_t   tc: 1
 
   uint8_t   aa: 1
 
   uint8_t   opcode: 4
 
   uint8_t   qr: 1
 
   uint8_t   rcode: 4
 
   uint8_t   z: 3
 
   uint8_t   ra: 1
 
   uint16_t   qdcount
 
   uint16_t   ancount
 
   uint16_t   nscount
 
   uint16_t   arcount
 
   uint8_t   questions []
 
   uint16_t   controlWord
 
   uint16_t   byteCount
 
   uint8_t   bLength
 
   uint8_t   bDescriptorType
 
   uint16_t   bcdUsb
 
   uint8_t   bDeviceClass
 
   uint8_t   bDeviceSubClass
 
   uint8_t   bDeviceProtocol
 
   uint8_t   bMaxPacketSize0
 
   uint16_t   idVendor
 
   uint16_t   idProduct
 
   uint16_t   bcdDevice
 
   uint8_t   iManufacturer
 
   uint8_t   iProduct
 
   uint8_t   iSerialNumber
 
   uint8_t   bNumConfigurations
 
   uint16_t   hrd
 
   uint16_t   pro
 
   uint8_t   hln
 
   uint8_t   pln
 
   uint16_t   op
 
   MacAddr   sha
 
   Ipv4Addr   spa
 
   MacAddr   tha
 
   Ipv4Addr   tpa
 
   uint8_t   maxRespTime
 
   Ipv4Addr   groupAddr
 
   uint8_t   length
 
   uint8_t   value []
 
   uint16_t   first
 
   uint16_t   last
 
   uint16_t   next
 
   union {
      uint8_t   b [16]
 
      uint16_t   w [8]
 
      uint32_t   dw [4]
 
   } 
 
   uint16_t   maxRespDelay
 
   uint16_t   reserved
 
   Ipv6Addr   multicastAddr
 
   uint32_t   reserved
 
   uint8_t   t: 1
 
   uint8_t   c: 1
 
   union {
      int32_t   integer
 
      uint8_t   octetString [1]
 
      uint8_t   oid [1]
 
      uint8_t   ipAddr [4]
 
      uint32_t   counter32
 
      uint32_t   gauge32
 
      uint32_t   unsigned32
 
      uint32_t   timeTicks
 
      uint64_t   counter64
 
   } 
 
   uint16_t   transactionId
 
   uint16_t   protocolId
 
   uint8_t   unitId
 
   uint8_t   pdu []
 
   uint8_t   retain: 1
 
   uint8_t   qos: 2
 
   uint8_t   dup: 1
 
   union {
      uint8_t   all
 
      struct {
         uint8_t   topicIdType: 2
 
         uint8_t   cleanSession: 1
 
         uint8_t   will: 1
 
         uint8_t   retain: 1
 
         uint8_t   qos: 2
 
         uint8_t   dup: 1
 
      } 
 
   } 
 
   uint8_t   b: 1
 
   uint8_t   identifier
 
   uint8_t   valueSize
 
   Ipv4Addr   srcIpAddr
 
   Ipv4Addr   destIpAddr
 
   Eui64   interfaceId
 
   uint16_t   mru
 
   uint8_t   peerIdLength
 
   uint8_t   peerId []
 
   uint32_t   seconds
 
   uint32_t   fraction
 
   uint16_t   opcode
 
   char_t   filename []
 
   uint8_t   reserved: 3
 
   uint8_t   fin: 1
 
   uint8_t   payloadLen: 7
 
   uint8_t   mask: 1
 
   uint8_t   extPayloadLen []
 
   uint32_t   length
 
   uint8_t   payload []
 
   uint32_t   packetLen
 
   uint8_t   paddingLen
 
   uint8_t   protocolVersionId
 
   uint8_t   bpduType
 
   StpBridgeId   rootId
 
   uint32_t   rootPathCost
 
   StpBridgeId   bridgeId
 
   uint16_t   portId
 
   uint16_t   messageAge
 
   uint16_t   maxAge
 
   uint16_t   helloTime
 
   uint16_t   forwardDelay
 
   uint8_t   version1Length
 
   uint16_t   priority
 
   MacAddr   addr
 
SftpPacketHeader
 SFTP packet header. More...
 
struct {
   char_t   type
 
   uint32_t   dataStart
 
   uint32_t   dataLength
 
   uint8_t   nameLength
 
   uint8_t   length: 4
 
   uint8_t   delta: 4
 
   union {
      uint8_t   b [8]
 
      uint16_t   w [4]
 
      uint32_t   dw [2]
 
   } 
 
   uint8_t   kind
 
   uint8_t   value []
 
   uint8_t   code
 
   uint16_t   type
 
   uint32_t   enterpriseNumber
 
   uint8_t   identifier []
 
   uint16_t   qtype
 
   uint16_t   qclass
 
   uint16_t   statusWord
 
   uint16_t   byteCount
 
   uint8_t   bLength
 
   uint8_t   bDescriptorType
 
   uint16_t   wTotalLength
 
   uint8_t   bNumInterfaces
 
   uint8_t   bConfigurationValue
 
   uint8_t   iConfiguration
 
   uint8_t   bmAttributes
 
   uint8_t   bMaxPower
 
   uint8_t   type
 
   uint16_t   checksum
 
   uint8_t   parameter
 
   uint8_t   unused [3]
 
   uint8_t   data []
 
   uint32_t   parameter
 
   uint8_t   nextHeader
 
   uint8_t   hdrExtLen
 
   uint8_t   options []
 
   uint8_t   curHopLimit
 
   uint8_t   reserved: 2
 
   uint8_t   p: 1
 
   uint8_t   prf: 2
 
   uint8_t   h: 1
 
   uint8_t   o: 1
 
   uint8_t   m: 1
 
   uint16_t   routerLifetime
 
   uint32_t   reachableTime
 
   uint32_t   retransTimer
 
   uint8_t   functionCode
 
   uint16_t   startingAddr
 
   uint16_t   quantityOfCoils
 
   uint16_t   length
 
   uint8_t   msgType
 
   uint16_t   flags
 
   Ipv4Addr   addr
 
   uint8_t   valueSize
 
   uint16_t   protocol
 
   uint32_t   accm
 
   uint8_t   msgLength
 
   uint8_t   message []
 
   uint8_t   mode: 3
 
   uint8_t   vn: 3
 
   uint8_t   li: 2
 
   uint8_t   stratum
 
   uint8_t   poll
 
   int8_t   precision
 
   uint32_t   rootDelay
 
   uint32_t   rootDispersion
 
   uint32_t   referenceId
 
   NtpTimestamp   referenceTimestamp
 
   NtpTimestamp   originateTimestamp
 
   NtpTimestamp   receiveTimestamp
 
   NtpTimestamp   transmitTimestamp
 
   uint16_t   opcode
 
   char_t   filename []
 
   uint16_t   value []
 
   uint16_t   group
 
   uint8_t   keyExchange []
 
   uint32_t   id
 
   uint32_t   dataLen
 
SftpFxpDataHeader
 SSH_FXP_DATA packet header. More...
 

Enumerations

enum  SftpVersion {
  SFTP_VERSION_0 = 0, SFTP_VERSION_1 = 1, SFTP_VERSION_2 = 2, SFTP_VERSION_3 = 3,
  SFTP_VERSION_4 = 4, SFTP_VERSION_5 = 5, SFTP_VERSION_6 = 6
}
 SFTP protocol version. More...
 
enum  SftpPacketType {
  SSH_FXP_INIT = 1, SSH_FXP_VERSION = 2, SSH_FXP_OPEN = 3, SSH_FXP_CLOSE = 4,
  SSH_FXP_READ = 5, SSH_FXP_WRITE = 6, SSH_FXP_LSTAT = 7, SSH_FXP_FSTAT = 8,
  SSH_FXP_SETSTAT = 9, SSH_FXP_FSETSTAT = 10, SSH_FXP_OPENDIR = 11, SSH_FXP_READDIR = 12,
  SSH_FXP_REMOVE = 13, SSH_FXP_MKDIR = 14, SSH_FXP_RMDIR = 15, SSH_FXP_REALPATH = 16,
  SSH_FXP_STAT = 17, SSH_FXP_RENAME = 18, SSH_FXP_READLINK = 19, SSH_FXP_SYMLINK = 20,
  SSH_FXP_STATUS = 101, SSH_FXP_HANDLE = 102, SSH_FXP_DATA = 103, SSH_FXP_NAME = 104,
  SSH_FXP_ATTRS = 105, SSH_FXP_EXTENDED = 200, SSH_FXP_EXTENDED_REPLY = 201
}
 SFTP packet types. More...
 
enum  SftpStatusCode {
  SSH_FX_OK = 0, SSH_FX_EOF = 1, SSH_FX_NO_SUCH_FILE = 2, SSH_FX_PERMISSION_DENIED = 3,
  SSH_FX_FAILURE = 4, SSH_FX_BAD_MESSAGE = 5, SSH_FX_NO_CONNECTION = 6, SSH_FX_CONNECTION_LOST = 7,
  SSH_FX_OP_UNSUPPORTED = 8
}
 Status codes. More...
 
enum  SftpFileType {
  SSH_FILEXFER_TYPE_INVALID = 0, SSH_FILEXFER_TYPE_REGULAR = 1, SSH_FILEXFER_TYPE_DIRECTORY = 2, SSH_FILEXFER_TYPE_SYMLINK = 3,
  SSH_FILEXFER_TYPE_SPECIAL = 4, SSH_FILEXFER_TYPE_UNKNOWN = 5, SSH_FILEXFER_TYPE_SOCKET = 6, SSH_FILEXFER_TYPE_CHAR_DEVICE = 7,
  SSH_FILEXFER_TYPE_BLOCK_DEVICE = 8, SSH_FILEXFER_TYPE_FIFO = 9
}
 File types. 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...
 

Detailed Description

Definitions common to SFTP client and server.

License

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

Copyright (C) 2019-2021 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.0.2

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.

Typedef Documentation

◆ SftpFxpDataHeader

typedef { ... } SftpFxpDataHeader

SSH_FXP_DATA packet header.

◆ SftpPacketHeader

typedef { ... } SftpPacketHeader

SFTP packet header.

Enumeration Type Documentation

◆ SftpFileType

File types.

Enumerator
SSH_FILEXFER_TYPE_INVALID 
SSH_FILEXFER_TYPE_REGULAR 
SSH_FILEXFER_TYPE_DIRECTORY 
SSH_FILEXFER_TYPE_SYMLINK 
SSH_FILEXFER_TYPE_SPECIAL 
SSH_FILEXFER_TYPE_UNKNOWN 
SSH_FILEXFER_TYPE_SOCKET 
SSH_FILEXFER_TYPE_CHAR_DEVICE 
SSH_FILEXFER_TYPE_BLOCK_DEVICE 
SSH_FILEXFER_TYPE_FIFO 

Definition at line 187 of file sftp_common.h.

◆ SftpPacketType

SFTP packet types.

Enumerator
SSH_FXP_INIT 
SSH_FXP_VERSION 
SSH_FXP_OPEN 
SSH_FXP_CLOSE 
SSH_FXP_READ 
SSH_FXP_WRITE 
SSH_FXP_LSTAT 
SSH_FXP_FSTAT 
SSH_FXP_SETSTAT 
SSH_FXP_FSETSTAT 
SSH_FXP_OPENDIR 
SSH_FXP_READDIR 
SSH_FXP_REMOVE 
SSH_FXP_MKDIR 
SSH_FXP_RMDIR 
SSH_FXP_REALPATH 
SSH_FXP_STAT 
SSH_FXP_RENAME 
SSH_FXP_READLINK 
SSH_FXP_SYMLINK 
SSH_FXP_STATUS 
SSH_FXP_HANDLE 
SSH_FXP_DATA 
SSH_FXP_NAME 
SSH_FXP_ATTRS 
SSH_FXP_EXTENDED 
SSH_FXP_EXTENDED_REPLY 

Definition at line 133 of file sftp_common.h.

◆ 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

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]typeFile type
Returns
Permission bits

Definition at line 700 of file sftp_common.c.

◆ sftpConvertPermToFileType()

SftpFileType sftpConvertPermToFileType ( uint32_t  permissions)

Extract file type from permission bits.

Parameters
[in]permissionsPermission bits
Returns
File type

Definition at line 648 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]versionProtocol version
[in]attributesFile attributes
[in]pBuffer where to format the attributes
[out]writtenTotal number of bytes that have been written
Returns
Error code

Definition at line 247 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]filenameFile name
[in]attributesFile attributes
[in]pBuffer where to format the long file name
[out]writtenTotal 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]versionProtocol version
[in]namePointer to the name structure
[in]pBuffer where to format the name structure
[out]writtenTotal 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]versionProtocol version
[out]attributesFile attributes
[in]dataPointer to ATTRS compound data
[in]lengthNumber of bytes available in the input stream
[out]consumedTotal number of bytes that have been consumed
Returns
Error code

Definition at line 446 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]versionProtocol version
[out]namePointer to the name structure
[in]dataInput data stream
[in]lengthNumber of bytes available in the input stream
[out]consumedTotal number of bytes that have been consumed
Returns
Error code

Definition at line 362 of file sftp_common.c.

Variable Documentation

◆ data

uint8_t data[]

Definition at line 228 of file sftp_common.h.

◆ dataLen

uint32_t dataLen

Definition at line 227 of file sftp_common.h.

◆ id

uint32_t id

Definition at line 226 of file sftp_common.h.

◆ length

uint32_t length

Definition at line 214 of file sftp_common.h.

◆ payload

uint8_t payload[]

Definition at line 216 of file sftp_common.h.

◆ type

uint8_t type

Definition at line 215 of file sftp_common.h.