Philipp Maier | c66ab2c | 2020-06-02 20:55:34 +0200 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Philipp Maier | 889fe7f | 2020-07-06 17:44:12 +0200 | [diff] [blame] | 3 | #include <osmocom/gsm/i460_mux.h> |
Philipp Maier | 3c293b4 | 2020-11-26 22:16:23 +0100 | [diff] [blame] | 4 | #include <osmocom/abis/e1_input.h> |
Eric | 1e8d5fa | 2021-08-24 01:36:49 +0200 | [diff] [blame] | 5 | #include <osmocom/mgcp/mgcp_ratectr.h> |
| 6 | |
Philipp Maier | 889fe7f | 2020-07-06 17:44:12 +0200 | [diff] [blame] | 7 | |
| 8 | #define LOGPTRUNK(trunk, cat, level, fmt, args...) \ |
| 9 | LOGP(cat, level, "trunk:%u " fmt, \ |
| 10 | trunk ? trunk->trunk_nr : 0, \ |
| 11 | ## args) |
| 12 | |
Philipp Maier | bea5678 | 2020-07-01 23:18:58 +0200 | [diff] [blame] | 13 | enum mgcp_trunk_type { |
| 14 | MGCP_TRUNK_VIRTUAL, |
| 15 | MGCP_TRUNK_E1, |
| 16 | }; |
| 17 | |
Philipp Maier | bd060c3 | 2021-07-09 10:24:33 +0200 | [diff] [blame] | 18 | extern const struct value_string mgcp_trunk_type_strs[]; |
| 19 | static 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 Maier | c66ab2c | 2020-06-02 20:55:34 +0200 | [diff] [blame] | 22 | struct mgcp_trunk { |
| 23 | struct llist_head entry; |
| 24 | |
| 25 | struct mgcp_config *cfg; |
| 26 | |
Philipp Maier | d70eef6 | 2021-07-19 13:53:28 +0200 | [diff] [blame] | 27 | unsigned int trunk_nr; |
Philipp Maier | 04bbb9d | 2020-07-02 21:21:26 +0200 | [diff] [blame] | 28 | enum mgcp_trunk_type trunk_type; |
Philipp Maier | c66ab2c | 2020-06-02 20:55:34 +0200 | [diff] [blame] | 29 | |
Philipp Maier | c66ab2c | 2020-06-02 20:55:34 +0200 | [diff] [blame] | 30 | int audio_send_ptime; |
| 31 | int audio_send_name; |
Philipp Maier | c66ab2c | 2020-06-02 20:55:34 +0200 | [diff] [blame] | 32 | |
Philipp Maier | c66ab2c | 2020-06-02 20:55:34 +0200 | [diff] [blame] | 33 | 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 Maier | c66ab2c | 2020-06-02 20:55:34 +0200 | [diff] [blame] | 52 | struct mgcp_endpoint **endpoints; |
| 53 | |
Philipp Maier | 124a3e0 | 2021-07-26 11:17:15 +0200 | [diff] [blame] | 54 | /* rate counters and stat items to measure the trunks overall performance and health */ |
Philipp Maier | c66ab2c | 2020-06-02 20:55:34 +0200 | [diff] [blame] | 55 | struct mgcp_ratectr_trunk ratectr; |
Philipp Maier | 124a3e0 | 2021-07-26 11:17:15 +0200 | [diff] [blame] | 56 | struct mgcp_stat_trunk stats; |
Philipp Maier | 889fe7f | 2020-07-06 17:44:12 +0200 | [diff] [blame] | 57 | |
| 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 Maier | 2a9ba66 | 2023-02-09 13:39:31 +0100 | [diff] [blame] | 66 | uint8_t ts_usecount[NUM_E1_TS-1]; |
Philipp Maier | 3c293b4 | 2020-11-26 22:16:23 +0100 | [diff] [blame] | 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 Maier | 889fe7f | 2020-07-06 17:44:12 +0200 | [diff] [blame] | 71 | } e1; |
| 72 | }; |
Philipp Maier | c66ab2c | 2020-06-02 20:55:34 +0200 | [diff] [blame] | 73 | }; |
| 74 | |
Philipp Maier | d70eef6 | 2021-07-19 13:53:28 +0200 | [diff] [blame] | 75 | struct mgcp_trunk *mgcp_trunk_alloc(struct mgcp_config *cfg, enum mgcp_trunk_type ttype, unsigned int nr); |
Philipp Maier | 889fe7f | 2020-07-06 17:44:12 +0200 | [diff] [blame] | 76 | int mgcp_trunk_equip(struct mgcp_trunk *trunk); |
Philipp Maier | d70eef6 | 2021-07-19 13:53:28 +0200 | [diff] [blame] | 77 | struct mgcp_trunk *mgcp_trunk_by_num(const struct mgcp_config *cfg, enum mgcp_trunk_type ttype, unsigned int nr); |
Philipp Maier | c66ab2c | 2020-06-02 20:55:34 +0200 | [diff] [blame] | 78 | struct mgcp_trunk *mgcp_trunk_by_name(const struct mgcp_config *cfg, const char *epname); |
Philipp Maier | d70eef6 | 2021-07-19 13:53:28 +0200 | [diff] [blame] | 79 | int e1_trunk_nr_from_epname(unsigned int *trunk_nr, const char *epname); |
Philipp Maier | 889fe7f | 2020-07-06 17:44:12 +0200 | [diff] [blame] | 80 | struct mgcp_trunk *mgcp_trunk_by_line_num(const struct mgcp_config *cfg, unsigned int num); |
Philipp Maier | d19de2e | 2020-06-03 13:55:33 +0200 | [diff] [blame] | 81 | |
| 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 |