diff options
author | Pierre Ossman <ossman@cendio.se> | 2006-03-02 21:56:15 +0000 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2006-03-02 21:56:15 +0000 |
commit | bc97b29447bf5c9932ceccb665fa57dd7f654b36 (patch) | |
tree | f190713863f976e8e05cb9ee2b41cbaa8b433e71 /src/polyp/context.c | |
parent | fbaaf5acb7b391c605585971dac2b417b55f1100 (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/polyp/context.c')
-rw-r--r-- | src/polyp/context.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/polyp/context.c b/src/polyp/context.c index 59079cb0..845e88d9 100644 --- a/src/polyp/context.c +++ b/src/polyp/context.c @@ -354,6 +354,19 @@ static void setup_complete_callback(pa_pdispatch *pd, uint32_t command, uint32_t switch(c->state) { case PA_CONTEXT_AUTHORIZING: { pa_tagstruct *reply; + + if (pa_tagstruct_getu32(t, &c->version) < 0 || + !pa_tagstruct_eof(t)) { + pa_context_fail(c, PA_ERR_PROTOCOL); + goto finish; + } + + /* Minimum supported version */ + if (c->version < 8) { + pa_context_fail(c, PA_ERR_VERSION); + goto finish; + } + reply = pa_tagstruct_command(c, PA_COMMAND_SET_CLIENT_NAME, &tag); pa_tagstruct_puts(reply, c->name); pa_pstream_send_tagstruct(c->pstream, reply); @@ -400,6 +413,7 @@ static void setup_context(pa_context *c, pa_iochannel *io) { } t = pa_tagstruct_command(c, PA_COMMAND_AUTH, &tag); + pa_tagstruct_putu32(t, PA_PROTOCOL_VERSION); pa_tagstruct_put_arbitrary(t, c->conf->cookie, sizeof(c->conf->cookie)); pa_pstream_send_tagstruct_with_creds(c->pstream, t, 1); pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, setup_complete_callback, c); @@ -936,6 +950,17 @@ const char* pa_context_get_server(pa_context *c) { return c->server; } +uint32_t pa_context_get_protocol_version(pa_context *c) { + return PA_PROTOCOL_VERSION; +} + +uint32_t pa_context_get_server_protocol_version(pa_context *c) { + assert(c); + assert(c->ref >= 1); + + return c->version; +} + pa_tagstruct *pa_tagstruct_command(pa_context *c, uint32_t command, uint32_t *tag) { pa_tagstruct *t; |