blob: d99f801a3fd080496e027d1f11f959420d73f366 [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;
27 int audio_loop;
28
29 int no_audio_transcoding;
30
31 int omit_rtcp;
32 int keepalive_interval;
33
34 /* RTP patching */
35 int force_constant_ssrc; /* 0: don't, 1: once */
36 int force_aligned_timing;
37 bool rfc5993_hr_convert;
38
39 /* spec handling */
40 int force_realloc;
41
42 /* timer */
43 struct osmo_timer_list keepalive_timer;
44
45 /* When set, incoming RTP packets are not filtered
46 * when ports and ip-address do not match (debug) */
47 int rtp_accept_all;
48
49 unsigned int number_endpoints;
Philipp Maierc66ab2c2020-06-02 20:55:34 +020050 struct mgcp_endpoint **endpoints;
51
52 /* global rate counters to measure the trunks overall performance and health */
53 struct mgcp_ratectr_trunk ratectr;
Philipp Maier889fe7f2020-07-06 17:44:12 +020054
55 union {
56 /* Virtual trunk specific */
57 struct {
58 unsigned int vty_number_endpoints;
59 } v;
60 /* E1 specific */
61 struct {
62 unsigned int vty_line_nr;
63 struct e1inp_line *line;
64 bool ts_in_use[31];
65 struct osmo_i460_timeslot i460_ts[31];
66 } e1;
67 };
Philipp Maierc66ab2c2020-06-02 20:55:34 +020068};
69
70struct mgcp_trunk *mgcp_trunk_alloc(struct mgcp_config *cfg, enum mgcp_trunk_type ttype, int nr);
Philipp Maier889fe7f2020-07-06 17:44:12 +020071int mgcp_trunk_equip(struct mgcp_trunk *trunk);
Philipp Maier6fbbeec2020-07-01 23:00:54 +020072struct 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 +020073struct mgcp_trunk *mgcp_trunk_by_name(const struct mgcp_config *cfg, const char *epname);
Philipp Maier7e9ddc92020-06-10 15:22:32 +020074int e1_trunk_nr_from_epname(const char *epname);
Philipp Maier889fe7f2020-07-06 17:44:12 +020075struct mgcp_trunk *mgcp_trunk_by_line_num(const struct mgcp_config *cfg, unsigned int num);
Philipp Maierd19de2e2020-06-03 13:55:33 +020076
77/* The virtual trunk is always created on trunk id 0 for historical reasons,
78 * use this define constant as ID when allocating a virtual trunk. Other
79 * trunks may be assigned with arbritrary id numbers */
80#define MGCP_VIRT_TRUNK_ID 0