aboutsummaryrefslogtreecommitdiff
path: root/src/channels.c
diff options
context:
space:
mode:
authormilo <milo@r0ot.me>2011-03-11 13:39:29 +0100
committermilo <milo@r0ot.me>2011-04-14 13:32:16 +0200
commita3cddd5fad88499255399fb469fee52f1a3e48fc (patch)
tree94ee1d003931dedf5b8a9572bf6bff7e3f9913f2 /src/channels.c
parent89a3385b98ff4def869b88e6b28559a7df51a2a0 (diff)
downloadlibssh-a3cddd5fad88499255399fb469fee52f1a3e48fc.tar.gz
libssh-a3cddd5fad88499255399fb469fee52f1a3e48fc.tar.xz
libssh-a3cddd5fad88499255399fb469fee52f1a3e48fc.zip
Implemented X11 server side
Diffstat (limited to 'src/channels.c')
-rw-r--r--src/channels.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/channels.c b/src/channels.c
index 6a4c98b..ad1ed81 100644
--- a/src/channels.c
+++ b/src/channels.c
@@ -2929,6 +2929,69 @@ error:
}
/**
+ * @brief Open a X11 channel.
+ *
+ * @param[in] channel An allocated channel.
+ *
+ * @param[in] orig_addr The source host (the local server).
+ *
+ * @param[in] orig_port The source port (the local server).
+ *
+ * @return SSH_OK on success, SSH_ERROR if an error occured.
+ *
+ * @warning This function does not bind the local port and does not automatically
+ * forward the content of a socket to the channel. You still have to
+ * use channel_read and channel_write for this.
+ */
+int ssh_channel_open_x11(ssh_channel channel,
+ const char *orig_addr, int orig_port) {
+ ssh_session session;
+ ssh_buffer payload = NULL;
+ ssh_string str = NULL;
+ int rc = SSH_ERROR;
+
+ if(channel == NULL) {
+ return rc;
+ }
+ if(orig_addr == NULL) {
+ ssh_set_error_invalid(channel->session, __FUNCTION__);
+ return rc;
+ }
+
+
+ session = channel->session;
+
+ enter_function();
+
+ payload = ssh_buffer_new();
+ if (payload == NULL) {
+ ssh_set_error_oom(session);
+ goto error;
+ }
+
+ str = ssh_string_from_char(orig_addr);
+ if (str == NULL) {
+ ssh_set_error_oom(session);
+ goto error;
+ }
+
+ if (buffer_add_ssh_string(payload, str) < 0 ||
+ buffer_add_u32(payload,htonl(orig_port)) < 0) {
+ ssh_set_error_oom(session);
+ goto error;
+ }
+
+ rc = channel_open(channel, "x11", 64000, 32000, payload);
+
+error:
+ ssh_buffer_free(payload);
+ ssh_string_free(str);
+
+ leave_function();
+ return rc;
+}
+
+/**
* @brief Send the exit status to the remote process (as described in RFC 4254, section 6.10).
*
* Sends the exit status to the remote process.