Add support for UST application registration
[lttng-tools.git] / ltt-sessiond / ust-comm.c
CommitLineData
099e26bd
DG
1/*
2 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; only version 2
7 * of the License.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19#include <lttngerr.h>
20
21#include "ust-comm.h"
22
23/*
24 * Send msg containing a command to an UST application via sock and wait for
25 * the reply.
26 *
27 * Return -1 on error or if reply fails else return 0.
28 */
29int ustcomm_send_command(int sock, struct lttcomm_ust_msg *msg)
30{
31 ssize_t len;
32 struct lttcomm_ust_reply reply;
33
34 DBG("Sending UST command %d to sock %d", msg->cmd, sock);
35
36 /* Send UST msg */
37 len = lttcomm_send_unix_sock(sock, msg, sizeof(*msg));
38 if (len < 0) {
39 goto error;
40 }
41
42 DBG("Receiving UST reply on sock %d", sock);
43
44 /* Get UST reply */
45 len = lttcomm_recv_unix_sock(sock, &reply, sizeof(reply));
46 if (len < 0) {
47 goto error;
48 }
49
50 if (reply.ret_code != LTTCOMM_OK) {
51 goto error;
52 }
53
54 return 0;
55
56error:
57 return -1;
58}
This page took 0.02424 seconds and 4 git commands to generate.