original files of m241

This commit is contained in:
neelimap
2026-07-30 11:19:44 +05:30
parent 170c2b3f3a
commit afc7070c1f
12254 changed files with 7655111 additions and 0 deletions
@@ -0,0 +1,535 @@
/* ipssh.h - Public API of Wind River SSH */
/*
******************************************************************************
* HEADER FILE
*
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipssh.h,v $ $Revision: 1.55.10.2 $
* $Source: /home/interpeak/CVSRoot/ipssh/include/ipssh.h,v $
* $Author: svc-cmnet $ $Date: 2013-03-13 07:45:43 $
* $State: Exp $ $Locker: $
*
* INTERPEAK_COPYRIGHT_STRING
* Design and implementation by Roger Boden <roger@interpeak.se>
******************************************************************************
*/
#ifndef IPSSH_H
#define IPSSH_H
/*
****************************************************************************
* 1 DESCRIPTION
****************************************************************************
*/
/*
DESCRIPTION
This library contains the API for Wind River SSH.
*/
/*
****************************************************************************
* 2 CONFIGURATION
****************************************************************************
*/
#include <ipssh_config.h>
/*
****************************************************************************
* 3 INCLUDE FILES
****************************************************************************
*/
#include <ipcom_sock.h>
#include <ipcom_list.h>
#include <ipcom_file.h>
#include <ipcom_shell.h>
#include <openssl/dsa.h>
#ifdef IPSSH_USE_RSA
#include <openssl/rsa.h>
#endif
#include <openssl/evp.h>
#include <openssl/hmac.h>
#ifdef __cplusplus
extern "C"
{
#endif
/*
****************************************************************************
* 4 DEFINES
****************************************************************************
*/
#define IPSSH_RELEASE 60900
#define IPSSH_HEX 1
#define IPSSH_BUBBLE_BABBLE 2
#define IPSSH_SFTP_ROOT_DIR (IPCOM_SHELL_CTX_IPSSH_BASE)
#define IPSSH_CLT_FD (IPCOM_SHELL_CTX_IPSSH_BASE + 1)
/*
****************************************************************************
* 5 TYPES
****************************************************************************
*/
/* Forward declaration */
struct Ipssh_conn_st;
typedef struct Ipssh_clt_info_st
{
char userid[32];
char service[16];
char clt_addr[40];
Ip_pid_t pid;
char auth_method[16];
char cipher [16];
char mac [16];
char ssh_clt_sw[32];
} Ipssh_clt_info;
#ifdef IPSSH_USE_SFTP
struct Ipssh_sftp_func_cb_st
{
char type[16];
/* File mgnt callbacks */
Ip_fd (*open_cb)(const char *pathname, int omode, Ip_mode_t attrs);
Ip_err (*close_cb)(Ip_fd fd);
Ip_err (*stat_cb)(const char* path, struct Ip_stat* buf);
Ip_ssize_t(*read_cb)(Ip_fd fd, char* data, Ip_size_t len);
Ip_ssize_t(*write_cb)(Ip_fd fd, const char* data, Ip_size_t len);
Ip_off_t (*lseek_cb)(Ip_fd fd, Ip_u64 offset, int whence);
/* Directory mgnt callbacks */
IP_DIR* (*opendir_cb)(const char* path);
int (*closedir_cb)(IP_DIR* dirp);
struct Ip_dirent* (*readdir_cb)(IP_DIR *dirp);
int (*mkdir_cb)(const char* path, Ip_mode_t mode);
int (*rmdir_cb)(const char* path);
int (*unlink_cb)(const char* path);
int (*rename_cb)(const char* oldpath, const char* newpath);
};
typedef struct Ipssh_sftp_func_cb_st Ipssh_sftp_func_cb;
#endif
/* Forward declarations */
struct Ipssh_channel_st;
union Ip_sockaddr_union;
typedef Ip_err (*Ipssh_subsystem_init_cb)(struct Ipssh_channel_st* channel, Ip_fd* sock);
/*
****************************************************************************
* 6 FUNCTIONS
****************************************************************************
*/
/*******************************************************************************
*
* ipssh_conn_new - create a new SSH connection handle
*
* This routine creates an SSH connection handle.
*
* RETURNS: A connection handle or 'IP_NULL', if the operation fails.
*
* ERRNO:
*/
IP_PUBLIC struct Ipssh_conn_st* ipssh_conn_new
(
void
);
IP_PUBLIC const char* ipssh_version(void);
/*******************************************************************************
*
* ipssh_stop_spawn - stop a spawned process
*
* DESCRIPTION
* This routine stops a spawned process.
*
* Parameter:
* \is
* \i <pid>
* The process ID of the process to stop.
* \ie
*
* RETURNS: 'IPCOM_SUCCESS' or 'IPCOM_ERR_NOT_INSTALLED,' if there is no spawned
* process with the given process ID.
*
* ERRNO:
*/
IP_PUBLIC Ip_err ipssh_stop_spawn
(
Ip_pid_t pid
);
/*******************************************************************************
*
* ipssh_stop_all_spawns - stop all spawned IPSSH tasks
*
* This routine stops all spawned IPSSH tasks. This is equivalent to logging out all
* users.
*
* Parameters:
*
* None.
*
* RETURNS: 'IPCOM_SUCCESS' or 'IPCOM_ERR_FAILED'
*
* ERRNO:
*/
IP_PUBLIC Ip_err ipssh_stop_all_spawns(void);
/*******************************************************************************
*
* ipssh_evp_pkey_cmp - compare two public keys
*
* This routine compares two public keys. It is a utility function to aid
* implementers of 'ipssh_validate_public_key'.
*
* Parameters:
* \is
* \i <key1>
* A pointer to the first public key to be used in the comparison.
* \i <key2>
* A pointer to the second public key to be used in the comparison.
* \ie
*
* RETURNS: 0, if keys are equal; non-zero, otherwise.
*
* ERRNO:
*/
IP_PUBLIC Ip_s32 ipssh_evp_pkey_cmp
(
EVP_PKEY* key1,
EVP_PKEY* key2
);
/*******************************************************************************
*
* ipssh_get_clt_info - return information on logged-in client
*
* This routine returns information on logged-in client.
*
* Parameters:
* \is
* \i <clt_info>
* A pointer to an 'Ipssh_clt_info' structure.
*
* \i <pos>
* An index value indicating the client for which information is being returned
* \ie
*
* RETURNS: 'IPCOM_SUCCESS', or 'IPCOM_ERR_NOT_FOUND', if <pos> exceeds the
* number of logged in clients.
*
* ERRNO:
*/
IP_PUBLIC Ip_err ipssh_get_clt_info
(
Ipssh_clt_info* clt_info,
int pos
);
/*******************************************************************************
*
* ipssh_key_fingerprint2 - generate a fingerprint of a public key
*
* Generates a fingerprint of a public key.
*
* Parameters:
* \is
* \i <key>
* Public key for which a fingerprint is to be generated.
* \i <key_type>
* The key type to generate a fingerprint of. Allowed values are: EVP_PKEY_DSA for SSHv2 DSA keys, EVP_PKEY_RSA for SSHv2 RSA keys and IPSSH_V1_RSA_ID for SSHv1 RSA keys.
* \i <fp>
* Pointer to a pointer to the generated fingerprint. This pointer must be freed
* by the caller.
* \i <fp_type>
* Specifies the type of fingerprint to generate. Two fingerprint formats are
* supported: 'IPSSH_HEXIP' and' SSH_BUBBLE_BABBLE'.
* \ie
*
* RETURNS: 'IPCOM_SUCCESS' if the fingerprint was generated, otherwise
* 'IPCOM_ERR_FAILED'.
*
* ERRNO:
*
*/
IP_PUBLIC Ip_err ipssh_key_fingerprint2
(
EVP_PKEY* key,
int key_type,
char** fp,
int fp_type
);
/*******************************************************************************
*
* ipssh_key_fingerprint - generate a fingerprint of a public key
*
* Deprecated, please use ipssh_key_fingerprint2. Generates a fingerprint of a public key.
*
* Parameters:
* \is
* \i <key>
* Public key for which a fingerprint is to be generated.
* \i <fp>
* Pointer to a pointer to the generated fingerprint. This pointer must be freed
* by the caller.
* \i <fp_type>
* Specifies the type of fingerprint to generate. Two fingerprint formats are
* supported: 'IPSSH_HEXIP' and' SSH_BUBBLE_BABBLE'.
* \ie
*
* RETURNS: 'IPCOM_SUCCESS' if the fingerprint was generated, otherwise
* 'IPCOM_ERR_FAILED'.
*
* ERRNO:
*
*/
IP_PUBLIC Ip_err ipssh_key_fingerprint
(
EVP_PKEY* key,
char** fp,
int fp_type
);
#ifdef IPSSH_USE_SFTP
/*******************************************************************************
*
* ipssh_get_sftp_func_cb - perform file operations on a specified file
*
* This callback routine is called once for each request for a file operation on
* a specific path. It returns a set of pointers to file-system routines that are
* called during the processing of the request. Note that a typical file
* operation, such as a get or a put operation, consists of several SFTP
* messages, so that a single file operation request may result in several calls
* to the routine pointers.
*
* Parameter:
* \is
* \i <path>
* The path to the file on which a file operation is to be performed.
* \ie
*
* RETURNS: A pointer to 'Ipssh_sftp_func_cb', which is defined as follows:
* \cs
* struct Ipssh_sftp_func_cb_st
* {
* char type[16];
* /@ File management callbacks @/
* Ip_fd (*open_cb)(const char *pathname, int omode, Ip_mode_t attrs);
* Ip_err (*close_cb)(Ip_fd fd);
* Ip_err (*stat_cb)(const char* path, struct Ip_stat* buf);
* int (*read_cb)(Ip_fd fd, char* data, Ip_size_t len);
* int (*write_cb)(Ip_fd fd, const char* data, Ip_size_t len);
* int (*lseek_cb)(Ip_fd fd, Ip_u64 offset, int whence);
* /@ Directory mgnt callbacks @/
* IP_DIR* (*opendir_cb)(const char* path);
* int (*closedir_cb)(IP_DIR* dirp);
* struct Ip_dirent* (*readdir_cb)(IP_DIR *dirp);
* int (*mkdir_cb)(const char* path, Ip_mode_t mode);
* int (*rmdir_cb)(const char* path);
* };
* typedef struct Ipssh_sftp_func_cb_st Ipssh_sftp_func_cb;
* \ce
*
* ERRNO:
*/
IP_PUBLIC Ipssh_sftp_func_cb* ipssh_get_sftp_file_func_cb
(
void
);
#endif
/*******************************************************************************
*
* ipssh_register_subsystem - register a subsystem init function
*
* Parameter:
* \is
* \i <subsystem_name>
* The name of the subsystem that init_cb will initialize
* \i <init_cb>
* function pointer to the init function of the subsystem
* \ie
*
* RETURNS: IPCOM_ERR_SUCCESS if successful. IPCOM_ERR_NO_MEMORY if not enough memory could be allocated. IPCOM_ERR_ALREADY_INSTALLED if there already is an init function registered for this subsystem name.
*/
IP_PUBLIC Ip_err ipssh_register_subsystem
(
const char* subsystem_name,
Ipssh_subsystem_init_cb init_cb
);
/*******************************************************************************
*
* ipssh_deregister_subsystem - deregister a subsystem init function
*
* Parameter:
* \is
* \i <subsystem_name>
* The name of the subsystem that init_cb will be removed for
* \ie
*
* RETURNS: IPCOM_ERR_SUCCESS if successful. IPCOM_ERR_NOT_FOUND if no init function is registered for this subsystem name
*/
IP_PUBLIC Ip_err ipssh_deregister_subsystem
(
const char* subsystem_name
);
IP_PUBLIC Ip_err ipssh_peer_addr_get
(
const struct Ipssh_channel_st* channel,
union Ip_sockaddr_union* peer_addr
);
IP_PUBLIC Ip_err ipssh_user_get
(
const struct Ipssh_channel_st* channel,
char* userid, int* userid_len
);
/* Subsystem client API */
/*******************************************************************************
*
* ipssh_subsystem_clt_open - open an SSH subsystem connection
*
*
* Parameter:
* \is
* \i <ssh_conn>
* Handle to the ssh connection context
* \i hostname
* hostname or IP address of the SSH server to connect to
* \i port
* TCP port to connect to
* \i subsystem
* name of the subsystem to invoke on the SSH server
* \ie
*
* RETURNS: number of bytes read, or -1 in case of error
*/
IP_PUBLIC Ip_err ipssh_subsystem_clt_open
(
struct Ipssh_conn_st* ssh_conn,
const char* hostname,
const Ip_u16 port,
const char* subsystem
);
/*******************************************************************************
*
* ipssh_subsystem_clt_read - read data from an SSH subsystem client connection
*
* This function reads data from an SSH subsystem client connection. The data are
* are carried in SSH_MSG_CHANNEL_DATA messages. In order to process a call a
* SSH_MSG_CHANNEL_DATA must be read in its entirity. This means that more data
* may be received from the peer, than the caller requests. In this case the
* extra data is cached and is returned in the next call to
* ipssh_subsystem_clt_read. Special attention must be payed when using select.
* Before select is called to wait for additional data, one must check that there
* is no cached data available by calling ipssh_subsystem_clt_pending_bytes.
*
* Parameter:
* \is
* \i <ssh_conn>
* Handle to the ssh connection context
* \i buf
* pointer to the buffer where the data shall be placed
* \i len
* number of bytes requested
* \i flags
* currently not used
* \ie
*
* RETURNS: number of bytes read, or -1 in case of error
*/
IP_PUBLIC Ip_ssize_t ipssh_subsystem_clt_read
(
struct Ipssh_conn_st* ssh_conn,
char* buf,
Ip_size_t len,
int flags
);
/*******************************************************************************
*
* ipssh_subsystem_clt_write - write data to an SSH subsystem client connection
*
* This function writes data to an SSH subsystem client connection.
*
* Parameter:
* \is
* \i <ssh_conn>
* Handle to the ssh connection context
* \i buf
* pointer to the buffer holding the data to be written
* \i len
* number of bytes to write
* \i flags
* currently not used
* \ie
*
* RETURNS: number of bytes written, or -1 in case of error
*/
IP_PUBLIC Ip_ssize_t ipssh_subsystem_clt_write
(
struct Ipssh_conn_st* ssh_conn,
void* buf,
Ip_size_t len,
int flags
);
IP_PUBLIC Ip_fd ipssh_conn_get_fd
(
struct Ipssh_conn_st* ssh_conn
);
/*******************************************************************************
*
* ipssh_subsystem_clt_pending_bytes - number of cached bytes read
*
* This function returns the number of cached bytes available in an SSH subsystem
* client connection.
*
* Parameter:
* \is
* \i <ssh_conn>
* Handle to the ssh connection context
* \ie
*
* RETURNS: number of cached bytes
*/
IP_PUBLIC Ip_size_t ipssh_subsystem_clt_pending_bytes
(
struct Ipssh_conn_st* ssh_conn
);
#ifdef __cplusplus
}
#endif
#endif
/*
****************************************************************************
* END OF FILE
****************************************************************************
*/
@@ -0,0 +1,690 @@
/* ipssh_sftp_clt.h - Public SFTP API of Wind River SSH */
/*
******************************************************************************
* INTERPEAK API HEADER FILE
*
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipssh_sftp_clt.h,v $ $Revision: 1.15.16.4 $
* $Source: /home/interpeak/CVSRoot/ipssh/include/ipssh_sftp_clt.h,v $
* $Author: jren $ $Date: 2017-12-13 02:42:24 $
* $State: Exp $ $Locker: $
*
* INTERPEAK_COPYRIGHT_STRING
* Design and implementation by Roger Boden <roger@interpeak.se>
******************************************************************************
*/
#ifndef IPSSH_SFTP_CLT_H
#define IPSSH_SFTP_CLT_H
/*
****************************************************************************
* 1 DESCRIPTION
****************************************************************************
*/
/*
DESCRIPTION
This library contains the SFTP API for Wind River SSH.
*/
/*
****************************************************************************
* 2 CONFIGURATION
****************************************************************************
*/
#include "ipssh_config.h"
/*
****************************************************************************
* 3 INCLUDE FILES
****************************************************************************
*/
#include <ipcom_type.h>
#include <ipcom_cstyle.h>
#include <ipcom_err.h>
#include <ipcom_list.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
****************************************************************************
* 4 DEFINES
****************************************************************************
*/
/* File open and creation flags */
#define IPSSH_FXF_READ 0x00000001
#define IPSSH_FXF_WRITE 0x00000002
#define IPSSH_FXF_APPEND 0x00000004
#define IPSSH_FXF_CREAT 0x00000008
#define IPSSH_FXF_TRUNC 0x00000010
#define IPSSH_FXF_EXCL 0x00000020
/*
****************************************************************************
* 5 TYPES
****************************************************************************
*/
/* Forward declarations */
struct Ipssh_conn_st;
struct Ipssh_dirent_st
{
char name[256];
char longname[256];
struct Ip_stat attr;
};
typedef struct Ipssh_dirent_st Ipssh_dirent;
/*
****************************************************************************
* 6 FUNCTIONS
****************************************************************************
*/
/*******************************************************************************
*
* ipssh_sftp_clt_open - open a connection to an SFTP server
*
* This routine establishes a connection to an SFTP server.
*
* Parameters:
* \is
* \i <ssh_conn>
* Connection handle.
* \i <hostname>
* Host name or IP address of the SFTP server.
* \i <port>
* Port on which the SFTP server listens.
* \ie
*
* RETURNS: 'IPCOM_SUCCESS' or one of the following errors:
* \is
* \i 'IPCOM_ERR_INVALID_ARG'
* Arguments are bad; for example, no authentication data set.
* \i 'IPCOM_ERR_AUTH_FAILED'
* Server rejected the login request.
* \i 'IPCOM_ERR_FAILED'
* Connection could not be established.
* \ie
*
* ERRNO:
*/
IP_PUBLIC Ip_err ipssh_sftp_clt_open
(
struct Ipssh_conn_st* ssh_conn,
const char* hostname,
Ip_u16 port
);
/*******************************************************************************
*
* ipssh_sftp_clt_get - get a file from the server
*
* This routine transfers a file from the SFTP server to the local file system.
*
* Parameters:
* \is
* \i <ssh_conn>
* A handle to the connection.
* \i <src_path>
* The path to the source file on the SFTP server.
* \i <dst_path>
* The Path to the destination file on the local file system.
* \ie
*
* RETURNS: 'IPCOM_SUCCESS' or one of the following errors:
* \is
* \i 'IPCOM_ERR_INVALID_ARGS'
* invalid input parameters.
* \i 'IPCOM_ERR_NOT_FOUND'
* The file does not exist on the SFTP server.
* \i 'IPCOM_ERR_PERMISSION_DENIED'
* Insufficient permission to access file on SFTP server.
* \i 'IPCOM_ERR_FAILED'
* Operation failed.
* \ie
*
* ERRNO:
*/
IP_PUBLIC Ip_err ipssh_sftp_clt_get
(
struct Ipssh_conn_st* ssh_conn,
const char* src_path,
const char* dst_path
);
/*******************************************************************************
*
* ipssh_sftp_clt_put - transfer a file to the server
*
* This routine transfers a file from the local file system to the SFTP server.
*
* Parameters:
* \is
* \i <ssh_conn>
* A handle to the connection.
* \i <src_path>
* The path to the source file on the local file system.
* \i <dst_path>
* The path to the destination file on the SFTP server.
* \ie
*
* RETURNS: 'IPCOM_SUCCESS' or one of the following errors:
* \is
* \i 'IPCOM_ERR_INVALID_ARGS'
* invalid input parameters.
* \i 'IPCOM_ERR_NOT_FOUND'
* File does not exist on the SFTP server.
* \i 'IPCOM_ERR_PERMISSION_DENIED'
* Insufficient permission to access file on SFTP server.
* \i 'IPCOM_ERR_FAILED'
* Operation failed.
* \ie
*
* ERRNO:
*/
IP_PUBLIC Ip_err ipssh_sftp_clt_put
(
struct Ipssh_conn_st* ssh_conn,
const char* src_path,
const char* dst_path
);
/*******************************************************************************
*
* ipssh_sftp_clt_put_flags - transfer a file to the server
*
* This routine transfers a file from the local file system to the SFTP server.
*
* Parameters:
* \is
* \i <ssh_conn>
* A handle to the connection.
* \i <src_path>
* The path to the source file on the local file system.
* \i <dst_path>
* The path to the destination file on the SFTP server.
* \i <dst_path_flags>
* File open flags for the destination file on the SFTP server.
* \ie
*
* RETURNS: 'IPCOM_SUCCESS' or one of the following errors:
* \is
* \i 'IPCOM_ERR_INVALID_ARGS'
* invalid input parameters.
* \i 'IPCOM_ERR_NOT_FOUND'
* File does not exist on the SFTP server.
* \i 'IPCOM_ERR_PERMISSION_DENIED'
* Insufficient permission to access file on SFTP server.
* \i 'IPCOM_ERR_FAILED'
* Operation failed.
* \ie
*
* ERRNO:
*/
IP_PUBLIC Ip_err ipssh_sftp_clt_put_flags
(
struct Ipssh_conn_st* ssh_conn,
const char* src_path,
const char* dst_path,
Ip_u32 dst_path_flags
);
/*******************************************************************************
*
* ipssh_sftp_clt_close - close a connection
*
* Disconnects an SFTP connection and frees all resources tied to the connection.
*
* Parameters:
* \is
* \i <ssh_conn>
* A handle to the connection.
* \ie
*
* RETURNS: 'IPCOM_SUCCESS' or an error code (see 'ipcom_err.h').
*
* ERRNO:
*/
IP_PUBLIC Ip_err ipssh_sftp_clt_close
(
struct Ipssh_conn_st* ssh_conn
);
/*******************************************************************************
*
* ipssh_sftp_clt_set_userid - set user ID for authentication
*
* This routine sets the user ID to be used for authenticating to the SFTP
* server.
*
* Parameters:
* \is
* \i <ssh_conn>
* A handle to the connection.
* \i <user>
* User ID to be used for authentication.
* \ie
*
* RETURNS: 'IPCOM_SUCCESS' or the following error:
* \is
* \i 'IPCOM_ERR_INVALID_ARG'
* User ID is too long.
* \ie
*
* ERRNO:
*/
IP_PUBLIC Ip_err ipssh_sftp_clt_set_userid
(
struct Ipssh_conn_st* ssh_conn,
const char* user
);
/*******************************************************************************
*
* ipssh_sftp_clt_set_pw - set password for authentication
*
* This routine sets the password to be used for authenticating to the SFTP
* server.
*
* Parameters:
* \is
* \i <ssh_conn>
* A handle to the connection.
* \i <pw>
* The password to be used for authentication.
* \ie
*
* RETURNS: 'IPCOM_SUCCESS' or the following error:
* \is
* \i 'IPCOM_ERR_INVALID_ARG'
* Password is too long.
* \ie
*
* ERRNO:
*/
IP_PUBLIC Ip_err ipssh_sftp_clt_set_pw
(
struct Ipssh_conn_st* ssh_conn,
const char* pw
);
/*******************************************************************************
*
* ipssh_sftp_clt_set_key - set key pair for publickey authentication
*
* This routine sets the key pair that will be used for publickey authenticating to the
* SFTP server. The reference counter of the key is incremented. RSA and DSA key
* pairs are currently supported.
*
* Parameters:
* \is
* \i <ssh_conn>
* A handle to the connection.
* \i <key>
* Key pair.
* \ie
*
* RETURNS: 'IPCOM_SUCCESS' or an error code (see 'ipcom_err.h').
*
* ERRNO:
*/
IP_PUBLIC Ip_err ipssh_sftp_clt_set_key
(
struct Ipssh_conn_st* ssh_conn,
EVP_PKEY* key
);
/*******************************************************************************
*
* ipssh_sftp_clt_set_hostb_key - set key pair for hostbased authentication
*
* This routine sets the key pair that will be used for hostbased authenticating to the
* SFTP server. The reference counter of the key is incremented. RSA and DSA key
* pairs are currently supported.
*
* Parameters:
* \is
* \i <ssh_conn>
* A handle to the connection.
* \i <key>
* Key pair.
* \ie
*
* RETURNS: 'IPCOM_SUCCESS' or an error code (see 'ipcom_err.h').
*
* ERRNO:
*/
IP_PUBLIC Ip_err ipssh_sftp_clt_set_hostb_key
(
struct Ipssh_conn_st* ssh_conn,
EVP_PKEY* key
);
/*******************************************************************************
*
* ipssh_sftp_clt_get_realpath - convert a relative path to an absolute path
*
* This routine converts a relative path on the server into an absolute path.
* This is useful for converting a path containing .. or a relative pathname
* without a leading slash into an absolute path.
*
* Parameters:
* \is
* \i <ssh_conn>
* A handle to the connection.
* \i <path>
* The relative path to be converted.
* \i <buf>
* The buffer for holding the returned path.
* \i <buf_len>
* The length of the buffer, in bytes.
* \ie
*
* RETURNS: 'IPCOM_SUCCESS' or one of the following errors:
* \is
* \i 'IPCOM_ERR_INVALID_ARGS'
* Buffer is too small to contain the returned path.
* \i 'IPCOM_ERR_FAILED'
* Communication with server failed.
* \ie
*
* ERRNO:
*/
IP_PUBLIC Ip_err ipssh_sftp_clt_get_realpath
(
struct Ipssh_conn_st* ssh_conn,
const char* path,
char* buf,
int buf_len
);
/*******************************************************************************
*
* ipssh_sftp_clt_get_cwd - get current working directory on the server
*
* This routine returns the current working directory on the SFTP server.
*
* Parameters:
* \is
* \i <ssh_conn>
* A handle to the connection.
* \i <buf>
* The buffer for holding the returned directory name.
* \i <buf_len>
* The length of the buffer, in bytes.
* \ie
*
* RETURNS: 'IPCOM_SUCCESS' or one of the following errors:
* \is
* \i 'IPCOM_ERR_INVALID_ARGS'
* Buffer is too small to contain the returned directory name.
* \i 'IPCOM_ERR_FAILED'
* Communication with server failed.
* \ie
*
* ERRNO:
*/
IP_PUBLIC Ip_err ipssh_sftp_clt_get_cwd
(
struct Ipssh_conn_st* ssh_conn,
char* buf,
int buf_len
);
/*******************************************************************************
*
* ipssh_sftp_clt_chdir - change current working directory on the server
*
* This routine changes the current working directory on the SFTP server.
*
* Parameters:
* \is
* \i <ssh_conn>
* A handle to the connection.
* \i <path>
* The path to the new working directory, either relative or absolute.
* \ie
*
* RETURNS: 'IPCOM_SUCCESS' or the following error:
* \is
* \i 'IPCOM_ERR_FAILED'
* Working directory not updated.
* \ie
*
* ERRNO:
*/
IP_PUBLIC Ip_err ipssh_sftp_clt_chdir
(
struct Ipssh_conn_st* ssh_conn,
const char* path
);
/*******************************************************************************
*
* ipssh_sftp_clt_mkdir - create a directory on the server
*
* This routine creates a directory on the remote server.
*
* Parameters:
* \is
* \i <ssh_conn>
* A handle to the connection.
* \i <path>
* The path to the directory to be created.
* \i <mode>
* An integer specifying the file privileges that apply to the directory.
* The integer is usually expressed as an octal value, read (4), write (2) and
* execute (1). These values can be combined, e.g. 6 means read and write
* permission. Three octal value are used to express the priviliges for the
* user, group and others, respectively. For example 0644 means the user has
* read and write privileges, the group has read privileges and
* others have read privileges.
* \ie
*
* RETURNS: 'IPCOM_SUCCESS' if the directory was created.
*
* ERRNO:
*/
IP_PUBLIC Ip_err ipssh_sftp_clt_mkdir
(
struct Ipssh_conn_st* ssh_conn,
const char* path,
Ip_mode_t mode
);
/*******************************************************************************
*
* ipssh_sftp_clt_rmdir - delete a directory on the server
*
* The routine deletes a directory on the remote server.
*
* Parameters:
* \is
* \i <ssh_conn>
* A handle to the connection.
* \i <path>
* The path to the directory to be deleted.
* \ie
*
* RETURNS: 'IPCOM_SUCCESS', if the directory was deleted. [* What if not
* deleted--e.g., insufficient privilege]
*
* ERRNO:
*/
IP_PUBLIC Ip_err ipssh_sftp_clt_rmdir
(
struct Ipssh_conn_st* ssh_conn,
const char* path
);
/*******************************************************************************
*
* ipssh_sftp_clt_opendir - open a directory stream on a server
*
* This routine opens a directory stream for a specified directory. The stream is
* positioned at the first entry in the directory.
*
* Parameters:
* \is
* \i <ssh_conn>
* A handle to the connection.
* \i <path>
* The path to the directory.
* \ie
*
* RETURNS: A pointer to the directory stream, or 'IP_NULL' if the operation
* failed.
*
* ERRNO:
*/
IP_PUBLIC void* ipssh_sftp_clt_opendir
(
struct Ipssh_conn_st* ssh_conn,
const char* path
);
/*******************************************************************************
*
* ipssh_sftp_clt_readdir - read the next directory entry on the server
*
* This routine returns a pointer to an 'ipssh_dirent' structure containing the
* next directory entry in the specified directory stream.
*
* Parameters:
* \is
* \i <ssh_conn>
* A handle to the connection.
* \i <handle>
* A handle to the directory stream.
* \ie
*
* RETURNS: A pointer to an 'ipssh_dirent' structure, or 'IP_NULL' if the last
* entry has been read.
*
* ERRNO:
*/
IP_PUBLIC Ipssh_dirent* ipssh_sftp_clt_readdir
(
struct Ipssh_conn_st* ssh_conn,
void* handle
);
/*******************************************************************************
*
* ipssh_sftp_clt_closedir - close a directory stream on the server
*
* This routine closes a directory stream that was opened with
* ipssh_sftp_clt_opendir().
*
* Parameters:
* \is
* \i <ssh_conn>
* A handle to the connection.
* \i <handle>
* A handle to the directory stream to be closed.
* \ie
*
* RETURNS: 'IPCOM_SUCCESS' or the following error:
* \is
* \i 'IPCOM_ERR_FAILED'
* Communication with the SFTP server failed.
* \ie
*
* ERRNO:
*/
IP_PUBLIC Ip_err ipssh_sftp_clt_closedir
(
struct Ipssh_conn_st* ssh_conn,
void* handle
);
/*******************************************************************************
*
* ipssh_sftp_clt_rename - rename a file on the server
*
* This routine renames a file on the server.
*
* Parameters:
* \is
* \i <ssh_conn>
* A handle to the connection.
* \i oldpath
* path to the file to be renamed
* \i newpath
* new path for the renamed file
* \ie
*
* RETURNS: 'IPCOM_SUCCESS' or one of the following errors:
* \is
* \i 'IPCOM_ERR_NOT_FOUND'
* File not found on SFTP server.
* \i 'IPCOM_ERR_PERMISSION_DENIED'
* Insufficient privileges to rename file.
* \i 'IPCOM_ERR_FAILED'
* Communication with SFTP server failed.
* \ie
*
* ERRNO:
*/
IP_PUBLIC Ip_err ipssh_sftp_clt_rename
(
struct Ipssh_conn_st* ssh_conn,
const char* oldpath,
const char* newpath
);
/*******************************************************************************
*
* ipssh_sftp_clt_unlink - delete a file on the server
*
* This routine deletes a file from the server.
*
* Parameters:
* \is
* \i <ssh_conn>
* A handle to the connection.
* \ie
*
* RETURNS: 'IPCOM_SUCCESS' or one of the following errors:
* \is
* \i 'IPCOM_ERR_NOT_FOUND'
* File not found on SFTP server.
* \i 'IPCOM_ERR_PERMISSION_DENIED'
* Insufficient privileges to remove file.
* \i 'IPCOM_ERR_FAILED'
* Communication with SFTP server failed.
* \ie
*
* ERRNO:
*/
IP_PUBLIC Ip_err ipssh_sftp_clt_unlink
(
struct Ipssh_conn_st* ssh_conn,
const char* path
);
#ifdef __cplusplus
}
#endif
#endif
/*
****************************************************************************
* END OF FILE
****************************************************************************
*/