original files of m241
This commit is contained in:
@@ -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
|
||||
****************************************************************************
|
||||
*/
|
||||
Reference in New Issue
Block a user