blob: 784894c18a6e264a3fe4fed62f65889d9f07f117 [file] [log] [blame]
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001/* 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 Hofmeyrf83ec562017-09-07 19:18:40 +020024#include <osmocom/core/talloc.h>
Pau Espin Pedrola790f0c2020-08-31 13:29:11 +020025#include <osmocom/core/sockaddr_str.h>
Stefan Sperling1e174872018-10-25 18:36:10 +020026#include <osmocom/vty/misc.h>
Philipp Maier87bd9be2017-08-22 16:35:41 +020027#include <osmocom/mgcp/mgcp.h>
Neels Hofmeyr67793542017-09-08 04:25:16 +020028#include <osmocom/mgcp/mgcp_common.h>
Philipp Maier993ea6b2020-08-04 18:26:50 +020029#include <osmocom/mgcp/osmux.h>
30#include <osmocom/mgcp/mgcp_protocol.h>
Philipp Maier87bd9be2017-08-22 16:35:41 +020031#include <osmocom/mgcp/vty.h>
32#include <osmocom/mgcp/mgcp_conn.h>
Philipp Maier37d11c82018-02-01 14:38:12 +010033#include <osmocom/mgcp/mgcp_endp.h>
Philipp Maierc66ab2c2020-06-02 20:55:34 +020034#include <osmocom/mgcp/mgcp_trunk.h>
Neels Hofmeyrf83ec562017-09-07 19:18:40 +020035
36#include <string.h>
Philipp Maierbca0ef62018-07-09 17:20:51 +020037#include <inttypes.h>
Stefan Sperling12086582018-06-26 15:26:28 +020038#include <limits.h>
Neels Hofmeyrf83ec562017-09-07 19:18:40 +020039
40#define RTCP_OMIT_STR "Drop RTCP packets in both directions\n"
41#define RTP_PATCH_STR "Modify RTP packet header in both directions\n"
42#define RTP_KEEPALIVE_STR "Send dummy UDP packet to net RTP destination\n"
Philipp Maier9fc8a022019-02-20 12:26:52 +010043#define RTP_TS101318_RFC5993_CONV_STR "Convert GSM-HR from TS101318 to RFC5993 and vice versa\n"
44
Philipp Maier19c430f2020-09-22 15:52:50 +020045#define X(x) (1 << x)
Neels Hofmeyrf83ec562017-09-07 19:18:40 +020046
47static struct mgcp_config *g_cfg = NULL;
48
Neels Hofmeyrf83ec562017-09-07 19:18:40 +020049struct cmd_node mgcp_node = {
50 MGCP_NODE,
51 "%s(config-mgcp)# ",
52 1,
53};
54
55struct cmd_node trunk_node = {
56 TRUNK_NODE,
57 "%s(config-mgcp-trunk)# ",
58 1,
59};
60
61static int config_write_mgcp(struct vty *vty)
62{
Philipp Maier6fbbeec2020-07-01 23:00:54 +020063 struct mgcp_trunk *trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_VIRTUAL, MGCP_VIRT_TRUNK_ID);
Philipp Maierd19de2e2020-06-03 13:55:33 +020064 OSMO_ASSERT(trunk);
Harald Weltec39b1bf2020-03-08 11:29:39 +010065
Neels Hofmeyrf83ec562017-09-07 19:18:40 +020066 vty_out(vty, "mgcp%s", VTY_NEWLINE);
Philipp Maierf53796c2020-06-02 20:38:28 +020067 vty_out(vty, " domain %s%s", g_cfg->domain, VTY_NEWLINE);
Eric2764bdb2021-08-23 22:11:47 +020068 if (strlen(g_cfg->local_ip))
Neels Hofmeyrf83ec562017-09-07 19:18:40 +020069 vty_out(vty, " local ip %s%s", g_cfg->local_ip, VTY_NEWLINE);
Philipp Maierf53796c2020-06-02 20:38:28 +020070 vty_out(vty, " bind ip %s%s", g_cfg->source_addr, VTY_NEWLINE);
71 vty_out(vty, " bind port %u%s", g_cfg->source_port, VTY_NEWLINE);
72 vty_out(vty, " rtp port-range %u %u%s",
Philipp Maier87bd9be2017-08-22 16:35:41 +020073 g_cfg->net_ports.range_start, g_cfg->net_ports.range_end,
74 VTY_NEWLINE);
Eric2764bdb2021-08-23 22:11:47 +020075 if (strlen(g_cfg->net_ports.bind_addr_v4))
Philipp Maierf53796c2020-06-02 20:38:28 +020076 vty_out(vty, " rtp bind-ip %s%s",
Pau Espin Pedrol8a2a1b22020-09-02 20:46:24 +020077 g_cfg->net_ports.bind_addr_v4, VTY_NEWLINE);
Eric2764bdb2021-08-23 22:11:47 +020078 if (strlen(g_cfg->net_ports.bind_addr_v6))
Pau Espin Pedrol8a2a1b22020-09-02 20:46:24 +020079 vty_out(vty, " rtp bind-ip-v6 %s%s",
80 g_cfg->net_ports.bind_addr_v6, VTY_NEWLINE);
Philipp Maier1cb1e382017-11-02 17:16:04 +010081 if (g_cfg->net_ports.bind_addr_probe)
Philipp Maierf53796c2020-06-02 20:38:28 +020082 vty_out(vty, " rtp ip-probing%s", VTY_NEWLINE);
Philipp Maier1cb1e382017-11-02 17:16:04 +010083 else
Philipp Maierf53796c2020-06-02 20:38:28 +020084 vty_out(vty, " no rtp ip-probing%s", VTY_NEWLINE);
85 vty_out(vty, " rtp ip-dscp %d%s", g_cfg->endp_dscp, VTY_NEWLINE);
Harald Welte55a92292021-04-28 19:06:34 +020086 if (g_cfg->endp_priority)
87 vty_out(vty, " rtp socket-priority %d%s", g_cfg->endp_priority, VTY_NEWLINE);
Harald Weltec39b1bf2020-03-08 11:29:39 +010088 if (trunk->keepalive_interval == MGCP_KEEPALIVE_ONCE)
Philipp Maierf53796c2020-06-02 20:38:28 +020089 vty_out(vty, " rtp keep-alive once%s", VTY_NEWLINE);
Harald Weltec39b1bf2020-03-08 11:29:39 +010090 else if (trunk->keepalive_interval)
Philipp Maierf53796c2020-06-02 20:38:28 +020091 vty_out(vty, " rtp keep-alive %d%s",
Harald Weltec39b1bf2020-03-08 11:29:39 +010092 trunk->keepalive_interval, VTY_NEWLINE);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +020093 else
Philipp Maierf53796c2020-06-02 20:38:28 +020094 vty_out(vty, " no rtp keep-alive%s", VTY_NEWLINE);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +020095
Harald Weltec39b1bf2020-03-08 11:29:39 +010096 if (trunk->omit_rtcp)
Philipp Maierf53796c2020-06-02 20:38:28 +020097 vty_out(vty, " rtcp-omit%s", VTY_NEWLINE);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +020098 else
Philipp Maierf53796c2020-06-02 20:38:28 +020099 vty_out(vty, " no rtcp-omit%s", VTY_NEWLINE);
Harald Weltec39b1bf2020-03-08 11:29:39 +0100100 if (trunk->force_constant_ssrc
101 || trunk->force_aligned_timing
102 || trunk->rfc5993_hr_convert) {
Philipp Maierf53796c2020-06-02 20:38:28 +0200103 vty_out(vty, " %srtp-patch ssrc%s",
Harald Weltec39b1bf2020-03-08 11:29:39 +0100104 trunk->force_constant_ssrc ? "" : "no ",
Philipp Maier87bd9be2017-08-22 16:35:41 +0200105 VTY_NEWLINE);
Philipp Maierf53796c2020-06-02 20:38:28 +0200106 vty_out(vty, " %srtp-patch timestamp%s",
Harald Weltec39b1bf2020-03-08 11:29:39 +0100107 trunk->force_aligned_timing ? "" : "no ",
Philipp Maier87bd9be2017-08-22 16:35:41 +0200108 VTY_NEWLINE);
Philipp Maierf53796c2020-06-02 20:38:28 +0200109 vty_out(vty, " %srtp-patch rfc5993hr%s",
Harald Weltec39b1bf2020-03-08 11:29:39 +0100110 trunk->rfc5993_hr_convert ? "" : "no ",
Philipp Maier9fc8a022019-02-20 12:26:52 +0100111 VTY_NEWLINE);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200112 } else
Philipp Maierf53796c2020-06-02 20:38:28 +0200113 vty_out(vty, " no rtp-patch%s", VTY_NEWLINE);
Harald Weltec39b1bf2020-03-08 11:29:39 +0100114 if (trunk->audio_fmtp_extra)
Philipp Maierf53796c2020-06-02 20:38:28 +0200115 vty_out(vty, " sdp audio fmtp-extra %s%s",
Harald Weltec39b1bf2020-03-08 11:29:39 +0100116 trunk->audio_fmtp_extra, VTY_NEWLINE);
Philipp Maierf53796c2020-06-02 20:38:28 +0200117 vty_out(vty, " %ssdp audio-payload send-ptime%s",
Harald Weltec39b1bf2020-03-08 11:29:39 +0100118 trunk->audio_send_ptime ? "" : "no ", VTY_NEWLINE);
Philipp Maierf53796c2020-06-02 20:38:28 +0200119 vty_out(vty, " %ssdp audio-payload send-name%s",
Harald Weltec39b1bf2020-03-08 11:29:39 +0100120 trunk->audio_send_name ? "" : "no ", VTY_NEWLINE);
Philipp Maierf53796c2020-06-02 20:38:28 +0200121 vty_out(vty, " number endpoints %u%s",
Philipp Maier889fe7f2020-07-06 17:44:12 +0200122 trunk->v.vty_number_endpoints, VTY_NEWLINE);
Eric2764bdb2021-08-23 22:11:47 +0200123 if (strlen(g_cfg->call_agent_addr))
Philipp Maierf53796c2020-06-02 20:38:28 +0200124 vty_out(vty, " call-agent ip %s%s", g_cfg->call_agent_addr,
Philipp Maier87bd9be2017-08-22 16:35:41 +0200125 VTY_NEWLINE);
126 if (g_cfg->force_ptime > 0)
Philipp Maierf53796c2020-06-02 20:38:28 +0200127 vty_out(vty, " rtp force-ptime %d%s", g_cfg->force_ptime,
Philipp Maier87bd9be2017-08-22 16:35:41 +0200128 VTY_NEWLINE);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200129
Pau Espin Pedrol36413c02022-10-12 17:58:17 +0200130 switch (g_cfg->osmux.usage) {
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200131 case OSMUX_USAGE_ON:
Philipp Maierf53796c2020-06-02 20:38:28 +0200132 vty_out(vty, " osmux on%s", VTY_NEWLINE);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200133 break;
134 case OSMUX_USAGE_ONLY:
Philipp Maierf53796c2020-06-02 20:38:28 +0200135 vty_out(vty, " osmux only%s", VTY_NEWLINE);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200136 break;
137 case OSMUX_USAGE_OFF:
138 default:
Philipp Maierf53796c2020-06-02 20:38:28 +0200139 vty_out(vty, " osmux off%s", VTY_NEWLINE);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200140 break;
141 }
Pau Espin Pedrol36413c02022-10-12 17:58:17 +0200142 if (g_cfg->osmux.usage != OSMUX_USAGE_OFF) {
143 if (g_cfg->osmux.local_addr_v4)
Pau Espin Pedrol70c03f52022-10-04 16:49:41 +0200144 vty_out(vty, " osmux bind-ip %s%s",
Pau Espin Pedrol36413c02022-10-12 17:58:17 +0200145 g_cfg->osmux.local_addr_v4, VTY_NEWLINE);
146 if (g_cfg->osmux.local_addr_v6)
Pau Espin Pedrol70c03f52022-10-04 16:49:41 +0200147 vty_out(vty, " osmux bind-ip-v6 %s%s",
Pau Espin Pedrol36413c02022-10-12 17:58:17 +0200148 g_cfg->osmux.local_addr_v6, VTY_NEWLINE);
Philipp Maierf53796c2020-06-02 20:38:28 +0200149 vty_out(vty, " osmux batch-factor %d%s",
Pau Espin Pedrol36413c02022-10-12 17:58:17 +0200150 g_cfg->osmux.batch_factor, VTY_NEWLINE);
Philipp Maierf53796c2020-06-02 20:38:28 +0200151 vty_out(vty, " osmux batch-size %u%s",
Pau Espin Pedrol36413c02022-10-12 17:58:17 +0200152 g_cfg->osmux.batch_size, VTY_NEWLINE);
Philipp Maierf53796c2020-06-02 20:38:28 +0200153 vty_out(vty, " osmux port %u%s",
Pau Espin Pedrol36413c02022-10-12 17:58:17 +0200154 g_cfg->osmux.local_port, VTY_NEWLINE);
Philipp Maierf53796c2020-06-02 20:38:28 +0200155 vty_out(vty, " osmux dummy %s%s",
Pau Espin Pedrol36413c02022-10-12 17:58:17 +0200156 g_cfg->osmux.dummy_padding ? "on" : "off", VTY_NEWLINE);
Pau Espin Pedrol833281d2022-10-06 17:41:22 +0200157 vty_out(vty, " osmux peer-behind-nat %s%s",
Pau Espin Pedrol36413c02022-10-12 17:58:17 +0200158 g_cfg->osmux.peer_behind_nat ? "on" : "off", VTY_NEWLINE);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200159 }
Oliver Smithe36b7752019-01-22 16:31:36 +0100160
161 if (g_cfg->conn_timeout)
Philipp Maierf53796c2020-06-02 20:38:28 +0200162 vty_out(vty, " conn-timeout %u%s", g_cfg->conn_timeout, VTY_NEWLINE);
Oliver Smithe36b7752019-01-22 16:31:36 +0100163
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200164 return CMD_SUCCESS;
165}
166
Philipp Maiercede2a42018-07-03 14:14:21 +0200167static void dump_rtp_end(struct vty *vty, struct mgcp_conn_rtp *conn)
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200168{
Philipp Maiercede2a42018-07-03 14:14:21 +0200169 struct mgcp_rtp_state *state = &conn->state;
170 struct mgcp_rtp_end *end = &conn->end;
Philipp Maierbc0346e2018-06-07 09:52:16 +0200171 struct mgcp_rtp_codec *codec = end->codec;
Stefan Sperlingb7974e22018-10-29 13:22:00 +0100172 struct rate_ctr *tx_packets, *tx_bytes;
173 struct rate_ctr *rx_packets, *rx_bytes;
Philipp Maiercede2a42018-07-03 14:14:21 +0200174 struct rate_ctr *dropped_packets;
175
Pau Espin Pedroldaf5bce2022-09-22 19:14:24 +0200176 tx_packets = rate_ctr_group_get_ctr(conn->ctrg, RTP_PACKETS_TX_CTR);
177 tx_bytes = rate_ctr_group_get_ctr(conn->ctrg, RTP_OCTETS_TX_CTR);
178 rx_packets = rate_ctr_group_get_ctr(conn->ctrg, RTP_PACKETS_RX_CTR);
179 rx_bytes = rate_ctr_group_get_ctr(conn->ctrg, RTP_OCTETS_RX_CTR);
180 dropped_packets = rate_ctr_group_get_ctr(conn->ctrg, RTP_DROPPED_PACKETS_CTR);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200181
182 vty_out(vty,
Stefan Sperlingb7974e22018-10-29 13:22:00 +0100183 " Packets Sent: %" PRIu64 " (%" PRIu64 " bytes total)%s"
184 " Packets Received: %" PRIu64 " (%" PRIu64 " bytes total)%s"
Philipp Maierbca0ef62018-07-09 17:20:51 +0200185 " Timestamp Errs: %" PRIu64 "->%" PRIu64 "%s"
186 " Dropped Packets: %" PRIu64 "%s"
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200187 " Payload Type: %d Rate: %u Channels: %d %s"
188 " Frame Duration: %u Frame Denominator: %u%s"
189 " FPP: %d Packet Duration: %u%s"
190 " FMTP-Extra: %s Audio-Name: %s Sub-Type: %s%s"
191 " Output-Enabled: %d Force-PTIME: %d%s",
Stefan Sperlingb7974e22018-10-29 13:22:00 +0100192 tx_packets->current, tx_bytes->current, VTY_NEWLINE,
193 rx_packets->current, rx_bytes->current, VTY_NEWLINE,
Philipp Maier9e1d1642018-05-09 16:26:34 +0200194 state->in_stream.err_ts_ctr->current,
195 state->out_stream.err_ts_ctr->current,
Pau Espin Pedrol83df47c2022-09-21 20:07:59 +0200196 VTY_NEWLINE,
Philipp Maiercede2a42018-07-03 14:14:21 +0200197 dropped_packets->current, VTY_NEWLINE,
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200198 codec->payload_type, codec->rate, codec->channels, VTY_NEWLINE,
Philipp Maier87bd9be2017-08-22 16:35:41 +0200199 codec->frame_duration_num, codec->frame_duration_den,
200 VTY_NEWLINE, end->frames_per_packet, end->packet_duration_ms,
201 VTY_NEWLINE, end->fmtp_extra, codec->audio_name,
202 codec->subtype_name, VTY_NEWLINE, end->output_enabled,
203 end->force_output_ptime, VTY_NEWLINE);
Pau Espin Pedrolea7aaf22022-09-22 21:07:54 +0200204 if (mgcp_conn_rtp_is_osmux(conn)) {
205 struct rate_ctr *rx_chunks, *rx_octets, *rtp_tx, *rtp_tx_dropped, *octets_tx;
206 rx_chunks = rate_ctr_group_get_ctr(conn->osmux.ctrg, OSMUX_CHUNKS_RX_CTR);
207 rx_octets = rate_ctr_group_get_ctr(conn->osmux.ctrg, OSMUX_OCTETS_RX_CTR);
208 rtp_tx = rate_ctr_group_get_ctr(conn->osmux.ctrg, OSMUX_RTP_PACKETS_TX_CTR);
209 rtp_tx_dropped = rate_ctr_group_get_ctr(conn->osmux.ctrg, OSMUX_RTP_PACKETS_TX_DROPPED_CTR);
210 octets_tx = rate_ctr_group_get_ctr(conn->osmux.ctrg, OSMUX_AMR_OCTETS_TX_CTR);
211 vty_out(vty,
212 " Osmux:%s"
213 " State: %s%s"
214 " Local CID: %d%s"
215 " Remote CID: %d%s"
216 " Chunks received: %" PRIu64 " (%" PRIu64 " bytes total)%s"
217 " RTP Packets encoded (Tx): %" PRIu64 " (%" PRIu64 " AMR octets total)%s"
218 " AMR payloads Dropped (Tx): %" PRIu64 "%s",
219 VTY_NEWLINE, osmux_state_str(conn->osmux.state), VTY_NEWLINE,
220 conn->osmux.local_cid_allocated ? conn->osmux.local_cid : -1, VTY_NEWLINE,
221 conn->osmux.remote_cid_present ? conn->osmux.remote_cid : -1, VTY_NEWLINE,
222 rx_chunks->current, rx_octets->current, VTY_NEWLINE,
223 rtp_tx->current, octets_tx->current, VTY_NEWLINE,
224 rtp_tx_dropped->current, VTY_NEWLINE
225 );
226
227 }
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200228}
229
Philipp Maierc66ab2c2020-06-02 20:55:34 +0200230static void dump_endpoint(struct vty *vty, struct mgcp_endpoint *endp,
Philipp Maierd70eef62021-07-19 13:53:28 +0200231 unsigned int trunk_nr, enum mgcp_trunk_type trunk_type, int show_stats)
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200232{
Philipp Maier87bd9be2017-08-22 16:35:41 +0200233 struct mgcp_conn *conn;
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200234
Philipp Maierd70eef62021-07-19 13:53:28 +0200235 vty_out(vty, "%s trunk %u endpoint %s:%s",
Philipp Maierc66ab2c2020-06-02 20:55:34 +0200236 trunk_type == MGCP_TRUNK_VIRTUAL ? "Virtual" : "E1", trunk_nr, endp->name, VTY_NEWLINE);
Philipp Maier8d6a1932020-06-18 12:19:31 +0200237 vty_out(vty, " Availability: %s%s",
238 mgcp_endp_avail(endp) ? "available" : "not in service", VTY_NEWLINE);
Stefan Sperling12086582018-06-26 15:26:28 +0200239
240 if (llist_empty(&endp->conns)) {
241 vty_out(vty, " No active connections%s", VTY_NEWLINE);
242 return;
243 }
244
245 llist_for_each_entry(conn, &endp->conns, entry) {
246 vty_out(vty, " CONN: %s%s", mgcp_conn_dump(conn), VTY_NEWLINE);
247
248 if (show_stats) {
Ericfbf78d12021-08-23 22:31:39 +0200249 if (endp->trunk->cfg->conn_timeout) {
Oliver Smithe36b7752019-01-22 16:31:36 +0100250 struct timeval remaining;
251 osmo_timer_remaining(&conn->watchdog, NULL, &remaining);
252 vty_out(vty, " Currently remaining timeout (seconds): %d.%06d%s",
253 (int)remaining.tv_sec, (int)remaining.tv_usec, VTY_NEWLINE);
254 }
255
Stefan Sperling12086582018-06-26 15:26:28 +0200256 /* FIXME: Also add verbosity for other
257 * connection types (E1) as soon as
258 * the implementation is available */
259 if (conn->type == MGCP_CONN_TYPE_RTP) {
260 dump_rtp_end(vty, &conn->u.rtp);
261 }
262 }
263 }
264}
265
Philipp Maierc66ab2c2020-06-02 20:55:34 +0200266static void dump_ratectr_global(struct vty *vty, struct mgcp_ratectr_global *ratectr)
267{
268 vty_out(vty, "%s", VTY_NEWLINE);
269 vty_out(vty, "Rate counters (global):%s", VTY_NEWLINE);
270
271 if (ratectr->mgcp_general_ctr_group) {
272 vty_out(vty, " %s:%s",
273 ratectr->mgcp_general_ctr_group->desc->
274 group_description, VTY_NEWLINE);
275 vty_out_rate_ctr_group_fmt(vty,
276 " %25n: %10c (%S/s %M/m %H/h %D/d) %d",
277 ratectr->mgcp_general_ctr_group);
278 }
279}
280
Philipp Maier889fe7f2020-07-06 17:44:12 +0200281static void dump_ratectr_trunk(struct vty *vty, struct mgcp_trunk *trunk)
Philipp Maierc66ab2c2020-06-02 20:55:34 +0200282{
Philipp Maier889fe7f2020-07-06 17:44:12 +0200283 struct mgcp_ratectr_trunk *ratectr = &trunk->ratectr;
284
Philipp Maierc66ab2c2020-06-02 20:55:34 +0200285 vty_out(vty, "%s", VTY_NEWLINE);
286 vty_out(vty, "Rate counters (trunk):%s", VTY_NEWLINE);
287
288 if (ratectr->mgcp_crcx_ctr_group) {
289 vty_out(vty, " %s:%s",
290 ratectr->mgcp_crcx_ctr_group->desc->group_description,
291 VTY_NEWLINE);
292 vty_out_rate_ctr_group_fmt(vty,
293 " %25n: %10c (%S/s %M/m %H/h %D/d) %d",
294 ratectr->mgcp_crcx_ctr_group);
295 }
296 if (ratectr->mgcp_dlcx_ctr_group) {
297 vty_out(vty, " %s:%s",
298 ratectr->mgcp_dlcx_ctr_group->desc->group_description,
299 VTY_NEWLINE);
300 vty_out_rate_ctr_group_fmt(vty,
301 " %25n: %10c (%S/s %M/m %H/h %D/d) %d",
302 ratectr->mgcp_dlcx_ctr_group);
303 }
304 if (ratectr->mgcp_mdcx_ctr_group) {
305 vty_out(vty, " %s:%s",
306 ratectr->mgcp_mdcx_ctr_group->desc->group_description,
307 VTY_NEWLINE);
308 vty_out_rate_ctr_group_fmt(vty,
309 " %25n: %10c (%S/s %M/m %H/h %D/d) %d",
310 ratectr->mgcp_mdcx_ctr_group);
311 }
312 if (ratectr->all_rtp_conn_stats) {
313 vty_out(vty, " %s:%s",
314 ratectr->all_rtp_conn_stats->desc->group_description,
315 VTY_NEWLINE);
316 vty_out_rate_ctr_group_fmt(vty,
317 " %25n: %10c (%S/s %M/m %H/h %D/d) %d",
318 ratectr->all_rtp_conn_stats);
319 }
Pau Espin Pedrol582c2bf2022-09-22 17:53:44 +0200320 if (ratectr->all_osmux_conn_stats) {
321 vty_out(vty, " %s:%s",
322 ratectr->all_osmux_conn_stats->desc->group_description,
323 VTY_NEWLINE);
324 vty_out_rate_ctr_group_fmt(vty,
325 " %25n: %10c (%S/s %M/m %H/h %D/d) %d",
326 ratectr->all_osmux_conn_stats);
327 }
Philipp Maier889fe7f2020-07-06 17:44:12 +0200328
329 if (ratectr->e1_stats && trunk->trunk_type == MGCP_TRUNK_E1) {
330 vty_out(vty, " %s:%s",
331 ratectr->e1_stats->desc->group_description,
332 VTY_NEWLINE);
333 vty_out_rate_ctr_group_fmt(vty,
334 " %25n: %10c (%S/s %M/m %H/h %D/d) %d",
335 ratectr->e1_stats);
336 }
Philipp Maierc66ab2c2020-06-02 20:55:34 +0200337}
338
339
Keithfe53edd2021-05-04 15:23:30 -0500340static void dump_trunk(struct vty *vty, struct mgcp_trunk *trunk, int show_stats, int active_only)
Stefan Sperling12086582018-06-26 15:26:28 +0200341{
342 int i;
Keithfe53edd2021-05-04 15:23:30 -0500343 int active_count = 0;
Stefan Sperling12086582018-06-26 15:26:28 +0200344
345 vty_out(vty, "%s trunk %d with %d endpoints:%s",
Philipp Maierc66ab2c2020-06-02 20:55:34 +0200346 trunk->trunk_type == MGCP_TRUNK_VIRTUAL ? "Virtual" : "E1",
Philipp Maier869b21c2020-07-03 16:04:16 +0200347 trunk->trunk_nr, trunk->number_endpoints, VTY_NEWLINE);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200348
Philipp Maierc66ab2c2020-06-02 20:55:34 +0200349 if (!trunk->endpoints) {
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200350 vty_out(vty, "No endpoints allocated yet.%s", VTY_NEWLINE);
351 return;
352 }
353
Philipp Maierc66ab2c2020-06-02 20:55:34 +0200354 for (i = 0; i < trunk->number_endpoints; ++i) {
355 struct mgcp_endpoint *endp = trunk->endpoints[i];
Keithfe53edd2021-05-04 15:23:30 -0500356 if (!active_only || !llist_empty(&endp->conns)) {
357 dump_endpoint(vty, endp, trunk->trunk_nr, trunk->trunk_type,
358 show_stats);
359 if (i < trunk->number_endpoints - 1)
360 vty_out(vty, "%s", VTY_NEWLINE);
361 }
362 if (!llist_empty(&endp->conns))
363 active_count++;
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200364 }
Stefan Sperling1e174872018-10-25 18:36:10 +0200365
Keithfe53edd2021-05-04 15:23:30 -0500366 if (active_count == 0)
367 vty_out(vty, "No endpoints in use.%s", VTY_NEWLINE);
368
Philipp Maierc66ab2c2020-06-02 20:55:34 +0200369 if (show_stats)
Philipp Maier889fe7f2020-07-06 17:44:12 +0200370 dump_ratectr_trunk(vty, trunk);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200371}
372
Keithfe53edd2021-05-04 15:23:30 -0500373static int mgcp_show(struct vty *vty, int argc, const char **argv,
374 int show_stats, int active_only)
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200375{
Philipp Maier14b27a82020-06-02 20:15:30 +0200376 struct mgcp_trunk *trunk;
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200377
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200378 llist_for_each_entry(trunk, &g_cfg->trunks, entry)
Keithfe53edd2021-05-04 15:23:30 -0500379 dump_trunk(vty, trunk, show_stats, active_only);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200380
Pau Espin Pedrol36413c02022-10-12 17:58:17 +0200381 if (g_cfg->osmux.usage != OSMUX_USAGE_OFF)
Pau Espin Pedrol8de58e72019-04-24 13:33:46 +0200382 vty_out(vty, "Osmux used CID: %d%s", osmux_cid_pool_count_used(),
Philipp Maier87bd9be2017-08-22 16:35:41 +0200383 VTY_NEWLINE);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200384
Philipp Maierc66ab2c2020-06-02 20:55:34 +0200385 if (show_stats)
386 dump_ratectr_global(vty, &g_cfg->ratectr);
387
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200388 return CMD_SUCCESS;
389}
390
Keithfe53edd2021-05-04 15:23:30 -0500391#define SHOW_MGCP_STR "Display information about the MGCP Media Gateway\n"
392
393DEFUN(show_mgcp, show_mgcp_cmd,
394 "show mgcp [stats]",
395 SHOW_STR
396 SHOW_MGCP_STR
397 "Include statistics\n")
398{
399 int show_stats = argc >= 1;
400 return mgcp_show(vty, argc, argv, show_stats, 0);
401}
402
403DEFUN(show_mgcp_active, show_mgcp_active_cmd,
404 "show mgcp active",
405 SHOW_STR
406 SHOW_MGCP_STR
407 "Show only endpoints with active connections\n")
408{
409 return mgcp_show(vty, argc, argv, 0, 1);
410}
411
Stefan Sperling12086582018-06-26 15:26:28 +0200412static void
Philipp Maier14b27a82020-06-02 20:15:30 +0200413dump_mgcp_endpoint(struct vty *vty, struct mgcp_trunk *trunk, const char *epname)
Stefan Sperling12086582018-06-26 15:26:28 +0200414{
Philipp Maierc66ab2c2020-06-02 20:55:34 +0200415 struct mgcp_endpoint *endp;
Stefan Sperling12086582018-06-26 15:26:28 +0200416
Philipp Maierc66ab2c2020-06-02 20:55:34 +0200417 if (trunk) {
418 /* If a trunk is given, search on that specific trunk only */
419 endp = mgcp_endp_by_name_trunk(NULL, epname, trunk);
420 if (!endp) {
Philipp Maierd70eef62021-07-19 13:53:28 +0200421 vty_out(vty, "endpoint %s not configured on trunk %u%s", epname, trunk->trunk_nr, VTY_NEWLINE);
Philipp Maierc66ab2c2020-06-02 20:55:34 +0200422 return;
423 }
424 } else {
425 /* If no trunk is given, search on all possible trunks */
426 endp = mgcp_endp_by_name(NULL, epname, g_cfg);
427 if (!endp) {
428 vty_out(vty, "endpoint %s not configured%s", epname, VTY_NEWLINE);
429 return;
Stefan Sperling12086582018-06-26 15:26:28 +0200430 }
431 }
Philipp Maierc66ab2c2020-06-02 20:55:34 +0200432
433 trunk = endp->trunk;
434 dump_endpoint(vty, endp, trunk->trunk_nr, trunk->trunk_type, true);
Stefan Sperling12086582018-06-26 15:26:28 +0200435}
436
437DEFUN(show_mcgp_endpoint, show_mgcp_endpoint_cmd,
438 "show mgcp endpoint NAME",
439 SHOW_STR
440 SHOW_MGCP_STR
441 "Display information about an endpoint\n" "The name of the endpoint\n")
442{
Philipp Maierc66ab2c2020-06-02 20:55:34 +0200443 dump_mgcp_endpoint(vty, NULL, argv[0]);
Stefan Sperling12086582018-06-26 15:26:28 +0200444 return CMD_SUCCESS;
445}
446
447DEFUN(show_mcgp_trunk_endpoint, show_mgcp_trunk_endpoint_cmd,
448 "show mgcp trunk <0-64> endpoint NAME",
449 SHOW_STR
450 SHOW_MGCP_STR
451 "Display information about a trunk\n" "Trunk number\n"
452 "Display information about an endpoint\n" "The name of the endpoint\n")
453{
Philipp Maier14b27a82020-06-02 20:15:30 +0200454 struct mgcp_trunk *trunk;
Stefan Sperling12086582018-06-26 15:26:28 +0200455 int trunkidx = atoi(argv[0]);
456
Philipp Maier6fbbeec2020-07-01 23:00:54 +0200457 trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_E1, trunkidx);
Stefan Sperling12086582018-06-26 15:26:28 +0200458 if (!trunk) {
459 vty_out(vty, "trunk %d not found%s", trunkidx, VTY_NEWLINE);
460 return CMD_WARNING;
461 }
462
463 dump_mgcp_endpoint(vty, trunk, argv[1]);
464 return CMD_SUCCESS;
465}
466
Philipp Maier87bd9be2017-08-22 16:35:41 +0200467DEFUN(cfg_mgcp, cfg_mgcp_cmd, "mgcp", "Configure the MGCP")
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200468{
469 vty->node = MGCP_NODE;
470 return CMD_SUCCESS;
471}
472
Philipp Maier19c430f2020-09-22 15:52:50 +0200473DEFUN_USRATTR(cfg_mgcp_local_ip,
474 cfg_mgcp_local_ip_cmd,
475 X(MGW_CMD_ATTR_NEWCONN),
476 "local ip " VTY_IPV46_CMD,
477 "Local options for the SDP record\n"
478 IP_STR
479 "IPv4 Address to use in SDP record\n"
480 "IPv6 Address to use in SDP record\n")
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200481{
Eric2764bdb2021-08-23 22:11:47 +0200482 osmo_strlcpy(g_cfg->local_ip, argv[0], sizeof(g_cfg->local_ip));
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200483 return CMD_SUCCESS;
484}
485
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200486#define BIND_STR "Listen/Bind related socket option\n"
487DEFUN(cfg_mgcp_bind_ip,
488 cfg_mgcp_bind_ip_cmd,
Pau Espin Pedrola790f0c2020-08-31 13:29:11 +0200489 "bind ip " VTY_IPV46_CMD,
490 BIND_STR IP_STR
491 "IPv4 Address to bind to\n"
492 "IPv6 Address to bind to\n")
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200493{
Eric2764bdb2021-08-23 22:11:47 +0200494 osmo_strlcpy(g_cfg->source_addr, argv[0], sizeof(g_cfg->source_addr));
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200495 return CMD_SUCCESS;
496}
497
498DEFUN(cfg_mgcp_bind_port,
499 cfg_mgcp_bind_port_cmd,
500 "bind port <0-65534>",
Philipp Maier87bd9be2017-08-22 16:35:41 +0200501 BIND_STR "Port information\n" "UDP port to listen for MGCP messages\n")
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200502{
503 unsigned int port = atoi(argv[0]);
504 g_cfg->source_port = port;
505 return CMD_SUCCESS;
506}
507
Philipp Maier8cfe7df2020-09-22 16:18:26 +0200508DEFUN_DEPRECATED(cfg_mgcp_bind_early,
509 cfg_mgcp_bind_early_cmd,
510 "bind early (0|1)",
511 BIND_STR
512 "Bind local ports on start up\n" "Bind on demand\n" "Bind on startup\n")
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200513{
Philipp Maier72761b32023-04-06 16:04:12 +0200514 vty_out(vty, "%% Deprecated 'bind early (0|1)' config no longer has any effect%s", VTY_NEWLINE);
Philipp Maier8cfe7df2020-09-22 16:18:26 +0200515 return CMD_SUCCESS;
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200516}
517
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200518#define RTP_STR "RTP configuration\n"
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200519#define UDP_PORT_STR "UDP Port number\n"
Philipp Maier87bd9be2017-08-22 16:35:41 +0200520#define NET_START_STR "First UDP port allocated\n"
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200521#define RANGE_START_STR "Start of the range of ports\n"
522#define RANGE_END_STR "End of the range of ports\n"
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200523
Philipp Maierf1889d82017-11-08 14:59:39 +0100524DEFUN(cfg_mgcp_rtp_port_range,
525 cfg_mgcp_rtp_port_range_cmd,
Philipp Maiera19547b2018-05-22 13:44:34 +0200526 "rtp port-range <1024-65534> <1025-65535>",
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200527 RTP_STR "Range of ports to use for the NET side\n"
528 RANGE_START_STR RANGE_END_STR)
529{
Philipp Maiera19547b2018-05-22 13:44:34 +0200530 int start;
531 int end;
532
533 start = atoi(argv[0]);
534 end = atoi(argv[1]);
535
536 if (end < start) {
537 vty_out(vty, "range end port (%i) must be greater than the range start port (%i)!%s",
538 end, start, VTY_NEWLINE);
539 return CMD_WARNING;
540 }
541
542 if (start & 1) {
543 vty_out(vty, "range must begin at an even port number, autocorrecting port (%i) to: %i%s",
544 start, start & 0xFFFE, VTY_NEWLINE);
545 start &= 0xFFFE;
546 }
547
548 if ((end & 1) == 0) {
549 vty_out(vty, "range must end at an odd port number, autocorrecting port (%i) to: %i%s",
550 end, end | 1, VTY_NEWLINE);
551 end |= 1;
552 }
553
554 g_cfg->net_ports.range_start = start;
555 g_cfg->net_ports.range_end = end;
556 g_cfg->net_ports.last_port = g_cfg->net_ports.range_start;
557
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200558 return CMD_SUCCESS;
559}
Philipp Maierf1889d82017-11-08 14:59:39 +0100560ALIAS_DEPRECATED(cfg_mgcp_rtp_port_range,
561 cfg_mgcp_rtp_net_range_cmd,
562 "rtp net-range <0-65534> <0-65534>",
563 RTP_STR "Range of ports to use for the NET side\n"
564 RANGE_START_STR RANGE_END_STR)
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200565
Philipp Maier19c430f2020-09-22 15:52:50 +0200566DEFUN_USRATTR(cfg_mgcp_rtp_bind_ip,
567 cfg_mgcp_rtp_bind_ip_cmd,
568 X(MGW_CMD_ATTR_NEWCONN),
569 "rtp bind-ip A.B.C.D",
570 RTP_STR "Bind endpoints facing the Network\n"
571 "IPv4 Address to bind to\n")
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200572{
Eric2764bdb2021-08-23 22:11:47 +0200573 osmo_strlcpy(g_cfg->net_ports.bind_addr_v4, argv[0], sizeof(g_cfg->net_ports.bind_addr_v4));
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200574 return CMD_SUCCESS;
575}
Philipp Maierf1889d82017-11-08 14:59:39 +0100576ALIAS_DEPRECATED(cfg_mgcp_rtp_bind_ip,
577 cfg_mgcp_rtp_net_bind_ip_cmd,
578 "rtp net-bind-ip A.B.C.D",
579 RTP_STR "Bind endpoints facing the Network\n" "Address to bind to\n")
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200580
Philipp Maier19c430f2020-09-22 15:52:50 +0200581DEFUN_USRATTR(cfg_mgcp_rtp_no_bind_ip,
582 cfg_mgcp_rtp_no_bind_ip_cmd,
583 X(MGW_CMD_ATTR_NEWCONN),
584 "no rtp bind-ip",
585 NO_STR RTP_STR "Bind endpoints facing the Network\n"
586 "Address to bind to\n")
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200587{
Eric2764bdb2021-08-23 22:11:47 +0200588 osmo_strlcpy(g_cfg->net_ports.bind_addr_v4, "", sizeof(g_cfg->net_ports.bind_addr_v4));
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200589 return CMD_SUCCESS;
590}
Philipp Maierf1889d82017-11-08 14:59:39 +0100591ALIAS_DEPRECATED(cfg_mgcp_rtp_no_bind_ip,
592 cfg_mgcp_rtp_no_net_bind_ip_cmd,
593 "no rtp net-bind-ip",
594 NO_STR RTP_STR "Bind endpoints facing the Network\n"
595 "Address to bind to\n")
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200596
Philipp Maier19c430f2020-09-22 15:52:50 +0200597DEFUN_USRATTR(cfg_mgcp_rtp_bind_ip_v6,
598 cfg_mgcp_rtp_bind_ip_v6_cmd,
599 X(MGW_CMD_ATTR_NEWCONN),
600 "rtp bind-ip-v6 " VTY_IPV6_CMD,
601 RTP_STR "Bind endpoints facing the Network\n"
602 "IPv6 Address to bind to\n")
Pau Espin Pedrol8a2a1b22020-09-02 20:46:24 +0200603{
Eric2764bdb2021-08-23 22:11:47 +0200604 osmo_strlcpy(g_cfg->net_ports.bind_addr_v6, argv[0], sizeof(g_cfg->net_ports.bind_addr_v6));
Pau Espin Pedrol8a2a1b22020-09-02 20:46:24 +0200605 return CMD_SUCCESS;
606}
607
Philipp Maier19c430f2020-09-22 15:52:50 +0200608DEFUN_USRATTR(cfg_mgcp_rtp_no_bind_ip_v6,
609 cfg_mgcp_rtp_no_bind_ip_v6_cmd,
610 X(MGW_CMD_ATTR_NEWCONN),
611 "no rtp bind-ip-v6",
612 NO_STR RTP_STR "Bind endpoints facing the Network\n"
613 "Address to bind to\n")
Pau Espin Pedrol8a2a1b22020-09-02 20:46:24 +0200614{
Eric2764bdb2021-08-23 22:11:47 +0200615 osmo_strlcpy(g_cfg->net_ports.bind_addr_v6, "", sizeof(g_cfg->net_ports.bind_addr_v6));
Pau Espin Pedrol8a2a1b22020-09-02 20:46:24 +0200616 return CMD_SUCCESS;
617}
618
Philipp Maier19c430f2020-09-22 15:52:50 +0200619DEFUN_USRATTR(cfg_mgcp_rtp_net_bind_ip_probing,
620 cfg_mgcp_rtp_net_bind_ip_probing_cmd,
621 X(MGW_CMD_ATTR_NEWCONN),
622 "rtp ip-probing",
623 RTP_STR "automatic rtp bind ip selection\n")
Philipp Maier1cb1e382017-11-02 17:16:04 +0100624{
625 g_cfg->net_ports.bind_addr_probe = true;
626 return CMD_SUCCESS;
627}
628
Philipp Maier19c430f2020-09-22 15:52:50 +0200629DEFUN_USRATTR(cfg_mgcp_rtp_no_net_bind_ip_probing,
630 cfg_mgcp_rtp_no_net_bind_ip_probing_cmd,
631 X(MGW_CMD_ATTR_NEWCONN),
632 "no rtp ip-probing",
633 NO_STR RTP_STR "no automatic rtp bind ip selection\n")
Philipp Maier1cb1e382017-11-02 17:16:04 +0100634{
635 g_cfg->net_ports.bind_addr_probe = false;
636 return CMD_SUCCESS;
637}
638
Philipp Maier19c430f2020-09-22 15:52:50 +0200639DEFUN_USRATTR(cfg_mgcp_rtp_ip_dscp,
640 cfg_mgcp_rtp_ip_dscp_cmd,
641 X(MGW_CMD_ATTR_NEWCONN),
Harald Welte5936a9c2021-04-27 22:30:52 +0200642 "rtp ip-dscp <0-63>",
Philipp Maier19c430f2020-09-22 15:52:50 +0200643 RTP_STR
Harald Welte5936a9c2021-04-27 22:30:52 +0200644 "Use specified DSCP for the audio stream (including Osmux)\n" "The DSCP value\n")
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200645{
646 int dscp = atoi(argv[0]);
647 g_cfg->endp_dscp = dscp;
648 return CMD_SUCCESS;
649}
650
Harald Welte55a92292021-04-28 19:06:34 +0200651DEFUN_USRATTR(cfg_mgcp_rtp_priority,
652 cfg_mgcp_rtp_priority_cmd,
653 X(MGW_CMD_ATTR_NEWCONN),
654 "rtp socket-priority <0-255>",
655 RTP_STR
656 "socket priority (values > 6 require CAP_NET_ADMIN)\n" "socket priority value\n")
657{
658 int prio = atoi(argv[0]);
659 g_cfg->endp_priority = prio;
660 return CMD_SUCCESS;
661}
662
Philipp Maier87bd9be2017-08-22 16:35:41 +0200663#define FORCE_PTIME_STR "Force a fixed ptime for packets sent"
Philipp Maier19c430f2020-09-22 15:52:50 +0200664DEFUN_USRATTR(cfg_mgcp_rtp_force_ptime,
665 cfg_mgcp_rtp_force_ptime_cmd,
666 X(MGW_CMD_ATTR_NEWCONN),
667 "rtp force-ptime (10|20|40)",
668 RTP_STR FORCE_PTIME_STR
669 "The required ptime (packet duration) in ms\n" "10 ms\n20 ms\n40 ms\n")
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200670{
Philipp Maier87bd9be2017-08-22 16:35:41 +0200671 g_cfg->force_ptime = atoi(argv[0]);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200672 return CMD_SUCCESS;
673}
674
Philipp Maier19c430f2020-09-22 15:52:50 +0200675DEFUN_USRATTR(cfg_mgcp_no_rtp_force_ptime,
676 cfg_mgcp_no_rtp_force_ptime_cmd,
677 X(MGW_CMD_ATTR_NEWCONN),
678 "no rtp force-ptime", NO_STR RTP_STR FORCE_PTIME_STR)
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200679{
Philipp Maier87bd9be2017-08-22 16:35:41 +0200680 g_cfg->force_ptime = 0;
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200681 return CMD_SUCCESS;
682}
683
Philipp Maier19c430f2020-09-22 15:52:50 +0200684DEFUN_USRATTR(cfg_mgcp_sdp_fmtp_extra,
685 cfg_mgcp_sdp_fmtp_extra_cmd,
686 X(MGW_CMD_ATTR_NEWCONN),
687 "sdp audio fmtp-extra .NAME",
688 "Add extra fmtp for the SDP file\n" "Audio\n" "Fmtp-extra\n"
689 "Extra Information\n")
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200690{
Philipp Maier6fbbeec2020-07-01 23:00:54 +0200691 struct mgcp_trunk *trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_VIRTUAL, MGCP_VIRT_TRUNK_ID);
Philipp Maierd19de2e2020-06-03 13:55:33 +0200692 OSMO_ASSERT(trunk);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200693 char *txt = argv_concat(argv, argc, 0);
694 if (!txt)
695 return CMD_WARNING;
696
Philipp Maierd19de2e2020-06-03 13:55:33 +0200697 osmo_talloc_replace_string(g_cfg, &trunk->audio_fmtp_extra, txt);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200698 talloc_free(txt);
699 return CMD_SUCCESS;
700}
701
Philipp Maier4c4d2272023-04-26 15:45:17 +0200702DEFUN_DEPRECATED(cfg_mgcp_allow_transcoding,
703 cfg_mgcp_allow_transcoding_cmd,
704 "allow-transcoding", "Allow transcoding\n")
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200705{
Philipp Maier4c4d2272023-04-26 15:45:17 +0200706 vty_out(vty, "%% Deprecated 'allow-transcoding' config no longer has any effect%s", VTY_NEWLINE);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200707 return CMD_SUCCESS;
708}
709
Philipp Maier4c4d2272023-04-26 15:45:17 +0200710DEFUN_DEPRECATED(cfg_mgcp_no_allow_transcoding,
711 cfg_mgcp_no_allow_transcoding_cmd,
712 "no allow-transcoding", NO_STR "Allow transcoding\n")
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200713{
Philipp Maier4c4d2272023-04-26 15:45:17 +0200714 vty_out(vty, "%% Deprecated 'no allow-transcoding' config no longer has any effect%s", VTY_NEWLINE);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200715 return CMD_SUCCESS;
716}
717
718#define SDP_STR "SDP File related options\n"
719#define AUDIO_STR "Audio payload options\n"
Philipp Maier7f90ddb2020-06-02 21:52:53 +0200720DEFUN_DEPRECATED(cfg_mgcp_sdp_payload_number,
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200721 cfg_mgcp_sdp_payload_number_cmd,
722 "sdp audio-payload number <0-255>",
Philipp Maier87bd9be2017-08-22 16:35:41 +0200723 SDP_STR AUDIO_STR "Number\n" "Payload number\n")
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200724{
Philipp Maier72761b32023-04-06 16:04:12 +0200725 vty_out(vty, "%% Deprecated 'sdp audio-payload number <0-255>' config no longer has any effect%s", VTY_NEWLINE);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200726 return CMD_SUCCESS;
727}
728
Philipp Maier87bd9be2017-08-22 16:35:41 +0200729ALIAS_DEPRECATED(cfg_mgcp_sdp_payload_number,
730 cfg_mgcp_sdp_payload_number_cmd_old,
731 "sdp audio payload number <0-255>",
732 SDP_STR AUDIO_STR AUDIO_STR "Number\n" "Payload number\n")
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200733
Philipp Maier7f90ddb2020-06-02 21:52:53 +0200734DEFUN_DEPRECATED(cfg_mgcp_sdp_payload_name,
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200735 cfg_mgcp_sdp_payload_name_cmd,
736 "sdp audio-payload name NAME",
737 SDP_STR AUDIO_STR "Name\n" "Payload name\n")
738{
Philipp Maier72761b32023-04-06 16:04:12 +0200739 vty_out(vty, "%% Deprecated 'sdp audio-payload name NAME' config no longer has any effect%s", VTY_NEWLINE);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200740 return CMD_SUCCESS;
741}
742
743ALIAS_DEPRECATED(cfg_mgcp_sdp_payload_name, cfg_mgcp_sdp_payload_name_cmd_old,
Philipp Maier87bd9be2017-08-22 16:35:41 +0200744 "sdp audio payload name NAME",
745 SDP_STR AUDIO_STR AUDIO_STR "Name\n" "Payload name\n")
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200746
Philipp Maier19c430f2020-09-22 15:52:50 +0200747DEFUN_USRATTR(cfg_mgcp_sdp_payload_send_ptime,
748 cfg_mgcp_sdp_payload_send_ptime_cmd,
749 X(MGW_CMD_ATTR_NEWCONN),
750 "sdp audio-payload send-ptime",
751 SDP_STR AUDIO_STR "Send SDP ptime (packet duration) attribute\n")
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200752{
Philipp Maier6fbbeec2020-07-01 23:00:54 +0200753 struct mgcp_trunk *trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_VIRTUAL, MGCP_VIRT_TRUNK_ID);
Philipp Maierd19de2e2020-06-03 13:55:33 +0200754 OSMO_ASSERT(trunk);
755 trunk->audio_send_ptime = 1;
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200756 return CMD_SUCCESS;
757}
758
Philipp Maier19c430f2020-09-22 15:52:50 +0200759DEFUN_USRATTR(cfg_mgcp_no_sdp_payload_send_ptime,
760 cfg_mgcp_no_sdp_payload_send_ptime_cmd,
761 X(MGW_CMD_ATTR_NEWCONN),
762 "no sdp audio-payload send-ptime",
763 NO_STR SDP_STR AUDIO_STR "Send SDP ptime (packet duration) attribute\n")
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200764{
Philipp Maier6fbbeec2020-07-01 23:00:54 +0200765 struct mgcp_trunk *trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_VIRTUAL, MGCP_VIRT_TRUNK_ID);
Philipp Maierd19de2e2020-06-03 13:55:33 +0200766 OSMO_ASSERT(trunk);
767 trunk->audio_send_ptime = 0;
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200768 return CMD_SUCCESS;
769}
770
Philipp Maier19c430f2020-09-22 15:52:50 +0200771DEFUN_USRATTR(cfg_mgcp_sdp_payload_send_name,
772 cfg_mgcp_sdp_payload_send_name_cmd,
773 X(MGW_CMD_ATTR_NEWCONN),
774 "sdp audio-payload send-name",
775 SDP_STR AUDIO_STR "Send SDP rtpmap with the audio name\n")
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200776{
Philipp Maier6fbbeec2020-07-01 23:00:54 +0200777 struct mgcp_trunk *trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_VIRTUAL, MGCP_VIRT_TRUNK_ID);
Philipp Maierd19de2e2020-06-03 13:55:33 +0200778 OSMO_ASSERT(trunk);
779 trunk->audio_send_name = 1;
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200780 return CMD_SUCCESS;
781}
782
Philipp Maier19c430f2020-09-22 15:52:50 +0200783DEFUN_USRATTR(cfg_mgcp_no_sdp_payload_send_name,
784 cfg_mgcp_no_sdp_payload_send_name_cmd,
785 X(MGW_CMD_ATTR_NEWCONN),
786 "no sdp audio-payload send-name",
787 NO_STR SDP_STR AUDIO_STR "Send SDP rtpmap with the audio name\n")
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200788{
Philipp Maier6fbbeec2020-07-01 23:00:54 +0200789 struct mgcp_trunk *trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_VIRTUAL, MGCP_VIRT_TRUNK_ID);
Philipp Maierd19de2e2020-06-03 13:55:33 +0200790 OSMO_ASSERT(trunk);
791 trunk->audio_send_name = 0;
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200792 return CMD_SUCCESS;
793}
794
Philipp Maierba94b6d2020-09-22 16:14:32 +0200795DEFUN_DEPRECATED(cfg_mgcp_loop,
796 cfg_mgcp_loop_cmd,
797 "loop (0|1)",
798 "Loop audio for all endpoints on main trunk\n" "Don't Loop\n" "Loop\n")
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200799{
Philipp Maier72761b32023-04-06 16:04:12 +0200800 vty_out(vty, "%% Deprecated 'loop (0|1)' config no longer has any effect%s", VTY_NEWLINE);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200801 return CMD_SUCCESS;
802}
803
Philipp Maier19c430f2020-09-22 15:52:50 +0200804DEFUN_USRATTR(cfg_mgcp_force_realloc,
805 cfg_mgcp_force_realloc_cmd,
806 X(MGW_CMD_ATTR_NEWCONN),
807 "force-realloc (0|1)",
808 "Force endpoint reallocation when the endpoint is still seized\n"
809 "Don't force reallocation\n" "force reallocation\n")
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200810{
Philipp Maier6fbbeec2020-07-01 23:00:54 +0200811 struct mgcp_trunk *trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_VIRTUAL, MGCP_VIRT_TRUNK_ID);
Philipp Maierd19de2e2020-06-03 13:55:33 +0200812 OSMO_ASSERT(trunk);
813 trunk->force_realloc = atoi(argv[0]);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200814 return CMD_SUCCESS;
815}
816
Philipp Maier19c430f2020-09-22 15:52:50 +0200817DEFUN_ATTR(cfg_mgcp_rtp_accept_all,
818 cfg_mgcp_rtp_accept_all_cmd,
819 "rtp-accept-all (0|1)",
820 "Accept all RTP packets, even when the originating IP/Port does not match\n"
821 "enable filter\n" "disable filter\n",
822 CMD_ATTR_IMMEDIATE)
Philipp Maier87bd9be2017-08-22 16:35:41 +0200823{
Philipp Maier6fbbeec2020-07-01 23:00:54 +0200824 struct mgcp_trunk *trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_VIRTUAL, MGCP_VIRT_TRUNK_ID);
Philipp Maierd19de2e2020-06-03 13:55:33 +0200825 OSMO_ASSERT(trunk);
826 trunk->rtp_accept_all = atoi(argv[0]);
Philipp Maier87bd9be2017-08-22 16:35:41 +0200827 return CMD_SUCCESS;
828}
829
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200830DEFUN(cfg_mgcp_number_endp,
831 cfg_mgcp_number_endp_cmd,
Philipp Maier869b21c2020-07-03 16:04:16 +0200832 "number endpoints <1-65534>",
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200833 "Number options\n" "Endpoints available\n" "Number endpoints\n")
834{
Philipp Maier6fbbeec2020-07-01 23:00:54 +0200835 struct mgcp_trunk *trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_VIRTUAL, MGCP_VIRT_TRUNK_ID);
Philipp Maierd19de2e2020-06-03 13:55:33 +0200836 OSMO_ASSERT(trunk);
Philipp Maier889fe7f2020-07-06 17:44:12 +0200837 trunk->v.vty_number_endpoints = atoi(argv[0]);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200838 return CMD_SUCCESS;
839}
840
Philipp Maier19c430f2020-09-22 15:52:50 +0200841DEFUN_ATTR(cfg_mgcp_omit_rtcp,
842 cfg_mgcp_omit_rtcp_cmd,
843 "rtcp-omit", RTCP_OMIT_STR,
844 CMD_ATTR_IMMEDIATE)
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200845{
Philipp Maier6fbbeec2020-07-01 23:00:54 +0200846 struct mgcp_trunk *trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_VIRTUAL, MGCP_VIRT_TRUNK_ID);
Philipp Maierd19de2e2020-06-03 13:55:33 +0200847 trunk->omit_rtcp = 1;
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200848 return CMD_SUCCESS;
849}
850
Philipp Maier19c430f2020-09-22 15:52:50 +0200851DEFUN_ATTR(cfg_mgcp_no_omit_rtcp,
852 cfg_mgcp_no_omit_rtcp_cmd,
853 "no rtcp-omit",
854 NO_STR RTCP_OMIT_STR,
855 CMD_ATTR_IMMEDIATE)
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200856{
Philipp Maier6fbbeec2020-07-01 23:00:54 +0200857 struct mgcp_trunk *trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_VIRTUAL, MGCP_VIRT_TRUNK_ID);
Philipp Maierd19de2e2020-06-03 13:55:33 +0200858 OSMO_ASSERT(trunk);
859 trunk->omit_rtcp = 0;
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200860 return CMD_SUCCESS;
861}
862
Philipp Maier19c430f2020-09-22 15:52:50 +0200863DEFUN_USRATTR(cfg_mgcp_patch_rtp_ssrc,
864 cfg_mgcp_patch_rtp_ssrc_cmd,
865 X(MGW_CMD_ATTR_NEWCONN),
866 "rtp-patch ssrc", RTP_PATCH_STR "Force a fixed SSRC\n")
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200867{
Philipp Maier6fbbeec2020-07-01 23:00:54 +0200868 struct mgcp_trunk *trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_VIRTUAL, MGCP_VIRT_TRUNK_ID);
Philipp Maierd19de2e2020-06-03 13:55:33 +0200869 OSMO_ASSERT(trunk);
870 trunk->force_constant_ssrc = 1;
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200871 return CMD_SUCCESS;
872}
873
Philipp Maier19c430f2020-09-22 15:52:50 +0200874DEFUN_USRATTR(cfg_mgcp_no_patch_rtp_ssrc,
875 cfg_mgcp_no_patch_rtp_ssrc_cmd,
876 X(MGW_CMD_ATTR_NEWCONN),
877 "no rtp-patch ssrc", NO_STR RTP_PATCH_STR "Force a fixed SSRC\n")
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200878{
Philipp Maier6fbbeec2020-07-01 23:00:54 +0200879 struct mgcp_trunk *trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_VIRTUAL, MGCP_VIRT_TRUNK_ID);
Philipp Maierd19de2e2020-06-03 13:55:33 +0200880 OSMO_ASSERT(trunk);
881 trunk->force_constant_ssrc = 0;
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200882 return CMD_SUCCESS;
883}
884
Philipp Maier19c430f2020-09-22 15:52:50 +0200885DEFUN_USRATTR(cfg_mgcp_patch_rtp_ts,
886 cfg_mgcp_patch_rtp_ts_cmd,
887 X(MGW_CMD_ATTR_NEWCONN),
888 "rtp-patch timestamp", RTP_PATCH_STR "Adjust RTP timestamp\n")
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200889{
Philipp Maier6fbbeec2020-07-01 23:00:54 +0200890 struct mgcp_trunk *trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_VIRTUAL, MGCP_VIRT_TRUNK_ID);
Philipp Maierd19de2e2020-06-03 13:55:33 +0200891 OSMO_ASSERT(trunk);
892 trunk->force_aligned_timing = 1;
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200893 return CMD_SUCCESS;
894}
895
Philipp Maier19c430f2020-09-22 15:52:50 +0200896DEFUN_USRATTR(cfg_mgcp_no_patch_rtp_ts,
897 cfg_mgcp_no_patch_rtp_ts_cmd,
898 X(MGW_CMD_ATTR_NEWCONN),
899 "no rtp-patch timestamp", NO_STR RTP_PATCH_STR "Adjust RTP timestamp\n")
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200900{
Philipp Maier6fbbeec2020-07-01 23:00:54 +0200901 struct mgcp_trunk *trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_VIRTUAL, MGCP_VIRT_TRUNK_ID);
Philipp Maierd19de2e2020-06-03 13:55:33 +0200902 OSMO_ASSERT(trunk);
903 trunk->force_aligned_timing = 0;
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200904 return CMD_SUCCESS;
905}
906
Philipp Maier19c430f2020-09-22 15:52:50 +0200907DEFUN_USRATTR(cfg_mgcp_patch_rtp_rfc5993hr,
908 cfg_mgcp_patch_rtp_rfc5993hr_cmd,
909 X(MGW_CMD_ATTR_NEWCONN),
910 "rtp-patch rfc5993hr", RTP_PATCH_STR RTP_TS101318_RFC5993_CONV_STR)
Philipp Maier9fc8a022019-02-20 12:26:52 +0100911{
Philipp Maier6fbbeec2020-07-01 23:00:54 +0200912 struct mgcp_trunk *trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_VIRTUAL, MGCP_VIRT_TRUNK_ID);
Philipp Maierd19de2e2020-06-03 13:55:33 +0200913 OSMO_ASSERT(trunk);
914 trunk->rfc5993_hr_convert = true;
Philipp Maier9fc8a022019-02-20 12:26:52 +0100915 return CMD_SUCCESS;
916}
917
Philipp Maier19c430f2020-09-22 15:52:50 +0200918DEFUN_USRATTR(cfg_mgcp_no_patch_rtp_rfc5993hr,
919 cfg_mgcp_no_patch_rtp_rfc5993hr_cmd,
920 X(MGW_CMD_ATTR_NEWCONN),
921 "no rtp-patch rfc5993hr", NO_STR RTP_PATCH_STR RTP_TS101318_RFC5993_CONV_STR)
Philipp Maier9fc8a022019-02-20 12:26:52 +0100922{
Philipp Maier6fbbeec2020-07-01 23:00:54 +0200923 struct mgcp_trunk *trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_VIRTUAL, MGCP_VIRT_TRUNK_ID);
Philipp Maierd19de2e2020-06-03 13:55:33 +0200924 OSMO_ASSERT(trunk);
925 trunk->rfc5993_hr_convert = false;
Philipp Maier9fc8a022019-02-20 12:26:52 +0100926 return CMD_SUCCESS;
927}
928
Philipp Maier19c430f2020-09-22 15:52:50 +0200929DEFUN_USRATTR(cfg_mgcp_no_patch_rtp,
930 cfg_mgcp_no_patch_rtp_cmd,
931 X(MGW_CMD_ATTR_NEWCONN),
932 "no rtp-patch", NO_STR RTP_PATCH_STR)
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200933{
Philipp Maier6fbbeec2020-07-01 23:00:54 +0200934 struct mgcp_trunk *trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_VIRTUAL, MGCP_VIRT_TRUNK_ID);
Philipp Maierd19de2e2020-06-03 13:55:33 +0200935 OSMO_ASSERT(trunk);
936 trunk->force_constant_ssrc = 0;
937 trunk->force_aligned_timing = 0;
938 trunk->rfc5993_hr_convert = false;
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200939 return CMD_SUCCESS;
940}
941
Philipp Maier19c430f2020-09-22 15:52:50 +0200942DEFUN_ATTR(cfg_mgcp_rtp_keepalive,
943 cfg_mgcp_rtp_keepalive_cmd,
944 "rtp keep-alive <1-120>",
945 RTP_STR RTP_KEEPALIVE_STR "Keep alive interval in secs\n",
946 CMD_ATTR_IMMEDIATE)
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200947{
Philipp Maier6fbbeec2020-07-01 23:00:54 +0200948 struct mgcp_trunk *trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_VIRTUAL, MGCP_VIRT_TRUNK_ID);
Philipp Maierd19de2e2020-06-03 13:55:33 +0200949 OSMO_ASSERT(trunk);
950 mgcp_trunk_set_keepalive(trunk, atoi(argv[0]));
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200951 return CMD_SUCCESS;
952}
953
Philipp Maier19c430f2020-09-22 15:52:50 +0200954DEFUN_ATTR(cfg_mgcp_rtp_keepalive_once,
955 cfg_mgcp_rtp_keepalive_once_cmd,
956 "rtp keep-alive once",
957 RTP_STR RTP_KEEPALIVE_STR "Send dummy packet only once after CRCX/MDCX\n",
958 CMD_ATTR_IMMEDIATE)
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200959{
Philipp Maier6fbbeec2020-07-01 23:00:54 +0200960 struct mgcp_trunk *trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_VIRTUAL, MGCP_VIRT_TRUNK_ID);
Philipp Maierd19de2e2020-06-03 13:55:33 +0200961 OSMO_ASSERT(trunk);
962 mgcp_trunk_set_keepalive(trunk, MGCP_KEEPALIVE_ONCE);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200963 return CMD_SUCCESS;
964}
965
Philipp Maier19c430f2020-09-22 15:52:50 +0200966DEFUN_ATTR(cfg_mgcp_no_rtp_keepalive,
967 cfg_mgcp_no_rtp_keepalive_cmd,
968 "no rtp keep-alive", NO_STR RTP_STR RTP_KEEPALIVE_STR,
969 CMD_ATTR_IMMEDIATE)
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200970{
Philipp Maier6fbbeec2020-07-01 23:00:54 +0200971 struct mgcp_trunk *trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_VIRTUAL, MGCP_VIRT_TRUNK_ID);
Philipp Maierd19de2e2020-06-03 13:55:33 +0200972 OSMO_ASSERT(trunk);
973 mgcp_trunk_set_keepalive(trunk, MGCP_KEEPALIVE_NEVER);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200974 return CMD_SUCCESS;
975}
976
Pau Espin Pedrola790f0c2020-08-31 13:29:11 +0200977#define CALL_AGENT_STR "Call agent information\n"
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200978DEFUN(cfg_mgcp_agent_addr,
979 cfg_mgcp_agent_addr_cmd,
Pau Espin Pedrola790f0c2020-08-31 13:29:11 +0200980 "call-agent ip " VTY_IPV46_CMD,
981 CALL_AGENT_STR IP_STR
982 "IPv4 Address of the call agent\n"
983 "IPv6 Address of the call agent\n")
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200984{
Eric2764bdb2021-08-23 22:11:47 +0200985 osmo_strlcpy(g_cfg->call_agent_addr, argv[0], sizeof(g_cfg->call_agent_addr));
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200986 return CMD_SUCCESS;
987}
988
989ALIAS_DEPRECATED(cfg_mgcp_agent_addr, cfg_mgcp_agent_addr_cmd_old,
Philipp Maier87bd9be2017-08-22 16:35:41 +0200990 "call agent ip A.B.C.D",
991 CALL_AGENT_STR CALL_AGENT_STR IP_STR
992 "IPv4 Address of the callagent\n")
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200993
Philipp Maier21be42a2020-05-29 21:39:48 +0200994DEFUN(cfg_mgcp_trunk, cfg_mgcp_trunk_cmd,
Philipp Maier0653cc82020-08-10 22:52:51 +0200995 "trunk <0-64>", "Configure a SS7 trunk\n" "Trunk Nr\n")
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200996{
Philipp Maier14b27a82020-06-02 20:15:30 +0200997 struct mgcp_trunk *trunk;
Philipp Maierd70eef62021-07-19 13:53:28 +0200998 unsigned int index = atoi(argv[0]);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +0200999
Philipp Maier6fbbeec2020-07-01 23:00:54 +02001000 trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_E1, index);
Harald Weltec39b1bf2020-03-08 11:29:39 +01001001 if (!trunk) {
1002 trunk = mgcp_trunk_alloc(g_cfg, MGCP_TRUNK_E1, index);
Philipp Maier2d681fd2020-05-29 16:20:25 +02001003 if (!trunk) {
1004 vty_out(vty, "%%Unable to allocate trunk %u.%s",
1005 index, VTY_NEWLINE);
Harald Weltec39b1bf2020-03-08 11:29:39 +01001006 return CMD_WARNING;
Philipp Maier2d681fd2020-05-29 16:20:25 +02001007 }
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001008 }
1009
1010 vty->node = TRUNK_NODE;
1011 vty->index = trunk;
1012 return CMD_SUCCESS;
1013}
1014
1015static int config_write_trunk(struct vty *vty)
1016{
Philipp Maier14b27a82020-06-02 20:15:30 +02001017 struct mgcp_trunk *trunk;
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001018
1019 llist_for_each_entry(trunk, &g_cfg->trunks, entry) {
Philipp Maierd19de2e2020-06-03 13:55:33 +02001020
1021 /* Due to historical reasons, the virtual trunk is configured
1022 using separate VTY parameters, so we omit writing the trunk
1023 config of trunk 0 here. The configuration for the virtual
1024 trunk is written by config_write_mgcp(). */
1025
Philipp Maier31682a32020-11-26 00:39:35 +01001026 if (trunk->trunk_type == MGCP_TRUNK_VIRTUAL
1027 && trunk->trunk_nr == MGCP_VIRT_TRUNK_ID)
Philipp Maierd19de2e2020-06-03 13:55:33 +02001028 continue;
1029
Philipp Maierd70eef62021-07-19 13:53:28 +02001030 vty_out(vty, " trunk %u%s", trunk->trunk_nr, VTY_NEWLINE);
Philipp Maier889fe7f2020-07-06 17:44:12 +02001031 vty_out(vty, " line %u%s", trunk->e1.vty_line_nr, VTY_NEWLINE);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001032 vty_out(vty, " %ssdp audio-payload send-ptime%s",
1033 trunk->audio_send_ptime ? "" : "no ", VTY_NEWLINE);
1034 vty_out(vty, " %ssdp audio-payload send-name%s",
1035 trunk->audio_send_name ? "" : "no ", VTY_NEWLINE);
1036
1037 if (trunk->keepalive_interval == MGCP_KEEPALIVE_ONCE)
1038 vty_out(vty, " rtp keep-alive once%s", VTY_NEWLINE);
1039 else if (trunk->keepalive_interval)
1040 vty_out(vty, " rtp keep-alive %d%s",
1041 trunk->keepalive_interval, VTY_NEWLINE);
1042 else
1043 vty_out(vty, " no rtp keep-alive%s", VTY_NEWLINE);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001044 vty_out(vty, " force-realloc %d%s",
1045 trunk->force_realloc, VTY_NEWLINE);
Philipp Maier87bd9be2017-08-22 16:35:41 +02001046 vty_out(vty, " rtp-accept-all %d%s",
1047 trunk->rtp_accept_all, VTY_NEWLINE);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001048 if (trunk->omit_rtcp)
1049 vty_out(vty, " rtcp-omit%s", VTY_NEWLINE);
1050 else
1051 vty_out(vty, " no rtcp-omit%s", VTY_NEWLINE);
Philipp Maier9fc8a022019-02-20 12:26:52 +01001052 if (trunk->force_constant_ssrc || trunk->force_aligned_timing
Philipp Maierd19de2e2020-06-03 13:55:33 +02001053 || trunk->rfc5993_hr_convert) {
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001054 vty_out(vty, " %srtp-patch ssrc%s",
Philipp Maier87bd9be2017-08-22 16:35:41 +02001055 trunk->force_constant_ssrc ? "" : "no ",
1056 VTY_NEWLINE);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001057 vty_out(vty, " %srtp-patch timestamp%s",
Philipp Maier87bd9be2017-08-22 16:35:41 +02001058 trunk->force_aligned_timing ? "" : "no ",
1059 VTY_NEWLINE);
Philipp Maier9fc8a022019-02-20 12:26:52 +01001060 vty_out(vty, " %srtp-patch rfc5993hr%s",
1061 trunk->rfc5993_hr_convert ? "" : "no ",
1062 VTY_NEWLINE);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001063 } else
1064 vty_out(vty, " no rtp-patch%s", VTY_NEWLINE);
1065 if (trunk->audio_fmtp_extra)
1066 vty_out(vty, " sdp audio fmtp-extra %s%s",
1067 trunk->audio_fmtp_extra, VTY_NEWLINE);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001068 }
1069
1070 return CMD_SUCCESS;
1071}
1072
Philipp Maier19c430f2020-09-22 15:52:50 +02001073DEFUN_USRATTR(cfg_trunk_sdp_fmtp_extra,
1074 cfg_trunk_sdp_fmtp_extra_cmd,
1075 X(MGW_CMD_ATTR_NEWCONN),
1076 "sdp audio fmtp-extra .NAME",
1077 "Add extra fmtp for the SDP file\n" "Audio\n" "Fmtp-extra\n"
1078 "Extra Information\n")
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001079{
Philipp Maier14b27a82020-06-02 20:15:30 +02001080 struct mgcp_trunk *trunk = vty->index;
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001081 char *txt = argv_concat(argv, argc, 0);
1082 if (!txt)
1083 return CMD_WARNING;
1084
1085 osmo_talloc_replace_string(g_cfg, &trunk->audio_fmtp_extra, txt);
1086 talloc_free(txt);
1087 return CMD_SUCCESS;
1088}
1089
Philipp Maier7f90ddb2020-06-02 21:52:53 +02001090DEFUN_DEPRECATED(cfg_trunk_payload_number,
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001091 cfg_trunk_payload_number_cmd,
1092 "sdp audio-payload number <0-255>",
1093 SDP_STR AUDIO_STR "Number\n" "Payload Number\n")
1094{
Philipp Maier72761b32023-04-06 16:04:12 +02001095 vty_out(vty, "%% Deprecated 'sdp audio-payload number <0-255>' config no longer has any effect%s", VTY_NEWLINE);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001096 return CMD_SUCCESS;
1097}
1098
1099ALIAS_DEPRECATED(cfg_trunk_payload_number, cfg_trunk_payload_number_cmd_old,
Philipp Maier87bd9be2017-08-22 16:35:41 +02001100 "sdp audio payload number <0-255>",
1101 SDP_STR AUDIO_STR AUDIO_STR "Number\n" "Payload Number\n")
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001102
Philipp Maier7f90ddb2020-06-02 21:52:53 +02001103DEFUN_DEPRECATED(cfg_trunk_payload_name,
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001104 cfg_trunk_payload_name_cmd,
1105 "sdp audio-payload name NAME",
Philipp Maier87bd9be2017-08-22 16:35:41 +02001106 SDP_STR AUDIO_STR "Payload\n" "Payload Name\n")
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001107{
Philipp Maier72761b32023-04-06 16:04:12 +02001108 vty_out(vty, "%% Deprecated 'sdp audio-payload name NAME' config no longer has any effect%s", VTY_NEWLINE);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001109 return CMD_SUCCESS;
1110}
1111
1112ALIAS_DEPRECATED(cfg_trunk_payload_name, cfg_trunk_payload_name_cmd_old,
Philipp Maier87bd9be2017-08-22 16:35:41 +02001113 "sdp audio payload name NAME",
1114 SDP_STR AUDIO_STR AUDIO_STR "Payload\n" "Payload Name\n")
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001115
Philipp Maierba94b6d2020-09-22 16:14:32 +02001116DEFUN_DEPRECATED(cfg_trunk_loop,
1117 cfg_trunk_loop_cmd,
1118 "loop (0|1)",
1119 "Loop audio for all endpoints on this trunk\n" "Don't Loop\n" "Loop\n")
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001120{
Philipp Maier72761b32023-04-06 16:04:12 +02001121 vty_out(vty, "%% Deprecated 'loop (0|1)' config no longer has any effect%s", VTY_NEWLINE);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001122 return CMD_SUCCESS;
1123}
1124
Philipp Maier41425e92020-11-26 00:41:59 +01001125DEFUN_USRATTR(cfg_trunk_force_realloc,
1126 cfg_trunk_force_realloc_cmd,
1127 X(MGW_CMD_ATTR_NEWCONN),
1128 "force-realloc (0|1)",
1129 "Force endpoint reallocation when the endpoint is still seized\n"
1130 "Don't force reallocation\n" "force reallocation\n")
1131{
1132 struct mgcp_trunk *trunk = vty->index;
1133 OSMO_ASSERT(trunk);
1134 trunk->force_realloc = atoi(argv[0]);
1135 return CMD_SUCCESS;
1136}
1137
1138DEFUN_ATTR(cfg_trunk_rtp_accept_all,
1139 cfg_trunk_rtp_accept_all_cmd,
1140 "rtp-accept-all (0|1)",
1141 "Accept all RTP packets, even when the originating IP/Port does not match\n"
1142 "enable filter\n" "disable filter\n",
1143 CMD_ATTR_IMMEDIATE)
1144{
1145 struct mgcp_trunk *trunk = vty->index;
1146 OSMO_ASSERT(trunk);
1147 trunk->rtp_accept_all = atoi(argv[0]);
1148 return CMD_SUCCESS;
1149}
1150
Philipp Maier19c430f2020-09-22 15:52:50 +02001151DEFUN_USRATTR(cfg_trunk_sdp_payload_send_ptime,
1152 cfg_trunk_sdp_payload_send_ptime_cmd,
1153 X(MGW_CMD_ATTR_NEWCONN),
1154 "sdp audio-payload send-ptime",
1155 SDP_STR AUDIO_STR "Send SDP ptime (packet duration) attribute\n")
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001156{
Philipp Maier14b27a82020-06-02 20:15:30 +02001157 struct mgcp_trunk *trunk = vty->index;
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001158 trunk->audio_send_ptime = 1;
1159 return CMD_SUCCESS;
1160}
1161
Philipp Maier19c430f2020-09-22 15:52:50 +02001162DEFUN_USRATTR(cfg_trunk_no_sdp_payload_send_ptime,
1163 cfg_trunk_no_sdp_payload_send_ptime_cmd,
1164 X(MGW_CMD_ATTR_NEWCONN),
1165 "no sdp audio-payload send-ptime",
1166 NO_STR SDP_STR AUDIO_STR "Send SDP ptime (packet duration) attribute\n")
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001167{
Philipp Maier14b27a82020-06-02 20:15:30 +02001168 struct mgcp_trunk *trunk = vty->index;
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001169 trunk->audio_send_ptime = 0;
1170 return CMD_SUCCESS;
1171}
1172
Philipp Maier19c430f2020-09-22 15:52:50 +02001173DEFUN_USRATTR(cfg_trunk_sdp_payload_send_name,
1174 cfg_trunk_sdp_payload_send_name_cmd,
1175 X(MGW_CMD_ATTR_NEWCONN),
1176 "sdp audio-payload send-name",
1177 SDP_STR AUDIO_STR "Send SDP rtpmap with the audio name\n")
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001178{
Philipp Maier14b27a82020-06-02 20:15:30 +02001179 struct mgcp_trunk *trunk = vty->index;
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001180 trunk->audio_send_name = 1;
1181 return CMD_SUCCESS;
1182}
1183
Philipp Maier19c430f2020-09-22 15:52:50 +02001184DEFUN_USRATTR(cfg_trunk_no_sdp_payload_send_name,
1185 cfg_trunk_no_sdp_payload_send_name_cmd,
1186 X(MGW_CMD_ATTR_NEWCONN),
1187 "no sdp audio-payload send-name",
1188 NO_STR SDP_STR AUDIO_STR "Send SDP rtpmap with the audio name\n")
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001189{
Philipp Maier14b27a82020-06-02 20:15:30 +02001190 struct mgcp_trunk *trunk = vty->index;
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001191 trunk->audio_send_name = 0;
1192 return CMD_SUCCESS;
1193}
1194
Philipp Maier19c430f2020-09-22 15:52:50 +02001195DEFUN_ATTR(cfg_trunk_omit_rtcp,
1196 cfg_trunk_omit_rtcp_cmd,
1197 "rtcp-omit", RTCP_OMIT_STR,
1198 CMD_ATTR_IMMEDIATE)
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001199{
Philipp Maier14b27a82020-06-02 20:15:30 +02001200 struct mgcp_trunk *trunk = vty->index;
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001201 trunk->omit_rtcp = 1;
1202 return CMD_SUCCESS;
1203}
1204
Philipp Maier19c430f2020-09-22 15:52:50 +02001205DEFUN_ATTR(cfg_trunk_no_omit_rtcp,
1206 cfg_trunk_no_omit_rtcp_cmd,
1207 "no rtcp-omit", NO_STR RTCP_OMIT_STR,
1208 CMD_ATTR_IMMEDIATE)
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001209{
Philipp Maier14b27a82020-06-02 20:15:30 +02001210 struct mgcp_trunk *trunk = vty->index;
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001211 trunk->omit_rtcp = 0;
1212 return CMD_SUCCESS;
1213}
1214
Philipp Maier19c430f2020-09-22 15:52:50 +02001215DEFUN_USRATTR(cfg_trunk_patch_rtp_ssrc,
1216 cfg_trunk_patch_rtp_ssrc_cmd,
1217 X(MGW_CMD_ATTR_NEWCONN),
1218 "rtp-patch ssrc", RTP_PATCH_STR "Force a fixed SSRC\n")
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001219{
Philipp Maier14b27a82020-06-02 20:15:30 +02001220 struct mgcp_trunk *trunk = vty->index;
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001221 trunk->force_constant_ssrc = 1;
1222 return CMD_SUCCESS;
1223}
1224
Philipp Maier19c430f2020-09-22 15:52:50 +02001225DEFUN_USRATTR(cfg_trunk_no_patch_rtp_ssrc,
1226 cfg_trunk_no_patch_rtp_ssrc_cmd,
1227 X(MGW_CMD_ATTR_NEWCONN),
1228 "no rtp-patch ssrc", NO_STR RTP_PATCH_STR "Force a fixed SSRC\n")
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001229{
Philipp Maier14b27a82020-06-02 20:15:30 +02001230 struct mgcp_trunk *trunk = vty->index;
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001231 trunk->force_constant_ssrc = 0;
1232 return CMD_SUCCESS;
1233}
1234
Philipp Maier19c430f2020-09-22 15:52:50 +02001235DEFUN_USRATTR(cfg_trunk_patch_rtp_ts,
1236 cfg_trunk_patch_rtp_ts_cmd,
1237 X(MGW_CMD_ATTR_NEWCONN),
1238 "rtp-patch timestamp", RTP_PATCH_STR "Adjust RTP timestamp\n")
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001239{
Philipp Maier14b27a82020-06-02 20:15:30 +02001240 struct mgcp_trunk *trunk = vty->index;
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001241 trunk->force_aligned_timing = 1;
1242 return CMD_SUCCESS;
1243}
1244
Philipp Maier19c430f2020-09-22 15:52:50 +02001245DEFUN_USRATTR(cfg_trunk_no_patch_rtp_ts,
1246 cfg_trunk_no_patch_rtp_ts_cmd,
1247 X(MGW_CMD_ATTR_NEWCONN),
1248 "no rtp-patch timestamp", NO_STR RTP_PATCH_STR "Adjust RTP timestamp\n")
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001249{
Philipp Maier14b27a82020-06-02 20:15:30 +02001250 struct mgcp_trunk *trunk = vty->index;
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001251 trunk->force_aligned_timing = 0;
1252 return CMD_SUCCESS;
1253}
1254
Philipp Maier19c430f2020-09-22 15:52:50 +02001255DEFUN_USRATTR(cfg_trunk_patch_rtp_rfc5993hr,
1256 cfg_trunk_patch_rtp_rfc5993hr_cmd,
1257 X(MGW_CMD_ATTR_NEWCONN),
1258 "rtp-patch rfc5993hr", RTP_PATCH_STR RTP_TS101318_RFC5993_CONV_STR)
Philipp Maier9fc8a022019-02-20 12:26:52 +01001259{
Philipp Maier14b27a82020-06-02 20:15:30 +02001260 struct mgcp_trunk *trunk = vty->index;
Philipp Maier9fc8a022019-02-20 12:26:52 +01001261 trunk->rfc5993_hr_convert = true;
1262 return CMD_SUCCESS;
1263}
1264
Philipp Maier19c430f2020-09-22 15:52:50 +02001265DEFUN_USRATTR(cfg_trunk_no_patch_rtp_rfc5993hr,
1266 cfg_trunk_no_patch_rtp_rfc5993hr_cmd,
1267 X(MGW_CMD_ATTR_NEWCONN),
1268 "no rtp-patch rfc5993hr", NO_STR RTP_PATCH_STR RTP_TS101318_RFC5993_CONV_STR)
Philipp Maier9fc8a022019-02-20 12:26:52 +01001269{
Philipp Maier14b27a82020-06-02 20:15:30 +02001270 struct mgcp_trunk *trunk = vty->index;
Philipp Maier9fc8a022019-02-20 12:26:52 +01001271 trunk->rfc5993_hr_convert = false;
1272 return CMD_SUCCESS;
1273}
1274
Philipp Maier19c430f2020-09-22 15:52:50 +02001275DEFUN_USRATTR(cfg_trunk_no_patch_rtp,
1276 cfg_trunk_no_patch_rtp_cmd,
1277 X(MGW_CMD_ATTR_NEWCONN),
1278 "no rtp-patch", NO_STR RTP_PATCH_STR)
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001279{
Philipp Maier14b27a82020-06-02 20:15:30 +02001280 struct mgcp_trunk *trunk = vty->index;
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001281 trunk->force_constant_ssrc = 0;
1282 trunk->force_aligned_timing = 0;
Philipp Maier9fc8a022019-02-20 12:26:52 +01001283 trunk->rfc5993_hr_convert = false;
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001284 return CMD_SUCCESS;
1285}
1286
Philipp Maier19c430f2020-09-22 15:52:50 +02001287DEFUN_ATTR(cfg_trunk_rtp_keepalive,
1288 cfg_trunk_rtp_keepalive_cmd,
1289 "rtp keep-alive <1-120>",
1290 RTP_STR RTP_KEEPALIVE_STR "Keep-alive interval in secs\n",
1291 CMD_ATTR_IMMEDIATE)
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001292{
Philipp Maier14b27a82020-06-02 20:15:30 +02001293 struct mgcp_trunk *trunk = vty->index;
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001294 mgcp_trunk_set_keepalive(trunk, atoi(argv[0]));
1295 return CMD_SUCCESS;
1296}
1297
Philipp Maier19c430f2020-09-22 15:52:50 +02001298DEFUN_ATTR(cfg_trunk_rtp_keepalive_once,
1299 cfg_trunk_rtp_keepalive_once_cmd,
1300 "rtp keep-alive once",
1301 RTP_STR RTP_KEEPALIVE_STR "Send dummy packet only once after CRCX/MDCX\n",
1302 CMD_ATTR_IMMEDIATE)
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001303{
Philipp Maier14b27a82020-06-02 20:15:30 +02001304 struct mgcp_trunk *trunk = vty->index;
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001305 mgcp_trunk_set_keepalive(trunk, MGCP_KEEPALIVE_ONCE);
1306 return CMD_SUCCESS;
1307}
1308
Philipp Maier19c430f2020-09-22 15:52:50 +02001309DEFUN_ATTR(cfg_trunk_no_rtp_keepalive,
1310 cfg_trunk_no_rtp_keepalive_cmd,
1311 "no rtp keep-alive", NO_STR RTP_STR RTP_KEEPALIVE_STR,
1312 CMD_ATTR_IMMEDIATE)
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001313{
Philipp Maier14b27a82020-06-02 20:15:30 +02001314 struct mgcp_trunk *trunk = vty->index;
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001315 mgcp_trunk_set_keepalive(trunk, 0);
1316 return CMD_SUCCESS;
1317}
1318
Philipp Maier4c4d2272023-04-26 15:45:17 +02001319DEFUN_DEPRECATED(cfg_trunk_allow_transcoding,
1320 cfg_trunk_allow_transcoding_cmd,
1321 "allow-transcoding", "Allow transcoding\n")
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001322{
Philipp Maier4c4d2272023-04-26 15:45:17 +02001323 vty_out(vty, "%% Deprecated 'allow-transcoding' config no longer has any effect%s", VTY_NEWLINE);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001324 return CMD_SUCCESS;
1325}
1326
Philipp Maier4c4d2272023-04-26 15:45:17 +02001327DEFUN_DEPRECATED(cfg_trunk_no_allow_transcoding,
1328 cfg_trunk_no_allow_transcoding_cmd,
1329 "no allow-transcoding", NO_STR "Allow transcoding\n")
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001330{
Philipp Maier4c4d2272023-04-26 15:45:17 +02001331 vty_out(vty, "%% Deprecated 'no allow-transcoding' config no longer has any effect%s", VTY_NEWLINE);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001332 return CMD_SUCCESS;
1333}
1334
Philipp Maier889fe7f2020-07-06 17:44:12 +02001335#define LINE_STR "Configure trunk for given Line\nE1/T1 Line Number\n"
1336
1337DEFUN(cfg_trunk_line,
1338 cfg_trunk_line_cmd,
1339 "line <0-255>",
1340 LINE_STR)
1341{
1342 struct mgcp_trunk *trunk = vty->index;
1343 int line_nr = atoi(argv[0]);
1344 trunk->e1.vty_line_nr = line_nr;
1345 return CMD_SUCCESS;
1346}
1347
Philipp Maier87bd9be2017-08-22 16:35:41 +02001348DEFUN(loop_conn,
1349 loop_conn_cmd,
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001350 "loop-endpoint <0-64> NAME (0|1)",
1351 "Loop a given endpoint\n" "Trunk number\n"
Philipp Maier87bd9be2017-08-22 16:35:41 +02001352 "The name in hex of the endpoint\n" "Disable the loop\n"
1353 "Enable the loop\n")
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001354{
Philipp Maier14b27a82020-06-02 20:15:30 +02001355 struct mgcp_trunk *trunk;
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001356 struct mgcp_endpoint *endp;
Philipp Maier87bd9be2017-08-22 16:35:41 +02001357 struct mgcp_conn *conn;
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001358
Philipp Maier6fbbeec2020-07-01 23:00:54 +02001359 trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_E1, atoi(argv[0]));
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001360 if (!trunk) {
1361 vty_out(vty, "%%Trunk %d not found in the config.%s",
1362 atoi(argv[0]), VTY_NEWLINE);
1363 return CMD_WARNING;
1364 }
1365
1366 if (!trunk->endpoints) {
Philipp Maierd70eef62021-07-19 13:53:28 +02001367 vty_out(vty, "%%Trunk %u has no endpoints allocated.%s",
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001368 trunk->trunk_nr, VTY_NEWLINE);
1369 return CMD_WARNING;
1370 }
1371
1372 int endp_no = strtoul(argv[1], NULL, 16);
1373 if (endp_no < 1 || endp_no >= trunk->number_endpoints) {
1374 vty_out(vty, "Loopback number %s/%d is invalid.%s",
Philipp Maier87bd9be2017-08-22 16:35:41 +02001375 argv[1], endp_no, VTY_NEWLINE);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001376 return CMD_WARNING;
1377 }
1378
Philipp Maierc66ab2c2020-06-02 20:55:34 +02001379 endp = trunk->endpoints[endp_no];
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001380 int loop = atoi(argv[2]);
Philipp Maier87bd9be2017-08-22 16:35:41 +02001381 llist_for_each_entry(conn, &endp->conns, entry) {
1382 if (conn->type == MGCP_CONN_TYPE_RTP)
1383 /* Handle it like a MDCX, switch on SSRC patching if enabled */
1384 mgcp_rtp_end_config(endp, 1, &conn->u.rtp.end);
1385 else {
1386 /* FIXME: Introduce support for other connection (E1)
1387 * types when implementation is available */
1388 vty_out(vty, "%%Can't enable SSRC patching,"
1389 "connection %s is not an RTP connection.%s",
1390 mgcp_conn_dump(conn), VTY_NEWLINE);
1391 }
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001392
Philipp Maier87bd9be2017-08-22 16:35:41 +02001393 if (loop)
1394 conn->mode = MGCP_CONN_LOOPBACK;
1395 else
1396 conn->mode = conn->mode_orig;
1397 }
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001398
1399 return CMD_SUCCESS;
1400}
1401
Philipp Maier87bd9be2017-08-22 16:35:41 +02001402DEFUN(tap_rtp,
1403 tap_rtp_cmd,
Pau Espin Pedrola790f0c2020-08-31 13:29:11 +02001404 "tap-rtp <0-64> ENDPOINT CONN (in|out) " VTY_IPV46_CMD " <0-65534>",
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001405 "Forward data on endpoint to a different system\n" "Trunk number\n"
1406 "The endpoint in hex\n"
Philipp Maier87bd9be2017-08-22 16:35:41 +02001407 "The connection id in hex\n"
1408 "Forward incoming data\n"
1409 "Forward leaving data\n"
Pau Espin Pedrola790f0c2020-08-31 13:29:11 +02001410 "Destination IPv4 of the data\n"
1411 "Destination IPv6 of the data\n"
1412 "Destination port\n")
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001413{
1414 struct mgcp_rtp_tap *tap;
Philipp Maier14b27a82020-06-02 20:15:30 +02001415 struct mgcp_trunk *trunk;
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001416 struct mgcp_endpoint *endp;
Philipp Maier87bd9be2017-08-22 16:35:41 +02001417 struct mgcp_conn_rtp *conn;
Philipp Maier01d24a32017-11-21 17:26:09 +01001418 const char *conn_id = NULL;
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001419
Philipp Maier6fbbeec2020-07-01 23:00:54 +02001420 trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_E1, atoi(argv[0]));
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001421 if (!trunk) {
1422 vty_out(vty, "%%Trunk %d not found in the config.%s",
1423 atoi(argv[0]), VTY_NEWLINE);
1424 return CMD_WARNING;
1425 }
1426
1427 if (!trunk->endpoints) {
Philipp Maierd70eef62021-07-19 13:53:28 +02001428 vty_out(vty, "%%Trunk %u has no endpoints allocated.%s",
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001429 trunk->trunk_nr, VTY_NEWLINE);
1430 return CMD_WARNING;
1431 }
1432
1433 int endp_no = strtoul(argv[1], NULL, 16);
1434 if (endp_no < 1 || endp_no >= trunk->number_endpoints) {
1435 vty_out(vty, "Endpoint number %s/%d is invalid.%s",
Philipp Maier87bd9be2017-08-22 16:35:41 +02001436 argv[1], endp_no, VTY_NEWLINE);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001437 return CMD_WARNING;
1438 }
1439
Philipp Maierc66ab2c2020-06-02 20:55:34 +02001440 endp = trunk->endpoints[endp_no];
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001441
Philipp Maier01d24a32017-11-21 17:26:09 +01001442 conn_id = argv[2];
Philipp Maier87bd9be2017-08-22 16:35:41 +02001443 conn = mgcp_conn_get_rtp(endp, conn_id);
1444 if (!conn) {
Philipp Maier01d24a32017-11-21 17:26:09 +01001445 vty_out(vty, "Conn ID %s is invalid.%s",
1446 conn_id, VTY_NEWLINE);
Philipp Maier87bd9be2017-08-22 16:35:41 +02001447 return CMD_WARNING;
1448 }
1449
1450 if (strcmp(argv[3], "in") == 0)
1451 tap = &conn->tap_in;
1452 else if (strcmp(argv[3], "out") == 0)
1453 tap = &conn->tap_out;
1454 else {
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001455 vty_out(vty, "Unknown mode... tricked vty?%s", VTY_NEWLINE);
1456 return CMD_WARNING;
1457 }
1458
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001459 memset(&tap->forward, 0, sizeof(tap->forward));
Pau Espin Pedrola790f0c2020-08-31 13:29:11 +02001460
1461 tap->forward.u.sa.sa_family = osmo_ip_str_type(argv[4]);
1462 switch (tap->forward.u.sa.sa_family) {
1463 case AF_INET:
1464 if (inet_pton(AF_INET, argv[4], &tap->forward.u.sin.sin_addr) != 1)
1465 return CMD_WARNING;
1466 tap->forward.u.sin.sin_port = htons(atoi(argv[5]));
1467 break;
1468 case AF_INET6:
1469 if (inet_pton(AF_INET6, argv[4], &tap->forward.u.sin6.sin6_addr) != 1)
1470 return CMD_WARNING;
1471 tap->forward.u.sin6.sin6_port = htons(atoi(argv[5]));
1472 break;
1473 default:
1474 return CMD_WARNING;
1475 }
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001476 tap->enabled = 1;
1477 return CMD_SUCCESS;
1478}
1479
1480DEFUN(free_endp, free_endp_cmd,
1481 "free-endpoint <0-64> NUMBER",
Philipp Maier87bd9be2017-08-22 16:35:41 +02001482 "Free the given endpoint\n" "Trunk number\n" "Endpoint number in hex.\n")
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001483{
Philipp Maier14b27a82020-06-02 20:15:30 +02001484 struct mgcp_trunk *trunk;
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001485 struct mgcp_endpoint *endp;
1486
Philipp Maier6fbbeec2020-07-01 23:00:54 +02001487 trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_E1, atoi(argv[0]));
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001488 if (!trunk) {
1489 vty_out(vty, "%%Trunk %d not found in the config.%s",
1490 atoi(argv[0]), VTY_NEWLINE);
1491 return CMD_WARNING;
1492 }
1493
1494 if (!trunk->endpoints) {
Philipp Maierd70eef62021-07-19 13:53:28 +02001495 vty_out(vty, "%%Trunk %u has no endpoints allocated.%s",
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001496 trunk->trunk_nr, VTY_NEWLINE);
1497 return CMD_WARNING;
1498 }
1499
1500 int endp_no = strtoul(argv[1], NULL, 16);
1501 if (endp_no < 1 || endp_no >= trunk->number_endpoints) {
1502 vty_out(vty, "Endpoint number %s/%d is invalid.%s",
Philipp Maier87bd9be2017-08-22 16:35:41 +02001503 argv[1], endp_no, VTY_NEWLINE);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001504 return CMD_WARNING;
1505 }
1506
Philipp Maierc66ab2c2020-06-02 20:55:34 +02001507 endp = trunk->endpoints[endp_no];
Philipp Maier1355d7e2018-02-01 14:30:06 +01001508 mgcp_endp_release(endp);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001509 return CMD_SUCCESS;
1510}
1511
1512DEFUN(reset_endp, reset_endp_cmd,
1513 "reset-endpoint <0-64> NUMBER",
Philipp Maier87bd9be2017-08-22 16:35:41 +02001514 "Reset the given endpoint\n" "Trunk number\n" "Endpoint number in hex.\n")
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001515{
Philipp Maier14b27a82020-06-02 20:15:30 +02001516 struct mgcp_trunk *trunk;
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001517 struct mgcp_endpoint *endp;
1518 int endp_no, rc;
1519
Philipp Maier6fbbeec2020-07-01 23:00:54 +02001520 trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_E1, atoi(argv[0]));
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001521 if (!trunk) {
1522 vty_out(vty, "%%Trunk %d not found in the config.%s",
1523 atoi(argv[0]), VTY_NEWLINE);
1524 return CMD_WARNING;
1525 }
1526
1527 if (!trunk->endpoints) {
Philipp Maierd70eef62021-07-19 13:53:28 +02001528 vty_out(vty, "%%Trunk %u has no endpoints allocated.%s",
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001529 trunk->trunk_nr, VTY_NEWLINE);
1530 return CMD_WARNING;
1531 }
1532
1533 endp_no = strtoul(argv[1], NULL, 16);
1534 if (endp_no < 1 || endp_no >= trunk->number_endpoints) {
1535 vty_out(vty, "Endpoint number %s/%d is invalid.%s",
Philipp Maier87bd9be2017-08-22 16:35:41 +02001536 argv[1], endp_no, VTY_NEWLINE);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001537 return CMD_WARNING;
1538 }
1539
Philipp Maierc66ab2c2020-06-02 20:55:34 +02001540 endp = trunk->endpoints[endp_no];
1541 rc = mgcp_send_reset_ep(endp);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001542 if (rc < 0) {
1543 vty_out(vty, "Error %d sending reset.%s", rc, VTY_NEWLINE);
1544 return CMD_WARNING;
1545 }
1546 return CMD_SUCCESS;
1547}
1548
1549DEFUN(reset_all_endp, reset_all_endp_cmd,
Philipp Maier87bd9be2017-08-22 16:35:41 +02001550 "reset-all-endpoints", "Reset all endpoints\n")
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001551{
1552 int rc;
1553
1554 rc = mgcp_send_reset_all(g_cfg);
1555 if (rc < 0) {
1556 vty_out(vty, "Error %d during endpoint reset.%s",
1557 rc, VTY_NEWLINE);
1558 return CMD_WARNING;
1559 }
1560 return CMD_SUCCESS;
1561}
1562
1563#define OSMUX_STR "RTP multiplexing\n"
1564DEFUN(cfg_mgcp_osmux,
1565 cfg_mgcp_osmux_cmd,
1566 "osmux (on|off|only)",
Philipp Maier87bd9be2017-08-22 16:35:41 +02001567 OSMUX_STR "Enable OSMUX\n" "Disable OSMUX\n" "Only use OSMUX\n")
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001568{
Philipp Maier6fbbeec2020-07-01 23:00:54 +02001569 struct mgcp_trunk *trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_VIRTUAL, MGCP_VIRT_TRUNK_ID);
Philipp Maierd19de2e2020-06-03 13:55:33 +02001570 OSMO_ASSERT(trunk);
1571
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001572 if (strcmp(argv[0], "off") == 0) {
Pau Espin Pedrol36413c02022-10-12 17:58:17 +02001573 g_cfg->osmux.usage = OSMUX_USAGE_OFF;
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001574 return CMD_SUCCESS;
Pau Espin Pedrolb542b042019-04-23 13:09:32 +02001575 } else if (strcmp(argv[0], "on") == 0)
Pau Espin Pedrol36413c02022-10-12 17:58:17 +02001576 g_cfg->osmux.usage = OSMUX_USAGE_ON;
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001577 else if (strcmp(argv[0], "only") == 0)
Pau Espin Pedrol36413c02022-10-12 17:58:17 +02001578 g_cfg->osmux.usage = OSMUX_USAGE_ONLY;
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001579
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001580 return CMD_SUCCESS;
Pau Espin Pedrolb542b042019-04-23 13:09:32 +02001581
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001582}
1583
1584DEFUN(cfg_mgcp_osmux_ip,
1585 cfg_mgcp_osmux_ip_cmd,
Pau Espin Pedrol70c03f52022-10-04 16:49:41 +02001586 "osmux bind-ip " VTY_IPV4_CMD,
Pau Espin Pedrola790f0c2020-08-31 13:29:11 +02001587 OSMUX_STR IP_STR
Pau Espin Pedrol70c03f52022-10-04 16:49:41 +02001588 "IPv4 Address to bind to\n")
1589{
Pau Espin Pedrol36413c02022-10-12 17:58:17 +02001590 osmo_talloc_replace_string(g_cfg, &g_cfg->osmux.local_addr_v4, argv[0]);
Pau Espin Pedrol70c03f52022-10-04 16:49:41 +02001591 return CMD_SUCCESS;
1592}
1593
1594DEFUN(cfg_mgcp_osmux_ip_v6,
1595 cfg_mgcp_osmux_ip_v6_cmd,
1596 "osmux bind-ip-v6 " VTY_IPV6_CMD,
1597 OSMUX_STR IP_STR
Pau Espin Pedrola790f0c2020-08-31 13:29:11 +02001598 "IPv6 Address to bind to\n")
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001599{
Pau Espin Pedrol36413c02022-10-12 17:58:17 +02001600 osmo_talloc_replace_string(g_cfg, &g_cfg->osmux.local_addr_v6, argv[0]);
1601 return CMD_SUCCESS;
1602}
1603
1604DEFUN(cfg_mgcp_osmux_port,
1605 cfg_mgcp_osmux_port_cmd,
1606 "osmux port <1-65535>", OSMUX_STR "port\n" "UDP port\n")
1607{
1608 g_cfg->osmux.local_port = atoi(argv[0]);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001609 return CMD_SUCCESS;
1610}
1611
1612DEFUN(cfg_mgcp_osmux_batch_factor,
1613 cfg_mgcp_osmux_batch_factor_cmd,
1614 "osmux batch-factor <1-8>",
1615 OSMUX_STR "Batching factor\n" "Number of messages in the batch\n")
1616{
Pau Espin Pedrol36413c02022-10-12 17:58:17 +02001617 g_cfg->osmux.batch_factor = atoi(argv[0]);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001618 return CMD_SUCCESS;
1619}
1620
1621DEFUN(cfg_mgcp_osmux_batch_size,
1622 cfg_mgcp_osmux_batch_size_cmd,
1623 "osmux batch-size <1-65535>",
1624 OSMUX_STR "batch size\n" "Batch size in bytes\n")
1625{
Pau Espin Pedrol36413c02022-10-12 17:58:17 +02001626 g_cfg->osmux.batch_size = atoi(argv[0]);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001627 return CMD_SUCCESS;
1628}
1629
1630DEFUN(cfg_mgcp_osmux_dummy,
1631 cfg_mgcp_osmux_dummy_cmd,
1632 "osmux dummy (on|off)",
Philipp Maier87bd9be2017-08-22 16:35:41 +02001633 OSMUX_STR "Dummy padding\n" "Enable dummy padding\n"
1634 "Disable dummy padding\n")
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001635{
1636 if (strcmp(argv[0], "on") == 0)
Pau Espin Pedrol36413c02022-10-12 17:58:17 +02001637 g_cfg->osmux.dummy_padding = true;
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001638 else if (strcmp(argv[0], "off") == 0)
Pau Espin Pedrol36413c02022-10-12 17:58:17 +02001639 g_cfg->osmux.dummy_padding = false;
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001640
1641 return CMD_SUCCESS;
1642}
1643
Pau Espin Pedrol833281d2022-10-06 17:41:22 +02001644DEFUN(cfg_mgcp_osmux_peer_behind_nat,
1645 cfg_mgcp_osmux_peer_behind_nat_cmd,
1646 "osmux peer-behind-nat (on|off)",
1647 OSMUX_STR "Define whether peer is behind NAT\n"
1648 "Peer is behind NAT\n"
1649 "Peer is NOT behind NAT\n")
1650{
1651 if (strcmp(argv[0], "on") == 0)
Pau Espin Pedrol36413c02022-10-12 17:58:17 +02001652 g_cfg->osmux.peer_behind_nat = true;
Pau Espin Pedrol833281d2022-10-06 17:41:22 +02001653 else if (strcmp(argv[0], "off") == 0)
Pau Espin Pedrol36413c02022-10-12 17:58:17 +02001654 g_cfg->osmux.peer_behind_nat = false;
Pau Espin Pedrol833281d2022-10-06 17:41:22 +02001655
1656 return CMD_SUCCESS;
1657}
1658
Philipp Maier12943ea2018-01-17 15:40:25 +01001659DEFUN(cfg_mgcp_domain,
1660 cfg_mgcp_domain_cmd,
Neels Hofmeyr352eed02018-08-20 23:59:32 +02001661 "domain NAME",
1662 "Set the domain part expected in MGCP messages' endpoint names\n"
1663 "Qualified domain name expected in MGCP endpoint names, or '*' to accept any domain\n")
Philipp Maier12943ea2018-01-17 15:40:25 +01001664{
1665 osmo_strlcpy(g_cfg->domain, argv[0], sizeof(g_cfg->domain));
1666 return CMD_SUCCESS;
1667}
1668
Oliver Smithe36b7752019-01-22 16:31:36 +01001669DEFUN(cfg_mgcp_conn_timeout,
1670 cfg_mgcp_conn_timeout_cmd,
Oliver Smithd2ce4442019-06-26 09:56:44 +02001671 "conn-timeout <0-65534>",
1672 "Set a time after which inactive connections (CIs) are closed. Set to 0 to disable timeout. This can be used to"
1673 " work around interoperability problems causing connections to stay open forever, and slowly exhausting all"
Oliver Smith189f29e2019-06-26 12:08:20 +02001674 " available ports. Enable keep-alive packets in MGW clients when using this option together with LCLS (OsmoBSC,"
1675 " OsmoMSC: 'rtp keep-alive')!\n"
Oliver Smithe36b7752019-01-22 16:31:36 +01001676 "Timeout value (sec.)\n")
1677{
1678 g_cfg->conn_timeout = strtoul(argv[0], NULL, 10);
1679 return CMD_SUCCESS;
1680}
1681
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001682int mgcp_vty_init(void)
1683{
1684 install_element_ve(&show_mgcp_cmd);
Keithfe53edd2021-05-04 15:23:30 -05001685 install_element_ve(&show_mgcp_active_cmd);
Stefan Sperling12086582018-06-26 15:26:28 +02001686 install_element_ve(&show_mgcp_endpoint_cmd);
1687 install_element_ve(&show_mgcp_trunk_endpoint_cmd);
Philipp Maier87bd9be2017-08-22 16:35:41 +02001688 install_element(ENABLE_NODE, &loop_conn_cmd);
1689 install_element(ENABLE_NODE, &tap_rtp_cmd);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001690 install_element(ENABLE_NODE, &free_endp_cmd);
1691 install_element(ENABLE_NODE, &reset_endp_cmd);
1692 install_element(ENABLE_NODE, &reset_all_endp_cmd);
1693
1694 install_element(CONFIG_NODE, &cfg_mgcp_cmd);
1695 install_node(&mgcp_node, config_write_mgcp);
1696
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001697 install_element(MGCP_NODE, &cfg_mgcp_local_ip_cmd);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001698 install_element(MGCP_NODE, &cfg_mgcp_bind_ip_cmd);
1699 install_element(MGCP_NODE, &cfg_mgcp_bind_port_cmd);
1700 install_element(MGCP_NODE, &cfg_mgcp_bind_early_cmd);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001701 install_element(MGCP_NODE, &cfg_mgcp_rtp_net_range_cmd);
Philipp Maierf1889d82017-11-08 14:59:39 +01001702 install_element(MGCP_NODE, &cfg_mgcp_rtp_port_range_cmd);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001703 install_element(MGCP_NODE, &cfg_mgcp_rtp_net_bind_ip_cmd);
Philipp Maierf1889d82017-11-08 14:59:39 +01001704 install_element(MGCP_NODE, &cfg_mgcp_rtp_bind_ip_cmd);
Pau Espin Pedrol8a2a1b22020-09-02 20:46:24 +02001705 install_element(MGCP_NODE, &cfg_mgcp_rtp_bind_ip_v6_cmd);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001706 install_element(MGCP_NODE, &cfg_mgcp_rtp_no_net_bind_ip_cmd);
Philipp Maierf1889d82017-11-08 14:59:39 +01001707 install_element(MGCP_NODE, &cfg_mgcp_rtp_no_bind_ip_cmd);
Pau Espin Pedrol8a2a1b22020-09-02 20:46:24 +02001708 install_element(MGCP_NODE, &cfg_mgcp_rtp_no_bind_ip_v6_cmd);
Philipp Maier1cb1e382017-11-02 17:16:04 +01001709 install_element(MGCP_NODE, &cfg_mgcp_rtp_net_bind_ip_probing_cmd);
1710 install_element(MGCP_NODE, &cfg_mgcp_rtp_no_net_bind_ip_probing_cmd);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001711 install_element(MGCP_NODE, &cfg_mgcp_rtp_ip_dscp_cmd);
Harald Welte55a92292021-04-28 19:06:34 +02001712 install_element(MGCP_NODE, &cfg_mgcp_rtp_priority_cmd);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001713 install_element(MGCP_NODE, &cfg_mgcp_rtp_force_ptime_cmd);
1714 install_element(MGCP_NODE, &cfg_mgcp_no_rtp_force_ptime_cmd);
1715 install_element(MGCP_NODE, &cfg_mgcp_rtp_keepalive_cmd);
1716 install_element(MGCP_NODE, &cfg_mgcp_rtp_keepalive_once_cmd);
1717 install_element(MGCP_NODE, &cfg_mgcp_no_rtp_keepalive_cmd);
1718 install_element(MGCP_NODE, &cfg_mgcp_agent_addr_cmd);
1719 install_element(MGCP_NODE, &cfg_mgcp_agent_addr_cmd_old);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001720 install_element(MGCP_NODE, &cfg_mgcp_sdp_payload_number_cmd);
1721 install_element(MGCP_NODE, &cfg_mgcp_sdp_payload_name_cmd);
1722 install_element(MGCP_NODE, &cfg_mgcp_sdp_payload_number_cmd_old);
1723 install_element(MGCP_NODE, &cfg_mgcp_sdp_payload_name_cmd_old);
1724 install_element(MGCP_NODE, &cfg_mgcp_loop_cmd);
1725 install_element(MGCP_NODE, &cfg_mgcp_force_realloc_cmd);
Philipp Maier87bd9be2017-08-22 16:35:41 +02001726 install_element(MGCP_NODE, &cfg_mgcp_rtp_accept_all_cmd);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001727 install_element(MGCP_NODE, &cfg_mgcp_number_endp_cmd);
1728 install_element(MGCP_NODE, &cfg_mgcp_omit_rtcp_cmd);
1729 install_element(MGCP_NODE, &cfg_mgcp_no_omit_rtcp_cmd);
1730 install_element(MGCP_NODE, &cfg_mgcp_patch_rtp_ssrc_cmd);
1731 install_element(MGCP_NODE, &cfg_mgcp_no_patch_rtp_ssrc_cmd);
1732 install_element(MGCP_NODE, &cfg_mgcp_patch_rtp_ts_cmd);
1733 install_element(MGCP_NODE, &cfg_mgcp_no_patch_rtp_ts_cmd);
1734 install_element(MGCP_NODE, &cfg_mgcp_no_patch_rtp_cmd);
Philipp Maier9fc8a022019-02-20 12:26:52 +01001735 install_element(MGCP_NODE, &cfg_mgcp_patch_rtp_rfc5993hr_cmd);
1736 install_element(MGCP_NODE, &cfg_mgcp_no_patch_rtp_rfc5993hr_cmd);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001737 install_element(MGCP_NODE, &cfg_mgcp_sdp_fmtp_extra_cmd);
1738 install_element(MGCP_NODE, &cfg_mgcp_sdp_payload_send_ptime_cmd);
1739 install_element(MGCP_NODE, &cfg_mgcp_no_sdp_payload_send_ptime_cmd);
1740 install_element(MGCP_NODE, &cfg_mgcp_sdp_payload_send_name_cmd);
1741 install_element(MGCP_NODE, &cfg_mgcp_no_sdp_payload_send_name_cmd);
1742 install_element(MGCP_NODE, &cfg_mgcp_osmux_cmd);
1743 install_element(MGCP_NODE, &cfg_mgcp_osmux_ip_cmd);
Pau Espin Pedrol70c03f52022-10-04 16:49:41 +02001744 install_element(MGCP_NODE, &cfg_mgcp_osmux_ip_v6_cmd);
Pau Espin Pedrol36413c02022-10-12 17:58:17 +02001745 install_element(MGCP_NODE, &cfg_mgcp_osmux_port_cmd);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001746 install_element(MGCP_NODE, &cfg_mgcp_osmux_batch_factor_cmd);
1747 install_element(MGCP_NODE, &cfg_mgcp_osmux_batch_size_cmd);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001748 install_element(MGCP_NODE, &cfg_mgcp_osmux_dummy_cmd);
Pau Espin Pedrol833281d2022-10-06 17:41:22 +02001749 install_element(MGCP_NODE, &cfg_mgcp_osmux_peer_behind_nat_cmd);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001750 install_element(MGCP_NODE, &cfg_mgcp_allow_transcoding_cmd);
1751 install_element(MGCP_NODE, &cfg_mgcp_no_allow_transcoding_cmd);
Philipp Maier12943ea2018-01-17 15:40:25 +01001752 install_element(MGCP_NODE, &cfg_mgcp_domain_cmd);
Oliver Smithe36b7752019-01-22 16:31:36 +01001753 install_element(MGCP_NODE, &cfg_mgcp_conn_timeout_cmd);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001754
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001755 install_element(MGCP_NODE, &cfg_mgcp_trunk_cmd);
1756 install_node(&trunk_node, config_write_trunk);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001757 install_element(TRUNK_NODE, &cfg_trunk_rtp_keepalive_cmd);
1758 install_element(TRUNK_NODE, &cfg_trunk_rtp_keepalive_once_cmd);
1759 install_element(TRUNK_NODE, &cfg_trunk_no_rtp_keepalive_cmd);
1760 install_element(TRUNK_NODE, &cfg_trunk_payload_number_cmd);
1761 install_element(TRUNK_NODE, &cfg_trunk_payload_name_cmd);
1762 install_element(TRUNK_NODE, &cfg_trunk_payload_number_cmd_old);
1763 install_element(TRUNK_NODE, &cfg_trunk_payload_name_cmd_old);
1764 install_element(TRUNK_NODE, &cfg_trunk_loop_cmd);
Philipp Maier41425e92020-11-26 00:41:59 +01001765 install_element(TRUNK_NODE, &cfg_trunk_force_realloc_cmd);
1766 install_element(TRUNK_NODE, &cfg_trunk_rtp_accept_all_cmd);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001767 install_element(TRUNK_NODE, &cfg_trunk_omit_rtcp_cmd);
1768 install_element(TRUNK_NODE, &cfg_trunk_no_omit_rtcp_cmd);
1769 install_element(TRUNK_NODE, &cfg_trunk_patch_rtp_ssrc_cmd);
1770 install_element(TRUNK_NODE, &cfg_trunk_no_patch_rtp_ssrc_cmd);
1771 install_element(TRUNK_NODE, &cfg_trunk_patch_rtp_ts_cmd);
Philipp Maier9fc8a022019-02-20 12:26:52 +01001772 install_element(TRUNK_NODE, &cfg_trunk_patch_rtp_rfc5993hr_cmd);
1773 install_element(TRUNK_NODE, &cfg_trunk_no_patch_rtp_rfc5993hr_cmd);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001774 install_element(TRUNK_NODE, &cfg_trunk_no_patch_rtp_ts_cmd);
1775 install_element(TRUNK_NODE, &cfg_trunk_no_patch_rtp_cmd);
1776 install_element(TRUNK_NODE, &cfg_trunk_sdp_fmtp_extra_cmd);
1777 install_element(TRUNK_NODE, &cfg_trunk_sdp_payload_send_ptime_cmd);
1778 install_element(TRUNK_NODE, &cfg_trunk_no_sdp_payload_send_ptime_cmd);
1779 install_element(TRUNK_NODE, &cfg_trunk_sdp_payload_send_name_cmd);
1780 install_element(TRUNK_NODE, &cfg_trunk_no_sdp_payload_send_name_cmd);
1781 install_element(TRUNK_NODE, &cfg_trunk_allow_transcoding_cmd);
1782 install_element(TRUNK_NODE, &cfg_trunk_no_allow_transcoding_cmd);
Philipp Maier889fe7f2020-07-06 17:44:12 +02001783 install_element(TRUNK_NODE, &cfg_trunk_line_cmd);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001784
1785 return 0;
1786}
1787
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001788int mgcp_parse_config(const char *config_file, struct mgcp_config *cfg,
1789 enum mgcp_role role)
1790{
1791 int rc;
Philipp Maier14b27a82020-06-02 20:15:30 +02001792 struct mgcp_trunk *trunk;
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001793
Pau Espin Pedrol36413c02022-10-12 17:58:17 +02001794 cfg->osmux.local_port = OSMUX_DEFAULT_PORT;
1795 cfg->osmux.batch_factor = 4;
1796 cfg->osmux.batch_size = OSMUX_BATCH_DEFAULT_MAX;
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001797
1798 g_cfg = cfg;
1799 rc = vty_read_config_file(config_file, NULL);
1800 if (rc < 0) {
Philipp Maier87bd9be2017-08-22 16:35:41 +02001801 fprintf(stderr, "Failed to parse the config file: '%s'\n",
1802 config_file);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001803 return rc;
1804 }
1805
Eric2764bdb2021-08-23 22:11:47 +02001806 if (!strlen(g_cfg->source_addr)) {
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001807 fprintf(stderr, "You need to specify a bind address.\n");
1808 return -1;
1809 }
1810
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001811 llist_for_each_entry(trunk, &g_cfg->trunks, entry) {
Philipp Maier889fe7f2020-07-06 17:44:12 +02001812 if (mgcp_trunk_equip(trunk) != 0) {
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001813 LOGP(DLMGCP, LOGL_ERROR,
Philipp Maierd70eef62021-07-19 13:53:28 +02001814 "Failed to initialize trunk %u (%d endpoints)\n",
Philipp Maier48454982017-11-10 16:46:41 +01001815 trunk->trunk_nr, trunk->number_endpoints);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02001816 return -1;
1817 }
1818 }
1819 cfg->role = role;
1820
1821 return 0;
1822}