osmo-mgw: refactor endpoint and trunk handling
The trunk and endpoint handling in osmo-mgw is still very complex and
implemented in various places (mostly mgcp_protocol.c). Also we use
still integers for endpoint identification, which is not flexible enough
to address timeslots/subslots on an E1 trunk. Some refactoring is needed.
- get rid of integers as endpoint identifiers, use strings instead and
find the endpoint based on its string name on the trunk.
- identify the trunk based on the trunk prefix given in the endpoint
name.
- refactor trunk and endpoint allocation. Aggregate functionality in
in mgcp_endp.c and mgcp_trunk.c. Also remove non-reusable code that
relates to the still exisiting, but unfinished E1 trunk support.
- refactor rate counters, put them into a separate module and do no
longer allocate them per trunk. Allocate them globally instead.
Change-Id: Ia8cf4d6caf05a4e13f1f507dc68cbabb7e6239aa
Related: OS#2659
diff --git a/include/osmocom/mgcp/mgcp_ratectr.h b/include/osmocom/mgcp/mgcp_ratectr.h
new file mode 100644
index 0000000..e05b70c
--- /dev/null
+++ b/include/osmocom/mgcp/mgcp_ratectr.h
@@ -0,0 +1,22 @@
+#pragma once
+
+/* NOTE: When adding counters, also the dump_ratectr_* routines in vty.c must be updated. */
+
+struct mgcp_ratectr_global {
+ /* Rate counter group which contains stats for generic MGCP events. */
+ struct rate_ctr_group *mgcp_general_ctr_group;
+};
+
+struct mgcp_ratectr_trunk {
+ /* Rate counter group which contains stats for processed CRCX commands. */
+ struct rate_ctr_group *mgcp_crcx_ctr_group;
+ /* Rate counter group which contains stats for processed MDCX commands. */
+ struct rate_ctr_group *mgcp_mdcx_ctr_group;
+ /* Rate counter group which contains stats for processed DLCX commands. */
+ struct rate_ctr_group *mgcp_dlcx_ctr_group;
+ /* Rate counter group which aggregates stats of individual RTP connections. */
+ struct rate_ctr_group *all_rtp_conn_stats;
+};
+
+int mgcp_ratectr_global_alloc(void *ctx, struct mgcp_ratectr_global *ratectr);
+int mgcp_ratectr_trunk_alloc(void *ctx, struct mgcp_ratectr_trunk *ratectr);