From 3a2e1eee3b964512ccd344142c4d3545d162a3bb Mon Sep 17 00:00:00 2001
From: Robert Xu <robxu9@gmail.com>
Date: Mon, 12 Jan 2015 13:03:43 -0600
Subject: [PATCH] channels: add ssh_channel_request_custom for custom requests

---
 include/libssh/libssh.h |  1 +
 src/channels.c          | 21 +++++++++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/include/libssh/libssh.h b/include/libssh/libssh.h
index f4e4fe9..366f752 100644
--- a/include/libssh/libssh.h
+++ b/include/libssh/libssh.h
@@ -390,6 +390,7 @@ LIBSSH_API int ssh_channel_read(ssh_channel channel, void *dest, uint32_t count,
 LIBSSH_API int ssh_channel_read_timeout(ssh_channel channel, void *dest, uint32_t count, int is_stderr, int timeout_ms);
 LIBSSH_API int ssh_channel_read_nonblocking(ssh_channel channel, void *dest, uint32_t count,
     int is_stderr);
+LIBSSH_API int ssh_channel_request_custom(ssh_channel channel, const char *request, ssh_buffer buffer, int reply);
 LIBSSH_API int ssh_channel_request_env(ssh_channel channel, const char *name, const char *value);
 LIBSSH_API int ssh_channel_request_exec(ssh_channel channel, const char *cmd);
 LIBSSH_API int ssh_channel_request_pty(ssh_channel channel);
diff --git a/src/channels.c b/src/channels.c
index 7a4e71f..387806f 100644
--- a/src/channels.c
+++ b/src/channels.c
@@ -1602,6 +1602,27 @@ error:
 }
 
 /**
+ * @brief Send a custom request to a channel.
+ *
+ * @param[in] channel   The channel to send the request.
+ *
+ * @param[in] request   The request name.
+ *
+ * @param[in] buffer    The request payload.
+ *
+ * @param[in] reply     Whether to expect a reply: 0 for no, 1 for yes.
+ *
+ * @return              SSH_OK on success,
+ *                      SSH_ERROR if an error occured,
+ *                      SSH_AGAIN if in nonblocking mode and call has
+ *                      to be done again.
+ */
+int ssh_channel_request_custom(ssh_channel channel, const char *request,
+    ssh_buffer buffer, int reply) {
+  return channel_request(channel, request, buffer, reply);
+}
+
+/**
  * @brief Request a pty with a specific type and size.
  *
  * @param[in]  channel  The channel to sent the request.
-- 
2.2.1

