From e797781bb54685a69735d8b1e84dd26a69227c47 Mon Sep 17 00:00:00 2001 From: Lee Hambley Date: Fri, 28 Oct 2011 10:26:32 +0200 Subject: Implement ssh_options_get_port(ssh_session, unsigned int*). --- src/options.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src') diff --git a/src/options.c b/src/options.c index f6b1ae9..4dbcb67 100644 --- a/src/options.c +++ b/src/options.c @@ -778,6 +778,32 @@ int ssh_options_set(ssh_session session, enum ssh_options_e type, return 0; } +/** + * @brief This function can get ssh the ssh port. It must only be used on + * a valid ssh session. This function is useful when the session + * options have been automatically inferred from the environment + * or configuration files and one + * + * @param session An allocated SSH session structure. + * + * @param unsigned int An unsigned integer into which the + * port will be set from the ssh session. + * + * @return 0 on success, < 0 on error. + * + */ +int ssh_options_get_port(ssh_session session, unsigned int* port_target) { + if (session == NULL) { + return -1; + } + if (!session->port) { + ssh_set_error_invalid(session); + return -1; + } + *port_target = session->port; + return 0; +} + /** * @brief This function can get ssh options, it does not support all options provided for * ssh options set, but mostly those which a user-space program may care about having -- cgit