Improve ssh_options_set_bind().

git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@353 7dcaeef0-15fb-0310-b436-a5af3365683c
This commit is contained in:
Andreas Schneider
2009-04-02 11:56:13 +00:00
parent b6fbe97f24
commit 4373fc64e3
2 changed files with 27 additions and 12 deletions

View File

@@ -313,7 +313,7 @@ int ssh_options_set_port(SSH_OPTIONS *opt, unsigned int port);
int ssh_options_getopt(SSH_OPTIONS *options, int *argcptr, char **argv); int ssh_options_getopt(SSH_OPTIONS *options, int *argcptr, char **argv);
int ssh_options_set_host(SSH_OPTIONS *opt, const char *host); int ssh_options_set_host(SSH_OPTIONS *opt, const char *host);
int ssh_options_set_fd(SSH_OPTIONS *opt, socket_t fd); int ssh_options_set_fd(SSH_OPTIONS *opt, socket_t fd);
void ssh_options_set_bind(SSH_OPTIONS *opt, const char *bindaddr, int port); int ssh_options_set_bind(SSH_OPTIONS *opt, const char *bindaddr, int port);
void ssh_options_set_identity(SSH_OPTIONS *opt, const char *identity); void ssh_options_set_identity(SSH_OPTIONS *opt, const char *identity);
void ssh_options_set_status_callback(SSH_OPTIONS *opt, void (*callback) void ssh_options_set_status_callback(SSH_OPTIONS *opt, void (*callback)
(void *arg, float status), void *arg); (void *arg, float status), void *arg);

View File

@@ -326,18 +326,33 @@ int ssh_options_set_fd(SSH_OPTIONS *opt, socket_t fd) {
return 0; return 0;
} }
/** In case your client has multiple IP adresses, select the local address /**
* and port to use for the socket.\n * @brief Set the local address and port binding.
* If the address or port is not bindable, it may be impossible to *
* connect. * In case your client has multiple IP adresses, select the local address and
* \brief set the local address and port binding * port to use for the socket.\n
* \param opt options structure * If the address or port is not bindable, it may be impossible to connect.
* \param bindaddr bind address in form of hostname or ip address *
* \param port port number to bind * @param opt The options structure to use.
*
* @param bindaddr The bind address in form of hostname or ip address.
*
* @param port The port number to bind.
*
* @return 0 on success, < 0 on error.
*/ */
void ssh_options_set_bind(SSH_OPTIONS *opt, const char *bindaddr, int port){ int ssh_options_set_bind(SSH_OPTIONS *opt, const char *bindaddr, int port) {
opt->bindaddr=strdup(bindaddr); if (opt == NULL || bindaddr == NULL) {
opt->bindport=port; return -1;
}
opt->bindaddr = strdup(bindaddr);
if (opt->bindaddr == NULL) {
return -1;
}
opt->bindport = port;
return 0;
} }
/** the ssh directory is used for files like known_hosts and /** the ssh directory is used for files like known_hosts and