Helper functions for SFTP server. More...
#include "ssh/ssh.h"
#include "ssh/ssh_request.h"
#include "ssh/ssh_misc.h"
#include "sftp/sftp_server.h"
#include "sftp/sftp_server_file.h"
#include "sftp/sftp_server_directory.h"
#include "sftp/sftp_server_packet.h"
#include "sftp/sftp_server_misc.h"
#include "str.h"
#include "path.h"
#include "debug.h"
Go to the source code of this file.
Macros | |
#define | TRACE_LEVEL SFTP_TRACE_LEVEL |
Functions | |
void | sftpServerTick (SftpServerContext *context) |
Handle periodic operations. More... | |
error_t | sftpServerChannelRequestCallback (SshChannel *channel, const SshString *type, const uint8_t *data, size_t length, void *param) |
SSH channel request callback. More... | |
SftpServerSession * | sftpServerFindSession (SftpServerContext *context, SshChannel *channel) |
Find the SFTP session that matches a given SSH channel. More... | |
SftpServerSession * | sftpServerOpenSession (SftpServerContext *context, SshChannel *channel) |
Open a new SFTP session. More... | |
void | sftpServerCloseSession (SftpServerSession *session) |
Close an SFTP session. More... | |
void | sftpServerRegisterSessionEvents (SftpServerSession *session, SshChannelEventDesc *eventDesc) |
Register session events. More... | |
void | sftpServerProcessSessionEvents (SftpServerSession *session) |
Session event handler. More... | |
error_t | sftpServerParsePacketLength (SftpServerSession *session, const uint8_t *packet) |
Retrieve the length of an incoming SFTP packet. More... | |
error_t | sftpServerParsePacket (SftpServerSession *session, const uint8_t *packet, size_t fragLen, size_t totalLen) |
SFTP packet processing. More... | |
uint32_t | sftpServerGenerateHandle (SftpServerSession *session) |
Generate a unique handle. More... | |
uint_t | sftpServerGetFilePermissions (SftpServerSession *session, const char_t *path) |
Get permissions for the specified file or directory. More... | |
error_t | sftpServerGetPath (SftpServerSession *session, const SshString *path, char_t *fullPath, size_t maxLen) |
Retrieve the full pathname. More... | |
const char_t * | sftpServerStripRootDir (SftpServerSession *session, const char_t *path) |
Strip root dir from specified pathname. More... | |
Detailed Description
Helper functions for SFTP 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 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.4.4
Definition in file sftp_server_misc.c.
Macro Definition Documentation
◆ TRACE_LEVEL
#define TRACE_LEVEL SFTP_TRACE_LEVEL |
Definition at line 32 of file sftp_server_misc.c.
Function Documentation
◆ sftpServerChannelRequestCallback()
error_t sftpServerChannelRequestCallback | ( | SshChannel * | channel, |
const SshString * | type, | ||
const uint8_t * | data, | ||
size_t | length, | ||
void * | param | ||
) |
SSH channel request callback.
- Parameters
-
[in] channel Handle referencing an SSH channel [in] type Request type [in] data Request-specific data [in] length Length of the request-specific data, in bytes [in] param Pointer to the SFTP server context
- Returns
- Error code
Definition at line 71 of file sftp_server_misc.c.
◆ sftpServerCloseSession()
void sftpServerCloseSession | ( | SftpServerSession * | session | ) |
Close an SFTP session.
- Parameters
-
[in] session Handle referencing an SFTP session
Definition at line 246 of file sftp_server_misc.c.
◆ sftpServerFindSession()
SftpServerSession* sftpServerFindSession | ( | SftpServerContext * | context, |
SshChannel * | channel | ||
) |
Find the SFTP session that matches a given SSH channel.
- Parameters
-
[in] context Pointer to the SFTP server context [in] channel Handle referencing an SSH channel
- Returns
- Pointer to the matching SFTP session
Definition at line 165 of file sftp_server_misc.c.
◆ sftpServerGenerateHandle()
uint32_t sftpServerGenerateHandle | ( | SftpServerSession * | session | ) |
Generate a unique handle.
- Parameters
-
[in] session Handle referencing an SFTP session
- Returns
- Handle value
Definition at line 803 of file sftp_server_misc.c.
◆ sftpServerGetFilePermissions()
uint_t sftpServerGetFilePermissions | ( | SftpServerSession * | session, |
const char_t * | path | ||
) |
Get permissions for the specified file or directory.
- Parameters
-
[in] session Handle referencing an SFTP session [in] path Canonical path of the file
- Returns
- Access rights for the specified file
Definition at line 852 of file sftp_server_misc.c.
◆ sftpServerGetPath()
error_t sftpServerGetPath | ( | SftpServerSession * | session, |
const SshString * | path, | ||
char_t * | fullPath, | ||
size_t | maxLen | ||
) |
Retrieve the full pathname.
- Parameters
-
[in] session Handle referencing an SFTP session [in] path Relative or absolute path [out] fullPath Resulting full path [in] maxLen Maximum acceptable path length
- Returns
- Error code
Definition at line 905 of file sftp_server_misc.c.
◆ sftpServerOpenSession()
SftpServerSession* sftpServerOpenSession | ( | SftpServerContext * | context, |
SshChannel * | channel | ||
) |
Open a new SFTP session.
- Parameters
-
[in] context Pointer to the SFTP server context [in] channel Handle referencing an SSH channel
- Returns
- Pointer to the newly created SFTP session
Definition at line 200 of file sftp_server_misc.c.
◆ sftpServerParsePacket()
error_t sftpServerParsePacket | ( | SftpServerSession * | session, |
const uint8_t * | packet, | ||
size_t | fragLen, | ||
size_t | totalLen | ||
) |
SFTP packet processing.
- Parameters
-
[in] session Handle referencing an SFTP session [in] packet Pointer to the received SFTP packet [in] fragLen Number of bytes available on hand [in] totalLen Total length of the packet, in bytes
- Returns
- Error code
Definition at line 635 of file sftp_server_misc.c.
◆ sftpServerParsePacketLength()
error_t sftpServerParsePacketLength | ( | SftpServerSession * | session, |
const uint8_t * | packet | ||
) |
Retrieve the length of an incoming SFTP packet.
- Parameters
-
[in] session Handle referencing an SFTP session [in] packet Pointer to received SFTP packet
- Returns
- Error code
Definition at line 574 of file sftp_server_misc.c.
◆ sftpServerProcessSessionEvents()
void sftpServerProcessSessionEvents | ( | SftpServerSession * | session | ) |
Session event handler.
- Parameters
-
[in] session Handle referencing an SFTP session
Definition at line 384 of file sftp_server_misc.c.
◆ sftpServerRegisterSessionEvents()
void sftpServerRegisterSessionEvents | ( | SftpServerSession * | session, |
SshChannelEventDesc * | eventDesc | ||
) |
Register session events.
- Parameters
-
[in] session Handle referencing an SFTP session [in] eventDesc SSH channel events to be registered
Definition at line 302 of file sftp_server_misc.c.
◆ sftpServerStripRootDir()
const char_t* sftpServerStripRootDir | ( | SftpServerSession * | session, |
const char_t * | path | ||
) |
Strip root dir from specified pathname.
- Parameters
-
[in] session Handle referencing an SFTP session [in] path input pathname
- Returns
- Resulting pathname with root dir stripped
Definition at line 971 of file sftp_server_misc.c.
◆ sftpServerTick()
void sftpServerTick | ( | SftpServerContext * | context | ) |
Handle periodic operations.
- Parameters
-
[in] context Pointer to the SFTP server context
Definition at line 56 of file sftp_server_misc.c.