sftp_server_misc.h File Reference

Helper functions for SFTP server. More...

#include "sftp/sftp_server.h"

Go to the source code of this file.

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...
 
SftpServerSessionsftpServerFindSession (SftpServerContext *context, SshChannel *channel)
 Find the SFTP session that matches a given SSH channel. More...
 
SftpServerSessionsftpServerOpenSession (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_tsftpServerStripRootDir (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.

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
2.4.0

Definition in file sftp_server_misc.h.

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]channelHandle referencing an SSH channel
[in]typeRequest type
[in]dataRequest-specific data
[in]lengthLength of the request-specific data, in bytes
[in]paramPointer 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]sessionHandle 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]contextPointer to the SFTP server context
[in]channelHandle 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]sessionHandle 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]sessionHandle referencing an SFTP session
[in]pathCanonical 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]sessionHandle referencing an SFTP session
[in]pathRelative or absolute path
[out]fullPathResulting full path
[in]maxLenMaximum 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]contextPointer to the SFTP server context
[in]channelHandle 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]sessionHandle referencing an SFTP session
[in]packetPointer to the received SFTP packet
[in]fragLenNumber of bytes available on hand
[in]totalLenTotal 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]sessionHandle referencing an SFTP session
[in]packetPointer 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]sessionHandle 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]sessionHandle referencing an SFTP session
[in]eventDescSSH 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]sessionHandle referencing an SFTP session
[in]pathinput 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]contextPointer to the SFTP server context

Definition at line 56 of file sftp_server_misc.c.