Commit | Line | Data |
---|---|---|
0f907de1 JD |
1 | /* |
2 | * Copyright (C) 2013 - Julien Desfossez <jdesfossez@efficios.com> | |
3 | * David Goulet <dgoulet@efficios.com> | |
5a693d30 | 4 | * 2015 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com> |
0f907de1 JD |
5 | * |
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. | |
9 | * | |
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 | |
13 | * more details. | |
14 | * | |
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. | |
18 | */ | |
19 | ||
20 | #define _GNU_SOURCE | |
6c1c0768 | 21 | #define _LGPL_SOURCE |
0f907de1 JD |
22 | #include <assert.h> |
23 | #include <string.h> | |
24 | ||
25 | #include <common/common.h> | |
26 | #include <common/sessiond-comm/relayd.h> | |
27 | ||
28 | #include "cmd-generic.h" | |
29 | #include "cmd-2-1.h" | |
30 | #include "utils.h" | |
31 | ||
5a693d30 MD |
32 | /* |
33 | * cmd_recv_stream_2_1 allocates path_name and channel_name. | |
34 | */ | |
58eb9381 | 35 | int cmd_recv_stream_2_1(struct relay_connection *conn, |
5a693d30 | 36 | char **ret_path_name, char **ret_channel_name) |
0f907de1 JD |
37 | { |
38 | int ret; | |
39 | struct lttcomm_relayd_add_stream stream_info; | |
5a693d30 MD |
40 | char *path_name = NULL; |
41 | char *channel_name = NULL; | |
0f907de1 | 42 | |
58eb9381 | 43 | ret = cmd_recv(conn->sock, &stream_info, sizeof(stream_info)); |
0f907de1 JD |
44 | if (ret < 0) { |
45 | ERR("Unable to recv stream version 2.1"); | |
46 | goto error; | |
47 | } | |
48 | ||
5a693d30 MD |
49 | path_name = create_output_path(stream_info.pathname); |
50 | if (!path_name) { | |
0f907de1 JD |
51 | PERROR("Path name allocation"); |
52 | ret = -ENOMEM; | |
53 | goto error; | |
54 | } | |
55 | ||
5a693d30 MD |
56 | channel_name = strdup(stream_info.channel_name); |
57 | if (!channel_name) { | |
0f907de1 JD |
58 | ret = -errno; |
59 | PERROR("Path name allocation"); | |
60 | goto error; | |
61 | } | |
0f907de1 | 62 | |
5a693d30 MD |
63 | *ret_path_name = path_name; |
64 | *ret_channel_name = channel_name; | |
65 | return 0; | |
0f907de1 | 66 | error: |
5a693d30 MD |
67 | free(path_name); |
68 | free(channel_name); | |
0f907de1 JD |
69 | return ret; |
70 | } |