sftp_common.c
Go to the documentation of this file.
1 /**
2  * @file sftp_common.c
3  * @brief Definitions common to SFTP client and server
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2019-2022 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneTCP Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.2.0
29  **/
30 
31 //Switch to the appropriate trace level
32 #define TRACE_LEVEL SFTP_TRACE_LEVEL
33 
34 //Dependencies
35 #include "ssh/ssh.h"
36 #include "ssh/ssh_misc.h"
37 #include "sftp/sftp_common.h"
38 #include "debug.h"
39 
40 
41 /**
42  * @brief Format name structure
43  * @param[in] version Protocol version
44  * @param[in] name Pointer to the name structure
45  * @param[in] p Buffer where to format the name structure
46  * @param[out] written Total number of bytes that have been written
47  * @return Error code
48  **/
49 
51  uint8_t *p, size_t *written)
52 {
53  error_t error;
54  size_t n;
55 
56  //Total number of bytes that have been written
57  *written = 0;
58 
59  //Format the file name
60  error = sshFormatBinaryString(name->filename.value, name->filename.length,
61  p, &n);
62  //Any error to report?
63  if(error)
64  return error;
65 
66  //Point to the next field
67  p += n;
68  *written += n;
69 
70  //The long file name has been removed in version 4
71  if(version <= SFTP_VERSION_3)
72  {
73  //Format the long file name
74  error = sftpFormatLongFilename(&name->filename, &name->attributes,
75  (char_t *) p + 4, &n);
76  //Any error to report?
77  if(error)
78  return error;
79 
80  //The string is preceded by a uint32 containing its length
81  STORE32BE(n, p);
82 
83  //Point to the next field
84  p += sizeof(uint32_t) + n;
85  *written += sizeof(uint32_t) + n;
86  }
87 
88  //Format ATTRS compound data
89  error = sftpFormatAttributes(version, &name->attributes, p, &n);
90  //Any error to report?
91  if(error)
92  return error;
93 
94  //Total number of bytes that have been written
95  *written += n;
96 
97  //Successful processing
98  return NO_ERROR;
99 }
100 
101 
102 /**
103  * @brief Format long file name
104  * @param[in] filename File name
105  * @param[in] attributes File attributes
106  * @param[in] p Buffer where to format the long file name
107  * @param[out] written Total number of bytes that have been written
108  * @return Error code
109  **/
110 
112  const SftpFileAttrs *attributes, char_t *p, size_t *written)
113 {
114  size_t n;
115  time_t time;
116  time_t modified;
117 
118  //Abbreviated months
119  static const char_t months[13][4] =
120  {
121  " ",
122  "Jan",
123  "Feb",
124  "Mar",
125  "Apr",
126  "May",
127  "Jun",
128  "Jul",
129  "Aug",
130  "Sep",
131  "Oct",
132  "Nov",
133  "Dec"
134  };
135 
136  //Valid attributes?
137  if(attributes->flags != 0)
138  {
139  //Format links, owner, group and size fields
140  n = osSprintf(p, "---------- 1 owner group %10" PRIu64,
141  attributes->size);
142 
143  //Check whether the current entry is a directory
144  if(attributes->type == SSH_FILEXFER_TYPE_DIRECTORY)
145  {
146  p[0] = 'd';
147  }
148 
149  //Check user permissions
150  if((attributes->permissions & SFTP_MODE_IRUSR) != 0)
151  {
152  p[1] = 'r';
153  }
154 
155  if((attributes->permissions & SFTP_MODE_IWUSR) != 0)
156  {
157  p[2] = 'w';
158  }
159 
160  if((attributes->permissions & SFTP_MODE_IXUSR) != 0)
161  {
162  p[3] = 'x';
163  }
164 
165  //Check group permissions
166  if((attributes->permissions & SFTP_MODE_IRGRP) != 0)
167  {
168  p[4] = 'r';
169  }
170 
171  if((attributes->permissions & SFTP_MODE_IWGRP) != 0)
172  {
173  p[5] = 'w';
174  }
175 
176  if((attributes->permissions & SFTP_MODE_IXGRP) != 0)
177  {
178  p[6] = 'x';
179  }
180 
181  //Check other (everyone) permissions
182  if((attributes->permissions & SFTP_MODE_IROTH) != 0)
183  {
184  p[7] = 'r';
185  }
186 
187  if((attributes->permissions & SFTP_MODE_IWOTH) != 0)
188  {
189  p[8] = 'w';
190  }
191 
192  if((attributes->permissions & SFTP_MODE_IXOTH) != 0)
193  {
194  p[9] = 'x';
195  }
196 
197  //Get current time
199  //Get modification time
200  modified = convertDateToUnixTime(&attributes->mtime);
201 
202  //Check whether the modification time is within the previous 180 days
203  if(time > modified && time < (modified + SFTP_180_DAYS))
204  {
205  //The format of the date/time field is Mmm dd hh:mm
206  n += osSprintf(p + n, " %s %02" PRIu8 " %02" PRIu8 ":%02" PRIu8,
207  months[MIN(attributes->mtime.month, 12)], attributes->mtime.day,
208  attributes->mtime.hours, attributes->mtime.minutes);
209  }
210  else
211  {
212  //The format of the date/time field is Mmm dd yyyy
213  n += osSprintf(p + n, " %s %02" PRIu8 " %04" PRIu16,
214  months[MIN(attributes->mtime.month, 12)], attributes->mtime.day,
215  attributes->mtime.year);
216  }
217 
218  //Append a space character
219  p[n++] = ' ';
220  }
221  else
222  {
223  //The file attributes are not valid
224  n = 0;
225  }
226 
227  //Copy file name
228  osMemcpy(p + n, filename->value, filename->length);
229 
230  //Total number of bytes that have been written
231  *written = n + filename->length;
232 
233  //Successful processing
234  return NO_ERROR;
235 }
236 
237 
238 /**
239  * @brief Format file attributes
240  * @param[in] version Protocol version
241  * @param[in] attributes File attributes
242  * @param[in] p Buffer where to format the attributes
243  * @param[out] written Total number of bytes that have been written
244  * @return Error code
245  **/
246 
248  const SftpFileAttrs *attributes, uint8_t *p, size_t *written)
249 {
250  time_t time;
251  uint32_t permissions;
252 
253  //Total number of bytes that have been written
254  *written = 0;
255 
256  //The flags specify which of the fields are present
257  STORE32BE(attributes->flags, p);
258 
259  //Point to the next field
260  p += sizeof(uint32_t);
261  *written += sizeof(uint32_t);
262 
263  //Version 4 splits the file type out of the permissions field and into
264  //its own field (which is always present)
265  if(version >= SFTP_VERSION_4)
266  {
267  //The 'type' field is encoded as a byte
268  p[0] = (uint8_t) attributes->type;
269 
270  //Point to the next field
271  p += sizeof(uint8_t);
272  *written += sizeof(uint8_t);
273  }
274 
275  //The 'size' field is optional
276  if((attributes->flags & SSH_FILEXFER_ATTR_SIZE) != 0)
277  {
278  //The size field specifies the size of the file in bytes
279  STORE64BE(attributes->size, p);
280 
281  //Point to the next field
282  p += sizeof(uint64_t);
283  *written += sizeof(uint64_t);
284  }
285 
286  //The 'uid' and 'gid' fields are optional
287  if((attributes->flags & SSH_FILEXFER_ATTR_UIDGID) != 0)
288  {
289  //The 'uid' field contains numeric Unix-like user identifier
290  STORE32BE(attributes->uid, p);
291 
292  //Point to the next field
293  p += sizeof(uint32_t);
294  *written += sizeof(uint32_t);
295 
296  //The 'gid' field contains numeric Unix-like group identifier
297  STORE32BE(attributes->gid, p);
298 
299  //Point to the next field
300  p += sizeof(uint32_t);
301  *written += sizeof(uint32_t);
302  }
303 
304  //The 'permissions' field is optional
305  if((attributes->flags & SSH_FILEXFER_ATTR_PERMISSIONS) != 0)
306  {
307  //The 'permissions' field contains a bit mask of file permissions
308  permissions = attributes->permissions & ~SFTP_MODE_IFMT;
309 
310  //Check SFTP protocol version
311  if(version <= SFTP_VERSION_3)
312  {
313  //Convert file type to permission bits
314  permissions |= sftpConvertFileTypeToPerm(attributes->type);
315  }
316 
317  //The 'permissions' field is encoded as a 32-bit integer
318  STORE32BE(permissions, p);
319 
320  //Point to the next field
321  p += sizeof(uint32_t);
322  *written += sizeof(uint32_t);
323  }
324 
325  //The 'atime' and 'mtime' fields are optional
326  if((attributes->flags & SSH_FILEXFER_ATTR_ACMODTIME) != 0)
327  {
328  //The 'atime' field contain the access time of the file
329  time = convertDateToUnixTime(&attributes->atime);
330  //The time is represented as seconds from Jan 1, 1970 in UTC
331  STORE32BE(time, p);
332 
333  //Point to the next field
334  p += sizeof(uint32_t);
335  *written += sizeof(uint32_t);
336 
337  //The 'mtime' field contain the modification time of the file
338  time = convertDateToUnixTime(&attributes->mtime);
339  //The time is represented as seconds from Jan 1, 1970 in UTC
340  STORE32BE(time, p);
341 
342  //Point to the next field
343  p += sizeof(uint32_t);
344  *written += sizeof(uint32_t);
345  }
346 
347  //Successful processing
348  return NO_ERROR;
349 }
350 
351 
352 /**
353  * @brief Parse name structure
354  * @param[in] version Protocol version
355  * @param[out] name Pointer to the name structure
356  * @param[in] data Input data stream
357  * @param[in] length Number of bytes available in the input stream
358  * @param[out] consumed Total number of bytes that have been consumed
359  * @return Error code
360  **/
361 
363  size_t length, size_t *consumed)
364 {
365  error_t error;
366  size_t n;
367  const uint8_t *p;
368 
369  //Clear name structure
370  osMemset(name, 0, sizeof(SftpName));
371 
372  //Point to the input data stream
373  p = data;
374 
375  //Decode the file name
376  error = sshParseString(p, length, &name->filename);
377  //Any error to report?
378  if(error)
379  return error;
380 
381  //Point to the next field
382  p += sizeof(uint32_t) + name->filename.length;
383  length -= sizeof(uint32_t) + name->filename.length;
384 
385  //The long file name has been removed in version 4
386  if(version <= SFTP_VERSION_3)
387  {
388  //Decode the long file name
389  error = sshParseString(p, length, &name->longname);
390  //Any error to report?
391  if(error)
392  return error;
393 
394  //Point to the next field
395  p += sizeof(uint32_t) + name->longname.length;
396  length -= sizeof(uint32_t) + name->longname.length;
397  }
398 
399  //Parse ATTRS compound data
400  error = sftpParseAttributes(version, &name->attributes, p, length, &n);
401  //Any error to report?
402  if(error)
403  return error;
404 
405  //Point to the next field
406  p += n;
407  length -= n;
408 
409  //Check SFTP protocol version
410  if(version <= SFTP_VERSION_3)
411  {
412  //Unknown file type?
413  if(name->attributes.type == SSH_FILEXFER_TYPE_UNKNOWN &&
414  name->longname.length > 0)
415  {
416  //Check file type
417  if(name->longname.value[0] == 'd')
418  {
419  name->attributes.type = SSH_FILEXFER_TYPE_DIRECTORY;
420  }
421  else
422  {
423  name->attributes.type = SSH_FILEXFER_TYPE_REGULAR;
424  }
425  }
426  }
427 
428  //Total number of bytes that have been consumed
429  *consumed = p - data;
430 
431  //Successful processing
432  return NO_ERROR;
433 }
434 
435 
436 /**
437  * @brief Parse file attributes
438  * @param[in] version Protocol version
439  * @param[out] attributes File attributes
440  * @param[in] data Pointer to ATTRS compound data
441  * @param[in] length Number of bytes available in the input stream
442  * @param[out] consumed Total number of bytes that have been consumed
443  * @return Error code
444  **/
445 
447  const uint8_t *data, size_t length, size_t *consumed)
448 {
449  error_t error;
450  time_t time;
451  uint32_t i;
452  uint32_t extendedCount;
453  SshString extendedType;
454  SshString extendedData;
455  const uint8_t *p;
456 
457  //Clear file attributes
458  osMemset(attributes, 0, sizeof(SftpFileAttrs));
459 
460  //Point to the first byte of the ATTRS compound data
461  p = data;
462 
463  //Malformed packet?
464  if(length < sizeof(uint32_t))
465  return ERROR_INVALID_PACKET;
466 
467  //The flags specify which of the fields are present
468  attributes->flags = LOAD32BE(p);
469 
470  //Point to the next field
471  p += sizeof(uint32_t);
472  length -= sizeof(uint32_t);
473 
474  //Version 4 splits the file type out of the permissions field and into
475  //its own field (which is always present)
476  if(version >= SFTP_VERSION_4)
477  {
478  //Malformed packet?
479  if(length < sizeof(uint8_t))
480  return ERROR_INVALID_PACKET;
481 
482  //The 'type' field is always present in version 4
483  attributes->type = (SftpFileType) p[0];
484 
485  //Point to the next field
486  p += sizeof(uint8_t);
487  length -= sizeof(uint8_t);
488  }
489  else
490  {
491  //The 'type' field is not present in version 3
492  attributes->type = SSH_FILEXFER_TYPE_UNKNOWN;
493  }
494 
495  //Check if the 'size' field is present?
496  if((attributes->flags & SSH_FILEXFER_ATTR_SIZE) != 0)
497  {
498  //Malformed packet?
499  if(length < sizeof(uint64_t))
500  return ERROR_INVALID_PACKET;
501 
502  //The 'size' field specifies the size of the file in bytes
503  attributes->size = LOAD64BE(p);
504 
505  //Point to the next field
506  p += sizeof(uint64_t);
507  length -= sizeof(uint64_t);
508  }
509 
510  //Check if the 'uid' and 'gid' fields are present?
511  if((attributes->flags & SSH_FILEXFER_ATTR_UIDGID) != 0)
512  {
513  //Malformed packet?
514  if(length < sizeof(uint32_t))
515  return ERROR_INVALID_PACKET;
516 
517  //The 'uid' field contains numeric Unix-like user identifier
518  attributes->uid = LOAD32BE(p);
519 
520  //Point to the next field
521  p += sizeof(uint32_t);
522  length -= sizeof(uint32_t);
523 
524  //Malformed packet?
525  if(length < sizeof(uint32_t))
526  return ERROR_INVALID_PACKET;
527 
528  //The 'gid' field contains numeric Unix-like group identifier
529  attributes->gid = LOAD32BE(p);
530 
531  //Point to the next field
532  p += sizeof(uint32_t);
533  length -= sizeof(uint32_t);
534  }
535 
536  //Check if the 'permissions' field is present?
537  if((attributes->flags & SSH_FILEXFER_ATTR_PERMISSIONS) != 0)
538  {
539  //Malformed packet?
540  if(length < sizeof(uint32_t))
541  return ERROR_INVALID_PACKET;
542 
543  //The 'permissions' field contains a bit mask of file permissions
544  attributes->permissions = LOAD32BE(p);
545 
546  //Check SFTP protocol version
547  if(version <= SFTP_VERSION_3)
548  {
549  //Extract file type from permission bits
550  attributes->type = sftpConvertPermToFileType(attributes->permissions);
551  }
552 
553  //Point to the next field
554  p += sizeof(uint32_t);
555  length -= sizeof(uint32_t);
556  }
557 
558  //Check if the 'atime' and 'mtime' fields are present?
559  if((attributes->flags & SSH_FILEXFER_ATTR_ACMODTIME) != 0)
560  {
561  //Malformed packet?
562  if(length < sizeof(uint32_t))
563  return ERROR_INVALID_PACKET;
564 
565  //The 'atime' field contain the access time of the file
566  time = LOAD32BE(p);
567  //The time is represented as seconds from Jan 1, 1970 in UTC
568  convertUnixTimeToDate(time, &attributes->atime);
569 
570  //Point to the next field
571  p += sizeof(uint32_t);
572  length -= sizeof(uint32_t);
573 
574  //Malformed packet?
575  if(length < sizeof(uint32_t))
576  return ERROR_INVALID_PACKET;
577 
578  //The 'mtime' field contain the modification time of the file
579  time = LOAD32BE(p);
580  //The time is represented as seconds from Jan 1, 1970 in UTC
581  convertUnixTimeToDate(time, &attributes->mtime);
582 
583  //Point to the next field
584  p += sizeof(uint32_t);
585  length -= sizeof(uint32_t);
586  }
587 
588  //Check if the 'extended_count' field is present?
589  if((attributes->flags & SSH_FILEXFER_ATTR_EXTENDED) != 0)
590  {
591  //Malformed packet?
592  if(length < sizeof(uint32_t))
593  return ERROR_INVALID_PACKET;
594 
595  //Parse the 'extended_count' field
596  extendedCount = LOAD32BE(p);
597 
598  //Point to the next field
599  p += sizeof(uint32_t);
600  length -= sizeof(uint32_t);
601  }
602  else
603  {
604  //The 'extended_count' field is not present
605  extendedCount = 0;
606  }
607 
608  //The 'extended_count' field specifies the number of extended type/data
609  //pairs that follow
610  for(i = 0; i < extendedCount; i++)
611  {
612  //For each of the attributes, the 'extended_type' field should be a
613  //string of the format "name@domain"
614  error = sshParseString(p, length, &extendedType);
615  //Any error to report?
616  if(error)
617  return error;
618 
619  //Point to the next field
620  p += sizeof(uint32_t) + extendedType.length;
621  length -= sizeof(uint32_t) + extendedType.length;
622 
623  //The interpretation of 'extended_data' depends on the type
624  error = sshParseString(p, length, &extendedData);
625  //Any error to report?
626  if(error)
627  return error;
628 
629  //Point to the next field
630  p += sizeof(uint32_t) + extendedData.length;
631  length -= sizeof(uint32_t) + extendedData.length;
632  }
633 
634  //Total number of bytes that have been consumed
635  *consumed = p - data;
636 
637  //Successful processing
638  return NO_ERROR;
639 }
640 
641 
642 /**
643  * @brief Extract file type from permission bits
644  * @param[in] permissions Permission bits
645  * @return File type
646  **/
647 
649 {
651 
652  //Check permission bits
653  switch(permissions & SFTP_MODE_IFMT)
654  {
655  case SFTP_MODE_IFREG:
656  //The file is a regular file
658  break;
659  case SFTP_MODE_IFDIR:
660  //The file is a directory
662  break;
663  case SFTP_MODE_IFLNK:
664  //The file is a symbolic link
666  break;
667  case SFTP_MODE_IFSOCK:
668  //The file is a socket
670  break;
671  case SFTP_MODE_IFCHR:
672  //The file is a character special file
674  break;
675  case SFTP_MODE_IFBLK:
676  //The file is a block special file
678  break;
679  case SFTP_MODE_IFIFO:
680  //The file is a FIFO special file or a pipe
682  break;
683  default:
684  //The file type is unknown
686  break;
687  }
688 
689  //Return file type
690  return type;
691 }
692 
693 
694 /**
695  * @brief Convert file type to permission bits
696  * @param[in] type File type
697  * @return Permission bits
698  **/
699 
701 {
702  uint32_t permissions;
703 
704  //Check file type
705  switch(type)
706  {
708  //The file is a regular file
709  permissions = SFTP_MODE_IFREG;
710  break;
712  //The file is a directory
713  permissions = SFTP_MODE_IFDIR;
714  break;
716  //The file is a symbolic link
717  permissions = SFTP_MODE_IFLNK;
718  break;
720  //The file is a socket
721  permissions = SFTP_MODE_IFSOCK;
722  break;
724  //The file is a character special file
725  permissions = SFTP_MODE_IFCHR;
726  break;
728  //The file is a block special file
729  permissions = SFTP_MODE_IFBLK;
730  break;
732  //The file is a FIFO special file or a pipe
733  permissions = SFTP_MODE_IFIFO;
734  break;
735  default:
736  //The file type is unknown
737  permissions = 0;
738  break;
739  }
740 
741  //Return permission bits
742  return permissions;
743 }
uint32_t permissions
Definition: sftp_common.h:249
#define SSH_FILEXFER_ATTR_EXTENDED
Definition: sftp_common.h:66
uint8_t length
Definition: coap_common.h:193
SftpFileType
File types.
Definition: sftp_common.h:188
uint8_t data[]
Definition: ethernet.h:220
uint64_t size
Definition: sftp_common.h:246
#define SFTP_MODE_IXOTH
Definition: sftp_common.h:83
#define LOAD32BE(p)
Definition: cpu_endian.h:210
uint8_t p
Definition: ndp.h:298
@ SFTP_VERSION_4
Definition: sftp_common.h:123
time_t convertDateToUnixTime(const DateTime *date)
Convert date to Unix timestamp.
Definition: date_time.c:258
uint16_t year
Definition: date_time.h:48
uint32_t flags
Definition: sftp_common.h:244
@ SSH_FILEXFER_TYPE_FIFO
Definition: sftp_common.h:198
error_t sftpFormatName(SftpVersion version, const SftpName *name, uint8_t *p, size_t *written)
Format name structure.
Definition: sftp_common.c:50
@ SFTP_VERSION_3
Definition: sftp_common.h:122
error_t sshParseString(const uint8_t *p, size_t length, SshString *string)
Parse a string.
Definition: ssh_misc.c:1141
void convertUnixTimeToDate(time_t t, DateTime *date)
Convert Unix timestamp to date.
Definition: date_time.c:198
SftpFileType type
Definition: sftp_common.h:245
char_t name[]
@ SSH_FILEXFER_TYPE_CHAR_DEVICE
Definition: sftp_common.h:196
size_t length
Definition: ssh_types.h:58
#define SFTP_MODE_IFCHR
Definition: sftp_common.h:100
uint8_t version
Definition: coap_common.h:175
#define SFTP_MODE_IFLNK
Definition: sftp_common.h:104
#define LOAD64BE(p)
Definition: cpu_endian.h:246
uint8_t day
Definition: date_time.h:50
#define SFTP_MODE_IROTH
Definition: sftp_common.h:85
#define SSH_FILEXFER_ATTR_SIZE
Definition: sftp_common.h:50
error_t sshFormatBinaryString(const void *value, size_t valueLen, uint8_t *p, size_t *written)
Format a binary string.
Definition: ssh_misc.c:1404
@ SSH_FILEXFER_TYPE_REGULAR
Definition: sftp_common.h:190
#define osMemcpy(dest, src, length)
Definition: os_port.h:137
char_t filename[]
Definition: tftp_common.h:91
char_t type
uint8_t minutes
Definition: date_time.h:53
error_t
Error codes.
Definition: error.h:43
#define SFTP_MODE_IWUSR
Definition: sftp_common.h:92
#define osSprintf(dest,...)
Definition: os_port.h:221
error_t sftpParseAttributes(SftpVersion version, SftpFileAttrs *attributes, const uint8_t *data, size_t length, size_t *consumed)
Parse file attributes.
Definition: sftp_common.c:446
error_t sftpParseName(SftpVersion version, SftpName *name, const uint8_t *data, size_t length, size_t *consumed)
Parse name structure.
Definition: sftp_common.c:362
error_t sftpFormatAttributes(SftpVersion version, const SftpFileAttrs *attributes, uint8_t *p, size_t *written)
Format file attributes.
Definition: sftp_common.c:247
#define SFTP_MODE_IFBLK
Definition: sftp_common.h:102
@ ERROR_INVALID_PACKET
Definition: error.h:139
@ SSH_FILEXFER_TYPE_UNKNOWN
Definition: sftp_common.h:194
uint8_t hours
Definition: date_time.h:52
uint32_t gid
Definition: sftp_common.h:248
#define SFTP_MODE_IWGRP
Definition: sftp_common.h:88
#define MIN(a, b)
Definition: os_port.h:62
String.
Definition: ssh_types.h:56
#define SFTP_MODE_IXUSR
Definition: sftp_common.h:91
DateTime mtime
Definition: sftp_common.h:251
SftpFileType sftpConvertPermToFileType(uint32_t permissions)
Extract file type from permission bits.
Definition: sftp_common.c:648
#define SFTP_MODE_IRGRP
Definition: sftp_common.h:89
#define SSH_FILEXFER_ATTR_ACMODTIME
Definition: sftp_common.h:53
uint8_t month
Definition: date_time.h:49
#define SFTP_MODE_IWOTH
Definition: sftp_common.h:84
char char_t
Definition: compiler_port.h:43
Name structure.
Definition: sftp_common.h:261
#define STORE64BE(a, p)
Definition: cpu_endian.h:322
@ SSH_FILEXFER_TYPE_SOCKET
Definition: sftp_common.h:195
uint32_t time
#define SFTP_MODE_IFREG
Definition: sftp_common.h:103
#define SFTP_MODE_IXGRP
Definition: sftp_common.h:87
uint8_t n
error_t sftpFormatLongFilename(const SshString *filename, const SftpFileAttrs *attributes, char_t *p, size_t *written)
Format long file name.
Definition: sftp_common.c:111
#define SFTP_180_DAYS
Definition: sftp_common.h:39
#define SFTP_MODE_IFSOCK
Definition: sftp_common.h:105
SSH helper functions.
#define SFTP_MODE_IRUSR
Definition: sftp_common.h:93
#define SSH_FILEXFER_ATTR_PERMISSIONS
Definition: sftp_common.h:52
@ SSH_FILEXFER_TYPE_DIRECTORY
Definition: sftp_common.h:191
#define SFTP_MODE_IFMT
Definition: sftp_common.h:98
Definitions common to SFTP client and server.
SftpVersion
SFTP protocol version.
Definition: sftp_common.h:118
@ SSH_FILEXFER_TYPE_BLOCK_DEVICE
Definition: sftp_common.h:197
uint32_t sftpConvertFileTypeToPerm(SftpFileType type)
Convert file type to permission bits.
Definition: sftp_common.c:700
@ SSH_FILEXFER_TYPE_SYMLINK
Definition: sftp_common.h:192
#define osMemset(p, value, length)
Definition: os_port.h:131
DateTime atime
Definition: sftp_common.h:250
File attributes.
Definition: sftp_common.h:243
Secure Shell (SSH)
uint32_t uid
Definition: sftp_common.h:247
#define SFTP_MODE_IFIFO
Definition: sftp_common.h:99
__weak_func time_t getCurrentUnixTime(void)
Get current time.
Definition: date_time.c:180
#define STORE32BE(a, p)
Definition: cpu_endian.h:286
@ NO_ERROR
Success.
Definition: error.h:44
#define SFTP_MODE_IFDIR
Definition: sftp_common.h:101
Debugging facilities.
#define SSH_FILEXFER_ATTR_UIDGID
Definition: sftp_common.h:51