Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1 | /* A Media Gateway Control Protocol Media Gateway: RFC 3435 */ |
| 2 | /* The protocol implementation */ |
| 3 | |
| 4 | /* |
| 5 | * (C) 2009-2014 by Holger Hans Peter Freyther <zecke@selfish.org> |
| 6 | * (C) 2009-2011 by On-Waves |
| 7 | * All Rights Reserved |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU Affero General Public License as published by |
| 11 | * the Free Software Foundation; either version 3 of the License, or |
| 12 | * (at your option) any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU Affero General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU Affero General Public License |
| 20 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 21 | * |
| 22 | */ |
| 23 | |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 24 | #include <osmocom/core/talloc.h> |
Pau Espin Pedrol | a790f0c | 2020-08-31 13:29:11 +0200 | [diff] [blame] | 25 | #include <osmocom/core/sockaddr_str.h> |
Stefan Sperling | 1e17487 | 2018-10-25 18:36:10 +0200 | [diff] [blame] | 26 | #include <osmocom/vty/misc.h> |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 27 | #include <osmocom/mgcp/mgcp.h> |
Neels Hofmeyr | 6779354 | 2017-09-08 04:25:16 +0200 | [diff] [blame] | 28 | #include <osmocom/mgcp/mgcp_common.h> |
Philipp Maier | 993ea6b | 2020-08-04 18:26:50 +0200 | [diff] [blame] | 29 | #include <osmocom/mgcp/osmux.h> |
| 30 | #include <osmocom/mgcp/mgcp_protocol.h> |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 31 | #include <osmocom/mgcp/vty.h> |
| 32 | #include <osmocom/mgcp/mgcp_conn.h> |
Philipp Maier | 37d11c8 | 2018-02-01 14:38:12 +0100 | [diff] [blame] | 33 | #include <osmocom/mgcp/mgcp_endp.h> |
Philipp Maier | c66ab2c | 2020-06-02 20:55:34 +0200 | [diff] [blame] | 34 | #include <osmocom/mgcp/mgcp_trunk.h> |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 35 | |
| 36 | #include <string.h> |
Philipp Maier | bca0ef6 | 2018-07-09 17:20:51 +0200 | [diff] [blame] | 37 | #include <inttypes.h> |
Stefan Sperling | 1208658 | 2018-06-26 15:26:28 +0200 | [diff] [blame] | 38 | #include <limits.h> |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 39 | |
| 40 | #define RTCP_OMIT_STR "Drop RTCP packets in both directions\n" |
| 41 | #define RTP_PATCH_STR "Modify RTP packet header in both directions\n" |
| 42 | #define RTP_KEEPALIVE_STR "Send dummy UDP packet to net RTP destination\n" |
Philipp Maier | 9fc8a02 | 2019-02-20 12:26:52 +0100 | [diff] [blame] | 43 | #define RTP_TS101318_RFC5993_CONV_STR "Convert GSM-HR from TS101318 to RFC5993 and vice versa\n" |
| 44 | |
Philipp Maier | 19c430f | 2020-09-22 15:52:50 +0200 | [diff] [blame] | 45 | #define X(x) (1 << x) |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 46 | |
| 47 | static struct mgcp_config *g_cfg = NULL; |
| 48 | |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 49 | struct cmd_node mgcp_node = { |
| 50 | MGCP_NODE, |
| 51 | "%s(config-mgcp)# ", |
| 52 | 1, |
| 53 | }; |
| 54 | |
| 55 | struct cmd_node trunk_node = { |
| 56 | TRUNK_NODE, |
| 57 | "%s(config-mgcp-trunk)# ", |
| 58 | 1, |
| 59 | }; |
| 60 | |
| 61 | static int config_write_mgcp(struct vty *vty) |
| 62 | { |
Philipp Maier | 6fbbeec | 2020-07-01 23:00:54 +0200 | [diff] [blame] | 63 | struct mgcp_trunk *trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_VIRTUAL, MGCP_VIRT_TRUNK_ID); |
Philipp Maier | d19de2e | 2020-06-03 13:55:33 +0200 | [diff] [blame] | 64 | OSMO_ASSERT(trunk); |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 65 | |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 66 | vty_out(vty, "mgcp%s", VTY_NEWLINE); |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 67 | vty_out(vty, " domain %s%s", g_cfg->domain, VTY_NEWLINE); |
Eric | 2764bdb | 2021-08-23 22:11:47 +0200 | [diff] [blame] | 68 | if (strlen(g_cfg->local_ip)) |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 69 | vty_out(vty, " local ip %s%s", g_cfg->local_ip, VTY_NEWLINE); |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 70 | vty_out(vty, " bind ip %s%s", g_cfg->source_addr, VTY_NEWLINE); |
| 71 | vty_out(vty, " bind port %u%s", g_cfg->source_port, VTY_NEWLINE); |
| 72 | vty_out(vty, " rtp port-range %u %u%s", |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 73 | g_cfg->net_ports.range_start, g_cfg->net_ports.range_end, |
| 74 | VTY_NEWLINE); |
Eric | 2764bdb | 2021-08-23 22:11:47 +0200 | [diff] [blame] | 75 | if (strlen(g_cfg->net_ports.bind_addr_v4)) |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 76 | vty_out(vty, " rtp bind-ip %s%s", |
Pau Espin Pedrol | 8a2a1b2 | 2020-09-02 20:46:24 +0200 | [diff] [blame] | 77 | g_cfg->net_ports.bind_addr_v4, VTY_NEWLINE); |
Eric | 2764bdb | 2021-08-23 22:11:47 +0200 | [diff] [blame] | 78 | if (strlen(g_cfg->net_ports.bind_addr_v6)) |
Pau Espin Pedrol | 8a2a1b2 | 2020-09-02 20:46:24 +0200 | [diff] [blame] | 79 | vty_out(vty, " rtp bind-ip-v6 %s%s", |
| 80 | g_cfg->net_ports.bind_addr_v6, VTY_NEWLINE); |
Philipp Maier | 1cb1e38 | 2017-11-02 17:16:04 +0100 | [diff] [blame] | 81 | if (g_cfg->net_ports.bind_addr_probe) |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 82 | vty_out(vty, " rtp ip-probing%s", VTY_NEWLINE); |
Philipp Maier | 1cb1e38 | 2017-11-02 17:16:04 +0100 | [diff] [blame] | 83 | else |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 84 | vty_out(vty, " no rtp ip-probing%s", VTY_NEWLINE); |
| 85 | vty_out(vty, " rtp ip-dscp %d%s", g_cfg->endp_dscp, VTY_NEWLINE); |
Harald Welte | 55a9229 | 2021-04-28 19:06:34 +0200 | [diff] [blame] | 86 | if (g_cfg->endp_priority) |
| 87 | vty_out(vty, " rtp socket-priority %d%s", g_cfg->endp_priority, VTY_NEWLINE); |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 88 | if (trunk->keepalive_interval == MGCP_KEEPALIVE_ONCE) |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 89 | vty_out(vty, " rtp keep-alive once%s", VTY_NEWLINE); |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 90 | else if (trunk->keepalive_interval) |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 91 | vty_out(vty, " rtp keep-alive %d%s", |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 92 | trunk->keepalive_interval, VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 93 | else |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 94 | vty_out(vty, " no rtp keep-alive%s", VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 95 | |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 96 | if (trunk->omit_rtcp) |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 97 | vty_out(vty, " rtcp-omit%s", VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 98 | else |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 99 | vty_out(vty, " no rtcp-omit%s", VTY_NEWLINE); |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 100 | if (trunk->force_constant_ssrc |
| 101 | || trunk->force_aligned_timing |
| 102 | || trunk->rfc5993_hr_convert) { |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 103 | vty_out(vty, " %srtp-patch ssrc%s", |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 104 | trunk->force_constant_ssrc ? "" : "no ", |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 105 | VTY_NEWLINE); |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 106 | vty_out(vty, " %srtp-patch timestamp%s", |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 107 | trunk->force_aligned_timing ? "" : "no ", |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 108 | VTY_NEWLINE); |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 109 | vty_out(vty, " %srtp-patch rfc5993hr%s", |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 110 | trunk->rfc5993_hr_convert ? "" : "no ", |
Philipp Maier | 9fc8a02 | 2019-02-20 12:26:52 +0100 | [diff] [blame] | 111 | VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 112 | } else |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 113 | vty_out(vty, " no rtp-patch%s", VTY_NEWLINE); |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 114 | if (trunk->audio_fmtp_extra) |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 115 | vty_out(vty, " sdp audio fmtp-extra %s%s", |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 116 | trunk->audio_fmtp_extra, VTY_NEWLINE); |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 117 | vty_out(vty, " %ssdp audio-payload send-ptime%s", |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 118 | trunk->audio_send_ptime ? "" : "no ", VTY_NEWLINE); |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 119 | vty_out(vty, " %ssdp audio-payload send-name%s", |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 120 | trunk->audio_send_name ? "" : "no ", VTY_NEWLINE); |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 121 | vty_out(vty, " number endpoints %u%s", |
Philipp Maier | 889fe7f | 2020-07-06 17:44:12 +0200 | [diff] [blame] | 122 | trunk->v.vty_number_endpoints, VTY_NEWLINE); |
Eric | 2764bdb | 2021-08-23 22:11:47 +0200 | [diff] [blame] | 123 | if (strlen(g_cfg->call_agent_addr)) |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 124 | vty_out(vty, " call-agent ip %s%s", g_cfg->call_agent_addr, |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 125 | VTY_NEWLINE); |
| 126 | if (g_cfg->force_ptime > 0) |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 127 | vty_out(vty, " rtp force-ptime %d%s", g_cfg->force_ptime, |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 128 | VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 129 | |
Pau Espin Pedrol | 36413c0 | 2022-10-12 17:58:17 +0200 | [diff] [blame] | 130 | switch (g_cfg->osmux.usage) { |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 131 | case OSMUX_USAGE_ON: |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 132 | vty_out(vty, " osmux on%s", VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 133 | break; |
| 134 | case OSMUX_USAGE_ONLY: |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 135 | vty_out(vty, " osmux only%s", VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 136 | break; |
| 137 | case OSMUX_USAGE_OFF: |
| 138 | default: |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 139 | vty_out(vty, " osmux off%s", VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 140 | break; |
| 141 | } |
Pau Espin Pedrol | 36413c0 | 2022-10-12 17:58:17 +0200 | [diff] [blame] | 142 | if (g_cfg->osmux.usage != OSMUX_USAGE_OFF) { |
| 143 | if (g_cfg->osmux.local_addr_v4) |
Pau Espin Pedrol | 70c03f5 | 2022-10-04 16:49:41 +0200 | [diff] [blame] | 144 | vty_out(vty, " osmux bind-ip %s%s", |
Pau Espin Pedrol | 36413c0 | 2022-10-12 17:58:17 +0200 | [diff] [blame] | 145 | g_cfg->osmux.local_addr_v4, VTY_NEWLINE); |
| 146 | if (g_cfg->osmux.local_addr_v6) |
Pau Espin Pedrol | 70c03f5 | 2022-10-04 16:49:41 +0200 | [diff] [blame] | 147 | vty_out(vty, " osmux bind-ip-v6 %s%s", |
Pau Espin Pedrol | 36413c0 | 2022-10-12 17:58:17 +0200 | [diff] [blame] | 148 | g_cfg->osmux.local_addr_v6, VTY_NEWLINE); |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 149 | vty_out(vty, " osmux batch-factor %d%s", |
Pau Espin Pedrol | 36413c0 | 2022-10-12 17:58:17 +0200 | [diff] [blame] | 150 | g_cfg->osmux.batch_factor, VTY_NEWLINE); |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 151 | vty_out(vty, " osmux batch-size %u%s", |
Pau Espin Pedrol | 36413c0 | 2022-10-12 17:58:17 +0200 | [diff] [blame] | 152 | g_cfg->osmux.batch_size, VTY_NEWLINE); |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 153 | vty_out(vty, " osmux port %u%s", |
Pau Espin Pedrol | 36413c0 | 2022-10-12 17:58:17 +0200 | [diff] [blame] | 154 | g_cfg->osmux.local_port, VTY_NEWLINE); |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 155 | vty_out(vty, " osmux dummy %s%s", |
Pau Espin Pedrol | 36413c0 | 2022-10-12 17:58:17 +0200 | [diff] [blame] | 156 | g_cfg->osmux.dummy_padding ? "on" : "off", VTY_NEWLINE); |
Pau Espin Pedrol | 833281d | 2022-10-06 17:41:22 +0200 | [diff] [blame] | 157 | vty_out(vty, " osmux peer-behind-nat %s%s", |
Pau Espin Pedrol | 36413c0 | 2022-10-12 17:58:17 +0200 | [diff] [blame] | 158 | g_cfg->osmux.peer_behind_nat ? "on" : "off", VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 159 | } |
Oliver Smith | e36b775 | 2019-01-22 16:31:36 +0100 | [diff] [blame] | 160 | |
| 161 | if (g_cfg->conn_timeout) |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 162 | vty_out(vty, " conn-timeout %u%s", g_cfg->conn_timeout, VTY_NEWLINE); |
Oliver Smith | e36b775 | 2019-01-22 16:31:36 +0100 | [diff] [blame] | 163 | |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 164 | return CMD_SUCCESS; |
| 165 | } |
| 166 | |
Philipp Maier | cede2a4 | 2018-07-03 14:14:21 +0200 | [diff] [blame] | 167 | static void dump_rtp_end(struct vty *vty, struct mgcp_conn_rtp *conn) |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 168 | { |
Philipp Maier | cede2a4 | 2018-07-03 14:14:21 +0200 | [diff] [blame] | 169 | struct mgcp_rtp_state *state = &conn->state; |
| 170 | struct mgcp_rtp_end *end = &conn->end; |
Philipp Maier | bc0346e | 2018-06-07 09:52:16 +0200 | [diff] [blame] | 171 | struct mgcp_rtp_codec *codec = end->codec; |
Stefan Sperling | b7974e2 | 2018-10-29 13:22:00 +0100 | [diff] [blame] | 172 | struct rate_ctr *tx_packets, *tx_bytes; |
| 173 | struct rate_ctr *rx_packets, *rx_bytes; |
Philipp Maier | cede2a4 | 2018-07-03 14:14:21 +0200 | [diff] [blame] | 174 | struct rate_ctr *dropped_packets; |
| 175 | |
Pau Espin Pedrol | daf5bce | 2022-09-22 19:14:24 +0200 | [diff] [blame] | 176 | tx_packets = rate_ctr_group_get_ctr(conn->ctrg, RTP_PACKETS_TX_CTR); |
| 177 | tx_bytes = rate_ctr_group_get_ctr(conn->ctrg, RTP_OCTETS_TX_CTR); |
| 178 | rx_packets = rate_ctr_group_get_ctr(conn->ctrg, RTP_PACKETS_RX_CTR); |
| 179 | rx_bytes = rate_ctr_group_get_ctr(conn->ctrg, RTP_OCTETS_RX_CTR); |
| 180 | dropped_packets = rate_ctr_group_get_ctr(conn->ctrg, RTP_DROPPED_PACKETS_CTR); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 181 | |
| 182 | vty_out(vty, |
Stefan Sperling | b7974e2 | 2018-10-29 13:22:00 +0100 | [diff] [blame] | 183 | " Packets Sent: %" PRIu64 " (%" PRIu64 " bytes total)%s" |
| 184 | " Packets Received: %" PRIu64 " (%" PRIu64 " bytes total)%s" |
Philipp Maier | bca0ef6 | 2018-07-09 17:20:51 +0200 | [diff] [blame] | 185 | " Timestamp Errs: %" PRIu64 "->%" PRIu64 "%s" |
| 186 | " Dropped Packets: %" PRIu64 "%s" |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 187 | " Payload Type: %d Rate: %u Channels: %d %s" |
| 188 | " Frame Duration: %u Frame Denominator: %u%s" |
| 189 | " FPP: %d Packet Duration: %u%s" |
| 190 | " FMTP-Extra: %s Audio-Name: %s Sub-Type: %s%s" |
| 191 | " Output-Enabled: %d Force-PTIME: %d%s", |
Stefan Sperling | b7974e2 | 2018-10-29 13:22:00 +0100 | [diff] [blame] | 192 | tx_packets->current, tx_bytes->current, VTY_NEWLINE, |
| 193 | rx_packets->current, rx_bytes->current, VTY_NEWLINE, |
Philipp Maier | 9e1d164 | 2018-05-09 16:26:34 +0200 | [diff] [blame] | 194 | state->in_stream.err_ts_ctr->current, |
| 195 | state->out_stream.err_ts_ctr->current, |
Pau Espin Pedrol | 83df47c | 2022-09-21 20:07:59 +0200 | [diff] [blame] | 196 | VTY_NEWLINE, |
Philipp Maier | cede2a4 | 2018-07-03 14:14:21 +0200 | [diff] [blame] | 197 | dropped_packets->current, VTY_NEWLINE, |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 198 | codec->payload_type, codec->rate, codec->channels, VTY_NEWLINE, |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 199 | codec->frame_duration_num, codec->frame_duration_den, |
| 200 | VTY_NEWLINE, end->frames_per_packet, end->packet_duration_ms, |
| 201 | VTY_NEWLINE, end->fmtp_extra, codec->audio_name, |
| 202 | codec->subtype_name, VTY_NEWLINE, end->output_enabled, |
| 203 | end->force_output_ptime, VTY_NEWLINE); |
Pau Espin Pedrol | ea7aaf2 | 2022-09-22 21:07:54 +0200 | [diff] [blame] | 204 | if (mgcp_conn_rtp_is_osmux(conn)) { |
| 205 | struct rate_ctr *rx_chunks, *rx_octets, *rtp_tx, *rtp_tx_dropped, *octets_tx; |
| 206 | rx_chunks = rate_ctr_group_get_ctr(conn->osmux.ctrg, OSMUX_CHUNKS_RX_CTR); |
| 207 | rx_octets = rate_ctr_group_get_ctr(conn->osmux.ctrg, OSMUX_OCTETS_RX_CTR); |
| 208 | rtp_tx = rate_ctr_group_get_ctr(conn->osmux.ctrg, OSMUX_RTP_PACKETS_TX_CTR); |
| 209 | rtp_tx_dropped = rate_ctr_group_get_ctr(conn->osmux.ctrg, OSMUX_RTP_PACKETS_TX_DROPPED_CTR); |
| 210 | octets_tx = rate_ctr_group_get_ctr(conn->osmux.ctrg, OSMUX_AMR_OCTETS_TX_CTR); |
| 211 | vty_out(vty, |
| 212 | " Osmux:%s" |
| 213 | " State: %s%s" |
| 214 | " Local CID: %d%s" |
| 215 | " Remote CID: %d%s" |
| 216 | " Chunks received: %" PRIu64 " (%" PRIu64 " bytes total)%s" |
| 217 | " RTP Packets encoded (Tx): %" PRIu64 " (%" PRIu64 " AMR octets total)%s" |
| 218 | " AMR payloads Dropped (Tx): %" PRIu64 "%s", |
| 219 | VTY_NEWLINE, osmux_state_str(conn->osmux.state), VTY_NEWLINE, |
| 220 | conn->osmux.local_cid_allocated ? conn->osmux.local_cid : -1, VTY_NEWLINE, |
| 221 | conn->osmux.remote_cid_present ? conn->osmux.remote_cid : -1, VTY_NEWLINE, |
| 222 | rx_chunks->current, rx_octets->current, VTY_NEWLINE, |
| 223 | rtp_tx->current, octets_tx->current, VTY_NEWLINE, |
| 224 | rtp_tx_dropped->current, VTY_NEWLINE |
| 225 | ); |
| 226 | |
| 227 | } |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 228 | } |
| 229 | |
Philipp Maier | c66ab2c | 2020-06-02 20:55:34 +0200 | [diff] [blame] | 230 | static void dump_endpoint(struct vty *vty, struct mgcp_endpoint *endp, |
Philipp Maier | d70eef6 | 2021-07-19 13:53:28 +0200 | [diff] [blame] | 231 | unsigned int trunk_nr, enum mgcp_trunk_type trunk_type, int show_stats) |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 232 | { |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 233 | struct mgcp_conn *conn; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 234 | |
Philipp Maier | d70eef6 | 2021-07-19 13:53:28 +0200 | [diff] [blame] | 235 | vty_out(vty, "%s trunk %u endpoint %s:%s", |
Philipp Maier | c66ab2c | 2020-06-02 20:55:34 +0200 | [diff] [blame] | 236 | trunk_type == MGCP_TRUNK_VIRTUAL ? "Virtual" : "E1", trunk_nr, endp->name, VTY_NEWLINE); |
Philipp Maier | 8d6a193 | 2020-06-18 12:19:31 +0200 | [diff] [blame] | 237 | vty_out(vty, " Availability: %s%s", |
| 238 | mgcp_endp_avail(endp) ? "available" : "not in service", VTY_NEWLINE); |
Stefan Sperling | 1208658 | 2018-06-26 15:26:28 +0200 | [diff] [blame] | 239 | |
| 240 | if (llist_empty(&endp->conns)) { |
| 241 | vty_out(vty, " No active connections%s", VTY_NEWLINE); |
| 242 | return; |
| 243 | } |
| 244 | |
| 245 | llist_for_each_entry(conn, &endp->conns, entry) { |
| 246 | vty_out(vty, " CONN: %s%s", mgcp_conn_dump(conn), VTY_NEWLINE); |
| 247 | |
| 248 | if (show_stats) { |
Eric | fbf78d1 | 2021-08-23 22:31:39 +0200 | [diff] [blame] | 249 | if (endp->trunk->cfg->conn_timeout) { |
Oliver Smith | e36b775 | 2019-01-22 16:31:36 +0100 | [diff] [blame] | 250 | struct timeval remaining; |
| 251 | osmo_timer_remaining(&conn->watchdog, NULL, &remaining); |
| 252 | vty_out(vty, " Currently remaining timeout (seconds): %d.%06d%s", |
| 253 | (int)remaining.tv_sec, (int)remaining.tv_usec, VTY_NEWLINE); |
| 254 | } |
| 255 | |
Stefan Sperling | 1208658 | 2018-06-26 15:26:28 +0200 | [diff] [blame] | 256 | /* FIXME: Also add verbosity for other |
| 257 | * connection types (E1) as soon as |
| 258 | * the implementation is available */ |
| 259 | if (conn->type == MGCP_CONN_TYPE_RTP) { |
| 260 | dump_rtp_end(vty, &conn->u.rtp); |
| 261 | } |
| 262 | } |
| 263 | } |
| 264 | } |
| 265 | |
Philipp Maier | c66ab2c | 2020-06-02 20:55:34 +0200 | [diff] [blame] | 266 | static void dump_ratectr_global(struct vty *vty, struct mgcp_ratectr_global *ratectr) |
| 267 | { |
| 268 | vty_out(vty, "%s", VTY_NEWLINE); |
| 269 | vty_out(vty, "Rate counters (global):%s", VTY_NEWLINE); |
| 270 | |
| 271 | if (ratectr->mgcp_general_ctr_group) { |
| 272 | vty_out(vty, " %s:%s", |
| 273 | ratectr->mgcp_general_ctr_group->desc-> |
| 274 | group_description, VTY_NEWLINE); |
| 275 | vty_out_rate_ctr_group_fmt(vty, |
| 276 | " %25n: %10c (%S/s %M/m %H/h %D/d) %d", |
| 277 | ratectr->mgcp_general_ctr_group); |
| 278 | } |
| 279 | } |
| 280 | |
Philipp Maier | 889fe7f | 2020-07-06 17:44:12 +0200 | [diff] [blame] | 281 | static void dump_ratectr_trunk(struct vty *vty, struct mgcp_trunk *trunk) |
Philipp Maier | c66ab2c | 2020-06-02 20:55:34 +0200 | [diff] [blame] | 282 | { |
Philipp Maier | 889fe7f | 2020-07-06 17:44:12 +0200 | [diff] [blame] | 283 | struct mgcp_ratectr_trunk *ratectr = &trunk->ratectr; |
| 284 | |
Philipp Maier | c66ab2c | 2020-06-02 20:55:34 +0200 | [diff] [blame] | 285 | vty_out(vty, "%s", VTY_NEWLINE); |
| 286 | vty_out(vty, "Rate counters (trunk):%s", VTY_NEWLINE); |
| 287 | |
| 288 | if (ratectr->mgcp_crcx_ctr_group) { |
| 289 | vty_out(vty, " %s:%s", |
| 290 | ratectr->mgcp_crcx_ctr_group->desc->group_description, |
| 291 | VTY_NEWLINE); |
| 292 | vty_out_rate_ctr_group_fmt(vty, |
| 293 | " %25n: %10c (%S/s %M/m %H/h %D/d) %d", |
| 294 | ratectr->mgcp_crcx_ctr_group); |
| 295 | } |
| 296 | if (ratectr->mgcp_dlcx_ctr_group) { |
| 297 | vty_out(vty, " %s:%s", |
| 298 | ratectr->mgcp_dlcx_ctr_group->desc->group_description, |
| 299 | VTY_NEWLINE); |
| 300 | vty_out_rate_ctr_group_fmt(vty, |
| 301 | " %25n: %10c (%S/s %M/m %H/h %D/d) %d", |
| 302 | ratectr->mgcp_dlcx_ctr_group); |
| 303 | } |
| 304 | if (ratectr->mgcp_mdcx_ctr_group) { |
| 305 | vty_out(vty, " %s:%s", |
| 306 | ratectr->mgcp_mdcx_ctr_group->desc->group_description, |
| 307 | VTY_NEWLINE); |
| 308 | vty_out_rate_ctr_group_fmt(vty, |
| 309 | " %25n: %10c (%S/s %M/m %H/h %D/d) %d", |
| 310 | ratectr->mgcp_mdcx_ctr_group); |
| 311 | } |
| 312 | if (ratectr->all_rtp_conn_stats) { |
| 313 | vty_out(vty, " %s:%s", |
| 314 | ratectr->all_rtp_conn_stats->desc->group_description, |
| 315 | VTY_NEWLINE); |
| 316 | vty_out_rate_ctr_group_fmt(vty, |
| 317 | " %25n: %10c (%S/s %M/m %H/h %D/d) %d", |
| 318 | ratectr->all_rtp_conn_stats); |
| 319 | } |
Pau Espin Pedrol | 582c2bf | 2022-09-22 17:53:44 +0200 | [diff] [blame] | 320 | if (ratectr->all_osmux_conn_stats) { |
| 321 | vty_out(vty, " %s:%s", |
| 322 | ratectr->all_osmux_conn_stats->desc->group_description, |
| 323 | VTY_NEWLINE); |
| 324 | vty_out_rate_ctr_group_fmt(vty, |
| 325 | " %25n: %10c (%S/s %M/m %H/h %D/d) %d", |
| 326 | ratectr->all_osmux_conn_stats); |
| 327 | } |
Philipp Maier | 889fe7f | 2020-07-06 17:44:12 +0200 | [diff] [blame] | 328 | |
| 329 | if (ratectr->e1_stats && trunk->trunk_type == MGCP_TRUNK_E1) { |
| 330 | vty_out(vty, " %s:%s", |
| 331 | ratectr->e1_stats->desc->group_description, |
| 332 | VTY_NEWLINE); |
| 333 | vty_out_rate_ctr_group_fmt(vty, |
| 334 | " %25n: %10c (%S/s %M/m %H/h %D/d) %d", |
| 335 | ratectr->e1_stats); |
| 336 | } |
Philipp Maier | c66ab2c | 2020-06-02 20:55:34 +0200 | [diff] [blame] | 337 | } |
| 338 | |
| 339 | |
Keith | fe53edd | 2021-05-04 15:23:30 -0500 | [diff] [blame] | 340 | static void dump_trunk(struct vty *vty, struct mgcp_trunk *trunk, int show_stats, int active_only) |
Stefan Sperling | 1208658 | 2018-06-26 15:26:28 +0200 | [diff] [blame] | 341 | { |
| 342 | int i; |
Keith | fe53edd | 2021-05-04 15:23:30 -0500 | [diff] [blame] | 343 | int active_count = 0; |
Stefan Sperling | 1208658 | 2018-06-26 15:26:28 +0200 | [diff] [blame] | 344 | |
| 345 | vty_out(vty, "%s trunk %d with %d endpoints:%s", |
Philipp Maier | c66ab2c | 2020-06-02 20:55:34 +0200 | [diff] [blame] | 346 | trunk->trunk_type == MGCP_TRUNK_VIRTUAL ? "Virtual" : "E1", |
Philipp Maier | 869b21c | 2020-07-03 16:04:16 +0200 | [diff] [blame] | 347 | trunk->trunk_nr, trunk->number_endpoints, VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 348 | |
Philipp Maier | c66ab2c | 2020-06-02 20:55:34 +0200 | [diff] [blame] | 349 | if (!trunk->endpoints) { |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 350 | vty_out(vty, "No endpoints allocated yet.%s", VTY_NEWLINE); |
| 351 | return; |
| 352 | } |
| 353 | |
Philipp Maier | c66ab2c | 2020-06-02 20:55:34 +0200 | [diff] [blame] | 354 | for (i = 0; i < trunk->number_endpoints; ++i) { |
| 355 | struct mgcp_endpoint *endp = trunk->endpoints[i]; |
Keith | fe53edd | 2021-05-04 15:23:30 -0500 | [diff] [blame] | 356 | if (!active_only || !llist_empty(&endp->conns)) { |
| 357 | dump_endpoint(vty, endp, trunk->trunk_nr, trunk->trunk_type, |
| 358 | show_stats); |
| 359 | if (i < trunk->number_endpoints - 1) |
| 360 | vty_out(vty, "%s", VTY_NEWLINE); |
| 361 | } |
| 362 | if (!llist_empty(&endp->conns)) |
| 363 | active_count++; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 364 | } |
Stefan Sperling | 1e17487 | 2018-10-25 18:36:10 +0200 | [diff] [blame] | 365 | |
Keith | fe53edd | 2021-05-04 15:23:30 -0500 | [diff] [blame] | 366 | if (active_count == 0) |
| 367 | vty_out(vty, "No endpoints in use.%s", VTY_NEWLINE); |
| 368 | |
Philipp Maier | c66ab2c | 2020-06-02 20:55:34 +0200 | [diff] [blame] | 369 | if (show_stats) |
Philipp Maier | 889fe7f | 2020-07-06 17:44:12 +0200 | [diff] [blame] | 370 | dump_ratectr_trunk(vty, trunk); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 371 | } |
| 372 | |
Keith | fe53edd | 2021-05-04 15:23:30 -0500 | [diff] [blame] | 373 | static int mgcp_show(struct vty *vty, int argc, const char **argv, |
| 374 | int show_stats, int active_only) |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 375 | { |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 376 | struct mgcp_trunk *trunk; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 377 | |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 378 | llist_for_each_entry(trunk, &g_cfg->trunks, entry) |
Keith | fe53edd | 2021-05-04 15:23:30 -0500 | [diff] [blame] | 379 | dump_trunk(vty, trunk, show_stats, active_only); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 380 | |
Pau Espin Pedrol | 36413c0 | 2022-10-12 17:58:17 +0200 | [diff] [blame] | 381 | if (g_cfg->osmux.usage != OSMUX_USAGE_OFF) |
Pau Espin Pedrol | 8de58e7 | 2019-04-24 13:33:46 +0200 | [diff] [blame] | 382 | vty_out(vty, "Osmux used CID: %d%s", osmux_cid_pool_count_used(), |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 383 | VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 384 | |
Philipp Maier | c66ab2c | 2020-06-02 20:55:34 +0200 | [diff] [blame] | 385 | if (show_stats) |
| 386 | dump_ratectr_global(vty, &g_cfg->ratectr); |
| 387 | |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 388 | return CMD_SUCCESS; |
| 389 | } |
| 390 | |
Keith | fe53edd | 2021-05-04 15:23:30 -0500 | [diff] [blame] | 391 | #define SHOW_MGCP_STR "Display information about the MGCP Media Gateway\n" |
| 392 | |
| 393 | DEFUN(show_mgcp, show_mgcp_cmd, |
| 394 | "show mgcp [stats]", |
| 395 | SHOW_STR |
| 396 | SHOW_MGCP_STR |
| 397 | "Include statistics\n") |
| 398 | { |
| 399 | int show_stats = argc >= 1; |
| 400 | return mgcp_show(vty, argc, argv, show_stats, 0); |
| 401 | } |
| 402 | |
| 403 | DEFUN(show_mgcp_active, show_mgcp_active_cmd, |
| 404 | "show mgcp active", |
| 405 | SHOW_STR |
| 406 | SHOW_MGCP_STR |
| 407 | "Show only endpoints with active connections\n") |
| 408 | { |
| 409 | return mgcp_show(vty, argc, argv, 0, 1); |
| 410 | } |
| 411 | |
Stefan Sperling | 1208658 | 2018-06-26 15:26:28 +0200 | [diff] [blame] | 412 | static void |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 413 | dump_mgcp_endpoint(struct vty *vty, struct mgcp_trunk *trunk, const char *epname) |
Stefan Sperling | 1208658 | 2018-06-26 15:26:28 +0200 | [diff] [blame] | 414 | { |
Philipp Maier | c66ab2c | 2020-06-02 20:55:34 +0200 | [diff] [blame] | 415 | struct mgcp_endpoint *endp; |
Stefan Sperling | 1208658 | 2018-06-26 15:26:28 +0200 | [diff] [blame] | 416 | |
Philipp Maier | c66ab2c | 2020-06-02 20:55:34 +0200 | [diff] [blame] | 417 | if (trunk) { |
| 418 | /* If a trunk is given, search on that specific trunk only */ |
| 419 | endp = mgcp_endp_by_name_trunk(NULL, epname, trunk); |
| 420 | if (!endp) { |
Philipp Maier | d70eef6 | 2021-07-19 13:53:28 +0200 | [diff] [blame] | 421 | vty_out(vty, "endpoint %s not configured on trunk %u%s", epname, trunk->trunk_nr, VTY_NEWLINE); |
Philipp Maier | c66ab2c | 2020-06-02 20:55:34 +0200 | [diff] [blame] | 422 | return; |
| 423 | } |
| 424 | } else { |
| 425 | /* If no trunk is given, search on all possible trunks */ |
| 426 | endp = mgcp_endp_by_name(NULL, epname, g_cfg); |
| 427 | if (!endp) { |
| 428 | vty_out(vty, "endpoint %s not configured%s", epname, VTY_NEWLINE); |
| 429 | return; |
Stefan Sperling | 1208658 | 2018-06-26 15:26:28 +0200 | [diff] [blame] | 430 | } |
| 431 | } |
Philipp Maier | c66ab2c | 2020-06-02 20:55:34 +0200 | [diff] [blame] | 432 | |
| 433 | trunk = endp->trunk; |
| 434 | dump_endpoint(vty, endp, trunk->trunk_nr, trunk->trunk_type, true); |
Stefan Sperling | 1208658 | 2018-06-26 15:26:28 +0200 | [diff] [blame] | 435 | } |
| 436 | |
| 437 | DEFUN(show_mcgp_endpoint, show_mgcp_endpoint_cmd, |
| 438 | "show mgcp endpoint NAME", |
| 439 | SHOW_STR |
| 440 | SHOW_MGCP_STR |
| 441 | "Display information about an endpoint\n" "The name of the endpoint\n") |
| 442 | { |
Philipp Maier | c66ab2c | 2020-06-02 20:55:34 +0200 | [diff] [blame] | 443 | dump_mgcp_endpoint(vty, NULL, argv[0]); |
Stefan Sperling | 1208658 | 2018-06-26 15:26:28 +0200 | [diff] [blame] | 444 | return CMD_SUCCESS; |
| 445 | } |
| 446 | |
| 447 | DEFUN(show_mcgp_trunk_endpoint, show_mgcp_trunk_endpoint_cmd, |
| 448 | "show mgcp trunk <0-64> endpoint NAME", |
| 449 | SHOW_STR |
| 450 | SHOW_MGCP_STR |
| 451 | "Display information about a trunk\n" "Trunk number\n" |
| 452 | "Display information about an endpoint\n" "The name of the endpoint\n") |
| 453 | { |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 454 | struct mgcp_trunk *trunk; |
Stefan Sperling | 1208658 | 2018-06-26 15:26:28 +0200 | [diff] [blame] | 455 | int trunkidx = atoi(argv[0]); |
| 456 | |
Philipp Maier | 6fbbeec | 2020-07-01 23:00:54 +0200 | [diff] [blame] | 457 | trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_E1, trunkidx); |
Stefan Sperling | 1208658 | 2018-06-26 15:26:28 +0200 | [diff] [blame] | 458 | if (!trunk) { |
| 459 | vty_out(vty, "trunk %d not found%s", trunkidx, VTY_NEWLINE); |
| 460 | return CMD_WARNING; |
| 461 | } |
| 462 | |
| 463 | dump_mgcp_endpoint(vty, trunk, argv[1]); |
| 464 | return CMD_SUCCESS; |
| 465 | } |
| 466 | |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 467 | DEFUN(cfg_mgcp, cfg_mgcp_cmd, "mgcp", "Configure the MGCP") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 468 | { |
| 469 | vty->node = MGCP_NODE; |
| 470 | return CMD_SUCCESS; |
| 471 | } |
| 472 | |
Philipp Maier | 19c430f | 2020-09-22 15:52:50 +0200 | [diff] [blame] | 473 | DEFUN_USRATTR(cfg_mgcp_local_ip, |
| 474 | cfg_mgcp_local_ip_cmd, |
| 475 | X(MGW_CMD_ATTR_NEWCONN), |
| 476 | "local ip " VTY_IPV46_CMD, |
| 477 | "Local options for the SDP record\n" |
| 478 | IP_STR |
| 479 | "IPv4 Address to use in SDP record\n" |
| 480 | "IPv6 Address to use in SDP record\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 481 | { |
Eric | 2764bdb | 2021-08-23 22:11:47 +0200 | [diff] [blame] | 482 | osmo_strlcpy(g_cfg->local_ip, argv[0], sizeof(g_cfg->local_ip)); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 483 | return CMD_SUCCESS; |
| 484 | } |
| 485 | |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 486 | #define BIND_STR "Listen/Bind related socket option\n" |
| 487 | DEFUN(cfg_mgcp_bind_ip, |
| 488 | cfg_mgcp_bind_ip_cmd, |
Pau Espin Pedrol | a790f0c | 2020-08-31 13:29:11 +0200 | [diff] [blame] | 489 | "bind ip " VTY_IPV46_CMD, |
| 490 | BIND_STR IP_STR |
| 491 | "IPv4 Address to bind to\n" |
| 492 | "IPv6 Address to bind to\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 493 | { |
Eric | 2764bdb | 2021-08-23 22:11:47 +0200 | [diff] [blame] | 494 | osmo_strlcpy(g_cfg->source_addr, argv[0], sizeof(g_cfg->source_addr)); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 495 | return CMD_SUCCESS; |
| 496 | } |
| 497 | |
| 498 | DEFUN(cfg_mgcp_bind_port, |
| 499 | cfg_mgcp_bind_port_cmd, |
| 500 | "bind port <0-65534>", |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 501 | BIND_STR "Port information\n" "UDP port to listen for MGCP messages\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 502 | { |
| 503 | unsigned int port = atoi(argv[0]); |
| 504 | g_cfg->source_port = port; |
| 505 | return CMD_SUCCESS; |
| 506 | } |
| 507 | |
Philipp Maier | 8cfe7df | 2020-09-22 16:18:26 +0200 | [diff] [blame] | 508 | DEFUN_DEPRECATED(cfg_mgcp_bind_early, |
| 509 | cfg_mgcp_bind_early_cmd, |
| 510 | "bind early (0|1)", |
| 511 | BIND_STR |
| 512 | "Bind local ports on start up\n" "Bind on demand\n" "Bind on startup\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 513 | { |
Philipp Maier | 72761b3 | 2023-04-06 16:04:12 +0200 | [diff] [blame] | 514 | vty_out(vty, "%% Deprecated 'bind early (0|1)' config no longer has any effect%s", VTY_NEWLINE); |
Philipp Maier | 8cfe7df | 2020-09-22 16:18:26 +0200 | [diff] [blame] | 515 | return CMD_SUCCESS; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 516 | } |
| 517 | |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 518 | #define RTP_STR "RTP configuration\n" |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 519 | #define UDP_PORT_STR "UDP Port number\n" |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 520 | #define NET_START_STR "First UDP port allocated\n" |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 521 | #define RANGE_START_STR "Start of the range of ports\n" |
| 522 | #define RANGE_END_STR "End of the range of ports\n" |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 523 | |
Philipp Maier | f1889d8 | 2017-11-08 14:59:39 +0100 | [diff] [blame] | 524 | DEFUN(cfg_mgcp_rtp_port_range, |
| 525 | cfg_mgcp_rtp_port_range_cmd, |
Philipp Maier | a19547b | 2018-05-22 13:44:34 +0200 | [diff] [blame] | 526 | "rtp port-range <1024-65534> <1025-65535>", |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 527 | RTP_STR "Range of ports to use for the NET side\n" |
| 528 | RANGE_START_STR RANGE_END_STR) |
| 529 | { |
Philipp Maier | a19547b | 2018-05-22 13:44:34 +0200 | [diff] [blame] | 530 | int start; |
| 531 | int end; |
| 532 | |
| 533 | start = atoi(argv[0]); |
| 534 | end = atoi(argv[1]); |
| 535 | |
| 536 | if (end < start) { |
| 537 | vty_out(vty, "range end port (%i) must be greater than the range start port (%i)!%s", |
| 538 | end, start, VTY_NEWLINE); |
| 539 | return CMD_WARNING; |
| 540 | } |
| 541 | |
| 542 | if (start & 1) { |
| 543 | vty_out(vty, "range must begin at an even port number, autocorrecting port (%i) to: %i%s", |
| 544 | start, start & 0xFFFE, VTY_NEWLINE); |
| 545 | start &= 0xFFFE; |
| 546 | } |
| 547 | |
| 548 | if ((end & 1) == 0) { |
| 549 | vty_out(vty, "range must end at an odd port number, autocorrecting port (%i) to: %i%s", |
| 550 | end, end | 1, VTY_NEWLINE); |
| 551 | end |= 1; |
| 552 | } |
| 553 | |
| 554 | g_cfg->net_ports.range_start = start; |
| 555 | g_cfg->net_ports.range_end = end; |
| 556 | g_cfg->net_ports.last_port = g_cfg->net_ports.range_start; |
| 557 | |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 558 | return CMD_SUCCESS; |
| 559 | } |
Philipp Maier | f1889d8 | 2017-11-08 14:59:39 +0100 | [diff] [blame] | 560 | ALIAS_DEPRECATED(cfg_mgcp_rtp_port_range, |
| 561 | cfg_mgcp_rtp_net_range_cmd, |
| 562 | "rtp net-range <0-65534> <0-65534>", |
| 563 | RTP_STR "Range of ports to use for the NET side\n" |
| 564 | RANGE_START_STR RANGE_END_STR) |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 565 | |
Philipp Maier | 19c430f | 2020-09-22 15:52:50 +0200 | [diff] [blame] | 566 | DEFUN_USRATTR(cfg_mgcp_rtp_bind_ip, |
| 567 | cfg_mgcp_rtp_bind_ip_cmd, |
| 568 | X(MGW_CMD_ATTR_NEWCONN), |
| 569 | "rtp bind-ip A.B.C.D", |
| 570 | RTP_STR "Bind endpoints facing the Network\n" |
| 571 | "IPv4 Address to bind to\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 572 | { |
Eric | 2764bdb | 2021-08-23 22:11:47 +0200 | [diff] [blame] | 573 | osmo_strlcpy(g_cfg->net_ports.bind_addr_v4, argv[0], sizeof(g_cfg->net_ports.bind_addr_v4)); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 574 | return CMD_SUCCESS; |
| 575 | } |
Philipp Maier | f1889d8 | 2017-11-08 14:59:39 +0100 | [diff] [blame] | 576 | ALIAS_DEPRECATED(cfg_mgcp_rtp_bind_ip, |
| 577 | cfg_mgcp_rtp_net_bind_ip_cmd, |
| 578 | "rtp net-bind-ip A.B.C.D", |
| 579 | RTP_STR "Bind endpoints facing the Network\n" "Address to bind to\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 580 | |
Philipp Maier | 19c430f | 2020-09-22 15:52:50 +0200 | [diff] [blame] | 581 | DEFUN_USRATTR(cfg_mgcp_rtp_no_bind_ip, |
| 582 | cfg_mgcp_rtp_no_bind_ip_cmd, |
| 583 | X(MGW_CMD_ATTR_NEWCONN), |
| 584 | "no rtp bind-ip", |
| 585 | NO_STR RTP_STR "Bind endpoints facing the Network\n" |
| 586 | "Address to bind to\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 587 | { |
Eric | 2764bdb | 2021-08-23 22:11:47 +0200 | [diff] [blame] | 588 | osmo_strlcpy(g_cfg->net_ports.bind_addr_v4, "", sizeof(g_cfg->net_ports.bind_addr_v4)); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 589 | return CMD_SUCCESS; |
| 590 | } |
Philipp Maier | f1889d8 | 2017-11-08 14:59:39 +0100 | [diff] [blame] | 591 | ALIAS_DEPRECATED(cfg_mgcp_rtp_no_bind_ip, |
| 592 | cfg_mgcp_rtp_no_net_bind_ip_cmd, |
| 593 | "no rtp net-bind-ip", |
| 594 | NO_STR RTP_STR "Bind endpoints facing the Network\n" |
| 595 | "Address to bind to\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 596 | |
Philipp Maier | 19c430f | 2020-09-22 15:52:50 +0200 | [diff] [blame] | 597 | DEFUN_USRATTR(cfg_mgcp_rtp_bind_ip_v6, |
| 598 | cfg_mgcp_rtp_bind_ip_v6_cmd, |
| 599 | X(MGW_CMD_ATTR_NEWCONN), |
| 600 | "rtp bind-ip-v6 " VTY_IPV6_CMD, |
| 601 | RTP_STR "Bind endpoints facing the Network\n" |
| 602 | "IPv6 Address to bind to\n") |
Pau Espin Pedrol | 8a2a1b2 | 2020-09-02 20:46:24 +0200 | [diff] [blame] | 603 | { |
Eric | 2764bdb | 2021-08-23 22:11:47 +0200 | [diff] [blame] | 604 | osmo_strlcpy(g_cfg->net_ports.bind_addr_v6, argv[0], sizeof(g_cfg->net_ports.bind_addr_v6)); |
Pau Espin Pedrol | 8a2a1b2 | 2020-09-02 20:46:24 +0200 | [diff] [blame] | 605 | return CMD_SUCCESS; |
| 606 | } |
| 607 | |
Philipp Maier | 19c430f | 2020-09-22 15:52:50 +0200 | [diff] [blame] | 608 | DEFUN_USRATTR(cfg_mgcp_rtp_no_bind_ip_v6, |
| 609 | cfg_mgcp_rtp_no_bind_ip_v6_cmd, |
| 610 | X(MGW_CMD_ATTR_NEWCONN), |
| 611 | "no rtp bind-ip-v6", |
| 612 | NO_STR RTP_STR "Bind endpoints facing the Network\n" |
| 613 | "Address to bind to\n") |
Pau Espin Pedrol | 8a2a1b2 | 2020-09-02 20:46:24 +0200 | [diff] [blame] | 614 | { |
Eric | 2764bdb | 2021-08-23 22:11:47 +0200 | [diff] [blame] | 615 | osmo_strlcpy(g_cfg->net_ports.bind_addr_v6, "", sizeof(g_cfg->net_ports.bind_addr_v6)); |
Pau Espin Pedrol | 8a2a1b2 | 2020-09-02 20:46:24 +0200 | [diff] [blame] | 616 | return CMD_SUCCESS; |
| 617 | } |
| 618 | |
Philipp Maier | 19c430f | 2020-09-22 15:52:50 +0200 | [diff] [blame] | 619 | DEFUN_USRATTR(cfg_mgcp_rtp_net_bind_ip_probing, |
| 620 | cfg_mgcp_rtp_net_bind_ip_probing_cmd, |
| 621 | X(MGW_CMD_ATTR_NEWCONN), |
| 622 | "rtp ip-probing", |
| 623 | RTP_STR "automatic rtp bind ip selection\n") |
Philipp Maier | 1cb1e38 | 2017-11-02 17:16:04 +0100 | [diff] [blame] | 624 | { |
| 625 | g_cfg->net_ports.bind_addr_probe = true; |
| 626 | return CMD_SUCCESS; |
| 627 | } |
| 628 | |
Philipp Maier | 19c430f | 2020-09-22 15:52:50 +0200 | [diff] [blame] | 629 | DEFUN_USRATTR(cfg_mgcp_rtp_no_net_bind_ip_probing, |
| 630 | cfg_mgcp_rtp_no_net_bind_ip_probing_cmd, |
| 631 | X(MGW_CMD_ATTR_NEWCONN), |
| 632 | "no rtp ip-probing", |
| 633 | NO_STR RTP_STR "no automatic rtp bind ip selection\n") |
Philipp Maier | 1cb1e38 | 2017-11-02 17:16:04 +0100 | [diff] [blame] | 634 | { |
| 635 | g_cfg->net_ports.bind_addr_probe = false; |
| 636 | return CMD_SUCCESS; |
| 637 | } |
| 638 | |
Philipp Maier | 19c430f | 2020-09-22 15:52:50 +0200 | [diff] [blame] | 639 | DEFUN_USRATTR(cfg_mgcp_rtp_ip_dscp, |
| 640 | cfg_mgcp_rtp_ip_dscp_cmd, |
| 641 | X(MGW_CMD_ATTR_NEWCONN), |
Harald Welte | 5936a9c | 2021-04-27 22:30:52 +0200 | [diff] [blame] | 642 | "rtp ip-dscp <0-63>", |
Philipp Maier | 19c430f | 2020-09-22 15:52:50 +0200 | [diff] [blame] | 643 | RTP_STR |
Harald Welte | 5936a9c | 2021-04-27 22:30:52 +0200 | [diff] [blame] | 644 | "Use specified DSCP for the audio stream (including Osmux)\n" "The DSCP value\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 645 | { |
| 646 | int dscp = atoi(argv[0]); |
| 647 | g_cfg->endp_dscp = dscp; |
| 648 | return CMD_SUCCESS; |
| 649 | } |
| 650 | |
Harald Welte | 55a9229 | 2021-04-28 19:06:34 +0200 | [diff] [blame] | 651 | DEFUN_USRATTR(cfg_mgcp_rtp_priority, |
| 652 | cfg_mgcp_rtp_priority_cmd, |
| 653 | X(MGW_CMD_ATTR_NEWCONN), |
| 654 | "rtp socket-priority <0-255>", |
| 655 | RTP_STR |
| 656 | "socket priority (values > 6 require CAP_NET_ADMIN)\n" "socket priority value\n") |
| 657 | { |
| 658 | int prio = atoi(argv[0]); |
| 659 | g_cfg->endp_priority = prio; |
| 660 | return CMD_SUCCESS; |
| 661 | } |
| 662 | |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 663 | #define FORCE_PTIME_STR "Force a fixed ptime for packets sent" |
Philipp Maier | 19c430f | 2020-09-22 15:52:50 +0200 | [diff] [blame] | 664 | DEFUN_USRATTR(cfg_mgcp_rtp_force_ptime, |
| 665 | cfg_mgcp_rtp_force_ptime_cmd, |
| 666 | X(MGW_CMD_ATTR_NEWCONN), |
| 667 | "rtp force-ptime (10|20|40)", |
| 668 | RTP_STR FORCE_PTIME_STR |
| 669 | "The required ptime (packet duration) in ms\n" "10 ms\n20 ms\n40 ms\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 670 | { |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 671 | g_cfg->force_ptime = atoi(argv[0]); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 672 | return CMD_SUCCESS; |
| 673 | } |
| 674 | |
Philipp Maier | 19c430f | 2020-09-22 15:52:50 +0200 | [diff] [blame] | 675 | DEFUN_USRATTR(cfg_mgcp_no_rtp_force_ptime, |
| 676 | cfg_mgcp_no_rtp_force_ptime_cmd, |
| 677 | X(MGW_CMD_ATTR_NEWCONN), |
| 678 | "no rtp force-ptime", NO_STR RTP_STR FORCE_PTIME_STR) |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 679 | { |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 680 | g_cfg->force_ptime = 0; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 681 | return CMD_SUCCESS; |
| 682 | } |
| 683 | |
Philipp Maier | 19c430f | 2020-09-22 15:52:50 +0200 | [diff] [blame] | 684 | DEFUN_USRATTR(cfg_mgcp_sdp_fmtp_extra, |
| 685 | cfg_mgcp_sdp_fmtp_extra_cmd, |
| 686 | X(MGW_CMD_ATTR_NEWCONN), |
| 687 | "sdp audio fmtp-extra .NAME", |
| 688 | "Add extra fmtp for the SDP file\n" "Audio\n" "Fmtp-extra\n" |
| 689 | "Extra Information\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 690 | { |
Philipp Maier | 6fbbeec | 2020-07-01 23:00:54 +0200 | [diff] [blame] | 691 | struct mgcp_trunk *trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_VIRTUAL, MGCP_VIRT_TRUNK_ID); |
Philipp Maier | d19de2e | 2020-06-03 13:55:33 +0200 | [diff] [blame] | 692 | OSMO_ASSERT(trunk); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 693 | char *txt = argv_concat(argv, argc, 0); |
| 694 | if (!txt) |
| 695 | return CMD_WARNING; |
| 696 | |
Philipp Maier | d19de2e | 2020-06-03 13:55:33 +0200 | [diff] [blame] | 697 | osmo_talloc_replace_string(g_cfg, &trunk->audio_fmtp_extra, txt); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 698 | talloc_free(txt); |
| 699 | return CMD_SUCCESS; |
| 700 | } |
| 701 | |
Philipp Maier | 4c4d227 | 2023-04-26 15:45:17 +0200 | [diff] [blame] | 702 | DEFUN_DEPRECATED(cfg_mgcp_allow_transcoding, |
| 703 | cfg_mgcp_allow_transcoding_cmd, |
| 704 | "allow-transcoding", "Allow transcoding\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 705 | { |
Philipp Maier | 4c4d227 | 2023-04-26 15:45:17 +0200 | [diff] [blame] | 706 | vty_out(vty, "%% Deprecated 'allow-transcoding' config no longer has any effect%s", VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 707 | return CMD_SUCCESS; |
| 708 | } |
| 709 | |
Philipp Maier | 4c4d227 | 2023-04-26 15:45:17 +0200 | [diff] [blame] | 710 | DEFUN_DEPRECATED(cfg_mgcp_no_allow_transcoding, |
| 711 | cfg_mgcp_no_allow_transcoding_cmd, |
| 712 | "no allow-transcoding", NO_STR "Allow transcoding\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 713 | { |
Philipp Maier | 4c4d227 | 2023-04-26 15:45:17 +0200 | [diff] [blame] | 714 | vty_out(vty, "%% Deprecated 'no allow-transcoding' config no longer has any effect%s", VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 715 | return CMD_SUCCESS; |
| 716 | } |
| 717 | |
| 718 | #define SDP_STR "SDP File related options\n" |
| 719 | #define AUDIO_STR "Audio payload options\n" |
Philipp Maier | 7f90ddb | 2020-06-02 21:52:53 +0200 | [diff] [blame] | 720 | DEFUN_DEPRECATED(cfg_mgcp_sdp_payload_number, |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 721 | cfg_mgcp_sdp_payload_number_cmd, |
| 722 | "sdp audio-payload number <0-255>", |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 723 | SDP_STR AUDIO_STR "Number\n" "Payload number\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 724 | { |
Philipp Maier | 72761b3 | 2023-04-06 16:04:12 +0200 | [diff] [blame] | 725 | vty_out(vty, "%% Deprecated 'sdp audio-payload number <0-255>' config no longer has any effect%s", VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 726 | return CMD_SUCCESS; |
| 727 | } |
| 728 | |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 729 | ALIAS_DEPRECATED(cfg_mgcp_sdp_payload_number, |
| 730 | cfg_mgcp_sdp_payload_number_cmd_old, |
| 731 | "sdp audio payload number <0-255>", |
| 732 | SDP_STR AUDIO_STR AUDIO_STR "Number\n" "Payload number\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 733 | |
Philipp Maier | 7f90ddb | 2020-06-02 21:52:53 +0200 | [diff] [blame] | 734 | DEFUN_DEPRECATED(cfg_mgcp_sdp_payload_name, |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 735 | cfg_mgcp_sdp_payload_name_cmd, |
| 736 | "sdp audio-payload name NAME", |
| 737 | SDP_STR AUDIO_STR "Name\n" "Payload name\n") |
| 738 | { |
Philipp Maier | 72761b3 | 2023-04-06 16:04:12 +0200 | [diff] [blame] | 739 | vty_out(vty, "%% Deprecated 'sdp audio-payload name NAME' config no longer has any effect%s", VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 740 | return CMD_SUCCESS; |
| 741 | } |
| 742 | |
| 743 | ALIAS_DEPRECATED(cfg_mgcp_sdp_payload_name, cfg_mgcp_sdp_payload_name_cmd_old, |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 744 | "sdp audio payload name NAME", |
| 745 | SDP_STR AUDIO_STR AUDIO_STR "Name\n" "Payload name\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 746 | |
Philipp Maier | 19c430f | 2020-09-22 15:52:50 +0200 | [diff] [blame] | 747 | DEFUN_USRATTR(cfg_mgcp_sdp_payload_send_ptime, |
| 748 | cfg_mgcp_sdp_payload_send_ptime_cmd, |
| 749 | X(MGW_CMD_ATTR_NEWCONN), |
| 750 | "sdp audio-payload send-ptime", |
| 751 | SDP_STR AUDIO_STR "Send SDP ptime (packet duration) attribute\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 752 | { |
Philipp Maier | 6fbbeec | 2020-07-01 23:00:54 +0200 | [diff] [blame] | 753 | struct mgcp_trunk *trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_VIRTUAL, MGCP_VIRT_TRUNK_ID); |
Philipp Maier | d19de2e | 2020-06-03 13:55:33 +0200 | [diff] [blame] | 754 | OSMO_ASSERT(trunk); |
| 755 | trunk->audio_send_ptime = 1; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 756 | return CMD_SUCCESS; |
| 757 | } |
| 758 | |
Philipp Maier | 19c430f | 2020-09-22 15:52:50 +0200 | [diff] [blame] | 759 | DEFUN_USRATTR(cfg_mgcp_no_sdp_payload_send_ptime, |
| 760 | cfg_mgcp_no_sdp_payload_send_ptime_cmd, |
| 761 | X(MGW_CMD_ATTR_NEWCONN), |
| 762 | "no sdp audio-payload send-ptime", |
| 763 | NO_STR SDP_STR AUDIO_STR "Send SDP ptime (packet duration) attribute\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 764 | { |
Philipp Maier | 6fbbeec | 2020-07-01 23:00:54 +0200 | [diff] [blame] | 765 | struct mgcp_trunk *trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_VIRTUAL, MGCP_VIRT_TRUNK_ID); |
Philipp Maier | d19de2e | 2020-06-03 13:55:33 +0200 | [diff] [blame] | 766 | OSMO_ASSERT(trunk); |
| 767 | trunk->audio_send_ptime = 0; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 768 | return CMD_SUCCESS; |
| 769 | } |
| 770 | |
Philipp Maier | 19c430f | 2020-09-22 15:52:50 +0200 | [diff] [blame] | 771 | DEFUN_USRATTR(cfg_mgcp_sdp_payload_send_name, |
| 772 | cfg_mgcp_sdp_payload_send_name_cmd, |
| 773 | X(MGW_CMD_ATTR_NEWCONN), |
| 774 | "sdp audio-payload send-name", |
| 775 | SDP_STR AUDIO_STR "Send SDP rtpmap with the audio name\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 776 | { |
Philipp Maier | 6fbbeec | 2020-07-01 23:00:54 +0200 | [diff] [blame] | 777 | struct mgcp_trunk *trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_VIRTUAL, MGCP_VIRT_TRUNK_ID); |
Philipp Maier | d19de2e | 2020-06-03 13:55:33 +0200 | [diff] [blame] | 778 | OSMO_ASSERT(trunk); |
| 779 | trunk->audio_send_name = 1; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 780 | return CMD_SUCCESS; |
| 781 | } |
| 782 | |
Philipp Maier | 19c430f | 2020-09-22 15:52:50 +0200 | [diff] [blame] | 783 | DEFUN_USRATTR(cfg_mgcp_no_sdp_payload_send_name, |
| 784 | cfg_mgcp_no_sdp_payload_send_name_cmd, |
| 785 | X(MGW_CMD_ATTR_NEWCONN), |
| 786 | "no sdp audio-payload send-name", |
| 787 | NO_STR SDP_STR AUDIO_STR "Send SDP rtpmap with the audio name\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 788 | { |
Philipp Maier | 6fbbeec | 2020-07-01 23:00:54 +0200 | [diff] [blame] | 789 | struct mgcp_trunk *trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_VIRTUAL, MGCP_VIRT_TRUNK_ID); |
Philipp Maier | d19de2e | 2020-06-03 13:55:33 +0200 | [diff] [blame] | 790 | OSMO_ASSERT(trunk); |
| 791 | trunk->audio_send_name = 0; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 792 | return CMD_SUCCESS; |
| 793 | } |
| 794 | |
Philipp Maier | ba94b6d | 2020-09-22 16:14:32 +0200 | [diff] [blame] | 795 | DEFUN_DEPRECATED(cfg_mgcp_loop, |
| 796 | cfg_mgcp_loop_cmd, |
| 797 | "loop (0|1)", |
| 798 | "Loop audio for all endpoints on main trunk\n" "Don't Loop\n" "Loop\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 799 | { |
Philipp Maier | 72761b3 | 2023-04-06 16:04:12 +0200 | [diff] [blame] | 800 | vty_out(vty, "%% Deprecated 'loop (0|1)' config no longer has any effect%s", VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 801 | return CMD_SUCCESS; |
| 802 | } |
| 803 | |
Philipp Maier | 19c430f | 2020-09-22 15:52:50 +0200 | [diff] [blame] | 804 | DEFUN_USRATTR(cfg_mgcp_force_realloc, |
| 805 | cfg_mgcp_force_realloc_cmd, |
| 806 | X(MGW_CMD_ATTR_NEWCONN), |
| 807 | "force-realloc (0|1)", |
| 808 | "Force endpoint reallocation when the endpoint is still seized\n" |
| 809 | "Don't force reallocation\n" "force reallocation\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 810 | { |
Philipp Maier | 6fbbeec | 2020-07-01 23:00:54 +0200 | [diff] [blame] | 811 | struct mgcp_trunk *trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_VIRTUAL, MGCP_VIRT_TRUNK_ID); |
Philipp Maier | d19de2e | 2020-06-03 13:55:33 +0200 | [diff] [blame] | 812 | OSMO_ASSERT(trunk); |
| 813 | trunk->force_realloc = atoi(argv[0]); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 814 | return CMD_SUCCESS; |
| 815 | } |
| 816 | |
Philipp Maier | 19c430f | 2020-09-22 15:52:50 +0200 | [diff] [blame] | 817 | DEFUN_ATTR(cfg_mgcp_rtp_accept_all, |
| 818 | cfg_mgcp_rtp_accept_all_cmd, |
| 819 | "rtp-accept-all (0|1)", |
| 820 | "Accept all RTP packets, even when the originating IP/Port does not match\n" |
| 821 | "enable filter\n" "disable filter\n", |
| 822 | CMD_ATTR_IMMEDIATE) |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 823 | { |
Philipp Maier | 6fbbeec | 2020-07-01 23:00:54 +0200 | [diff] [blame] | 824 | struct mgcp_trunk *trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_VIRTUAL, MGCP_VIRT_TRUNK_ID); |
Philipp Maier | d19de2e | 2020-06-03 13:55:33 +0200 | [diff] [blame] | 825 | OSMO_ASSERT(trunk); |
| 826 | trunk->rtp_accept_all = atoi(argv[0]); |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 827 | return CMD_SUCCESS; |
| 828 | } |
| 829 | |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 830 | DEFUN(cfg_mgcp_number_endp, |
| 831 | cfg_mgcp_number_endp_cmd, |
Philipp Maier | 869b21c | 2020-07-03 16:04:16 +0200 | [diff] [blame] | 832 | "number endpoints <1-65534>", |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 833 | "Number options\n" "Endpoints available\n" "Number endpoints\n") |
| 834 | { |
Philipp Maier | 6fbbeec | 2020-07-01 23:00:54 +0200 | [diff] [blame] | 835 | struct mgcp_trunk *trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_VIRTUAL, MGCP_VIRT_TRUNK_ID); |
Philipp Maier | d19de2e | 2020-06-03 13:55:33 +0200 | [diff] [blame] | 836 | OSMO_ASSERT(trunk); |
Philipp Maier | 889fe7f | 2020-07-06 17:44:12 +0200 | [diff] [blame] | 837 | trunk->v.vty_number_endpoints = atoi(argv[0]); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 838 | return CMD_SUCCESS; |
| 839 | } |
| 840 | |
Philipp Maier | 19c430f | 2020-09-22 15:52:50 +0200 | [diff] [blame] | 841 | DEFUN_ATTR(cfg_mgcp_omit_rtcp, |
| 842 | cfg_mgcp_omit_rtcp_cmd, |
| 843 | "rtcp-omit", RTCP_OMIT_STR, |
| 844 | CMD_ATTR_IMMEDIATE) |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 845 | { |
Philipp Maier | 6fbbeec | 2020-07-01 23:00:54 +0200 | [diff] [blame] | 846 | struct mgcp_trunk *trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_VIRTUAL, MGCP_VIRT_TRUNK_ID); |
Philipp Maier | d19de2e | 2020-06-03 13:55:33 +0200 | [diff] [blame] | 847 | trunk->omit_rtcp = 1; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 848 | return CMD_SUCCESS; |
| 849 | } |
| 850 | |
Philipp Maier | 19c430f | 2020-09-22 15:52:50 +0200 | [diff] [blame] | 851 | DEFUN_ATTR(cfg_mgcp_no_omit_rtcp, |
| 852 | cfg_mgcp_no_omit_rtcp_cmd, |
| 853 | "no rtcp-omit", |
| 854 | NO_STR RTCP_OMIT_STR, |
| 855 | CMD_ATTR_IMMEDIATE) |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 856 | { |
Philipp Maier | 6fbbeec | 2020-07-01 23:00:54 +0200 | [diff] [blame] | 857 | struct mgcp_trunk *trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_VIRTUAL, MGCP_VIRT_TRUNK_ID); |
Philipp Maier | d19de2e | 2020-06-03 13:55:33 +0200 | [diff] [blame] | 858 | OSMO_ASSERT(trunk); |
| 859 | trunk->omit_rtcp = 0; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 860 | return CMD_SUCCESS; |
| 861 | } |
| 862 | |
Philipp Maier | 19c430f | 2020-09-22 15:52:50 +0200 | [diff] [blame] | 863 | DEFUN_USRATTR(cfg_mgcp_patch_rtp_ssrc, |
| 864 | cfg_mgcp_patch_rtp_ssrc_cmd, |
| 865 | X(MGW_CMD_ATTR_NEWCONN), |
| 866 | "rtp-patch ssrc", RTP_PATCH_STR "Force a fixed SSRC\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 867 | { |
Philipp Maier | 6fbbeec | 2020-07-01 23:00:54 +0200 | [diff] [blame] | 868 | struct mgcp_trunk *trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_VIRTUAL, MGCP_VIRT_TRUNK_ID); |
Philipp Maier | d19de2e | 2020-06-03 13:55:33 +0200 | [diff] [blame] | 869 | OSMO_ASSERT(trunk); |
| 870 | trunk->force_constant_ssrc = 1; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 871 | return CMD_SUCCESS; |
| 872 | } |
| 873 | |
Philipp Maier | 19c430f | 2020-09-22 15:52:50 +0200 | [diff] [blame] | 874 | DEFUN_USRATTR(cfg_mgcp_no_patch_rtp_ssrc, |
| 875 | cfg_mgcp_no_patch_rtp_ssrc_cmd, |
| 876 | X(MGW_CMD_ATTR_NEWCONN), |
| 877 | "no rtp-patch ssrc", NO_STR RTP_PATCH_STR "Force a fixed SSRC\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 878 | { |
Philipp Maier | 6fbbeec | 2020-07-01 23:00:54 +0200 | [diff] [blame] | 879 | struct mgcp_trunk *trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_VIRTUAL, MGCP_VIRT_TRUNK_ID); |
Philipp Maier | d19de2e | 2020-06-03 13:55:33 +0200 | [diff] [blame] | 880 | OSMO_ASSERT(trunk); |
| 881 | trunk->force_constant_ssrc = 0; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 882 | return CMD_SUCCESS; |
| 883 | } |
| 884 | |
Philipp Maier | 19c430f | 2020-09-22 15:52:50 +0200 | [diff] [blame] | 885 | DEFUN_USRATTR(cfg_mgcp_patch_rtp_ts, |
| 886 | cfg_mgcp_patch_rtp_ts_cmd, |
| 887 | X(MGW_CMD_ATTR_NEWCONN), |
| 888 | "rtp-patch timestamp", RTP_PATCH_STR "Adjust RTP timestamp\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 889 | { |
Philipp Maier | 6fbbeec | 2020-07-01 23:00:54 +0200 | [diff] [blame] | 890 | struct mgcp_trunk *trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_VIRTUAL, MGCP_VIRT_TRUNK_ID); |
Philipp Maier | d19de2e | 2020-06-03 13:55:33 +0200 | [diff] [blame] | 891 | OSMO_ASSERT(trunk); |
| 892 | trunk->force_aligned_timing = 1; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 893 | return CMD_SUCCESS; |
| 894 | } |
| 895 | |
Philipp Maier | 19c430f | 2020-09-22 15:52:50 +0200 | [diff] [blame] | 896 | DEFUN_USRATTR(cfg_mgcp_no_patch_rtp_ts, |
| 897 | cfg_mgcp_no_patch_rtp_ts_cmd, |
| 898 | X(MGW_CMD_ATTR_NEWCONN), |
| 899 | "no rtp-patch timestamp", NO_STR RTP_PATCH_STR "Adjust RTP timestamp\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 900 | { |
Philipp Maier | 6fbbeec | 2020-07-01 23:00:54 +0200 | [diff] [blame] | 901 | struct mgcp_trunk *trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_VIRTUAL, MGCP_VIRT_TRUNK_ID); |
Philipp Maier | d19de2e | 2020-06-03 13:55:33 +0200 | [diff] [blame] | 902 | OSMO_ASSERT(trunk); |
| 903 | trunk->force_aligned_timing = 0; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 904 | return CMD_SUCCESS; |
| 905 | } |
| 906 | |
Philipp Maier | 19c430f | 2020-09-22 15:52:50 +0200 | [diff] [blame] | 907 | DEFUN_USRATTR(cfg_mgcp_patch_rtp_rfc5993hr, |
| 908 | cfg_mgcp_patch_rtp_rfc5993hr_cmd, |
| 909 | X(MGW_CMD_ATTR_NEWCONN), |
| 910 | "rtp-patch rfc5993hr", RTP_PATCH_STR RTP_TS101318_RFC5993_CONV_STR) |
Philipp Maier | 9fc8a02 | 2019-02-20 12:26:52 +0100 | [diff] [blame] | 911 | { |
Philipp Maier | 6fbbeec | 2020-07-01 23:00:54 +0200 | [diff] [blame] | 912 | struct mgcp_trunk *trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_VIRTUAL, MGCP_VIRT_TRUNK_ID); |
Philipp Maier | d19de2e | 2020-06-03 13:55:33 +0200 | [diff] [blame] | 913 | OSMO_ASSERT(trunk); |
| 914 | trunk->rfc5993_hr_convert = true; |
Philipp Maier | 9fc8a02 | 2019-02-20 12:26:52 +0100 | [diff] [blame] | 915 | return CMD_SUCCESS; |
| 916 | } |
| 917 | |
Philipp Maier | 19c430f | 2020-09-22 15:52:50 +0200 | [diff] [blame] | 918 | DEFUN_USRATTR(cfg_mgcp_no_patch_rtp_rfc5993hr, |
| 919 | cfg_mgcp_no_patch_rtp_rfc5993hr_cmd, |
| 920 | X(MGW_CMD_ATTR_NEWCONN), |
| 921 | "no rtp-patch rfc5993hr", NO_STR RTP_PATCH_STR RTP_TS101318_RFC5993_CONV_STR) |
Philipp Maier | 9fc8a02 | 2019-02-20 12:26:52 +0100 | [diff] [blame] | 922 | { |
Philipp Maier | 6fbbeec | 2020-07-01 23:00:54 +0200 | [diff] [blame] | 923 | struct mgcp_trunk *trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_VIRTUAL, MGCP_VIRT_TRUNK_ID); |
Philipp Maier | d19de2e | 2020-06-03 13:55:33 +0200 | [diff] [blame] | 924 | OSMO_ASSERT(trunk); |
| 925 | trunk->rfc5993_hr_convert = false; |
Philipp Maier | 9fc8a02 | 2019-02-20 12:26:52 +0100 | [diff] [blame] | 926 | return CMD_SUCCESS; |
| 927 | } |
| 928 | |
Philipp Maier | 19c430f | 2020-09-22 15:52:50 +0200 | [diff] [blame] | 929 | DEFUN_USRATTR(cfg_mgcp_no_patch_rtp, |
| 930 | cfg_mgcp_no_patch_rtp_cmd, |
| 931 | X(MGW_CMD_ATTR_NEWCONN), |
| 932 | "no rtp-patch", NO_STR RTP_PATCH_STR) |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 933 | { |
Philipp Maier | 6fbbeec | 2020-07-01 23:00:54 +0200 | [diff] [blame] | 934 | struct mgcp_trunk *trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_VIRTUAL, MGCP_VIRT_TRUNK_ID); |
Philipp Maier | d19de2e | 2020-06-03 13:55:33 +0200 | [diff] [blame] | 935 | OSMO_ASSERT(trunk); |
| 936 | trunk->force_constant_ssrc = 0; |
| 937 | trunk->force_aligned_timing = 0; |
| 938 | trunk->rfc5993_hr_convert = false; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 939 | return CMD_SUCCESS; |
| 940 | } |
| 941 | |
Philipp Maier | 19c430f | 2020-09-22 15:52:50 +0200 | [diff] [blame] | 942 | DEFUN_ATTR(cfg_mgcp_rtp_keepalive, |
| 943 | cfg_mgcp_rtp_keepalive_cmd, |
| 944 | "rtp keep-alive <1-120>", |
| 945 | RTP_STR RTP_KEEPALIVE_STR "Keep alive interval in secs\n", |
| 946 | CMD_ATTR_IMMEDIATE) |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 947 | { |
Philipp Maier | 6fbbeec | 2020-07-01 23:00:54 +0200 | [diff] [blame] | 948 | struct mgcp_trunk *trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_VIRTUAL, MGCP_VIRT_TRUNK_ID); |
Philipp Maier | d19de2e | 2020-06-03 13:55:33 +0200 | [diff] [blame] | 949 | OSMO_ASSERT(trunk); |
| 950 | mgcp_trunk_set_keepalive(trunk, atoi(argv[0])); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 951 | return CMD_SUCCESS; |
| 952 | } |
| 953 | |
Philipp Maier | 19c430f | 2020-09-22 15:52:50 +0200 | [diff] [blame] | 954 | DEFUN_ATTR(cfg_mgcp_rtp_keepalive_once, |
| 955 | cfg_mgcp_rtp_keepalive_once_cmd, |
| 956 | "rtp keep-alive once", |
| 957 | RTP_STR RTP_KEEPALIVE_STR "Send dummy packet only once after CRCX/MDCX\n", |
| 958 | CMD_ATTR_IMMEDIATE) |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 959 | { |
Philipp Maier | 6fbbeec | 2020-07-01 23:00:54 +0200 | [diff] [blame] | 960 | struct mgcp_trunk *trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_VIRTUAL, MGCP_VIRT_TRUNK_ID); |
Philipp Maier | d19de2e | 2020-06-03 13:55:33 +0200 | [diff] [blame] | 961 | OSMO_ASSERT(trunk); |
| 962 | mgcp_trunk_set_keepalive(trunk, MGCP_KEEPALIVE_ONCE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 963 | return CMD_SUCCESS; |
| 964 | } |
| 965 | |
Philipp Maier | 19c430f | 2020-09-22 15:52:50 +0200 | [diff] [blame] | 966 | DEFUN_ATTR(cfg_mgcp_no_rtp_keepalive, |
| 967 | cfg_mgcp_no_rtp_keepalive_cmd, |
| 968 | "no rtp keep-alive", NO_STR RTP_STR RTP_KEEPALIVE_STR, |
| 969 | CMD_ATTR_IMMEDIATE) |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 970 | { |
Philipp Maier | 6fbbeec | 2020-07-01 23:00:54 +0200 | [diff] [blame] | 971 | struct mgcp_trunk *trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_VIRTUAL, MGCP_VIRT_TRUNK_ID); |
Philipp Maier | d19de2e | 2020-06-03 13:55:33 +0200 | [diff] [blame] | 972 | OSMO_ASSERT(trunk); |
| 973 | mgcp_trunk_set_keepalive(trunk, MGCP_KEEPALIVE_NEVER); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 974 | return CMD_SUCCESS; |
| 975 | } |
| 976 | |
Pau Espin Pedrol | a790f0c | 2020-08-31 13:29:11 +0200 | [diff] [blame] | 977 | #define CALL_AGENT_STR "Call agent information\n" |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 978 | DEFUN(cfg_mgcp_agent_addr, |
| 979 | cfg_mgcp_agent_addr_cmd, |
Pau Espin Pedrol | a790f0c | 2020-08-31 13:29:11 +0200 | [diff] [blame] | 980 | "call-agent ip " VTY_IPV46_CMD, |
| 981 | CALL_AGENT_STR IP_STR |
| 982 | "IPv4 Address of the call agent\n" |
| 983 | "IPv6 Address of the call agent\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 984 | { |
Eric | 2764bdb | 2021-08-23 22:11:47 +0200 | [diff] [blame] | 985 | osmo_strlcpy(g_cfg->call_agent_addr, argv[0], sizeof(g_cfg->call_agent_addr)); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 986 | return CMD_SUCCESS; |
| 987 | } |
| 988 | |
| 989 | ALIAS_DEPRECATED(cfg_mgcp_agent_addr, cfg_mgcp_agent_addr_cmd_old, |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 990 | "call agent ip A.B.C.D", |
| 991 | CALL_AGENT_STR CALL_AGENT_STR IP_STR |
| 992 | "IPv4 Address of the callagent\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 993 | |
Philipp Maier | 21be42a | 2020-05-29 21:39:48 +0200 | [diff] [blame] | 994 | DEFUN(cfg_mgcp_trunk, cfg_mgcp_trunk_cmd, |
Philipp Maier | 0653cc8 | 2020-08-10 22:52:51 +0200 | [diff] [blame] | 995 | "trunk <0-64>", "Configure a SS7 trunk\n" "Trunk Nr\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 996 | { |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 997 | struct mgcp_trunk *trunk; |
Philipp Maier | d70eef6 | 2021-07-19 13:53:28 +0200 | [diff] [blame] | 998 | unsigned int index = atoi(argv[0]); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 999 | |
Philipp Maier | 6fbbeec | 2020-07-01 23:00:54 +0200 | [diff] [blame] | 1000 | trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_E1, index); |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 1001 | if (!trunk) { |
| 1002 | trunk = mgcp_trunk_alloc(g_cfg, MGCP_TRUNK_E1, index); |
Philipp Maier | 2d681fd | 2020-05-29 16:20:25 +0200 | [diff] [blame] | 1003 | if (!trunk) { |
| 1004 | vty_out(vty, "%%Unable to allocate trunk %u.%s", |
| 1005 | index, VTY_NEWLINE); |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 1006 | return CMD_WARNING; |
Philipp Maier | 2d681fd | 2020-05-29 16:20:25 +0200 | [diff] [blame] | 1007 | } |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1008 | } |
| 1009 | |
| 1010 | vty->node = TRUNK_NODE; |
| 1011 | vty->index = trunk; |
| 1012 | return CMD_SUCCESS; |
| 1013 | } |
| 1014 | |
| 1015 | static int config_write_trunk(struct vty *vty) |
| 1016 | { |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 1017 | struct mgcp_trunk *trunk; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1018 | |
| 1019 | llist_for_each_entry(trunk, &g_cfg->trunks, entry) { |
Philipp Maier | d19de2e | 2020-06-03 13:55:33 +0200 | [diff] [blame] | 1020 | |
| 1021 | /* Due to historical reasons, the virtual trunk is configured |
| 1022 | using separate VTY parameters, so we omit writing the trunk |
| 1023 | config of trunk 0 here. The configuration for the virtual |
| 1024 | trunk is written by config_write_mgcp(). */ |
| 1025 | |
Philipp Maier | 31682a3 | 2020-11-26 00:39:35 +0100 | [diff] [blame] | 1026 | if (trunk->trunk_type == MGCP_TRUNK_VIRTUAL |
| 1027 | && trunk->trunk_nr == MGCP_VIRT_TRUNK_ID) |
Philipp Maier | d19de2e | 2020-06-03 13:55:33 +0200 | [diff] [blame] | 1028 | continue; |
| 1029 | |
Philipp Maier | d70eef6 | 2021-07-19 13:53:28 +0200 | [diff] [blame] | 1030 | vty_out(vty, " trunk %u%s", trunk->trunk_nr, VTY_NEWLINE); |
Philipp Maier | 889fe7f | 2020-07-06 17:44:12 +0200 | [diff] [blame] | 1031 | vty_out(vty, " line %u%s", trunk->e1.vty_line_nr, VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1032 | vty_out(vty, " %ssdp audio-payload send-ptime%s", |
| 1033 | trunk->audio_send_ptime ? "" : "no ", VTY_NEWLINE); |
| 1034 | vty_out(vty, " %ssdp audio-payload send-name%s", |
| 1035 | trunk->audio_send_name ? "" : "no ", VTY_NEWLINE); |
| 1036 | |
| 1037 | if (trunk->keepalive_interval == MGCP_KEEPALIVE_ONCE) |
| 1038 | vty_out(vty, " rtp keep-alive once%s", VTY_NEWLINE); |
| 1039 | else if (trunk->keepalive_interval) |
| 1040 | vty_out(vty, " rtp keep-alive %d%s", |
| 1041 | trunk->keepalive_interval, VTY_NEWLINE); |
| 1042 | else |
| 1043 | vty_out(vty, " no rtp keep-alive%s", VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1044 | vty_out(vty, " force-realloc %d%s", |
| 1045 | trunk->force_realloc, VTY_NEWLINE); |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1046 | vty_out(vty, " rtp-accept-all %d%s", |
| 1047 | trunk->rtp_accept_all, VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1048 | if (trunk->omit_rtcp) |
| 1049 | vty_out(vty, " rtcp-omit%s", VTY_NEWLINE); |
| 1050 | else |
| 1051 | vty_out(vty, " no rtcp-omit%s", VTY_NEWLINE); |
Philipp Maier | 9fc8a02 | 2019-02-20 12:26:52 +0100 | [diff] [blame] | 1052 | if (trunk->force_constant_ssrc || trunk->force_aligned_timing |
Philipp Maier | d19de2e | 2020-06-03 13:55:33 +0200 | [diff] [blame] | 1053 | || trunk->rfc5993_hr_convert) { |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1054 | vty_out(vty, " %srtp-patch ssrc%s", |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1055 | trunk->force_constant_ssrc ? "" : "no ", |
| 1056 | VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1057 | vty_out(vty, " %srtp-patch timestamp%s", |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1058 | trunk->force_aligned_timing ? "" : "no ", |
| 1059 | VTY_NEWLINE); |
Philipp Maier | 9fc8a02 | 2019-02-20 12:26:52 +0100 | [diff] [blame] | 1060 | vty_out(vty, " %srtp-patch rfc5993hr%s", |
| 1061 | trunk->rfc5993_hr_convert ? "" : "no ", |
| 1062 | VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1063 | } else |
| 1064 | vty_out(vty, " no rtp-patch%s", VTY_NEWLINE); |
| 1065 | if (trunk->audio_fmtp_extra) |
| 1066 | vty_out(vty, " sdp audio fmtp-extra %s%s", |
| 1067 | trunk->audio_fmtp_extra, VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1068 | } |
| 1069 | |
| 1070 | return CMD_SUCCESS; |
| 1071 | } |
| 1072 | |
Philipp Maier | 19c430f | 2020-09-22 15:52:50 +0200 | [diff] [blame] | 1073 | DEFUN_USRATTR(cfg_trunk_sdp_fmtp_extra, |
| 1074 | cfg_trunk_sdp_fmtp_extra_cmd, |
| 1075 | X(MGW_CMD_ATTR_NEWCONN), |
| 1076 | "sdp audio fmtp-extra .NAME", |
| 1077 | "Add extra fmtp for the SDP file\n" "Audio\n" "Fmtp-extra\n" |
| 1078 | "Extra Information\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1079 | { |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 1080 | struct mgcp_trunk *trunk = vty->index; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1081 | char *txt = argv_concat(argv, argc, 0); |
| 1082 | if (!txt) |
| 1083 | return CMD_WARNING; |
| 1084 | |
| 1085 | osmo_talloc_replace_string(g_cfg, &trunk->audio_fmtp_extra, txt); |
| 1086 | talloc_free(txt); |
| 1087 | return CMD_SUCCESS; |
| 1088 | } |
| 1089 | |
Philipp Maier | 7f90ddb | 2020-06-02 21:52:53 +0200 | [diff] [blame] | 1090 | DEFUN_DEPRECATED(cfg_trunk_payload_number, |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1091 | cfg_trunk_payload_number_cmd, |
| 1092 | "sdp audio-payload number <0-255>", |
| 1093 | SDP_STR AUDIO_STR "Number\n" "Payload Number\n") |
| 1094 | { |
Philipp Maier | 72761b3 | 2023-04-06 16:04:12 +0200 | [diff] [blame] | 1095 | vty_out(vty, "%% Deprecated 'sdp audio-payload number <0-255>' config no longer has any effect%s", VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1096 | return CMD_SUCCESS; |
| 1097 | } |
| 1098 | |
| 1099 | ALIAS_DEPRECATED(cfg_trunk_payload_number, cfg_trunk_payload_number_cmd_old, |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1100 | "sdp audio payload number <0-255>", |
| 1101 | SDP_STR AUDIO_STR AUDIO_STR "Number\n" "Payload Number\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1102 | |
Philipp Maier | 7f90ddb | 2020-06-02 21:52:53 +0200 | [diff] [blame] | 1103 | DEFUN_DEPRECATED(cfg_trunk_payload_name, |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1104 | cfg_trunk_payload_name_cmd, |
| 1105 | "sdp audio-payload name NAME", |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1106 | SDP_STR AUDIO_STR "Payload\n" "Payload Name\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1107 | { |
Philipp Maier | 72761b3 | 2023-04-06 16:04:12 +0200 | [diff] [blame] | 1108 | vty_out(vty, "%% Deprecated 'sdp audio-payload name NAME' config no longer has any effect%s", VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1109 | return CMD_SUCCESS; |
| 1110 | } |
| 1111 | |
| 1112 | ALIAS_DEPRECATED(cfg_trunk_payload_name, cfg_trunk_payload_name_cmd_old, |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1113 | "sdp audio payload name NAME", |
| 1114 | SDP_STR AUDIO_STR AUDIO_STR "Payload\n" "Payload Name\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1115 | |
Philipp Maier | ba94b6d | 2020-09-22 16:14:32 +0200 | [diff] [blame] | 1116 | DEFUN_DEPRECATED(cfg_trunk_loop, |
| 1117 | cfg_trunk_loop_cmd, |
| 1118 | "loop (0|1)", |
| 1119 | "Loop audio for all endpoints on this trunk\n" "Don't Loop\n" "Loop\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1120 | { |
Philipp Maier | 72761b3 | 2023-04-06 16:04:12 +0200 | [diff] [blame] | 1121 | vty_out(vty, "%% Deprecated 'loop (0|1)' config no longer has any effect%s", VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1122 | return CMD_SUCCESS; |
| 1123 | } |
| 1124 | |
Philipp Maier | 41425e9 | 2020-11-26 00:41:59 +0100 | [diff] [blame] | 1125 | DEFUN_USRATTR(cfg_trunk_force_realloc, |
| 1126 | cfg_trunk_force_realloc_cmd, |
| 1127 | X(MGW_CMD_ATTR_NEWCONN), |
| 1128 | "force-realloc (0|1)", |
| 1129 | "Force endpoint reallocation when the endpoint is still seized\n" |
| 1130 | "Don't force reallocation\n" "force reallocation\n") |
| 1131 | { |
| 1132 | struct mgcp_trunk *trunk = vty->index; |
| 1133 | OSMO_ASSERT(trunk); |
| 1134 | trunk->force_realloc = atoi(argv[0]); |
| 1135 | return CMD_SUCCESS; |
| 1136 | } |
| 1137 | |
| 1138 | DEFUN_ATTR(cfg_trunk_rtp_accept_all, |
| 1139 | cfg_trunk_rtp_accept_all_cmd, |
| 1140 | "rtp-accept-all (0|1)", |
| 1141 | "Accept all RTP packets, even when the originating IP/Port does not match\n" |
| 1142 | "enable filter\n" "disable filter\n", |
| 1143 | CMD_ATTR_IMMEDIATE) |
| 1144 | { |
| 1145 | struct mgcp_trunk *trunk = vty->index; |
| 1146 | OSMO_ASSERT(trunk); |
| 1147 | trunk->rtp_accept_all = atoi(argv[0]); |
| 1148 | return CMD_SUCCESS; |
| 1149 | } |
| 1150 | |
Philipp Maier | 19c430f | 2020-09-22 15:52:50 +0200 | [diff] [blame] | 1151 | DEFUN_USRATTR(cfg_trunk_sdp_payload_send_ptime, |
| 1152 | cfg_trunk_sdp_payload_send_ptime_cmd, |
| 1153 | X(MGW_CMD_ATTR_NEWCONN), |
| 1154 | "sdp audio-payload send-ptime", |
| 1155 | SDP_STR AUDIO_STR "Send SDP ptime (packet duration) attribute\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1156 | { |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 1157 | struct mgcp_trunk *trunk = vty->index; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1158 | trunk->audio_send_ptime = 1; |
| 1159 | return CMD_SUCCESS; |
| 1160 | } |
| 1161 | |
Philipp Maier | 19c430f | 2020-09-22 15:52:50 +0200 | [diff] [blame] | 1162 | DEFUN_USRATTR(cfg_trunk_no_sdp_payload_send_ptime, |
| 1163 | cfg_trunk_no_sdp_payload_send_ptime_cmd, |
| 1164 | X(MGW_CMD_ATTR_NEWCONN), |
| 1165 | "no sdp audio-payload send-ptime", |
| 1166 | NO_STR SDP_STR AUDIO_STR "Send SDP ptime (packet duration) attribute\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1167 | { |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 1168 | struct mgcp_trunk *trunk = vty->index; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1169 | trunk->audio_send_ptime = 0; |
| 1170 | return CMD_SUCCESS; |
| 1171 | } |
| 1172 | |
Philipp Maier | 19c430f | 2020-09-22 15:52:50 +0200 | [diff] [blame] | 1173 | DEFUN_USRATTR(cfg_trunk_sdp_payload_send_name, |
| 1174 | cfg_trunk_sdp_payload_send_name_cmd, |
| 1175 | X(MGW_CMD_ATTR_NEWCONN), |
| 1176 | "sdp audio-payload send-name", |
| 1177 | SDP_STR AUDIO_STR "Send SDP rtpmap with the audio name\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1178 | { |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 1179 | struct mgcp_trunk *trunk = vty->index; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1180 | trunk->audio_send_name = 1; |
| 1181 | return CMD_SUCCESS; |
| 1182 | } |
| 1183 | |
Philipp Maier | 19c430f | 2020-09-22 15:52:50 +0200 | [diff] [blame] | 1184 | DEFUN_USRATTR(cfg_trunk_no_sdp_payload_send_name, |
| 1185 | cfg_trunk_no_sdp_payload_send_name_cmd, |
| 1186 | X(MGW_CMD_ATTR_NEWCONN), |
| 1187 | "no sdp audio-payload send-name", |
| 1188 | NO_STR SDP_STR AUDIO_STR "Send SDP rtpmap with the audio name\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1189 | { |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 1190 | struct mgcp_trunk *trunk = vty->index; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1191 | trunk->audio_send_name = 0; |
| 1192 | return CMD_SUCCESS; |
| 1193 | } |
| 1194 | |
Philipp Maier | 19c430f | 2020-09-22 15:52:50 +0200 | [diff] [blame] | 1195 | DEFUN_ATTR(cfg_trunk_omit_rtcp, |
| 1196 | cfg_trunk_omit_rtcp_cmd, |
| 1197 | "rtcp-omit", RTCP_OMIT_STR, |
| 1198 | CMD_ATTR_IMMEDIATE) |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1199 | { |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 1200 | struct mgcp_trunk *trunk = vty->index; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1201 | trunk->omit_rtcp = 1; |
| 1202 | return CMD_SUCCESS; |
| 1203 | } |
| 1204 | |
Philipp Maier | 19c430f | 2020-09-22 15:52:50 +0200 | [diff] [blame] | 1205 | DEFUN_ATTR(cfg_trunk_no_omit_rtcp, |
| 1206 | cfg_trunk_no_omit_rtcp_cmd, |
| 1207 | "no rtcp-omit", NO_STR RTCP_OMIT_STR, |
| 1208 | CMD_ATTR_IMMEDIATE) |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1209 | { |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 1210 | struct mgcp_trunk *trunk = vty->index; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1211 | trunk->omit_rtcp = 0; |
| 1212 | return CMD_SUCCESS; |
| 1213 | } |
| 1214 | |
Philipp Maier | 19c430f | 2020-09-22 15:52:50 +0200 | [diff] [blame] | 1215 | DEFUN_USRATTR(cfg_trunk_patch_rtp_ssrc, |
| 1216 | cfg_trunk_patch_rtp_ssrc_cmd, |
| 1217 | X(MGW_CMD_ATTR_NEWCONN), |
| 1218 | "rtp-patch ssrc", RTP_PATCH_STR "Force a fixed SSRC\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1219 | { |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 1220 | struct mgcp_trunk *trunk = vty->index; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1221 | trunk->force_constant_ssrc = 1; |
| 1222 | return CMD_SUCCESS; |
| 1223 | } |
| 1224 | |
Philipp Maier | 19c430f | 2020-09-22 15:52:50 +0200 | [diff] [blame] | 1225 | DEFUN_USRATTR(cfg_trunk_no_patch_rtp_ssrc, |
| 1226 | cfg_trunk_no_patch_rtp_ssrc_cmd, |
| 1227 | X(MGW_CMD_ATTR_NEWCONN), |
| 1228 | "no rtp-patch ssrc", NO_STR RTP_PATCH_STR "Force a fixed SSRC\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1229 | { |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 1230 | struct mgcp_trunk *trunk = vty->index; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1231 | trunk->force_constant_ssrc = 0; |
| 1232 | return CMD_SUCCESS; |
| 1233 | } |
| 1234 | |
Philipp Maier | 19c430f | 2020-09-22 15:52:50 +0200 | [diff] [blame] | 1235 | DEFUN_USRATTR(cfg_trunk_patch_rtp_ts, |
| 1236 | cfg_trunk_patch_rtp_ts_cmd, |
| 1237 | X(MGW_CMD_ATTR_NEWCONN), |
| 1238 | "rtp-patch timestamp", RTP_PATCH_STR "Adjust RTP timestamp\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1239 | { |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 1240 | struct mgcp_trunk *trunk = vty->index; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1241 | trunk->force_aligned_timing = 1; |
| 1242 | return CMD_SUCCESS; |
| 1243 | } |
| 1244 | |
Philipp Maier | 19c430f | 2020-09-22 15:52:50 +0200 | [diff] [blame] | 1245 | DEFUN_USRATTR(cfg_trunk_no_patch_rtp_ts, |
| 1246 | cfg_trunk_no_patch_rtp_ts_cmd, |
| 1247 | X(MGW_CMD_ATTR_NEWCONN), |
| 1248 | "no rtp-patch timestamp", NO_STR RTP_PATCH_STR "Adjust RTP timestamp\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1249 | { |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 1250 | struct mgcp_trunk *trunk = vty->index; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1251 | trunk->force_aligned_timing = 0; |
| 1252 | return CMD_SUCCESS; |
| 1253 | } |
| 1254 | |
Philipp Maier | 19c430f | 2020-09-22 15:52:50 +0200 | [diff] [blame] | 1255 | DEFUN_USRATTR(cfg_trunk_patch_rtp_rfc5993hr, |
| 1256 | cfg_trunk_patch_rtp_rfc5993hr_cmd, |
| 1257 | X(MGW_CMD_ATTR_NEWCONN), |
| 1258 | "rtp-patch rfc5993hr", RTP_PATCH_STR RTP_TS101318_RFC5993_CONV_STR) |
Philipp Maier | 9fc8a02 | 2019-02-20 12:26:52 +0100 | [diff] [blame] | 1259 | { |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 1260 | struct mgcp_trunk *trunk = vty->index; |
Philipp Maier | 9fc8a02 | 2019-02-20 12:26:52 +0100 | [diff] [blame] | 1261 | trunk->rfc5993_hr_convert = true; |
| 1262 | return CMD_SUCCESS; |
| 1263 | } |
| 1264 | |
Philipp Maier | 19c430f | 2020-09-22 15:52:50 +0200 | [diff] [blame] | 1265 | DEFUN_USRATTR(cfg_trunk_no_patch_rtp_rfc5993hr, |
| 1266 | cfg_trunk_no_patch_rtp_rfc5993hr_cmd, |
| 1267 | X(MGW_CMD_ATTR_NEWCONN), |
| 1268 | "no rtp-patch rfc5993hr", NO_STR RTP_PATCH_STR RTP_TS101318_RFC5993_CONV_STR) |
Philipp Maier | 9fc8a02 | 2019-02-20 12:26:52 +0100 | [diff] [blame] | 1269 | { |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 1270 | struct mgcp_trunk *trunk = vty->index; |
Philipp Maier | 9fc8a02 | 2019-02-20 12:26:52 +0100 | [diff] [blame] | 1271 | trunk->rfc5993_hr_convert = false; |
| 1272 | return CMD_SUCCESS; |
| 1273 | } |
| 1274 | |
Philipp Maier | 19c430f | 2020-09-22 15:52:50 +0200 | [diff] [blame] | 1275 | DEFUN_USRATTR(cfg_trunk_no_patch_rtp, |
| 1276 | cfg_trunk_no_patch_rtp_cmd, |
| 1277 | X(MGW_CMD_ATTR_NEWCONN), |
| 1278 | "no rtp-patch", NO_STR RTP_PATCH_STR) |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1279 | { |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 1280 | struct mgcp_trunk *trunk = vty->index; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1281 | trunk->force_constant_ssrc = 0; |
| 1282 | trunk->force_aligned_timing = 0; |
Philipp Maier | 9fc8a02 | 2019-02-20 12:26:52 +0100 | [diff] [blame] | 1283 | trunk->rfc5993_hr_convert = false; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1284 | return CMD_SUCCESS; |
| 1285 | } |
| 1286 | |
Philipp Maier | 19c430f | 2020-09-22 15:52:50 +0200 | [diff] [blame] | 1287 | DEFUN_ATTR(cfg_trunk_rtp_keepalive, |
| 1288 | cfg_trunk_rtp_keepalive_cmd, |
| 1289 | "rtp keep-alive <1-120>", |
| 1290 | RTP_STR RTP_KEEPALIVE_STR "Keep-alive interval in secs\n", |
| 1291 | CMD_ATTR_IMMEDIATE) |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1292 | { |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 1293 | struct mgcp_trunk *trunk = vty->index; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1294 | mgcp_trunk_set_keepalive(trunk, atoi(argv[0])); |
| 1295 | return CMD_SUCCESS; |
| 1296 | } |
| 1297 | |
Philipp Maier | 19c430f | 2020-09-22 15:52:50 +0200 | [diff] [blame] | 1298 | DEFUN_ATTR(cfg_trunk_rtp_keepalive_once, |
| 1299 | cfg_trunk_rtp_keepalive_once_cmd, |
| 1300 | "rtp keep-alive once", |
| 1301 | RTP_STR RTP_KEEPALIVE_STR "Send dummy packet only once after CRCX/MDCX\n", |
| 1302 | CMD_ATTR_IMMEDIATE) |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1303 | { |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 1304 | struct mgcp_trunk *trunk = vty->index; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1305 | mgcp_trunk_set_keepalive(trunk, MGCP_KEEPALIVE_ONCE); |
| 1306 | return CMD_SUCCESS; |
| 1307 | } |
| 1308 | |
Philipp Maier | 19c430f | 2020-09-22 15:52:50 +0200 | [diff] [blame] | 1309 | DEFUN_ATTR(cfg_trunk_no_rtp_keepalive, |
| 1310 | cfg_trunk_no_rtp_keepalive_cmd, |
| 1311 | "no rtp keep-alive", NO_STR RTP_STR RTP_KEEPALIVE_STR, |
| 1312 | CMD_ATTR_IMMEDIATE) |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1313 | { |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 1314 | struct mgcp_trunk *trunk = vty->index; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1315 | mgcp_trunk_set_keepalive(trunk, 0); |
| 1316 | return CMD_SUCCESS; |
| 1317 | } |
| 1318 | |
Philipp Maier | 4c4d227 | 2023-04-26 15:45:17 +0200 | [diff] [blame] | 1319 | DEFUN_DEPRECATED(cfg_trunk_allow_transcoding, |
| 1320 | cfg_trunk_allow_transcoding_cmd, |
| 1321 | "allow-transcoding", "Allow transcoding\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1322 | { |
Philipp Maier | 4c4d227 | 2023-04-26 15:45:17 +0200 | [diff] [blame] | 1323 | vty_out(vty, "%% Deprecated 'allow-transcoding' config no longer has any effect%s", VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1324 | return CMD_SUCCESS; |
| 1325 | } |
| 1326 | |
Philipp Maier | 4c4d227 | 2023-04-26 15:45:17 +0200 | [diff] [blame] | 1327 | DEFUN_DEPRECATED(cfg_trunk_no_allow_transcoding, |
| 1328 | cfg_trunk_no_allow_transcoding_cmd, |
| 1329 | "no allow-transcoding", NO_STR "Allow transcoding\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1330 | { |
Philipp Maier | 4c4d227 | 2023-04-26 15:45:17 +0200 | [diff] [blame] | 1331 | vty_out(vty, "%% Deprecated 'no allow-transcoding' config no longer has any effect%s", VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1332 | return CMD_SUCCESS; |
| 1333 | } |
| 1334 | |
Philipp Maier | 889fe7f | 2020-07-06 17:44:12 +0200 | [diff] [blame] | 1335 | #define LINE_STR "Configure trunk for given Line\nE1/T1 Line Number\n" |
| 1336 | |
| 1337 | DEFUN(cfg_trunk_line, |
| 1338 | cfg_trunk_line_cmd, |
| 1339 | "line <0-255>", |
| 1340 | LINE_STR) |
| 1341 | { |
| 1342 | struct mgcp_trunk *trunk = vty->index; |
| 1343 | int line_nr = atoi(argv[0]); |
| 1344 | trunk->e1.vty_line_nr = line_nr; |
| 1345 | return CMD_SUCCESS; |
| 1346 | } |
| 1347 | |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1348 | DEFUN(loop_conn, |
| 1349 | loop_conn_cmd, |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1350 | "loop-endpoint <0-64> NAME (0|1)", |
| 1351 | "Loop a given endpoint\n" "Trunk number\n" |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1352 | "The name in hex of the endpoint\n" "Disable the loop\n" |
| 1353 | "Enable the loop\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1354 | { |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 1355 | struct mgcp_trunk *trunk; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1356 | struct mgcp_endpoint *endp; |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1357 | struct mgcp_conn *conn; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1358 | |
Philipp Maier | 6fbbeec | 2020-07-01 23:00:54 +0200 | [diff] [blame] | 1359 | trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_E1, atoi(argv[0])); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1360 | if (!trunk) { |
| 1361 | vty_out(vty, "%%Trunk %d not found in the config.%s", |
| 1362 | atoi(argv[0]), VTY_NEWLINE); |
| 1363 | return CMD_WARNING; |
| 1364 | } |
| 1365 | |
| 1366 | if (!trunk->endpoints) { |
Philipp Maier | d70eef6 | 2021-07-19 13:53:28 +0200 | [diff] [blame] | 1367 | vty_out(vty, "%%Trunk %u has no endpoints allocated.%s", |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1368 | trunk->trunk_nr, VTY_NEWLINE); |
| 1369 | return CMD_WARNING; |
| 1370 | } |
| 1371 | |
| 1372 | int endp_no = strtoul(argv[1], NULL, 16); |
| 1373 | if (endp_no < 1 || endp_no >= trunk->number_endpoints) { |
| 1374 | vty_out(vty, "Loopback number %s/%d is invalid.%s", |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1375 | argv[1], endp_no, VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1376 | return CMD_WARNING; |
| 1377 | } |
| 1378 | |
Philipp Maier | c66ab2c | 2020-06-02 20:55:34 +0200 | [diff] [blame] | 1379 | endp = trunk->endpoints[endp_no]; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1380 | int loop = atoi(argv[2]); |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1381 | llist_for_each_entry(conn, &endp->conns, entry) { |
| 1382 | if (conn->type == MGCP_CONN_TYPE_RTP) |
| 1383 | /* Handle it like a MDCX, switch on SSRC patching if enabled */ |
| 1384 | mgcp_rtp_end_config(endp, 1, &conn->u.rtp.end); |
| 1385 | else { |
| 1386 | /* FIXME: Introduce support for other connection (E1) |
| 1387 | * types when implementation is available */ |
| 1388 | vty_out(vty, "%%Can't enable SSRC patching," |
| 1389 | "connection %s is not an RTP connection.%s", |
| 1390 | mgcp_conn_dump(conn), VTY_NEWLINE); |
| 1391 | } |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1392 | |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1393 | if (loop) |
| 1394 | conn->mode = MGCP_CONN_LOOPBACK; |
| 1395 | else |
| 1396 | conn->mode = conn->mode_orig; |
| 1397 | } |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1398 | |
| 1399 | return CMD_SUCCESS; |
| 1400 | } |
| 1401 | |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1402 | DEFUN(tap_rtp, |
| 1403 | tap_rtp_cmd, |
Pau Espin Pedrol | a790f0c | 2020-08-31 13:29:11 +0200 | [diff] [blame] | 1404 | "tap-rtp <0-64> ENDPOINT CONN (in|out) " VTY_IPV46_CMD " <0-65534>", |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1405 | "Forward data on endpoint to a different system\n" "Trunk number\n" |
| 1406 | "The endpoint in hex\n" |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1407 | "The connection id in hex\n" |
| 1408 | "Forward incoming data\n" |
| 1409 | "Forward leaving data\n" |
Pau Espin Pedrol | a790f0c | 2020-08-31 13:29:11 +0200 | [diff] [blame] | 1410 | "Destination IPv4 of the data\n" |
| 1411 | "Destination IPv6 of the data\n" |
| 1412 | "Destination port\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1413 | { |
| 1414 | struct mgcp_rtp_tap *tap; |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 1415 | struct mgcp_trunk *trunk; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1416 | struct mgcp_endpoint *endp; |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1417 | struct mgcp_conn_rtp *conn; |
Philipp Maier | 01d24a3 | 2017-11-21 17:26:09 +0100 | [diff] [blame] | 1418 | const char *conn_id = NULL; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1419 | |
Philipp Maier | 6fbbeec | 2020-07-01 23:00:54 +0200 | [diff] [blame] | 1420 | trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_E1, atoi(argv[0])); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1421 | if (!trunk) { |
| 1422 | vty_out(vty, "%%Trunk %d not found in the config.%s", |
| 1423 | atoi(argv[0]), VTY_NEWLINE); |
| 1424 | return CMD_WARNING; |
| 1425 | } |
| 1426 | |
| 1427 | if (!trunk->endpoints) { |
Philipp Maier | d70eef6 | 2021-07-19 13:53:28 +0200 | [diff] [blame] | 1428 | vty_out(vty, "%%Trunk %u has no endpoints allocated.%s", |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1429 | trunk->trunk_nr, VTY_NEWLINE); |
| 1430 | return CMD_WARNING; |
| 1431 | } |
| 1432 | |
| 1433 | int endp_no = strtoul(argv[1], NULL, 16); |
| 1434 | if (endp_no < 1 || endp_no >= trunk->number_endpoints) { |
| 1435 | vty_out(vty, "Endpoint number %s/%d is invalid.%s", |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1436 | argv[1], endp_no, VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1437 | return CMD_WARNING; |
| 1438 | } |
| 1439 | |
Philipp Maier | c66ab2c | 2020-06-02 20:55:34 +0200 | [diff] [blame] | 1440 | endp = trunk->endpoints[endp_no]; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1441 | |
Philipp Maier | 01d24a3 | 2017-11-21 17:26:09 +0100 | [diff] [blame] | 1442 | conn_id = argv[2]; |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1443 | conn = mgcp_conn_get_rtp(endp, conn_id); |
| 1444 | if (!conn) { |
Philipp Maier | 01d24a3 | 2017-11-21 17:26:09 +0100 | [diff] [blame] | 1445 | vty_out(vty, "Conn ID %s is invalid.%s", |
| 1446 | conn_id, VTY_NEWLINE); |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1447 | return CMD_WARNING; |
| 1448 | } |
| 1449 | |
| 1450 | if (strcmp(argv[3], "in") == 0) |
| 1451 | tap = &conn->tap_in; |
| 1452 | else if (strcmp(argv[3], "out") == 0) |
| 1453 | tap = &conn->tap_out; |
| 1454 | else { |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1455 | vty_out(vty, "Unknown mode... tricked vty?%s", VTY_NEWLINE); |
| 1456 | return CMD_WARNING; |
| 1457 | } |
| 1458 | |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1459 | memset(&tap->forward, 0, sizeof(tap->forward)); |
Pau Espin Pedrol | a790f0c | 2020-08-31 13:29:11 +0200 | [diff] [blame] | 1460 | |
| 1461 | tap->forward.u.sa.sa_family = osmo_ip_str_type(argv[4]); |
| 1462 | switch (tap->forward.u.sa.sa_family) { |
| 1463 | case AF_INET: |
| 1464 | if (inet_pton(AF_INET, argv[4], &tap->forward.u.sin.sin_addr) != 1) |
| 1465 | return CMD_WARNING; |
| 1466 | tap->forward.u.sin.sin_port = htons(atoi(argv[5])); |
| 1467 | break; |
| 1468 | case AF_INET6: |
| 1469 | if (inet_pton(AF_INET6, argv[4], &tap->forward.u.sin6.sin6_addr) != 1) |
| 1470 | return CMD_WARNING; |
| 1471 | tap->forward.u.sin6.sin6_port = htons(atoi(argv[5])); |
| 1472 | break; |
| 1473 | default: |
| 1474 | return CMD_WARNING; |
| 1475 | } |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1476 | tap->enabled = 1; |
| 1477 | return CMD_SUCCESS; |
| 1478 | } |
| 1479 | |
| 1480 | DEFUN(free_endp, free_endp_cmd, |
| 1481 | "free-endpoint <0-64> NUMBER", |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1482 | "Free the given endpoint\n" "Trunk number\n" "Endpoint number in hex.\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1483 | { |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 1484 | struct mgcp_trunk *trunk; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1485 | struct mgcp_endpoint *endp; |
| 1486 | |
Philipp Maier | 6fbbeec | 2020-07-01 23:00:54 +0200 | [diff] [blame] | 1487 | trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_E1, atoi(argv[0])); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1488 | if (!trunk) { |
| 1489 | vty_out(vty, "%%Trunk %d not found in the config.%s", |
| 1490 | atoi(argv[0]), VTY_NEWLINE); |
| 1491 | return CMD_WARNING; |
| 1492 | } |
| 1493 | |
| 1494 | if (!trunk->endpoints) { |
Philipp Maier | d70eef6 | 2021-07-19 13:53:28 +0200 | [diff] [blame] | 1495 | vty_out(vty, "%%Trunk %u has no endpoints allocated.%s", |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1496 | trunk->trunk_nr, VTY_NEWLINE); |
| 1497 | return CMD_WARNING; |
| 1498 | } |
| 1499 | |
| 1500 | int endp_no = strtoul(argv[1], NULL, 16); |
| 1501 | if (endp_no < 1 || endp_no >= trunk->number_endpoints) { |
| 1502 | vty_out(vty, "Endpoint number %s/%d is invalid.%s", |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1503 | argv[1], endp_no, VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1504 | return CMD_WARNING; |
| 1505 | } |
| 1506 | |
Philipp Maier | c66ab2c | 2020-06-02 20:55:34 +0200 | [diff] [blame] | 1507 | endp = trunk->endpoints[endp_no]; |
Philipp Maier | 1355d7e | 2018-02-01 14:30:06 +0100 | [diff] [blame] | 1508 | mgcp_endp_release(endp); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1509 | return CMD_SUCCESS; |
| 1510 | } |
| 1511 | |
| 1512 | DEFUN(reset_endp, reset_endp_cmd, |
| 1513 | "reset-endpoint <0-64> NUMBER", |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1514 | "Reset the given endpoint\n" "Trunk number\n" "Endpoint number in hex.\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1515 | { |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 1516 | struct mgcp_trunk *trunk; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1517 | struct mgcp_endpoint *endp; |
| 1518 | int endp_no, rc; |
| 1519 | |
Philipp Maier | 6fbbeec | 2020-07-01 23:00:54 +0200 | [diff] [blame] | 1520 | trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_E1, atoi(argv[0])); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1521 | if (!trunk) { |
| 1522 | vty_out(vty, "%%Trunk %d not found in the config.%s", |
| 1523 | atoi(argv[0]), VTY_NEWLINE); |
| 1524 | return CMD_WARNING; |
| 1525 | } |
| 1526 | |
| 1527 | if (!trunk->endpoints) { |
Philipp Maier | d70eef6 | 2021-07-19 13:53:28 +0200 | [diff] [blame] | 1528 | vty_out(vty, "%%Trunk %u has no endpoints allocated.%s", |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1529 | trunk->trunk_nr, VTY_NEWLINE); |
| 1530 | return CMD_WARNING; |
| 1531 | } |
| 1532 | |
| 1533 | endp_no = strtoul(argv[1], NULL, 16); |
| 1534 | if (endp_no < 1 || endp_no >= trunk->number_endpoints) { |
| 1535 | vty_out(vty, "Endpoint number %s/%d is invalid.%s", |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1536 | argv[1], endp_no, VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1537 | return CMD_WARNING; |
| 1538 | } |
| 1539 | |
Philipp Maier | c66ab2c | 2020-06-02 20:55:34 +0200 | [diff] [blame] | 1540 | endp = trunk->endpoints[endp_no]; |
| 1541 | rc = mgcp_send_reset_ep(endp); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1542 | if (rc < 0) { |
| 1543 | vty_out(vty, "Error %d sending reset.%s", rc, VTY_NEWLINE); |
| 1544 | return CMD_WARNING; |
| 1545 | } |
| 1546 | return CMD_SUCCESS; |
| 1547 | } |
| 1548 | |
| 1549 | DEFUN(reset_all_endp, reset_all_endp_cmd, |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1550 | "reset-all-endpoints", "Reset all endpoints\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1551 | { |
| 1552 | int rc; |
| 1553 | |
| 1554 | rc = mgcp_send_reset_all(g_cfg); |
| 1555 | if (rc < 0) { |
| 1556 | vty_out(vty, "Error %d during endpoint reset.%s", |
| 1557 | rc, VTY_NEWLINE); |
| 1558 | return CMD_WARNING; |
| 1559 | } |
| 1560 | return CMD_SUCCESS; |
| 1561 | } |
| 1562 | |
| 1563 | #define OSMUX_STR "RTP multiplexing\n" |
| 1564 | DEFUN(cfg_mgcp_osmux, |
| 1565 | cfg_mgcp_osmux_cmd, |
| 1566 | "osmux (on|off|only)", |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1567 | OSMUX_STR "Enable OSMUX\n" "Disable OSMUX\n" "Only use OSMUX\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1568 | { |
Philipp Maier | 6fbbeec | 2020-07-01 23:00:54 +0200 | [diff] [blame] | 1569 | struct mgcp_trunk *trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_VIRTUAL, MGCP_VIRT_TRUNK_ID); |
Philipp Maier | d19de2e | 2020-06-03 13:55:33 +0200 | [diff] [blame] | 1570 | OSMO_ASSERT(trunk); |
| 1571 | |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1572 | if (strcmp(argv[0], "off") == 0) { |
Pau Espin Pedrol | 36413c0 | 2022-10-12 17:58:17 +0200 | [diff] [blame] | 1573 | g_cfg->osmux.usage = OSMUX_USAGE_OFF; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1574 | return CMD_SUCCESS; |
Pau Espin Pedrol | b542b04 | 2019-04-23 13:09:32 +0200 | [diff] [blame] | 1575 | } else if (strcmp(argv[0], "on") == 0) |
Pau Espin Pedrol | 36413c0 | 2022-10-12 17:58:17 +0200 | [diff] [blame] | 1576 | g_cfg->osmux.usage = OSMUX_USAGE_ON; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1577 | else if (strcmp(argv[0], "only") == 0) |
Pau Espin Pedrol | 36413c0 | 2022-10-12 17:58:17 +0200 | [diff] [blame] | 1578 | g_cfg->osmux.usage = OSMUX_USAGE_ONLY; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1579 | |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1580 | return CMD_SUCCESS; |
Pau Espin Pedrol | b542b04 | 2019-04-23 13:09:32 +0200 | [diff] [blame] | 1581 | |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1582 | } |
| 1583 | |
| 1584 | DEFUN(cfg_mgcp_osmux_ip, |
| 1585 | cfg_mgcp_osmux_ip_cmd, |
Pau Espin Pedrol | 70c03f5 | 2022-10-04 16:49:41 +0200 | [diff] [blame] | 1586 | "osmux bind-ip " VTY_IPV4_CMD, |
Pau Espin Pedrol | a790f0c | 2020-08-31 13:29:11 +0200 | [diff] [blame] | 1587 | OSMUX_STR IP_STR |
Pau Espin Pedrol | 70c03f5 | 2022-10-04 16:49:41 +0200 | [diff] [blame] | 1588 | "IPv4 Address to bind to\n") |
| 1589 | { |
Pau Espin Pedrol | 36413c0 | 2022-10-12 17:58:17 +0200 | [diff] [blame] | 1590 | osmo_talloc_replace_string(g_cfg, &g_cfg->osmux.local_addr_v4, argv[0]); |
Pau Espin Pedrol | 70c03f5 | 2022-10-04 16:49:41 +0200 | [diff] [blame] | 1591 | return CMD_SUCCESS; |
| 1592 | } |
| 1593 | |
| 1594 | DEFUN(cfg_mgcp_osmux_ip_v6, |
| 1595 | cfg_mgcp_osmux_ip_v6_cmd, |
| 1596 | "osmux bind-ip-v6 " VTY_IPV6_CMD, |
| 1597 | OSMUX_STR IP_STR |
Pau Espin Pedrol | a790f0c | 2020-08-31 13:29:11 +0200 | [diff] [blame] | 1598 | "IPv6 Address to bind to\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1599 | { |
Pau Espin Pedrol | 36413c0 | 2022-10-12 17:58:17 +0200 | [diff] [blame] | 1600 | osmo_talloc_replace_string(g_cfg, &g_cfg->osmux.local_addr_v6, argv[0]); |
| 1601 | return CMD_SUCCESS; |
| 1602 | } |
| 1603 | |
| 1604 | DEFUN(cfg_mgcp_osmux_port, |
| 1605 | cfg_mgcp_osmux_port_cmd, |
| 1606 | "osmux port <1-65535>", OSMUX_STR "port\n" "UDP port\n") |
| 1607 | { |
| 1608 | g_cfg->osmux.local_port = atoi(argv[0]); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1609 | return CMD_SUCCESS; |
| 1610 | } |
| 1611 | |
| 1612 | DEFUN(cfg_mgcp_osmux_batch_factor, |
| 1613 | cfg_mgcp_osmux_batch_factor_cmd, |
| 1614 | "osmux batch-factor <1-8>", |
| 1615 | OSMUX_STR "Batching factor\n" "Number of messages in the batch\n") |
| 1616 | { |
Pau Espin Pedrol | 36413c0 | 2022-10-12 17:58:17 +0200 | [diff] [blame] | 1617 | g_cfg->osmux.batch_factor = atoi(argv[0]); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1618 | return CMD_SUCCESS; |
| 1619 | } |
| 1620 | |
| 1621 | DEFUN(cfg_mgcp_osmux_batch_size, |
| 1622 | cfg_mgcp_osmux_batch_size_cmd, |
| 1623 | "osmux batch-size <1-65535>", |
| 1624 | OSMUX_STR "batch size\n" "Batch size in bytes\n") |
| 1625 | { |
Pau Espin Pedrol | 36413c0 | 2022-10-12 17:58:17 +0200 | [diff] [blame] | 1626 | g_cfg->osmux.batch_size = atoi(argv[0]); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1627 | return CMD_SUCCESS; |
| 1628 | } |
| 1629 | |
| 1630 | DEFUN(cfg_mgcp_osmux_dummy, |
| 1631 | cfg_mgcp_osmux_dummy_cmd, |
| 1632 | "osmux dummy (on|off)", |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1633 | OSMUX_STR "Dummy padding\n" "Enable dummy padding\n" |
| 1634 | "Disable dummy padding\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1635 | { |
| 1636 | if (strcmp(argv[0], "on") == 0) |
Pau Espin Pedrol | 36413c0 | 2022-10-12 17:58:17 +0200 | [diff] [blame] | 1637 | g_cfg->osmux.dummy_padding = true; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1638 | else if (strcmp(argv[0], "off") == 0) |
Pau Espin Pedrol | 36413c0 | 2022-10-12 17:58:17 +0200 | [diff] [blame] | 1639 | g_cfg->osmux.dummy_padding = false; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1640 | |
| 1641 | return CMD_SUCCESS; |
| 1642 | } |
| 1643 | |
Pau Espin Pedrol | 833281d | 2022-10-06 17:41:22 +0200 | [diff] [blame] | 1644 | DEFUN(cfg_mgcp_osmux_peer_behind_nat, |
| 1645 | cfg_mgcp_osmux_peer_behind_nat_cmd, |
| 1646 | "osmux peer-behind-nat (on|off)", |
| 1647 | OSMUX_STR "Define whether peer is behind NAT\n" |
| 1648 | "Peer is behind NAT\n" |
| 1649 | "Peer is NOT behind NAT\n") |
| 1650 | { |
| 1651 | if (strcmp(argv[0], "on") == 0) |
Pau Espin Pedrol | 36413c0 | 2022-10-12 17:58:17 +0200 | [diff] [blame] | 1652 | g_cfg->osmux.peer_behind_nat = true; |
Pau Espin Pedrol | 833281d | 2022-10-06 17:41:22 +0200 | [diff] [blame] | 1653 | else if (strcmp(argv[0], "off") == 0) |
Pau Espin Pedrol | 36413c0 | 2022-10-12 17:58:17 +0200 | [diff] [blame] | 1654 | g_cfg->osmux.peer_behind_nat = false; |
Pau Espin Pedrol | 833281d | 2022-10-06 17:41:22 +0200 | [diff] [blame] | 1655 | |
| 1656 | return CMD_SUCCESS; |
| 1657 | } |
| 1658 | |
Philipp Maier | 12943ea | 2018-01-17 15:40:25 +0100 | [diff] [blame] | 1659 | DEFUN(cfg_mgcp_domain, |
| 1660 | cfg_mgcp_domain_cmd, |
Neels Hofmeyr | 352eed0 | 2018-08-20 23:59:32 +0200 | [diff] [blame] | 1661 | "domain NAME", |
| 1662 | "Set the domain part expected in MGCP messages' endpoint names\n" |
| 1663 | "Qualified domain name expected in MGCP endpoint names, or '*' to accept any domain\n") |
Philipp Maier | 12943ea | 2018-01-17 15:40:25 +0100 | [diff] [blame] | 1664 | { |
| 1665 | osmo_strlcpy(g_cfg->domain, argv[0], sizeof(g_cfg->domain)); |
| 1666 | return CMD_SUCCESS; |
| 1667 | } |
| 1668 | |
Oliver Smith | e36b775 | 2019-01-22 16:31:36 +0100 | [diff] [blame] | 1669 | DEFUN(cfg_mgcp_conn_timeout, |
| 1670 | cfg_mgcp_conn_timeout_cmd, |
Oliver Smith | d2ce444 | 2019-06-26 09:56:44 +0200 | [diff] [blame] | 1671 | "conn-timeout <0-65534>", |
| 1672 | "Set a time after which inactive connections (CIs) are closed. Set to 0 to disable timeout. This can be used to" |
| 1673 | " work around interoperability problems causing connections to stay open forever, and slowly exhausting all" |
Oliver Smith | 189f29e | 2019-06-26 12:08:20 +0200 | [diff] [blame] | 1674 | " available ports. Enable keep-alive packets in MGW clients when using this option together with LCLS (OsmoBSC," |
| 1675 | " OsmoMSC: 'rtp keep-alive')!\n" |
Oliver Smith | e36b775 | 2019-01-22 16:31:36 +0100 | [diff] [blame] | 1676 | "Timeout value (sec.)\n") |
| 1677 | { |
| 1678 | g_cfg->conn_timeout = strtoul(argv[0], NULL, 10); |
| 1679 | return CMD_SUCCESS; |
| 1680 | } |
| 1681 | |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1682 | int mgcp_vty_init(void) |
| 1683 | { |
| 1684 | install_element_ve(&show_mgcp_cmd); |
Keith | fe53edd | 2021-05-04 15:23:30 -0500 | [diff] [blame] | 1685 | install_element_ve(&show_mgcp_active_cmd); |
Stefan Sperling | 1208658 | 2018-06-26 15:26:28 +0200 | [diff] [blame] | 1686 | install_element_ve(&show_mgcp_endpoint_cmd); |
| 1687 | install_element_ve(&show_mgcp_trunk_endpoint_cmd); |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1688 | install_element(ENABLE_NODE, &loop_conn_cmd); |
| 1689 | install_element(ENABLE_NODE, &tap_rtp_cmd); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1690 | install_element(ENABLE_NODE, &free_endp_cmd); |
| 1691 | install_element(ENABLE_NODE, &reset_endp_cmd); |
| 1692 | install_element(ENABLE_NODE, &reset_all_endp_cmd); |
| 1693 | |
| 1694 | install_element(CONFIG_NODE, &cfg_mgcp_cmd); |
| 1695 | install_node(&mgcp_node, config_write_mgcp); |
| 1696 | |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1697 | install_element(MGCP_NODE, &cfg_mgcp_local_ip_cmd); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1698 | install_element(MGCP_NODE, &cfg_mgcp_bind_ip_cmd); |
| 1699 | install_element(MGCP_NODE, &cfg_mgcp_bind_port_cmd); |
| 1700 | install_element(MGCP_NODE, &cfg_mgcp_bind_early_cmd); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1701 | install_element(MGCP_NODE, &cfg_mgcp_rtp_net_range_cmd); |
Philipp Maier | f1889d8 | 2017-11-08 14:59:39 +0100 | [diff] [blame] | 1702 | install_element(MGCP_NODE, &cfg_mgcp_rtp_port_range_cmd); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1703 | install_element(MGCP_NODE, &cfg_mgcp_rtp_net_bind_ip_cmd); |
Philipp Maier | f1889d8 | 2017-11-08 14:59:39 +0100 | [diff] [blame] | 1704 | install_element(MGCP_NODE, &cfg_mgcp_rtp_bind_ip_cmd); |
Pau Espin Pedrol | 8a2a1b2 | 2020-09-02 20:46:24 +0200 | [diff] [blame] | 1705 | install_element(MGCP_NODE, &cfg_mgcp_rtp_bind_ip_v6_cmd); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1706 | install_element(MGCP_NODE, &cfg_mgcp_rtp_no_net_bind_ip_cmd); |
Philipp Maier | f1889d8 | 2017-11-08 14:59:39 +0100 | [diff] [blame] | 1707 | install_element(MGCP_NODE, &cfg_mgcp_rtp_no_bind_ip_cmd); |
Pau Espin Pedrol | 8a2a1b2 | 2020-09-02 20:46:24 +0200 | [diff] [blame] | 1708 | install_element(MGCP_NODE, &cfg_mgcp_rtp_no_bind_ip_v6_cmd); |
Philipp Maier | 1cb1e38 | 2017-11-02 17:16:04 +0100 | [diff] [blame] | 1709 | install_element(MGCP_NODE, &cfg_mgcp_rtp_net_bind_ip_probing_cmd); |
| 1710 | install_element(MGCP_NODE, &cfg_mgcp_rtp_no_net_bind_ip_probing_cmd); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1711 | install_element(MGCP_NODE, &cfg_mgcp_rtp_ip_dscp_cmd); |
Harald Welte | 55a9229 | 2021-04-28 19:06:34 +0200 | [diff] [blame] | 1712 | install_element(MGCP_NODE, &cfg_mgcp_rtp_priority_cmd); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1713 | install_element(MGCP_NODE, &cfg_mgcp_rtp_force_ptime_cmd); |
| 1714 | install_element(MGCP_NODE, &cfg_mgcp_no_rtp_force_ptime_cmd); |
| 1715 | install_element(MGCP_NODE, &cfg_mgcp_rtp_keepalive_cmd); |
| 1716 | install_element(MGCP_NODE, &cfg_mgcp_rtp_keepalive_once_cmd); |
| 1717 | install_element(MGCP_NODE, &cfg_mgcp_no_rtp_keepalive_cmd); |
| 1718 | install_element(MGCP_NODE, &cfg_mgcp_agent_addr_cmd); |
| 1719 | install_element(MGCP_NODE, &cfg_mgcp_agent_addr_cmd_old); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1720 | install_element(MGCP_NODE, &cfg_mgcp_sdp_payload_number_cmd); |
| 1721 | install_element(MGCP_NODE, &cfg_mgcp_sdp_payload_name_cmd); |
| 1722 | install_element(MGCP_NODE, &cfg_mgcp_sdp_payload_number_cmd_old); |
| 1723 | install_element(MGCP_NODE, &cfg_mgcp_sdp_payload_name_cmd_old); |
| 1724 | install_element(MGCP_NODE, &cfg_mgcp_loop_cmd); |
| 1725 | install_element(MGCP_NODE, &cfg_mgcp_force_realloc_cmd); |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1726 | install_element(MGCP_NODE, &cfg_mgcp_rtp_accept_all_cmd); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1727 | install_element(MGCP_NODE, &cfg_mgcp_number_endp_cmd); |
| 1728 | install_element(MGCP_NODE, &cfg_mgcp_omit_rtcp_cmd); |
| 1729 | install_element(MGCP_NODE, &cfg_mgcp_no_omit_rtcp_cmd); |
| 1730 | install_element(MGCP_NODE, &cfg_mgcp_patch_rtp_ssrc_cmd); |
| 1731 | install_element(MGCP_NODE, &cfg_mgcp_no_patch_rtp_ssrc_cmd); |
| 1732 | install_element(MGCP_NODE, &cfg_mgcp_patch_rtp_ts_cmd); |
| 1733 | install_element(MGCP_NODE, &cfg_mgcp_no_patch_rtp_ts_cmd); |
| 1734 | install_element(MGCP_NODE, &cfg_mgcp_no_patch_rtp_cmd); |
Philipp Maier | 9fc8a02 | 2019-02-20 12:26:52 +0100 | [diff] [blame] | 1735 | install_element(MGCP_NODE, &cfg_mgcp_patch_rtp_rfc5993hr_cmd); |
| 1736 | install_element(MGCP_NODE, &cfg_mgcp_no_patch_rtp_rfc5993hr_cmd); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1737 | install_element(MGCP_NODE, &cfg_mgcp_sdp_fmtp_extra_cmd); |
| 1738 | install_element(MGCP_NODE, &cfg_mgcp_sdp_payload_send_ptime_cmd); |
| 1739 | install_element(MGCP_NODE, &cfg_mgcp_no_sdp_payload_send_ptime_cmd); |
| 1740 | install_element(MGCP_NODE, &cfg_mgcp_sdp_payload_send_name_cmd); |
| 1741 | install_element(MGCP_NODE, &cfg_mgcp_no_sdp_payload_send_name_cmd); |
| 1742 | install_element(MGCP_NODE, &cfg_mgcp_osmux_cmd); |
| 1743 | install_element(MGCP_NODE, &cfg_mgcp_osmux_ip_cmd); |
Pau Espin Pedrol | 70c03f5 | 2022-10-04 16:49:41 +0200 | [diff] [blame] | 1744 | install_element(MGCP_NODE, &cfg_mgcp_osmux_ip_v6_cmd); |
Pau Espin Pedrol | 36413c0 | 2022-10-12 17:58:17 +0200 | [diff] [blame] | 1745 | install_element(MGCP_NODE, &cfg_mgcp_osmux_port_cmd); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1746 | install_element(MGCP_NODE, &cfg_mgcp_osmux_batch_factor_cmd); |
| 1747 | install_element(MGCP_NODE, &cfg_mgcp_osmux_batch_size_cmd); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1748 | install_element(MGCP_NODE, &cfg_mgcp_osmux_dummy_cmd); |
Pau Espin Pedrol | 833281d | 2022-10-06 17:41:22 +0200 | [diff] [blame] | 1749 | install_element(MGCP_NODE, &cfg_mgcp_osmux_peer_behind_nat_cmd); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1750 | install_element(MGCP_NODE, &cfg_mgcp_allow_transcoding_cmd); |
| 1751 | install_element(MGCP_NODE, &cfg_mgcp_no_allow_transcoding_cmd); |
Philipp Maier | 12943ea | 2018-01-17 15:40:25 +0100 | [diff] [blame] | 1752 | install_element(MGCP_NODE, &cfg_mgcp_domain_cmd); |
Oliver Smith | e36b775 | 2019-01-22 16:31:36 +0100 | [diff] [blame] | 1753 | install_element(MGCP_NODE, &cfg_mgcp_conn_timeout_cmd); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1754 | |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1755 | install_element(MGCP_NODE, &cfg_mgcp_trunk_cmd); |
| 1756 | install_node(&trunk_node, config_write_trunk); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1757 | install_element(TRUNK_NODE, &cfg_trunk_rtp_keepalive_cmd); |
| 1758 | install_element(TRUNK_NODE, &cfg_trunk_rtp_keepalive_once_cmd); |
| 1759 | install_element(TRUNK_NODE, &cfg_trunk_no_rtp_keepalive_cmd); |
| 1760 | install_element(TRUNK_NODE, &cfg_trunk_payload_number_cmd); |
| 1761 | install_element(TRUNK_NODE, &cfg_trunk_payload_name_cmd); |
| 1762 | install_element(TRUNK_NODE, &cfg_trunk_payload_number_cmd_old); |
| 1763 | install_element(TRUNK_NODE, &cfg_trunk_payload_name_cmd_old); |
| 1764 | install_element(TRUNK_NODE, &cfg_trunk_loop_cmd); |
Philipp Maier | 41425e9 | 2020-11-26 00:41:59 +0100 | [diff] [blame] | 1765 | install_element(TRUNK_NODE, &cfg_trunk_force_realloc_cmd); |
| 1766 | install_element(TRUNK_NODE, &cfg_trunk_rtp_accept_all_cmd); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1767 | install_element(TRUNK_NODE, &cfg_trunk_omit_rtcp_cmd); |
| 1768 | install_element(TRUNK_NODE, &cfg_trunk_no_omit_rtcp_cmd); |
| 1769 | install_element(TRUNK_NODE, &cfg_trunk_patch_rtp_ssrc_cmd); |
| 1770 | install_element(TRUNK_NODE, &cfg_trunk_no_patch_rtp_ssrc_cmd); |
| 1771 | install_element(TRUNK_NODE, &cfg_trunk_patch_rtp_ts_cmd); |
Philipp Maier | 9fc8a02 | 2019-02-20 12:26:52 +0100 | [diff] [blame] | 1772 | install_element(TRUNK_NODE, &cfg_trunk_patch_rtp_rfc5993hr_cmd); |
| 1773 | install_element(TRUNK_NODE, &cfg_trunk_no_patch_rtp_rfc5993hr_cmd); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1774 | install_element(TRUNK_NODE, &cfg_trunk_no_patch_rtp_ts_cmd); |
| 1775 | install_element(TRUNK_NODE, &cfg_trunk_no_patch_rtp_cmd); |
| 1776 | install_element(TRUNK_NODE, &cfg_trunk_sdp_fmtp_extra_cmd); |
| 1777 | install_element(TRUNK_NODE, &cfg_trunk_sdp_payload_send_ptime_cmd); |
| 1778 | install_element(TRUNK_NODE, &cfg_trunk_no_sdp_payload_send_ptime_cmd); |
| 1779 | install_element(TRUNK_NODE, &cfg_trunk_sdp_payload_send_name_cmd); |
| 1780 | install_element(TRUNK_NODE, &cfg_trunk_no_sdp_payload_send_name_cmd); |
| 1781 | install_element(TRUNK_NODE, &cfg_trunk_allow_transcoding_cmd); |
| 1782 | install_element(TRUNK_NODE, &cfg_trunk_no_allow_transcoding_cmd); |
Philipp Maier | 889fe7f | 2020-07-06 17:44:12 +0200 | [diff] [blame] | 1783 | install_element(TRUNK_NODE, &cfg_trunk_line_cmd); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1784 | |
| 1785 | return 0; |
| 1786 | } |
| 1787 | |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1788 | int mgcp_parse_config(const char *config_file, struct mgcp_config *cfg, |
| 1789 | enum mgcp_role role) |
| 1790 | { |
| 1791 | int rc; |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 1792 | struct mgcp_trunk *trunk; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1793 | |
Pau Espin Pedrol | 36413c0 | 2022-10-12 17:58:17 +0200 | [diff] [blame] | 1794 | cfg->osmux.local_port = OSMUX_DEFAULT_PORT; |
| 1795 | cfg->osmux.batch_factor = 4; |
| 1796 | cfg->osmux.batch_size = OSMUX_BATCH_DEFAULT_MAX; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1797 | |
| 1798 | g_cfg = cfg; |
| 1799 | rc = vty_read_config_file(config_file, NULL); |
| 1800 | if (rc < 0) { |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1801 | fprintf(stderr, "Failed to parse the config file: '%s'\n", |
| 1802 | config_file); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1803 | return rc; |
| 1804 | } |
| 1805 | |
Eric | 2764bdb | 2021-08-23 22:11:47 +0200 | [diff] [blame] | 1806 | if (!strlen(g_cfg->source_addr)) { |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1807 | fprintf(stderr, "You need to specify a bind address.\n"); |
| 1808 | return -1; |
| 1809 | } |
| 1810 | |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1811 | llist_for_each_entry(trunk, &g_cfg->trunks, entry) { |
Philipp Maier | 889fe7f | 2020-07-06 17:44:12 +0200 | [diff] [blame] | 1812 | if (mgcp_trunk_equip(trunk) != 0) { |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1813 | LOGP(DLMGCP, LOGL_ERROR, |
Philipp Maier | d70eef6 | 2021-07-19 13:53:28 +0200 | [diff] [blame] | 1814 | "Failed to initialize trunk %u (%d endpoints)\n", |
Philipp Maier | 4845498 | 2017-11-10 16:46:41 +0100 | [diff] [blame] | 1815 | trunk->trunk_nr, trunk->number_endpoints); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1816 | return -1; |
| 1817 | } |
| 1818 | } |
| 1819 | cfg->role = role; |
| 1820 | |
| 1821 | return 0; |
| 1822 | } |