+ * lttng_add_context
+ */
+int lttng_add_context(struct lttng_domain *domain,
+ struct lttng_event_context *ctx, const char *event_name,
+ const char *channel_name)
+{
+ copy_string(lsm.u.context.channel_name, channel_name, NAME_MAX);
+ copy_string(lsm.u.context.event_name, event_name, NAME_MAX);
+ copy_lttng_domain(domain);
+
+ if (ctx) {
+ memcpy(&lsm.u.context.ctx, ctx, sizeof(struct lttng_event_context));
+ }
+
+ return ask_sessiond(LTTNG_ADD_CONTEXT, NULL);
+}
+
+/*
+ * lttng_enable_event
+ */
+int lttng_enable_event(struct lttng_domain *domain,
+ struct lttng_event *ev, const char *channel_name)
+{
+ int ret = -1;
+
+ if (channel_name == NULL) {
+ copy_string(lsm.u.enable.channel_name, DEFAULT_CHANNEL_NAME, NAME_MAX);
+ } else {
+ copy_string(lsm.u.enable.channel_name, channel_name, NAME_MAX);
+ }
+
+ if (domain) {
+ switch (domain->type) {
+ case LTTNG_DOMAIN_KERNEL:
+ if (ev == NULL) {
+ ret = ask_sessiond(LTTNG_KERNEL_ENABLE_ALL_EVENT, NULL);
+ } else {
+ memcpy(&lsm.u.enable.event, ev, sizeof(struct lttng_event));
+ ret = ask_sessiond(LTTNG_KERNEL_ENABLE_EVENT, NULL);
+ }
+ break;
+ case LTTNG_DOMAIN_UST:
+ ret = LTTCOMM_NOT_IMPLEMENTED;
+ break;
+ default:
+ ret = LTTCOMM_UNKNOWN_DOMAIN;
+ break;
+ };
+ }
+
+ return ret;
+}
+
+/*
+ * Disable an event in the kernel tracer.
+ */
+int lttng_disable_event(struct lttng_domain *domain, const char *name,
+ const char *channel_name)
+{
+ int ret = -1;
+
+ if (channel_name == NULL) {
+ copy_string(lsm.u.disable.channel_name, DEFAULT_CHANNEL_NAME, NAME_MAX);
+ } else {
+ copy_string(lsm.u.disable.channel_name, channel_name, NAME_MAX);
+ }
+
+ if (domain) {
+ switch (domain->type) {
+ case LTTNG_DOMAIN_KERNEL:
+ if (name == NULL) {
+ ret = ask_sessiond(LTTNG_KERNEL_DISABLE_ALL_EVENT, NULL);
+ } else {
+ copy_string(lsm.u.disable.name, name, NAME_MAX);
+ ret = ask_sessiond(LTTNG_KERNEL_DISABLE_EVENT, NULL);
+ }
+ break;
+ case LTTNG_DOMAIN_UST:
+ ret = LTTCOMM_NOT_IMPLEMENTED;
+ break;
+ default:
+ ret = LTTCOMM_UNKNOWN_DOMAIN;
+ break;
+ };
+ }
+
+ return ret;
+}
+
+/*
+ * Enable recording for a channel for the kernel tracer.
+ */
+int lttng_enable_channel(struct lttng_domain *domain,
+ struct lttng_channel *chan)
+{
+ int ret = -1;
+
+ if (chan) {
+ memcpy(&lsm.u.channel.chan, chan, sizeof(struct lttng_channel));
+ }
+
+ if (domain) {
+ switch (domain->type) {
+ case LTTNG_DOMAIN_KERNEL:
+ ret = ask_sessiond(LTTNG_KERNEL_ENABLE_CHANNEL, NULL);
+ break;
+ case LTTNG_DOMAIN_UST:
+ ret = LTTCOMM_NOT_IMPLEMENTED;
+ break;
+ default:
+ ret = LTTCOMM_UNKNOWN_DOMAIN;
+ break;
+ };
+ }
+
+ return ret;
+}
+
+/*
+ * Disable channel.