diff --git a/include/libssh/libssh.h b/include/libssh/libssh.h index 2b125f23..a34e9ee4 100644 --- a/include/libssh/libssh.h +++ b/include/libssh/libssh.h @@ -405,10 +405,19 @@ LIBSSH_API const char *ssh_copyright(void); LIBSSH_API void ssh_disconnect(ssh_session session); LIBSSH_API char *ssh_dirname (const char *path); LIBSSH_API int ssh_finalize(void); -LIBSSH_API ssh_channel ssh_forward_accept(ssh_session session, int timeout_ms); -LIBSSH_API ssh_channel ssh_channel_accept_forward(ssh_session session, int timeout_ms, int *destination_port); -LIBSSH_API int ssh_forward_cancel(ssh_session session, const char *address, int port); -LIBSSH_API int ssh_forward_listen(ssh_session session, const char *address, int port, int *bound_port); + +/* REVERSE PORT FORWARDING */ +LIBSSH_API ssh_channel ssh_channel_accept_forward(ssh_session session, + int timeout_ms, + int *destination_port); +LIBSSH_API int ssh_channel_cancel_forward(ssh_session session, + const char *address, + int port); +LIBSSH_API int ssh_channel_listen_forward(ssh_session session, + const char *address, + int port, + int *bound_port); + LIBSSH_API void ssh_free(ssh_session session); LIBSSH_API const char *ssh_get_disconnect_message(ssh_session session); LIBSSH_API const char *ssh_get_error(void *error); @@ -429,7 +438,12 @@ LIBSSH_API int ssh_get_publickey_hash(const ssh_key key, unsigned char **hash, size_t *hlen); +/* DEPRECATED FUNCTIONS */ SSH_DEPRECATED LIBSSH_API int ssh_get_pubkey_hash(ssh_session session, unsigned char **hash); +SSH_DEPRECATED LIBSSH_API ssh_channel ssh_forward_accept(ssh_session session, int timeout_ms); +SSH_DEPRECATED LIBSSH_API int ssh_forward_cancel(ssh_session session, const char *address, int port); +SSH_DEPRECATED LIBSSH_API int ssh_forward_listen(ssh_session session, const char *address, int port, int *bound_port); + LIBSSH_API int ssh_get_random(void *where,int len,int strong); LIBSSH_API int ssh_get_version(ssh_session session); diff --git a/include/libssh/libsshpp.hpp b/include/libssh/libsshpp.hpp index 1a5d80a9..71d6ff5e 100644 --- a/include/libssh/libsshpp.hpp +++ b/include/libssh/libsshpp.hpp @@ -365,14 +365,14 @@ public: /* acceptForward is implemented later in this file */ void_throwable cancelForward(const char *address, int port){ - int err=ssh_forward_cancel(c_session, address, port); + int err=ssh_channel_cancel_forward(c_session, address, port); ssh_throw(err); return_throwable; } void_throwable listenForward(const char *address, int port, int &boundport){ - int err=ssh_forward_listen(c_session, address, port, &boundport); + int err=ssh_channel_listen_forward(c_session, address, port, &boundport); ssh_throw(err); return_throwable; } @@ -583,8 +583,8 @@ private: /* This code cannot be put inline due to references to Channel */ Channel *Session::acceptForward(int timeout_ms){ - ssh_channel forward = ssh_forward_accept(c_session, - timeout_ms); + ssh_channel forward = + ssh_channel_accept_forward(c_session, timeout_ms, NULL); ssh_throw_null(c_session,forward); Channel *newchan = new Channel(*this,forward); return newchan; diff --git a/src/channels.c b/src/channels.c index dc51d959..116ada6d 100644 --- a/src/channels.c +++ b/src/channels.c @@ -2251,7 +2251,11 @@ error: * SSH_AGAIN if in nonblocking mode and call has * to be done again. **/ -int ssh_forward_listen(ssh_session session, const char *address, int port, int *bound_port) { +int ssh_channel_listen_forward(ssh_session session, + const char *address, + int port, + int *bound_port) +{ ssh_buffer buffer = NULL; ssh_string addr = NULL; int rc = SSH_ERROR; @@ -2293,16 +2297,7 @@ error: return rc; } -/** - * @brief Accept an incoming TCP/IP forwarding channel. - * - * @param[in] session The ssh session to use. - * - * @param[in] timeout_ms A timeout in milliseconds. - * - * @return Newly created channel, or NULL if no incoming channel request from - * the server - */ +/* DEPRECATED */ ssh_channel ssh_forward_accept(ssh_session session, int timeout_ms) { return ssh_channel_accept(session, SSH_CHANNEL_FORWARDED_TCPIP, timeout_ms, NULL); } @@ -2338,7 +2333,10 @@ ssh_channel ssh_channel_accept_forward(ssh_session session, int timeout_ms, int* * SSH_AGAIN if in nonblocking mode and call has * to be done again. */ -int ssh_forward_cancel(ssh_session session, const char *address, int port) { +int ssh_channel_cancel_forward(ssh_session session, + const char *address, + int port) +{ ssh_buffer buffer = NULL; ssh_string addr = NULL; int rc = SSH_ERROR; @@ -2372,6 +2370,10 @@ error: return rc; } +int ssh_forward_cancel(ssh_session session, const char *address, int port) { + return ssh_channel_cancel_forward(session, address, port); +} + /** * @brief Set environment variables. * diff --git a/src/legacy.c b/src/legacy.c index 6e7bfffc..c98f3e0c 100644 --- a/src/legacy.c +++ b/src/legacy.c @@ -163,7 +163,7 @@ int channel_change_pty_size(ssh_channel channel,int cols,int rows){ } ssh_channel channel_forward_accept(ssh_session session, int timeout_ms){ - return ssh_forward_accept(session,timeout_ms); + return ssh_channel_accept_forward(session, timeout_ms, NULL); } int channel_close(ssh_channel channel){ @@ -171,12 +171,12 @@ int channel_close(ssh_channel channel){ } int channel_forward_cancel(ssh_session session, const char *address, int port){ - return ssh_forward_cancel(session, address, port); + return ssh_channel_cancel_forward(session, address, port); } int channel_forward_listen(ssh_session session, const char *address, int port, int *bound_port){ - return ssh_forward_listen(session, address, port, bound_port); + return ssh_channel_listen_forward(session, address, port, bound_port); } void channel_free(ssh_channel channel){ diff --git a/tests/client/torture_forward.c b/tests/client/torture_forward.c index 73e6e60e..5754386f 100644 --- a/tests/client/torture_forward.c +++ b/tests/client/torture_forward.c @@ -66,7 +66,7 @@ static void torture_ssh_forward(void **state) int bound_port; int rc; - rc = ssh_forward_listen(session, "127.0.0.1", 8080, &bound_port); + rc = ssh_channel_listen_forward(session, "127.0.0.1", 8080, &bound_port); assert_int_equal(rc, SSH_OK); #if 0