summaryrefslogtreecommitdiffstats
path: root/src/polypcore
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2006-03-02 21:56:15 +0000
committerPierre Ossman <ossman@cendio.se>2006-03-02 21:56:15 +0000
commitbc97b29447bf5c9932ceccb665fa57dd7f654b36 (patch)
treef190713863f976e8e05cb9ee2b41cbaa8b433e71 /src/polypcore
parentfbaaf5acb7b391c605585971dac2b417b55f1100 (diff)
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
Diffstat (limited to 'src/polypcore')
-rw-r--r--src/polypcore/protocol-native.c19
1 files changed, 16 insertions, 3 deletions
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 <stdlib.h>
#include <unistd.h>
+#include <polyp/version.h>
+
#include <polypcore/native-common.h>
#include <polypcore/packet.h>
#include <polypcore/client.h>
@@ -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) {