vscode: Add configurations to run the executables under the debugger
[lttng-tools.git] / src / bin / lttng-relayd / cmd-2-4.c
1 /*
2 * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
3 * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
4 * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
5 *
6 * SPDX-License-Identifier: GPL-2.0-only
7 *
8 */
9
10 #define _LGPL_SOURCE
11
12 #include <common/common.h>
13 #include <common/sessiond-comm/relayd.h>
14
15 #include <common/compat/endian.h>
16 #include <common/compat/string.h>
17 #include <lttng/constant.h>
18
19 #include "cmd-2-4.h"
20 #include "lttng-relayd.h"
21
22 int cmd_create_session_2_4(const struct lttng_buffer_view *payload,
23 char *session_name, char *hostname,
24 uint32_t *live_timer, bool *snapshot)
25 {
26 int ret;
27 struct lttcomm_relayd_create_session_2_4 session_info;
28 size_t len;
29
30 if (payload->size < sizeof(session_info)) {
31 ERR("Unexpected payload size in \"cmd_create_session_2_4\": expected >= %zu bytes, got %zu bytes",
32 sizeof(session_info), payload->size);
33 ret = -1;
34 goto error;
35 }
36 memcpy(&session_info, payload->data, sizeof(session_info));
37
38 len = lttng_strnlen(session_info.session_name, sizeof(session_info.session_name));
39 /* Ensure that NULL-terminated and fits in local filename length. */
40 if (len == sizeof(session_info.session_name) || len >= LTTNG_NAME_MAX) {
41 ret = -ENAMETOOLONG;
42 ERR("Session name too long");
43 goto error;
44 } else if (len == 0) {
45 ret = -EINVAL;
46 ERR("Session name can't be of length 0");
47 goto error;
48 }
49 strncpy(session_name, session_info.session_name, LTTNG_NAME_MAX);
50
51 len = lttng_strnlen(session_info.hostname, sizeof(session_info.hostname));
52 if (len == sizeof(session_info.hostname) || len >= LTTNG_HOST_NAME_MAX) {
53 ret = -ENAMETOOLONG;
54 ERR("Session name too long");
55 goto error;
56 }
57 strncpy(hostname, session_info.hostname, LTTNG_HOST_NAME_MAX);
58
59 *live_timer = be32toh(session_info.live_timer);
60 *snapshot = be32toh(session_info.snapshot);
61
62 ret = 0;
63
64 error:
65 return ret;
66 }
This page took 0.029798 seconds and 4 git commands to generate.