summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/libssh/libssh.h2
-rw-r--r--libssh/options.c23
2 files changed, 18 insertions, 7 deletions
diff --git a/include/libssh/libssh.h b/include/libssh/libssh.h
index 322b0e0..ad81ee9 100644
--- a/include/libssh/libssh.h
+++ b/include/libssh/libssh.h
@@ -309,7 +309,7 @@ SSH_OPTIONS *ssh_options_copy(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_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_set_host(SSH_OPTIONS *opt, const char *host);
void ssh_options_set_fd(SSH_OPTIONS *opt, socket_t fd);
diff --git a/libssh/options.c b/libssh/options.c
index 77bf1f4..af20d88 100644
--- a/libssh/options.c
+++ b/libssh/options.c
@@ -70,13 +70,24 @@ SSH_OPTIONS *ssh_options_new(void) {
return option;
}
-/** \brief set port to connect or to bind for a connection
- * \param opt options structure
- * \param port port to connect or to bind
+/**
+ * @brief Set port to connect or to bind for a connection.
+ *
+ * @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){
- opt->port=port&0xffff;
- opt->bindport=port&0xffff;
+int ssh_options_set_port(SSH_OPTIONS *opt, unsigned int port) {
+ if (opt == NULL) {
+ return -1;
+ }
+
+ opt->port = port & 0xffff;
+ opt->bindport = port & 0xffff;
+
+ return 0;
}
/**