diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2011-02-03 19:00:32 +0100 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@redhat.com> | 2011-02-19 00:16:44 +0100 |
commit | 2d9ed06339499e252c5b947794088f18dc6df165 (patch) | |
tree | 8fe09fafc357b2126cd46021f142601ba68b296e | |
parent | bedc6c6d52d9b0aca74f7d5c97208666278e9b1d (diff) |
gtk: add spice_channel_flush_sasl()
-rw-r--r-- | gtk/spice-channel.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c index 01a1b25..1a2b5e9 100644 --- a/gtk/spice-channel.c +++ b/gtk/spice-channel.c @@ -619,10 +619,42 @@ static void spice_channel_flush_wire(SpiceChannel *channel, } } +#if HAVE_SASL +/* + * Encode all buffered data, write all encrypted data out + * to the wire + */ +static void spice_channel_flush_sasl(SpiceChannel *channel, const void *data, size_t len) +{ + spice_channel *c = channel->priv; + const char *output; + unsigned int outputlen; + int err; + + err = sasl_encode(c->sasl_conn, data, len, &output, &outputlen); + if (err != SASL_OK) { + g_warning ("Failed to encode SASL data %s", + sasl_errstring(err, NULL, NULL)); + c->has_error = TRUE; + return; + } + + //SPICE_DEBUG("Flush SASL %d: %p %d", len, output, outputlen); + spice_channel_flush_wire(channel, output, outputlen); +} +#endif + /* coroutine context */ static void spice_channel_write(SpiceChannel *channel, const void *data, size_t len) { - spice_channel_flush_wire(channel, data, len); + spice_channel *c = channel->priv; + +#if HAVE_SASL + if (c->sasl_conn) + spice_channel_flush_sasl(channel, data, len); + else +#endif + spice_channel_flush_wire(channel, data, len); } /* |