Commit | Line | Data |
---|---|---|
0f907de1 JD |
1 | /* |
2 | * Copyright (C) 2013 - Julien Desfossez <jdesfossez@efficios.com> | |
3 | * David Goulet <dgoulet@efficios.com> | |
4 | * | |
5 | * This program is free software; you can redistribute it and/or modify it | |
6 | * under the terms of the GNU General Public License, version 2 only, as | |
7 | * published by the Free Software Foundation. | |
8 | * | |
9 | * This program is distributed in the hope that it will be useful, but WITHOUT | |
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
12 | * more details. | |
13 | * | |
14 | * You should have received a copy of the GNU General Public License along with | |
15 | * this program; if not, write to the Free Software Foundation, Inc., 51 | |
16 | * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
17 | */ | |
18 | ||
19 | #define _GNU_SOURCE | |
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 | ||
58eb9381 DG |
31 | int cmd_recv_stream_2_1(struct relay_connection *conn, |
32 | struct relay_stream *stream) | |
0f907de1 JD |
33 | { |
34 | int ret; | |
35 | struct lttcomm_relayd_add_stream stream_info; | |
36 | ||
58eb9381 | 37 | assert(conn); |
0f907de1 JD |
38 | assert(stream); |
39 | ||
58eb9381 | 40 | ret = cmd_recv(conn->sock, &stream_info, sizeof(stream_info)); |
0f907de1 JD |
41 | if (ret < 0) { |
42 | ERR("Unable to recv stream version 2.1"); | |
43 | goto error; | |
44 | } | |
45 | ||
46 | stream->path_name = create_output_path(stream_info.pathname); | |
47 | if (stream->path_name == NULL) { | |
48 | PERROR("Path name allocation"); | |
49 | ret = -ENOMEM; | |
50 | goto error; | |
51 | } | |
52 | ||
53 | stream->channel_name = strdup(stream_info.channel_name); | |
54 | if (stream->channel_name == NULL) { | |
55 | ret = -errno; | |
56 | PERROR("Path name allocation"); | |
57 | goto error; | |
58 | } | |
59 | ret = 0; | |
60 | ||
61 | error: | |
62 | return ret; | |
63 | } |