ZOO-Project
Data Structures | Macros | Functions | Variables
sshapi.h File Reference
#include <libssh2.h>
#include <libssh2_sftp.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h>
#include <ctype.h>
#include <time.h>
#include "service.h"

Go to the source code of this file.

Data Structures

struct  SSHCON
 

Macros

#define MAX_PARALLEL_SSH_CON   128
 

Functions

ZOO_DLL_EXPORT SSHCONssh_connect (maps *)
 Connect to a remote host using SSH protocol. More...
 
ZOO_DLL_EXPORT bool ssh_copy (maps *, const char *, const char *, int)
 Upload a file over an opened SSH connection. More...
 
ZOO_DLL_EXPORT int ssh_get_cnt (maps *)
 Get the number of opened SSH connections. More...
 
ZOO_DLL_EXPORT int ssh_fetch (maps *, const char *, const char *, int)
 Download a file over an opened SSH connection. More...
 
ZOO_DLL_EXPORT int ssh_exec (maps *, const char *, int)
 Execute a command over an opened SSH connection. More...
 
ZOO_DLL_EXPORT bool ssh_close_session (maps *, SSHCON *)
 Close an opened SSH connection. More...
 
ZOO_DLL_EXPORT bool ssh_close (maps *)
 Close all the opened SSH connections. More...
 
ZOO_DLL_EXPORT bool addToUploadQueue (maps **, maps *)
 
ZOO_DLL_EXPORT bool runUpload (maps **)
 

Variables

static int nb_sessions
 

Data Structure Documentation

struct SSHCON
Data Fields
int index
LIBSSH2_SESSION * session
LIBSSH2_SFTP * sftp_session
int sock_id

Macro Definition Documentation

#define MAX_PARALLEL_SSH_CON   128

Function Documentation

ZOO_DLL_EXPORT bool addToUploadQueue ( maps **  ,
maps  
)
ZOO_DLL_EXPORT bool runUpload ( maps **  )
ZOO_DLL_EXPORT bool ssh_close ( maps conf)

Close all the opened SSH connections.

Parameters
confmaps pointer to the main configuration maps
Returns
true in case of success, false if failure occured
ZOO_DLL_EXPORT bool ssh_close_session ( maps conf,
SSHCON con 
)

Close an opened SSH connection.

Parameters
confmaps pointer to the main configuration maps
conSSHCON pointer to the SSH connection
Returns
true in case of success, false if failure occured
ZOO_DLL_EXPORT SSHCON* ssh_connect ( maps conf)

Connect to a remote host using SSH protocol.

Parameters
confmaps The main configuration maps
Returns
the libssh2 sessions pointer or NULL in case any failure occured.
ZOO_DLL_EXPORT bool ssh_copy ( maps conf,
const char *  localPath,
const char *  targetPath,
int  cnt 
)

Upload a file over an opened SSH connection.

Parameters
confmaps pointer to the main configuration maps
localPathconst char* defining the local path for accessing the file
targetPathconst char* defining the path for storing the file on the remote host
Returns
true in case of success, false if failure occured
ZOO_DLL_EXPORT int ssh_exec ( maps conf,
const char *  command,
int  cnt 
)

Execute a command over an opened SSH connection.

Parameters
confmaps pointer to the main configuration maps
commandconst char pointer to the command to be executed
Returns
bytecount resulting from the execution of the command
ZOO_DLL_EXPORT int ssh_fetch ( maps conf,
const char *  localPath,
const char *  targetPath,
int  cnt 
)

Download a file over an opened SSH connection.

Parameters
confmaps pointer to the main configuration maps
localPathconst char* defining the local path for storing the file
targetPathconst char* defining the path for accessing the file on the remote host
Returns
0 in case of success, -1 if failure occured
ZOO_DLL_EXPORT int ssh_get_cnt ( maps conf)

Get the number of opened SSH connections.

Parameters
confmaps pointer to the main configuration maps
Returns
the number of opened SSH connections

Variable Documentation

int nb_sessions
static