eeb1d545bb7ac279b81ef11798666bee2689c377
[lttng-tools.git] / src / bin / lttng-relayd / connection.h
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 #ifndef _CONNECTION_H
20 #define _CONNECTION_H
21
22 #include <limits.h>
23 #include <inttypes.h>
24 #include <pthread.h>
25 #include <urcu.h>
26 #include <urcu/wfqueue.h>
27 #include <urcu/list.h>
28
29 #include <common/hashtable/hashtable.h>
30 #include <common/sessiond-comm/sessiond-comm.h>
31
32 #include "session.h"
33
34 enum connection_type {
35 RELAY_DATA = 1,
36 RELAY_CONTROL = 2,
37 RELAY_VIEWER_COMMAND = 3,
38 RELAY_VIEWER_NOTIFICATION = 4,
39 };
40
41 /*
42 * Internal structure to map a socket with the corresponding session.
43 * A hashtable indexed on the socket FD is used for the lookups.
44 */
45 struct relay_connection {
46 struct lttcomm_sock *sock;
47 struct relay_session *session;
48 struct relay_viewer_session *viewer_session;
49 struct cds_wfq_node qnode;
50 struct lttng_ht_node_ulong sock_n;
51 struct rcu_head rcu_node;
52 enum connection_type type;
53 /* Protocol version to use for this connection. */
54 uint32_t major;
55 uint32_t minor;
56 uint64_t session_id;
57 struct cds_list_head recv_head;
58 unsigned int version_check_done:1;
59
60 /* Pointer to the sessions HT that this connection can use. */
61 struct lttng_ht *sessions_ht;
62 };
63
64 struct relay_connection *connection_find_by_sock(struct lttng_ht *ht,
65 int sock);
66 struct relay_connection *connection_create(void);
67 void connection_init(struct relay_connection *conn);
68 void connection_delete(struct lttng_ht *ht, struct relay_connection *conn);
69 void connection_destroy(struct relay_connection *conn);
70 void connection_free(struct relay_connection *conn);
71
72 #endif /* _CONNECTION_H */
This page took 0.029708 seconds and 3 git commands to generate.