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> |
Stefan Sperling | 1e17487 | 2018-10-25 18:36:10 +0200 | [diff] [blame] | 25 | #include <osmocom/vty/misc.h> |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 26 | #include <osmocom/mgcp/mgcp.h> |
Neels Hofmeyr | 6779354 | 2017-09-08 04:25:16 +0200 | [diff] [blame] | 27 | #include <osmocom/mgcp/mgcp_common.h> |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 28 | #include <osmocom/mgcp/mgcp_internal.h> |
| 29 | #include <osmocom/mgcp/vty.h> |
| 30 | #include <osmocom/mgcp/mgcp_conn.h> |
Philipp Maier | 37d11c8 | 2018-02-01 14:38:12 +0100 | [diff] [blame] | 31 | #include <osmocom/mgcp/mgcp_endp.h> |
Philipp Maier | c66ab2c | 2020-06-02 20:55:34 +0200 | [diff] [blame] | 32 | #include <osmocom/mgcp/mgcp_trunk.h> |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 33 | |
| 34 | #include <string.h> |
Philipp Maier | bca0ef6 | 2018-07-09 17:20:51 +0200 | [diff] [blame] | 35 | #include <inttypes.h> |
Stefan Sperling | 1208658 | 2018-06-26 15:26:28 +0200 | [diff] [blame] | 36 | #include <limits.h> |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 37 | |
| 38 | #define RTCP_OMIT_STR "Drop RTCP packets in both directions\n" |
| 39 | #define RTP_PATCH_STR "Modify RTP packet header in both directions\n" |
| 40 | #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] | 41 | #define RTP_TS101318_RFC5993_CONV_STR "Convert GSM-HR from TS101318 to RFC5993 and vice versa\n" |
| 42 | |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 43 | |
| 44 | static struct mgcp_config *g_cfg = NULL; |
| 45 | |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 46 | static struct mgcp_trunk *find_trunk(struct mgcp_config *cfg, int nr) |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 47 | { |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 48 | struct mgcp_trunk *trunk; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 49 | |
| 50 | if (nr == 0) |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 51 | trunk = cfg->virt_trunk; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 52 | else |
Philipp Maier | c66ab2c | 2020-06-02 20:55:34 +0200 | [diff] [blame] | 53 | trunk = mgcp_trunk_by_num(cfg, nr); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 54 | |
| 55 | return trunk; |
| 56 | } |
| 57 | |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 58 | struct cmd_node mgcp_node = { |
| 59 | MGCP_NODE, |
| 60 | "%s(config-mgcp)# ", |
| 61 | 1, |
| 62 | }; |
| 63 | |
| 64 | struct cmd_node trunk_node = { |
| 65 | TRUNK_NODE, |
| 66 | "%s(config-mgcp-trunk)# ", |
| 67 | 1, |
| 68 | }; |
| 69 | |
| 70 | static int config_write_mgcp(struct vty *vty) |
| 71 | { |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 72 | struct mgcp_trunk *trunk = g_cfg->virt_trunk; |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 73 | |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 74 | vty_out(vty, "mgcp%s", VTY_NEWLINE); |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 75 | vty_out(vty, " domain %s%s", g_cfg->domain, VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 76 | if (g_cfg->local_ip) |
| 77 | 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] | 78 | vty_out(vty, " bind ip %s%s", g_cfg->source_addr, VTY_NEWLINE); |
| 79 | vty_out(vty, " bind port %u%s", g_cfg->source_port, VTY_NEWLINE); |
| 80 | vty_out(vty, " rtp port-range %u %u%s", |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 81 | g_cfg->net_ports.range_start, g_cfg->net_ports.range_end, |
| 82 | VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 83 | if (g_cfg->net_ports.bind_addr) |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 84 | vty_out(vty, " rtp bind-ip %s%s", |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 85 | g_cfg->net_ports.bind_addr, VTY_NEWLINE); |
Philipp Maier | 1cb1e38 | 2017-11-02 17:16:04 +0100 | [diff] [blame] | 86 | if (g_cfg->net_ports.bind_addr_probe) |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 87 | vty_out(vty, " rtp ip-probing%s", VTY_NEWLINE); |
Philipp Maier | 1cb1e38 | 2017-11-02 17:16:04 +0100 | [diff] [blame] | 88 | else |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 89 | vty_out(vty, " no rtp ip-probing%s", VTY_NEWLINE); |
| 90 | vty_out(vty, " rtp ip-dscp %d%s", g_cfg->endp_dscp, VTY_NEWLINE); |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 91 | if (trunk->keepalive_interval == MGCP_KEEPALIVE_ONCE) |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 92 | vty_out(vty, " rtp keep-alive once%s", VTY_NEWLINE); |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 93 | else if (trunk->keepalive_interval) |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 94 | vty_out(vty, " rtp keep-alive %d%s", |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 95 | trunk->keepalive_interval, VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 96 | else |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 97 | vty_out(vty, " no rtp keep-alive%s", VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 98 | |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 99 | if (trunk->omit_rtcp) |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 100 | vty_out(vty, " rtcp-omit%s", VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 101 | else |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 102 | vty_out(vty, " no rtcp-omit%s", VTY_NEWLINE); |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 103 | if (trunk->force_constant_ssrc |
| 104 | || trunk->force_aligned_timing |
| 105 | || trunk->rfc5993_hr_convert) { |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 106 | vty_out(vty, " %srtp-patch ssrc%s", |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 107 | trunk->force_constant_ssrc ? "" : "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 timestamp%s", |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 110 | trunk->force_aligned_timing ? "" : "no ", |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 111 | VTY_NEWLINE); |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 112 | vty_out(vty, " %srtp-patch rfc5993hr%s", |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 113 | trunk->rfc5993_hr_convert ? "" : "no ", |
Philipp Maier | 9fc8a02 | 2019-02-20 12:26:52 +0100 | [diff] [blame] | 114 | VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 115 | } else |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 116 | vty_out(vty, " no rtp-patch%s", VTY_NEWLINE); |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 117 | if (trunk->audio_fmtp_extra) |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 118 | vty_out(vty, " sdp audio fmtp-extra %s%s", |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 119 | trunk->audio_fmtp_extra, VTY_NEWLINE); |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 120 | vty_out(vty, " %ssdp audio-payload send-ptime%s", |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 121 | trunk->audio_send_ptime ? "" : "no ", VTY_NEWLINE); |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 122 | vty_out(vty, " %ssdp audio-payload send-name%s", |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 123 | trunk->audio_send_name ? "" : "no ", VTY_NEWLINE); |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 124 | vty_out(vty, " loop %u%s", ! !trunk->audio_loop, VTY_NEWLINE); |
| 125 | vty_out(vty, " number endpoints %u%s", |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 126 | trunk->vty_number_endpoints - 1, VTY_NEWLINE); |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 127 | vty_out(vty, " %sallow-transcoding%s", |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 128 | trunk->no_audio_transcoding ? "no " : "", VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 129 | if (g_cfg->call_agent_addr) |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 130 | 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] | 131 | VTY_NEWLINE); |
| 132 | if (g_cfg->force_ptime > 0) |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 133 | vty_out(vty, " rtp force-ptime %d%s", g_cfg->force_ptime, |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 134 | VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 135 | |
| 136 | switch (g_cfg->osmux) { |
| 137 | case OSMUX_USAGE_ON: |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 138 | vty_out(vty, " osmux on%s", VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 139 | break; |
| 140 | case OSMUX_USAGE_ONLY: |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 141 | vty_out(vty, " osmux only%s", VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 142 | break; |
| 143 | case OSMUX_USAGE_OFF: |
| 144 | default: |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 145 | vty_out(vty, " osmux off%s", VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 146 | break; |
| 147 | } |
| 148 | if (g_cfg->osmux) { |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 149 | vty_out(vty, " osmux bind-ip %s%s", |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 150 | g_cfg->osmux_addr, VTY_NEWLINE); |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 151 | vty_out(vty, " osmux batch-factor %d%s", |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 152 | g_cfg->osmux_batch, VTY_NEWLINE); |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 153 | vty_out(vty, " osmux batch-size %u%s", |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 154 | g_cfg->osmux_batch_size, VTY_NEWLINE); |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 155 | vty_out(vty, " osmux port %u%s", |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 156 | g_cfg->osmux_port, VTY_NEWLINE); |
Philipp Maier | f53796c | 2020-06-02 20:38:28 +0200 | [diff] [blame] | 157 | vty_out(vty, " osmux dummy %s%s", |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 158 | g_cfg->osmux_dummy ? "on" : "off", VTY_NEWLINE); |
| 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 | |
Stefan Sperling | b7974e2 | 2018-10-29 13:22:00 +0100 | [diff] [blame] | 176 | tx_packets = &conn->rate_ctr_group->ctr[RTP_PACKETS_TX_CTR]; |
| 177 | tx_bytes = &conn->rate_ctr_group->ctr[RTP_OCTETS_TX_CTR]; |
| 178 | rx_packets = &conn->rate_ctr_group->ctr[RTP_PACKETS_RX_CTR]; |
| 179 | rx_bytes = &conn->rate_ctr_group->ctr[RTP_OCTETS_RX_CTR]; |
Philipp Maier | cede2a4 | 2018-07-03 14:14:21 +0200 | [diff] [blame] | 180 | dropped_packets = &conn->rate_ctr_group->ctr[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, |
| 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); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 204 | } |
| 205 | |
Philipp Maier | c66ab2c | 2020-06-02 20:55:34 +0200 | [diff] [blame] | 206 | static void dump_endpoint(struct vty *vty, struct mgcp_endpoint *endp, |
Stefan Sperling | 1208658 | 2018-06-26 15:26:28 +0200 | [diff] [blame] | 207 | int trunk_nr, enum mgcp_trunk_type trunk_type, int show_stats) |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 208 | { |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 209 | struct mgcp_conn *conn; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 210 | |
Philipp Maier | c66ab2c | 2020-06-02 20:55:34 +0200 | [diff] [blame] | 211 | vty_out(vty, "%s trunk %d endpoint %s:%s", |
| 212 | trunk_type == MGCP_TRUNK_VIRTUAL ? "Virtual" : "E1", trunk_nr, endp->name, VTY_NEWLINE); |
Stefan Sperling | 1208658 | 2018-06-26 15:26:28 +0200 | [diff] [blame] | 213 | |
| 214 | if (llist_empty(&endp->conns)) { |
| 215 | vty_out(vty, " No active connections%s", VTY_NEWLINE); |
| 216 | return; |
| 217 | } |
| 218 | |
| 219 | llist_for_each_entry(conn, &endp->conns, entry) { |
| 220 | vty_out(vty, " CONN: %s%s", mgcp_conn_dump(conn), VTY_NEWLINE); |
| 221 | |
| 222 | if (show_stats) { |
Oliver Smith | e36b775 | 2019-01-22 16:31:36 +0100 | [diff] [blame] | 223 | if (endp->cfg->conn_timeout) { |
| 224 | struct timeval remaining; |
| 225 | osmo_timer_remaining(&conn->watchdog, NULL, &remaining); |
| 226 | vty_out(vty, " Currently remaining timeout (seconds): %d.%06d%s", |
| 227 | (int)remaining.tv_sec, (int)remaining.tv_usec, VTY_NEWLINE); |
| 228 | } |
| 229 | |
Stefan Sperling | 1208658 | 2018-06-26 15:26:28 +0200 | [diff] [blame] | 230 | /* FIXME: Also add verbosity for other |
| 231 | * connection types (E1) as soon as |
| 232 | * the implementation is available */ |
| 233 | if (conn->type == MGCP_CONN_TYPE_RTP) { |
| 234 | dump_rtp_end(vty, &conn->u.rtp); |
| 235 | } |
| 236 | } |
| 237 | } |
| 238 | } |
| 239 | |
Philipp Maier | c66ab2c | 2020-06-02 20:55:34 +0200 | [diff] [blame] | 240 | static void dump_ratectr_global(struct vty *vty, struct mgcp_ratectr_global *ratectr) |
| 241 | { |
| 242 | vty_out(vty, "%s", VTY_NEWLINE); |
| 243 | vty_out(vty, "Rate counters (global):%s", VTY_NEWLINE); |
| 244 | |
| 245 | if (ratectr->mgcp_general_ctr_group) { |
| 246 | vty_out(vty, " %s:%s", |
| 247 | ratectr->mgcp_general_ctr_group->desc-> |
| 248 | group_description, VTY_NEWLINE); |
| 249 | vty_out_rate_ctr_group_fmt(vty, |
| 250 | " %25n: %10c (%S/s %M/m %H/h %D/d) %d", |
| 251 | ratectr->mgcp_general_ctr_group); |
| 252 | } |
| 253 | } |
| 254 | |
| 255 | static void dump_ratectr_trunk(struct vty *vty, struct mgcp_ratectr_trunk *ratectr) |
| 256 | { |
| 257 | vty_out(vty, "%s", VTY_NEWLINE); |
| 258 | vty_out(vty, "Rate counters (trunk):%s", VTY_NEWLINE); |
| 259 | |
| 260 | if (ratectr->mgcp_crcx_ctr_group) { |
| 261 | vty_out(vty, " %s:%s", |
| 262 | ratectr->mgcp_crcx_ctr_group->desc->group_description, |
| 263 | VTY_NEWLINE); |
| 264 | vty_out_rate_ctr_group_fmt(vty, |
| 265 | " %25n: %10c (%S/s %M/m %H/h %D/d) %d", |
| 266 | ratectr->mgcp_crcx_ctr_group); |
| 267 | } |
| 268 | if (ratectr->mgcp_dlcx_ctr_group) { |
| 269 | vty_out(vty, " %s:%s", |
| 270 | ratectr->mgcp_dlcx_ctr_group->desc->group_description, |
| 271 | VTY_NEWLINE); |
| 272 | vty_out_rate_ctr_group_fmt(vty, |
| 273 | " %25n: %10c (%S/s %M/m %H/h %D/d) %d", |
| 274 | ratectr->mgcp_dlcx_ctr_group); |
| 275 | } |
| 276 | if (ratectr->mgcp_mdcx_ctr_group) { |
| 277 | vty_out(vty, " %s:%s", |
| 278 | ratectr->mgcp_mdcx_ctr_group->desc->group_description, |
| 279 | VTY_NEWLINE); |
| 280 | vty_out_rate_ctr_group_fmt(vty, |
| 281 | " %25n: %10c (%S/s %M/m %H/h %D/d) %d", |
| 282 | ratectr->mgcp_mdcx_ctr_group); |
| 283 | } |
| 284 | if (ratectr->all_rtp_conn_stats) { |
| 285 | vty_out(vty, " %s:%s", |
| 286 | ratectr->all_rtp_conn_stats->desc->group_description, |
| 287 | VTY_NEWLINE); |
| 288 | vty_out_rate_ctr_group_fmt(vty, |
| 289 | " %25n: %10c (%S/s %M/m %H/h %D/d) %d", |
| 290 | ratectr->all_rtp_conn_stats); |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | |
| 295 | static void dump_trunk(struct vty *vty, struct mgcp_trunk *trunk, int show_stats) |
Stefan Sperling | 1208658 | 2018-06-26 15:26:28 +0200 | [diff] [blame] | 296 | { |
| 297 | int i; |
| 298 | |
| 299 | vty_out(vty, "%s trunk %d with %d endpoints:%s", |
Philipp Maier | c66ab2c | 2020-06-02 20:55:34 +0200 | [diff] [blame] | 300 | trunk->trunk_type == MGCP_TRUNK_VIRTUAL ? "Virtual" : "E1", |
| 301 | trunk->trunk_nr, trunk->number_endpoints - 1, VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 302 | |
Philipp Maier | c66ab2c | 2020-06-02 20:55:34 +0200 | [diff] [blame] | 303 | if (!trunk->endpoints) { |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 304 | vty_out(vty, "No endpoints allocated yet.%s", VTY_NEWLINE); |
| 305 | return; |
| 306 | } |
| 307 | |
Philipp Maier | c66ab2c | 2020-06-02 20:55:34 +0200 | [diff] [blame] | 308 | for (i = 0; i < trunk->number_endpoints; ++i) { |
| 309 | struct mgcp_endpoint *endp = trunk->endpoints[i]; |
| 310 | dump_endpoint(vty, endp, trunk->trunk_nr, trunk->trunk_type, |
| 311 | show_stats); |
| 312 | if (i < trunk->number_endpoints - 1) |
Stefan Sperling | 1208658 | 2018-06-26 15:26:28 +0200 | [diff] [blame] | 313 | vty_out(vty, "%s", VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 314 | } |
Stefan Sperling | 1e17487 | 2018-10-25 18:36:10 +0200 | [diff] [blame] | 315 | |
Philipp Maier | c66ab2c | 2020-06-02 20:55:34 +0200 | [diff] [blame] | 316 | if (show_stats) |
| 317 | dump_ratectr_trunk(vty, &trunk->ratectr); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 318 | } |
| 319 | |
Stefan Sperling | 1208658 | 2018-06-26 15:26:28 +0200 | [diff] [blame] | 320 | #define SHOW_MGCP_STR "Display information about the MGCP Media Gateway\n" |
| 321 | |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 322 | DEFUN(show_mcgp, show_mgcp_cmd, |
| 323 | "show mgcp [stats]", |
| 324 | SHOW_STR |
Stefan Sperling | 1208658 | 2018-06-26 15:26:28 +0200 | [diff] [blame] | 325 | SHOW_MGCP_STR |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 326 | "Include Statistics\n") |
| 327 | { |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 328 | struct mgcp_trunk *trunk; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 329 | int show_stats = argc >= 1; |
| 330 | |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 331 | dump_trunk(vty, g_cfg->virt_trunk, show_stats); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 332 | |
| 333 | llist_for_each_entry(trunk, &g_cfg->trunks, entry) |
Philipp Maier | c66ab2c | 2020-06-02 20:55:34 +0200 | [diff] [blame] | 334 | dump_trunk(vty, trunk, show_stats); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 335 | |
| 336 | if (g_cfg->osmux) |
Pau Espin Pedrol | 8de58e7 | 2019-04-24 13:33:46 +0200 | [diff] [blame] | 337 | 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] | 338 | VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 339 | |
Philipp Maier | c66ab2c | 2020-06-02 20:55:34 +0200 | [diff] [blame] | 340 | if (show_stats) |
| 341 | dump_ratectr_global(vty, &g_cfg->ratectr); |
| 342 | |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 343 | return CMD_SUCCESS; |
| 344 | } |
| 345 | |
Stefan Sperling | 1208658 | 2018-06-26 15:26:28 +0200 | [diff] [blame] | 346 | static void |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 347 | 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] | 348 | { |
Philipp Maier | c66ab2c | 2020-06-02 20:55:34 +0200 | [diff] [blame] | 349 | struct mgcp_endpoint *endp; |
Stefan Sperling | 1208658 | 2018-06-26 15:26:28 +0200 | [diff] [blame] | 350 | |
Philipp Maier | c66ab2c | 2020-06-02 20:55:34 +0200 | [diff] [blame] | 351 | if (trunk) { |
| 352 | /* If a trunk is given, search on that specific trunk only */ |
| 353 | endp = mgcp_endp_by_name_trunk(NULL, epname, trunk); |
| 354 | if (!endp) { |
| 355 | vty_out(vty, "endpoint %s not configured on trunk %d%s", epname, trunk->trunk_nr, VTY_NEWLINE); |
| 356 | return; |
| 357 | } |
| 358 | } else { |
| 359 | /* If no trunk is given, search on all possible trunks */ |
| 360 | endp = mgcp_endp_by_name(NULL, epname, g_cfg); |
| 361 | if (!endp) { |
| 362 | vty_out(vty, "endpoint %s not configured%s", epname, VTY_NEWLINE); |
| 363 | return; |
Stefan Sperling | 1208658 | 2018-06-26 15:26:28 +0200 | [diff] [blame] | 364 | } |
| 365 | } |
Philipp Maier | c66ab2c | 2020-06-02 20:55:34 +0200 | [diff] [blame] | 366 | |
| 367 | trunk = endp->trunk; |
| 368 | dump_endpoint(vty, endp, trunk->trunk_nr, trunk->trunk_type, true); |
Stefan Sperling | 1208658 | 2018-06-26 15:26:28 +0200 | [diff] [blame] | 369 | } |
| 370 | |
| 371 | DEFUN(show_mcgp_endpoint, show_mgcp_endpoint_cmd, |
| 372 | "show mgcp endpoint NAME", |
| 373 | SHOW_STR |
| 374 | SHOW_MGCP_STR |
| 375 | "Display information about an endpoint\n" "The name of the endpoint\n") |
| 376 | { |
Philipp Maier | c66ab2c | 2020-06-02 20:55:34 +0200 | [diff] [blame] | 377 | dump_mgcp_endpoint(vty, NULL, argv[0]); |
Stefan Sperling | 1208658 | 2018-06-26 15:26:28 +0200 | [diff] [blame] | 378 | return CMD_SUCCESS; |
| 379 | } |
| 380 | |
| 381 | DEFUN(show_mcgp_trunk_endpoint, show_mgcp_trunk_endpoint_cmd, |
| 382 | "show mgcp trunk <0-64> endpoint NAME", |
| 383 | SHOW_STR |
| 384 | SHOW_MGCP_STR |
| 385 | "Display information about a trunk\n" "Trunk number\n" |
| 386 | "Display information about an endpoint\n" "The name of the endpoint\n") |
| 387 | { |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 388 | struct mgcp_trunk *trunk; |
Stefan Sperling | 1208658 | 2018-06-26 15:26:28 +0200 | [diff] [blame] | 389 | int trunkidx = atoi(argv[0]); |
| 390 | |
| 391 | trunk = find_trunk(g_cfg, trunkidx); |
| 392 | if (!trunk) { |
| 393 | vty_out(vty, "trunk %d not found%s", trunkidx, VTY_NEWLINE); |
| 394 | return CMD_WARNING; |
| 395 | } |
| 396 | |
| 397 | dump_mgcp_endpoint(vty, trunk, argv[1]); |
| 398 | return CMD_SUCCESS; |
| 399 | } |
| 400 | |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 401 | DEFUN(cfg_mgcp, cfg_mgcp_cmd, "mgcp", "Configure the MGCP") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 402 | { |
| 403 | vty->node = MGCP_NODE; |
| 404 | return CMD_SUCCESS; |
| 405 | } |
| 406 | |
| 407 | DEFUN(cfg_mgcp_local_ip, |
| 408 | cfg_mgcp_local_ip_cmd, |
| 409 | "local ip A.B.C.D", |
| 410 | "Local options for the SDP record\n" |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 411 | IP_STR "IPv4 Address to use in SDP record\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 412 | { |
| 413 | osmo_talloc_replace_string(g_cfg, &g_cfg->local_ip, argv[0]); |
| 414 | return CMD_SUCCESS; |
| 415 | } |
| 416 | |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 417 | #define BIND_STR "Listen/Bind related socket option\n" |
| 418 | DEFUN(cfg_mgcp_bind_ip, |
| 419 | cfg_mgcp_bind_ip_cmd, |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 420 | "bind ip A.B.C.D", BIND_STR IP_STR "IPv4 Address to bind to\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 421 | { |
| 422 | osmo_talloc_replace_string(g_cfg, &g_cfg->source_addr, argv[0]); |
| 423 | return CMD_SUCCESS; |
| 424 | } |
| 425 | |
| 426 | DEFUN(cfg_mgcp_bind_port, |
| 427 | cfg_mgcp_bind_port_cmd, |
| 428 | "bind port <0-65534>", |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 429 | 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] | 430 | { |
| 431 | unsigned int port = atoi(argv[0]); |
| 432 | g_cfg->source_port = port; |
| 433 | return CMD_SUCCESS; |
| 434 | } |
| 435 | |
| 436 | DEFUN(cfg_mgcp_bind_early, |
| 437 | cfg_mgcp_bind_early_cmd, |
| 438 | "bind early (0|1)", |
| 439 | BIND_STR |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 440 | "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] | 441 | { |
| 442 | vty_out(vty, "bind early is deprecated, remove it from the config.\n"); |
| 443 | return CMD_WARNING; |
| 444 | } |
| 445 | |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 446 | #define RTP_STR "RTP configuration\n" |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 447 | #define UDP_PORT_STR "UDP Port number\n" |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 448 | #define NET_START_STR "First UDP port allocated\n" |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 449 | #define RANGE_START_STR "Start of the range of ports\n" |
| 450 | #define RANGE_END_STR "End of the range of ports\n" |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 451 | |
Philipp Maier | f1889d8 | 2017-11-08 14:59:39 +0100 | [diff] [blame] | 452 | DEFUN(cfg_mgcp_rtp_port_range, |
| 453 | cfg_mgcp_rtp_port_range_cmd, |
Philipp Maier | a19547b | 2018-05-22 13:44:34 +0200 | [diff] [blame] | 454 | "rtp port-range <1024-65534> <1025-65535>", |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 455 | RTP_STR "Range of ports to use for the NET side\n" |
| 456 | RANGE_START_STR RANGE_END_STR) |
| 457 | { |
Philipp Maier | a19547b | 2018-05-22 13:44:34 +0200 | [diff] [blame] | 458 | int start; |
| 459 | int end; |
| 460 | |
| 461 | start = atoi(argv[0]); |
| 462 | end = atoi(argv[1]); |
| 463 | |
| 464 | if (end < start) { |
| 465 | vty_out(vty, "range end port (%i) must be greater than the range start port (%i)!%s", |
| 466 | end, start, VTY_NEWLINE); |
| 467 | return CMD_WARNING; |
| 468 | } |
| 469 | |
| 470 | if (start & 1) { |
| 471 | vty_out(vty, "range must begin at an even port number, autocorrecting port (%i) to: %i%s", |
| 472 | start, start & 0xFFFE, VTY_NEWLINE); |
| 473 | start &= 0xFFFE; |
| 474 | } |
| 475 | |
| 476 | if ((end & 1) == 0) { |
| 477 | vty_out(vty, "range must end at an odd port number, autocorrecting port (%i) to: %i%s", |
| 478 | end, end | 1, VTY_NEWLINE); |
| 479 | end |= 1; |
| 480 | } |
| 481 | |
| 482 | g_cfg->net_ports.range_start = start; |
| 483 | g_cfg->net_ports.range_end = end; |
| 484 | g_cfg->net_ports.last_port = g_cfg->net_ports.range_start; |
| 485 | |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 486 | return CMD_SUCCESS; |
| 487 | } |
Philipp Maier | f1889d8 | 2017-11-08 14:59:39 +0100 | [diff] [blame] | 488 | ALIAS_DEPRECATED(cfg_mgcp_rtp_port_range, |
| 489 | cfg_mgcp_rtp_net_range_cmd, |
| 490 | "rtp net-range <0-65534> <0-65534>", |
| 491 | RTP_STR "Range of ports to use for the NET side\n" |
| 492 | RANGE_START_STR RANGE_END_STR) |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 493 | |
Philipp Maier | f1889d8 | 2017-11-08 14:59:39 +0100 | [diff] [blame] | 494 | DEFUN(cfg_mgcp_rtp_bind_ip, |
| 495 | cfg_mgcp_rtp_bind_ip_cmd, |
| 496 | "rtp bind-ip A.B.C.D", |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 497 | RTP_STR "Bind endpoints facing the Network\n" "Address to bind to\n") |
| 498 | { |
| 499 | osmo_talloc_replace_string(g_cfg, &g_cfg->net_ports.bind_addr, argv[0]); |
| 500 | return CMD_SUCCESS; |
| 501 | } |
Philipp Maier | f1889d8 | 2017-11-08 14:59:39 +0100 | [diff] [blame] | 502 | ALIAS_DEPRECATED(cfg_mgcp_rtp_bind_ip, |
| 503 | cfg_mgcp_rtp_net_bind_ip_cmd, |
| 504 | "rtp net-bind-ip A.B.C.D", |
| 505 | 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] | 506 | |
Philipp Maier | f1889d8 | 2017-11-08 14:59:39 +0100 | [diff] [blame] | 507 | DEFUN(cfg_mgcp_rtp_no_bind_ip, |
| 508 | cfg_mgcp_rtp_no_bind_ip_cmd, |
| 509 | "no rtp bind-ip", |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 510 | NO_STR RTP_STR "Bind endpoints facing the Network\n" |
| 511 | "Address to bind to\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 512 | { |
| 513 | talloc_free(g_cfg->net_ports.bind_addr); |
| 514 | g_cfg->net_ports.bind_addr = NULL; |
| 515 | return CMD_SUCCESS; |
| 516 | } |
Philipp Maier | f1889d8 | 2017-11-08 14:59:39 +0100 | [diff] [blame] | 517 | ALIAS_DEPRECATED(cfg_mgcp_rtp_no_bind_ip, |
| 518 | cfg_mgcp_rtp_no_net_bind_ip_cmd, |
| 519 | "no rtp net-bind-ip", |
| 520 | NO_STR RTP_STR "Bind endpoints facing the Network\n" |
| 521 | "Address to bind to\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 522 | |
Philipp Maier | 1cb1e38 | 2017-11-02 17:16:04 +0100 | [diff] [blame] | 523 | DEFUN(cfg_mgcp_rtp_net_bind_ip_probing, |
| 524 | cfg_mgcp_rtp_net_bind_ip_probing_cmd, |
| 525 | "rtp ip-probing", |
| 526 | RTP_STR "automatic rtp bind ip selection\n") |
| 527 | { |
| 528 | g_cfg->net_ports.bind_addr_probe = true; |
| 529 | return CMD_SUCCESS; |
| 530 | } |
| 531 | |
| 532 | DEFUN(cfg_mgcp_rtp_no_net_bind_ip_probing, |
| 533 | cfg_mgcp_rtp_no_net_bind_ip_probing_cmd, |
| 534 | "no rtp ip-probing", |
| 535 | NO_STR RTP_STR "no automatic rtp bind ip selection\n") |
| 536 | { |
| 537 | g_cfg->net_ports.bind_addr_probe = false; |
| 538 | return CMD_SUCCESS; |
| 539 | } |
| 540 | |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 541 | DEFUN(cfg_mgcp_rtp_ip_dscp, |
| 542 | cfg_mgcp_rtp_ip_dscp_cmd, |
| 543 | "rtp ip-dscp <0-255>", |
| 544 | RTP_STR |
| 545 | "Apply IP_TOS to the audio stream (including Osmux)\n" "The DSCP value\n") |
| 546 | { |
| 547 | int dscp = atoi(argv[0]); |
| 548 | g_cfg->endp_dscp = dscp; |
| 549 | return CMD_SUCCESS; |
| 550 | } |
| 551 | |
| 552 | ALIAS_DEPRECATED(cfg_mgcp_rtp_ip_dscp, cfg_mgcp_rtp_ip_tos_cmd, |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 553 | "rtp ip-tos <0-255>", |
| 554 | RTP_STR |
| 555 | "Apply IP_TOS to the audio stream\n" "The DSCP value\n") |
| 556 | #define FORCE_PTIME_STR "Force a fixed ptime for packets sent" |
Philipp Maier | 21be42a | 2020-05-29 21:39:48 +0200 | [diff] [blame] | 557 | DEFUN(cfg_mgcp_rtp_force_ptime, |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 558 | cfg_mgcp_rtp_force_ptime_cmd, |
| 559 | "rtp force-ptime (10|20|40)", |
| 560 | RTP_STR FORCE_PTIME_STR |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 561 | "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] | 562 | { |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 563 | g_cfg->force_ptime = atoi(argv[0]); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 564 | return CMD_SUCCESS; |
| 565 | } |
| 566 | |
| 567 | DEFUN(cfg_mgcp_no_rtp_force_ptime, |
| 568 | cfg_mgcp_no_rtp_force_ptime_cmd, |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 569 | "no rtp force-ptime", NO_STR RTP_STR FORCE_PTIME_STR) |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 570 | { |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 571 | g_cfg->force_ptime = 0; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 572 | return CMD_SUCCESS; |
| 573 | } |
| 574 | |
| 575 | DEFUN(cfg_mgcp_sdp_fmtp_extra, |
| 576 | cfg_mgcp_sdp_fmtp_extra_cmd, |
| 577 | "sdp audio fmtp-extra .NAME", |
| 578 | "Add extra fmtp for the SDP file\n" "Audio\n" "Fmtp-extra\n" |
| 579 | "Extra Information\n") |
| 580 | { |
| 581 | char *txt = argv_concat(argv, argc, 0); |
| 582 | if (!txt) |
| 583 | return CMD_WARNING; |
| 584 | |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 585 | osmo_talloc_replace_string(g_cfg, &g_cfg->virt_trunk->audio_fmtp_extra, txt); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 586 | talloc_free(txt); |
| 587 | return CMD_SUCCESS; |
| 588 | } |
| 589 | |
| 590 | DEFUN(cfg_mgcp_allow_transcoding, |
| 591 | cfg_mgcp_allow_transcoding_cmd, |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 592 | "allow-transcoding", "Allow transcoding\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 593 | { |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 594 | g_cfg->virt_trunk->no_audio_transcoding = 0; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 595 | return CMD_SUCCESS; |
| 596 | } |
| 597 | |
| 598 | DEFUN(cfg_mgcp_no_allow_transcoding, |
| 599 | cfg_mgcp_no_allow_transcoding_cmd, |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 600 | "no allow-transcoding", NO_STR "Allow transcoding\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 601 | { |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 602 | g_cfg->virt_trunk->no_audio_transcoding = 1; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 603 | return CMD_SUCCESS; |
| 604 | } |
| 605 | |
| 606 | #define SDP_STR "SDP File related options\n" |
| 607 | #define AUDIO_STR "Audio payload options\n" |
Philipp Maier | 7f90ddb | 2020-06-02 21:52:53 +0200 | [diff] [blame] | 608 | DEFUN_DEPRECATED(cfg_mgcp_sdp_payload_number, |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 609 | cfg_mgcp_sdp_payload_number_cmd, |
| 610 | "sdp audio-payload number <0-255>", |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 611 | SDP_STR AUDIO_STR "Number\n" "Payload number\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 612 | { |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 613 | return CMD_SUCCESS; |
| 614 | } |
| 615 | |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 616 | ALIAS_DEPRECATED(cfg_mgcp_sdp_payload_number, |
| 617 | cfg_mgcp_sdp_payload_number_cmd_old, |
| 618 | "sdp audio payload number <0-255>", |
| 619 | SDP_STR AUDIO_STR AUDIO_STR "Number\n" "Payload number\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 620 | |
Philipp Maier | 7f90ddb | 2020-06-02 21:52:53 +0200 | [diff] [blame] | 621 | DEFUN_DEPRECATED(cfg_mgcp_sdp_payload_name, |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 622 | cfg_mgcp_sdp_payload_name_cmd, |
| 623 | "sdp audio-payload name NAME", |
| 624 | SDP_STR AUDIO_STR "Name\n" "Payload name\n") |
| 625 | { |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 626 | return CMD_SUCCESS; |
| 627 | } |
| 628 | |
| 629 | 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] | 630 | "sdp audio payload name NAME", |
| 631 | SDP_STR AUDIO_STR AUDIO_STR "Name\n" "Payload name\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 632 | |
Philipp Maier | 21be42a | 2020-05-29 21:39:48 +0200 | [diff] [blame] | 633 | DEFUN(cfg_mgcp_sdp_payload_send_ptime, |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 634 | cfg_mgcp_sdp_payload_send_ptime_cmd, |
| 635 | "sdp audio-payload send-ptime", |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 636 | SDP_STR AUDIO_STR "Send SDP ptime (packet duration) attribute\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 637 | { |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 638 | g_cfg->virt_trunk->audio_send_ptime = 1; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 639 | return CMD_SUCCESS; |
| 640 | } |
| 641 | |
| 642 | DEFUN(cfg_mgcp_no_sdp_payload_send_ptime, |
| 643 | cfg_mgcp_no_sdp_payload_send_ptime_cmd, |
| 644 | "no sdp audio-payload send-ptime", |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 645 | 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] | 646 | { |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 647 | g_cfg->virt_trunk->audio_send_ptime = 0; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 648 | return CMD_SUCCESS; |
| 649 | } |
| 650 | |
| 651 | DEFUN(cfg_mgcp_sdp_payload_send_name, |
| 652 | cfg_mgcp_sdp_payload_send_name_cmd, |
| 653 | "sdp audio-payload send-name", |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 654 | SDP_STR AUDIO_STR "Send SDP rtpmap with the audio name\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 655 | { |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 656 | g_cfg->virt_trunk->audio_send_name = 1; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 657 | return CMD_SUCCESS; |
| 658 | } |
| 659 | |
| 660 | DEFUN(cfg_mgcp_no_sdp_payload_send_name, |
| 661 | cfg_mgcp_no_sdp_payload_send_name_cmd, |
| 662 | "no sdp audio-payload send-name", |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 663 | 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] | 664 | { |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 665 | g_cfg->virt_trunk->audio_send_name = 0; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 666 | return CMD_SUCCESS; |
| 667 | } |
| 668 | |
| 669 | DEFUN(cfg_mgcp_loop, |
| 670 | cfg_mgcp_loop_cmd, |
| 671 | "loop (0|1)", |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 672 | "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] | 673 | { |
| 674 | if (g_cfg->osmux) { |
| 675 | vty_out(vty, "Cannot use `loop' with `osmux'.%s", VTY_NEWLINE); |
| 676 | return CMD_WARNING; |
| 677 | } |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 678 | g_cfg->virt_trunk->audio_loop = atoi(argv[0]); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 679 | return CMD_SUCCESS; |
| 680 | } |
| 681 | |
| 682 | DEFUN(cfg_mgcp_force_realloc, |
| 683 | cfg_mgcp_force_realloc_cmd, |
| 684 | "force-realloc (0|1)", |
| 685 | "Force endpoint reallocation when the endpoint is still seized\n" |
| 686 | "Don't force reallocation\n" "force reallocation\n") |
| 687 | { |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 688 | g_cfg->virt_trunk->force_realloc = atoi(argv[0]); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 689 | return CMD_SUCCESS; |
| 690 | } |
| 691 | |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 692 | DEFUN(cfg_mgcp_rtp_accept_all, |
| 693 | cfg_mgcp_rtp_accept_all_cmd, |
| 694 | "rtp-accept-all (0|1)", |
| 695 | "Accept all RTP packets, even when the originating IP/Port does not match\n" |
| 696 | "enable filter\n" "disable filter\n") |
| 697 | { |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 698 | g_cfg->virt_trunk->rtp_accept_all = atoi(argv[0]); |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 699 | return CMD_SUCCESS; |
| 700 | } |
| 701 | |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 702 | DEFUN(cfg_mgcp_number_endp, |
| 703 | cfg_mgcp_number_endp_cmd, |
| 704 | "number endpoints <0-65534>", |
| 705 | "Number options\n" "Endpoints available\n" "Number endpoints\n") |
| 706 | { |
| 707 | /* + 1 as we start counting at one */ |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 708 | g_cfg->virt_trunk->vty_number_endpoints = atoi(argv[0]) + 1; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 709 | return CMD_SUCCESS; |
| 710 | } |
| 711 | |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 712 | DEFUN(cfg_mgcp_omit_rtcp, cfg_mgcp_omit_rtcp_cmd, "rtcp-omit", RTCP_OMIT_STR) |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 713 | { |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 714 | g_cfg->virt_trunk->omit_rtcp = 1; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 715 | return CMD_SUCCESS; |
| 716 | } |
| 717 | |
| 718 | DEFUN(cfg_mgcp_no_omit_rtcp, |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 719 | cfg_mgcp_no_omit_rtcp_cmd, "no rtcp-omit", NO_STR RTCP_OMIT_STR) |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 720 | { |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 721 | g_cfg->virt_trunk->omit_rtcp = 0; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 722 | return CMD_SUCCESS; |
| 723 | } |
| 724 | |
| 725 | DEFUN(cfg_mgcp_patch_rtp_ssrc, |
| 726 | cfg_mgcp_patch_rtp_ssrc_cmd, |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 727 | "rtp-patch ssrc", RTP_PATCH_STR "Force a fixed SSRC\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 728 | { |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 729 | g_cfg->virt_trunk->force_constant_ssrc = 1; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 730 | return CMD_SUCCESS; |
| 731 | } |
| 732 | |
| 733 | DEFUN(cfg_mgcp_no_patch_rtp_ssrc, |
| 734 | cfg_mgcp_no_patch_rtp_ssrc_cmd, |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 735 | "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] | 736 | { |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 737 | g_cfg->virt_trunk->force_constant_ssrc = 0; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 738 | return CMD_SUCCESS; |
| 739 | } |
| 740 | |
| 741 | DEFUN(cfg_mgcp_patch_rtp_ts, |
| 742 | cfg_mgcp_patch_rtp_ts_cmd, |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 743 | "rtp-patch timestamp", RTP_PATCH_STR "Adjust RTP timestamp\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 744 | { |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 745 | g_cfg->virt_trunk->force_aligned_timing = 1; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 746 | return CMD_SUCCESS; |
| 747 | } |
| 748 | |
| 749 | DEFUN(cfg_mgcp_no_patch_rtp_ts, |
| 750 | cfg_mgcp_no_patch_rtp_ts_cmd, |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 751 | "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] | 752 | { |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 753 | g_cfg->virt_trunk->force_aligned_timing = 0; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 754 | return CMD_SUCCESS; |
| 755 | } |
| 756 | |
Philipp Maier | 9fc8a02 | 2019-02-20 12:26:52 +0100 | [diff] [blame] | 757 | DEFUN(cfg_mgcp_patch_rtp_rfc5993hr, |
| 758 | cfg_mgcp_patch_rtp_rfc5993hr_cmd, |
| 759 | "rtp-patch rfc5993hr", RTP_PATCH_STR RTP_TS101318_RFC5993_CONV_STR) |
| 760 | { |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 761 | g_cfg->virt_trunk->rfc5993_hr_convert = true; |
Philipp Maier | 9fc8a02 | 2019-02-20 12:26:52 +0100 | [diff] [blame] | 762 | return CMD_SUCCESS; |
| 763 | } |
| 764 | |
| 765 | DEFUN(cfg_mgcp_no_patch_rtp_rfc5993hr, |
| 766 | cfg_mgcp_no_patch_rtp_rfc5993hr_cmd, |
| 767 | "no rtp-patch rfc5993hr", NO_STR RTP_PATCH_STR RTP_TS101318_RFC5993_CONV_STR) |
| 768 | { |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 769 | g_cfg->virt_trunk->rfc5993_hr_convert = false; |
Philipp Maier | 9fc8a02 | 2019-02-20 12:26:52 +0100 | [diff] [blame] | 770 | return CMD_SUCCESS; |
| 771 | } |
| 772 | |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 773 | DEFUN(cfg_mgcp_no_patch_rtp, |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 774 | cfg_mgcp_no_patch_rtp_cmd, "no rtp-patch", NO_STR RTP_PATCH_STR) |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 775 | { |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 776 | g_cfg->virt_trunk->force_constant_ssrc = 0; |
| 777 | g_cfg->virt_trunk->force_aligned_timing = 0; |
| 778 | g_cfg->virt_trunk->rfc5993_hr_convert = false; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 779 | return CMD_SUCCESS; |
| 780 | } |
| 781 | |
| 782 | DEFUN(cfg_mgcp_rtp_keepalive, |
| 783 | cfg_mgcp_rtp_keepalive_cmd, |
| 784 | "rtp keep-alive <1-120>", |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 785 | RTP_STR RTP_KEEPALIVE_STR "Keep alive interval in secs\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 786 | { |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 787 | mgcp_trunk_set_keepalive(g_cfg->virt_trunk, atoi(argv[0])); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 788 | return CMD_SUCCESS; |
| 789 | } |
| 790 | |
| 791 | DEFUN(cfg_mgcp_rtp_keepalive_once, |
| 792 | cfg_mgcp_rtp_keepalive_once_cmd, |
| 793 | "rtp keep-alive once", |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 794 | RTP_STR RTP_KEEPALIVE_STR "Send dummy packet only once after CRCX/MDCX\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 795 | { |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 796 | mgcp_trunk_set_keepalive(g_cfg->virt_trunk, MGCP_KEEPALIVE_ONCE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 797 | return CMD_SUCCESS; |
| 798 | } |
| 799 | |
| 800 | DEFUN(cfg_mgcp_no_rtp_keepalive, |
| 801 | cfg_mgcp_no_rtp_keepalive_cmd, |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 802 | "no rtp keep-alive", NO_STR RTP_STR RTP_KEEPALIVE_STR) |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 803 | { |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 804 | mgcp_trunk_set_keepalive(g_cfg->virt_trunk, MGCP_KEEPALIVE_NEVER); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 805 | return CMD_SUCCESS; |
| 806 | } |
| 807 | |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 808 | #define CALL_AGENT_STR "Callagent information\n" |
| 809 | DEFUN(cfg_mgcp_agent_addr, |
| 810 | cfg_mgcp_agent_addr_cmd, |
| 811 | "call-agent ip A.B.C.D", |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 812 | CALL_AGENT_STR IP_STR "IPv4 Address of the callagent\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 813 | { |
| 814 | osmo_talloc_replace_string(g_cfg, &g_cfg->call_agent_addr, argv[0]); |
| 815 | return CMD_SUCCESS; |
| 816 | } |
| 817 | |
| 818 | ALIAS_DEPRECATED(cfg_mgcp_agent_addr, cfg_mgcp_agent_addr_cmd_old, |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 819 | "call agent ip A.B.C.D", |
| 820 | CALL_AGENT_STR CALL_AGENT_STR IP_STR |
| 821 | "IPv4 Address of the callagent\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 822 | |
Philipp Maier | 21be42a | 2020-05-29 21:39:48 +0200 | [diff] [blame] | 823 | DEFUN(cfg_mgcp_trunk, cfg_mgcp_trunk_cmd, |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 824 | "trunk <1-64>", "Configure a SS7 trunk\n" "Trunk Nr\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 825 | { |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 826 | struct mgcp_trunk *trunk; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 827 | int index = atoi(argv[0]); |
| 828 | |
Philipp Maier | c66ab2c | 2020-06-02 20:55:34 +0200 | [diff] [blame] | 829 | trunk = mgcp_trunk_by_num(g_cfg, index); |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 830 | if (!trunk) { |
| 831 | trunk = mgcp_trunk_alloc(g_cfg, MGCP_TRUNK_E1, index); |
Philipp Maier | 2d681fd | 2020-05-29 16:20:25 +0200 | [diff] [blame] | 832 | if (!trunk) { |
| 833 | vty_out(vty, "%%Unable to allocate trunk %u.%s", |
| 834 | index, VTY_NEWLINE); |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 835 | return CMD_WARNING; |
Philipp Maier | 2d681fd | 2020-05-29 16:20:25 +0200 | [diff] [blame] | 836 | } |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 837 | } |
| 838 | |
| 839 | vty->node = TRUNK_NODE; |
| 840 | vty->index = trunk; |
| 841 | return CMD_SUCCESS; |
| 842 | } |
| 843 | |
| 844 | static int config_write_trunk(struct vty *vty) |
| 845 | { |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 846 | struct mgcp_trunk *trunk; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 847 | |
| 848 | llist_for_each_entry(trunk, &g_cfg->trunks, entry) { |
| 849 | vty_out(vty, " trunk %d%s", trunk->trunk_nr, VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 850 | vty_out(vty, " %ssdp audio-payload send-ptime%s", |
| 851 | trunk->audio_send_ptime ? "" : "no ", VTY_NEWLINE); |
| 852 | vty_out(vty, " %ssdp audio-payload send-name%s", |
| 853 | trunk->audio_send_name ? "" : "no ", VTY_NEWLINE); |
| 854 | |
| 855 | if (trunk->keepalive_interval == MGCP_KEEPALIVE_ONCE) |
| 856 | vty_out(vty, " rtp keep-alive once%s", VTY_NEWLINE); |
| 857 | else if (trunk->keepalive_interval) |
| 858 | vty_out(vty, " rtp keep-alive %d%s", |
| 859 | trunk->keepalive_interval, VTY_NEWLINE); |
| 860 | else |
| 861 | vty_out(vty, " no rtp keep-alive%s", VTY_NEWLINE); |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 862 | vty_out(vty, " loop %d%s", trunk->audio_loop, VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 863 | vty_out(vty, " force-realloc %d%s", |
| 864 | trunk->force_realloc, VTY_NEWLINE); |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 865 | vty_out(vty, " rtp-accept-all %d%s", |
| 866 | trunk->rtp_accept_all, VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 867 | if (trunk->omit_rtcp) |
| 868 | vty_out(vty, " rtcp-omit%s", VTY_NEWLINE); |
| 869 | else |
| 870 | vty_out(vty, " no rtcp-omit%s", VTY_NEWLINE); |
Philipp Maier | 9fc8a02 | 2019-02-20 12:26:52 +0100 | [diff] [blame] | 871 | if (trunk->force_constant_ssrc || trunk->force_aligned_timing |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 872 | || g_cfg->virt_trunk->rfc5993_hr_convert) { |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 873 | vty_out(vty, " %srtp-patch ssrc%s", |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 874 | trunk->force_constant_ssrc ? "" : "no ", |
| 875 | VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 876 | vty_out(vty, " %srtp-patch timestamp%s", |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 877 | trunk->force_aligned_timing ? "" : "no ", |
| 878 | VTY_NEWLINE); |
Philipp Maier | 9fc8a02 | 2019-02-20 12:26:52 +0100 | [diff] [blame] | 879 | vty_out(vty, " %srtp-patch rfc5993hr%s", |
| 880 | trunk->rfc5993_hr_convert ? "" : "no ", |
| 881 | VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 882 | } else |
| 883 | vty_out(vty, " no rtp-patch%s", VTY_NEWLINE); |
| 884 | if (trunk->audio_fmtp_extra) |
| 885 | vty_out(vty, " sdp audio fmtp-extra %s%s", |
| 886 | trunk->audio_fmtp_extra, VTY_NEWLINE); |
| 887 | vty_out(vty, " %sallow-transcoding%s", |
| 888 | trunk->no_audio_transcoding ? "no " : "", VTY_NEWLINE); |
| 889 | } |
| 890 | |
| 891 | return CMD_SUCCESS; |
| 892 | } |
| 893 | |
| 894 | DEFUN(cfg_trunk_sdp_fmtp_extra, |
| 895 | cfg_trunk_sdp_fmtp_extra_cmd, |
| 896 | "sdp audio fmtp-extra .NAME", |
| 897 | "Add extra fmtp for the SDP file\n" "Audio\n" "Fmtp-extra\n" |
| 898 | "Extra Information\n") |
| 899 | { |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 900 | struct mgcp_trunk *trunk = vty->index; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 901 | char *txt = argv_concat(argv, argc, 0); |
| 902 | if (!txt) |
| 903 | return CMD_WARNING; |
| 904 | |
| 905 | osmo_talloc_replace_string(g_cfg, &trunk->audio_fmtp_extra, txt); |
| 906 | talloc_free(txt); |
| 907 | return CMD_SUCCESS; |
| 908 | } |
| 909 | |
Philipp Maier | 7f90ddb | 2020-06-02 21:52:53 +0200 | [diff] [blame] | 910 | DEFUN_DEPRECATED(cfg_trunk_payload_number, |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 911 | cfg_trunk_payload_number_cmd, |
| 912 | "sdp audio-payload number <0-255>", |
| 913 | SDP_STR AUDIO_STR "Number\n" "Payload Number\n") |
| 914 | { |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 915 | return CMD_SUCCESS; |
| 916 | } |
| 917 | |
| 918 | ALIAS_DEPRECATED(cfg_trunk_payload_number, cfg_trunk_payload_number_cmd_old, |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 919 | "sdp audio payload number <0-255>", |
| 920 | SDP_STR AUDIO_STR AUDIO_STR "Number\n" "Payload Number\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 921 | |
Philipp Maier | 7f90ddb | 2020-06-02 21:52:53 +0200 | [diff] [blame] | 922 | DEFUN_DEPRECATED(cfg_trunk_payload_name, |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 923 | cfg_trunk_payload_name_cmd, |
| 924 | "sdp audio-payload name NAME", |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 925 | SDP_STR AUDIO_STR "Payload\n" "Payload Name\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 926 | { |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 927 | return CMD_SUCCESS; |
| 928 | } |
| 929 | |
| 930 | ALIAS_DEPRECATED(cfg_trunk_payload_name, cfg_trunk_payload_name_cmd_old, |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 931 | "sdp audio payload name NAME", |
| 932 | SDP_STR AUDIO_STR AUDIO_STR "Payload\n" "Payload Name\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 933 | |
Philipp Maier | 21be42a | 2020-05-29 21:39:48 +0200 | [diff] [blame] | 934 | DEFUN(cfg_trunk_loop, |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 935 | cfg_trunk_loop_cmd, |
| 936 | "loop (0|1)", |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 937 | "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] | 938 | { |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 939 | struct mgcp_trunk *trunk = vty->index; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 940 | |
| 941 | if (g_cfg->osmux) { |
| 942 | vty_out(vty, "Cannot use `loop' with `osmux'.%s", VTY_NEWLINE); |
| 943 | return CMD_WARNING; |
| 944 | } |
| 945 | trunk->audio_loop = atoi(argv[0]); |
| 946 | return CMD_SUCCESS; |
| 947 | } |
| 948 | |
| 949 | DEFUN(cfg_trunk_sdp_payload_send_ptime, |
| 950 | cfg_trunk_sdp_payload_send_ptime_cmd, |
| 951 | "sdp audio-payload send-ptime", |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 952 | SDP_STR AUDIO_STR "Send SDP ptime (packet duration) attribute\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 953 | { |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 954 | struct mgcp_trunk *trunk = vty->index; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 955 | trunk->audio_send_ptime = 1; |
| 956 | return CMD_SUCCESS; |
| 957 | } |
| 958 | |
| 959 | DEFUN(cfg_trunk_no_sdp_payload_send_ptime, |
| 960 | cfg_trunk_no_sdp_payload_send_ptime_cmd, |
| 961 | "no sdp audio-payload send-ptime", |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 962 | 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] | 963 | { |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 964 | struct mgcp_trunk *trunk = vty->index; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 965 | trunk->audio_send_ptime = 0; |
| 966 | return CMD_SUCCESS; |
| 967 | } |
| 968 | |
| 969 | DEFUN(cfg_trunk_sdp_payload_send_name, |
| 970 | cfg_trunk_sdp_payload_send_name_cmd, |
| 971 | "sdp audio-payload send-name", |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 972 | SDP_STR AUDIO_STR "Send SDP rtpmap with the audio name\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 973 | { |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 974 | struct mgcp_trunk *trunk = vty->index; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 975 | trunk->audio_send_name = 1; |
| 976 | return CMD_SUCCESS; |
| 977 | } |
| 978 | |
| 979 | DEFUN(cfg_trunk_no_sdp_payload_send_name, |
| 980 | cfg_trunk_no_sdp_payload_send_name_cmd, |
| 981 | "no sdp audio-payload send-name", |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 982 | 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] | 983 | { |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 984 | struct mgcp_trunk *trunk = vty->index; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 985 | trunk->audio_send_name = 0; |
| 986 | return CMD_SUCCESS; |
| 987 | } |
| 988 | |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 989 | DEFUN(cfg_trunk_omit_rtcp, cfg_trunk_omit_rtcp_cmd, "rtcp-omit", RTCP_OMIT_STR) |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 990 | { |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 991 | struct mgcp_trunk *trunk = vty->index; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 992 | trunk->omit_rtcp = 1; |
| 993 | return CMD_SUCCESS; |
| 994 | } |
| 995 | |
| 996 | DEFUN(cfg_trunk_no_omit_rtcp, |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 997 | cfg_trunk_no_omit_rtcp_cmd, "no rtcp-omit", NO_STR RTCP_OMIT_STR) |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 998 | { |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 999 | struct mgcp_trunk *trunk = vty->index; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1000 | trunk->omit_rtcp = 0; |
| 1001 | return CMD_SUCCESS; |
| 1002 | } |
| 1003 | |
| 1004 | DEFUN(cfg_trunk_patch_rtp_ssrc, |
| 1005 | cfg_trunk_patch_rtp_ssrc_cmd, |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1006 | "rtp-patch ssrc", RTP_PATCH_STR "Force a fixed SSRC\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1007 | { |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 1008 | struct mgcp_trunk *trunk = vty->index; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1009 | trunk->force_constant_ssrc = 1; |
| 1010 | return CMD_SUCCESS; |
| 1011 | } |
| 1012 | |
| 1013 | DEFUN(cfg_trunk_no_patch_rtp_ssrc, |
| 1014 | cfg_trunk_no_patch_rtp_ssrc_cmd, |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1015 | "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] | 1016 | { |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 1017 | struct mgcp_trunk *trunk = vty->index; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1018 | trunk->force_constant_ssrc = 0; |
| 1019 | return CMD_SUCCESS; |
| 1020 | } |
| 1021 | |
| 1022 | DEFUN(cfg_trunk_patch_rtp_ts, |
| 1023 | cfg_trunk_patch_rtp_ts_cmd, |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1024 | "rtp-patch timestamp", RTP_PATCH_STR "Adjust RTP timestamp\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1025 | { |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 1026 | struct mgcp_trunk *trunk = vty->index; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1027 | trunk->force_aligned_timing = 1; |
| 1028 | return CMD_SUCCESS; |
| 1029 | } |
| 1030 | |
| 1031 | DEFUN(cfg_trunk_no_patch_rtp_ts, |
| 1032 | cfg_trunk_no_patch_rtp_ts_cmd, |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1033 | "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] | 1034 | { |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 1035 | struct mgcp_trunk *trunk = vty->index; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1036 | trunk->force_aligned_timing = 0; |
| 1037 | return CMD_SUCCESS; |
| 1038 | } |
| 1039 | |
Philipp Maier | 9fc8a02 | 2019-02-20 12:26:52 +0100 | [diff] [blame] | 1040 | DEFUN(cfg_trunk_patch_rtp_rfc5993hr, |
| 1041 | cfg_trunk_patch_rtp_rfc5993hr_cmd, |
| 1042 | "rtp-patch rfc5993hr", RTP_PATCH_STR RTP_TS101318_RFC5993_CONV_STR) |
| 1043 | { |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 1044 | struct mgcp_trunk *trunk = vty->index; |
Philipp Maier | 9fc8a02 | 2019-02-20 12:26:52 +0100 | [diff] [blame] | 1045 | trunk->rfc5993_hr_convert = true; |
| 1046 | return CMD_SUCCESS; |
| 1047 | } |
| 1048 | |
| 1049 | DEFUN(cfg_trunk_no_patch_rtp_rfc5993hr, |
| 1050 | cfg_trunk_no_patch_rtp_rfc5993hr_cmd, |
| 1051 | "no rtp-patch rfc5993hr", NO_STR RTP_PATCH_STR RTP_TS101318_RFC5993_CONV_STR) |
| 1052 | { |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 1053 | struct mgcp_trunk *trunk = vty->index; |
Philipp Maier | 9fc8a02 | 2019-02-20 12:26:52 +0100 | [diff] [blame] | 1054 | trunk->rfc5993_hr_convert = false; |
| 1055 | return CMD_SUCCESS; |
| 1056 | } |
| 1057 | |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1058 | DEFUN(cfg_trunk_no_patch_rtp, |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1059 | cfg_trunk_no_patch_rtp_cmd, "no rtp-patch", NO_STR RTP_PATCH_STR) |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1060 | { |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 1061 | struct mgcp_trunk *trunk = vty->index; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1062 | trunk->force_constant_ssrc = 0; |
| 1063 | trunk->force_aligned_timing = 0; |
Philipp Maier | 9fc8a02 | 2019-02-20 12:26:52 +0100 | [diff] [blame] | 1064 | trunk->rfc5993_hr_convert = false; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1065 | return CMD_SUCCESS; |
| 1066 | } |
| 1067 | |
| 1068 | DEFUN(cfg_trunk_rtp_keepalive, |
| 1069 | cfg_trunk_rtp_keepalive_cmd, |
| 1070 | "rtp keep-alive <1-120>", |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1071 | RTP_STR RTP_KEEPALIVE_STR "Keep-alive interval in secs\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1072 | { |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 1073 | struct mgcp_trunk *trunk = vty->index; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1074 | mgcp_trunk_set_keepalive(trunk, atoi(argv[0])); |
| 1075 | return CMD_SUCCESS; |
| 1076 | } |
| 1077 | |
| 1078 | DEFUN(cfg_trunk_rtp_keepalive_once, |
| 1079 | cfg_trunk_rtp_keepalive_once_cmd, |
| 1080 | "rtp keep-alive once", |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1081 | RTP_STR RTP_KEEPALIVE_STR "Send dummy packet only once after CRCX/MDCX\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1082 | { |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 1083 | struct mgcp_trunk *trunk = vty->index; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1084 | mgcp_trunk_set_keepalive(trunk, MGCP_KEEPALIVE_ONCE); |
| 1085 | return CMD_SUCCESS; |
| 1086 | } |
| 1087 | |
| 1088 | DEFUN(cfg_trunk_no_rtp_keepalive, |
| 1089 | cfg_trunk_no_rtp_keepalive_cmd, |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1090 | "no rtp keep-alive", NO_STR RTP_STR RTP_KEEPALIVE_STR) |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1091 | { |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 1092 | struct mgcp_trunk *trunk = vty->index; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1093 | mgcp_trunk_set_keepalive(trunk, 0); |
| 1094 | return CMD_SUCCESS; |
| 1095 | } |
| 1096 | |
| 1097 | DEFUN(cfg_trunk_allow_transcoding, |
| 1098 | cfg_trunk_allow_transcoding_cmd, |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1099 | "allow-transcoding", "Allow transcoding\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1100 | { |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 1101 | struct mgcp_trunk *trunk = vty->index; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1102 | trunk->no_audio_transcoding = 0; |
| 1103 | return CMD_SUCCESS; |
| 1104 | } |
| 1105 | |
| 1106 | DEFUN(cfg_trunk_no_allow_transcoding, |
| 1107 | cfg_trunk_no_allow_transcoding_cmd, |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1108 | "no allow-transcoding", NO_STR "Allow transcoding\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1109 | { |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 1110 | struct mgcp_trunk *trunk = vty->index; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1111 | trunk->no_audio_transcoding = 1; |
| 1112 | return CMD_SUCCESS; |
| 1113 | } |
| 1114 | |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1115 | DEFUN(loop_conn, |
| 1116 | loop_conn_cmd, |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1117 | "loop-endpoint <0-64> NAME (0|1)", |
| 1118 | "Loop a given endpoint\n" "Trunk number\n" |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1119 | "The name in hex of the endpoint\n" "Disable the loop\n" |
| 1120 | "Enable the loop\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1121 | { |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 1122 | struct mgcp_trunk *trunk; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1123 | struct mgcp_endpoint *endp; |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1124 | struct mgcp_conn *conn; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1125 | |
| 1126 | trunk = find_trunk(g_cfg, atoi(argv[0])); |
| 1127 | if (!trunk) { |
| 1128 | vty_out(vty, "%%Trunk %d not found in the config.%s", |
| 1129 | atoi(argv[0]), VTY_NEWLINE); |
| 1130 | return CMD_WARNING; |
| 1131 | } |
| 1132 | |
| 1133 | if (!trunk->endpoints) { |
| 1134 | vty_out(vty, "%%Trunk %d has no endpoints allocated.%s", |
| 1135 | trunk->trunk_nr, VTY_NEWLINE); |
| 1136 | return CMD_WARNING; |
| 1137 | } |
| 1138 | |
| 1139 | int endp_no = strtoul(argv[1], NULL, 16); |
| 1140 | if (endp_no < 1 || endp_no >= trunk->number_endpoints) { |
| 1141 | vty_out(vty, "Loopback number %s/%d is invalid.%s", |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1142 | argv[1], endp_no, VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1143 | return CMD_WARNING; |
| 1144 | } |
| 1145 | |
Philipp Maier | c66ab2c | 2020-06-02 20:55:34 +0200 | [diff] [blame] | 1146 | endp = trunk->endpoints[endp_no]; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1147 | int loop = atoi(argv[2]); |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1148 | llist_for_each_entry(conn, &endp->conns, entry) { |
| 1149 | if (conn->type == MGCP_CONN_TYPE_RTP) |
| 1150 | /* Handle it like a MDCX, switch on SSRC patching if enabled */ |
| 1151 | mgcp_rtp_end_config(endp, 1, &conn->u.rtp.end); |
| 1152 | else { |
| 1153 | /* FIXME: Introduce support for other connection (E1) |
| 1154 | * types when implementation is available */ |
| 1155 | vty_out(vty, "%%Can't enable SSRC patching," |
| 1156 | "connection %s is not an RTP connection.%s", |
| 1157 | mgcp_conn_dump(conn), VTY_NEWLINE); |
| 1158 | } |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1159 | |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1160 | if (loop) |
| 1161 | conn->mode = MGCP_CONN_LOOPBACK; |
| 1162 | else |
| 1163 | conn->mode = conn->mode_orig; |
| 1164 | } |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1165 | |
| 1166 | return CMD_SUCCESS; |
| 1167 | } |
| 1168 | |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1169 | DEFUN(tap_rtp, |
| 1170 | tap_rtp_cmd, |
| 1171 | "tap-rtp <0-64> ENDPOINT CONN (in|out) A.B.C.D <0-65534>", |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1172 | "Forward data on endpoint to a different system\n" "Trunk number\n" |
| 1173 | "The endpoint in hex\n" |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1174 | "The connection id in hex\n" |
| 1175 | "Forward incoming data\n" |
| 1176 | "Forward leaving data\n" |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1177 | "destination IP of the data\n" "destination port\n") |
| 1178 | { |
| 1179 | struct mgcp_rtp_tap *tap; |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 1180 | struct mgcp_trunk *trunk; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1181 | struct mgcp_endpoint *endp; |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1182 | struct mgcp_conn_rtp *conn; |
Philipp Maier | 01d24a3 | 2017-11-21 17:26:09 +0100 | [diff] [blame] | 1183 | const char *conn_id = NULL; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1184 | |
| 1185 | trunk = find_trunk(g_cfg, atoi(argv[0])); |
| 1186 | if (!trunk) { |
| 1187 | vty_out(vty, "%%Trunk %d not found in the config.%s", |
| 1188 | atoi(argv[0]), VTY_NEWLINE); |
| 1189 | return CMD_WARNING; |
| 1190 | } |
| 1191 | |
| 1192 | if (!trunk->endpoints) { |
| 1193 | vty_out(vty, "%%Trunk %d has no endpoints allocated.%s", |
| 1194 | trunk->trunk_nr, VTY_NEWLINE); |
| 1195 | return CMD_WARNING; |
| 1196 | } |
| 1197 | |
| 1198 | int endp_no = strtoul(argv[1], NULL, 16); |
| 1199 | if (endp_no < 1 || endp_no >= trunk->number_endpoints) { |
| 1200 | vty_out(vty, "Endpoint number %s/%d is invalid.%s", |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1201 | argv[1], endp_no, VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1202 | return CMD_WARNING; |
| 1203 | } |
| 1204 | |
Philipp Maier | c66ab2c | 2020-06-02 20:55:34 +0200 | [diff] [blame] | 1205 | endp = trunk->endpoints[endp_no]; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1206 | |
Philipp Maier | 01d24a3 | 2017-11-21 17:26:09 +0100 | [diff] [blame] | 1207 | conn_id = argv[2]; |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1208 | conn = mgcp_conn_get_rtp(endp, conn_id); |
| 1209 | if (!conn) { |
Philipp Maier | 01d24a3 | 2017-11-21 17:26:09 +0100 | [diff] [blame] | 1210 | vty_out(vty, "Conn ID %s is invalid.%s", |
| 1211 | conn_id, VTY_NEWLINE); |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1212 | return CMD_WARNING; |
| 1213 | } |
| 1214 | |
| 1215 | if (strcmp(argv[3], "in") == 0) |
| 1216 | tap = &conn->tap_in; |
| 1217 | else if (strcmp(argv[3], "out") == 0) |
| 1218 | tap = &conn->tap_out; |
| 1219 | else { |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1220 | vty_out(vty, "Unknown mode... tricked vty?%s", VTY_NEWLINE); |
| 1221 | return CMD_WARNING; |
| 1222 | } |
| 1223 | |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1224 | memset(&tap->forward, 0, sizeof(tap->forward)); |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1225 | inet_aton(argv[4], &tap->forward.sin_addr); |
| 1226 | tap->forward.sin_port = htons(atoi(argv[5])); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1227 | tap->enabled = 1; |
| 1228 | return CMD_SUCCESS; |
| 1229 | } |
| 1230 | |
| 1231 | DEFUN(free_endp, free_endp_cmd, |
| 1232 | "free-endpoint <0-64> NUMBER", |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1233 | "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] | 1234 | { |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 1235 | struct mgcp_trunk *trunk; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1236 | struct mgcp_endpoint *endp; |
| 1237 | |
| 1238 | trunk = find_trunk(g_cfg, atoi(argv[0])); |
| 1239 | if (!trunk) { |
| 1240 | vty_out(vty, "%%Trunk %d not found in the config.%s", |
| 1241 | atoi(argv[0]), VTY_NEWLINE); |
| 1242 | return CMD_WARNING; |
| 1243 | } |
| 1244 | |
| 1245 | if (!trunk->endpoints) { |
| 1246 | vty_out(vty, "%%Trunk %d has no endpoints allocated.%s", |
| 1247 | trunk->trunk_nr, VTY_NEWLINE); |
| 1248 | return CMD_WARNING; |
| 1249 | } |
| 1250 | |
| 1251 | int endp_no = strtoul(argv[1], NULL, 16); |
| 1252 | if (endp_no < 1 || endp_no >= trunk->number_endpoints) { |
| 1253 | vty_out(vty, "Endpoint number %s/%d is invalid.%s", |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1254 | argv[1], endp_no, VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1255 | return CMD_WARNING; |
| 1256 | } |
| 1257 | |
Philipp Maier | c66ab2c | 2020-06-02 20:55:34 +0200 | [diff] [blame] | 1258 | endp = trunk->endpoints[endp_no]; |
Philipp Maier | 1355d7e | 2018-02-01 14:30:06 +0100 | [diff] [blame] | 1259 | mgcp_endp_release(endp); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1260 | return CMD_SUCCESS; |
| 1261 | } |
| 1262 | |
| 1263 | DEFUN(reset_endp, reset_endp_cmd, |
| 1264 | "reset-endpoint <0-64> NUMBER", |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1265 | "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] | 1266 | { |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 1267 | struct mgcp_trunk *trunk; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1268 | struct mgcp_endpoint *endp; |
| 1269 | int endp_no, rc; |
| 1270 | |
| 1271 | trunk = find_trunk(g_cfg, atoi(argv[0])); |
| 1272 | if (!trunk) { |
| 1273 | vty_out(vty, "%%Trunk %d not found in the config.%s", |
| 1274 | atoi(argv[0]), VTY_NEWLINE); |
| 1275 | return CMD_WARNING; |
| 1276 | } |
| 1277 | |
| 1278 | if (!trunk->endpoints) { |
| 1279 | vty_out(vty, "%%Trunk %d has no endpoints allocated.%s", |
| 1280 | trunk->trunk_nr, VTY_NEWLINE); |
| 1281 | return CMD_WARNING; |
| 1282 | } |
| 1283 | |
| 1284 | endp_no = strtoul(argv[1], NULL, 16); |
| 1285 | if (endp_no < 1 || endp_no >= trunk->number_endpoints) { |
| 1286 | vty_out(vty, "Endpoint number %s/%d is invalid.%s", |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1287 | argv[1], endp_no, VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1288 | return CMD_WARNING; |
| 1289 | } |
| 1290 | |
Philipp Maier | c66ab2c | 2020-06-02 20:55:34 +0200 | [diff] [blame] | 1291 | endp = trunk->endpoints[endp_no]; |
| 1292 | rc = mgcp_send_reset_ep(endp); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1293 | if (rc < 0) { |
| 1294 | vty_out(vty, "Error %d sending reset.%s", rc, VTY_NEWLINE); |
| 1295 | return CMD_WARNING; |
| 1296 | } |
| 1297 | return CMD_SUCCESS; |
| 1298 | } |
| 1299 | |
| 1300 | DEFUN(reset_all_endp, reset_all_endp_cmd, |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1301 | "reset-all-endpoints", "Reset all endpoints\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1302 | { |
| 1303 | int rc; |
| 1304 | |
| 1305 | rc = mgcp_send_reset_all(g_cfg); |
| 1306 | if (rc < 0) { |
| 1307 | vty_out(vty, "Error %d during endpoint reset.%s", |
| 1308 | rc, VTY_NEWLINE); |
| 1309 | return CMD_WARNING; |
| 1310 | } |
| 1311 | return CMD_SUCCESS; |
| 1312 | } |
| 1313 | |
| 1314 | #define OSMUX_STR "RTP multiplexing\n" |
| 1315 | DEFUN(cfg_mgcp_osmux, |
| 1316 | cfg_mgcp_osmux_cmd, |
| 1317 | "osmux (on|off|only)", |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1318 | OSMUX_STR "Enable OSMUX\n" "Disable OSMUX\n" "Only use OSMUX\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1319 | { |
| 1320 | if (strcmp(argv[0], "off") == 0) { |
| 1321 | g_cfg->osmux = OSMUX_USAGE_OFF; |
| 1322 | return CMD_SUCCESS; |
Pau Espin Pedrol | b542b04 | 2019-04-23 13:09:32 +0200 | [diff] [blame] | 1323 | } else if (strcmp(argv[0], "on") == 0) |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1324 | g_cfg->osmux = OSMUX_USAGE_ON; |
| 1325 | else if (strcmp(argv[0], "only") == 0) |
| 1326 | g_cfg->osmux = OSMUX_USAGE_ONLY; |
| 1327 | |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 1328 | if (g_cfg->virt_trunk->audio_loop) { |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1329 | vty_out(vty, "Cannot use `loop' with `osmux'.%s", VTY_NEWLINE); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1330 | return CMD_WARNING; |
| 1331 | } |
| 1332 | |
| 1333 | return CMD_SUCCESS; |
Pau Espin Pedrol | b542b04 | 2019-04-23 13:09:32 +0200 | [diff] [blame] | 1334 | |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1335 | } |
| 1336 | |
| 1337 | DEFUN(cfg_mgcp_osmux_ip, |
| 1338 | cfg_mgcp_osmux_ip_cmd, |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1339 | "osmux bind-ip A.B.C.D", OSMUX_STR IP_STR "IPv4 Address to bind to\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1340 | { |
| 1341 | osmo_talloc_replace_string(g_cfg, &g_cfg->osmux_addr, argv[0]); |
| 1342 | return CMD_SUCCESS; |
| 1343 | } |
| 1344 | |
| 1345 | DEFUN(cfg_mgcp_osmux_batch_factor, |
| 1346 | cfg_mgcp_osmux_batch_factor_cmd, |
| 1347 | "osmux batch-factor <1-8>", |
| 1348 | OSMUX_STR "Batching factor\n" "Number of messages in the batch\n") |
| 1349 | { |
| 1350 | g_cfg->osmux_batch = atoi(argv[0]); |
| 1351 | return CMD_SUCCESS; |
| 1352 | } |
| 1353 | |
| 1354 | DEFUN(cfg_mgcp_osmux_batch_size, |
| 1355 | cfg_mgcp_osmux_batch_size_cmd, |
| 1356 | "osmux batch-size <1-65535>", |
| 1357 | OSMUX_STR "batch size\n" "Batch size in bytes\n") |
| 1358 | { |
| 1359 | g_cfg->osmux_batch_size = atoi(argv[0]); |
| 1360 | return CMD_SUCCESS; |
| 1361 | } |
| 1362 | |
| 1363 | DEFUN(cfg_mgcp_osmux_port, |
| 1364 | cfg_mgcp_osmux_port_cmd, |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1365 | "osmux port <1-65535>", OSMUX_STR "port\n" "UDP port\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1366 | { |
| 1367 | g_cfg->osmux_port = atoi(argv[0]); |
| 1368 | return CMD_SUCCESS; |
| 1369 | } |
| 1370 | |
| 1371 | DEFUN(cfg_mgcp_osmux_dummy, |
| 1372 | cfg_mgcp_osmux_dummy_cmd, |
| 1373 | "osmux dummy (on|off)", |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1374 | OSMUX_STR "Dummy padding\n" "Enable dummy padding\n" |
| 1375 | "Disable dummy padding\n") |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1376 | { |
| 1377 | if (strcmp(argv[0], "on") == 0) |
| 1378 | g_cfg->osmux_dummy = 1; |
| 1379 | else if (strcmp(argv[0], "off") == 0) |
| 1380 | g_cfg->osmux_dummy = 0; |
| 1381 | |
| 1382 | return CMD_SUCCESS; |
| 1383 | } |
| 1384 | |
Philipp Maier | 12943ea | 2018-01-17 15:40:25 +0100 | [diff] [blame] | 1385 | DEFUN(cfg_mgcp_domain, |
| 1386 | cfg_mgcp_domain_cmd, |
Neels Hofmeyr | 352eed0 | 2018-08-20 23:59:32 +0200 | [diff] [blame] | 1387 | "domain NAME", |
| 1388 | "Set the domain part expected in MGCP messages' endpoint names\n" |
| 1389 | "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] | 1390 | { |
| 1391 | osmo_strlcpy(g_cfg->domain, argv[0], sizeof(g_cfg->domain)); |
| 1392 | return CMD_SUCCESS; |
| 1393 | } |
| 1394 | |
Oliver Smith | e36b775 | 2019-01-22 16:31:36 +0100 | [diff] [blame] | 1395 | DEFUN(cfg_mgcp_conn_timeout, |
| 1396 | cfg_mgcp_conn_timeout_cmd, |
Oliver Smith | d2ce444 | 2019-06-26 09:56:44 +0200 | [diff] [blame] | 1397 | "conn-timeout <0-65534>", |
| 1398 | "Set a time after which inactive connections (CIs) are closed. Set to 0 to disable timeout. This can be used to" |
| 1399 | " 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] | 1400 | " available ports. Enable keep-alive packets in MGW clients when using this option together with LCLS (OsmoBSC," |
| 1401 | " OsmoMSC: 'rtp keep-alive')!\n" |
Oliver Smith | e36b775 | 2019-01-22 16:31:36 +0100 | [diff] [blame] | 1402 | "Timeout value (sec.)\n") |
| 1403 | { |
| 1404 | g_cfg->conn_timeout = strtoul(argv[0], NULL, 10); |
| 1405 | return CMD_SUCCESS; |
| 1406 | } |
| 1407 | |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1408 | int mgcp_vty_init(void) |
| 1409 | { |
| 1410 | install_element_ve(&show_mgcp_cmd); |
Stefan Sperling | 1208658 | 2018-06-26 15:26:28 +0200 | [diff] [blame] | 1411 | install_element_ve(&show_mgcp_endpoint_cmd); |
| 1412 | install_element_ve(&show_mgcp_trunk_endpoint_cmd); |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1413 | install_element(ENABLE_NODE, &loop_conn_cmd); |
| 1414 | install_element(ENABLE_NODE, &tap_rtp_cmd); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1415 | install_element(ENABLE_NODE, &free_endp_cmd); |
| 1416 | install_element(ENABLE_NODE, &reset_endp_cmd); |
| 1417 | install_element(ENABLE_NODE, &reset_all_endp_cmd); |
| 1418 | |
| 1419 | install_element(CONFIG_NODE, &cfg_mgcp_cmd); |
| 1420 | install_node(&mgcp_node, config_write_mgcp); |
| 1421 | |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1422 | install_element(MGCP_NODE, &cfg_mgcp_local_ip_cmd); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1423 | install_element(MGCP_NODE, &cfg_mgcp_bind_ip_cmd); |
| 1424 | install_element(MGCP_NODE, &cfg_mgcp_bind_port_cmd); |
| 1425 | install_element(MGCP_NODE, &cfg_mgcp_bind_early_cmd); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1426 | install_element(MGCP_NODE, &cfg_mgcp_rtp_net_range_cmd); |
Philipp Maier | f1889d8 | 2017-11-08 14:59:39 +0100 | [diff] [blame] | 1427 | install_element(MGCP_NODE, &cfg_mgcp_rtp_port_range_cmd); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1428 | install_element(MGCP_NODE, &cfg_mgcp_rtp_net_bind_ip_cmd); |
Philipp Maier | f1889d8 | 2017-11-08 14:59:39 +0100 | [diff] [blame] | 1429 | install_element(MGCP_NODE, &cfg_mgcp_rtp_bind_ip_cmd); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1430 | install_element(MGCP_NODE, &cfg_mgcp_rtp_no_net_bind_ip_cmd); |
Philipp Maier | f1889d8 | 2017-11-08 14:59:39 +0100 | [diff] [blame] | 1431 | install_element(MGCP_NODE, &cfg_mgcp_rtp_no_bind_ip_cmd); |
Philipp Maier | 1cb1e38 | 2017-11-02 17:16:04 +0100 | [diff] [blame] | 1432 | install_element(MGCP_NODE, &cfg_mgcp_rtp_net_bind_ip_probing_cmd); |
| 1433 | 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] | 1434 | install_element(MGCP_NODE, &cfg_mgcp_rtp_ip_dscp_cmd); |
| 1435 | install_element(MGCP_NODE, &cfg_mgcp_rtp_ip_tos_cmd); |
| 1436 | install_element(MGCP_NODE, &cfg_mgcp_rtp_force_ptime_cmd); |
| 1437 | install_element(MGCP_NODE, &cfg_mgcp_no_rtp_force_ptime_cmd); |
| 1438 | install_element(MGCP_NODE, &cfg_mgcp_rtp_keepalive_cmd); |
| 1439 | install_element(MGCP_NODE, &cfg_mgcp_rtp_keepalive_once_cmd); |
| 1440 | install_element(MGCP_NODE, &cfg_mgcp_no_rtp_keepalive_cmd); |
| 1441 | install_element(MGCP_NODE, &cfg_mgcp_agent_addr_cmd); |
| 1442 | install_element(MGCP_NODE, &cfg_mgcp_agent_addr_cmd_old); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1443 | install_element(MGCP_NODE, &cfg_mgcp_sdp_payload_number_cmd); |
| 1444 | install_element(MGCP_NODE, &cfg_mgcp_sdp_payload_name_cmd); |
| 1445 | install_element(MGCP_NODE, &cfg_mgcp_sdp_payload_number_cmd_old); |
| 1446 | install_element(MGCP_NODE, &cfg_mgcp_sdp_payload_name_cmd_old); |
| 1447 | install_element(MGCP_NODE, &cfg_mgcp_loop_cmd); |
| 1448 | install_element(MGCP_NODE, &cfg_mgcp_force_realloc_cmd); |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1449 | install_element(MGCP_NODE, &cfg_mgcp_rtp_accept_all_cmd); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1450 | install_element(MGCP_NODE, &cfg_mgcp_number_endp_cmd); |
| 1451 | install_element(MGCP_NODE, &cfg_mgcp_omit_rtcp_cmd); |
| 1452 | install_element(MGCP_NODE, &cfg_mgcp_no_omit_rtcp_cmd); |
| 1453 | install_element(MGCP_NODE, &cfg_mgcp_patch_rtp_ssrc_cmd); |
| 1454 | install_element(MGCP_NODE, &cfg_mgcp_no_patch_rtp_ssrc_cmd); |
| 1455 | install_element(MGCP_NODE, &cfg_mgcp_patch_rtp_ts_cmd); |
| 1456 | install_element(MGCP_NODE, &cfg_mgcp_no_patch_rtp_ts_cmd); |
| 1457 | install_element(MGCP_NODE, &cfg_mgcp_no_patch_rtp_cmd); |
Philipp Maier | 9fc8a02 | 2019-02-20 12:26:52 +0100 | [diff] [blame] | 1458 | install_element(MGCP_NODE, &cfg_mgcp_patch_rtp_rfc5993hr_cmd); |
| 1459 | install_element(MGCP_NODE, &cfg_mgcp_no_patch_rtp_rfc5993hr_cmd); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1460 | install_element(MGCP_NODE, &cfg_mgcp_sdp_fmtp_extra_cmd); |
| 1461 | install_element(MGCP_NODE, &cfg_mgcp_sdp_payload_send_ptime_cmd); |
| 1462 | install_element(MGCP_NODE, &cfg_mgcp_no_sdp_payload_send_ptime_cmd); |
| 1463 | install_element(MGCP_NODE, &cfg_mgcp_sdp_payload_send_name_cmd); |
| 1464 | install_element(MGCP_NODE, &cfg_mgcp_no_sdp_payload_send_name_cmd); |
| 1465 | install_element(MGCP_NODE, &cfg_mgcp_osmux_cmd); |
| 1466 | install_element(MGCP_NODE, &cfg_mgcp_osmux_ip_cmd); |
| 1467 | install_element(MGCP_NODE, &cfg_mgcp_osmux_batch_factor_cmd); |
| 1468 | install_element(MGCP_NODE, &cfg_mgcp_osmux_batch_size_cmd); |
| 1469 | install_element(MGCP_NODE, &cfg_mgcp_osmux_port_cmd); |
| 1470 | install_element(MGCP_NODE, &cfg_mgcp_osmux_dummy_cmd); |
| 1471 | install_element(MGCP_NODE, &cfg_mgcp_allow_transcoding_cmd); |
| 1472 | install_element(MGCP_NODE, &cfg_mgcp_no_allow_transcoding_cmd); |
Philipp Maier | 12943ea | 2018-01-17 15:40:25 +0100 | [diff] [blame] | 1473 | install_element(MGCP_NODE, &cfg_mgcp_domain_cmd); |
Oliver Smith | e36b775 | 2019-01-22 16:31:36 +0100 | [diff] [blame] | 1474 | install_element(MGCP_NODE, &cfg_mgcp_conn_timeout_cmd); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1475 | |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1476 | install_element(MGCP_NODE, &cfg_mgcp_trunk_cmd); |
| 1477 | install_node(&trunk_node, config_write_trunk); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1478 | install_element(TRUNK_NODE, &cfg_trunk_rtp_keepalive_cmd); |
| 1479 | install_element(TRUNK_NODE, &cfg_trunk_rtp_keepalive_once_cmd); |
| 1480 | install_element(TRUNK_NODE, &cfg_trunk_no_rtp_keepalive_cmd); |
| 1481 | install_element(TRUNK_NODE, &cfg_trunk_payload_number_cmd); |
| 1482 | install_element(TRUNK_NODE, &cfg_trunk_payload_name_cmd); |
| 1483 | install_element(TRUNK_NODE, &cfg_trunk_payload_number_cmd_old); |
| 1484 | install_element(TRUNK_NODE, &cfg_trunk_payload_name_cmd_old); |
| 1485 | install_element(TRUNK_NODE, &cfg_trunk_loop_cmd); |
| 1486 | install_element(TRUNK_NODE, &cfg_trunk_omit_rtcp_cmd); |
| 1487 | install_element(TRUNK_NODE, &cfg_trunk_no_omit_rtcp_cmd); |
| 1488 | install_element(TRUNK_NODE, &cfg_trunk_patch_rtp_ssrc_cmd); |
| 1489 | install_element(TRUNK_NODE, &cfg_trunk_no_patch_rtp_ssrc_cmd); |
| 1490 | install_element(TRUNK_NODE, &cfg_trunk_patch_rtp_ts_cmd); |
Philipp Maier | 9fc8a02 | 2019-02-20 12:26:52 +0100 | [diff] [blame] | 1491 | install_element(TRUNK_NODE, &cfg_trunk_patch_rtp_rfc5993hr_cmd); |
| 1492 | install_element(TRUNK_NODE, &cfg_trunk_no_patch_rtp_rfc5993hr_cmd); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1493 | install_element(TRUNK_NODE, &cfg_trunk_no_patch_rtp_ts_cmd); |
| 1494 | install_element(TRUNK_NODE, &cfg_trunk_no_patch_rtp_cmd); |
| 1495 | install_element(TRUNK_NODE, &cfg_trunk_sdp_fmtp_extra_cmd); |
| 1496 | install_element(TRUNK_NODE, &cfg_trunk_sdp_payload_send_ptime_cmd); |
| 1497 | install_element(TRUNK_NODE, &cfg_trunk_no_sdp_payload_send_ptime_cmd); |
| 1498 | install_element(TRUNK_NODE, &cfg_trunk_sdp_payload_send_name_cmd); |
| 1499 | install_element(TRUNK_NODE, &cfg_trunk_no_sdp_payload_send_name_cmd); |
| 1500 | install_element(TRUNK_NODE, &cfg_trunk_allow_transcoding_cmd); |
| 1501 | install_element(TRUNK_NODE, &cfg_trunk_no_allow_transcoding_cmd); |
| 1502 | |
| 1503 | return 0; |
| 1504 | } |
| 1505 | |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1506 | int mgcp_parse_config(const char *config_file, struct mgcp_config *cfg, |
| 1507 | enum mgcp_role role) |
| 1508 | { |
| 1509 | int rc; |
Philipp Maier | 14b27a8 | 2020-06-02 20:15:30 +0200 | [diff] [blame] | 1510 | struct mgcp_trunk *trunk; |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1511 | |
| 1512 | cfg->osmux_port = OSMUX_PORT; |
| 1513 | cfg->osmux_batch = 4; |
| 1514 | cfg->osmux_batch_size = OSMUX_BATCH_DEFAULT_MAX; |
| 1515 | |
| 1516 | g_cfg = cfg; |
| 1517 | rc = vty_read_config_file(config_file, NULL); |
| 1518 | if (rc < 0) { |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1519 | fprintf(stderr, "Failed to parse the config file: '%s'\n", |
| 1520 | config_file); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1521 | return rc; |
| 1522 | } |
| 1523 | |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1524 | if (!g_cfg->source_addr) { |
| 1525 | fprintf(stderr, "You need to specify a bind address.\n"); |
| 1526 | return -1; |
| 1527 | } |
| 1528 | |
Philipp Maier | c66ab2c | 2020-06-02 20:55:34 +0200 | [diff] [blame] | 1529 | if (mgcp_trunk_alloc_endpts(g_cfg->virt_trunk) != 0) { |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1530 | LOGP(DLMGCP, LOGL_ERROR, |
Philipp Maier | 4845498 | 2017-11-10 16:46:41 +0100 | [diff] [blame] | 1531 | "Failed to initialize the virtual trunk (%d endpoints)\n", |
Harald Welte | c39b1bf | 2020-03-08 11:29:39 +0100 | [diff] [blame] | 1532 | g_cfg->virt_trunk->number_endpoints); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1533 | return -1; |
| 1534 | } |
| 1535 | |
| 1536 | llist_for_each_entry(trunk, &g_cfg->trunks, entry) { |
Philipp Maier | c66ab2c | 2020-06-02 20:55:34 +0200 | [diff] [blame] | 1537 | if (mgcp_trunk_alloc_endpts(trunk) != 0) { |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1538 | LOGP(DLMGCP, LOGL_ERROR, |
Philipp Maier | 4845498 | 2017-11-10 16:46:41 +0100 | [diff] [blame] | 1539 | "Failed to initialize trunk %d (%d endpoints)\n", |
| 1540 | trunk->trunk_nr, trunk->number_endpoints); |
Neels Hofmeyr | f83ec56 | 2017-09-07 19:18:40 +0200 | [diff] [blame] | 1541 | return -1; |
| 1542 | } |
| 1543 | } |
| 1544 | cfg->role = role; |
| 1545 | |
| 1546 | return 0; |
| 1547 | } |