blob: b0978a6cbc50a82ff6c81bb8e4407c0c827dab83 [file] [log] [blame]
Philipp Maier87bd9be2017-08-22 16:35:41 +02001/* Message connection list handling */
2
3/*
4 * (C) 2017 by sysmocom s.f.m.c. GmbH <info@sysmocom.de>
5 * All Rights Reserved
6 *
7 * Author: Philipp Maier
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU Affero General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Affero General Public License for more details.
18 *
19 * You should have received a copy of the GNU Affero General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 *
22 */
23
24#pragma once
25
26#include <osmocom/mgcp/mgcp_internal.h>
27#include <osmocom/core/linuxlist.h>
Stefan Sperlingba25eab2018-10-30 14:32:31 +010028#include <osmocom/core/rate_ctr.h>
Philipp Maier87bd9be2017-08-22 16:35:41 +020029#include <inttypes.h>
30
Philipp Maiercede2a42018-07-03 14:14:21 +020031/* RTP connection related counters */
32enum {
33 IN_STREAM_ERR_TSTMP_CTR,
34 OUT_STREAM_ERR_TSTMP_CTR,
35 RTP_PACKETS_RX_CTR,
36 RTP_OCTETS_RX_CTR,
37 RTP_PACKETS_TX_CTR,
38 RTP_OCTETS_TX_CTR,
Stefan Sperlingba25eab2018-10-30 14:32:31 +010039 RTP_DROPPED_PACKETS_CTR,
40 RTP_NUM_CONNECTIONS,
41};
42
43/* RTP per-connection statistics. Instances of the corresponding rate counter group
44 * exist for the lifetime of an RTP connection.
45 * Must be kept in sync with all_rtp_conn_rate_ctr_desc below */
46static const struct rate_ctr_desc mgcp_conn_rate_ctr_desc[] = {
47 [IN_STREAM_ERR_TSTMP_CTR] = {"stream_err_tstmp:in", "Inbound rtp-stream timestamp errors."},
48 [OUT_STREAM_ERR_TSTMP_CTR] = {"stream_err_tstmp:out", "Outbound rtp-stream timestamp errors."},
49 [RTP_PACKETS_RX_CTR] = {"rtp:packets_rx", "Inbound rtp packets."},
50 [RTP_OCTETS_RX_CTR] = {"rtp:octets_rx", "Inbound rtp octets."},
51 [RTP_PACKETS_TX_CTR] = {"rtp:packets_tx", "Outbound rtp packets."},
52 [RTP_OCTETS_TX_CTR] = {"rtp:octets_tx", "Outbound rtp octets."},
53 [RTP_DROPPED_PACKETS_CTR] = {"rtp:dropped", "dropped rtp packets."}
54};
55
56/* Aggregated RTP connection stats. These are updated when an RTP connection is freed.
57 * Must be kept in sync with mgcp_conn_rate_ctr_desc above */
58static const struct rate_ctr_desc all_rtp_conn_rate_ctr_desc[] = {
59 [IN_STREAM_ERR_TSTMP_CTR] = {"all_rtp:err_tstmp_in", "Total inbound rtp-stream timestamp errors."},
60 [OUT_STREAM_ERR_TSTMP_CTR] = {"all_rtp:err_tstmp_out", "Total outbound rtp-stream timestamp errors."},
61 [RTP_PACKETS_RX_CTR] = {"all_rtp:packets_rx", "Total inbound rtp packets."},
62 [RTP_OCTETS_RX_CTR] = {"all_rtp:octets_rx", "Total inbound rtp octets."},
63 [RTP_PACKETS_TX_CTR] = {"all_rtp:packets_tx", "Total outbound rtp packets."},
64 [RTP_OCTETS_TX_CTR] = {"all_rtp:octets_tx", "Total outbound rtp octets."},
65 [RTP_DROPPED_PACKETS_CTR] = {"all_rtp:dropped", "Total dropped rtp packets."},
66
67 /* This last counter does not exist in per-connection stats, only here. */
68 [RTP_NUM_CONNECTIONS] = {"all_rtp:num_closed_conns", "Total number of rtp connections closed."}
Philipp Maiercede2a42018-07-03 14:14:21 +020069};
70
Philipp Maier87bd9be2017-08-22 16:35:41 +020071struct mgcp_conn *mgcp_conn_alloc(void *ctx, struct mgcp_endpoint *endp,
Philipp Maierffd75e42017-11-22 11:44:50 +010072 enum mgcp_conn_type type, char *name);
Philipp Maier01d24a32017-11-21 17:26:09 +010073struct mgcp_conn *mgcp_conn_get(struct mgcp_endpoint *endp, const char *id);
Philipp Maier87bd9be2017-08-22 16:35:41 +020074struct mgcp_conn_rtp *mgcp_conn_get_rtp(struct mgcp_endpoint *endp,
Philipp Maier01d24a32017-11-21 17:26:09 +010075 const char *id);
76void mgcp_conn_free(struct mgcp_endpoint *endp, const char *id);
Philipp Maier87bd9be2017-08-22 16:35:41 +020077void mgcp_conn_free_oldest(struct mgcp_endpoint *endp);
78void mgcp_conn_free_all(struct mgcp_endpoint *endp);
79char *mgcp_conn_dump(struct mgcp_conn *conn);
80struct mgcp_conn *mgcp_find_dst_conn(struct mgcp_conn *conn);