blob: 3f14f97ac1358d0c4be7b58ac334dd5f3eeab3e7 [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
30 char *audio_fmtp_extra;
Philipp Maierc66ab2c2020-06-02 20:55:34 +020031 int audio_send_ptime;
32 int audio_send_name;
Philipp Maierc66ab2c2020-06-02 20:55:34 +020033
34 int no_audio_transcoding;
35
36 int omit_rtcp;
37 int keepalive_interval;
38
39 /* RTP patching */
40 int force_constant_ssrc; /* 0: don't, 1: once */
41 int force_aligned_timing;
42 bool rfc5993_hr_convert;
43
44 /* spec handling */
45 int force_realloc;
46
47 /* timer */
48 struct osmo_timer_list keepalive_timer;
49
50 /* When set, incoming RTP packets are not filtered
51 * when ports and ip-address do not match (debug) */
52 int rtp_accept_all;
53
54 unsigned int number_endpoints;
Philipp Maierc66ab2c2020-06-02 20:55:34 +020055 struct mgcp_endpoint **endpoints;
56
Philipp Maier124a3e02021-07-26 11:17:15 +020057 /* rate counters and stat items to measure the trunks overall performance and health */
Philipp Maierc66ab2c2020-06-02 20:55:34 +020058 struct mgcp_ratectr_trunk ratectr;
Philipp Maier124a3e02021-07-26 11:17:15 +020059 struct mgcp_stat_trunk stats;
Philipp Maier889fe7f2020-07-06 17:44:12 +020060
61 union {
62 /* Virtual trunk specific */
63 struct {
64 unsigned int vty_number_endpoints;
65 } v;
66 /* E1 specific */
67 struct {
68 unsigned int vty_line_nr;
Philipp Maier3c293b42020-11-26 22:16:23 +010069 bool ts_in_use[NUM_E1_TS-1];
70 struct osmo_i460_timeslot i460_ts[NUM_E1_TS-1];
71 /* Note: on an E1 line TS 0 is devoted to framing and
72 * alignment and therefore only NUM_E1_TS-1 timeslots
73 * are available for traffic. */
Philipp Maier889fe7f2020-07-06 17:44:12 +020074 } e1;
75 };
Philipp Maierc66ab2c2020-06-02 20:55:34 +020076};
77
Philipp Maierd70eef62021-07-19 13:53:28 +020078struct mgcp_trunk *mgcp_trunk_alloc(struct mgcp_config *cfg, enum mgcp_trunk_type ttype, unsigned int nr);
Philipp Maier889fe7f2020-07-06 17:44:12 +020079int mgcp_trunk_equip(struct mgcp_trunk *trunk);
Philipp Maierd70eef62021-07-19 13:53:28 +020080struct 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 +020081struct mgcp_trunk *mgcp_trunk_by_name(const struct mgcp_config *cfg, const char *epname);
Philipp Maierd70eef62021-07-19 13:53:28 +020082int e1_trunk_nr_from_epname(unsigned int *trunk_nr, const char *epname);
Philipp Maier889fe7f2020-07-06 17:44:12 +020083struct mgcp_trunk *mgcp_trunk_by_line_num(const struct mgcp_config *cfg, unsigned int num);
Philipp Maierd19de2e2020-06-03 13:55:33 +020084
85/* The virtual trunk is always created on trunk id 0 for historical reasons,
86 * use this define constant as ID when allocating a virtual trunk. Other
87 * trunks may be assigned with arbritrary id numbers */
88#define MGCP_VIRT_TRUNK_ID 0