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