Initial import of kconsumerd and libkernelctl
[lttng-tools.git] / liblttsessiondcomm / liblttsessiondcomm.h
index bd17a2ac6375003c06ee2a20c0d4b913a938bd28..8b505eb980f3ea6782ec0cef60083c2f2549f4d0 100644 (file)
@@ -1,4 +1,6 @@
-/* Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
+/*
+ * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
+ *                      Julien Desfossez <julien.desfossez@polymtl.ca>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
 #include <limits.h>
 #include <uuid/uuid.h>
 
+#include "lttng-share.h"
+
+#define LTTNG_RUNDIR                                           "/var/run/lttng"
+
 /* Default unix socket path */
-#define DEFAULT_GLOBAL_CLIENT_UNIX_SOCK                "/tmp/client-ltt-sessiond"
-#define DEFAULT_GLOBAL_APPS_UNIX_SOCK          "/tmp/apps-ltt-sessiond"
+#define DEFAULT_GLOBAL_CLIENT_UNIX_SOCK                LTTNG_RUNDIR "/client-ltt-sessiond"
+#define DEFAULT_GLOBAL_APPS_UNIX_SOCK          LTTNG_RUNDIR "/apps-ltt-sessiond"
 #define DEFAULT_HOME_APPS_UNIX_SOCK                    "%s/.apps-ltt-sessiond"
 #define DEFAULT_HOME_CLIENT_UNIX_SOCK          "%s/.client-ltt-sessiond"
 
+/* Kernel consumer path */
+#define KCONSUMERD_PATH                                                LTTNG_RUNDIR "/kconsumerd"
+#define KCONSUMERD_CMD_SOCK_PATH                       KCONSUMERD_PATH "/command"
+#define KCONSUMERD_ERR_SOCK_PATH                       KCONSUMERD_PATH "/error"
+
 /* Queue size of listen(2) */
 #define MAX_LISTEN 10
 
@@ -36,7 +47,7 @@
  */
 #define LTTCOMM_ERR_INDEX(code) (code - LTTCOMM_OK)
 
-enum lttcomm_command_type {
+enum lttcomm_sessiond_command {
        LTTNG_CREATE_SESSION,
        LTTNG_DESTROY_SESSION,
        LTTNG_FORCE_SUBBUF_SWITCH,
@@ -73,6 +84,7 @@ enum lttcomm_return_code {
        LTTCOMM_CREATE_FAIL,    /* Create trace fail */
        LTTCOMM_SESSION_FAIL,   /* Create session fail */
        LTTCOMM_START_FAIL,             /* Start tracing fail */
+       LTTCOMM_STOP_FAIL,              /* Stop tracing fail */
        LTTCOMM_LIST_FAIL,              /* Listing apps fail */
        LTTCOMM_NO_APPS,                /* No traceable application */
        LTTCOMM_NO_SESS,                /* No sessions available */
@@ -82,18 +94,40 @@ enum lttcomm_return_code {
        LTTCOMM_SELECT_SESS,    /* Must select a session */
        LTTCOMM_EXIST_SESS,             /* Session name already exist */
        LTTCOMM_NR,                             /* Last element */
+       KCONSUMERD_COMMAND_SOCK_READY,  /* when kconsumerd command socket ready */
+       KCONSUMERD_SUCCESS_RECV_FD,     /* success on receiving fds */
+       KCONSUMERD_ERROR_RECV_FD,       /* error on receiving fds */
+       KCONSUMERD_POLL_ERROR,  /* Error in polling thread in kconsumerd */
+       KCONSUMERD_POLL_NVAL,   /* Poll on closed fd */
+       KCONSUMERD_POLL_HUP,    /* All fds have hungup */
+       KCONSUMERD_EXIT_SUCCESS,        /* kconsumerd exiting normally */
+       KCONSUMERD_EXIT_FAILURE,        /* kconsumerd exiting on error */
+       KCONSUMERD_OUTFD_ERROR, /* error opening the tracefile */
+};
+
+/* commands for kconsumerd */
+enum lttcomm_consumerd_command {
+       LTTCOMM_ADD_STREAM = 1100,
+       LTTCOMM_UPDATE_STREAM, /* pause, delete, start depending on fd state */
+       LTTCOMM_STOP, /* delete all */
+};
+
+/* state of each fd in consumerd */
+enum lttcomm_kconsumerd_fd_state {
+       ACTIVE_FD,
+       PAUSE_FD,
+       DELETE_FD,
 };
 
 /*
- * Data structure for ltt-session received message
+ * Data structure received from lttng client to session daemon.
  */
 struct lttcomm_session_msg {
-       /* Common data to almost all command */
-       enum lttcomm_command_type cmd_type;
-       uuid_t session_id;
+       u32 cmd_type;    /* enum lttcomm_sessiond_command */
+       uuid_t session_uuid;
        char trace_name[NAME_MAX];
        char session_name[NAME_MAX];
-       pid_t pid;
+       u32 pid;    /* pid_t */
        union {
                struct {
                        int auto_session;
@@ -121,19 +155,39 @@ struct lttcomm_session_msg {
 };
 
 /*
- * Data structure for the lttng client response.
- *
- * This data structure is the control struct use in
- * the header of the transmission. NEVER put variable
- * size data in here.
+ * Data structure for the response from sessiond to the lttng client.
  */
 struct lttcomm_lttng_msg {
-       enum lttcomm_command_type cmd_type;
-       enum lttcomm_return_code ret_code;
-       uuid_t session_id;
-       pid_t pid;
-       char trace_name[NAME_MAX];
-       unsigned int size_payload;
+       u32 cmd_type;   /* enum lttcomm_sessiond_command */
+       u32 ret_code;   /* enum lttcomm_return_code */
+       u32 pid;        /* pid_t */
+       u32 trace_name_offset;
+       u32 data_size;
+       uuid_t session_uuid;
+       /* Contains: trace_name + data */
+       char payload[];
+};
+
+/*
+ * Data structures for the kconsumerd communications
+ *
+ * The header structure is sent to the kconsumerd daemon to inform
+ * how many lttcomm_kconsumerd_msg it is about to receive
+ */
+struct lttcomm_kconsumerd_header {
+       u32 payload_size;
+       u32 cmd_type;   /* enum lttcomm_consumerd_command */
+       u32 ret_code;   /* enum lttcomm_return_code */
+};
+
+/* lttcomm_kconsumerd_msg represents a file descriptor to consume the
+ * data and a path name to write it
+ */
+struct lttcomm_kconsumerd_msg {
+       char path_name[PATH_MAX];
+       int fd;
+       u32 state;    /* enum lttcomm_kconsumerd_fd_state */
+       unsigned long max_sb_size; /* the subbuffer size for this channel */
 };
 
 extern int lttcomm_create_unix_sock(const char *pathname);
This page took 0.024555 seconds and 4 git commands to generate.