2 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
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
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.
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.
25 #include <lttng-sessiond-comm.h>
32 * Send registration done packet to the application.
34 int ustctl_register_done(int sock
)
36 struct lttcomm_ust_msg command
;
37 struct lttcomm_ust_reply
*reply
;
39 DBG("Sending register done command to %d", sock
);
41 command
.cmd
= LTTNG_UST_REGISTER_DONE
;
42 command
.handle
= LTTNG_UST_ROOT_HANDLE
;
44 reply
= ustcomm_send_command(sock
, &command
);
49 if (reply
->ret_code
!= LTTCOMM_OK
) {
50 DBG("Return code: %s", lttcomm_get_readable_code(reply
->ret_code
));
61 * Create an UST session on the tracer.
63 int ustctl_create_session(int sock
, struct ltt_ust_session
*session
)
65 struct lttcomm_ust_msg command
;
66 struct lttcomm_ust_reply
*reply
= NULL
;
68 command
.cmd
= LTTNG_UST_SESSION
;
69 command
.handle
= LTTNG_UST_ROOT_HANDLE
;
71 reply
= ustcomm_send_command(sock
, &command
);
76 if (reply
->ret_code
!= LTTCOMM_OK
) {
77 DBG("Return code: %s", lttcomm_get_readable_code(reply
->ret_code
));
81 /* Save session handle */
82 session
->handle
= reply
->ret_val
;
85 DBG2("ustctl create session command successful");
94 * Create UST channel to the tracer.
96 int ustctl_create_channel(int sock
, struct ltt_ust_session
*session
,
97 struct lttng_channel
*channel
)
99 struct lttcomm_ust_msg command
;
100 struct lttcomm_ust_reply
*reply
= NULL
;
101 struct ltt_ust_channel
*uchan
;
103 uchan
= trace_ust_create_channel(channel
, session
->path
);
108 memset(&command
, 0, sizeof(command
));
110 command
.cmd
= LTTNG_UST_CHANNEL
;
111 command
.handle
= session
->handle
;
113 /* Copy channel attributes to command */
114 memcpy(&command
.u
.channel
, &uchan
->attr
, sizeof(command
.u
.channel
));
116 reply
= ustcomm_send_command(sock
, &command
);
121 if (reply
->ret_code
!= LTTCOMM_OK
) {
122 DBG("Return code (%d): %s", reply
->ret_code
,
123 lttcomm_get_readable_code(reply
->ret_code
));
127 uchan
->handle
= reply
->ret_val
;
129 /* Add channel to session */
130 cds_list_add(&uchan
->list
, &session
->channels
.head
);
131 session
->channels
.count
++;
143 * Enable UST channel.
145 int ustctl_enable_channel(int sock
, struct ltt_ust_session
*session
,
146 struct ltt_ust_channel
*chan
)
148 struct lttcomm_ust_msg command
;
149 struct lttcomm_ust_reply
*reply
= NULL
;
151 memset(&command
, 0, sizeof(command
));
153 command
.cmd
= LTTNG_UST_ENABLE
;
154 command
.handle
= chan
->handle
;
156 reply
= ustcomm_send_command(sock
, &command
);
161 if (reply
->ret_code
!= LTTCOMM_OK
) {
162 DBG("Return code (%d): %s", reply
->ret_code
,
163 lttcomm_get_readable_code(reply
->ret_code
));
165 } else if (reply
->handle
!= chan
->handle
) {
166 ERR("Receive wrong handle from UST reply on enable channel");
173 DBG2("ustctl enable channel successful for sock %d", sock
);
182 * Disable UST channel.
184 int ustctl_disable_channel(int sock
, struct ltt_ust_session
*session
,
185 struct ltt_ust_channel
*chan
)
187 struct lttcomm_ust_msg command
;
188 struct lttcomm_ust_reply
*reply
= NULL
;
190 memset(&command
, 0, sizeof(command
));
192 command
.cmd
= LTTNG_UST_DISABLE
;
193 command
.handle
= chan
->handle
;
195 reply
= ustcomm_send_command(sock
, &command
);
200 if (reply
->ret_code
!= LTTCOMM_OK
) {
201 DBG("Return code (%d): %s", reply
->ret_code
,
202 lttcomm_get_readable_code(reply
->ret_code
));
204 } else if (reply
->handle
!= chan
->handle
) {
205 ERR("Receive wrong handle from UST reply on enable channel");
212 DBG2("ustctl disable channel successful for sock %d", sock
);
This page took 0.034878 seconds and 5 git commands to generate.