Improve ssh_options_set_port().

git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@351 7dcaeef0-15fb-0310-b436-a5af3365683c
This commit is contained in:
Andreas Schneider
2009-04-02 11:50:23 +00:00
parent 71913c8fea
commit d86ac9e04b
2 changed files with 18 additions and 7 deletions

View File

@@ -309,7 +309,7 @@ SSH_OPTIONS *ssh_options_copy(SSH_OPTIONS *opt);
void ssh_options_free(SSH_OPTIONS *opt); void ssh_options_free(SSH_OPTIONS *opt);
int ssh_options_set_wanted_algos(SSH_OPTIONS *opt, int algo, const char *list); int ssh_options_set_wanted_algos(SSH_OPTIONS *opt, int algo, const char *list);
int ssh_options_set_username(SSH_OPTIONS *opt, const char *username); int ssh_options_set_username(SSH_OPTIONS *opt, const char *username);
void ssh_options_set_port(SSH_OPTIONS *opt, unsigned int port); 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);
void ssh_options_set_fd(SSH_OPTIONS *opt, socket_t fd); void ssh_options_set_fd(SSH_OPTIONS *opt, socket_t fd);

View File

@@ -70,13 +70,24 @@ SSH_OPTIONS *ssh_options_new(void) {
return option; return option;
} }
/** \brief set port to connect or to bind for a connection /**
* \param opt options structure * @brief Set port to connect or to bind for a connection.
* \param port port to connect or to bind *
* @param opt The options structure to use.
*
* @param port The port to connect or to bind.
*
* @return 0 on success, < 0 on error.
*/ */
void ssh_options_set_port(SSH_OPTIONS *opt, unsigned int port){ int ssh_options_set_port(SSH_OPTIONS *opt, unsigned int port) {
opt->port=port&0xffff; if (opt == NULL) {
opt->bindport=port&0xffff; return -1;
}
opt->port = port & 0xffff;
opt->bindport = port & 0xffff;
return 0;
} }
/** /**