diff options
author | Lee Hambley <lee.hambley@gmail.com> | 2011-10-28 10:26:32 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2011-10-28 12:15:12 +0200 |
commit | e797781bb54685a69735d8b1e84dd26a69227c47 (patch) | |
tree | 0b31b317214513c05508140cdbed811b39342c6f /src/options.c | |
parent | 6bd95b50f535d07594f3659c67a1f5e501887641 (diff) | |
download | libssh-e797781bb54685a69735d8b1e84dd26a69227c47.tar.gz libssh-e797781bb54685a69735d8b1e84dd26a69227c47.tar.xz libssh-e797781bb54685a69735d8b1e84dd26a69227c47.zip |
Implement ssh_options_get_port(ssh_session, unsigned int*).
Diffstat (limited to 'src/options.c')
-rw-r--r-- | src/options.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/options.c b/src/options.c index f6b1ae9c..4dbcb679 100644 --- a/src/options.c +++ b/src/options.c @@ -779,6 +779,32 @@ int ssh_options_set(ssh_session session, enum ssh_options_e type, } /** + * @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 * trusted the ssh driver to infer these values from underlaying configuration files. |