blob: 812718147a721ce0f576f9d0837c864980f9237b [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>
4
5#define LOGPTRUNK(trunk, cat, level, fmt, args...) \
6LOGP(cat, level, "trunk:%u " fmt, \
7 trunk ? trunk->trunk_nr : 0, \
8 ## args)
9
10
Philipp Maierbea56782020-07-01 23:18:58 +020011enum mgcp_trunk_type {
12 MGCP_TRUNK_VIRTUAL,
13 MGCP_TRUNK_E1,
14};
15
Philipp Maierc66ab2c2020-06-02 20:55:34 +020016struct mgcp_trunk {
17 struct llist_head entry;
18
19 struct mgcp_config *cfg;
20
21 int trunk_nr;
Philipp Maier04bbb9d2020-07-02 21:21:26 +020022 enum mgcp_trunk_type trunk_type;
Philipp Maierc66ab2c2020-06-02 20:55:34 +020023
24 char *audio_fmtp_extra;
Philipp Maierc66ab2c2020-06-02 20:55:34 +020025 int audio_send_ptime;
26 int audio_send_name;
Philipp Maierc66ab2c2020-06-02 20:55:34 +020027
28 int no_audio_transcoding;
29
30 int omit_rtcp;
31 int keepalive_interval;
32
33 /* RTP patching */
34 int force_constant_ssrc; /* 0: don't, 1: once */
35 int force_aligned_timing;
36 bool rfc5993_hr_convert;
37
38 /* spec handling */
39 int force_realloc;
40
41 /* timer */
42 struct osmo_timer_list keepalive_timer;
43
44 /* When set, incoming RTP packets are not filtered
45 * when ports and ip-address do not match (debug) */
46 int rtp_accept_all;
47
48 unsigned int number_endpoints;
Philipp Maierc66ab2c2020-06-02 20:55:34 +020049 struct mgcp_endpoint **endpoints;
50
51 /* global rate counters to measure the trunks overall performance and health */
52 struct mgcp_ratectr_trunk ratectr;
Philipp Maier889fe7f2020-07-06 17:44:12 +020053
54 union {
55 /* Virtual trunk specific */
56 struct {
57 unsigned int vty_number_endpoints;
58 } v;
59 /* E1 specific */
60 struct {
61 unsigned int vty_line_nr;
Philipp Maier889fe7f2020-07-06 17:44:12 +020062 bool ts_in_use[31];
63 struct osmo_i460_timeslot i460_ts[31];
64 } e1;
65 };
Philipp Maierc66ab2c2020-06-02 20:55:34 +020066};
67
68struct mgcp_trunk *mgcp_trunk_alloc(struct mgcp_config *cfg, enum mgcp_trunk_type ttype, int nr);
Philipp Maier889fe7f2020-07-06 17:44:12 +020069int mgcp_trunk_equip(struct mgcp_trunk *trunk);
Philipp Maier6fbbeec2020-07-01 23:00:54 +020070struct mgcp_trunk *mgcp_trunk_by_num(const struct mgcp_config *cfg, enum mgcp_trunk_type ttype, int nr);
Philipp Maierc66ab2c2020-06-02 20:55:34 +020071struct mgcp_trunk *mgcp_trunk_by_name(const struct mgcp_config *cfg, const char *epname);
Philipp Maier7e9ddc92020-06-10 15:22:32 +020072int e1_trunk_nr_from_epname(const char *epname);
Philipp Maier889fe7f2020-07-06 17:44:12 +020073struct mgcp_trunk *mgcp_trunk_by_line_num(const struct mgcp_config *cfg, unsigned int num);
Philipp Maierd19de2e2020-06-03 13:55:33 +020074
75/* The virtual trunk is always created on trunk id 0 for historical reasons,
76 * use this define constant as ID when allocating a virtual trunk. Other
77 * trunks may be assigned with arbritrary id numbers */
78#define MGCP_VIRT_TRUNK_ID 0