From bc97b29447bf5c9932ceccb665fa57dd7f654b36 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Thu, 2 Mar 2006 21:56:15 +0000 Subject: Negotiate protocol version between server and client. Will allow smoother protocol modifications in the future. git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@621 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/polypcore/protocol-native.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src/polypcore') diff --git a/src/polypcore/protocol-native.c b/src/polypcore/protocol-native.c index 76761b73..68dc6366 100644 --- a/src/polypcore/protocol-native.c +++ b/src/polypcore/protocol-native.c @@ -29,6 +29,8 @@ #include #include +#include + #include #include #include @@ -111,6 +113,7 @@ enum { struct connection { int authorized; + uint32_t version; pa_protocol_native *protocol; pa_client *client; pa_pstream *pstream; @@ -866,14 +869,22 @@ static void command_exit(PA_GCC_UNUSED pa_pdispatch *pd, PA_GCC_UNUSED uint32_t static void command_auth(PA_GCC_UNUSED pa_pdispatch *pd, PA_GCC_UNUSED uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) { struct connection *c = userdata; const void*cookie; + pa_tagstruct *reply; assert(c && t); - if (pa_tagstruct_get_arbitrary(t, &cookie, PA_NATIVE_COOKIE_LENGTH) < 0 || + if (pa_tagstruct_getu32(t, &c->version) < 0 || + pa_tagstruct_get_arbitrary(t, &cookie, PA_NATIVE_COOKIE_LENGTH) < 0 || !pa_tagstruct_eof(t)) { protocol_error(c); return; } + /* Minimum supported version */ + if (c->version < 8) { + pa_pstream_send_error(c->pstream, tag, PA_ERR_VERSION); + return; + } + if (!c->authorized) { int success = 0; @@ -915,8 +926,10 @@ static void command_auth(PA_GCC_UNUSED pa_pdispatch *pd, PA_GCC_UNUSED uint32_t c->auth_timeout_event = NULL; } } - - pa_pstream_send_simple_ack(c->pstream, tag); + + reply = reply_new(tag); + pa_tagstruct_putu32(reply, PA_PROTOCOL_VERSION); + pa_pstream_send_tagstruct(c->pstream, reply); } static void command_set_client_name(PA_GCC_UNUSED pa_pdispatch *pd, PA_GCC_UNUSED uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) { -- cgit