sftp_common.c File Reference

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

#include "ssh/ssh.h"
#include "ssh/ssh_misc.h"
#include "sftp/sftp_common.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   SFTP_TRACE_LEVEL
 

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-2024 Oryx Embedded SARL. All rights reserved.

This file is part of CycloneTCP 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_common.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   SFTP_TRACE_LEVEL

Definition at line 32 of file sftp_common.c.

Function Documentation

◆ sftpConvertFileTypeToPerm()

uint32_t sftpConvertFileTypeToPerm ( SftpFileType  type)

Convert file type to permission bits.

Parameters
[in]typeFile 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]permissionsPermission 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]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 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]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 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]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 370 of file sftp_common.c.