sftp_client_misc.c File Reference

Helper functions for SFTP client. More...

#include "ssh/ssh.h"
#include "ssh/ssh_connection.h"
#include "ssh/ssh_request.h"
#include "ssh/ssh_misc.h"
#include "sftp/sftp_client.h"
#include "sftp/sftp_client_packet.h"
#include "sftp/sftp_client_misc.h"
#include "path.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   SFTP_TRACE_LEVEL
 

Functions

void sftpClientChangeState (SftpClientContext *context, SftpClientState newState)
 Update SFTP client state. More...
 
error_t sftpClientOpenConnection (SftpClientContext *context)
 Open SSH connection. More...
 
error_t sftpClientEstablishConnection (SftpClientContext *context)
 Establish SSH connection. More...
 
void sftpClientCloseConnection (SftpClientContext *context)
 Close SSH connection. More...
 
error_t sftpClientSendCommand (SftpClientContext *context)
 Send SFTP request and wait for a response. More...
 
error_t sftpClientProcessEvents (SftpClientContext *context)
 Process SFTP client events. More...
 
error_t sftpClientParsePacketLength (SftpClientContext *context, const uint8_t *packet)
 Retrieve the length of an incoming SFTP packet. More...
 
error_t sftpClientParsePacket (SftpClientContext *context, const uint8_t *packet, size_t fragLen, size_t totalLen)
 SFTP packet processing. More...
 
error_t sftpClientCheckTimeout (SftpClientContext *context)
 Determine whether a timeout error has occurred. More...
 
error_t sftpFormatPath (SftpClientContext *context, const char_t *path, uint8_t *p, size_t *written)
 Format pathname. More...
 
void sftpGetAbsolutePath (SftpClientContext *context, const char_t *path, char_t *fullPath)
 Retrieve the full pathname. More...
 

Detailed Description

Helper functions for SFTP client.

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.4

Definition in file sftp_client_misc.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   SFTP_TRACE_LEVEL

Definition at line 32 of file sftp_client_misc.c.

Function Documentation

◆ sftpClientChangeState()

void sftpClientChangeState ( SftpClientContext context,
SftpClientState  newState 
)

Update SFTP client state.

Parameters
[in]contextPointer to the SFTP client context
[in]newStateNew state to switch to

Definition at line 55 of file sftp_client_misc.c.

◆ sftpClientCheckTimeout()

error_t sftpClientCheckTimeout ( SftpClientContext context)

Determine whether a timeout error has occurred.

Parameters
[in]contextPointer to the SFTP client context
Returns
Error code

Definition at line 630 of file sftp_client_misc.c.

◆ sftpClientCloseConnection()

void sftpClientCloseConnection ( SftpClientContext context)

Close SSH connection.

Parameters
[in]contextPointer to the SFTP client context

Definition at line 295 of file sftp_client_misc.c.

◆ sftpClientEstablishConnection()

error_t sftpClientEstablishConnection ( SftpClientContext context)

Establish SSH connection.

Parameters
[in]contextPointer to the SFTP client context
Returns
Error code

Definition at line 141 of file sftp_client_misc.c.

◆ sftpClientOpenConnection()

error_t sftpClientOpenConnection ( SftpClientContext context)

Open SSH connection.

Parameters
[in]contextPointer to the SFTP client context
Returns
Error code

Definition at line 72 of file sftp_client_misc.c.

◆ sftpClientParsePacket()

error_t sftpClientParsePacket ( SftpClientContext context,
const uint8_t *  packet,
size_t  fragLen,
size_t  totalLen 
)

SFTP packet processing.

Parameters
[in]contextPointer to the SFTP client context
[in]packetPointer to received SFTP packet
[in]fragLenNumber of bytes available on hand
[in]totalLenTotal length of the packet, in bytes
Returns
Error code

Definition at line 552 of file sftp_client_misc.c.

◆ sftpClientParsePacketLength()

error_t sftpClientParsePacketLength ( SftpClientContext context,
const uint8_t *  packet 
)

Retrieve the length of an incoming SFTP packet.

Parameters
[in]contextPointer to the SFTP client context
[in]packetPointer to received SFTP packet
Returns
Error code

Definition at line 484 of file sftp_client_misc.c.

◆ sftpClientProcessEvents()

error_t sftpClientProcessEvents ( SftpClientContext context)

Process SFTP client events.

Parameters
[in]contextPointer to the SFTP client context
Returns
Error code

Definition at line 409 of file sftp_client_misc.c.

◆ sftpClientSendCommand()

error_t sftpClientSendCommand ( SftpClientContext context)

Send SFTP request and wait for a response.

Parameters
[in]contextPointer to the SFTP client context
Returns
Error code

Definition at line 315 of file sftp_client_misc.c.

◆ sftpFormatPath()

error_t sftpFormatPath ( SftpClientContext context,
const char_t path,
uint8_t *  p,
size_t *  written 
)

Format pathname.

Parameters
[in]contextPointer to the SFTP client context
[in]pathNULL-terminated string that contains the pathname
[out]pOutput stream where to write the string
[out]writtenTotal number of bytes that have been written
Returns
Error code

Definition at line 669 of file sftp_client_misc.c.

◆ sftpGetAbsolutePath()

void sftpGetAbsolutePath ( SftpClientContext context,
const char_t path,
char_t fullPath 
)

Retrieve the full pathname.

Parameters
[in]contextPointer to the SFTP client context
[in]pathAbsolute or relative path
[in]fullPathOutput buffer where to store the resulting full pathname

Definition at line 699 of file sftp_client_misc.c.