aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAndreas Schneider <mail@cynapses.org>2009-10-02 14:06:41 +0200
committerAndreas Schneider <mail@cynapses.org>2009-10-02 20:26:14 +0200
commitab5b4c7cfe668ee4103de146c2a739532abfc416 (patch)
treeec30d19a18400dbfa0f94bf90262d2c439c724aa /include
parente78334688fa510a5c859b0367d4d4779efae518a (diff)
downloadlibssh-ab5b4c7cfe668ee4103de146c2a739532abfc416.tar.gz
libssh-ab5b4c7cfe668ee4103de146c2a739532abfc416.tar.xz
libssh-ab5b4c7cfe668ee4103de146c2a739532abfc416.zip
Get rid of the options structure.
Diffstat (limited to 'include')
-rw-r--r--include/libssh/callback.h9
-rw-r--r--include/libssh/libssh.h42
-rw-r--r--include/libssh/options.h52
-rw-r--r--include/libssh/priv.h20
-rw-r--r--include/libssh/server.h19
-rw-r--r--include/libssh/session.h19
6 files changed, 65 insertions, 96 deletions
diff --git a/include/libssh/callback.h b/include/libssh/callback.h
index 3aac65b..51a2ece 100644
--- a/include/libssh/callback.h
+++ b/include/libssh/callback.h
@@ -54,6 +54,7 @@ typedef void (*ssh_log_callback) (ssh_session session, int priority,
* connection */
typedef void (*ssh_status_callback) (ssh_session session, float status,
void *userdata);
+
struct ssh_callbacks_struct {
/** size of this structure. internal, shoud be set with ssh_callbacks_init()*/
size_t size;
@@ -81,12 +82,12 @@ typedef struct ssh_callbacks_struct * ssh_callbacks;
p->size=sizeof(*p); \
} while(0);
-LIBSSH_API int ssh_options_set_auth_callback(ssh_options opt, ssh_auth_callback cb,
+LIBSSH_API int ssh_set_auth_callback(ssh_session session, ssh_auth_callback cb,
void *userdata);
-LIBSSH_API int ssh_options_set_log_function(ssh_options opt,
+LIBSSH_API int ssh_set_log_callback(ssh_session session,
ssh_log_callback cb, void *userdata);
-LIBSSH_API int ssh_options_set_status_callback(ssh_options opt, void (*callback)
- (void *arg, float status), void *arg);
+LIBSSH_API int ssh_set_status_callback(ssh_session session, void (*callback)
+ (void *arg, float status), void *arg);
#ifdef __cplusplus
}
diff --git a/include/libssh/libssh.h b/include/libssh/libssh.h
index c6b3b72..f4cb55b 100644
--- a/include/libssh/libssh.h
+++ b/include/libssh/libssh.h
@@ -94,6 +94,12 @@
#define PRINTF_ATTRIBUTE(a,b)
#endif /* __GNUC__ */
+#ifdef __GNUC__
+#define SSH_DEPRECATED __attribute__ ((deprecated))
+#else
+#define SSH_DEPRECATED
+#endif
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -108,14 +114,14 @@ typedef struct ssh_agent_struct AGENT;
#endif
typedef struct ssh_message_struct SSH_MESSAGE;
-typedef struct ssh_options_struct SSH_OPTIONS;
+typedef struct ssh_session_struct SSH_OPTIONS;
typedef struct ssh_session_struct SSH_SESSION;
typedef struct ssh_agent_struct* ssh_agent;
typedef struct ssh_buffer_struct* ssh_buffer;
typedef struct ssh_channel_struct* ssh_channel;
typedef struct ssh_message_struct *ssh_message;
-typedef struct ssh_options_struct* ssh_options;
+typedef struct ssh_session_struct* ssh_options;
typedef struct ssh_private_key_struct* ssh_private_key;
typedef struct ssh_public_key_struct* ssh_public_key;
typedef struct ssh_scp_struct* ssh_scp;
@@ -267,14 +273,7 @@ enum ssh_options_e {
SSH_OPTIONS_CIPHERS_C_S,
SSH_OPTIONS_CIPHERS_S_C,
SSH_OPTIONS_COMPRESSION_C_S,
- SSH_OPTIONS_COMPRESSION_S_C,
-
- SSH_OPTIONS_SERVER_BINDADDR,
- SSH_OPTIONS_SERVER_BINDPORT,
- SSH_OPTIONS_SERVER_HOSTKEY,
- SSH_OPTIONS_SERVER_DSAKEY,
- SSH_OPTIONS_SERVER_RSAKEY,
- SSH_OPTIONS_SERVER_BANNER,
+ SSH_OPTIONS_COMPRESSION_S_C
};
enum {
@@ -383,30 +382,13 @@ LIBSSH_API int ssh_message_subtype(ssh_message msg);
LIBSSH_API int ssh_message_type(ssh_message msg);
LIBSSH_API int ssh_mkdir (const char *pathname, mode_t mode);
LIBSSH_API ssh_session ssh_new(void);
-LIBSSH_API ssh_options ssh_options_copy(ssh_options opt);
-LIBSSH_API void ssh_options_free(ssh_options opt);
-LIBSSH_API ssh_options ssh_options_new(void);
-LIBSSH_API int ssh_options_allow_ssh1(ssh_options opt, int allow);
-LIBSSH_API int ssh_options_allow_ssh2(ssh_options opt, int allow);
+LIBSSH_API ssh_options ssh_options_copy(ssh_options opt);
LIBSSH_API int ssh_options_getopt(ssh_options options, int *argcptr, char **argv);
LIBSSH_API int ssh_options_parse_config(ssh_options opt, const char *filename);
-LIBSSH_API int ssh_options_set(ssh_options opt, enum ssh_options_e type,
+LIBSSH_API int ssh_options_set(ssh_session session, enum ssh_options_e type,
const void *value);
-LIBSSH_API int ssh_options_set_banner(ssh_options opt, const char *banner);
-LIBSSH_API int ssh_options_set_bind(ssh_options opt, const char *bindaddr, int port);
-LIBSSH_API int ssh_options_set_dsa_server_key(ssh_options opt, const char *dsakey);
-LIBSSH_API int ssh_options_set_fd(ssh_options opt, socket_t fd);
-LIBSSH_API int ssh_options_set_host(ssh_options opt, const char *host);
-LIBSSH_API int ssh_options_set_identity(ssh_options opt, const char *identity);
-LIBSSH_API int ssh_options_set_log_verbosity(ssh_options opt, int verbosity);
-LIBSSH_API int ssh_options_set_known_hosts_file(ssh_options opt, const char *dir);
-LIBSSH_API int ssh_options_set_port(ssh_options opt, unsigned int port);
-LIBSSH_API int ssh_options_set_rsa_server_key(ssh_options opt, const char *rsakey);
-LIBSSH_API int ssh_options_set_ssh_dir(ssh_options opt, const char *dir);
-LIBSSH_API int ssh_options_set_timeout(ssh_options opt, long seconds, long usec);
-LIBSSH_API int ssh_options_set_username(ssh_options opt, const char *username);
-LIBSSH_API int ssh_options_set_wanted_algos(ssh_options opt, int algo, const char *list);
+
LIBSSH_API void ssh_print_hexa(const char *descr, const unsigned char *what, size_t len);
LIBSSH_API int ssh_scp_accept_request(ssh_scp scp);
LIBSSH_API int ssh_scp_close(ssh_scp scp);
diff --git a/include/libssh/options.h b/include/libssh/options.h
deleted file mode 100644
index 8b990d3..0000000
--- a/include/libssh/options.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * This file is part of the SSH Library
- *
- * Copyright (c) 2009 by Aris Adamantiadis
- *
- * The SSH Library is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2.1 of the License, or (at your
- * option) any later version.
- *
- * The SSH Library 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 Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with the SSH Library; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- * MA 02111-1307, USA.
- */
-
-#ifndef OPTIONS_H_
-#define OPTIONS_H_
-
-#include "libssh/priv.h"
-#include "libssh/callback.h"
-
-struct ssh_options_struct {
- struct error_struct error;
- char *banner;
- char *username;
- char *host;
- char *bindaddr;
- int bindport;
- char *identity;
- char *ssh_dir;
- char *known_hosts_file;
- socket_t fd; /* specificaly wanted file descriptor, don't connect host */
- int port;
- char *wanted_methods[10]; /* the kex methods can be choosed. better use the kex fonctions to do that */
- ssh_callbacks callbacks; /* Callbacks to user functions */
- long timeout; /* seconds */
- long timeout_usec;
- int ssh2allowed;
- int ssh1allowed;
- char *dsakey;
- char *rsakey; /* host key for server implementation */
- int log_verbosity;
-
-};
-
-#endif /* OPTIONS_H_ */
diff --git a/include/libssh/priv.h b/include/libssh/priv.h
index a9da5a5..8dbf9a3 100644
--- a/include/libssh/priv.h
+++ b/include/libssh/priv.h
@@ -95,11 +95,21 @@ struct ssh_message_struct;
/* server data */
struct ssh_bind_struct {
- struct error_struct error;
- socket_t bindfd;
- ssh_options options;
- int blocking;
- int toaccept;
+ struct error_struct error;
+
+ ssh_callbacks callbacks; /* Callbacks to user functions */
+
+ /* options */
+ char *wanted_methods[10];
+ char *banner;
+ char *dsakey;
+ char *rsakey;
+ char *bindaddr;
+ socket_t bindfd;
+ unsigned int bindport;
+
+ int blocking;
+ int toaccept;
};
diff --git a/include/libssh/server.h b/include/libssh/server.h
index 311003c..e1ef3df 100644
--- a/include/libssh/server.h
+++ b/include/libssh/server.h
@@ -35,7 +35,17 @@
extern "C" {
#endif
+enum ssh_bind_options_e {
+ SSH_BIND_OPTIONS_BINDADDR,
+ SSH_BIND_OPTIONS_BINDPORT,
+ SSH_BIND_OPTIONS_HOSTKEY,
+ SSH_BIND_OPTIONS_DSAKEY,
+ SSH_BIND_OPTIONS_RSAKEY,
+ SSH_BIND_OPTIONS_BANNER
+};
+
typedef struct ssh_bind_struct SSH_BIND;
+typedef struct ssh_bind_struct *ssh_bind;
/**
* @brief Creates a new SSH server bind.
@@ -51,7 +61,8 @@ LIBSSH_API SSH_BIND *ssh_bind_new(void);
*
* @param options The option structure to set.
*/
-LIBSSH_API void ssh_bind_set_options(SSH_BIND *ssh_bind, ssh_options options);
+LIBSSH_API int ssh_bind_options_set(ssh_bind sshbind,
+ enum ssh_bind_options_e type, const void *value);
/**
* @brief Start listening to the socket.
@@ -69,7 +80,7 @@ LIBSSH_API int ssh_bind_listen(SSH_BIND *ssh_bind);
*
* @param blocking Zero for nonblocking mode.
*/
-LIBSSH_API void ssh_bind_set_blocking(SSH_BIND *ssh_bind, int blocking);
+LIBSSH_API void ssh_bind_set_blocking(SSH_BIND *sshbind, int blocking);
/**
* @brief Recover the file descriptor from the session.
@@ -78,7 +89,7 @@ LIBSSH_API void ssh_bind_set_blocking(SSH_BIND *ssh_bind, int blocking);
*
* @return The file descriptor.
*/
-LIBSSH_API socket_t ssh_bind_get_fd(SSH_BIND *ssh_bind);
+LIBSSH_API socket_t ssh_bind_get_fd(SSH_BIND *sshbind);
/**
* @brief Set the file descriptor for a session.
@@ -87,7 +98,7 @@ LIBSSH_API socket_t ssh_bind_get_fd(SSH_BIND *ssh_bind);
*
* @param fd The file descriptor.
*/
-LIBSSH_API void ssh_bind_set_fd(SSH_BIND *ssh_bind, socket_t fd);
+LIBSSH_API void ssh_bind_set_fd(SSH_BIND *sshbind, socket_t fd);
/**
* @brief Allow the file descriptor to accept new sessions.
diff --git a/include/libssh/session.h b/include/libssh/session.h
index d7bbfcf..b9f425a 100644
--- a/include/libssh/session.h
+++ b/include/libssh/session.h
@@ -29,7 +29,6 @@ typedef struct ssh_kbdint_struct* ssh_kbdint;
struct ssh_session_struct {
struct error_struct error;
struct socket *socket;
- ssh_options options;
char *serverbanner;
char *clientbanner;
int protoversion;
@@ -93,6 +92,24 @@ struct ssh_session_struct {
int (*ssh_message_callback)( struct ssh_session_struct *session, ssh_message msg);
int log_verbosity; /*cached copy of the option structure */
int log_indent; /* indentation level in enter_function logs */
+
+ ssh_callbacks callbacks; /* Callbacks to user functions */
+
+ /* options */
+ char *username;
+ char *host;
+ char *bindaddr; /* TODO: check if needed */
+ char *xbanner; /* TODO: looks like it is not needed */
+ char *identity;
+ char *sshdir;
+ char *knownhosts;
+ char *wanted_methods[10];
+ unsigned long timeout; /* seconds */
+ unsigned long timeout_usec;
+ unsigned int port;
+ socket_t fd;
+ int ssh2;
+ int ssh1;
};
int ssh_handle_packets(ssh_session session);