scp_client.c File Reference

SCP client. More...

#include "ssh/ssh.h"
#include "ssh/ssh_connection.h"
#include "ssh/ssh_transport.h"
#include "ssh/ssh_request.h"
#include "scp/scp_client.h"
#include "scp/scp_client_misc.h"
#include "path.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   SCP_TRACE_LEVEL
 

Functions

error_t scpClientInit (ScpClientContext *context)
 Initialize SCP client context. More...
 
error_t scpClientRegisterSshInitCallback (ScpClientContext *context, ScpClientSshInitCallback callback)
 Register SSH initialization callback function. More...
 
error_t scpClientSetTimeout (ScpClientContext *context, systime_t timeout)
 Set communication timeout. More...
 
error_t scpClientBindToInterface (ScpClientContext *context, NetInterface *interface)
 Bind the SCP client to a particular network interface. More...
 
error_t scpClientConnect (ScpClientContext *context, const IpAddr *serverIpAddr, uint16_t serverPort)
 Establish a connection with the specified SCP server. More...
 
error_t scpClientOpenFileForWriting (ScpClientContext *context, const char_t *path, uint_t mode, uint64_t size)
 Open a file for writing. More...
 
error_t scpClientOpenFileForReading (ScpClientContext *context, const char_t *path, uint64_t *size)
 Open a file for reading. More...
 
error_t scpClientWriteFile (ScpClientContext *context, const void *data, size_t length, size_t *written, uint_t flags)
 Write to a remote file. More...
 
error_t scpClientReadFile (ScpClientContext *context, void *data, size_t size, size_t *received, uint_t flags)
 Read from a remote file. More...
 
error_t scpClientCloseFile (ScpClientContext *context)
 Close file. More...
 
error_t scpClientDisconnect (ScpClientContext *context)
 Gracefully disconnect from the SCP server. More...
 
error_t scpClientClose (ScpClientContext *context)
 Close the connection with the SCP server. More...
 
void scpClientDeinit (ScpClientContext *context)
 Release SCP client context. More...
 

Detailed Description

SCP 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.0

Definition in file scp_client.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   SCP_TRACE_LEVEL

Definition at line 32 of file scp_client.c.

Function Documentation

◆ scpClientBindToInterface()

error_t scpClientBindToInterface ( ScpClientContext context,
NetInterface interface 
)

Bind the SCP client to a particular network interface.

Parameters
[in]contextPointer to the SCP client context
[in]interfaceNetwork interface to be used
Returns
Error code

Definition at line 123 of file scp_client.c.

◆ scpClientClose()

error_t scpClientClose ( ScpClientContext context)

Close the connection with the SCP server.

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

Definition at line 1260 of file scp_client.c.

◆ scpClientCloseFile()

error_t scpClientCloseFile ( ScpClientContext context)

Close file.

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

Definition at line 996 of file scp_client.c.

◆ scpClientConnect()

error_t scpClientConnect ( ScpClientContext context,
const IpAddr serverIpAddr,
uint16_t  serverPort 
)

Establish a connection with the specified SCP server.

Parameters
[in]contextPointer to the SCP client context
[in]serverIpAddrIP address of the SCP server to connect to
[in]serverPortPort number
Returns
Error code

Definition at line 146 of file scp_client.c.

◆ scpClientDeinit()

void scpClientDeinit ( ScpClientContext context)

Release SCP client context.

Parameters
[in]contextPointer to the SCP client context

Definition at line 1281 of file scp_client.c.

◆ scpClientDisconnect()

error_t scpClientDisconnect ( ScpClientContext context)

Gracefully disconnect from the SCP server.

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

Definition at line 1161 of file scp_client.c.

◆ scpClientInit()

error_t scpClientInit ( ScpClientContext context)

Initialize SCP client context.

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

Definition at line 54 of file scp_client.c.

◆ scpClientOpenFileForReading()

error_t scpClientOpenFileForReading ( ScpClientContext context,
const char_t path,
uint64_t *  size 
)

Open a file for reading.

Parameters
[in]contextPointer to the SCP client context
[in]pathPath to the file to be be opened
[out]sizeSize of the file, in bytes (optional parameter)
Returns
Error code

Definition at line 504 of file scp_client.c.

◆ scpClientOpenFileForWriting()

error_t scpClientOpenFileForWriting ( ScpClientContext context,
const char_t path,
uint_t  mode,
uint64_t  size 
)

Open a file for writing.

Parameters
[in]contextPointer to the SCP client context
[in]pathPath to the file to be be opened
[in]modeFile permissions
[in]sizeSize of the file, in bytes
Returns
Error code

Definition at line 239 of file scp_client.c.

◆ scpClientReadFile()

error_t scpClientReadFile ( ScpClientContext context,
void *  data,
size_t  size,
size_t *  received,
uint_t  flags 
)

Read from a remote file.

Parameters
[in]contextPointer to the SCP client context
[out]dataBuffer where to store the incoming data
[in]sizeMaximum number of bytes that can be read
[out]receivedActual number of bytes that have been read
[in]flagsSet of flags that influences the behavior of this function
Returns
Error code

Definition at line 893 of file scp_client.c.

◆ scpClientRegisterSshInitCallback()

error_t scpClientRegisterSshInitCallback ( ScpClientContext context,
ScpClientSshInitCallback  callback 
)

Register SSH initialization callback function.

Parameters
[in]contextPointer to the SCP client context
[in]callbackSSH initialization callback function
Returns
Error code

Definition at line 80 of file scp_client.c.

◆ scpClientSetTimeout()

error_t scpClientSetTimeout ( ScpClientContext context,
systime_t  timeout 
)

Set communication timeout.

Parameters
[in]contextPointer to the SCP client context
[in]timeoutTimeout value, in milliseconds
Returns
Error code

Definition at line 102 of file scp_client.c.

◆ scpClientWriteFile()

error_t scpClientWriteFile ( ScpClientContext context,
const void *  data,
size_t  length,
size_t *  written,
uint_t  flags 
)

Write to a remote file.

Parameters
[in]contextPointer to the SCP client context
[in]dataPointer to a buffer containing the data to be written
[in]lengthNumber of data bytes to write
[in]writtenNumber of bytes that have been written (optional parameter)
[in]flagsSet of flags that influences the behavior of this function
Returns
Error code

Definition at line 771 of file scp_client.c.