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