From: Julien Desfossez Date: Mon, 14 Jul 2014 21:11:30 +0000 (-0400) Subject: Fix: check the lttng-relayd protocol version X-Git-Tag: v1.2.2~3 X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=9aa155c5e977ea5f31023b6726f99a58aa01daeb Fix: check the lttng-relayd protocol version Signed-off-by: Julien Desfossez Signed-off-by: Mathieu Desnoyers --- diff --git a/formats/lttng-live/lttng-live-comm.c b/formats/lttng-live/lttng-live-comm.c index f6f14ab0..a855891a 100644 --- a/formats/lttng-live/lttng-live-comm.c +++ b/formats/lttng-live/lttng-live-comm.c @@ -201,6 +201,18 @@ int lttng_live_establish_connection(struct lttng_live_ctx *ctx) be64toh(connect.viewer_session_id)); printf_verbose("Relayd version : %u.%u\n", be32toh(connect.major), be32toh(connect.minor)); + + if (LTTNG_LIVE_MAJOR != be32toh(connect.major)) { + fprintf(stderr, "[error] Incompatible lttng-relayd protocol\n"); + goto error; + } + /* Use the smallest protocol version implemented. */ + if (LTTNG_LIVE_MINOR > be32toh(connect.minor)) { + ctx->minor = be32toh(connect.minor); + } else { + ctx->minor = LTTNG_LIVE_MINOR; + } + ctx->major = LTTNG_LIVE_MAJOR; ret = 0; end: return ret; diff --git a/formats/lttng-live/lttng-live.h b/formats/lttng-live/lttng-live.h index cf47437b..d7b0e860 100644 --- a/formats/lttng-live/lttng-live.h +++ b/formats/lttng-live/lttng-live.h @@ -37,6 +37,9 @@ struct lttng_live_ctx { char relay_hostname[NAME_MAX]; int control_sock; int port; + /* Protocol version to use for this connection. */ + uint32_t major; + uint32_t minor; struct lttng_live_session *session; struct bt_context *bt_ctx; GArray *session_ids;