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 | ||
f263b7fd JD |
27 | #include <common/compat/endian.h> |
28 | ||
0f907de1 JD |
29 | #include "cmd-generic.h" |
30 | #include "cmd-2-1.h" | |
31 | #include "utils.h" | |
32 | ||
58eb9381 DG |
33 | int cmd_recv_stream_2_2(struct relay_connection *conn, |
34 | struct relay_stream *stream) | |
0f907de1 JD |
35 | { |
36 | int ret; | |
37 | struct lttcomm_relayd_add_stream_2_2 stream_info; | |
38 | ||
58eb9381 | 39 | assert(conn); |
0f907de1 JD |
40 | assert(stream); |
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.2"); | |
45 | goto error; | |
46 | } | |
47 | ||
48 | stream->path_name = create_output_path(stream_info.pathname); | |
49 | if (stream->path_name == NULL) { | |
50 | PERROR("Path name allocation"); | |
51 | ret = -ENOMEM; | |
52 | goto error; | |
53 | } | |
54 | ||
55 | stream->channel_name = strdup(stream_info.channel_name); | |
56 | if (stream->channel_name == NULL) { | |
57 | ret = -errno; | |
58 | PERROR("Path name allocation"); | |
59 | goto error; | |
60 | } | |
61 | ||
62 | stream->tracefile_size = be64toh(stream_info.tracefile_size); | |
63 | stream->tracefile_count = be64toh(stream_info.tracefile_count); | |
64 | ret = 0; | |
65 | ||
66 | error: | |
67 | return ret; | |
68 | } |