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