X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-relayd%2Fconnection.h;fp=src%2Fbin%2Flttng-relayd%2Fconnection.h;h=6fb8913bf4dc53756fc8e68a872b394f69c24efc;hp=0000000000000000000000000000000000000000;hb=58eb9381cd933f0644e6a5b89750dbd6d9b14570;hpb=2a174661a1e0ab551b41ff1cae7191688525fc1f diff --git a/src/bin/lttng-relayd/connection.h b/src/bin/lttng-relayd/connection.h new file mode 100644 index 000000000..6fb8913bf --- /dev/null +++ b/src/bin/lttng-relayd/connection.h @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2013 - Julien Desfossez + * David Goulet + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License, version 2 only, as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef _CONNECTION_H +#define _CONNECTION_H + +#include +#include +#include +#include +#include + +#include +#include + +#include "session.h" + +enum connection_type { + RELAY_DATA = 1, + RELAY_CONTROL = 2, + RELAY_VIEWER_COMMAND = 3, + RELAY_VIEWER_NOTIFICATION = 4, +}; + +/* + * Internal structure to map a socket with the corresponding session. + * A hashtable indexed on the socket FD is used for the lookups. + */ +struct relay_connection { + struct lttcomm_sock *sock; + struct relay_session *session; + struct cds_wfq_node qnode; + struct lttng_ht_node_ulong sock_n; + struct rcu_head rcu_node; + enum connection_type type; + /* Protocol version to use for this connection. */ + uint32_t major; + uint32_t minor; + uint64_t session_id; + struct cds_list_head recv_head; + unsigned int version_check_done:1; + + /* Pointer to the sessions HT that this connection can use. */ + struct lttng_ht *sessions_ht; +}; + +struct relay_connection *connection_find_by_sock(struct lttng_ht *ht, + int sock); +struct relay_connection *connection_create(void); +void connection_init(struct relay_connection *conn); +void connection_delete(struct lttng_ht *ht, struct relay_connection *conn); +void connection_destroy(struct relay_connection *conn); +void connection_free(struct relay_connection *conn); + +#endif /* _CONNECTION_H */