/* Communication structure to ltt-sessiond */
static struct lttcomm_session_msg lsm;
-static struct lttcomm_lttng_msg llm;
+static struct lttcomm_lttng_header llh;
/* Prototypes */
static int check_tracing_group(const char *grp_name);
-static int ask_sessiond(enum lttcomm_command_type lct, void **buf);
+static int ask_sessiond(enum lttcomm_sessiond_command lct, void **buf);
static int recv_data_sessiond(void *buf, size_t len);
static int send_data_sessiond(void);
static int set_session_daemon_path(void);
*
* Return size of data (only payload, not header).
*/
-static int ask_sessiond(enum lttcomm_command_type lct, void **buf)
+static int ask_sessiond(enum lttcomm_sessiond_command lct, void **buf)
{
int ret;
size_t size;
}
/* Get header from data transmission */
- ret = recv_data_sessiond(&llm, sizeof(llm));
+ ret = recv_data_sessiond(&llh, sizeof(llh));
if (ret < 0) {
goto end;
}
/* Check error code if OK */
- if (llm.ret_code != LTTCOMM_OK) {
- ret = -llm.ret_code;
+ if (llh.ret_code != LTTCOMM_OK) {
+ ret = -llh.ret_code;
goto end;
}
- size = llm.size_payload;
+ size = llh.payload_size;
if (size == 0) {
goto end;
}
goto end;
}
- uuid_copy(*session_id, llm.session_id);
+ uuid_copy(*session_id, llh.session_id);
end:
return ret;
static int send_unix_sock(int sock, void *buf, size_t len);
static int set_signal_handler(void);
static int set_permissions(void);
-static int setup_data_buffer(char **buf, size_t size, struct lttcomm_lttng_msg *llm);
+static int setup_data_buffer(char **buf, size_t size, struct lttcomm_lttng_header *llh);
static int create_lttng_rundir(void);
static int set_kconsumerd_sockets(void);
static void cleanup(void);
-static void copy_common_data(struct lttcomm_lttng_msg *llm, struct lttcomm_session_msg *lsm);
+static void copy_common_data(struct lttcomm_lttng_header *llh, struct lttcomm_session_msg *lsm);
static void sighandler(int sig);
static void *thread_manage_clients(void *data);
/* This function dispatch the work to the LTTng or UST libs
* and then sends back the response to the client. This is needed
- * because there might be more then one lttcomm_lttng_msg to
+ * because there might be more then one lttcomm_lttng_header to
* send out so process_client_msg do both jobs.
*/
ret = process_client_msg(sock, &lsm);
/*
* copy_common_data
*
- * Copy common data between lttcomm_lttng_msg and lttcomm_session_msg
+ * Copy common data between lttcomm_lttng_header and lttcomm_session_msg
*/
-static void copy_common_data(struct lttcomm_lttng_msg *llm, struct lttcomm_session_msg *lsm)
+static void copy_common_data(struct lttcomm_lttng_header *llh, struct lttcomm_session_msg *lsm)
{
- llm->cmd_type = lsm->cmd_type;
- llm->pid = lsm->pid;
+ llh->cmd_type = lsm->cmd_type;
+ llh->pid = lsm->pid;
/* Manage uuid */
if (!uuid_is_null(lsm->session_id)) {
- uuid_copy(llm->session_id, lsm->session_id);
+ uuid_copy(llh->session_id, lsm->session_id);
}
- strncpy(llm->trace_name, lsm->trace_name, strlen(llm->trace_name));
- llm->trace_name[strlen(llm->trace_name) - 1] = '\0';
+ strncpy(llh->trace_name, lsm->trace_name, strlen(llh->trace_name));
+ llh->trace_name[strlen(llh->trace_name) - 1] = '\0';
}
/*
*
* Return total size of the buffer pointed by buf.
*/
-static int setup_data_buffer(char **buf, size_t s_data, struct lttcomm_lttng_msg *llm)
+static int setup_data_buffer(char **buf, size_t s_data, struct lttcomm_lttng_header *llh)
{
int ret = 0;
size_t buf_size;
- buf_size = sizeof(struct lttcomm_lttng_msg) + s_data;
+ buf_size = sizeof(struct lttcomm_lttng_header) + s_data;
*buf = malloc(buf_size);
if (*buf == NULL) {
perror("malloc");
goto error;
}
- /* Setup lttcomm_lttng_msg data and copy
+ /* Setup lttcomm_lttng_header data and copy
* it to the newly allocated buffer.
*/
- llm->size_payload = s_data;
- memcpy(*buf, llm, sizeof(struct lttcomm_lttng_msg));
+ llh->payload_size = s_data;
+ memcpy(*buf, llh, sizeof(struct lttcomm_lttng_header));
return buf_size;
int buf_size;
size_t header_size;
char *send_buf = NULL;
- struct lttcomm_lttng_msg llm;
+ struct lttcomm_lttng_header llh;
DBG("Processing client message");
/* Copy common data to identify the response
* on the lttng client side.
*/
- copy_common_data(&llm, lsm);
+ copy_common_data(&llh, lsm);
/* Check command that needs a session */
if (lsm->cmd_type != LTTNG_CREATE_SESSION &&
/* Default return code.
* In our world, everything is OK... right? ;)
*/
- llm.ret_code = LTTCOMM_OK;
+ llh.ret_code = LTTCOMM_OK;
- header_size = sizeof(struct lttcomm_lttng_msg);
+ header_size = sizeof(struct lttcomm_lttng_header);
/* Process by command type */
switch (lsm->cmd_type) {
case LTTNG_CREATE_SESSION:
{
- ret = create_session(lsm->session_name, &llm.session_id);
+ ret = create_session(lsm->session_name, &llh.session_id);
if (ret < 0) {
if (ret == -1) {
ret = LTTCOMM_EXIST_SESS;
goto end;
}
- buf_size = setup_data_buffer(&send_buf, 0, &llm);
+ buf_size = setup_data_buffer(&send_buf, 0, &llh);
if (buf_size < 0) {
ret = LTTCOMM_FATAL;
goto end;
ret = LTTCOMM_OK;
}
- /* No auxiliary data so only send the llm struct. */
+ /* No auxiliary data so only send the llh struct. */
goto end;
}
case LTTNG_LIST_TRACES:
}
buf_size = setup_data_buffer(&send_buf,
- sizeof(struct lttng_trace) * trace_count, &llm);
+ sizeof(struct lttng_trace) * trace_count, &llh);
if (buf_size < 0) {
ret = LTTCOMM_FATAL;
goto end;
goto end;
}
- /* No auxiliary data so only send the llm struct. */
+ /* No auxiliary data so only send the llh struct. */
goto end;
}
case UST_LIST_APPS:
/* Setup data buffer and details for transmission */
buf_size = setup_data_buffer(&send_buf,
- sizeof(pid_t) * app_count, &llm);
+ sizeof(pid_t) * app_count, &llh);
if (buf_size < 0) {
ret = LTTCOMM_FATAL;
goto end;
{
ret = ust_start_trace(lsm->pid);
- /* No auxiliary data so only send the llm struct. */
+ /* No auxiliary data so only send the llh struct. */
goto end;
}
case UST_STOP_TRACE:
{
ret = ust_stop_trace(lsm->pid);
- /* No auxiliary data so only send the llm struct. */
+ /* No auxiliary data so only send the llh struct. */
goto end;
}
case LTTNG_LIST_SESSIONS:
/* Setup data buffer and details for transmission */
buf_size = setup_data_buffer(&send_buf,
- (sizeof(struct lttng_session) * session_count), &llm);
+ (sizeof(struct lttng_session) * session_count), &llh);
if (buf_size < 0) {
ret = LTTCOMM_FATAL;
goto end;
end:
DBG("Return code to client %d", ret);
/* Notify client of error */
- llm.ret_code = ret;
- llm.size_payload = 0;
- send_unix_sock(sock, (void*) &llm, sizeof(llm));
+ llh.ret_code = ret;
+ llh.payload_size = 0;
+ send_unix_sock(sock, (void*) &llh, sizeof(llh));
return ret;
}