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>
6 * SPDX-License-Identifier: GPL-2.0-only
12 #include "cmd-2-4.hpp"
13 #include "lttng-relayd.hpp"
15 #include <common/common.hpp>
16 #include <common/compat/endian.hpp>
17 #include <common/compat/string.hpp>
18 #include <common/sessiond-comm/relayd.hpp>
20 #include <lttng/constant.h>
22 int cmd_create_session_2_4(const struct lttng_buffer_view
*payload
,
29 struct lttcomm_relayd_create_session_2_4 session_info
;
32 if (payload
->size
< sizeof(session_info
)) {
33 ERR("Unexpected payload size in \"cmd_create_session_2_4\": expected >= %zu bytes, got %zu bytes",
39 memcpy(&session_info
, payload
->data
, sizeof(session_info
));
41 len
= lttng_strnlen(session_info
.session_name
, sizeof(session_info
.session_name
));
42 /* Ensure that NULL-terminated and fits in local filename length. */
43 if (len
== sizeof(session_info
.session_name
) || len
>= LTTNG_NAME_MAX
) {
45 ERR("Session name too long");
47 } else if (len
== 0) {
49 ERR("Session name can't be of length 0");
52 strncpy(session_name
, session_info
.session_name
, LTTNG_NAME_MAX
);
54 len
= lttng_strnlen(session_info
.hostname
, sizeof(session_info
.hostname
));
55 if (len
== sizeof(session_info
.hostname
) || len
>= LTTNG_HOST_NAME_MAX
) {
57 ERR("Session name too long");
60 strncpy(hostname
, session_info
.hostname
, LTTNG_HOST_NAME_MAX
);
62 *live_timer
= be32toh(session_info
.live_timer
);
63 *snapshot
= be32toh(session_info
.snapshot
);