blob: 048ac5bca718600ff95c7f63e6d8cd56481730e4 [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>
Philipp Maier889fe7f2020-07-06 17:44:12 +02005
6#define LOGPTRUNK(trunk, cat, level, fmt, args...) \
7LOGP(cat, level, "trunk:%u " fmt, \
8 trunk ? trunk->trunk_nr : 0, \
9 ## args)
10
Philipp Maierbea56782020-07-01 23:18:58 +020011enum mgcp_trunk_type {
12 MGCP_TRUNK_VIRTUAL,
13 MGCP_TRUNK_E1,
14};
15
Philipp Maierbd060c32021-07-09 10:24:33 +020016extern const struct value_string mgcp_trunk_type_strs[];
17static inline const char *mgcp_trunk_type_strs_str(enum mgcp_trunk_type val)
18{ return get_value_string(mgcp_trunk_type_strs, val); }
19
Philipp Maierc66ab2c2020-06-02 20:55:34 +020020struct mgcp_trunk {
21 struct llist_head entry;
22
23 struct mgcp_config *cfg;
24
Philipp Maierd70eef62021-07-19 13:53:28 +020025 unsigned int trunk_nr;
Philipp Maier04bbb9d2020-07-02 21:21:26 +020026 enum mgcp_trunk_type trunk_type;
Philipp Maierc66ab2c2020-06-02 20:55:34 +020027
28 char *audio_fmtp_extra;
Philipp Maierc66ab2c2020-06-02 20:55:34 +020029 int audio_send_ptime;
30 int audio_send_name;
Philipp Maierc66ab2c2020-06-02 20:55:34 +020031
32 int no_audio_transcoding;
33
34 int omit_rtcp;
35 int keepalive_interval;
36
37 /* RTP patching */
38 int force_constant_ssrc; /* 0: don't, 1: once */
39 int force_aligned_timing;
40 bool rfc5993_hr_convert;
41
42 /* spec handling */
43 int force_realloc;
44
45 /* timer */
46 struct osmo_timer_list keepalive_timer;
47
48 /* When set, incoming RTP packets are not filtered
49 * when ports and ip-address do not match (debug) */
50 int rtp_accept_all;
51
52 unsigned int number_endpoints;
Philipp Maierc66ab2c2020-06-02 20:55:34 +020053 struct mgcp_endpoint **endpoints;
54
55 /* global rate counters to measure the trunks overall performance and health */
56 struct mgcp_ratectr_trunk ratectr;
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 Maier3c293b42020-11-26 22:16:23 +010066 bool ts_in_use[NUM_E1_TS-1];
67 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