+ ret = reply->ret_val;
+ free(reply);
+
+ return ret;
+
+error:
+ free(reply);
+ return -1;
+}
+
+/*
+ * Enable UST channel.
+ */
+int ustctl_enable_channel(int sock, struct ltt_ust_session *session,
+ struct ltt_ust_channel *chan)
+{
+ struct lttcomm_ust_msg command;
+ struct lttcomm_ust_reply *reply = NULL;
+
+ init_command(LTTNG_UST_ENABLE, chan->handle, &command);
+
+ reply = ustcomm_send_command(sock, &command);
+ if (reply == NULL) {
+ goto error;
+ }
+
+ if (reply->handle != chan->handle) {
+ ERR("Receive wrong handle from UST reply on enable channel");
+ goto error;
+ }
+
+ chan->enabled = 1;
+ free(reply);
+
+ DBG2("ustctl enable channel successful for sock %d", sock);
+ return 0;
+
+error:
+ free(reply);
+ return -1;
+}
+
+/*
+ * Disable UST channel.
+ */
+int ustctl_disable_channel(int sock, struct ltt_ust_session *session,
+ struct ltt_ust_channel *chan)
+{
+ struct lttcomm_ust_msg command;
+ struct lttcomm_ust_reply *reply = NULL;
+
+ memset(&command, 0, sizeof(command));
+
+ command.cmd = LTTNG_UST_DISABLE;
+ command.handle = chan->handle;
+
+ reply = ustcomm_send_command(sock, &command);
+ if (reply == NULL) {
+ goto error;
+ }
+
+ if (reply->handle != chan->handle) {
+ ERR("Receive wrong handle from UST reply on enable channel");
+ goto error;
+ }
+
+ chan->enabled = 1;
+ free(reply);