blob: 16792397a6c4be18fb569f811678d5754e1358ee [file] [log] [blame]
Philipp Maierc66ab2c2020-06-02 20:55:34 +02001#pragma once
2
Philipp Maier889fe7f2020-07-06 17:44:12 +02003#include <osmocom/gsm/i460_mux.h>
Philipp Maier3c293b42020-11-26 22:16:23 +01004#include <osmocom/abis/e1_input.h>
Eric1e8d5fa2021-08-24 01:36:49 +02005#include <osmocom/mgcp/mgcp_ratectr.h>
6
Philipp Maier889fe7f2020-07-06 17:44:12 +02007
8#define LOGPTRUNK(trunk, cat, level, fmt, args...) \
9LOGP(cat, level, "trunk:%u " fmt, \
10 trunk ? trunk->trunk_nr : 0, \
11 ## args)
12
Philipp Maierbea56782020-07-01 23:18:58 +020013enum mgcp_trunk_type {
14 MGCP_TRUNK_VIRTUAL,
15 MGCP_TRUNK_E1,
16};
17
Philipp Maierbd060c32021-07-09 10:24:33 +020018extern const struct value_string mgcp_trunk_type_strs[];
19static inline const char *mgcp_trunk_type_strs_str(enum mgcp_trunk_type val)
20{ return get_value_string(mgcp_trunk_type_strs, val); }
21
Philipp Maierc66ab2c2020-06-02 20:55:34 +020022struct mgcp_trunk {
23 struct llist_head entry;
24
25 struct mgcp_config *cfg;
26
Philipp Maierd70eef62021-07-19 13:53:28 +020027 unsigned int trunk_nr;
Philipp Maier04bbb9d2020-07-02 21:21:26 +020028 enum mgcp_trunk_type trunk_type;
Philipp Maierc66ab2c2020-06-02 20:55:34 +020029
Philipp Maierc66ab2c2020-06-02 20:55:34 +020030 int audio_send_ptime;
31 int audio_send_name;
Philipp Maierc66ab2c2020-06-02 20:55:34 +020032
Philipp Maierc66ab2c2020-06-02 20:55:34 +020033 int omit_rtcp;
34 int keepalive_interval;
35
36 /* RTP patching */
37 int force_constant_ssrc; /* 0: don't, 1: once */
38 int force_aligned_timing;
39 bool rfc5993_hr_convert;
40
41 /* spec handling */
42 int force_realloc;
43
44 /* timer */
45 struct osmo_timer_list keepalive_timer;
46
47 /* When set, incoming RTP packets are not filtered
48 * when ports and ip-address do not match (debug) */
49 int rtp_accept_all;
50
51 unsigned int number_endpoints;
Philipp Maierc66ab2c2020-06-02 20:55:34 +020052 struct mgcp_endpoint **endpoints;
53
Philipp Maier124a3e02021-07-26 11:17:15 +020054 /* rate counters and stat items to measure the trunks overall performance and health */
Philipp Maierc66ab2c2020-06-02 20:55:34 +020055 struct mgcp_ratectr_trunk ratectr;
Philipp Maier124a3e02021-07-26 11:17:15 +020056 struct mgcp_stat_trunk stats;
Philipp Maier889fe7f2020-07-06 17:44:12 +020057
58 union {
59 /* Virtual trunk specific */
60 struct {
61 unsigned int vty_number_endpoints;
62 } v;
63 /* E1 specific */
64 struct {
65 unsigned int vty_line_nr;
Philipp Maier2a9ba662023-02-09 13:39:31 +010066 uint8_t ts_usecount[NUM_E1_TS-1];
Philipp Maier3c293b42020-11-26 22:16:23 +010067 struct osmo_i460_timeslot i460_ts[NUM_E1_TS-1];
68 /* Note: on an E1 line TS 0 is devoted to framing and
69 * alignment and therefore only NUM_E1_TS-1 timeslots
70 * are available for traffic. */
Philipp Maier889fe7f2020-07-06 17:44:12 +020071 } e1;
72 };
Philipp Maierc66ab2c2020-06-02 20:55:34 +020073};
74
Philipp Maierd70eef62021-07-19 13:53:28 +020075struct mgcp_trunk *mgcp_trunk_alloc(struct mgcp_config *cfg, enum mgcp_trunk_type ttype, unsigned int nr);
Philipp Maier889fe7f2020-07-06 17:44:12 +020076int mgcp_trunk_equip(struct mgcp_trunk *trunk);
Philipp Maierd70eef62021-07-19 13:53:28 +020077struct mgcp_trunk *mgcp_trunk_by_num(const struct mgcp_config *cfg, enum mgcp_trunk_type ttype, unsigned int nr);
Philipp Maierc66ab2c2020-06-02 20:55:34 +020078struct mgcp_trunk *mgcp_trunk_by_name(const struct mgcp_config *cfg, const char *epname);
Philipp Maierd70eef62021-07-19 13:53:28 +020079int e1_trunk_nr_from_epname(unsigned int *trunk_nr, const char *epname);
Philipp Maier889fe7f2020-07-06 17:44:12 +020080struct mgcp_trunk *mgcp_trunk_by_line_num(const struct mgcp_config *cfg, unsigned int num);
Philipp Maierd19de2e2020-06-03 13:55:33 +020081
82/* The virtual trunk is always created on trunk id 0 for historical reasons,
83 * use this define constant as ID when allocating a virtual trunk. Other
84 * trunks may be assigned with arbritrary id numbers */
85#define MGCP_VIRT_TRUNK_ID 0