2 * Copyright (C) 2013 - Julien Desfossez <jdesfossez@efficios.com>
3 * David Goulet <dgoulet@efficios.com>
4 * 2015 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License, version 2 only, as
8 * published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 51
17 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #include <common/common.h>
24 #include <common/sessiond-comm/relayd.h>
25 #include <common/compat/string.h>
26 #include <lttng/constant.h>
28 #include "cmd-generic.h"
33 * cmd_recv_stream_2_1 allocates path_name and channel_name.
35 int cmd_recv_stream_2_1(struct relay_connection
*conn
,
36 char **ret_path_name
, char **ret_channel_name
)
39 struct lttcomm_relayd_add_stream stream_info
;
40 char *path_name
= NULL
;
41 char *channel_name
= NULL
;
44 ret
= cmd_recv(conn
->sock
, &stream_info
, sizeof(stream_info
));
46 ERR("Unable to recv stream version 2.1");
50 len
= lttng_strnlen(stream_info
.pathname
, sizeof(stream_info
.pathname
));
51 /* Ensure that NULL-terminated and fits in local filename length. */
52 if (len
== sizeof(stream_info
.pathname
) || len
>= LTTNG_NAME_MAX
) {
54 ERR("Path name too long");
57 path_name
= create_output_path(stream_info
.pathname
);
59 PERROR("Path name allocation");
63 len
= lttng_strnlen(stream_info
.channel_name
, sizeof(stream_info
.channel_name
));
64 if (len
== sizeof(stream_info
.channel_name
) || len
>= DEFAULT_STREAM_NAME_LEN
) {
66 ERR("Channel name too long");
69 channel_name
= strdup(stream_info
.channel_name
);
72 PERROR("Channel name allocation");
76 *ret_path_name
= path_name
;
77 *ret_channel_name
= channel_name
;