diff options
author | Andreas Schneider <asn@cynapses.org> | 2010-07-07 12:40:49 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cynapses.org> | 2010-07-07 12:40:49 +0200 |
commit | 4ad78287979d383284de5355976fe820daec1e48 (patch) | |
tree | d9e07ce222baee5899c29a9de9fe437545c9a270 | |
parent | af8315b9ce287874e1b374743d6fbaa5fc5c2cfd (diff) | |
download | libssh-4ad78287979d383284de5355976fe820daec1e48.tar.gz libssh-4ad78287979d383284de5355976fe820daec1e48.tar.xz libssh-4ad78287979d383284de5355976fe820daec1e48.zip |
options: Added option to bind a client to an ip address.
Thanks to Donatello Boccaforno <donatello.boccaforno@gmail.com>.
-rw-r--r-- | include/libssh/libssh.h | 3 | ||||
-rw-r--r-- | include/libssh/session.h | 2 | ||||
-rw-r--r-- | libssh/options.c | 15 |
3 files changed, 18 insertions, 2 deletions
diff --git a/include/libssh/libssh.h b/include/libssh/libssh.h index 0b771272..98fdbc91 100644 --- a/include/libssh/libssh.h +++ b/include/libssh/libssh.h @@ -271,7 +271,8 @@ enum ssh_options_e { SSH_OPTIONS_CIPHERS_S_C, SSH_OPTIONS_COMPRESSION_C_S, SSH_OPTIONS_COMPRESSION_S_C, - SSH_OPTIONS_PROXYCOMMAND + SSH_OPTIONS_PROXYCOMMAND, + SSH_OPTIONS_BINDADDR }; enum { diff --git a/include/libssh/session.h b/include/libssh/session.h index 33106d24..ce73b86f 100644 --- a/include/libssh/session.h +++ b/include/libssh/session.h @@ -102,7 +102,7 @@ struct ssh_session_struct { #endif char *username; char *host; - char *bindaddr; /* TODO: check if needed */ + char *bindaddr; /* bind the client to an ip addr */ char *xbanner; /* TODO: looks like it is not needed */ struct ssh_list *identity; char *sshdir; diff --git a/libssh/options.c b/libssh/options.c index 35180847..c6b654cb 100644 --- a/libssh/options.c +++ b/libssh/options.c @@ -187,6 +187,9 @@ int ssh_options_set_algo(ssh_session session, int algo, * set the hostname as the hostname is used as a key in * the known_host mechanism. * + * - SSH_OPTIONS_BINDADDR: + * The address to bind the client to (string). + * * - SSH_OPTIONS_USER: * The username for authentication (string).\n * \n @@ -397,6 +400,18 @@ int ssh_options_set(ssh_session session, enum ssh_options_e type, session->fd = *x & 0xffff; } break; + case SSH_OPTIONS_BINDADDR: + if (value == NULL) { + ssh_set_error_invalid(session, __FUNCTION__); + return -1; + } + q = strdup(value); + if (q == NULL) { + return -1; + } + SAFE_FREE(session->bindaddr); + session->bindaddr = q; + break; case SSH_OPTIONS_USER: SAFE_FREE(session->username); if (value == NULL) { /* set default username */ |