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.
26 #include <ust/lttng-ust-comm.h>
33 * Send registration done packet to the application.
35 int ustctl_register_done(int sock
)
37 struct lttcomm_ust_msg command
;
38 struct lttcomm_ust_reply
*reply
;
40 DBG("Sending register done command to %d", sock
);
42 command
.cmd
= LTTNG_UST_REGISTER_DONE
;
43 command
.handle
= LTTNG_UST_ROOT_HANDLE
;
45 reply
= ustcomm_send_command(sock
, &command
);
50 if (reply
->ret_code
!= USTCOMM_OK
) {
51 DBG("Return code: %s", ustcomm_get_readable_code(reply
->ret_code
));
62 * Create an UST session on the tracer.
64 int ustctl_create_session(int sock
, struct ltt_ust_session
*session
)
66 struct lttcomm_ust_msg command
;
67 struct lttcomm_ust_reply
*reply
= NULL
;
69 command
.cmd
= LTTNG_UST_SESSION
;
70 command
.handle
= LTTNG_UST_ROOT_HANDLE
;
72 reply
= ustcomm_send_command(sock
, &command
);
77 if (reply
->ret_code
!= USTCOMM_OK
) {
78 DBG("Return code: %s", ustcomm_get_readable_code(reply
->ret_code
));
82 /* Save session handle */
83 session
->handle
= reply
->ret_val
;
86 DBG2("ustctl create session command successful");
95 * Create UST channel to the tracer.
97 int ustctl_create_channel(int sock
, struct ltt_ust_session
*session
,
98 struct lttng_channel
*channel
)
100 struct lttcomm_ust_msg command
;
101 struct lttcomm_ust_reply
*reply
= NULL
;
102 struct ltt_ust_channel
*uchan
;
104 uchan
= trace_ust_create_channel(channel
, session
->path
);
109 memset(&command
, 0, sizeof(command
));
111 command
.cmd
= LTTNG_UST_CHANNEL
;
112 command
.handle
= session
->handle
;
114 /* Copy channel attributes to command */
115 memcpy(&command
.u
.channel
, &uchan
->attr
, sizeof(command
.u
.channel
));
117 reply
= ustcomm_send_command(sock
, &command
);
122 if (reply
->ret_code
!= USTCOMM_OK
) {
123 DBG("Return code (%d): %s", reply
->ret_code
,
124 ustcomm_get_readable_code(reply
->ret_code
));
128 uchan
->handle
= reply
->ret_val
;
130 /* Add channel to session */
131 cds_list_add(&uchan
->list
, &session
->channels
.head
);
132 session
->channels
.count
++;
144 * Enable UST channel.
146 int ustctl_enable_channel(int sock
, struct ltt_ust_session
*session
,
147 struct ltt_ust_channel
*chan
)
149 struct lttcomm_ust_msg command
;
150 struct lttcomm_ust_reply
*reply
= NULL
;
152 memset(&command
, 0, sizeof(command
));
154 command
.cmd
= LTTNG_UST_ENABLE
;
155 command
.handle
= chan
->handle
;
157 reply
= ustcomm_send_command(sock
, &command
);
162 if (reply
->ret_code
!= USTCOMM_OK
) {
163 DBG("Return code (%d): %s", reply
->ret_code
,
164 ustcomm_get_readable_code(reply
->ret_code
));
166 } else if (reply
->handle
!= chan
->handle
) {
167 ERR("Receive wrong handle from UST reply on enable channel");
174 DBG2("ustctl enable channel successful for sock %d", sock
);
183 * Disable UST channel.
185 int ustctl_disable_channel(int sock
, struct ltt_ust_session
*session
,
186 struct ltt_ust_channel
*chan
)
188 struct lttcomm_ust_msg command
;
189 struct lttcomm_ust_reply
*reply
= NULL
;
191 memset(&command
, 0, sizeof(command
));
193 command
.cmd
= LTTNG_UST_DISABLE
;
194 command
.handle
= chan
->handle
;
196 reply
= ustcomm_send_command(sock
, &command
);
201 if (reply
->ret_code
!= USTCOMM_OK
) {
202 DBG("Return code (%d): %s", reply
->ret_code
,
203 ustcomm_get_readable_code(reply
->ret_code
));
205 } else if (reply
->handle
!= chan
->handle
) {
206 ERR("Receive wrong handle from UST reply on enable channel");
213 DBG2("ustctl disable channel successful for sock %d", sock
);
This page took 0.052753 seconds and 4 git commands to generate.